public void addEmployeeDescriptor(boolean methodAccess) { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Employee.class); descriptor.setDefaultRootElement("employee"); XMLDirectMapping idMapping = new XMLDirectMapping(); idMapping.setAttributeName("id"); idMapping.setXPath("@id"); descriptor.addMapping(idMapping); XMLDirectMapping firstNameMapping = new XMLDirectMapping(); firstNameMapping.setAttributeName("firstName"); firstNameMapping.setXPath("first-name/text()"); descriptor.addMapping(firstNameMapping); XMLDirectMapping lastNameMapping = new XMLDirectMapping(); lastNameMapping.setAttributeName("lastName"); lastNameMapping.setXPath("last-name/text()"); descriptor.addMapping(lastNameMapping); XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping(); addressMapping.setAttributeName("address"); addressMapping.setReferenceClass(Address.class); addressMapping.setXPath("address"); descriptor.addMapping(addressMapping); XMLCompositeCollectionMapping phoneMapping = new XMLCompositeCollectionMapping(); phoneMapping.setAttributeName("phoneNumbers"); phoneMapping.setReferenceClass(PhoneNumber.class); phoneMapping.setXPath("phone-numbers/number"); phoneMapping.setContainerPolicy(ContainerPolicy.buildPolicyFor(ArrayList.class)); descriptor.addMapping(phoneMapping); this.addDescriptor(descriptor); }
public XMLDescriptor addEmployeeDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Employee.class); descriptor.setDefaultRootElement("employee"); XMLCompositeObjectMapping addr = new XMLCompositeObjectMapping(); addr.setAttributeName("address"); addr.setXPath("address"); addr.setReferenceClass(Address.class); descriptor.addMapping(addr); XMLCompositeCollectionMapping phone = new XMLCompositeCollectionMapping(); phone.setAttributeName("phoneNumbers"); phone.setXPath("phone-number"); phone.setReferenceClass(PhoneNumber.class); phone.useCollectionClass(ArrayList.class); descriptor.addMapping(phone); XMLAnyObjectMapping object = new XMLAnyObjectMapping(); object.setAttributeName("anyObject"); object.setXPath("any-object"); descriptor.addMapping(object); XMLAnyCollectionMapping anyCollection = new XMLAnyCollectionMapping(); anyCollection.setAttributeName("anyCollection"); anyCollection.setXPath("any-collection"); anyCollection.useCollectionClass(ArrayList.class); descriptor.addMapping(anyCollection); this.addDescriptor(descriptor); return descriptor; }
protected XMLDescriptor getEmployeeDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Employee.class); // descriptor.setDefaultRootElement("employee"); XMLDirectMapping idMapping = new XMLDirectMapping(); idMapping.setXPath("id/text()"); idMapping.setAttributeName("id"); descriptor.addMapping(idMapping); XMLCompositeObjectMapping emailMapping = new XMLCompositeObjectMapping(); emailMapping.setAttributeName("emailAddress"); emailMapping.setXPath("info/email-address"); emailMapping.setGetMethodName("getEmailAddress"); emailMapping.setSetMethodName("setEmailAddress"); emailMapping.setReferenceClass(EmailAddress.class); descriptor.addMapping(emailMapping); URL schemaURL = ClassLoader.getSystemResource("org/eclipse/persistence/testing/oxm/jaxb/Employee.xsd"); XMLSchemaURLReference schemaRef = new XMLSchemaURLReference(schemaURL); schemaRef.setType(XMLSchemaURLReference.COMPLEX_TYPE); schemaRef.setSchemaContext("employee-root"); descriptor.setSchemaReference(schemaRef); /* NamespaceResolver try_test = new NamespaceResolver(); try_test.put("xsi", XMLConstants.SCHEMA_INSTANCE_URL); descriptor.setNamespaceResolver(try_test);*/ return descriptor; }
protected ClassDescriptor buildDocumentPreservationPolicyConfigDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(DocumentPreservationPolicyConfig.class); descriptor.setDefaultRootElement("document-preservation-policy"); XMLCompositeObjectMapping nodeOrderingPolicyMapping = new XMLCompositeObjectMapping(); nodeOrderingPolicyMapping.setReferenceClass(NodeOrderingPolicyConfig.class); nodeOrderingPolicyMapping.setAttributeName("m_nodeOrderingPolicy"); nodeOrderingPolicyMapping.setGetMethodName("getNodeOrderingPolicy"); nodeOrderingPolicyMapping.setSetMethodName("setNodeOrderingPolicy"); nodeOrderingPolicyMapping.setXPath("node-ordering-policy"); descriptor.addMapping(nodeOrderingPolicyMapping); descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type")); descriptor .getInheritancePolicy() .addClassIndicator( DescriptorLevelDocumentPreservationPolicyConfig.class, "descriptor-level-document-preservation-policy"); descriptor .getInheritancePolicy() .addClassIndicator( NoDocumentPreservationPolicyConfig.class, "no-document-preservation-policy"); descriptor .getInheritancePolicy() .addClassIndicator(XMLBinderPolicyConfig.class, "xml-binder-policy"); return descriptor; }
public XMLDescriptor getEmployeeDescriptor() { XMLDescriptor xmlDescriptor = new XMLDescriptor(); xmlDescriptor.setJavaClass(Employee.class); xmlDescriptor.setDefaultRootElement("employee"); XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping(); addressMapping.setReferenceClass(Address.class); addressMapping.setAttributeName("address"); addressMapping.setXPath("."); xmlDescriptor.addMapping(addressMapping); return xmlDescriptor; }
public static XMLDescriptor buildDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(MWMapContainerPolicy.class); descriptor.getInheritancePolicy().setParentClass(MWContainerPolicy.MWContainerPolicyRoot.class); XMLCompositeObjectMapping keyMethodHandleMapping = new XMLCompositeObjectMapping(); keyMethodHandleMapping.setAttributeName("keyMethodHandle"); keyMethodHandleMapping.setReferenceClass(MWMethodHandle.class); keyMethodHandleMapping.setSetMethodName("setKeyMethodHandleForTopLink"); keyMethodHandleMapping.setGetMethodName("getKeyMethodHandleForTopLink"); keyMethodHandleMapping.setXPath("key-method-handle"); descriptor.addMapping(keyMethodHandleMapping); XMLCompositeObjectMapping containerClassMapping = new XMLCompositeObjectMapping(); containerClassMapping.setAttributeName("containerClass"); containerClassMapping.setReferenceClass(DefaultingContainerClass.class); containerClassMapping.setXPath("container-class"); descriptor.addMapping(containerClassMapping); return descriptor; }
public static XMLDescriptor buildDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(ModelGroupDefinition.class); descriptor.getInheritancePolicy().setParentClass(AbstractNamedSchemaComponent.class); XMLCompositeObjectMapping modelGroupMapping = new XMLCompositeObjectMapping(); modelGroupMapping.setAttributeName("modelGroup"); modelGroupMapping.setReferenceClass(ExplicitModelGroup.class); modelGroupMapping.setXPath("model-group"); descriptor.addMapping(modelGroupMapping); return descriptor; }
public static XMLDescriptor buildDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(MWEisOneToManyMapping.class); descriptor.getInheritancePolicy().setParentClass(MWEisReferenceMapping.class); // use an object type mapping so we can preserve object identity ObjectTypeConverter foreignKeyLocationConverter = new ObjectTypeConverter(); foreignKeyLocationConverter.addConversionValue(KEYS_ON_TARGET, KEYS_ON_TARGET); foreignKeyLocationConverter.addConversionValue(KEYS_ON_SOURCE, KEYS_ON_SOURCE); XMLDirectMapping foreignKeyLocationMapping = new XMLDirectMapping(); foreignKeyLocationMapping.setAttributeName("foreignKeyLocation"); foreignKeyLocationMapping.setXPath("foreign-key-location/text()"); foreignKeyLocationMapping.setNullValue(KEYS_ON_SOURCE); foreignKeyLocationMapping.setConverter(foreignKeyLocationConverter); descriptor.addMapping(foreignKeyLocationMapping); XMLCompositeObjectMapping groupingElementMapping = new XMLCompositeObjectMapping(); groupingElementMapping.setAttributeName("foreignKeyGroupingElement"); groupingElementMapping.setReferenceClass(MWXmlField.class); groupingElementMapping.setGetMethodName("getGroupingElementForTopLink"); groupingElementMapping.setSetMethodName("setGroupingElementForTopLink"); groupingElementMapping.setXPath("foreign-key-grouping-element"); descriptor.addMapping(groupingElementMapping); XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping(); containerPolicyMapping.setAttributeName("containerPolicy"); containerPolicyMapping.setReferenceClass(MWContainerPolicy.MWContainerPolicyRoot.class); containerPolicyMapping.setXPath("container-policy"); descriptor.addMapping(containerPolicyMapping); XMLCompositeObjectMapping deleteAllInteractionMapping = new XMLCompositeObjectMapping(); deleteAllInteractionMapping.setAttributeName("deleteAllInteraction"); deleteAllInteractionMapping.setReferenceClass(MWEisInteraction.class); deleteAllInteractionMapping.setXPath("delete-all-interaction"); descriptor.addMapping(deleteAllInteractionMapping); return descriptor; }
public void addEmployeeDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Employee.class); descriptor.setDefaultRootElement("employee"); XMLCompositeObjectMapping addr = new XMLCompositeObjectMapping(); addr.setAttributeName("primaryAddress"); addr.setXPath("primary-address"); addr.setReferenceClass(Address.class); addr.readOnly(); descriptor.addMapping(addr); this.addDescriptor(descriptor); }
public static XMLDescriptor buildDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(MWQueryableArgumentElement.class); XMLCompositeObjectMapping queryableHandleMapping = new XMLCompositeObjectMapping(); queryableHandleMapping.setAttributeName("queryableHandle"); queryableHandleMapping.setGetMethodName("getQueryableHandleForTopLink"); queryableHandleMapping.setSetMethodName("setQueryableHandleForTopLink"); queryableHandleMapping.setReferenceClass(MWQueryableHandle.class); queryableHandleMapping.setXPath("queryable-handle"); descriptor.addMapping(queryableHandleMapping); ((XMLDirectMapping) descriptor.addDirectMapping("allowsNull", "allows-null/text()")) .setNullValue(Boolean.FALSE); XMLCompositeObjectMapping joinedQueryableElementMapping = new XMLCompositeObjectMapping(); joinedQueryableElementMapping.setAttributeName("joinedQueryableElement"); joinedQueryableElementMapping.setReferenceClass(MWQueryableArgumentElement.class); joinedQueryableElementMapping.setXPath("joined-queryable-element"); descriptor.addMapping(joinedQueryableElementMapping); return descriptor; }
// **************** TopLink Methods ***************** @SuppressWarnings("deprecation") public static XMLDescriptor buildDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(MWAbstractXmlDirectCollectionMapping.class); descriptor.getInheritancePolicy().setParentClass(MWDirectContainerMapping.class); XMLCompositeObjectMapping xmlFieldMapping = new XMLCompositeObjectMapping(); xmlFieldMapping.setReferenceClass(MWXmlField.class); xmlFieldMapping.setAttributeName("xmlField"); xmlFieldMapping.setGetMethodName("getXmlFieldForTopLink"); xmlFieldMapping.setSetMethodName("setXmlFieldForTopLink"); xmlFieldMapping.setXPath("xpath"); descriptor.addMapping(xmlFieldMapping); XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping(); containerPolicyMapping.setAttributeName("containerPolicy"); containerPolicyMapping.setReferenceClass(MWContainerPolicy.MWContainerPolicyRoot.class); containerPolicyMapping.setGetMethodName("getContainerPolicyForToplink"); containerPolicyMapping.setSetMethodName("setContainerPolicyForToplink"); containerPolicyMapping.setXPath("container-policy"); descriptor.addMapping(containerPolicyMapping); return descriptor; }
public static XMLDescriptor buildDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(MWDirectContainerMapping.class); descriptor.getInheritancePolicy().setParentClass(MWMapping.class); XMLCompositeObjectMapping converterMapping = new XMLCompositeObjectMapping(); converterMapping.setReferenceClass(MWConverter.class); converterMapping.setAttributeName("directValueConverter"); converterMapping.setGetMethodName("getConverterForTopLink"); converterMapping.setSetMethodName("setConverterForTopLink"); converterMapping.setXPath("direct-value-converter"); descriptor.addMapping(converterMapping); return descriptor; }
private XMLDescriptor getCustomerDescriptor() { XMLDescriptor xmlDescriptor = new XMLDescriptor(); xmlDescriptor.setJavaClass(Customer.class); xmlDescriptor.setDefaultRootElement("ns:customer"); NamespaceResolver nsResolver = new NamespaceResolver(); nsResolver.put("ns", "urn:example"); xmlDescriptor.setNamespaceResolver(nsResolver); XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping(); addressMapping.setAttributeName("address"); addressMapping.setXPath("//ns:customer/ns:phone-number/preceding-sibling::*[1]"); addressMapping.setReferenceClass(Address.class); xmlDescriptor.addMapping(addressMapping); return xmlDescriptor; }
public ClassDescriptor buildWrapperDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Wrapper.class); descriptor.setDefaultRootElement("myns:wrapper"); XMLCompositeObjectMapping mapping = new XMLCompositeObjectMapping(); mapping.setReferenceClass(Root.class); mapping.setAttributeName("theRoot"); mapping.setXPath("myns:root"); descriptor.addMapping(mapping); NamespaceResolver nr = new NamespaceResolver(); nr.put("myns", "www.example.com/some-dir/some.xsd"); nr.put("ns0", "www.example.com/test.xsd"); descriptor.setNamespaceResolver(nr); return descriptor; }
private XMLDescriptor getRootDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Root.class); descriptor.setDefaultRootElement("root"); // create employee mapping XMLCompositeObjectMapping empMapping = new XMLCompositeObjectMapping(); empMapping.setAttributeName("employee"); empMapping.setXPath("employee"); empMapping.setReferenceClass(Employee.class); descriptor.addMapping(empMapping); // create address mapping XMLCompositeCollectionMapping addMapping = new XMLCompositeCollectionMapping(); addMapping.setAttributeName("addresses"); addMapping.setXPath("address"); addMapping.setReferenceClass(Address.class); descriptor.addMapping(addMapping); return descriptor; }
// Persistence public static XMLDescriptor buildDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(MWLiteralArgument.class); descriptor.getInheritancePolicy().setParentClass(MWArgument.class); // 1:1 - type XMLCompositeObjectMapping typeMapping = new XMLCompositeObjectMapping(); typeMapping.setAttributeName("type"); typeMapping.setReferenceClass(MWTypeDeclaration.class); typeMapping.setXPath("type"); descriptor.addMapping(typeMapping); // DTF Object value XMLDirectMapping valueMapping = (XMLDirectMapping) descriptor.addDirectMapping("value", "value/text()"); valueMapping.setNullValue(""); return descriptor; }
public static XMLDescriptor legacy60BuildDescriptor() { XMLDescriptor descriptor = MWModel.legacy60BuildStandardDescriptor(); descriptor.setJavaClass(MWTypeDeclaration.class); // 'type' will never be null XMLCompositeObjectMapping typeHandleMapping = new XMLCompositeObjectMapping(); typeHandleMapping.setAttributeName("typeHandle"); typeHandleMapping.setReferenceClass(MWClassHandle.class); typeHandleMapping.setGetMethodName("getTypeHandleForTopLink"); typeHandleMapping.setSetMethodName("setTypeHandleForTopLink"); typeHandleMapping.setXPath("type-handle"); descriptor.addMapping(typeHandleMapping); XMLDirectMapping dimMapping = (XMLDirectMapping) descriptor.addDirectMapping("dimensionality", "dimensionality/text()"); dimMapping.setNullValue(new Integer(0)); return descriptor; }
public ClassDescriptor buildXMLLoginConfigDescriptor() { ClassDescriptor descriptor = super.buildXMLLoginConfigDescriptor(); XMLDirectMapping equalNamespaceResolversMapping = new XMLDirectMapping(); equalNamespaceResolversMapping.setAttributeName("m_equalNamespaceResolvers"); equalNamespaceResolversMapping.setGetMethodName("getEqualNamespaceResolvers"); equalNamespaceResolversMapping.setSetMethodName("setEqualNamespaceResolvers"); equalNamespaceResolversMapping.setXPath("equal-namespace-resolvers/text()"); equalNamespaceResolversMapping.setNullValue(Boolean.TRUE); descriptor.addMapping(equalNamespaceResolversMapping); XMLCompositeObjectMapping documentPreservationPolicyMapping = new XMLCompositeObjectMapping(); documentPreservationPolicyMapping.setReferenceClass(DocumentPreservationPolicyConfig.class); documentPreservationPolicyMapping.setAttributeName("m_documentPreservationPolicy"); documentPreservationPolicyMapping.setGetMethodName("getDocumentPreservationPolicy"); documentPreservationPolicyMapping.setSetMethodName("setDocumentPreservationPolicy"); documentPreservationPolicyMapping.setXPath("document-preservation-policy"); descriptor.addMapping(documentPreservationPolicyMapping); return descriptor; }
public static XMLDescriptor buildDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(MWEisLoginSpec.class); descriptor.addDirectMapping("name", "name/text()"); descriptor.addDirectMapping( "j2cAdapterName", "getJ2CAdapterNameForTopLink", "setJ2CAdapterNameForTopLink", "j2c-adapter-name/text()"); descriptor.addDirectMapping("userName", "user-name/text()"); descriptor.addDirectMapping( "password", "getPasswordForTopLink", "setPasswordForTopLink", "password/text()"); descriptor.addDirectMapping("connectionFactoryUrl", "connection-factory-url/text()"); ((XMLDirectMapping) descriptor.addDirectMapping("savePassword", "save-password/text()")) .setNullValue(Boolean.FALSE); XMLCompositeObjectMapping connectionSpecClassHandleMapping = new XMLCompositeObjectMapping(); connectionSpecClassHandleMapping.setAttributeName("connectionSpecClassHandle"); connectionSpecClassHandleMapping.setGetMethodName("getConnectionSpecClassHandleForTopLink"); connectionSpecClassHandleMapping.setSetMethodName("setConnectionSpecClassHandleForTopLink"); connectionSpecClassHandleMapping.setReferenceClass(MWClassHandle.class); connectionSpecClassHandleMapping.setXPath("connection-spec-class-handle"); descriptor.addMapping(connectionSpecClassHandleMapping); XMLCompositeCollectionMapping propertiesMapping = new XMLCompositeCollectionMapping(); propertiesMapping.setReferenceClass(MWProperty.class); propertiesMapping.setAttributeName("properties"); propertiesMapping.setGetMethodName("getPropertiesForTopLink"); propertiesMapping.setSetMethodName("setPropertiesForTopLink"); propertiesMapping.setXPath("property"); descriptor.addMapping(propertiesMapping); return descriptor; }