use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class XMLEntityMappingsMappingProject method buildEntityMappingsDescriptor.
/**
* INTERNAL:
* XSD: entity-mappings
*/
protected ClassDescriptor buildEntityMappingsDescriptor(String xsdLocation) {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setDefaultRootElement("orm:entity-mappings");
descriptor.setJavaClass(XMLEntityMappings.class);
descriptor.setSchemaReference(new XMLSchemaClassPathReference(xsdLocation));
descriptor.addMapping(getDescriptionMapping());
XMLCompositeObjectMapping persistenceUnitMetadataMapping = new XMLCompositeObjectMapping();
persistenceUnitMetadataMapping.setAttributeName("m_persistenceUnitMetadata");
persistenceUnitMetadataMapping.setGetMethodName("getPersistenceUnitMetadata");
persistenceUnitMetadataMapping.setSetMethodName("setPersistenceUnitMetadata");
persistenceUnitMetadataMapping.setReferenceClass(XMLPersistenceUnitMetadata.class);
persistenceUnitMetadataMapping.setXPath("orm:persistence-unit-metadata");
descriptor.addMapping(persistenceUnitMetadataMapping);
XMLDirectMapping packageMapping = new XMLDirectMapping();
packageMapping.setAttributeName("m_package");
packageMapping.setGetMethodName("getPackage");
packageMapping.setSetMethodName("setPackage");
packageMapping.setXPath("orm:package/text()");
descriptor.addMapping(packageMapping);
descriptor.addMapping(getSchemaMapping());
descriptor.addMapping(getCatalogMapping());
descriptor.addMapping(getAccessMapping());
descriptor.addMapping(getAccessMethodsMapping());
descriptor.addMapping(getTenantDiscriminatorColumnsMapping());
descriptor.addMapping(getMixedConverterMapping());
descriptor.addMapping(getTypeConverterMapping());
descriptor.addMapping(getObjectTypeConverterMapping());
descriptor.addMapping(getSerializedConverterMapping());
descriptor.addMapping(getStructConverterMapping());
XMLCompositeCollectionMapping sequenceGeneratorsMapping = new XMLCompositeCollectionMapping();
sequenceGeneratorsMapping.setAttributeName("m_sequenceGenerators");
sequenceGeneratorsMapping.setGetMethodName("getSequenceGenerators");
sequenceGeneratorsMapping.setSetMethodName("setSequenceGenerators");
sequenceGeneratorsMapping.setReferenceClass(SequenceGeneratorMetadata.class);
sequenceGeneratorsMapping.setXPath("orm:sequence-generator");
descriptor.addMapping(sequenceGeneratorsMapping);
XMLCompositeCollectionMapping tableGeneratorsMapping = new XMLCompositeCollectionMapping();
tableGeneratorsMapping.setAttributeName("m_tableGenerators");
tableGeneratorsMapping.setGetMethodName("getTableGenerators");
tableGeneratorsMapping.setSetMethodName("setTableGenerators");
tableGeneratorsMapping.setReferenceClass(TableGeneratorMetadata.class);
tableGeneratorsMapping.setXPath("orm:table-generator");
descriptor.addMapping(tableGeneratorsMapping);
XMLCompositeCollectionMapping uuidGeneratorsMapping = new XMLCompositeCollectionMapping();
uuidGeneratorsMapping.setAttributeName("m_uuidGenerators");
uuidGeneratorsMapping.setGetMethodName("getUuidGenerators");
uuidGeneratorsMapping.setSetMethodName("setUuidGenerators");
uuidGeneratorsMapping.setReferenceClass(UuidGeneratorMetadata.class);
uuidGeneratorsMapping.setXPath("orm:uuid-generator");
descriptor.addMapping(uuidGeneratorsMapping);
XMLCompositeCollectionMapping partitioningMapping = new XMLCompositeCollectionMapping();
partitioningMapping.setAttributeName("m_partitioning");
partitioningMapping.setGetMethodName("getPartitioning");
partitioningMapping.setSetMethodName("setPartitioning");
partitioningMapping.setReferenceClass(PartitioningMetadata.class);
partitioningMapping.setXPath("orm:partitioning");
descriptor.addMapping(partitioningMapping);
partitioningMapping = new XMLCompositeCollectionMapping();
partitioningMapping.setAttributeName("m_replicationPartitioning");
partitioningMapping.setGetMethodName("getReplicationPartitioning");
partitioningMapping.setSetMethodName("setReplicationPartitioning");
partitioningMapping.setReferenceClass(ReplicationPartitioningMetadata.class);
partitioningMapping.setXPath("orm:replication-partitioning");
descriptor.addMapping(partitioningMapping);
partitioningMapping = new XMLCompositeCollectionMapping();
partitioningMapping.setAttributeName("m_roundRobinPartitioning");
partitioningMapping.setGetMethodName("getRoundRobinPartitioning");
partitioningMapping.setSetMethodName("setRoundRobinPartitioning");
partitioningMapping.setReferenceClass(RoundRobinPartitioningMetadata.class);
partitioningMapping.setXPath("orm:round-robin-partitioning");
descriptor.addMapping(partitioningMapping);
partitioningMapping = new XMLCompositeCollectionMapping();
partitioningMapping.setAttributeName("m_pinnedPartitioning");
partitioningMapping.setGetMethodName("getPinnedPartitioning");
partitioningMapping.setSetMethodName("setPinnedPartitioning");
partitioningMapping.setReferenceClass(PinnedPartitioningMetadata.class);
partitioningMapping.setXPath("orm:pinned-partitioning");
descriptor.addMapping(partitioningMapping);
partitioningMapping = new XMLCompositeCollectionMapping();
partitioningMapping.setAttributeName("m_rangePartitioning");
partitioningMapping.setGetMethodName("getRangePartitioning");
partitioningMapping.setSetMethodName("setRangePartitioning");
partitioningMapping.setReferenceClass(RangePartitioningMetadata.class);
partitioningMapping.setXPath("orm:range-partitioning");
descriptor.addMapping(partitioningMapping);
partitioningMapping = new XMLCompositeCollectionMapping();
partitioningMapping.setAttributeName("m_valuePartitioning");
partitioningMapping.setGetMethodName("getValuePartitioning");
partitioningMapping.setSetMethodName("setValuePartitioning");
partitioningMapping.setReferenceClass(ValuePartitioningMetadata.class);
partitioningMapping.setXPath("orm:value-partitioning");
descriptor.addMapping(partitioningMapping);
partitioningMapping = new XMLCompositeCollectionMapping();
partitioningMapping.setAttributeName("m_hashPartitioning");
partitioningMapping.setGetMethodName("getHashPartitioning");
partitioningMapping.setSetMethodName("setHashPartitioning");
partitioningMapping.setReferenceClass(HashPartitioningMetadata.class);
partitioningMapping.setXPath("orm:hash-partitioning");
descriptor.addMapping(partitioningMapping);
partitioningMapping = new XMLCompositeCollectionMapping();
partitioningMapping.setAttributeName("m_unionPartitioning");
partitioningMapping.setGetMethodName("getUnionPartitioning");
partitioningMapping.setSetMethodName("setUnionPartitioning");
partitioningMapping.setReferenceClass(UnionPartitioningMetadata.class);
partitioningMapping.setXPath("orm:union-partitioning");
descriptor.addMapping(partitioningMapping);
descriptor.addMapping(getNamedQueryMapping());
descriptor.addMapping(getNamedNativeQueryMapping());
descriptor.addMapping(getNamedStoredProcedureQueryMapping());
descriptor.addMapping(getNamedStoredFunctionQueryMapping());
descriptor.addMapping(getNamedPLSQLStoredProcedureQueryMapping());
descriptor.addMapping(getNamedPLSQLStoredFunctionQueryMapping());
descriptor.addMapping(getOracleObjectTypeMapping());
descriptor.addMapping(getOracleArrayTypeMapping());
descriptor.addMapping(getPLSQLRecordMapping());
descriptor.addMapping(getPLSQLTableMapping());
descriptor.addMapping(getResultSetMappingMapping());
XMLCompositeCollectionMapping mappedSuperclassMapping = new XMLCompositeCollectionMapping();
mappedSuperclassMapping.setAttributeName("m_mappedSuperclasses");
mappedSuperclassMapping.setGetMethodName("getMappedSuperclasses");
mappedSuperclassMapping.setSetMethodName("setMappedSuperclasses");
mappedSuperclassMapping.setReferenceClass(MappedSuperclassAccessor.class);
mappedSuperclassMapping.setXPath("orm:mapped-superclass");
descriptor.addMapping(mappedSuperclassMapping);
XMLCompositeCollectionMapping entityMapping = new XMLCompositeCollectionMapping();
entityMapping.setAttributeName("m_entities");
entityMapping.setGetMethodName("getEntities");
entityMapping.setSetMethodName("setEntities");
entityMapping.setReferenceClass(EntityAccessor.class);
entityMapping.setXPath("orm:entity");
descriptor.addMapping(entityMapping);
XMLCompositeCollectionMapping embeddableMapping = new XMLCompositeCollectionMapping();
embeddableMapping.setAttributeName("m_embeddables");
embeddableMapping.setGetMethodName("getEmbeddables");
embeddableMapping.setSetMethodName("setEmbeddables");
embeddableMapping.setReferenceClass(EmbeddableAccessor.class);
embeddableMapping.setXPath("orm:embeddable");
descriptor.addMapping(embeddableMapping);
// What about the version attribute???
XMLDirectMapping versionMapping = new XMLDirectMapping();
versionMapping.setAttributeName("m_version");
versionMapping.setGetMethodName("getVersion");
versionMapping.setSetMethodName("setVersion");
versionMapping.setXPath("@version");
descriptor.addMapping(versionMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class SDOType method preInitialize.
/**
* INTERNAL:
* For this Type generate classes
* @param packageName
* @param namespaceResolvers
*/
public void preInitialize(String packageName, List namespaceResolvers) {
String instanceClassName = getInstanceClassName();
if (null == instanceClassName) {
if (null == packageName) {
String uri = getURI();
if (null == uri) {
packageName = SDOUtil.getDefaultPackageName() + SDOConstants.JAVA_PACKAGE_NAME_SEPARATOR;
} else {
packageName = SDOUtil.getPackageNameFromURI(uri) + SDOConstants.JAVA_PACKAGE_NAME_SEPARATOR;
}
}
// Verify and fix any Class name that does not conform to conventions
// run the class name through the JAXB mangler
String mangledClassName = SDOUtil.className(getName(), false, true, true);
// we will not fix any type collision at this time as a result of class renaming
// write fully qualified java class name
StringBuffer fullClassName = new StringBuffer(packageName);
fullClassName.append(mangledClassName);
setInstanceClassName(fullClassName.toString());
}
//
AbstractSessionLog.getLog().log(//
AbstractSessionLog.FINER, //
"sdo_type_generation_processing_type", new Object[] { Helper.getShortClassName(getClass()), getInstanceClassName() });
initializeNamespaces(namespaceResolvers);
getXmlDescriptor().setJavaClassName(getImplClassName());
// See SDOResolvable enhancement
String schemaContext = getName();
if (getXmlDescriptor().getNamespaceResolver() != null) {
String prefix = getXmlDescriptor().getNamespaceResolver().resolveNamespaceURI(getURI());
if ((prefix != null) && !prefix.equals(SDOConstants.EMPTY_STRING)) {
schemaContext = prefix + SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT + schemaContext;
}
}
String schemaContextWithSlash = SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT + schemaContext;
XMLSchemaReference schemaRef = new XMLSchemaClassPathReference();
schemaRef.setSchemaContext(schemaContextWithSlash);
schemaRef.setType(XMLSchemaReference.COMPLEX_TYPE);
getXmlDescriptor().setSchemaReference(schemaRef);
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class ChangeSummaryProject method getChild2Descriptor.
private XMLDescriptor getChild2Descriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Child2.class);
xmlDescriptor.setDefaultRootElement("tns:child2");
xmlDescriptor.addPrimaryKeyFieldName("@id");
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/tns:child2");
schemaReference.setType(XMLSchemaReference.ELEMENT);
xmlDescriptor.setSchemaReference(schemaReference);
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("tns", "urn:changesummary");
xmlDescriptor.setNamespaceResolver(namespaceResolver);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
xmlDescriptor.addMapping(idMapping);
XMLObjectReferenceMapping child1Mapping = new XMLObjectReferenceMapping();
child1Mapping.setReferenceClass(Child1.class);
child1Mapping.setAttributeName("child1");
child1Mapping.addSourceToTargetKeyFieldAssociation("tns:child1/text()", "@id");
xmlDescriptor.addMapping(child1Mapping);
XMLObjectReferenceMapping child1AttributeMapping = new XMLObjectReferenceMapping();
child1AttributeMapping.setReferenceClass(Child1.class);
child1AttributeMapping.setAttributeName("child1Attribute");
child1AttributeMapping.addSourceToTargetKeyFieldAssociation("@child1", "@id");
xmlDescriptor.addMapping(child1AttributeMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class ContainmentProject method getChildDescriptor.
private XMLDescriptor getChildDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Child.class);
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("tns", "urn:containment");
xmlDescriptor.setNamespaceResolver(namespaceResolver);
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/tns:child");
schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(schemaReference);
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName("value");
mapping.setXPath("tns:value/text()");
xmlDescriptor.addMapping(mapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class ContainmentProject method getRootDescriptor.
private XMLDescriptor getRootDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Root.class);
xmlDescriptor.setDefaultRootElement("tns:root-element");
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/tns:root");
schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(schemaReference);
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("tns", "urn:containment");
xmlDescriptor.setNamespaceResolver(namespaceResolver);
XMLCompositeObjectMapping mapping = new XMLCompositeObjectMapping();
mapping.setReferenceClass(Child.class);
if (mapping.getInverseReferenceMapping() != null) {
mapping.getInverseReferenceMapping().setAttributeName("container");
}
mapping.setAttributeName("childProperty");
mapping.setXPath("tns:child");
xmlDescriptor.addMapping(mapping);
XMLCompositeCollectionMapping mapping2 = new XMLCompositeCollectionMapping();
mapping2.setReferenceClass(Child.class);
if (mapping.getInverseReferenceMapping() != null) {
mapping2.getInverseReferenceMapping().setAttributeName("container");
}
mapping2.setAttributeName("childCollectionProperty");
mapping2.setXPath("tns:child-many");
mapping2.getContainerPolicy().setContainerClass(ArrayList.class);
xmlDescriptor.addMapping(mapping2);
return xmlDescriptor;
}
Aggregations