/** * INTERNAL: * Retrieve the target object's primary key value that is mapped to a given * source xpath (in the source-target key field association list). * * @param targetObject - the reference class instance that holds the required pk value * @param xmlFld * @param session * @return null if the target object is null, the reference class is null, or * a primary key field name does not exist on the reference descriptor that * matches the target field name - otherwise, return the associated primary * key value */ public Object buildFieldValue(Object targetObject, XMLField xmlFld, AbstractSession session) { if (targetObject == null || getReferenceClass() == null) { return null; } ClassDescriptor descriptor = getReferenceDescriptor(); ObjectBuilder objectBuilder = descriptor.getObjectBuilder(); Vector pks = objectBuilder.extractPrimaryKeyFromObject(targetObject, session); XMLField tgtXMLField = (XMLField) getSourceToTargetKeyFieldAssociations().get(xmlFld); int idx = descriptor.getPrimaryKeyFields().indexOf(tgtXMLField); if (idx == -1) { return null; } return pks.get(idx); }
XMLField tgtXMLField = (XMLField) getSourceToTargetKeyFieldAssociations().get(xmlFld); int idx = 0; if(!(null == referenceClass || ClassConstants.OBJECT == referenceClass)) {
XMLField tgtXMLField = (XMLField) getSourceToTargetKeyFieldAssociations().get(xmlFld); int idx = 0; if(!(null == referenceClass || ClassConstants.OBJECT == referenceClass)) {
XMLField tgtFld = (XMLField) getSourceToTargetKeyFieldAssociations().get(fld); Object fieldValue = databaseRow.getValues(fld); if ((fieldValue == null) || (fieldValue instanceof String) || !(fieldValue instanceof Vector)) {
XMLField tgtFld = (XMLField) getSourceToTargetKeyFieldAssociations().get(xmlField); String tgtXPath = tgtFld.getXPath(); HashMap primaryKeyMap = reference.getPrimaryKeyMap();
XMLField tgtFld = (XMLField) getSourceToTargetKeyFieldAssociations().get(xmlField); String tgtXPath = tgtFld.getXPath(); HashMap primaryKeyMap = reference.getPrimaryKeyMap();
XMLField tgtFld = (XMLField) getSourceToTargetKeyFieldAssociations().get(xmlField); String tgtXPath = tgtFld.getQualifiedName(); HashMap primaryKeyMap = reference.getPrimaryKeyMap();
@Override public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object value, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) { Object fieldValue = xmlCollectionReferenceMapping.buildFieldValue(value, xmlField, session); if (fieldValue == null) { if(null != value) { XMLField f2 = (XMLField) xmlCollectionReferenceMapping.getSourceToTargetKeyFieldAssociations().get(xmlField); fieldValue = marshalRecord.getMarshaller().getXMLContext().getValueByXPath(value, f2.getXPath(), f2.getNamespaceResolver(), Object.class); } if(null == fieldValue) { return false; } } QName schemaType = getSchemaType(xmlField, fieldValue, session); String stringValue = getValueToWrite(schemaType, fieldValue, (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(), namespaceResolver); if (stringValue != null) { if (xPathFragment.isAttribute()) { marshalRecord.attribute(xPathFragment, namespaceResolver, stringValue); marshalRecord.closeStartElement(); } else { marshalRecord.closeStartElement(); marshalRecord.characters(stringValue); } return true; } return false; }
if (fieldValue == null) { if(null != objectValue) { XMLField fkField = (XMLField) xmlCollectionReferenceMapping.getSourceToTargetKeyFieldAssociations().get(xmlField); fieldValue = marshalRecord.getMarshaller().getXMLContext().getValueByXPath(objectValue, fkField.getXPath(), fkField.getNamespaceResolver(), Object.class);