Package org.apache.oodt.profile

Examples of org.apache.oodt.profile.Profile


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


      String id = handler.getID();                                   // Get the ID, and if targeting to IDs
      if (!ids.isEmpty() && !ids.contains(id)) continue;             // ... and it's not one we want, skip it.
      List results = handler.findProfiles(query);                    // Have it find profiles
      if (results == null) results = Collections.EMPTY_LIST;         // Assume nothing
      for (Iterator j = results.iterator(); j.hasNext();) {          // For each matching profile
        Profile profile = (Profile) j.next();                 // Get the profile
        if (transformer == null) {                   // No transformer/doc yet?
          transformer = createTransformer();             // Then make the transformer
          doc = Profile.createProfileDocument();         // And the doc
        }                         // And use the doc ...
        Node profileNode = profile.toXML(doc);                 // To render the profile into XML
        DOMSource source = new DOMSource(profileNode);         // And the XML becomes is source
        StreamResult result = new StreamResult(res.getWriter()); // And the response is a result
        transformer.transform(source, result);                 // And serialize into glorious text
        sentAtLeastOne = true;               // OK, we got at least one out the doo
      }
View Full Code Here

    for (DapRoot root : roots) {
      DatasetExtractor d = new DatasetExtractor(xmlQuery, root.getCatalogUrl()
          .toExternalForm(), root.getDatasetUrl().toExternalForm());
      if (d.getDapUrls() != null) {
        for (String opendapUrl : d.getDapUrls()) {
          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());
          }

          Metadata datasetMet = d.getDatasetMet(opendapUrl);
          profile.setResourceAttributes(ProfileUtils.getResourceAttributes(
              this.conf, opendapUrl, dConn, datasetMet));
          profile.setProfileAttributes(ProfileUtils
              .getProfileAttributes(this.conf, datasetMet));
          profile.getProfileElements().putAll(
              ProfileUtils.getProfileElements(this.conf, dConn, datasetMet, profile));
          profiles.add(profile);
        }
      }
    }
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: ["
            + 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));
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.