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