use of org.eclipse.persistence.mappings.PropertyAssociation 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.mappings.PropertyAssociation in project eclipselink by eclipse-ee4j.
the class ObjectPersistenceRuntimeXMLProject method buildClassDescriptorDescriptor.
protected ClassDescriptor buildClassDescriptorDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(ClassDescriptor.class);
descriptor.setDefaultRootElement("class-mapping-descriptor");
descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
descriptor.getInheritancePolicy().addClassIndicator(ClassDescriptor.class, getPrimaryNamespaceXPath() + "relational-class-mapping-descriptor");
descriptor.getInheritancePolicy().addClassIndicator(RelationalDescriptor.class, getPrimaryNamespaceXPath() + "relational-class-mapping-descriptor");
descriptor.getInheritancePolicy().addClassIndicator(ObjectRelationalDataTypeDescriptor.class, getPrimaryNamespaceXPath() + "object-relational-class-mapping-descriptor");
descriptor.getInheritancePolicy().addClassIndicator(EISDescriptor.class, getPrimaryNamespaceXPath() + "eis-class-mapping-descriptor");
descriptor.getInheritancePolicy().addClassIndicator(XMLDescriptor.class, getPrimaryNamespaceXPath() + "xml-class-mapping-descriptor");
descriptor.getInheritancePolicy().addClassIndicator(ClassDescriptor.class, getPrimaryNamespaceXPath() + "class-mapping-descriptor");
descriptor.getEventManager().setPostBuildSelector("applyAmendmentMethod");
XMLDirectMapping javaClassMapping = new XMLDirectMapping();
javaClassMapping.setAttributeName("javaClass");
javaClassMapping.setGetMethodName("getJavaClass");
javaClassMapping.setSetMethodName("setJavaClass");
javaClassMapping.setXPath(getSecondaryNamespaceXPath() + "class/text()");
descriptor.addMapping(javaClassMapping);
XMLDirectMapping aliasMapping = new XMLDirectMapping();
aliasMapping.setAttributeName("alias");
aliasMapping.setGetMethodName("getAlias");
aliasMapping.setSetMethodName("setAlias");
aliasMapping.setXPath(getSecondaryNamespaceXPath() + "alias/text()");
descriptor.addMapping(aliasMapping);
XMLCompositeCollectionMapping primaryKeyFieldNamesMapping = new XMLCompositeCollectionMapping();
primaryKeyFieldNamesMapping.setAttributeName("primaryKeyFields");
primaryKeyFieldNamesMapping.setReferenceClass(DatabaseField.class);
primaryKeyFieldNamesMapping.setGetMethodName("getPrimaryKeyFields");
primaryKeyFieldNamesMapping.setSetMethodName("setPrimaryKeyFields");
primaryKeyFieldNamesMapping.setXPath(getSecondaryNamespaceXPath() + "primary-key/" + getSecondaryNamespaceXPath() + "field");
((XMLField) primaryKeyFieldNamesMapping.getField()).setLeafElementType(fieldQname);
primaryKeyFieldNamesMapping.useCollectionClass(ArrayList.class);
descriptor.addMapping(primaryKeyFieldNamesMapping);
XMLDirectMapping descriptorIsReadOnlyMapping = new XMLDirectMapping();
descriptorIsReadOnlyMapping.setAttributeName("shouldBeReadOnly");
descriptorIsReadOnlyMapping.setGetMethodName("shouldBeReadOnly");
descriptorIsReadOnlyMapping.setSetMethodName("setShouldBeReadOnly");
descriptorIsReadOnlyMapping.setXPath(getSecondaryNamespaceXPath() + "read-only/text()");
descriptorIsReadOnlyMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(descriptorIsReadOnlyMapping);
XMLCompositeObjectMapping inheritancePolicyMapping = new XMLCompositeObjectMapping();
inheritancePolicyMapping.setAttributeName("inheritancePolicy");
inheritancePolicyMapping.setGetMethodName("getInheritancePolicyOrNull");
inheritancePolicyMapping.setSetMethodName("setInheritancePolicy");
inheritancePolicyMapping.setReferenceClass(InheritancePolicy.class);
inheritancePolicyMapping.setXPath(getSecondaryNamespaceXPath() + "inheritance");
descriptor.addMapping(inheritancePolicyMapping);
XMLCompositeObjectMapping eventManagerMapping = new XMLCompositeObjectMapping();
eventManagerMapping.setAttributeName("eventManager");
eventManagerMapping.setGetMethodName("getEventManager");
eventManagerMapping.setSetMethodName("setEventManager");
eventManagerMapping.setReferenceClass(DescriptorEventManager.class);
eventManagerMapping.setXPath(getSecondaryNamespaceXPath() + "events");
descriptor.addMapping(eventManagerMapping);
XMLCompositeObjectMapping queryManagerMapping = new XMLCompositeObjectMapping();
queryManagerMapping.setAttributeName("queryManager");
queryManagerMapping.setGetMethodName("getQueryManager");
queryManagerMapping.setSetMethodName("setQueryManager");
queryManagerMapping.setReferenceClass(DescriptorQueryManager.class);
queryManagerMapping.setXPath(getSecondaryNamespaceXPath() + "querying");
descriptor.addMapping(queryManagerMapping);
XMLCompositeCollectionMapping aggregateCollectionMapping = new XMLCompositeCollectionMapping();
aggregateCollectionMapping.useCollectionClass(NonSynchronizedVector.class);
aggregateCollectionMapping.setAttributeName("mappings");
aggregateCollectionMapping.setReferenceClass(DatabaseMapping.class);
aggregateCollectionMapping.setXPath(getSecondaryNamespaceXPath() + "attribute-mappings/" + getSecondaryNamespaceXPath() + "attribute-mapping");
aggregateCollectionMapping.setSetMethodName("setMappings");
aggregateCollectionMapping.setGetMethodName("getMappings");
descriptor.addMapping(aggregateCollectionMapping);
XMLDirectMapping descriptorTypeMapping = new XMLDirectMapping();
descriptorTypeMapping.setAttributeName("descriptorTypeValue");
descriptorTypeMapping.setGetMethodName("getDescriptorTypeValue");
descriptorTypeMapping.setSetMethodName("setDescriptorTypeValue");
ObjectTypeConverter descriptorTypeConverter = new ObjectTypeConverter();
descriptorTypeConverter.addConversionValue("aggregate", "Aggregate");
descriptorTypeConverter.addConversionValue("aggregate-collection", "Aggregate collection");
descriptorTypeConverter.addConversionValue("composite", "Composite");
descriptorTypeConverter.addConversionValue("composite-collection", "Composite collection");
descriptorTypeConverter.addConversionValue("interface", "Interface");
descriptorTypeConverter.addConversionValue("independent", "Normal");
descriptorTypeMapping.setConverter(descriptorTypeConverter);
descriptorTypeMapping.setXPath(getPrimaryNamespaceXPath() + "descriptor-type/text()");
descriptor.addMapping(descriptorTypeMapping);
XMLCompositeObjectMapping interfacePolicyMapping = new XMLCompositeObjectMapping();
interfacePolicyMapping.setAttributeName("interfacePolicy");
interfacePolicyMapping.setGetMethodName("getInterfacePolicyOrNull");
interfacePolicyMapping.setSetMethodName("setInterfacePolicy");
interfacePolicyMapping.setReferenceClass(InterfacePolicy.class);
interfacePolicyMapping.setXPath(getPrimaryNamespaceXPath() + "interfaces");
descriptor.addMapping(interfacePolicyMapping);
XMLCompositeObjectMapping lockingPolicyMapping = new XMLCompositeObjectMapping();
lockingPolicyMapping.setAttributeName("lockingPolicy");
lockingPolicyMapping.setGetMethodName("getOptimisticLockingPolicy");
lockingPolicyMapping.setSetMethodName("setOptimisticLockingPolicy");
lockingPolicyMapping.setReferenceClass(VersionLockingPolicy.class);
lockingPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "locking");
descriptor.addMapping(lockingPolicyMapping);
XMLDirectMapping sequenceNameMapping = new XMLDirectMapping();
sequenceNameMapping.setAttributeName("sequenceNumberName");
sequenceNameMapping.setGetMethodName("getSequenceNumberName");
sequenceNameMapping.setSetMethodName("setSequenceNumberName");
sequenceNameMapping.setXPath(getPrimaryNamespaceXPath() + "sequencing/" + getPrimaryNamespaceXPath() + "sequence-name/text()");
descriptor.addMapping(sequenceNameMapping);
XMLDirectMapping sequenceFieldMapping = new XMLDirectMapping();
sequenceFieldMapping.setAttributeName("sequenceNumberField");
sequenceFieldMapping.setGetMethodName("getSequenceNumberFieldName");
sequenceFieldMapping.setSetMethodName("setSequenceNumberFieldName");
sequenceFieldMapping.setXPath(getPrimaryNamespaceXPath() + "sequencing/" + getPrimaryNamespaceXPath() + "sequence-field/@name");
descriptor.addMapping(sequenceFieldMapping);
XMLDirectMapping identityMapClassMapping = new XMLDirectMapping();
identityMapClassMapping.setAttributeName("identityMapClass");
identityMapClassMapping.setGetMethodName("getIdentityMapClass");
identityMapClassMapping.setSetMethodName("setIdentityMapClass");
ObjectTypeConverter identityMapClassConverter = new ObjectTypeConverter();
identityMapClassConverter.addConversionValue("none", NoIdentityMap.class);
identityMapClassConverter.addConversionValue("full", FullIdentityMap.class);
identityMapClassConverter.addConversionValue("cache", CacheIdentityMap.class);
identityMapClassConverter.addConversionValue("weak-reference", WeakIdentityMap.class);
identityMapClassConverter.addConversionValue("soft-cache-weak-reference", SoftCacheWeakIdentityMap.class);
identityMapClassConverter.addConversionValue("hard-cache-weak-reference", HardCacheWeakIdentityMap.class);
identityMapClassMapping.setConverter(identityMapClassConverter);
identityMapClassMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "cache-type/text()");
identityMapClassMapping.setNullValue(SoftCacheWeakIdentityMap.class);
descriptor.addMapping(identityMapClassMapping);
XMLDirectMapping remoteIdentityMapClassMapping = new XMLDirectMapping();
remoteIdentityMapClassMapping.setAttributeName("remoteIdentityMapClass");
remoteIdentityMapClassMapping.setGetMethodName("getRemoteIdentityMapClass");
remoteIdentityMapClassMapping.setSetMethodName("setRemoteIdentityMapClass");
ObjectTypeConverter remoteIdentityMapClassConverter = new ObjectTypeConverter();
remoteIdentityMapClassConverter.addConversionValue("none", NoIdentityMap.class);
remoteIdentityMapClassConverter.addConversionValue("full", FullIdentityMap.class);
remoteIdentityMapClassConverter.addConversionValue("cache", CacheIdentityMap.class);
remoteIdentityMapClassConverter.addConversionValue("weak-reference", WeakIdentityMap.class);
remoteIdentityMapClassConverter.addConversionValue("soft-cache-weak-reference", SoftCacheWeakIdentityMap.class);
remoteIdentityMapClassConverter.addConversionValue("hard-cache-weak-reference", HardCacheWeakIdentityMap.class);
remoteIdentityMapClassMapping.setConverter(remoteIdentityMapClassConverter);
remoteIdentityMapClassMapping.setXPath(getPrimaryNamespaceXPath() + "remote-caching/" + getPrimaryNamespaceXPath() + "cache-type/text()");
remoteIdentityMapClassMapping.setNullValue(SoftCacheWeakIdentityMap.class);
descriptor.addMapping(remoteIdentityMapClassMapping);
XMLDirectMapping identityMapSizeMapping = new XMLDirectMapping();
identityMapSizeMapping.setAttributeName("identityMapSize");
identityMapSizeMapping.setGetMethodName("getIdentityMapSize");
identityMapSizeMapping.setSetMethodName("setIdentityMapSize");
identityMapSizeMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "cache-size/text()");
identityMapSizeMapping.setNullValue(100);
descriptor.addMapping(identityMapSizeMapping);
XMLDirectMapping remoteIdentityMapSizeMapping = new XMLDirectMapping();
remoteIdentityMapSizeMapping.setAttributeName("remoteIdentityMapSize");
remoteIdentityMapSizeMapping.setGetMethodName("getRemoteIdentityMapSize");
remoteIdentityMapSizeMapping.setSetMethodName("setRemoteIdentityMapSize");
remoteIdentityMapSizeMapping.setXPath(getPrimaryNamespaceXPath() + "remote-caching/" + getPrimaryNamespaceXPath() + "cache-size/text()");
remoteIdentityMapSizeMapping.setNullValue(100);
descriptor.addMapping(remoteIdentityMapSizeMapping);
XMLDirectMapping shouldAlwaysRefreshCacheMapping = new XMLDirectMapping();
shouldAlwaysRefreshCacheMapping.setAttributeName("shouldAlwaysRefreshCache");
shouldAlwaysRefreshCacheMapping.setGetMethodName("shouldAlwaysRefreshCache");
shouldAlwaysRefreshCacheMapping.setSetMethodName("setShouldAlwaysRefreshCache");
shouldAlwaysRefreshCacheMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "always-refresh/text()");
shouldAlwaysRefreshCacheMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(shouldAlwaysRefreshCacheMapping);
XMLDirectMapping shouldAlwaysRefreshCacheOnRemoteMapping = new XMLDirectMapping();
shouldAlwaysRefreshCacheOnRemoteMapping.setAttributeName("shouldAlwaysRefreshCacheOnRemote");
shouldAlwaysRefreshCacheOnRemoteMapping.setGetMethodName("shouldAlwaysRefreshCacheOnRemote");
shouldAlwaysRefreshCacheOnRemoteMapping.setSetMethodName("setShouldAlwaysRefreshCacheOnRemote");
shouldAlwaysRefreshCacheOnRemoteMapping.setXPath(getPrimaryNamespaceXPath() + "remote-caching/" + getPrimaryNamespaceXPath() + "always-refresh/text()");
shouldAlwaysRefreshCacheOnRemoteMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(shouldAlwaysRefreshCacheOnRemoteMapping);
XMLDirectMapping shouldOnlyRefreshCacheIfNewerVersionMapping = new XMLDirectMapping();
shouldOnlyRefreshCacheIfNewerVersionMapping.setAttributeName("shouldOnlyRefreshCacheIfNewerVersion");
shouldOnlyRefreshCacheIfNewerVersionMapping.setGetMethodName("shouldOnlyRefreshCacheIfNewerVersion");
shouldOnlyRefreshCacheIfNewerVersionMapping.setSetMethodName("setShouldOnlyRefreshCacheIfNewerVersion");
shouldOnlyRefreshCacheIfNewerVersionMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "only-refresh-cache-if-newer-version/text()");
shouldOnlyRefreshCacheIfNewerVersionMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(shouldOnlyRefreshCacheIfNewerVersionMapping);
XMLDirectMapping shouldDisableCacheHitsMapping = new XMLDirectMapping();
shouldDisableCacheHitsMapping.setAttributeName("shouldDisableCacheHits");
shouldDisableCacheHitsMapping.setGetMethodName("shouldDisableCacheHits");
shouldDisableCacheHitsMapping.setSetMethodName("setShouldDisableCacheHits");
shouldDisableCacheHitsMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "disable-cache-hits/text()");
shouldDisableCacheHitsMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(shouldDisableCacheHitsMapping);
XMLDirectMapping shouldDisableCacheHitsOnRemoteMapping = new XMLDirectMapping();
shouldDisableCacheHitsOnRemoteMapping.setAttributeName("shouldDisableCacheHitsOnRemote");
shouldDisableCacheHitsOnRemoteMapping.setGetMethodName("shouldDisableCacheHitsOnRemote");
shouldDisableCacheHitsOnRemoteMapping.setSetMethodName("setShouldDisableCacheHitsOnRemote");
shouldDisableCacheHitsOnRemoteMapping.setXPath(getPrimaryNamespaceXPath() + "remote-caching/" + getPrimaryNamespaceXPath() + "disable-cache-hits/text()");
shouldDisableCacheHitsOnRemoteMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(shouldDisableCacheHitsOnRemoteMapping);
XMLDirectMapping shouldAlwaysConformResultsInUnitOfWorkMapping = new XMLDirectMapping();
shouldAlwaysConformResultsInUnitOfWorkMapping.setAttributeName("shouldAlwaysConformResultsInUnitOfWork");
shouldAlwaysConformResultsInUnitOfWorkMapping.setGetMethodName("shouldAlwaysConformResultsInUnitOfWork");
shouldAlwaysConformResultsInUnitOfWorkMapping.setSetMethodName("setShouldAlwaysConformResultsInUnitOfWork");
shouldAlwaysConformResultsInUnitOfWorkMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "always-conform/text()");
shouldAlwaysConformResultsInUnitOfWorkMapping.setNullValue(Boolean.FALSE);
descriptor.addMapping(shouldAlwaysConformResultsInUnitOfWorkMapping);
XMLDirectMapping isIsolatedMapping = new XMLDirectMapping();
isIsolatedMapping.setAttributeName("cacheIsolation");
isIsolatedMapping.setGetMethodName("getCacheIsolation");
isIsolatedMapping.setSetMethodName("setCacheIsolation");
isIsolatedMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "isolated/text()");
ObjectTypeConverter isIsolatedConverter = new ObjectTypeConverter();
isIsolatedConverter.addConversionValue("true", CacheIsolationType.ISOLATED);
isIsolatedConverter.addConversionValue("false", CacheIsolationType.SHARED);
isIsolatedMapping.setConverter(isIsolatedConverter);
isIsolatedMapping.setNullValue(CacheIsolationType.SHARED);
descriptor.addMapping(isIsolatedMapping);
XMLDirectMapping unitOfWorkCacheIsolationLevelMapping = new XMLDirectMapping();
unitOfWorkCacheIsolationLevelMapping.setAttributeName("unitOfWorkCacheIsolationLevel");
unitOfWorkCacheIsolationLevelMapping.setGetMethodName("getUnitOfWorkCacheIsolationLevel");
unitOfWorkCacheIsolationLevelMapping.setSetMethodName("setUnitOfWorkCacheIsolationLevel");
unitOfWorkCacheIsolationLevelMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "unitofwork-isolation-level/text()");
ObjectTypeConverter unitOfWorkCacheIsolationLevelConverter = new ObjectTypeConverter();
unitOfWorkCacheIsolationLevelConverter.addConversionValue("use-session-cache-after-transaction", ClassDescriptor.USE_SESSION_CACHE_AFTER_TRANSACTION);
unitOfWorkCacheIsolationLevelConverter.addConversionValue("isolate-new-data-after-transaction", ClassDescriptor.ISOLATE_NEW_DATA_AFTER_TRANSACTION);
unitOfWorkCacheIsolationLevelConverter.addConversionValue("isolate-cache-after-transaction", ClassDescriptor.ISOLATE_CACHE_AFTER_TRANSACTION);
unitOfWorkCacheIsolationLevelConverter.addConversionValue("isolate-cache-always", ClassDescriptor.ISOLATE_CACHE_ALWAYS);
unitOfWorkCacheIsolationLevelMapping.setConverter(unitOfWorkCacheIsolationLevelConverter);
unitOfWorkCacheIsolationLevelMapping.setNullValue(ClassDescriptor.ISOLATE_NEW_DATA_AFTER_TRANSACTION);
descriptor.addMapping(unitOfWorkCacheIsolationLevelMapping);
XMLCompositeObjectMapping cacheInvalidationPolicyMapping = new XMLCompositeObjectMapping();
cacheInvalidationPolicyMapping.setAttributeName("cacheInvalidationPolicy");
cacheInvalidationPolicyMapping.setReferenceClass(CacheInvalidationPolicy.class);
cacheInvalidationPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "cache-invalidation-policy");
descriptor.addMapping(cacheInvalidationPolicyMapping);
XMLDirectMapping cacheSyncTypeMapping = new XMLDirectMapping();
cacheSyncTypeMapping.setAttributeName("cacheSynchronizationType");
cacheSyncTypeMapping.setGetMethodName("getCacheSynchronizationType");
cacheSyncTypeMapping.setSetMethodName("setCacheSynchronizationType");
cacheSyncTypeMapping.setXPath(getPrimaryNamespaceXPath() + "caching/" + getPrimaryNamespaceXPath() + "cache-sync-type/text()");
ObjectTypeConverter cacheSyncTypeConverter = new ObjectTypeConverter();
cacheSyncTypeConverter.addConversionValue("invalidation", ClassDescriptor.INVALIDATE_CHANGED_OBJECTS);
cacheSyncTypeConverter.addConversionValue("no-changes", ClassDescriptor.DO_NOT_SEND_CHANGES);
cacheSyncTypeConverter.addConversionValue("change-set-with-new-objects", ClassDescriptor.SEND_NEW_OBJECTS_WITH_CHANGES);
cacheSyncTypeConverter.addConversionValue("change-set", ClassDescriptor.SEND_OBJECT_CHANGES);
cacheSyncTypeMapping.setConverter(cacheSyncTypeConverter);
cacheSyncTypeMapping.setNullValue(ClassDescriptor.UNDEFINED_OBJECT_CHANGE_BEHAVIOR);
descriptor.addMapping(cacheSyncTypeMapping);
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);
XMLCompositeObjectMapping returningPolicyMapping = new XMLCompositeObjectMapping();
returningPolicyMapping.setAttributeName("returningPolicy");
returningPolicyMapping.setGetMethodName("getReturningPolicy");
returningPolicyMapping.setSetMethodName("setReturningPolicy");
returningPolicyMapping.setReferenceClass(ReturningPolicy.class);
returningPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "returning-policy");
descriptor.addMapping(returningPolicyMapping);
XMLDirectMapping amendmentClassMapping = new XMLDirectMapping();
amendmentClassMapping.setAttributeName("amendmentClass");
amendmentClassMapping.setGetMethodName("getAmendmentClass");
amendmentClassMapping.setSetMethodName("setAmendmentClass");
amendmentClassMapping.setXPath(getPrimaryNamespaceXPath() + "amendment/" + getPrimaryNamespaceXPath() + "amendment-class/text()");
descriptor.addMapping(amendmentClassMapping);
XMLDirectMapping amendmentMethodNameMapping = new XMLDirectMapping();
amendmentMethodNameMapping.setAttributeName("amendmentMethodName");
amendmentMethodNameMapping.setGetMethodName("getAmendmentMethodName");
amendmentMethodNameMapping.setSetMethodName("setAmendmentMethodName");
amendmentMethodNameMapping.setXPath(getPrimaryNamespaceXPath() + "amendment/" + getPrimaryNamespaceXPath() + "amendment-method/text()");
descriptor.addMapping(amendmentMethodNameMapping);
XMLCompositeObjectMapping instantiationPolicyMapping = new XMLCompositeObjectMapping();
instantiationPolicyMapping.setAttributeName("instantiationPolicy");
instantiationPolicyMapping.setGetMethodName("getInstantiationPolicy");
instantiationPolicyMapping.setSetMethodName("setInstantiationPolicy");
instantiationPolicyMapping.setReferenceClass(InstantiationPolicy.class);
instantiationPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "instantiation");
descriptor.addMapping(instantiationPolicyMapping);
XMLCompositeObjectMapping copyPolicyMapping = new XMLCompositeObjectMapping();
copyPolicyMapping.setAttributeName("copyPolicy");
copyPolicyMapping.setGetMethodName("getCopyPolicy");
copyPolicyMapping.setSetMethodName("setCopyPolicy");
copyPolicyMapping.setReferenceClass(AbstractCopyPolicy.class);
copyPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "copying");
descriptor.addMapping(copyPolicyMapping);
XMLCompositeCollectionMapping queryKeysMapping = new XMLCompositeCollectionMapping();
queryKeysMapping.setAttributeName("queryKeys");
queryKeysMapping.setReferenceClass(QueryKey.class);
queryKeysMapping.setXPath(getPrimaryNamespaceXPath() + "query-keys/" + getPrimaryNamespaceXPath() + "query-key");
queryKeysMapping.setSetMethodName("setQueryKeys");
queryKeysMapping.setGetMethodName("getQueryKeys");
queryKeysMapping.useMapClass(HashMap.class, "getName");
descriptor.addMapping(queryKeysMapping);
XMLCompositeObjectMapping cmpPolicyMapping = new XMLCompositeObjectMapping();
cmpPolicyMapping.setAttributeName("cmpPolicy");
cmpPolicyMapping.setGetMethodName("getCMPPolicy");
cmpPolicyMapping.setSetMethodName("setCMPPolicy");
cmpPolicyMapping.setReferenceClass(CMPPolicy.class);
cmpPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "cmp-policy");
descriptor.addMapping(cmpPolicyMapping);
XMLCompositeObjectMapping fetchGroupManagerMapping = new XMLCompositeObjectMapping();
fetchGroupManagerMapping.setAttributeName("fetchGroupManager");
fetchGroupManagerMapping.setGetMethodName("getFetchGroupManager");
fetchGroupManagerMapping.setSetMethodName("setFetchGroupManager");
fetchGroupManagerMapping.setReferenceClass(FetchGroupManager.class);
fetchGroupManagerMapping.setXPath(getPrimaryNamespaceXPath() + "fetch-groups");
descriptor.addMapping(fetchGroupManagerMapping);
XMLCompositeObjectMapping changePolicyMapping = new XMLCompositeObjectMapping();
changePolicyMapping.setAttributeName("changePolicy");
changePolicyMapping.setReferenceClass(ObjectChangePolicy.class);
changePolicyMapping.setXPath(getPrimaryNamespaceXPath() + "change-policy");
descriptor.addMapping(changePolicyMapping);
XMLCompositeCollectionMapping propertiesMapping = new XMLCompositeCollectionMapping();
propertiesMapping.setAttributeName("properties");
propertiesMapping.setReferenceClass(PropertyAssociation.class);
propertiesMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object) {
ClassDescriptor desc = (ClassDescriptor) object;
List<PropertyAssociation> propertyAssociations = new ArrayList<>();
for (Iterator<Map.Entry<?, ?>> i = desc.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) {
ClassDescriptor desc = (ClassDescriptor) object;
@SuppressWarnings({ "unchecked" }) List<PropertyAssociation> propertyAssociations = (List<PropertyAssociation>) value;
for (int i = 0; i < propertyAssociations.size(); i++) {
PropertyAssociation propertyAssociation = propertyAssociations.get(i);
desc.getProperties().put(propertyAssociation.getKey(), propertyAssociation.getValue());
}
}
});
propertiesMapping.setXPath(getSecondaryNamespaceXPath() + "properties/" + getSecondaryNamespaceXPath() + "property");
descriptor.addMapping(propertiesMapping);
return descriptor;
}
Aggregations