throw new DataSourceException(msg);
}
} else {
expectedInstanceOf = null;
}
AttributeMapping attMapping;
String sourceElement = attDto.getLinkElement();
if (sourceElement != null) {
// nested complex attributes, this could be a function expression for polymorphic
// types
Expression elementExpr = parseOgcCqlExpression(sourceElement);
String sourceField = attDto.getLinkField();
StepList sourceFieldSteps = null;
if (sourceField != null) {
// it could be null for polymorphism mapping,
// i.e. when the linked element maps to the same table as the container mapping
sourceFieldSteps = XPath.steps(root, sourceField, namespaces);
}
// a nested feature
if (isJoining() && isJDBC) {
attMapping = new JoiningNestedAttributeMapping(idExpression, sourceExpression,
targetXPathSteps, isMultiValued, clientProperties, elementExpr,
sourceFieldSteps, namespaces);
} else {
attMapping = new NestedAttributeMapping(idExpression, sourceExpression,
targetXPathSteps, isMultiValued, clientProperties, elementExpr,
sourceFieldSteps, namespaces);
}
} else {
attMapping = new AttributeMapping(idExpression, sourceExpression, attDto.getSourceIndex(), targetXPathSteps,
expectedInstanceOf, isMultiValued, clientProperties);
}
if (attDto.isList()) {
attMapping.setList(true);
}
if (attDto.encodeIfEmpty()) {
attMapping.setEncodeIfEmpty(true);
}
/**
* Label and parent label are specific for web service backend
*/
if (attDto.getLabel() != null) {
attMapping.setLabel(attDto.getLabel());
}
if (attDto.getParentLabel() != null) {
attMapping.setParentLabel(attDto.getParentLabel());
}
if (attDto.getInstancePath() != null) {
attMapping.setInstanceXpath(attDto.getInstancePath());
}
attMappings.add(attMapping);
}
return attMappings;