Search in sources :

Example 26 with XMLField

use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.

the class ObjectPersistenceRuntimeXMLProject method buildInheritancePolicyDescriptor.

protected ClassDescriptor buildInheritancePolicyDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(InheritancePolicy.class);
    descriptor.setDefaultRootElement("inheritance-policy");
    descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
    descriptor.getInheritancePolicy().addClassIndicator(InheritancePolicy.class, getPrimaryNamespaceXPath() + "inheritance-policy");
    descriptor.getInheritancePolicy().addClassIndicator(QNameInheritancePolicy.class, getPrimaryNamespaceXPath() + "qname-inheritance-policy");
    descriptor.getInheritancePolicy().addClassIndicator(String.class, "string");
    XMLDirectMapping parentClassMapping = new XMLDirectMapping();
    parentClassMapping.setAttributeName("parentClass");
    parentClassMapping.setGetMethodName("getParentClass");
    parentClassMapping.setSetMethodName("setParentClass");
    parentClassMapping.setXPath(getSecondaryNamespaceXPath() + "parent-class/text()");
    descriptor.addMapping(parentClassMapping);
    XMLDirectMapping shouldReadSubclassesMapping = new XMLDirectMapping();
    shouldReadSubclassesMapping.setAttributeName("shouldReadSubclasses");
    shouldReadSubclassesMapping.setGetMethodName("shouldReadSubclassesValue");
    shouldReadSubclassesMapping.setSetMethodName("setShouldReadSubclasses");
    shouldReadSubclassesMapping.setXPath(getPrimaryNamespaceXPath() + "read-subclasses-on-queries/text()");
    descriptor.addMapping(shouldReadSubclassesMapping);
    XMLDirectMapping readAllSubclassesViewMapping = new XMLDirectMapping();
    readAllSubclassesViewMapping.setAttributeName("readAllSubclassesView");
    readAllSubclassesViewMapping.setGetMethodName("getReadAllSubclassesViewName");
    readAllSubclassesViewMapping.setSetMethodName("setReadAllSubclassesViewName");
    readAllSubclassesViewMapping.setXPath(getPrimaryNamespaceXPath() + "all-subclasses-view/text()");
    descriptor.addMapping(readAllSubclassesViewMapping);
    XMLDirectMapping shouldUseClassNameAsIndicatorMapping = new XMLDirectMapping();
    shouldUseClassNameAsIndicatorMapping.setAttributeName("shouldUseClassNameAsIndicator");
    shouldUseClassNameAsIndicatorMapping.setGetMethodName("shouldUseClassNameAsIndicator");
    shouldUseClassNameAsIndicatorMapping.setSetMethodName("setShouldUseClassNameAsIndicator");
    shouldUseClassNameAsIndicatorMapping.setXPath(getPrimaryNamespaceXPath() + "use-class-name-as-indicator/text()");
    shouldUseClassNameAsIndicatorMapping.setNullValue(Boolean.FALSE);
    descriptor.addMapping(shouldUseClassNameAsIndicatorMapping);
    XMLDirectMapping classExtractionMethodMapping = new XMLDirectMapping();
    classExtractionMethodMapping.setAttributeName("classExtractionMethod");
    classExtractionMethodMapping.setGetMethodName("getClassExtractionMethodName");
    classExtractionMethodMapping.setSetMethodName("setClassExtractionMethodName");
    classExtractionMethodMapping.setXPath(getPrimaryNamespaceXPath() + "class-extraction-method/text()");
    descriptor.addMapping(classExtractionMethodMapping);
    XMLCompositeObjectMapping classIndicatorFieldNameMapping = new XMLCompositeObjectMapping();
    classIndicatorFieldNameMapping.setAttributeName("classIndicatorField");
    classIndicatorFieldNameMapping.setReferenceClass(DatabaseField.class);
    classIndicatorFieldNameMapping.setGetMethodName("getClassIndicatorField");
    classIndicatorFieldNameMapping.setSetMethodName("setClassIndicatorField");
    classIndicatorFieldNameMapping.setXPath(getPrimaryNamespaceXPath() + "class-indicator-field");
    ((XMLField) classIndicatorFieldNameMapping.getField()).setLeafElementType(fieldQname);
    descriptor.addMapping(classIndicatorFieldNameMapping);
    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;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLCompositeCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Example 27 with XMLField

use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.

the class ObjectPersistenceRuntimeXMLProject method buildQueryKeyReferenceDescriptor.

protected ClassDescriptor buildQueryKeyReferenceDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(QueryKeyReference.class);
    descriptor.setDefaultRootElement("query-key-reference");
    XMLCompositeObjectMapping keyMapping = new XMLCompositeObjectMapping();
    keyMapping.setAttributeName("key");
    keyMapping.setGetMethodName("getKey");
    keyMapping.setSetMethodName("setKey");
    keyMapping.setReferenceClass(DatabaseField.class);
    keyMapping.setXPath(getPrimaryNamespaceXPath() + "source-field");
    ((XMLField) keyMapping.getField()).setLeafElementType(fieldQname);
    descriptor.addMapping(keyMapping);
    XMLDirectMapping valueMapping = new XMLDirectMapping();
    valueMapping.setAttributeName("value");
    valueMapping.setGetMethodName("getValue");
    valueMapping.setSetMethodName("setValue");
    valueMapping.setXPath(getPrimaryNamespaceXPath() + "target-query-key/text()");
    descriptor.addMapping(valueMapping);
    return descriptor;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Example 28 with XMLField

use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.

the class ObjectPersistenceRuntimeXMLProject method buildChangePolicyDescriptor.

protected ClassDescriptor buildChangePolicyDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(ObjectChangePolicy.class);
    descriptor.setDefaultRootElement("change-policy");
    descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
    descriptor.getInheritancePolicy().addClassIndicator(DeferredChangeDetectionPolicy.class, getPrimaryNamespaceXPath() + "deferred-detection-change-policy");
    descriptor.getInheritancePolicy().addClassIndicator(ObjectChangeTrackingPolicy.class, getPrimaryNamespaceXPath() + "object-level-change-policy");
    descriptor.getInheritancePolicy().addClassIndicator(AttributeChangeTrackingPolicy.class, getPrimaryNamespaceXPath() + "attribute-level-change-policy");
    return descriptor;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor)

Example 29 with XMLField

use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.

the class ObjectPersistenceRuntimeXMLProject method buildCacheInvalidationPolicyDescriptor.

protected ClassDescriptor buildCacheInvalidationPolicyDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(CacheInvalidationPolicy.class);
    descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
    descriptor.getInheritancePolicy().addClassIndicator(NoExpiryCacheInvalidationPolicy.class, getPrimaryNamespaceXPath() + "no-expiry-cache-invalidation-policy");
    descriptor.getInheritancePolicy().addClassIndicator(TimeToLiveCacheInvalidationPolicy.class, getPrimaryNamespaceXPath() + "time-to-live-cache-invalidation-policy");
    descriptor.getInheritancePolicy().addClassIndicator(DailyCacheInvalidationPolicy.class, getPrimaryNamespaceXPath() + "daily-cache-invalidation-policy");
    XMLDirectMapping updateOnReadMapping = new XMLDirectMapping();
    updateOnReadMapping.setAttributeName("shouldUpdateReadTimeOnUpdate");
    updateOnReadMapping.setGetMethodName("shouldUpdateReadTimeOnUpdate");
    updateOnReadMapping.setSetMethodName("setShouldUpdateReadTimeOnUpdate");
    updateOnReadMapping.setXPath(getPrimaryNamespaceXPath() + "update-read-time-on-update/text()");
    updateOnReadMapping.setNullValue(Boolean.FALSE);
    descriptor.addMapping(updateOnReadMapping);
    return descriptor;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping)

Example 30 with XMLField

use of org.eclipse.persistence.oxm.XMLField in project eclipselink by eclipse-ee4j.

the class ObjectPersistenceRuntimeXMLProject method buildAssociationDescriptor.

protected ClassDescriptor buildAssociationDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Association.class);
    descriptor.setDefaultRootElement("field-reference");
    XMLCompositeObjectMapping keyMapping = new XMLCompositeObjectMapping();
    keyMapping.setAttributeName("key");
    keyMapping.setGetMethodName("getKey");
    keyMapping.setSetMethodName("setKey");
    keyMapping.setXPath(getSecondaryNamespaceXPath() + "source-field");
    keyMapping.setReferenceClass(DatabaseField.class);
    ((XMLField) keyMapping.getField()).setLeafElementType(fieldQname);
    descriptor.addMapping(keyMapping);
    XMLCompositeObjectMapping valueMapping = new XMLCompositeObjectMapping();
    valueMapping.setAttributeName("value");
    valueMapping.setGetMethodName("getValue");
    valueMapping.setSetMethodName("setValue");
    valueMapping.setXPath(getSecondaryNamespaceXPath() + "target-field");
    valueMapping.setReferenceClass(DatabaseField.class);
    ((XMLField) valueMapping.getField()).setLeafElementType(fieldQname);
    descriptor.addMapping(valueMapping);
    return descriptor;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Aggregations

XMLField (org.eclipse.persistence.oxm.XMLField)302 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)141 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)99 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)48 QName (javax.xml.namespace.QName)43 Element (org.w3c.dom.Element)41 NodeList (org.w3c.dom.NodeList)39 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)36 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)30 ArrayList (java.util.ArrayList)27 Node (org.w3c.dom.Node)25 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)22 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)21 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)17 XMLRecord (org.eclipse.persistence.oxm.record.XMLRecord)17 XPathFragment (org.eclipse.persistence.internal.oxm.XPathFragment)15 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)15 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)15 AttributeAccessor (org.eclipse.persistence.mappings.AttributeAccessor)14 Field (org.eclipse.persistence.internal.oxm.mappings.Field)13