Search in sources :

Example 11 with XMLSchemaClassPathReference

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

the class ObjectPersistenceRuntimeXMLProject_11_1_1 method buildProjectDescriptor.

@Override
protected ClassDescriptor buildProjectDescriptor() {
    XMLDescriptor descriptor = (XMLDescriptor) super.buildProjectDescriptor();
    descriptor.setSchemaReference(new XMLSchemaClassPathReference(SCHEMA_DIR + TOPLINK_11_SCHEMA));
    XMLDirectMapping defaultTemporalMutableMapping = new XMLDirectMapping();
    defaultTemporalMutableMapping.setAttributeName("defaultTemporalMutable");
    defaultTemporalMutableMapping.setSetMethodName("setDefaultTemporalMutable");
    defaultTemporalMutableMapping.setGetMethodName("getDefaultTemporalMutable");
    defaultTemporalMutableMapping.setXPath(getSecondaryNamespaceXPath() + "default-temporal-mutable/text()");
    defaultTemporalMutableMapping.setNullValue(Boolean.FALSE);
    descriptor.addMapping(defaultTemporalMutableMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 12 with XMLSchemaClassPathReference

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

the class ObjectPersistenceRuntimeXMLProject method buildProjectDescriptor.

protected ClassDescriptor buildProjectDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Project.class);
    descriptor.setDefaultRootElement(getPrimaryNamespaceXPath() + "object-persistence");
    descriptor.setSchemaReference(new XMLSchemaClassPathReference(SCHEMA_DIR + TOPLINK_10_SCHEMA));
    XMLTransformationMapping versionMapping = new XMLTransformationMapping();
    versionMapping.addFieldTransformer("@version", getConstantTransformerForProjectVersionMapping());
    descriptor.addMapping(versionMapping);
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setSetMethodName("setName");
    nameMapping.setGetMethodName("getName");
    nameMapping.setXPath(getSecondaryNamespaceXPath() + "name/text()");
    descriptor.addMapping(nameMapping);
    XMLCompositeCollectionMapping descriptorsMapping = new XMLCompositeCollectionMapping();
    descriptorsMapping.useCollectionClass(NonSynchronizedVector.class);
    descriptorsMapping.setAttributeName("descriptors");
    descriptorsMapping.setSetMethodName("setOrderedDescriptors");
    descriptorsMapping.setGetMethodName("getOrderedDescriptors");
    descriptorsMapping.setReferenceClass(ClassDescriptor.class);
    descriptorsMapping.setXPath(getSecondaryNamespaceXPath() + "class-mapping-descriptors/" + getSecondaryNamespaceXPath() + "class-mapping-descriptor");
    descriptor.addMapping(descriptorsMapping);
    XMLCompositeObjectMapping loginMapping = new XMLCompositeObjectMapping();
    loginMapping.setSetMethodName("setDatasourceLogin");
    loginMapping.setGetMethodName("getDatasourceLogin");
    loginMapping.setAttributeName("login");
    loginMapping.setReferenceClass(DatasourceLogin.class);
    loginMapping.setXPath(getPrimaryNamespaceXPath() + "login");
    descriptor.addMapping(loginMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLCompositeCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping) XMLTransformationMapping(org.eclipse.persistence.oxm.mappings.XMLTransformationMapping) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Example 13 with XMLSchemaClassPathReference

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

the class ObjectPersistenceRuntimeXMLProject method buildDatabaseFieldDescriptor.

protected ClassDescriptor buildDatabaseFieldDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(DatabaseField.class);
    descriptor.setDefaultRootElement("field");
    descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
    descriptor.getInheritancePolicy().addClassIndicator(DatabaseField.class, getSecondaryNamespaceXPath() + "column");
    descriptor.getInheritancePolicy().addClassIndicator(XMLField.class, getPrimaryNamespaceXPath() + "node");
    descriptor.getInheritancePolicy().addClassIndicator(XMLUnionField.class, getPrimaryNamespaceXPath() + "union-node");
    XMLSchemaReference reference = new XMLSchemaClassPathReference();
    reference.setSchemaContext("/" + getSecondaryNamespaceXPath() + "column");
    descriptor.setSchemaReference(reference);
    XMLDirectMapping tableMapping = new XMLDirectMapping();
    tableMapping.setAttributeName("table");
    tableMapping.setGetMethodName("getTableName");
    tableMapping.setSetMethodName("setTableName");
    tableMapping.setXPath("@table");
    tableMapping.setNullValue("");
    descriptor.addMapping(tableMapping);
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setGetMethodName("getName");
    nameMapping.setSetMethodName("setName");
    nameMapping.setXPath("@name");
    nameMapping.getNullPolicy().setNullRepresentedByEmptyNode(false);
    descriptor.addMapping(nameMapping);
    return descriptor;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaReference(org.eclipse.persistence.oxm.schema.XMLSchemaReference) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 14 with XMLSchemaClassPathReference

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

the class ExtraNamespacesBug6004272Project method getManagerDescriptor.

private XMLDescriptor getManagerDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Manager.class);
    xmlDescriptor.setDefaultRootElement("ns3:manager");
    xmlDescriptor.getInheritancePolicy().setParentClass(Employee.class);
    XMLDirectMapping titleMapping = new XMLDirectMapping();
    titleMapping.setAttributeName("title");
    titleMapping.setXPath("ns3:title/text()");
    xmlDescriptor.addMapping(titleMapping);
    XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
    ref.setSchemaContext("/ns2:manager-type");
    ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
    xmlDescriptor.setSchemaReference(ref);
    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("ns3", "http://www.example.com/ns3");
    nsResolver.put("ns2", "http://www.example.com/ns2");
    nsResolver.put("ns4", "http://www.example.com/ns4");
    nsResolver.put("ns7", "http://www.example.com/ns7");
    nsResolver.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    xmlDescriptor.setNamespaceResolver(nsResolver);
    return xmlDescriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 15 with XMLSchemaClassPathReference

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

the class ExtraNamespacesBug6004272Project method getTeamDescriptor.

private XMLDescriptor getTeamDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Team.class);
    xmlDescriptor.setDefaultRootElement("ns4:team");
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("teamName");
    nameMapping.setXPath("ns4:teamName/text()");
    xmlDescriptor.addMapping(nameMapping);
    XMLAnyObjectMapping teamLeaderMapping = new XMLAnyObjectMapping();
    teamLeaderMapping.setAttributeName("teamLeader");
    teamLeaderMapping.setXPath("ns5:leader");
    xmlDescriptor.addMapping(teamLeaderMapping);
    XMLCompositeCollectionMapping empsMapping = new XMLCompositeCollectionMapping();
    empsMapping.setAttributeName("employees");
    empsMapping.setXPath("ns6:emp");
    // no reference class
    xmlDescriptor.addMapping(empsMapping);
    XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
    ref.setSchemaContext("/ns4:team");
    ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
    xmlDescriptor.setSchemaReference(ref);
    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("ns4", "http://www.example.com/ns4");
    nsResolver.put("ns5", "http://www.example.com/ns5");
    nsResolver.put("ns6", "http://www.example.com/ns6");
    // nsResolver.put("ns2", "http://www.example.com/ns2");
    xmlDescriptor.setNamespaceResolver(nsResolver);
    return xmlDescriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Aggregations

XMLSchemaClassPathReference (org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)71 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)69 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)52 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)36 QName (javax.xml.namespace.QName)13 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)9 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)9 XMLField (org.eclipse.persistence.oxm.XMLField)8 XMLObjectReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping)6 XMLSchemaReference (org.eclipse.persistence.oxm.schema.XMLSchemaReference)5 XMLCollectionReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping)4 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)2 XmlValue (jakarta.xml.bind.annotation.XmlValue)1 XMLAnyCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping)1 XMLTransformationMapping (org.eclipse.persistence.oxm.mappings.XMLTransformationMapping)1