use of org.openforis.idm.model.expression.ModelPathExpression in project collect by openforis.
the class SpeciesManager method extractQualifierValues.
protected String[] extractQualifierValues(TaxonAttribute attr) {
TaxonAttributeDefinition defn = attr.getDefinition();
List<String> qualifiers = defn.getQualifiers();
String[] qualifierValues = null;
if (qualifiers != null && !qualifiers.isEmpty()) {
qualifierValues = new String[qualifiers.size()];
Entity parent = attr.getParent();
for (int i = 0; i < qualifiers.size(); i++) {
String qualifierExpr = qualifiers.get(i);
try {
ModelPathExpression expression = expressionFactory.createModelPathExpression(qualifierExpr);
CodeAttribute code = (CodeAttribute) expression.evaluate(parent, null);
String qualifierValue = code.getValue().getCode();
qualifierValues[i] = qualifierValue;
} catch (Exception e) {
if (log.isWarnEnabled()) {
log.warn("Error evaluating taxon qualifiers: ", e);
}
break;
}
}
}
return qualifierValues;
}
Aggregations