typeFieldMapping.setSetMethodName("setTypeField");
typeFieldMapping.setReferenceClass(DatabaseField.class);
typeFieldMapping.setXPath(getPrimaryNamespaceXPath() + "type-field");
descriptor.addMapping(typeFieldMapping);
XMLCompositeCollectionMapping foreignKeyFieldsMapping = new XMLCompositeCollectionMapping();
foreignKeyFieldsMapping.useCollectionClass(NonSynchronizedVector.class);
foreignKeyFieldsMapping.setAttributeName("foreignKeyFields");
foreignKeyFieldsMapping.setGetMethodName("getForeignKeyFields");
foreignKeyFieldsMapping.setSetMethodName("setForeignKeyFields");
foreignKeyFieldsMapping.setXPath(getPrimaryNamespaceXPath() + "foreign-key-fields/" + getPrimaryNamespaceXPath() + "field");
foreignKeyFieldsMapping.setReferenceClass(DatabaseField.class);
descriptor.addMapping(foreignKeyFieldsMapping);
XMLCompositeCollectionMapping sourceFieldToTargetQueryKeyMapping = new XMLCompositeCollectionMapping();
sourceFieldToTargetQueryKeyMapping.setAttributeName("sourceToTargetQueryKeyNames");
sourceFieldToTargetQueryKeyMapping.setXPath(getPrimaryNamespaceXPath() + "foreign-key-to-query-key/" + getPrimaryNamespaceXPath() + "query-key-reference");
sourceFieldToTargetQueryKeyMapping.setGetMethodName("getSourceToTargetQueryKeyFieldAssociations");
sourceFieldToTargetQueryKeyMapping.setSetMethodName("setSourceToTargetQueryKeyFieldAssociations");
// Handle translation of query key associations string to field.
sourceFieldToTargetQueryKeyMapping.setAttributeAccessor(new AttributeAccessor() {
public Object getAttributeValueFromObject(Object object) {
VariableOneToOneMapping mapping = (VariableOneToOneMapping)object;
Vector associations = mapping.getSourceToTargetQueryKeyFieldAssociations();
Vector queryKeyReferences = new Vector(associations.size());
for (int index = 0; index < associations.size(); index++) {
Association association = (Association)associations.get(index);
QueryKeyReference reference = new QueryKeyReference();
reference.setKey(new DatabaseField((String)association.getKey()));
reference.setValue(association.getValue());
queryKeyReferences.add(reference);
}
return queryKeyReferences;
}
public void setAttributeValueInObject(Object object, Object value) {
VariableOneToOneMapping mapping = (VariableOneToOneMapping)object;
Vector associations = (Vector)value;
for (int index = 0; index < associations.size(); index++) {
Association association = (Association)associations.get(index);
association.setKey(((DatabaseField)association.getKey()).getQualifiedName());
}
mapping.setSourceToTargetQueryKeyFieldAssociations(associations);
}
});
sourceFieldToTargetQueryKeyMapping.setReferenceClass(QueryKeyReference.class);
descriptor.addMapping(sourceFieldToTargetQueryKeyMapping);
XMLCompositeCollectionMapping classIndicatorsMapping = new XMLCompositeCollectionMapping();
classIndicatorsMapping.setAttributeName("classIndicatorAssociations");
classIndicatorsMapping.setGetMethodName("getClassIndicatorAssociations");
classIndicatorsMapping.setSetMethodName("setClassIndicatorAssociations");
classIndicatorsMapping.setXPath(getPrimaryNamespaceXPath() + "class-indicator-mappings/" + getPrimaryNamespaceXPath() + "class-indicator-mapping");
classIndicatorsMapping.setReferenceClass(TypedAssociation.class);
descriptor.addMapping(classIndicatorsMapping);
return descriptor;
}