/** * INTERNAL: * Build the nested rows. */ public Vector buildNestedRowsFromFieldValue(Object fieldValue, AbstractSession session) { if (!getDataFormat().equals(XML)) { if (!(fieldValue instanceof List)) { return new Vector(); } return new Vector((List)fieldValue); } // BUG#2667762 if the tag was empty this could be a string of whitespace. if (!(fieldValue instanceof Vector)) { return new Vector(0); } return (Vector)fieldValue; }
/** * INTERNAL: * Build the appropriate field value for the specified * set of direct values. * The database better be expecting a Vector. */ public Object buildFieldValueFromDirectValues(Vector directValues, String elementDataTypeName, AbstractSession session) { if (!getDataFormat().equals(XML)) { return super.buildFieldValueFromDirectValues(directValues, elementDataTypeName, session); } return directValues; }
/** * INTERNAL: * Extract the direct values from the specified field value. * Return them in a vector. * The field value could be a vector or could be a text value if only a single value. */ public Vector buildDirectValuesFromFieldValue(Object fieldValue) { if (!getDataFormat().equals(XML)) { return super.buildDirectValuesFromFieldValue(fieldValue); } if (!(fieldValue instanceof Vector)) { Vector fieldValues = new Vector(1); fieldValues.add(fieldValue); return fieldValues; } return (Vector)fieldValue; }
public void initialize(AbstractSession session) throws DescriptorException { if (getDataFormat().equals(XML)) { for(int x = 0, primaryKeyFieldsSize = this.primaryKeyFields.size(); x<primaryKeyFieldsSize; x++) { XMLField pkField = (XMLField) this.primaryKeyFields.get(x); pkField.setNamespaceResolver(this.namespaceResolver); pkField.initialize(); } } super.initialize(session); }
protected void writeValueIntoRow(AbstractRecord row, DatabaseField field, Object fieldValue) { if (((EISDescriptor)this.getDescriptor()).getDataFormat() == EISDescriptor.XML) { row.put(field, fieldValue); } else { row.add(field, fieldValue); } }
/** * PUBLIC: * Specify the primary key field. * This should be called for each field that make up the primary key. * For EIS XML Descriptors use the addPrimaryKeyField(DatabaseField) API * and supply an org.eclipse.persistence.oxm.XMLField parameter instead of using this method */ public void addPrimaryKeyFieldName(String fieldName) { if (getDataFormat() == EISDescriptor.XML) { addPrimaryKeyField(new XMLField(fieldName)); } else { super.addPrimaryKeyFieldName(fieldName); } }
/** * INTERNAL: * We override this method in order to set the session on the record if the data * format is XML. * * Get a value from the object and set that in the respective field of the row. */ public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session) { if (((EISDescriptor) this.getDescriptor()).getDataFormat() == EISDescriptor.XML) { ((XMLRecord) row).setSession(session); } super.writeFromObjectIntoRow(object, row, session); } }
protected Object buildCompositeObject(ObjectBuilder objectBuilder, AbstractRecord nestedRow, ObjectBuildingQuery query, JoinedAttributeManager joinManager) { if (((EISDescriptor)getDescriptor()).getDataFormat() == EISDescriptor.XML) { return objectBuilder.buildObject(query, nestedRow, joinManager); } else { Object aggregateObject = objectBuilder.buildNewInstance(); objectBuilder.buildAttributesIntoObject(aggregateObject, nestedRow, query, joinManager, false); return aggregateObject; } }
/** * INTERNAL: * XML type descriptors should use XMLFields. */ public DatabaseField buildField(String fieldName) { if (getDataFormat().equals(XML)) { XMLField xmlField = new XMLField(fieldName); xmlField.setNamespaceResolver(this.getNamespaceResolver()); xmlField.initialize(); return xmlField; } else { return super.buildField(fieldName); } }
/** * PUBLIC: * The inheritance policy is used to define how a descriptor takes part in inheritance. * All inheritance properties for both child and parent classes is configured in inheritance policy. * Caution must be used in using this method as it lazy initializes an inheritance policy. * Calling this on a descriptor that does not use inheritance will cause problems, #hasInheritance() must always first be called. */ public InheritancePolicy getInheritancePolicy() { if (inheritancePolicy == null) { if(getDataFormat() == EISDescriptor.XML) { // Lazy initialize to conserve space in non-inherited classes. setInheritancePolicy(new org.eclipse.persistence.internal.oxm.QNameInheritancePolicy(this)); } else { setInheritancePolicy(new InheritancePolicy(this)); } } return inheritancePolicy; }
if (!getDataFormat().equals(XML)) { if (!(fieldValue instanceof List)) { return new DatabaseRecord(1);
/** * INTERNAL: * If the field is an XMLField then set the namespace resolver from the descriptor. * This allows the resolver to only be set in the descriptor. */ public DatabaseField buildField(DatabaseField field) { if(getDataFormat().equals(XML)) { if(!(field instanceof XMLField)) { field = new XMLField(field.getName()); } ((XMLField)field).setNamespaceResolver(getNamespaceResolver()); ((XMLField)field).initialize(); } return super.buildField(field); }
protected Object buildCompositeObject(ClassDescriptor descriptor, AbstractRecord nestedRow, ObjectBuildingQuery query, JoinedAttributeManager joinManager) { if (((EISDescriptor)descriptor).getDataFormat() == EISDescriptor.XML) { return descriptor.getObjectBuilder().buildObject(query, nestedRow, joinManager); } else { Object element = descriptor.getObjectBuilder().buildNewInstance(); descriptor.getObjectBuilder().buildAttributesIntoObject(element, nestedRow, query, joinManager, false); return element; } }
protected AbstractRecord buildCompositeRow(Object attributeValue, AbstractSession session, AbstractRecord parentRow) { if (((EISDescriptor)getDescriptor()).getDataFormat() == EISDescriptor.XML) { XMLObjectBuilder objectBuilder = (XMLObjectBuilder)getReferenceDescriptor(attributeValue, session).getObjectBuilder(); return objectBuilder.buildRow(attributeValue, session, getField(), (XMLRecord)parentRow); } else { return this.getObjectBuilder(attributeValue, session).buildRow(attributeValue, session); } } }
/** * PUBLIC: * Add a direct mapping to the receiver. The new mapping specifies that * an instance variable of the class of objects which the receiver describes maps in * the default manner for its type to the indicated database field. * * @param String instanceVariableName is the name of an instance variable of the * class which the receiver describes. * @param String fieldName is the name of the xml element or attribute which corresponds * with the designated instance variable. * @return The newly created DatabaseMapping is returned. */ public DatabaseMapping addDirectMapping(String attributeName, String fieldName) { EISDirectMapping mapping = new EISDirectMapping(); mapping.setAttributeName(attributeName); if (getDataFormat() == EISDescriptor.XML) { mapping.setXPath(fieldName); } else { mapping.setFieldName(fieldName); } return addMapping(mapping); }
/** * PUBLIC: * Add a direct to node mapping to the receiver. The new mapping specifies that * a variable accessed by the get and set methods of the class of objects which * the receiver describes maps in the default manner for its type to the indicated * database field. */ public DatabaseMapping addDirectMapping(String attributeName, String getMethodName, String setMethodName, String fieldName) { EISDirectMapping mapping = new EISDirectMapping(); mapping.setAttributeName(attributeName); mapping.setSetMethodName(setMethodName); mapping.setGetMethodName(getMethodName); if (getDataFormat() == EISDescriptor.XML) { mapping.setXPath(fieldName); } else { mapping.setFieldName(fieldName); } return addMapping(mapping); }
protected Object buildCompositeRow(Object attributeValue, AbstractSession session, AbstractRecord record) { if (((EISDescriptor)getDescriptor()).getDataFormat() == EISDescriptor.XML) { XMLObjectBuilder objectBuilder = (XMLObjectBuilder)getReferenceDescriptor(attributeValue, session).getObjectBuilder(); return objectBuilder.buildRow(attributeValue, session, getField(), (XMLRecord)record); } else { AbstractRecord nestedRow = this.getObjectBuilder(attributeValue, session).buildRow(attributeValue, session); return this.getReferenceDescriptor(attributeValue, session).buildFieldValueFromNestedRow(nestedRow, session); } }
if (((EISDescriptor) this.getDescriptor()).getDataFormat() == EISDescriptor.XML) { ((XMLRecord) row).setSession(executionSession);
/** * INTERNAL: * Build the value for the database field and put it in the * specified database row. */ public void writeFromObjectIntoRow(Object object, AbstractRecord record, AbstractSession session) throws DescriptorException { if (this.isReadOnly()) { return; } Object attributeValue = this.getAttributeValueFromObject(object); // handle "." xpath - condition: xml data format AND xml field is "self" if ((((EISDescriptor)getDescriptor()).getDataFormat() == EISDescriptor.XML) && ((XMLField)getField()).isSelfField()) { XMLObjectBuilder objectBuilder = (XMLObjectBuilder)getReferenceDescriptor(attributeValue, session).getObjectBuilder(); objectBuilder.buildIntoNestedRow(record, attributeValue, session); } else { Object fieldValue = null; if (attributeValue != null) { fieldValue = buildCompositeRow(attributeValue, session, record); } record.put(this.getField(), fieldValue); } } }