}
row.put(this.getField(), fieldValue);
}
public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, AbstractSession executionSession) throws DatabaseException {
ContainerPolicy cp = this.getContainerPolicy();
Object fieldValue = row.getValues(this.getField());
// BUG#2667762 there could be whitespace in the row instead of null
if ((fieldValue == null) || (fieldValue instanceof String)) {
return cp.containerInstance();
}
Vector nestedRows = this.getDescriptor().buildNestedRowsFromFieldValue(fieldValue, executionSession);
if (nestedRows == null) {
return cp.containerInstance();
}
Object result = cp.containerInstance(nestedRows.size());
for (Enumeration stream = nestedRows.elements(); stream.hasMoreElements();) {
AbstractRecord nestedRow = (AbstractRecord) stream.nextElement();
ClassDescriptor aDescriptor = getReferenceDescriptor((DOMRecord) nestedRow);
if (aDescriptor.hasInheritance()) {
Class newElementClass = aDescriptor.getInheritancePolicy().classFromRow(nestedRow, executionSession);
if (newElementClass == null) {
// no xsi:type attribute - look for type indicator on the field
QName leafElementType = ((XMLField) getField()).getLeafElementType();
if (leafElementType != null) {
Object indicator = aDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(leafElementType);
// if the inheritance policy does not contain the user-set type, throw an exception
if (indicator == null) {
throw DescriptorException.missingClassForIndicatorFieldValue(leafElementType, aDescriptor.getInheritancePolicy().getDescriptor());
}
newElementClass = (Class) indicator;
}
}
if (newElementClass != null) {
aDescriptor = this.getReferenceDescriptor(newElementClass, executionSession);
} else {
// since there is no xsi:type attribute or leaf element type set,
// use the reference descriptor - make sure it is non-abstract
if (Modifier.isAbstract(aDescriptor.getJavaClass().getModifiers())) {
// throw an exception
throw DescriptorException.missingClassIndicatorField(nestedRow, aDescriptor.getInheritancePolicy().getDescriptor());
}
}
}
Object element = buildCompositeObject(aDescriptor, nestedRow, sourceQuery, joinManager);
if (hasConverter()) {
if (getConverter() instanceof XMLConverter) {
element = ((XMLConverter) getConverter()).convertDataValueToObjectValue(element, executionSession, ((XMLRecord) nestedRow).getUnmarshaller());
} else {
element = getConverter().convertDataValueToObjectValue(element, executionSession);
}
}
cp.addInto(element, result, sourceQuery.getSession());
if(null != containerAccessor) {
containerAccessor.setAttributeValueInObject(element, ((DOMRecord)nestedRow).getOwningObject());
}
}
return result;