Package org.apache.oodt.profile

Examples of org.apache.oodt.profile.Profile


   *         {@link Product}.
   */
  public static Profile buildProfile(Product p, Metadata met,
      String dataDelivBaseUrl) {

    Profile prof = new Profile();

    ProfileAttributes profAttrs = new ProfileAttributes();
    profAttrs.setID(PROF_ID_PRE + p.getProductId());
    profAttrs.setRegAuthority("CAS");
    profAttrs.setType(PROF_TYPE);

    prof.setProfileAttributes(profAttrs);

    ResourceAttributes resAttrs = new ResourceAttributes();
    resAttrs.setDescription(p.getProductType().getDescription());
    resAttrs.setIdentifier(p.getProductId());
    resAttrs.setResClass(p.getProductType().getName());
    resAttrs.setTitle(p.getProductName());
    resAttrs.getPublishers().add("CAS");
    resAttrs.getResLocations().add(
        dataDelivBaseUrl + "?productID=" + p.getProductId());

    prof.setResourceAttributes(resAttrs);

    // build up profile elements
    for(Iterator i = met.getHashtable().keySet().iterator(); i.hasNext(); ){
      String key = (String)i.next();
      List vals = met.getAllMetadata(key);
     
      EnumeratedProfileElement elem = new EnumeratedProfileElement(prof);
      System.out.println("Adding ["+key+"]=>"+vals);
      elem.setName(key);
      elem.getValues().addAll(vals);
      prof.getProfileElements().put(key, elem);
    }
   
   
    return prof;

View Full Code Here


      ResultSet rs = statement.executeQuery(sql);

      profiles = new Vector<Profile>();

      while (rs.next()) {
        Profile prof = toProfile(rs, map, resLocationSpec);
        profiles.add(prof);
      }

    } catch (SQLException e) {
      e.printStackTrace();
View Full Code Here

    return profiles;

  }

  private Profile toProfile(ResultSet rs, Mapping map, String resLocationSpec) {
    Profile profile = new Profile();
    ResourceAttributes resAttr = profile.getResourceAttributes();
    ProfileAttributes profAttr = profile.getProfileAttributes();
    resAttr.setResClass("system.profile");
    profAttr.setStatusID("active");
    profAttr.setType("profile");

    Metadata met = new Metadata();

    for (Iterator<String> i = map.getFieldNames().iterator(); i.hasNext();) {
      String fldName = i.next();
      MappingField fld = map.getFieldByName(fldName);
      ProfileElement elem = new EnumeratedProfileElement(profile);
      elem.setName(fld.getName());

      try {
        if (fld.getType().equals(FieldType.CONSTANT)) {
          elem.getValues().add(fld.getConstantValue());
        } else {
          String elemDbVal = rs.getString(fld.getDbName());
          for (Iterator<MappingFunc> j = fld.getFuncs().iterator(); j.hasNext();) {
            MappingFunc func = j.next();
            CDEValue origVal = new CDEValue(fld.getName(), elemDbVal);
            CDEValue newVal = func.inverseTranslate(origVal);
            elemDbVal = newVal.getVal();
          }

          elem.getValues().add(elemDbVal);
        }
      } catch (SQLException e) {
        e.printStackTrace();
        LOG.log(Level.WARNING, "Unable to obtain field: ["
            + map.getFieldLocalName(fld) + "] from result set: message: "
            + e.getMessage());
      }

      met.addMetadata(elem.getName(), (String) elem.getValues().get(0));

      profile.getProfileElements().put(fld.getName(), elem);
    }

    if (resLocationSpec != null) {
      resAttr.getResLocations().add(
          PathUtils.replaceEnvVariables(resLocationSpec, met));
View Full Code Here

  /** Auto-generated event handler method */
  protected void newFileMenuItemActionPerformed(ActionEvent evt){
    //TODO add your handler code here
   
      createdProfile = new Profile();
      jEditorPane1.setText(new ProfilePrinter(createdProfile,"http://oodt.jpl.nasa.gov/dtd/prof.dtd").toXMLString());
     
      getJTree1().setModel(generateModelFromProfile(createdProfile));
      //getJTree1().addMouseListener(new LeafListener(getJTree1()));
  }
View Full Code Here

 
 
 
  private Profile generateProfileFromModel(TreeModel dtm){
   
    Profile p = new Profile();
    DefaultMutableTreeNode theProfileRoot = (DefaultMutableTreeNode)dtm.getRoot();
   
    //get the profile attributes
    //children List
    //id String
    //parent String
    //regAuthority String
    //revisionNotes List
    //securityType String
    //statusID String
    //type String
    //version String
    TreeNode theProfAttrRoot = theProfileRoot.getChildAt(0);

    TreeNode theProfAttr_Children = theProfAttrRoot.getChildAt(0);
    addElementsFromTreeNode(theProfAttr_Children,p.getProfileAttributes().getChildren());

    TreeNode theProfAttr_IDRoot = theProfAttrRoot.getChildAt(1);
    DefaultMutableTreeNode theProfAttr_ID = (DefaultMutableTreeNode)theProfAttr_IDRoot.getChildAt(0);
    p.getProfileAttributes().setID((String)theProfAttr_ID.getUserObject());
   
    TreeNode theProfAttr_ParentRoot = theProfAttrRoot.getChildAt(2);
    DefaultMutableTreeNode theProfAttr_Parent = (DefaultMutableTreeNode)theProfAttr_ParentRoot.getChildAt(0);
    p.getProfileAttributes().setParent((String)theProfAttr_Parent.getUserObject());
   
   
    TreeNode theProfAttr_RegAuthorityRoot = theProfAttrRoot.getChildAt(3);
    DefaultMutableTreeNode theProfAttr_RegAuthority = (DefaultMutableTreeNode)theProfAttr_RegAuthorityRoot.getChildAt(0);
    p.getProfileAttributes().setRegAuthority((String)theProfAttr_RegAuthority.getUserObject());
   
    TreeNode theProfAttr_revNotes = theProfAttrRoot.getChildAt(4);
    addElementsFromTreeNode(theProfAttr_revNotes,p.getProfileAttributes().getRevisionNotes());

    TreeNode theProfAttr_SecurityTypeRoot = theProfAttrRoot.getChildAt(5);
    DefaultMutableTreeNode theProfAttr_SecurityType = (DefaultMutableTreeNode)theProfAttr_SecurityTypeRoot.getChildAt(0);
    p.getProfileAttributes().setSecurityType((String)theProfAttr_SecurityType.getUserObject());
   
    TreeNode theProfAttr_StatusIDRoot = theProfAttrRoot.getChildAt(6);
    DefaultMutableTreeNode theProfAttr_StatusID = (DefaultMutableTreeNode)theProfAttr_StatusIDRoot.getChildAt(0);
    p.getProfileAttributes().setStatusID((String)theProfAttr_StatusID.getUserObject());
   
    TreeNode theProfAttr_TypeRoot = theProfAttrRoot.getChildAt(7);
    DefaultMutableTreeNode theProfAttr_Type = (DefaultMutableTreeNode)theProfAttr_TypeRoot.getChildAt(0);
    p.getProfileAttributes().setType((String)theProfAttr_Type.getUserObject());
   
    TreeNode theProfAttr_VersionRoot = theProfAttrRoot.getChildAt(8);
    DefaultMutableTreeNode theProfAttr_Version = (DefaultMutableTreeNode)theProfAttr_VersionRoot.getChildAt(0);
    p.getProfileAttributes().setVersion((String)theProfAttr_Version.getUserObject());
       

    //resource attributes
    //aggregation - string
    //class - string
    //contexts - list
    //contributors - list
    //coverages - list
    //creators - list
    //dates - list
    //description - string
    //formats - list
    //identifier - string
    //languages - list
    //locations - list
    //publishers - list
    //relations - list
    //rights - list
    //sources - list
    //subjects - list
    //title - string
    //types - list
   
    TreeNode theResAttrRoot = theProfileRoot.getChildAt(1);
   
    TreeNode ra_aggRoot=theResAttrRoot.getChildAt(0);
    TreeNode ra_classRoot=theResAttrRoot.getChildAt(1);
    TreeNode ra_contextRoot=theResAttrRoot.getChildAt(2);
    TreeNode ra_contribRoot=theResAttrRoot.getChildAt(3);
    TreeNode ra_coverageRoot=theResAttrRoot.getChildAt(4);
    TreeNode ra_creatorRoot=theResAttrRoot.getChildAt(5);
    TreeNode ra_datesRoot=theResAttrRoot.getChildAt(6);
    TreeNode ra_descRoot=theResAttrRoot.getChildAt(7);
    TreeNode ra_formatsRoot=theResAttrRoot.getChildAt(8);
    TreeNode ra_identifierRoot=theResAttrRoot.getChildAt(9);
    TreeNode ra_langRoot=theResAttrRoot.getChildAt(10);
    TreeNode ra_locationRoot=theResAttrRoot.getChildAt(11);
    TreeNode ra_publishersRoot=theResAttrRoot.getChildAt(12);
    TreeNode ra_relationsRoot=theResAttrRoot.getChildAt(13);
    TreeNode ra_rightsRoot=theResAttrRoot.getChildAt(14);
    TreeNode ra_sourcesRoot=theResAttrRoot.getChildAt(15);
    TreeNode ra_subjectsRoot=theResAttrRoot.getChildAt(16);
    TreeNode ra_titleRoot=theResAttrRoot.getChildAt(17);
    TreeNode ra_typesRoot=theResAttrRoot.getChildAt(18);
   
    DefaultMutableTreeNode ra_agg = (DefaultMutableTreeNode)ra_aggRoot.getChildAt(0);
    DefaultMutableTreeNode ra_class = (DefaultMutableTreeNode)ra_classRoot.getChildAt(0);
   
   
    p.getResourceAttributes().setResAggregation((String)ra_agg.getUserObject());
    p.getResourceAttributes().setResClass((String)ra_class.getUserObject());
    addElementsFromTreeNode(ra_contextRoot,p.getResourceAttributes().getResContexts());
    addElementsFromTreeNode(ra_contribRoot,p.getResourceAttributes().getContributors());
    addElementsFromTreeNode(ra_coverageRoot,p.getResourceAttributes().getCoverages());
    addElementsFromTreeNode(ra_creatorRoot,p.getResourceAttributes().getCreators());
    addElementsFromTreeNode(ra_datesRoot,p.getResourceAttributes().getDates());
   
    DefaultMutableTreeNode ra_desc = (DefaultMutableTreeNode)ra_descRoot.getChildAt(0);
    DefaultMutableTreeNode ra_identifier = (DefaultMutableTreeNode)ra_identifierRoot.getChildAt(0);
   
    p.getResourceAttributes().setDescription((String)ra_desc.getUserObject());
    p.getResourceAttributes().setIdentifier((String)ra_identifier.getUserObject());
   
    addElementsFromTreeNode(ra_formatsRoot,p.getResourceAttributes().getFormats());
    addElementsFromTreeNode(ra_langRoot,p.getResourceAttributes().getLanguages());
    addElementsFromTreeNode(ra_locationRoot,p.getResourceAttributes().getResLocations());
    addElementsFromTreeNode(ra_publishersRoot,p.getResourceAttributes().getPublishers());
    addElementsFromTreeNode(ra_relationsRoot,p.getResourceAttributes().getRelations());
    addElementsFromTreeNode(ra_rightsRoot,p.getResourceAttributes().getRights());
    addElementsFromTreeNode(ra_sourcesRoot,p.getResourceAttributes().getSources());
    addElementsFromTreeNode(ra_subjectsRoot,p.getResourceAttributes().getSubjects());
    addElementsFromTreeNode(ra_typesRoot,p.getResourceAttributes().getTypes());
   
    DefaultMutableTreeNode ra_title = (DefaultMutableTreeNode)ra_titleRoot.getChildAt(0);
    p.getResourceAttributes().setTitle((String)ra_title.getUserObject());
   
    //handle profile elements here
    TreeNode theProfElemRoot = theProfileRoot.getChildAt(2);
   
    for(Enumeration e = theProfElemRoot.children(); e.hasMoreElements(); ){
      DefaultMutableTreeNode profElemN_Root = (DefaultMutableTreeNode)e.nextElement();
      System.out.println("Got Profile Element "+(String)profElemN_Root.getUserObject());
      ProfileElement profElem = makeProfileElementFromTreeNode(p,profElemN_Root);
     
      if(profElem != null){
        System.out.println("Making profile element");
        System.out.println(profElem.toString());
       
        p.getProfileElements().put((String)profElemN_Root.getUserObject(),profElem);
      }
     
     
    }
   
View Full Code Here

   * @param profID a {@link String} value.
   * @return a {@link Profile} value.
   */
  public Profile get(String profID) {
    if (profID == null) return null;
    Profile rc = null;
    for (Iterator i = profiles.iterator(); i.hasNext();) {
      Profile p = (Profile) i.next();
      if (p.getProfileAttributes().getID().equals(profID)) {
        rc = p;
        break;
      }
    }
    return rc;
View Full Code Here

    }
   
    public DefaultMutableTreeNode generateNewProfileElementTree(String peName){
       DefaultMutableTreeNode peRoot = null;
      
       ProfileElement theProfileElement = new EnumeratedProfileElement(new Profile());
         
       
        peRoot = new DefaultMutableTreeNode(peName);
        DefaultMutableTreeNode theCommentsRoot = new DefaultMutableTreeNode("Comments");
        DefaultMutableTreeNode theComments = new DefaultMutableTreeNode(theProfileElement.getComments());
View Full Code Here

        System.out.println(ioe.getMessage());       
      }
     
      System.out.println("Read in "+sb.toString());
      try{
        createdProfile = new Profile(sb.toString());       
        jEditorPane1.setText(new ProfilePrinter(createdProfile,"http://oodt.jpl.nasa.gov/dtd/prof.dtd").toXMLString());
     
      getJTree1().setModel(generateModelFromProfile(createdProfile));
      //getJTree1().addMouseListener(new LeafListener(getJTree1()));
      }catch(SAXException se){
View Full Code Here

          // wrap the profile generation in try-catch to avoid stopping the whole harvesting process in case an exception is thrown
          try {

            LOG.log(Level.FINE,"Connecting to opendapurl="+opendapUrl);
 
            Profile profile = new Profile();
            DConnect dConn = null;
            try {
              dConn = new DConnect(opendapUrl, true);
            } catch (FileNotFoundException e) {
              LOG.log(Level.WARNING, "Opendap URL not found: [" + opendapUrl
                  + "]: Message: " + e.getMessage());
              throw new ProfileException("Opendap URL not found: [" + opendapUrl
                  + "]: Message: " + e.getMessage());
            }

            // retrieve already extracted THREDDS metadata
            Metadata datasetMet = d.getDatasetMet(opendapUrl);
           
            // extract DAS metadata
            MetadataExtractor dasExtractor = new DasMetadataExtractor(dConn);
            dasExtractor.extract(datasetMet, conf);
           
            // extract NcML metadata, if available
           if (datasetMet.containsKey(ThreddsMetadataExtractor.SERVICE_TYPE_NCML)) {
              // retrieve URL of NcML document, previously stored
              final String ncmlUrl = datasetMet.getMetadata(ThreddsMetadataExtractor.SERVICE_TYPE_NCML);
              MetadataExtractor ncmlExtractor = new NcmlMetadataExtractor(ncmlUrl);
              ncmlExtractor.extract(datasetMet, conf);
            }
           
            // debug: write out all metadata entries
            for (String key : datasetMet.getAllKeys()) {
              LOG.log(Level.FINER, "Metadata key="+key+" value="+datasetMet.getMetadata(key));
            }
        
            // <resAttributes>
            profile.setResourceAttributes(ProfileUtils.getResourceAttributes(
                this.conf, opendapUrl, dConn, datasetMet));
           
            // <profAttributes>
            profile.setProfileAttributes(ProfileUtils
                .getProfileAttributes(this.conf, datasetMet));
            // <profElement>
            profile.getProfileElements().putAll(
                ProfileUtils.getProfileElements(this.conf, dConn, datasetMet, profile));
            profiles.add(profile);
            LOG.log(Level.FINE, "Added profile id="+profile.getProfileAttributes().getID());
           
           
          } catch(Exception e) {
            // in case of exception, don't harvest this dataset, but keep going
            LOG.log(Level.WARNING,"Error while building profile for opendapurl="+opendapUrl);
View Full Code Here

      ResultSet rs = statement.executeQuery(sql);

      profiles = new Vector<Profile>();

      while (rs.next()) {
        Profile prof = toProfile(rs, map, resLocationSpec);
        profiles.add(prof);
      }

    } catch (SQLException e) {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.apache.oodt.profile.Profile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.