Search in sources :

Example 6 with XMLCompositeDirectCollectionMapping

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

the class OXDescriptorTestSuite method tbl2Asserts.

protected void tbl2Asserts(XMLDescriptor tbl2Descriptor) {
    assertTrue("Wrong Java class name.  Expected [" + TBL2_DESCRIPTOR_JAVACLASSNAME + "] but was [" + tbl2Descriptor.getJavaClassName() + "]", tbl2Descriptor.getJavaClassName().equals(TBL2_DESCRIPTOR_JAVACLASSNAME));
    Vector<DatabaseMapping> mappings = tbl2Descriptor.getMappings();
    assertTrue("Wrong number of mappings.  Expected [1] but was [" + mappings.size() + "]", mappings.size() == 1);
    DatabaseMapping mapping = mappings.get(0);
    assertTrue("Incorrect mapping attribute name.  Expected [" + BaseDBWSBuilderHelper.ITEMS_MAPPING_ATTRIBUTE_NAME + "] but was [" + mapping.getAttributeName() + "]", mapping.getAttributeName().equals(BaseDBWSBuilderHelper.ITEMS_MAPPING_ATTRIBUTE_NAME));
    assertTrue("Incorrect mapping type.  Expected [(XML) AbstractCompositeDirectCollection mapping], but was [" + mapping.getClass().getName() + "]", mapping.isXMLMapping() && mapping.isAbstractCompositeDirectCollectionMapping());
    XMLCompositeDirectCollectionMapping xdcm = (XMLCompositeDirectCollectionMapping) mapping;
    assertTrue("Incorrect mapping XPath.  Expected [item/text()] but was [" + xdcm.getXPath() + "]", xdcm.getXPath().equals("item/text()"));
    assertTrue("Wrong component class for mapping.  Expected [" + BigDecimal.class + "] but was [" + xdcm.getAttributeElementClass() + "]", xdcm.getAttributeElementClass().equals(BigDecimal.class));
}
Also used : DatabaseMapping(org.eclipse.persistence.mappings.DatabaseMapping) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping) BigDecimal(java.math.BigDecimal)

Example 7 with XMLCompositeDirectCollectionMapping

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

the class OXDescriptorTestSuite method tbl1Asserts.

// ASSERT METHODS
protected void tbl1Asserts(XMLDescriptor tbl1Descriptor) {
    assertTrue("Wrong Java class name.  Expected [" + TBL1_DESCRIPTOR_JAVACLASSNAME + "] but was [" + tbl1Descriptor.getJavaClassName() + "]", tbl1Descriptor.getJavaClassName().equals(TBL1_DESCRIPTOR_JAVACLASSNAME));
    Vector<DatabaseMapping> mappings = tbl1Descriptor.getMappings();
    assertTrue("Wrong number of mappings.  Expected [1] but was [" + mappings.size() + "]", mappings.size() == 1);
    DatabaseMapping mapping = mappings.get(0);
    assertTrue("Incorrect mapping attribute name.  Expected [" + BaseDBWSBuilderHelper.ITEMS_MAPPING_ATTRIBUTE_NAME + "] but was [" + mapping.getAttributeName() + "]", mapping.getAttributeName().equals(BaseDBWSBuilderHelper.ITEMS_MAPPING_ATTRIBUTE_NAME));
    assertTrue("Incorrect mapping type.  Expected [(XML) AbstractCompositeDirectCollection mapping], but was [" + mapping.getClass().getName() + "]", mapping.isXMLMapping() && mapping.isAbstractCompositeDirectCollectionMapping());
    XMLCompositeDirectCollectionMapping xdcm = (XMLCompositeDirectCollectionMapping) mapping;
    assertTrue("Incorrect mapping XPath.  Expected [item/text()] but was [" + xdcm.getXPath() + "]", xdcm.getXPath().equals("item/text()"));
    assertTrue("Wrong component class for mapping.  Expected [" + String.class + "] but was [" + xdcm.getAttributeElementClass() + "]", xdcm.getAttributeElementClass().equals(String.class));
}
Also used : DatabaseMapping(org.eclipse.persistence.mappings.DatabaseMapping) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)

Example 8 with XMLCompositeDirectCollectionMapping

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

the class OXDescriptorTestSuite method aRecordAsserts.

protected void aRecordAsserts(XMLDescriptor aRecordDescriptor) {
    assertTrue("Wrong Java class name.  Expected [" + ARECORD_DESCRIPTOR_JAVACLASSNAME + "] but was [" + aRecordDescriptor.getJavaClassName() + "]", aRecordDescriptor.getJavaClassName().equals(ARECORD_DESCRIPTOR_JAVACLASSNAME));
    Vector<DatabaseMapping> mappings = aRecordDescriptor.getMappings();
    assertTrue("Wrong number of mappings.  Expected [3] but was [" + mappings.size() + "]", mappings.size() == 3);
    DatabaseMapping dm1 = mappings.get(0);
    assertTrue("Incorrect mapping attribute name.  Expected [t1] but was [" + dm1.getAttributeName() + "]", dm1.getAttributeName().equals("t1"));
    assertTrue("Incorrect mapping type.  Expected [(XML) AbstractCompositeDirectCollection mapping] but was [" + dm1.getClass().getName() + "]", dm1.isXMLMapping() && dm1.isAbstractCompositeDirectCollectionMapping());
    XMLCompositeDirectCollectionMapping xcom1 = (XMLCompositeDirectCollectionMapping) dm1;
    assertTrue("Incorrect mapping XPath.  Expected [t1/item/text()] but was [" + xcom1.getXPath() + "]", xcom1.getXPath().equals("t1/item/text()"));
    assertTrue("Incorrect attribute element class.  Expected [" + String.class + "] but was [" + xcom1.getAttributeElementClass() + "]", xcom1.getAttributeElementClass().equals(String.class));
    DatabaseMapping dm2 = mappings.get(1);
    assertTrue("Incorrect mapping attribute name.  Expected [t2] but was [" + dm2.getAttributeName() + "]", dm2.getAttributeName().equals("t2"));
    assertTrue("Incorrect mapping type.  Expected [(XML) AbstractCompositeDirectCollection mapping ]but was [" + dm2.getClass().getName() + "]", dm2.isXMLMapping() && dm2.isAbstractCompositeDirectCollectionMapping());
    XMLCompositeDirectCollectionMapping xcom2 = (XMLCompositeDirectCollectionMapping) dm2;
    assertTrue("Incorrect mapping XPath.  Expected [t2/item/text()] but was [" + xcom2.getXPath() + "]", xcom2.getXPath().equals("t2/item/text()"));
    assertTrue("Incorrect attribute element class.  Expected [" + BigDecimal.class + "] but was [" + xcom2.getAttributeElementClass() + "]", xcom2.getAttributeElementClass().equals(BigDecimal.class));
    DatabaseMapping dm3 = mappings.get(2);
    assertTrue("Incorrect mapping attribute name.  Expected [t3] but was [" + dm3.getAttributeName() + "]", dm3.getAttributeName().equals("t3"));
    assertTrue("Incorrect mapping type.  Expected [(XML) DirectToField mapping] but was [" + dm3.getClass().getName() + "]", dm3.isXMLMapping() && dm3.isDirectToFieldMapping());
    assertTrue("Incorrect mapping XPath.  Expected [t3/text()] but was [" + ((XMLDirectMapping) dm3).getXPath() + "]", ((XMLDirectMapping) dm3).getXPath().equals("t3/text()"));
}
Also used : XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) DatabaseMapping(org.eclipse.persistence.mappings.DatabaseMapping) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping) BigDecimal(java.math.BigDecimal)

Example 9 with XMLCompositeDirectCollectionMapping

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

the class OracleHelper method buildXMLCompositeDirectCollectionMapping.

/**
 * Build an XMLCompositeDirectCollectionMapping based on a given attribute name, xpath,
 * and attribute element class.
 */
protected XMLCompositeDirectCollectionMapping buildXMLCompositeDirectCollectionMapping(String attributeName, String xPath, Class<?> attributeElementClass) {
    XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping();
    itemsMapping.setAttributeElementClass(attributeElementClass);
    itemsMapping.setAttributeName(attributeName);
    itemsMapping.setUsesSingleNode(true);
    itemsMapping.setXPath(xPath);
    ((XMLField) itemsMapping.getField()).setRequired(true);
    itemsMapping.useCollectionClass(ArrayList.class);
    AbstractNullPolicy nullPolicy = itemsMapping.getNullPolicy();
    nullPolicy.setNullRepresentedByEmptyNode(false);
    nullPolicy.setMarshalNullRepresentation(XSI_NIL);
    nullPolicy.setNullRepresentedByXsiNil(true);
    itemsMapping.setNullPolicy(nullPolicy);
    return itemsMapping;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) AbstractNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)

Example 10 with XMLCompositeDirectCollectionMapping

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

the class ObjectPersistenceRuntimeXMLProject method buildEventManagerDescriptor.

protected ClassDescriptor buildEventManagerDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(DescriptorEventManager.class);
    descriptor.setDefaultRootElement("event-policy");
    descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
    descriptor.getInheritancePolicy().addClassIndicator(DescriptorEventManager.class, getPrimaryNamespaceXPath() + "event-policy");
    XMLCompositeDirectCollectionMapping eventListenersMapping = new XMLCompositeDirectCollectionMapping();
    eventListenersMapping.setAttributeName("eventListeners");
    eventListenersMapping.setGetMethodName("getEventListeners");
    eventListenersMapping.setSetMethodName("setEventListeners");
    eventListenersMapping.useCollectionClass(org.eclipse.persistence.internal.helper.NonSynchronizedVector.class);
    eventListenersMapping.setValueConverter(new ClassInstanceConverter());
    eventListenersMapping.setXPath(getSecondaryNamespaceXPath() + "event-listeners/" + getSecondaryNamespaceXPath() + "event-listener/text()");
    descriptor.addMapping(eventListenersMapping);
    XMLDirectMapping postBuildSelectorMapping = new XMLDirectMapping();
    postBuildSelectorMapping.setAttributeName("getPostBuildSelector");
    postBuildSelectorMapping.setGetMethodName("getPostBuildSelector");
    postBuildSelectorMapping.setSetMethodName("setPostBuildSelector");
    postBuildSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "post-build-method/text()");
    descriptor.addMapping(postBuildSelectorMapping);
    XMLDirectMapping preWriteSelectorMapping = new XMLDirectMapping();
    preWriteSelectorMapping.setAttributeName("preWriteSelector");
    preWriteSelectorMapping.setGetMethodName("getPreWriteSelector");
    preWriteSelectorMapping.setSetMethodName("setPreWriteSelector");
    preWriteSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "pre-write-method/text()");
    descriptor.addMapping(preWriteSelectorMapping);
    XMLDirectMapping postWriteSelectorMapping = new XMLDirectMapping();
    postWriteSelectorMapping.setAttributeName("postWriteSelector");
    postWriteSelectorMapping.setGetMethodName("getPostWriteSelector");
    postWriteSelectorMapping.setSetMethodName("setPostWriteSelector");
    postWriteSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "post-write-method/text()");
    descriptor.addMapping(postWriteSelectorMapping);
    XMLDirectMapping preInsertSelectorMapping = new XMLDirectMapping();
    preInsertSelectorMapping.setAttributeName("preInsertSelector");
    preInsertSelectorMapping.setGetMethodName("getPreInsertSelector");
    preInsertSelectorMapping.setSetMethodName("setPreInsertSelector");
    preInsertSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "pre-insert-method/text()");
    descriptor.addMapping(preInsertSelectorMapping);
    XMLDirectMapping postInsertSelectorMapping = new XMLDirectMapping();
    postInsertSelectorMapping.setAttributeName("postInsertSelector");
    postInsertSelectorMapping.setGetMethodName("getPostInsertSelector");
    postInsertSelectorMapping.setSetMethodName("setPostInsertSelector");
    postInsertSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "post-insert-method/text()");
    descriptor.addMapping(postInsertSelectorMapping);
    XMLDirectMapping preUpdateSelectorMapping = new XMLDirectMapping();
    preUpdateSelectorMapping.setAttributeName("preUpdateSelector");
    preUpdateSelectorMapping.setGetMethodName("getPreUpdateSelector");
    preUpdateSelectorMapping.setSetMethodName("setPreUpdateSelector");
    preUpdateSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "pre-update-method/text()");
    descriptor.addMapping(preUpdateSelectorMapping);
    XMLDirectMapping postUpdateSelectorMapping = new XMLDirectMapping();
    postUpdateSelectorMapping.setAttributeName("postUpdateSelector");
    postUpdateSelectorMapping.setGetMethodName("getPostUpdateSelector");
    postUpdateSelectorMapping.setSetMethodName("setPostUpdateSelector");
    postUpdateSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "post-update-method/text()");
    descriptor.addMapping(postUpdateSelectorMapping);
    XMLDirectMapping preDeleteSelectorMapping = new XMLDirectMapping();
    preDeleteSelectorMapping.setAttributeName("preDeleteSelector");
    preDeleteSelectorMapping.setGetMethodName("getPreDeleteSelector");
    preDeleteSelectorMapping.setSetMethodName("setPreDeleteSelector");
    preDeleteSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "pre-delete-method/text()");
    descriptor.addMapping(preDeleteSelectorMapping);
    XMLDirectMapping postDeleteSelectorMapping = new XMLDirectMapping();
    postDeleteSelectorMapping.setAttributeName("postDeleteSelector");
    postDeleteSelectorMapping.setGetMethodName("getPostDeleteSelector");
    postDeleteSelectorMapping.setSetMethodName("setPostDeleteSelector");
    postDeleteSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "post-delete-method/text()");
    descriptor.addMapping(postDeleteSelectorMapping);
    XMLDirectMapping aboutToInsertSelectorMapping = new XMLDirectMapping();
    aboutToInsertSelectorMapping.setAttributeName("aboutToInsertSelector");
    aboutToInsertSelectorMapping.setGetMethodName("getAboutToInsertSelector");
    aboutToInsertSelectorMapping.setSetMethodName("setAboutToInsertSelector");
    aboutToInsertSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "about-to-insert-method/text()");
    descriptor.addMapping(aboutToInsertSelectorMapping);
    XMLDirectMapping aboutToUpdateSelectorMapping = new XMLDirectMapping();
    aboutToUpdateSelectorMapping.setAttributeName("aboutToUpdateSelector");
    aboutToUpdateSelectorMapping.setGetMethodName("getAboutToUpdateSelector");
    aboutToUpdateSelectorMapping.setSetMethodName("setAboutToUpdateSelector");
    aboutToUpdateSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "about-to-update-method/text()");
    descriptor.addMapping(aboutToUpdateSelectorMapping);
    XMLDirectMapping postCloneSelectorMapping = new XMLDirectMapping();
    postCloneSelectorMapping.setAttributeName("postCloneSelector");
    postCloneSelectorMapping.setGetMethodName("getPostCloneSelector");
    postCloneSelectorMapping.setSetMethodName("setPostCloneSelector");
    postCloneSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "post-clone-method/text()");
    descriptor.addMapping(postCloneSelectorMapping);
    XMLDirectMapping postMergeSelectorMapping = new XMLDirectMapping();
    postMergeSelectorMapping.setAttributeName("postMergeSelector");
    postMergeSelectorMapping.setGetMethodName("getPostMergeSelector");
    postMergeSelectorMapping.setSetMethodName("setPostMergeSelector");
    postMergeSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "post-merge-method/text()");
    descriptor.addMapping(postMergeSelectorMapping);
    XMLDirectMapping postRefreshSelectorMapping = new XMLDirectMapping();
    postRefreshSelectorMapping.setAttributeName("getPostRefreshSelector");
    postRefreshSelectorMapping.setGetMethodName("getPostRefreshSelector");
    postRefreshSelectorMapping.setSetMethodName("setPostRefreshSelector");
    postRefreshSelectorMapping.setXPath(getPrimaryNamespaceXPath() + "post-refresh-method/text()");
    descriptor.addMapping(postRefreshSelectorMapping);
    return descriptor;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping) ClassInstanceConverter(org.eclipse.persistence.mappings.converters.ClassInstanceConverter)

Aggregations

XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)63 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)49 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)40 XMLField (org.eclipse.persistence.oxm.XMLField)14 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)11 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)11 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)10 QName (javax.xml.namespace.QName)6 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)6 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)3 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)3 JAXBException (org.eclipse.persistence.exceptions.JAXBException)3 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)3 JAXBArrayAttributeAccessor (org.eclipse.persistence.internal.jaxb.many.JAXBArrayAttributeAccessor)3 Field (org.eclipse.persistence.internal.oxm.mappings.Field)3 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)3 BigDecimal (java.math.BigDecimal)2 CoreDescriptor (org.eclipse.persistence.core.descriptors.CoreDescriptor)2 CoreMapping (org.eclipse.persistence.core.mappings.CoreMapping)2 CoreConverter (org.eclipse.persistence.core.mappings.converters.CoreConverter)2