use of org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping in project aai-aai-common by onap.
the class FromOxmVertexSchema method fromOxm.
public void fromOxm(String vertexType, DynamicJAXBContext jaxbContext, HashMap<String, DynamicType> xmlElementLookup) throws SchemaProviderException {
name = vertexType;
properties = new HashMap<String, PropertySchema>();
annotations = new HashMap<String, String>();
String javaTypeName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, vertexType);
DynamicType modelObjectType = jaxbContext.getDynamicType(javaTypeName);
if (modelObjectType == null) {
// Try to lookup by xml root element by exact match
modelObjectType = xmlElementLookup.get(vertexType);
}
if (modelObjectType == null) {
// Try to lookup by xml root element by lowercase
modelObjectType = xmlElementLookup.get(vertexType.toLowerCase());
}
if (modelObjectType == null) {
// Direct lookup as java-type name
modelObjectType = jaxbContext.getDynamicType(vertexType);
}
if (modelObjectType == null) {
// Vertex isn't found in the OXM
throw new SchemaProviderException("Vertex " + vertexType + " not found in OXM");
}
// Check annotations
Map<String, Object> oxmProps = modelObjectType.getDescriptor().getProperties();
for (Map.Entry<String, Object> entry : oxmProps.entrySet()) {
if (entry.getValue() instanceof String) {
annotations.put(entry.getKey().toLowerCase(), (String) entry.getValue());
}
}
// Regular props
for (DatabaseMapping mapping : modelObjectType.getDescriptor().getMappings()) {
if (mapping instanceof XMLAnyObjectMapping)
continue;
if (mapping instanceof XMLAnyCollectionMapping)
continue;
FromOxmPropertySchema propSchema = new FromOxmPropertySchema();
propSchema.fromOxm(mapping, modelObjectType, false);
properties.put(propSchema.getName().toLowerCase(), propSchema);
}
// Reserved Props
final DynamicType reservedType = jaxbContext.getDynamicType("ReservedPropNames");
for (DatabaseMapping mapping : reservedType.getDescriptor().getMappings()) {
if (mapping.isAbstractDirectMapping()) {
FromOxmPropertySchema propSchema = new FromOxmPropertySchema();
propSchema.fromOxm(mapping, reservedType, true);
properties.put(propSchema.getName().toLowerCase(), propSchema);
}
}
}
use of org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping in project eclipselink by eclipse-ee4j.
the class XmlAnyElementListTestCases method testContainerType.
public void testContainerType() {
XMLDescriptor xDesc = xmlContext.getDescriptor(new QName("employee"));
assertNotNull("No descriptor was generated for EmployeeWithList.", xDesc);
DatabaseMapping mapping = xDesc.getMappingForAttributeName("stuff");
assertNotNull("No mapping exists on EmployeeWithList for attribute [stuff].", mapping);
assertTrue("Expected an XMLAnyCollectionMapping for attribute [stuff], but was [" + mapping.toString() + "].", mapping instanceof XMLAnyCollectionMapping);
assertTrue("Expected container class [java.util.LinkedList] but was [" + mapping.getContainerPolicy().getContainerClassName() + "]", mapping.getContainerPolicy().getContainerClassName().equals("java.util.LinkedList"));
}
use of org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping in project eclipselink by eclipse-ee4j.
the class SDOObjectType method addOpenMappings.
protected void addOpenMappings() {
XMLAnyCollectionMapping anyMapping = new XMLAnyCollectionMapping();
anyMapping.setAttributeName(ANY_MAPPING_ATTRIBUTE_NAME);
anyMapping.setGetMethodName(ANY_MAPPING_GET_METHOD_NAME);
anyMapping.setSetMethodName(ANY_MAPPING_SET_METHOD_NAME);
anyMapping.setUseXMLRoot(true);
getXmlDescriptor().addMapping(anyMapping);
XMLAnyAttributeMapping anyAttrMapping = new XMLAnyAttributeMapping();
anyAttrMapping.setAttributeName("openContentPropertiesAttributes");
anyAttrMapping.setGetMethodName("_getOpenContentPropertiesAttributesMap");
anyAttrMapping.setSetMethodName("_setOpenContentPropertiesAttributesMap");
getXmlDescriptor().addMapping(anyAttrMapping);
}
use of org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping in project eclipselink by eclipse-ee4j.
the class ChildAndGeneratedPrefixClashProject method getRootDescriptor.
private XMLDescriptor getRootDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Root.class);
xmlDescriptor.setDefaultRootElement("aaa:root");
// XMLCompositeCollectionMapping companiesMapping = new XMLCompositeCollectionMapping();
XMLAnyCollectionMapping companiesMapping = new XMLAnyCollectionMapping();
companiesMapping.setAttributeName("companies");
companiesMapping.setXPath("aaa:companies");
companiesMapping.setUseXMLRoot(true);
// companiesMapping.setReferenceClass(Company.class);
xmlDescriptor.addMapping(companiesMapping);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("aaa", "http://www.example.com/aaa");
xmlDescriptor.setNamespaceResolver(nsResolver);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping in project eclipselink by eclipse-ee4j.
the class CustomerProject method getCustomerDescriptor.
private XMLDescriptor getCustomerDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Customer.class);
xmlDescriptor.setDefaultRootElement("customer");
XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
addressMapping.setReferenceClass(Address.class);
addressMapping.setAttributeName("address");
addressMapping.setXPath("customer-address");
xmlDescriptor.addMapping(addressMapping);
XMLCompositeCollectionMapping addressesMapping = new XMLCompositeCollectionMapping();
addressesMapping.setReferenceClass(Address.class);
addressesMapping.setAttributeName("addresses");
addressesMapping.setXPath("customer-addresses/customer-address");
xmlDescriptor.addMapping(addressesMapping);
XMLAnyObjectMapping anyMapping = new XMLAnyObjectMapping();
anyMapping.setAttributeName("any");
anyMapping.setXPath("any-object");
xmlDescriptor.addMapping(anyMapping);
XMLAnyCollectionMapping anyCollectionMapping = new XMLAnyCollectionMapping();
anyCollectionMapping.setAttributeName("anyCollection");
anyCollectionMapping.setXPath("any-collection");
xmlDescriptor.addMapping(anyCollectionMapping);
return xmlDescriptor;
}
Aggregations