LOG.log(Level.FINE, "Extracting Darray variable: "+varName);
} else if (variable instanceof DGrid) {
LOG.log(Level.FINE, "Extracting Dgrid variable: "+varName);
}
RewriteSpec spec = getProfileElementSpec(varName, conf);
if (spec!=null) {
// use configuration to set variable re-name and type
String peName = spec.getRename() != null && !spec.getRename().equals("") ? spec.getRename() : spec.getOrigName();
if (spec.getElementType().equals(RANGED_ELEMENT_TYPE)) {
profElements.put(peName, pe.extractRangedProfileElement(peName, spec.getOrigName(), profile, dConn.getDAS()));
} else if (spec.getElementType().equals(ENUM_ELEMENT_TYPE)) {
profElements.put(peName, pe.extractEnumeratedProfileElement(peName, spec.getOrigName(), profile, dConn.getDAS()));
}
} else {
// if not explicitly configured, assume variable if of RANGED_ELEMENT_TYPE
profElements.put(varName, pe.extractRangedProfileElement(varName, varName, profile, dConn.getDAS()));
}
}
} catch(Exception e) {
e.printStackTrace();
LOG.log(Level.WARNING, "Error extracting metadata from DDS ("+dConn.URL()+") :" +e.getMessage());
// rethrow the exception so that this dataset is not harvested
throw e;
}
// add profile elements from <datasetMetadata> specification
if (datasetMet != null) {
for (DatasetMetElem datasetSpec : conf.getDatasetMetSpecs()) {
// retrieve values from metadata container
List<String> values = datasetMet.getAllMetadata(datasetSpec.getValue());
addValuesToEnumeratedProfileElement(datasetSpec.getProfileElementName(), values, profile, profElements);
}
}
// add profile elements from <constants> specification
for (ConstantSpec spec : conf.getConstSpecs()) {
if (spec.getType().equals(PROF_ELEM_SPEC_TYPE)) {
// retrieve value from XML configuration file, replace with value from metadata container if required,
// split according to delimiter
String replaceVal = PathUtils.replaceEnvVariables(spec.getValue(), datasetMet);
List<String> values = Arrays.asList(replaceVal.split(PathUtils.DELIMITER));
addValuesToEnumeratedProfileElement(spec.getName(), values, profile, profElements);
}
}
return profElements;