Package org.apache.oodt.profile

Examples of org.apache.oodt.profile.ResourceAttributes


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


  }

  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));
    }

    return profile;
  }
View Full Code Here

  private static final Logger LOG = Logger.getLogger(ProfileUtils.class
      .getName());

  public static ResourceAttributes getResourceAttributes(OpendapConfig conf,
      String opendapUrl, DConnect dConn, Metadata datasetMet) {
    ResourceAttributes resAttr = new ResourceAttributes();
    for (ConstantSpec spec : conf.getConstSpecs()) {
      if (spec.getType().equals(RES_ATTR_SPEC_TYPE)) {
        try {         
                           
          // first process expanded '[@...]' instructions
View Full Code Here

  }

  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.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) {
      resAttr.getResLocations().add(
          PathUtils.replaceEnvVariables(resLocationSpec, met));
    }

    return profile;
  }
View Full Code Here

  private static final Logger LOG = Logger.getLogger(ProfileUtils.class
      .getName());

  public static ResourceAttributes getResourceAttributes(OpendapConfig conf,
      String opendapUrl, DConnect dConn, Metadata datasetMet) {
    ResourceAttributes resAttr = new ResourceAttributes();
    for (ConstantSpec spec : conf.getConstSpecs()) {
      if (spec.getType().equals(RES_ATTR_SPEC_TYPE)) {
        try {
          setResourceAttributes(resAttr, spec.getName(), PathUtils
              .replaceEnvVariables(spec.getValue(), datasetMet, true));
        } catch (Exception e) {
          e.printStackTrace();
          LOG.log(Level.WARNING, "Error setting field: [" + spec.getName()
              + "] in resource attributes: Message: " + e.getMessage());
        }
      }
    }

    // set the identifier
    if (resAttr.getIdentifier() == null
        || (resAttr.getIdentifier() != null && (resAttr.getIdentifier().equals(
            "") || resAttr.getIdentifier().equals("UNKNOWN")))) {
      resAttr.setIdentifier(UUID.randomUUID().toString());
    }

    // set res location
    if (resAttr.getResLocations() == null
        || (resAttr.getResLocations() != null && resAttr.getResLocations()
            .size() == 0)) {
      resAttr.getResLocations().add(opendapUrl);
    }

    return resAttr;
  }
View Full Code Here

  }

  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: ["
            + 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) {
      resAttr.getResLocations().add(
          PathUtils.replaceEnvVariables(resLocationSpec, met));
    }

    return profile;
  }
View Full Code Here

TOP

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

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.