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);