use of org.eclipse.persistence.sdo.helper.SDOMethodAttributeAccessor in project eclipselink by eclipse-ee4j.
the class SDOProperty method addMappingToOwner.
/**
* INTERNAL:
*/
public void addMappingToOwner(boolean sdoMethodAttributeAccessor, int indexToAdd) {
if (xmlMapping != null) {
if (sdoMethodAttributeAccessor) {
SDOMethodAttributeAccessor accessor = null;
if (this.getType().isDataType()) {
Class<?> theClass = getType().getInstanceClass();
accessor = new SDOMethodAttributeAccessor(this, theClass);
} else {
accessor = new SDOMethodAttributeAccessor(this);
}
xmlMapping.setAttributeAccessor(accessor);
}
if ((getContainingType() != null) && !getContainingType().isDataType()) {
ClassDescriptor containingDescriptor = getContainingType().getXmlDescriptor();
xmlMapping.setDescriptor(containingDescriptor);
XMLMapping mapping = (XMLMapping) getContainingType().getXmlDescriptor().getMappingForAttributeName(getName());
if (mapping != null) {
getContainingType().getXmlDescriptor().getMappings().remove(mapping);
}
if (indexToAdd == -1) {
getContainingType().getXmlDescriptor().getMappings().add(xmlMapping);
} else {
// iterate over the mappings and find the correct place to insert this mapping relative to the
// indecies of the others.
SDOType containingType = getContainingType();
Vector<DatabaseMapping> mappings = containingType.getXmlDescriptor().getMappings();
boolean added = false;
for (int i = 0; i < mappings.size(); i++) {
DatabaseMapping next = mappings.get(i);
SDOProperty associatedProperty = containingType.getProperty(next.getAttributeName());
if (associatedProperty != null && indexToAdd < associatedProperty.getIndexInType()) {
mappings.add(i, xmlMapping);
added = true;
break;
}
}
if (!added) {
getContainingType().getXmlDescriptor().getMappings().add(xmlMapping);
}
}
}
}
}
use of org.eclipse.persistence.sdo.helper.SDOMethodAttributeAccessor in project eclipselink by eclipse-ee4j.
the class SDOWrapperType method initializeDescriptor.
private void initializeDescriptor(XMLDescriptor aDescriptor, QName aQName, Type aPropertyType, SDOProperty aValueProperty) {
aDescriptor.setNamespaceResolver(null);
SDOMethodAttributeAccessor accessor = null;
accessor = new SDOMethodAttributeAccessor(aValueProperty);
if (XMLConstants.QNAME_QNAME.equals(aQName)) {
XMLTransformationMapping mapping = new XMLTransformationMapping();
mapping.setAttributeName(ATTRIBUTE_NAME);
QNameTransformer transformer = new QNameTransformer("text()");
mapping.setAttributeTransformer(transformer);
mapping.addFieldTransformer(XPATH, transformer);
NamespaceResolver nsr = new NamespaceResolver();
nsr.setDefaultNamespaceURI(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
XMLField field = new XMLField();
field.setNamespaceResolver(nsr);
field.setXPath("@" + javax.xml.XMLConstants.XMLNS_ATTRIBUTE);
mapping.addFieldTransformer(field, new NamespaceURITransformer());
mapping.setAttributeAccessor(accessor);
aDescriptor.addMapping(mapping);
} else {
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName(ATTRIBUTE_NAME);
mapping.setXPath(XPATH);
mapping.setAttributeClassification(aPropertyType.getInstanceClass());
((XMLField) mapping.getField()).setSchemaType(aQName);
mapping.setAttributeAccessor(accessor);
aDescriptor.addMapping(mapping);
}
aDescriptor.setIsWrapper(true);
}
Aggregations