use of org.eclipse.persistence.mappings.Association in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildAggregateObjectMappingDescriptor.
protected ClassDescriptor buildAggregateObjectMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(AggregateObjectMapping.class);
descriptor.getInheritancePolicy().setParentClass(AggregateMapping.class);
XMLDirectMapping isNullAllowedMapping = new XMLDirectMapping();
isNullAllowedMapping.setAttributeName("isNullAllowed");
isNullAllowedMapping.setGetMethodName("isNullAllowed");
isNullAllowedMapping.setSetMethodName("setIsNullAllowed");
isNullAllowedMapping.setXPath(getPrimaryNamespaceXPath() + "allow-null/text()");
isNullAllowedMapping.setNullValue(Boolean.TRUE);
descriptor.addMapping(isNullAllowedMapping);
XMLCompositeCollectionMapping aggregateToSourceFieldNameAssociationsMapping = new XMLCompositeCollectionMapping();
aggregateToSourceFieldNameAssociationsMapping.setReferenceClass(FieldTranslation.class);
// Handle translation of fields associations string to field.
aggregateToSourceFieldNameAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
/*bug 322233: AttributeOverrides and AssociationOverride
* changed getAggregateToSourceFieldAssociations to hold String->DatabaseField associations
*/
AggregateObjectMapping mapping = (AggregateObjectMapping) object;
List<Association> associations = mapping.getAggregateToSourceFieldAssociations();
Vector<FieldTranslation> translations = new Vector<>(associations.size());
for (int index = 0; index < associations.size(); index++) {
Association association = associations.get(index);
FieldTranslation translation = new FieldTranslation();
translation.setKey(new DatabaseField((String) association.getKey()));
translation.setValue(association.getValue());
translations.add(translation);
}
return translations;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
AggregateObjectMapping mapping = (AggregateObjectMapping) object;
@SuppressWarnings({ "unchecked" }) Vector<Association> associations = (Vector<Association>) value;
for (int index = 0; index < associations.size(); index++) {
Association association = associations.get(index);
association.setKey(((DatabaseField) association.getKey()).getQualifiedName());
}
mapping.setAggregateToSourceFieldAssociations(associations);
}
});
aggregateToSourceFieldNameAssociationsMapping.setAttributeName("aggregateToSourceFieldNameAssociationsMapping");
aggregateToSourceFieldNameAssociationsMapping.setXPath(getPrimaryNamespaceXPath() + "field-translations/" + getPrimaryNamespaceXPath() + "field-translation");
descriptor.addMapping(aggregateToSourceFieldNameAssociationsMapping);
return descriptor;
}
use of org.eclipse.persistence.mappings.Association in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildVariableOneToOneMappingDescriptor.
protected ClassDescriptor buildVariableOneToOneMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(VariableOneToOneMapping.class);
descriptor.getInheritancePolicy().setParentClass(ObjectReferenceMapping.class);
XMLDirectMapping relationshipPartnerAttributeNameMapping = new XMLDirectMapping();
relationshipPartnerAttributeNameMapping.setAttributeName("relationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setGetMethodName("getRelationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setSetMethodName("setRelationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setXPath(getPrimaryNamespaceXPath() + "bidirectional-target-attribute/text()");
descriptor.addMapping(relationshipPartnerAttributeNameMapping);
XMLDirectMapping usesBatchReadingMapping = new XMLDirectMapping();
usesBatchReadingMapping.setAttributeName("usesBatchReading");
usesBatchReadingMapping.setGetMethodName("shouldUseBatchReading");
usesBatchReadingMapping.setSetMethodName("setUsesBatchReading");
usesBatchReadingMapping.setXPath(getPrimaryNamespaceXPath() + "batch-reading/text()");
usesBatchReadingMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(usesBatchReadingMapping);
XMLCompositeObjectMapping indirectionPolicyMapping = new XMLCompositeObjectMapping();
indirectionPolicyMapping.setReferenceClass(IndirectionPolicy.class);
// Handle translation of NoIndirectionPolicy -> null.
indirectionPolicyMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
IndirectionPolicy policy = ((ForeignReferenceMapping) object).getIndirectionPolicy();
if (policy instanceof NoIndirectionPolicy) {
return null;
}
return policy;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
IndirectionPolicy policy = (IndirectionPolicy) value;
if (value == null) {
policy = new NoIndirectionPolicy();
}
((ForeignReferenceMapping) object).setIndirectionPolicy(policy);
}
});
indirectionPolicyMapping.setAttributeName("indirectionPolicy");
indirectionPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "indirection");
descriptor.addMapping(indirectionPolicyMapping);
XMLCompositeObjectMapping selectionQueryMapping = new XMLCompositeObjectMapping();
selectionQueryMapping.setAttributeName("selectionQuery");
selectionQueryMapping.setGetMethodName("getSelectionQuery");
selectionQueryMapping.setSetMethodName("setSelectionQuery");
selectionQueryMapping.setReferenceClass(ReadQuery.class);
selectionQueryMapping.setXPath(getPrimaryNamespaceXPath() + "selection-query");
descriptor.addMapping(selectionQueryMapping);
XMLCompositeObjectMapping typeFieldMapping = new XMLCompositeObjectMapping();
typeFieldMapping.setAttributeName("typeField");
typeFieldMapping.setGetMethodName("getTypeField");
typeFieldMapping.setSetMethodName("setTypeField");
typeFieldMapping.setReferenceClass(DatabaseField.class);
typeFieldMapping.setXPath(getPrimaryNamespaceXPath() + "type-field");
((XMLField) typeFieldMapping.getField()).setLeafElementType(fieldQname);
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);
((XMLField) foreignKeyFieldsMapping.getField()).setLeafElementType(new QName(getSecondaryNamespace(), "field"));
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() {
@Override
public Object getAttributeValueFromObject(Object object) {
VariableOneToOneMapping mapping = (VariableOneToOneMapping) object;
List<Association> associations = mapping.getSourceToTargetQueryKeyFieldAssociations();
Vector<QueryKeyReference> queryKeyReferences = new Vector<>(associations.size());
for (int index = 0; index < associations.size(); index++) {
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;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
VariableOneToOneMapping mapping = (VariableOneToOneMapping) object;
@SuppressWarnings({ "unchecked" }) Vector<Association> associations = (Vector<Association>) value;
for (int index = 0; index < associations.size(); index++) {
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;
}
use of org.eclipse.persistence.mappings.Association in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildOneToManyMappingMappingDescriptor.
protected ClassDescriptor buildOneToManyMappingMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(OneToManyMapping.class);
descriptor.getInheritancePolicy().setParentClass(CollectionMapping.class);
XMLCompositeCollectionMapping sourceToTargetKeyFieldAssociationsMapping = new XMLCompositeCollectionMapping();
sourceToTargetKeyFieldAssociationsMapping.setReferenceClass(Association.class);
// Handle translation of foreign key associations to hashtables.
sourceToTargetKeyFieldAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
List<DatabaseField> sourceFields = ((OneToManyMapping) object).getSourceKeyFields();
List<DatabaseField> targetFields = ((OneToManyMapping) object).getTargetForeignKeyFields();
List<Association> associations = new ArrayList<>(sourceFields.size());
for (int index = 0; index < sourceFields.size(); index++) {
associations.add(new Association(targetFields.get(index), sourceFields.get(index)));
}
return associations;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
OneToManyMapping mapping = (OneToManyMapping) object;
@SuppressWarnings({ "unchecked" }) List<Association> associations = (List<Association>) value;
mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
mapping.setTargetForeignKeyFields(NonSynchronizedVector.newInstance(associations.size()));
Iterator<Association> iterator = associations.iterator();
while (iterator.hasNext()) {
Association association = iterator.next();
mapping.getSourceKeyFields().add((DatabaseField) association.getValue());
mapping.getTargetForeignKeyFields().add((DatabaseField) association.getKey());
}
}
});
sourceToTargetKeyFieldAssociationsMapping.setAttributeName("sourceToTargetKeyFieldAssociations");
sourceToTargetKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "target-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
descriptor.addMapping(sourceToTargetKeyFieldAssociationsMapping);
XMLDirectMapping relationshipPartnerAttributeNameMapping = new XMLDirectMapping();
relationshipPartnerAttributeNameMapping.setAttributeName("relationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setGetMethodName("getRelationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setSetMethodName("setRelationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setXPath(getPrimaryNamespaceXPath() + "bidirectional-target-attribute/text()");
descriptor.addMapping(relationshipPartnerAttributeNameMapping);
XMLDirectMapping usesBatchReadingMapping = new XMLDirectMapping();
usesBatchReadingMapping.setAttributeName("usesBatchReading");
usesBatchReadingMapping.setGetMethodName("shouldUseBatchReading");
usesBatchReadingMapping.setSetMethodName("setUsesBatchReading");
usesBatchReadingMapping.setXPath(getPrimaryNamespaceXPath() + "batch-reading/text()");
usesBatchReadingMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(usesBatchReadingMapping);
XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping();
containerPolicyMapping.setAttributeName("collectionPolicy");
containerPolicyMapping.setGetMethodName("getContainerPolicy");
containerPolicyMapping.setSetMethodName("setContainerPolicy");
containerPolicyMapping.setReferenceClass(ContainerPolicy.class);
containerPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "container");
descriptor.addMapping(containerPolicyMapping);
XMLCompositeObjectMapping indirectionPolicyMapping = new XMLCompositeObjectMapping();
indirectionPolicyMapping.setReferenceClass(IndirectionPolicy.class);
// Handle translation of NoIndirectionPolicy -> null.
indirectionPolicyMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
IndirectionPolicy policy = ((ForeignReferenceMapping) object).getIndirectionPolicy();
if (policy instanceof NoIndirectionPolicy) {
return null;
}
return policy;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
IndirectionPolicy policy = (IndirectionPolicy) value;
if (value == null) {
policy = new NoIndirectionPolicy();
}
((ForeignReferenceMapping) object).setIndirectionPolicy(policy);
}
});
indirectionPolicyMapping.setAttributeName("indirectionPolicy");
indirectionPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "indirection");
descriptor.addMapping(indirectionPolicyMapping);
XMLCompositeObjectMapping selectionQueryMapping = new XMLCompositeObjectMapping();
selectionQueryMapping.setAttributeName("selectionQuery");
selectionQueryMapping.setGetMethodName("getSelectionQuery");
selectionQueryMapping.setSetMethodName("setSelectionQuery");
selectionQueryMapping.setReferenceClass(ReadQuery.class);
selectionQueryMapping.setXPath(getPrimaryNamespaceXPath() + "selection-query");
descriptor.addMapping(selectionQueryMapping);
// delete-all query
return descriptor;
}
use of org.eclipse.persistence.mappings.Association in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildDirectCollectionMappingDescriptor.
protected ClassDescriptor buildDirectCollectionMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(DirectCollectionMapping.class);
descriptor.getInheritancePolicy().setParentClass(DatabaseMapping.class);
XMLDirectMapping usesBatchReadingMapping = new XMLDirectMapping();
usesBatchReadingMapping.setAttributeName("usesBatchReading");
usesBatchReadingMapping.setGetMethodName("shouldUseBatchReading");
usesBatchReadingMapping.setSetMethodName("setUsesBatchReading");
usesBatchReadingMapping.setXPath(getPrimaryNamespaceXPath() + "batch-reading/text()");
usesBatchReadingMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(usesBatchReadingMapping);
XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping();
containerPolicyMapping.setAttributeName("containerPolicy");
containerPolicyMapping.setGetMethodName("getContainerPolicy");
containerPolicyMapping.setSetMethodName("setContainerPolicy");
containerPolicyMapping.setReferenceClass(ContainerPolicy.class);
containerPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "container");
descriptor.addMapping(containerPolicyMapping);
XMLCompositeObjectMapping indirectionPolicyMapping = new XMLCompositeObjectMapping();
indirectionPolicyMapping.setReferenceClass(IndirectionPolicy.class);
// Handle translation of NoIndirectionPolicy -> null.
indirectionPolicyMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
IndirectionPolicy policy = ((ForeignReferenceMapping) object).getIndirectionPolicy();
if (policy instanceof NoIndirectionPolicy) {
return null;
}
return policy;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
IndirectionPolicy policy = (IndirectionPolicy) value;
if (value == null) {
policy = new NoIndirectionPolicy();
}
((ForeignReferenceMapping) object).setIndirectionPolicy(policy);
}
});
indirectionPolicyMapping.setAttributeName("indirectionPolicy");
indirectionPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "indirection");
descriptor.addMapping(indirectionPolicyMapping);
XMLCompositeObjectMapping selectionQueryMapping = new XMLCompositeObjectMapping();
selectionQueryMapping.setAttributeName("selectionQuery");
selectionQueryMapping.setGetMethodName("getSelectionQuery");
selectionQueryMapping.setSetMethodName("setSelectionQuery");
selectionQueryMapping.setReferenceClass(ReadQuery.class);
selectionQueryMapping.setXPath(getPrimaryNamespaceXPath() + "selection-query");
descriptor.addMapping(selectionQueryMapping);
XMLDirectMapping referenceTableMapping = new XMLDirectMapping();
referenceTableMapping.setAttributeName("referenceTableName");
// CR#2407 Call getReferenceTableQualifiedName that includes table qualifier.
referenceTableMapping.setGetMethodName("getReferenceTableQualifiedName");
referenceTableMapping.setSetMethodName("setReferenceTableName");
referenceTableMapping.setXPath(getPrimaryNamespaceXPath() + "reference-table/text()");
descriptor.addMapping(referenceTableMapping);
XMLCompositeObjectMapping directFieldMapping = new XMLCompositeObjectMapping();
directFieldMapping.setAttributeName("directField");
directFieldMapping.setGetMethodName("getDirectField");
directFieldMapping.setSetMethodName("setDirectField");
directFieldMapping.setXPath(getPrimaryNamespaceXPath() + "direct-field");
directFieldMapping.setReferenceClass(DatabaseField.class);
((XMLField) directFieldMapping.getField()).setLeafElementType(fieldQname);
descriptor.addMapping(directFieldMapping);
XMLCompositeCollectionMapping sourceToReferenceKeyFieldAssociationsMapping = new XMLCompositeCollectionMapping();
sourceToReferenceKeyFieldAssociationsMapping.setReferenceClass(Association.class);
// Handle translation of foreign key associations to hashtables.
sourceToReferenceKeyFieldAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
List<DatabaseField> sourceFields = ((DirectCollectionMapping) object).getSourceKeyFields();
List<DatabaseField> referenceFields = ((DirectCollectionMapping) object).getReferenceKeyFields();
List<Association> associations = new ArrayList<>(sourceFields.size());
for (int index = 0; index < sourceFields.size(); index++) {
associations.add(new Association(referenceFields.get(index), sourceFields.get(index)));
}
return associations;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
DirectCollectionMapping mapping = (DirectCollectionMapping) object;
@SuppressWarnings({ "unchecked" }) List<Association> associations = (List<Association>) value;
mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
mapping.setReferenceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
Iterator<Association> iterator = associations.iterator();
while (iterator.hasNext()) {
Association association = iterator.next();
mapping.getSourceKeyFields().add((DatabaseField) association.getValue());
mapping.getReferenceKeyFields().add((DatabaseField) association.getKey());
}
}
});
sourceToReferenceKeyFieldAssociationsMapping.setAttributeName("sourceToReferenceKeyFieldAssociations");
sourceToReferenceKeyFieldAssociationsMapping.setXPath(getPrimaryNamespaceXPath() + "reference-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
descriptor.addMapping(sourceToReferenceKeyFieldAssociationsMapping);
XMLCompositeObjectMapping valueConverterMapping = new XMLCompositeObjectMapping();
valueConverterMapping.setAttributeName("valueConverter");
valueConverterMapping.setGetMethodName("getValueConverter");
valueConverterMapping.setSetMethodName("setValueConverter");
valueConverterMapping.setXPath(getPrimaryNamespaceXPath() + "value-converter");
valueConverterMapping.setReferenceClass(Converter.class);
descriptor.addMapping(valueConverterMapping);
XMLCompositeObjectMapping historyPolicyMapping = new XMLCompositeObjectMapping();
historyPolicyMapping.setAttributeName("historyPolicy");
historyPolicyMapping.setGetMethodName("getHistoryPolicy");
historyPolicyMapping.setSetMethodName("setHistoryPolicy");
historyPolicyMapping.setReferenceClass(HistoryPolicy.class);
historyPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "history-policy");
descriptor.addMapping(historyPolicyMapping);
return descriptor;
}
use of org.eclipse.persistence.mappings.Association in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildAggregateCollectionMappingDescriptor.
protected ClassDescriptor buildAggregateCollectionMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(AggregateCollectionMapping.class);
descriptor.getInheritancePolicy().setParentClass(CollectionMapping.class);
XMLCompositeCollectionMapping sourceToTargetKeyFieldAssociationsMapping = new XMLCompositeCollectionMapping();
sourceToTargetKeyFieldAssociationsMapping.setReferenceClass(Association.class);
// Handle translation of foreign key associations to hashtables.
sourceToTargetKeyFieldAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
AggregateCollectionMapping mapping = (AggregateCollectionMapping) object;
List<DatabaseField> sourceFields = mapping.getSourceKeyFields();
List<DatabaseField> targetFields = mapping.getTargetForeignKeyFields();
List<Association> associations = new ArrayList<>(sourceFields.size());
for (int index = 0; index < sourceFields.size(); index++) {
associations.add(new Association(targetFields.get(index), sourceFields.get(index)));
}
return associations;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
AggregateCollectionMapping mapping = (AggregateCollectionMapping) object;
@SuppressWarnings({ "unchecked" }) List<Association> associations = (List<Association>) value;
mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
mapping.setTargetForeignKeyFields(NonSynchronizedVector.newInstance(associations.size()));
Iterator<Association> iterator = associations.iterator();
while (iterator.hasNext()) {
Association association = iterator.next();
mapping.getSourceKeyFields().add((DatabaseField) association.getValue());
mapping.getTargetForeignKeyFields().add((DatabaseField) association.getKey());
}
}
});
sourceToTargetKeyFieldAssociationsMapping.setAttributeName("sourceToTargetKeyFieldAssociations");
sourceToTargetKeyFieldAssociationsMapping.setXPath(getPrimaryNamespaceXPath() + "target-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
descriptor.addMapping(sourceToTargetKeyFieldAssociationsMapping);
XMLDirectMapping relationshipPartnerAttributeNameMapping = new XMLDirectMapping();
relationshipPartnerAttributeNameMapping.setAttributeName("relationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setGetMethodName("getRelationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setSetMethodName("setRelationshipPartnerAttributeName");
relationshipPartnerAttributeNameMapping.setXPath(getPrimaryNamespaceXPath() + "bidirectional-target-attribute/text()");
descriptor.addMapping(relationshipPartnerAttributeNameMapping);
XMLDirectMapping usesBatchReadingMapping = new XMLDirectMapping();
usesBatchReadingMapping.setAttributeName("usesBatchReading");
usesBatchReadingMapping.setGetMethodName("shouldUseBatchReading");
usesBatchReadingMapping.setSetMethodName("setUsesBatchReading");
usesBatchReadingMapping.setXPath(getPrimaryNamespaceXPath() + "batch-reading/text()");
usesBatchReadingMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(usesBatchReadingMapping);
XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping();
containerPolicyMapping.setAttributeName("collectionPolicy");
containerPolicyMapping.setGetMethodName("getContainerPolicy");
containerPolicyMapping.setSetMethodName("setContainerPolicy");
containerPolicyMapping.setReferenceClass(ContainerPolicy.class);
containerPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "container");
descriptor.addMapping(containerPolicyMapping);
XMLCompositeObjectMapping indirectionPolicyMapping = new XMLCompositeObjectMapping();
indirectionPolicyMapping.setReferenceClass(IndirectionPolicy.class);
// Handle translation of NoIndirectionPolicy -> null.
indirectionPolicyMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
IndirectionPolicy policy = ((ForeignReferenceMapping) object).getIndirectionPolicy();
if (policy instanceof NoIndirectionPolicy) {
return null;
}
return policy;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
IndirectionPolicy policy = (IndirectionPolicy) value;
if (value == null) {
policy = new NoIndirectionPolicy();
}
((ForeignReferenceMapping) object).setIndirectionPolicy(policy);
}
});
indirectionPolicyMapping.setAttributeName("indirectionPolicy");
indirectionPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "indirection");
descriptor.addMapping(indirectionPolicyMapping);
XMLCompositeObjectMapping selectionQueryMapping = new XMLCompositeObjectMapping();
selectionQueryMapping.setAttributeName("selectionQuery");
selectionQueryMapping.setGetMethodName("getSelectionQuery");
selectionQueryMapping.setSetMethodName("setSelectionQuery");
selectionQueryMapping.setReferenceClass(ReadQuery.class);
selectionQueryMapping.setXPath(getPrimaryNamespaceXPath() + "selection-query");
descriptor.addMapping(selectionQueryMapping);
// delete-all query
return descriptor;
}
Aggregations