use of org.eclipse.persistence.oxm.mappings.XMLDirectMapping in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildQueryKeyDescriptor.
protected ClassDescriptor buildQueryKeyDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(QueryKey.class);
descriptor.setDefaultRootElement("query-key");
descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
descriptor.getInheritancePolicy().addClassIndicator(QueryKey.class, getPrimaryNamespaceXPath() + "query-key");
descriptor.getInheritancePolicy().addClassIndicator(OneToOneQueryKey.class, getPrimaryNamespaceXPath() + "one-to-one-query-key");
descriptor.getInheritancePolicy().addClassIndicator(OneToManyQueryKey.class, getPrimaryNamespaceXPath() + "one-to-many-query-key");
descriptor.getInheritancePolicy().addClassIndicator(DirectQueryKey.class, getPrimaryNamespaceXPath() + "direct-query-key");
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setGetMethodName("getName");
nameMapping.setSetMethodName("setName");
nameMapping.setXPath("@name");
descriptor.addMapping(nameMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLDirectMapping in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildDatabaseMappingDescriptor.
protected ClassDescriptor buildDatabaseMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(DatabaseMapping.class);
descriptor.setDefaultRootElement("attribute-mapping");
descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
descriptor.getInheritancePolicy().addClassIndicator(DirectToFieldMapping.class, getPrimaryNamespaceXPath() + "direct-mapping");
descriptor.getInheritancePolicy().addClassIndicator(TransformationMapping.class, getPrimaryNamespaceXPath() + "transformation-mapping");
descriptor.getInheritancePolicy().addClassIndicator(OneToOneMapping.class, getPrimaryNamespaceXPath() + "one-to-one-mapping");
descriptor.getInheritancePolicy().addClassIndicator(VariableOneToOneMapping.class, getPrimaryNamespaceXPath() + "variable-one-to-one-mapping");
descriptor.getInheritancePolicy().addClassIndicator(OneToManyMapping.class, getPrimaryNamespaceXPath() + "one-to-many-mapping");
descriptor.getInheritancePolicy().addClassIndicator(ManyToManyMapping.class, getPrimaryNamespaceXPath() + "many-to-many-mapping");
descriptor.getInheritancePolicy().addClassIndicator(AggregateObjectMapping.class, getPrimaryNamespaceXPath() + "aggregate-object-mapping");
descriptor.getInheritancePolicy().addClassIndicator(AggregateCollectionMapping.class, getPrimaryNamespaceXPath() + "aggregate-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(DirectCollectionMapping.class, getPrimaryNamespaceXPath() + "direct-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(DirectMapMapping.class, getPrimaryNamespaceXPath() + "direct-map-mapping");
descriptor.getInheritancePolicy().addClassIndicator(NestedTableMapping.class, getPrimaryNamespaceXPath() + "nested-table-mapping");
descriptor.getInheritancePolicy().addClassIndicator(StructureMapping.class, getPrimaryNamespaceXPath() + "structure-mapping");
descriptor.getInheritancePolicy().addClassIndicator(ReferenceMapping.class, getPrimaryNamespaceXPath() + "reference-mapping");
descriptor.getInheritancePolicy().addClassIndicator(ArrayMapping.class, getPrimaryNamespaceXPath() + "array-mapping");
descriptor.getInheritancePolicy().addClassIndicator(ObjectArrayMapping.class, getPrimaryNamespaceXPath() + "object-array-mapping");
DirectToXMLTypeMappingHelper.getInstance().addClassIndicator(descriptor, getPrimaryNamespaceXPath());
descriptor.getInheritancePolicy().addClassIndicator(AbstractTransformationMapping.class, getPrimaryNamespaceXPath() + "abstract-transformation-mapping");
descriptor.getInheritancePolicy().addClassIndicator(AbstractCompositeDirectCollectionMapping.class, getPrimaryNamespaceXPath() + "abstract-composite-direct-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(AbstractCompositeObjectMapping.class, getPrimaryNamespaceXPath() + "abstract-composite-object-mapping");
descriptor.getInheritancePolicy().addClassIndicator(AbstractCompositeCollectionMapping.class, getPrimaryNamespaceXPath() + "abstract-composite-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(XMLDirectMapping.class, getPrimaryNamespaceXPath() + "xml-direct-mapping");
descriptor.getInheritancePolicy().addClassIndicator(XMLTransformationMapping.class, getPrimaryNamespaceXPath() + "xml-transformation-mapping");
descriptor.getInheritancePolicy().addClassIndicator(XMLCompositeDirectCollectionMapping.class, getPrimaryNamespaceXPath() + "xml-composite-direct-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(XMLCompositeObjectMapping.class, getPrimaryNamespaceXPath() + "xml-composite-object-mapping");
descriptor.getInheritancePolicy().addClassIndicator(XMLCompositeCollectionMapping.class, getPrimaryNamespaceXPath() + "xml-composite-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(XMLAnyCollectionMapping.class, getPrimaryNamespaceXPath() + "xml-any-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(XMLAnyObjectMapping.class, getPrimaryNamespaceXPath() + "xml-any-object-mapping");
descriptor.getInheritancePolicy().addClassIndicator(EISDirectMapping.class, getPrimaryNamespaceXPath() + "eis-direct-mapping");
descriptor.getInheritancePolicy().addClassIndicator(EISTransformationMapping.class, getPrimaryNamespaceXPath() + "eis-transformation-mapping");
descriptor.getInheritancePolicy().addClassIndicator(EISCompositeDirectCollectionMapping.class, getPrimaryNamespaceXPath() + "eis-composite-direct-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(EISCompositeObjectMapping.class, getPrimaryNamespaceXPath() + "eis-composite-object-mapping");
descriptor.getInheritancePolicy().addClassIndicator(EISCompositeCollectionMapping.class, getPrimaryNamespaceXPath() + "eis-composite-collection-mapping");
descriptor.getInheritancePolicy().addClassIndicator(EISOneToOneMapping.class, getPrimaryNamespaceXPath() + "eis-one-to-one-mapping");
descriptor.getInheritancePolicy().addClassIndicator(EISOneToManyMapping.class, getPrimaryNamespaceXPath() + "eis-one-to-many-mapping");
XMLDirectMapping XMLDirectMapping = new XMLDirectMapping();
XMLDirectMapping.setAttributeName("attributeName");
XMLDirectMapping.setGetMethodName("getAttributeName");
XMLDirectMapping.setSetMethodName("setAttributeName");
XMLDirectMapping.setXPath(getSecondaryNamespaceXPath() + "attribute-name/text()");
descriptor.addMapping(XMLDirectMapping);
XMLDirectMapping readonlyMapping = new XMLDirectMapping();
readonlyMapping.setAttributeName("isReadOnly");
readonlyMapping.setGetMethodName("isReadOnly");
readonlyMapping.setSetMethodName("setIsReadOnly");
readonlyMapping.setXPath(getSecondaryNamespaceXPath() + "read-only/text()");
readonlyMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(readonlyMapping);
XMLDirectMapping XMLDirectMapping3 = new XMLDirectMapping();
XMLDirectMapping3.setAttributeName("getMethodName");
XMLDirectMapping3.setGetMethodName("getGetMethodName");
XMLDirectMapping3.setSetMethodName("setGetMethodName");
XMLDirectMapping3.setXPath(getSecondaryNamespaceXPath() + "get-method/text()");
descriptor.addMapping(XMLDirectMapping3);
XMLDirectMapping XMLDirectMapping4 = new XMLDirectMapping();
XMLDirectMapping4.setAttributeName("setMethodName");
XMLDirectMapping4.setGetMethodName("getSetMethodName");
XMLDirectMapping4.setSetMethodName("setSetMethodName");
XMLDirectMapping4.setXPath(getSecondaryNamespaceXPath() + "set-method/text()");
descriptor.addMapping(XMLDirectMapping4);
XMLCompositeCollectionMapping propertiesMapping = new XMLCompositeCollectionMapping();
propertiesMapping.setAttributeName("properties");
propertiesMapping.setReferenceClass(PropertyAssociation.class);
propertiesMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
DatabaseMapping mapping = (DatabaseMapping) object;
List<PropertyAssociation> propertyAssociations = new ArrayList<>();
for (Iterator<Map.Entry<?, ?>> i = mapping.getProperties().entrySet().iterator(); i.hasNext(); ) {
Map.Entry<?, ?> me = i.next();
PropertyAssociation propertyAssociation = new PropertyAssociation();
propertyAssociation.setKey(me.getKey());
propertyAssociation.setValue(me.getValue());
propertyAssociations.add(propertyAssociation);
}
return propertyAssociations;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
DatabaseMapping mapping = (DatabaseMapping) object;
@SuppressWarnings({ "unchecked" }) List<PropertyAssociation> propertyAssociations = (List<PropertyAssociation>) value;
for (int i = 0; i < propertyAssociations.size(); i++) {
PropertyAssociation propertyAssociation = propertyAssociations.get(i);
mapping.getProperties().put(propertyAssociation.getKey(), propertyAssociation.getValue());
}
}
});
propertiesMapping.setXPath(getSecondaryNamespaceXPath() + "properties/" + getSecondaryNamespaceXPath() + "property");
descriptor.addMapping(propertiesMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLDirectMapping in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildQueryManagerDescriptor.
protected ClassDescriptor buildQueryManagerDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(DescriptorQueryManager.class);
descriptor.setDefaultRootElement("query-policy");
descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
descriptor.getInheritancePolicy().addClassIndicator(DescriptorQueryManager.class, getPrimaryNamespaceXPath() + "query-policy");
XMLCompositeCollectionMapping namedQueriesMapping = new XMLCompositeCollectionMapping();
namedQueriesMapping.setReferenceClass(DatabaseQuery.class);
namedQueriesMapping.useCollectionClass(Vector.class);
namedQueriesMapping.setAttributeName("queries");
namedQueriesMapping.setGetMethodName("getAllQueries");
namedQueriesMapping.setSetMethodName("setAllQueries");
namedQueriesMapping.setXPath(getSecondaryNamespaceXPath() + "queries/" + getSecondaryNamespaceXPath() + "query");
descriptor.addMapping(namedQueriesMapping);
XMLDirectMapping queryTimeoutMapping = new XMLDirectMapping();
queryTimeoutMapping.setAttributeName("queryTimeout");
queryTimeoutMapping.setGetMethodName("getQueryTimeout");
queryTimeoutMapping.setSetMethodName("setQueryTimeout");
queryTimeoutMapping.setXPath(getPrimaryNamespaceXPath() + "timeout/text()");
queryTimeoutMapping.setNullValue(DescriptorQueryManager.DefaultTimeout);
descriptor.addMapping(queryTimeoutMapping);
XMLCompositeObjectMapping insertQueryMapping = new XMLCompositeObjectMapping();
insertQueryMapping.setAttributeName("insertQuery");
insertQueryMapping.setGetMethodName("getInsertQuery");
insertQueryMapping.setSetMethodName("setInsertQuery");
insertQueryMapping.setXPath(getPrimaryNamespaceXPath() + "insert-query");
insertQueryMapping.setReferenceClass(InsertObjectQuery.class);
descriptor.addMapping(insertQueryMapping);
XMLCompositeObjectMapping updateQueryMapping = new XMLCompositeObjectMapping();
updateQueryMapping.setAttributeName("updateQuery");
updateQueryMapping.setGetMethodName("getUpdateQuery");
updateQueryMapping.setSetMethodName("setUpdateQuery");
updateQueryMapping.setXPath(getPrimaryNamespaceXPath() + "update-query");
updateQueryMapping.setReferenceClass(UpdateObjectQuery.class);
descriptor.addMapping(updateQueryMapping);
XMLCompositeObjectMapping deleteQueryMapping = new XMLCompositeObjectMapping();
deleteQueryMapping.setAttributeName("deleteQuery");
deleteQueryMapping.setGetMethodName("getDeleteQuery");
deleteQueryMapping.setSetMethodName("setDeleteQuery");
deleteQueryMapping.setXPath(getPrimaryNamespaceXPath() + "delete-query");
deleteQueryMapping.setReferenceClass(DeleteObjectQuery.class);
descriptor.addMapping(deleteQueryMapping);
XMLCompositeObjectMapping doesExistQueryMapping = new XMLCompositeObjectMapping();
doesExistQueryMapping.setAttributeName("doesExistQuery");
// Handle translation of default does-exist to null.
doesExistQueryMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
DoesExistQuery query = ((DescriptorQueryManager) object).getDoesExistQuery();
if ((!query.isCallQuery()) && query.shouldCheckCacheForDoesExist()) {
return null;
}
return query;
}
@Override
public void setAttributeValueInObject(Object object, Object value) {
DoesExistQuery query = (DoesExistQuery) value;
if (value == null) {
return;
}
((DescriptorQueryManager) object).setDoesExistQuery(query);
}
});
doesExistQueryMapping.setXPath(getPrimaryNamespaceXPath() + "does-exist-query");
doesExistQueryMapping.setReferenceClass(DoesExistQuery.class);
descriptor.addMapping(doesExistQueryMapping);
XMLCompositeObjectMapping readObjectQueryMapping = new XMLCompositeObjectMapping();
readObjectQueryMapping.setAttributeName("readObjectQuery");
readObjectQueryMapping.setGetMethodName("getReadObjectQuery");
readObjectQueryMapping.setSetMethodName("setReadObjectQuery");
readObjectQueryMapping.setXPath(getPrimaryNamespaceXPath() + "read-object-query");
readObjectQueryMapping.setReferenceClass(ReadObjectQuery.class);
descriptor.addMapping(readObjectQueryMapping);
XMLCompositeObjectMapping readAllQueryMapping = new XMLCompositeObjectMapping();
readAllQueryMapping.setAttributeName("readAllQuery");
readAllQueryMapping.setGetMethodName("getReadAllQuery");
readAllQueryMapping.setSetMethodName("setReadAllQuery");
readAllQueryMapping.setXPath(getPrimaryNamespaceXPath() + "read-all-query");
readAllQueryMapping.setReferenceClass(ReadAllQuery.class);
descriptor.addMapping(readAllQueryMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLDirectMapping in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildCMPPolicyDescriptor.
protected ClassDescriptor buildCMPPolicyDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(CMPPolicy.class);
descriptor.setDefaultRootElement("cmp-policy");
XMLDirectMapping modificationDeferralLevelMapping = new XMLDirectMapping();
modificationDeferralLevelMapping.setAttributeName("modificationDeferralLevel");
modificationDeferralLevelMapping.setGetMethodName("getDeferModificationsUntilCommit");
modificationDeferralLevelMapping.setSetMethodName("setDeferModificationsUntilCommit");
ObjectTypeConverter modificationDeferralLevelConverter = new ObjectTypeConverter();
modificationDeferralLevelConverter.addConversionValue("all-modifications", CMPPolicy.ALL_MODIFICATIONS);
modificationDeferralLevelConverter.addConversionValue("update-modifications", CMPPolicy.UPDATE_MODIFICATIONS);
modificationDeferralLevelConverter.addConversionValue("none", CMPPolicy.NONE);
modificationDeferralLevelMapping.setConverter(modificationDeferralLevelConverter);
modificationDeferralLevelMapping.setXPath(getPrimaryNamespaceXPath() + "defer-until-commit/text()");
modificationDeferralLevelMapping.setNullValue(CMPPolicy.ALL_MODIFICATIONS);
descriptor.addMapping(modificationDeferralLevelMapping);
XMLDirectMapping nonDeferredCreateTimeMapping = new XMLDirectMapping();
nonDeferredCreateTimeMapping.setAttributeName("nonDeferredCreateTime");
nonDeferredCreateTimeMapping.setGetMethodName("getNonDeferredCreateTime");
nonDeferredCreateTimeMapping.setSetMethodName("setNonDeferredCreateTime");
ObjectTypeConverter nonDeferredCreateTimeConverter = new ObjectTypeConverter();
nonDeferredCreateTimeConverter.addConversionValue("after-ejbcreate", CMPPolicy.AFTER_EJBCREATE);
nonDeferredCreateTimeConverter.addConversionValue("after-ejbpostcreate", CMPPolicy.AFTER_EJBPOSTCREATE);
nonDeferredCreateTimeConverter.addConversionValue("undefined", CMPPolicy.UNDEFINED);
nonDeferredCreateTimeMapping.setConverter(nonDeferredCreateTimeConverter);
nonDeferredCreateTimeMapping.setXPath(getPrimaryNamespaceXPath() + "non-deferred-create-time/text()");
nonDeferredCreateTimeMapping.setNullValue(CMPPolicy.UNDEFINED);
descriptor.addMapping(nonDeferredCreateTimeMapping);
XMLCompositeObjectMapping pessimisticLockingPolicyMapping = new XMLCompositeObjectMapping();
pessimisticLockingPolicyMapping.setAttributeName("pessimisticLockingPolicy");
pessimisticLockingPolicyMapping.setGetMethodName("getPessimisticLockingPolicy");
pessimisticLockingPolicyMapping.setSetMethodName("setPessimisticLockingPolicy");
pessimisticLockingPolicyMapping.setReferenceClass(PessimisticLockingPolicy.class);
pessimisticLockingPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "pessimistic-locking");
descriptor.addMapping(pessimisticLockingPolicyMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLDirectMapping in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildObjectRelationalDataTypeDescriptorDescriptor.
protected ClassDescriptor buildObjectRelationalDataTypeDescriptorDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(ObjectRelationalDataTypeDescriptor.class);
descriptor.getInheritancePolicy().setParentClass(RelationalDescriptor.class);
XMLDirectMapping structureMapping = new XMLDirectMapping();
structureMapping.setAttributeName("structureName");
structureMapping.setGetMethodName("getStructureName");
structureMapping.setSetMethodName("setStructureName");
structureMapping.setXPath(getPrimaryNamespaceXPath() + "structure/text()");
descriptor.addMapping(structureMapping);
XMLCompositeCollectionMapping orderedFieldsMapping = new XMLCompositeCollectionMapping();
orderedFieldsMapping.useCollectionClass(NonSynchronizedVector.class);
orderedFieldsMapping.setAttributeName("orderedFields");
orderedFieldsMapping.setXPath(getPrimaryNamespaceXPath() + "field-order/" + getPrimaryNamespaceXPath() + "field");
orderedFieldsMapping.setReferenceClass(DatabaseField.class);
((XMLField) orderedFieldsMapping.getField()).setLeafElementType(fieldQname);
descriptor.addMapping(orderedFieldsMapping);
return descriptor;
}
Aggregations