Package org.apache.oodt.profile

Examples of org.apache.oodt.profile.ProfileElement


   
    for(Iterator i = myProfile.getProfileElements().keySet().iterator(); i.hasNext(); ){
      String profElemName = (String)i.next();
     
      ProfileElement pe = (ProfileElement)myProfile.getProfileElements().get(profElemName);
      ProfileElementPrinter pPrinter = new ProfileElementPrinter(pe);
      rStr+=pPrinter.toXMLString();
    }
   
    rStr+="</profile>\n";
View Full Code Here


    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) {
View Full Code Here

      assertEquals(1, profiles.size());
      SearchableProfile profile = (SearchableProfile) profiles.get(0);
      assertEquals("PROFILE1", profile.getProfileAttributes().getID());
      Map elements = profile.getProfileElements();
      assertEquals(3, elements.size());
      ProfileElement element = (ProfileElement) elements.get("TEST");
      assertNotNull(element);
      assertEquals("3.14159", element.getID());

      // Now a negative one.
      profiles = doSearch("NONEXISTENT = 452712917824812123125100884");
      assertEquals(0, profiles.size());
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());
       
        theCommentsRoot.add(theComments);
       
        DefaultMutableTreeNode theDesc = new DefaultMutableTreeNode(theProfileElement.getDescription());
        DefaultMutableTreeNode theDescRoot = new DefaultMutableTreeNode("Description");
       
        theDescRoot.add(theDesc);
       
       
       
        DefaultMutableTreeNode theID = new DefaultMutableTreeNode(theProfileElement.getID());
        DefaultMutableTreeNode theIDRoot = new DefaultMutableTreeNode("ID");
       
        theIDRoot.add(theID);
       
        DefaultMutableTreeNode theMO = new DefaultMutableTreeNode(new Integer(theProfileElement.getMaxOccurrence()).toString());
        DefaultMutableTreeNode theMORoot = new DefaultMutableTreeNode("Max Occurence");
        theMORoot.add(theMO);
       
        DefaultMutableTreeNode theSynonyms = new DefaultMutableTreeNode("Synonyms");
       
        for(Iterator i2 = theProfileElement.getSynonyms().iterator(); i2.hasNext(); ){
          String theSynonym = (String)i2.next();
          DefaultMutableTreeNode sNode = new DefaultMutableTreeNode(theSynonym);
          theSynonyms.add(sNode);
        }
 
        DefaultMutableTreeNode theType = new DefaultMutableTreeNode(theProfileElement.getType());
        DefaultMutableTreeNode theTypeRoot = new DefaultMutableTreeNode("Type");
        theTypeRoot.add(theType);
       
       
        DefaultMutableTreeNode theUnit = new DefaultMutableTreeNode(theProfileElement.getUnit());
        DefaultMutableTreeNode theUnitRoot = new DefaultMutableTreeNode("Unit");
        theUnitRoot.add(theUnit);
     
      peRoot.add(theCommentsRoot);
      peRoot.add(theDescRoot);
View Full Code 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

    return p;
  }
 
  private ProfileElement makeProfileElementFromTreeNode(Profile theProfile,DefaultMutableTreeNode tn){
   
    ProfileElement theProfileElement = new RangedProfileElement(theProfile);
   
    DefaultMutableTreeNode commentRoot = (DefaultMutableTreeNode)tn.getChildAt(0);
    DefaultMutableTreeNode descRoot = (DefaultMutableTreeNode)tn.getChildAt(1);
    DefaultMutableTreeNode idRoot = (DefaultMutableTreeNode)tn.getChildAt(2);
    DefaultMutableTreeNode moRoot = (DefaultMutableTreeNode)tn.getChildAt(3);
    DefaultMutableTreeNode synRoot = (DefaultMutableTreeNode)tn.getChildAt(4);
    DefaultMutableTreeNode typeRoot = (DefaultMutableTreeNode)tn.getChildAt(5);
    DefaultMutableTreeNode unitRoot = (DefaultMutableTreeNode)tn.getChildAt(6);
   
    DefaultMutableTreeNode pe_Comments = (DefaultMutableTreeNode)commentRoot.getChildAt(0);
    DefaultMutableTreeNode pe_desc = (DefaultMutableTreeNode)descRoot.getChildAt(0);
    DefaultMutableTreeNode pe_id = (DefaultMutableTreeNode)idRoot.getChildAt(0);
    DefaultMutableTreeNode pe_mo = (DefaultMutableTreeNode)moRoot.getChildAt(0);
    DefaultMutableTreeNode pe_type = (DefaultMutableTreeNode)typeRoot.getChildAt(0);
    DefaultMutableTreeNode pe_unit = (DefaultMutableTreeNode)unitRoot.getChildAt(0);
   
    addElementsFromTreeNode(synRoot,theProfileElement.getSynonyms());
   
    theProfileElement.setName((String)tn.getUserObject());
    theProfileElement.setComments((String)pe_Comments.getUserObject());
    theProfileElement.setDescription((String)pe_desc.getUserObject());
    theProfileElement.setID((String)pe_id.getUserObject());
    theProfileElement.setMaxOccurrence(Integer.parseInt((String)pe_mo.getUserObject()));
    theProfileElement.setType((String)pe_type.getUserObject());
    theProfileElement.setUnit((String)pe_unit.getUserObject());
   
    return theProfileElement;
   
    //return new RangedProfileElement(new Profile());
  }
View Full Code Here

    resAttrRoot.add(resAttr_types);

        for(Iterator i = p.getProfileElements().keySet().iterator(); i.hasNext(); ){
          String peKey = (String)i.next();
         
          ProfileElement theProfileElement = (ProfileElement)p.getProfileElements().get(peKey);
          DefaultMutableTreeNode thePENode = new DefaultMutableTreeNode(theProfileElement.getName());
          DefaultMutableTreeNode theCommentsRoot = new DefaultMutableTreeNode("Comments");
          DefaultMutableTreeNode theComments = new DefaultMutableTreeNode(theProfileElement.getComments());
         
          theCommentsRoot.add(theComments);
         
          DefaultMutableTreeNode theDesc = new DefaultMutableTreeNode(theProfileElement.getDescription());
          DefaultMutableTreeNode theDescRoot = new DefaultMutableTreeNode("Description");
         
          theDescRoot.add(theDesc);
         
         
         
          DefaultMutableTreeNode theID = new DefaultMutableTreeNode(theProfileElement.getID());
          DefaultMutableTreeNode theIDRoot = new DefaultMutableTreeNode("ID");
         
          theIDRoot.add(theID);
         
          DefaultMutableTreeNode theMO = new DefaultMutableTreeNode(new Integer(theProfileElement.getMaxOccurrence()).toString());
          DefaultMutableTreeNode theMORoot = new DefaultMutableTreeNode("Max Occurence");
          theMORoot.add(theMO);
         
          DefaultMutableTreeNode theSynonyms = new DefaultMutableTreeNode("Synonyms");
         
          for(Iterator i2 = theProfileElement.getSynonyms().iterator(); i2.hasNext(); ){
            String theSynonym = (String)i2.next();
            DefaultMutableTreeNode sNode = new DefaultMutableTreeNode(theSynonym);
            theSynonyms.add(sNode);
          }

          DefaultMutableTreeNode theType = new DefaultMutableTreeNode(theProfileElement.getType());
          DefaultMutableTreeNode theTypeRoot = new DefaultMutableTreeNode("Type");
          theTypeRoot.add(theType);
         
         
          DefaultMutableTreeNode theUnit = new DefaultMutableTreeNode(theProfileElement.getUnit());
          DefaultMutableTreeNode theUnitRoot = new DefaultMutableTreeNode("Unit");
          theUnitRoot.add(theUnit);
         
          thePENode.add(theCommentsRoot);
          thePENode.add(theDescRoot);
View Full Code Here

   * The supplied values are added only if valid.
   */
  private static void addValuesToEnumeratedProfileElement(final String name, final List<String> values, Profile profile, Map<String, ProfileElement> profElements) {
   
    // try retrieve existing profile element
    ProfileElement epe = profElements.get(name);
    // or create a new one if not found
    if (epe==null) {
       epe = new EnumeratedProfileElement(profile);
       epe.setName(name);
    }
    if (values!=null) {
      for (String value : values) {
        if (StringUtils.hasText(value) && !value.equalsIgnoreCase("null")) {
          epe.getValues().add(value);
        }
      }
    }
    // only save profile elements with one or more values
    if (epe.getValues().size()>0) profElements.put(name, epe);
   
  }
View Full Code Here

    sb.append("\n\tProfile Element '" + name + "' = ");
    // profile element is valid by default
    boolean ok = true;
 
    if (profile.getProfileElements().containsKey(name)) {
        ProfileElement profElement = (ProfileElement)profile.getProfileElements().get(name);
     
        // profile element found
        List<String> values = profElement.getValues();
        if (values.size()>0) {
          boolean first = true;
          for (String value : values) {
            if (!StringUtils.hasText(value) || value.equalsIgnoreCase("null")) {
              if (mandatory) ok = false; // invalid value for this profile element
View Full Code Here

    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.translate(origVal);
            elemDbVal = newVal.getVal();
          }

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

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

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

    if (resLocationSpec != null) {
View Full Code Here

TOP

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

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.