Package org.apache.oodt.profile

Examples of org.apache.oodt.profile.EnumeratedProfileElement


    // 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


    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

    }
   
    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

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

  }

  public EnumeratedProfileElement extractEnumeratedProfileElement(String elemName, String varname,
      Profile profile, DAS das)
      throws NoSuchAttributeException {
    EnumeratedProfileElement elem = new EnumeratedProfileElement(profile);
    elem.setName(elemName);

    AttributeTable attTable = null;
    try {
      attTable = das.getAttributeTable(elemName);
    } catch (NoSuchAttributeException e) {
      LOG.log(Level.WARNING, "Error extracting attribute table for element: ["
          + elemName + "]: Message: " + e.getMessage());
      throw e;

    }

    Enumeration attributeNames = attTable.getNames();
    while (attributeNames.hasMoreElements()) {
      String attrName = (String) attributeNames.nextElement();
      Attribute attr = attTable.getAttribute(attrName);
      Enumeration attrValues = null;
      try {
        attrValues = attr.getValues();
      } catch (NoSuchAttributeException e) {
        LOG.log(Level.WARNING, "Attempt to resolve attribute: [" + attrName
            + "] failed: Message: " + e.getMessage());
        continue;
      }

      while (attrValues.hasMoreElements()) {
        String attrValue = (String) attrValues.nextElement();
        if (attrName.equals(ACTUAL_RANGE)) {
          String[] vals = attrValue.split(" ");
          elem.getValues().addAll(Arrays.asList(vals));
        } else if (attrName.equals(UNITS)) {
          elem.setUnit(attrValue);
        } else {
          elem.getValues().add(attrValue);
        }
      }

    }
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

  }

  public EnumeratedProfileElement extractEnumeratedProfileElement(String elemName, String varname,
      Profile profile, DAS das)
      throws NoSuchAttributeException {
    EnumeratedProfileElement elem = new EnumeratedProfileElement(profile);
    elem.setName(elemName);

    AttributeTable attTable = null;
    try {
      attTable = das.getAttributeTable(elemName);
    } catch (NoSuchAttributeException e) {
      LOG.log(Level.WARNING, "Error extracting attribute table for element: ["
          + elemName + "]: Message: " + e.getMessage());
      throw e;

    }

    Enumeration attributeNames = attTable.getNames();
    while (attributeNames.hasMoreElements()) {
      String attrName = (String) attributeNames.nextElement();
      Attribute attr = attTable.getAttribute(attrName);
      Enumeration attrValues = null;
      try {
        attrValues = attr.getValues();
      } catch (NoSuchAttributeException e) {
        LOG.log(Level.WARNING, "Attempt to resolve attribute: [" + attrName
            + "] failed: Message: " + e.getMessage());
        continue;
      }

      while (attrValues.hasMoreElements()) {
        String attrValue = (String) attrValues.nextElement();
        if (attrName.equals(ACTUAL_RANGE)) {
          String[] vals = attrValue.split(" ");
          elem.getValues().addAll(Arrays.asList(vals));
        } else if (attrName.equals(UNITS)) {
          elem.setUnit(attrValue);
        } else {
          elem.getValues().add(attrValue);
        }
      }

    }
View Full Code Here

    }

    if (datasetMet != null) {
      for (DatasetMetElem datasetSpec : conf.getDatasetMetSpecs()) {
        EnumeratedProfileElement epe = getEnumeratedProfileElement(datasetSpec
            .getProfileElementName(), profile);
        List<String> epeVals = datasetMet
            .getAllMetadata(datasetSpec.getValue());
        if (epeVals != null && epeVals.size() > 0)
          epe.getValues().addAll(epeVals);
        profElements.put(datasetSpec.getProfileElementName(), epe);
      }
    }
   
    // now add const prof elems
    for (ConstantSpec spec : conf.getConstSpecs()) {
      if (spec.getType().equals(PROF_ELEM_SPEC_TYPE)) {
        try {
          EnumeratedProfileElement epe = getEnumeratedProfileElement(spec.getName(), profile)
          String replaceVal = PathUtils.replaceEnvVariables(spec.getValue(), datasetMet);
          List<String> epeVals = Arrays.asList(replaceVal.split(PathUtils.DELIMITER));
          if (epeVals != null && epeVals.size() > 0)
            epe.getValues().addAll(epeVals);
          profElements.put(spec.getName(), epe);
        } catch (Exception e) {
          e.printStackTrace();
          LOG.log(Level.WARNING, "Error setting field: [" + spec.getName()
              + "] in resource attributes: Message: " + e.getMessage());
View Full Code Here

    }
  }

  private static EnumeratedProfileElement getEnumeratedProfileElement(
      String name, Profile profile) {
    EnumeratedProfileElement pe = new EnumeratedProfileElement(profile);
    pe.setName(name);
    return pe;
  }
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: ["
            + 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.EnumeratedProfileElement

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.