/** * Return all the fields mapped by the mapping. */ protected Vector collectFields() { if (isForeignKeyRelationship()) { if (this.getForeignKeyGroupingElement() != null) { Vector fields = new Vector(1); fields.addElement(this.getForeignKeyGroupingElement()); return fields; } else { return NO_FIELDS; } } else { return NO_FIELDS; } }
/** * Return all the fields mapped by the mapping. */ @Override protected Vector collectFields() { if (isForeignKeyRelationship()) { if (this.getForeignKeyGroupingElement() != null) { Vector fields = new Vector(1); fields.addElement(this.getForeignKeyGroupingElement()); return fields; } else { return NO_FIELDS; } } else { return NO_FIELDS; } }
/** * Return all the fields mapped by the mapping. */ @Override protected Vector collectFields() { if (isForeignKeyRelationship()) { if (this.getForeignKeyGroupingElement() != null) { Vector fields = new Vector(1); fields.addElement(this.getForeignKeyGroupingElement()); return fields; } else { return NO_FIELDS; } } else { return NO_FIELDS; } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ @Override public void writeInsertFieldsIntoRow(AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeInsertFieldsIntoRow(row, session); } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ public void writeInsertFieldsIntoRow(AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeInsertFieldsIntoRow(row, session); } }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * The foreign keys must be set to null to avoid constraints. */ public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeFromObjectIntoRowForShallowInsert(object, row, session); } }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * The foreign keys must be set to null to avoid constraints. */ @Override public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeFromObjectIntoRowForShallowInsert(object, row, session); } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ @Override public void writeInsertFieldsIntoRow(AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeInsertFieldsIntoRow(row, session); } }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * The foreign keys must be set to null to avoid constraints. */ public void writeFromObjectIntoRowForShallowInsertWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeFromObjectIntoRowForShallowInsertWithChangeRecord(changeRecord, row, session); } }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * The foreign keys must be set to null to avoid constraints. */ @Override public void writeFromObjectIntoRowForShallowInsertWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeFromObjectIntoRowForShallowInsertWithChangeRecord(changeRecord, row, session); } }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * The foreign keys must be set to null to avoid constraints. */ @Override public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeFromObjectIntoRowForShallowInsert(object, row, session); } }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * The foreign keys must be set to null to avoid constraints. */ @Override public void writeFromObjectIntoRowForShallowInsertWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session) { if (isForeignKeyRelationship() && !isReadOnly()) { if (getForeignKeyGroupingElement() != null) { row.put(getForeignKeyGroupingElement(), null); } else if (this.getSourceForeignKeyFields().size() > 0) { row.put(getSourceForeignKeyFields().get(0), null); } } else { super.writeFromObjectIntoRowForShallowInsertWithChangeRecord(changeRecord, row, session); } }
/** * INTERNAL: */ public Vector getForeignKeyRows(AbstractRecord row, AbstractSession session) { Vector subRows = new Vector(); if (getForeignKeyGroupingElement() == null) { if (this.getSourceForeignKeyFields().size() > 0) { Object values = row.getValues(this.getSourceForeignKeyFields().get(0)); if (values != null) { if (values instanceof Vector) { int valuesSize = ((Vector)values).size(); for (int j = 0; j < valuesSize; j++) { AbstractRecord newRecord = this.descriptor.getObjectBuilder().createRecord(session); newRecord.put(this.getSourceForeignKeyFields().get(0), ((Vector)values).get(j)); subRows.add(newRecord); } } else { AbstractRecord newRecord = this.descriptor.getObjectBuilder().createRecord(session); newRecord.put(getSourceForeignKeyFields().get(0), values); subRows.add(newRecord); } } } } else { subRows = (Vector)row.getValues(getForeignKeyGroupingElement()); } return subRows; }
/** * INTERNAL: * Initialize the mapping. */ @Override public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); if ((this.getForeignKeyGroupingElement() == null) && (this.getSourceForeignKeysToTargetKeys().size() > 1)) { throw EISException.groupingElementRequired(); } if (this.getForeignKeyGroupingElement() != null) { DatabaseField field = this.getDescriptor().buildField(this.getForeignKeyGroupingElement()); setForeignKeyGroupingElement(field); } this.initializeSourceForeignKeysToTargetKeys(); if (shouldInitializeSelectionCriteria()) { initializeSelectionCriteria(session); } this.initializeDeleteAllQuery(); }
/** * INTERNAL: * Initialize the mapping. */ public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); if (!this.hasCustomSelectionQuery()) { throw DescriptorException.operationNotSupported("customSelectionQueryRequired"); } if ((this.getForeignKeyGroupingElement() == null) && (this.getSourceForeignKeysToTargetKeys().size() > 1)) { throw EISException.groupingElementRequired(); } if (this.getForeignKeyGroupingElement() != null) { DatabaseField field = this.getDescriptor().buildField(this.getForeignKeyGroupingElement()); setForeignKeyGroupingElement((XMLField)field); } this.initializeSourceForeignKeysToTargetKeys(); this.initializeDeleteAllQuery(); }
/** * INTERNAL: * Initialize the mapping. */ @Override public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); if ((this.getForeignKeyGroupingElement() == null) && (this.getSourceForeignKeysToTargetKeys().size() > 1)) { throw EISException.groupingElementRequired(); } if (this.getForeignKeyGroupingElement() != null) { DatabaseField field = this.getDescriptor().buildField(this.getForeignKeyGroupingElement()); setForeignKeyGroupingElement(field); } this.initializeSourceForeignKeysToTargetKeys(); if (shouldInitializeSelectionCriteria()) { initializeSelectionCriteria(session); } this.initializeDeleteAllQuery(); }
/** * INTERNAL: * This row is built for update after shallow insert which happens in case of bidirectional inserts. * It contains the foreign keys with non null values that were set to null for shallow insert. * If mapping overrides writeFromObjectIntoRowForShallowInsert method it must override this one, too. */ public void writeFromObjectIntoRowForUpdateAfterShallowInsert(Object object, AbstractRecord row, AbstractSession session, DatabaseTable table) { if (isReadOnly() || !isForeignKeyRelationship()) { return; } if (getForeignKeyGroupingElement() != null) { if (!getForeignKeyGroupingElement().getTable().equals(table)) { return; } } else if (this.getSourceForeignKeyFields().size() > 0) { if (!getSourceForeignKeyFields().get(0).getTable().equals(table)) { return; } } writeFromObjectIntoRow(object, row, session, WriteType.UPDATE); }
/** * INTERNAL: * This row is built for update after shallow insert which happens in case of bidirectional inserts. * It contains the foreign keys with non null values that were set to null for shallow insert. * If mapping overrides writeFromObjectIntoRowForShallowInsert method it must override this one, too. */ public void writeFromObjectIntoRowForUpdateAfterShallowInsert(Object object, AbstractRecord row, AbstractSession session, DatabaseTable table) { if (isReadOnly() || !isForeignKeyRelationship()) { return; } if (getForeignKeyGroupingElement() != null) { if (!getForeignKeyGroupingElement().getTable().equals(table)) { return; } } else if (this.getSourceForeignKeyFields().size() > 0) { if (!getSourceForeignKeyFields().get(0).getTable().equals(table)) { return; } } writeFromObjectIntoRow(object, row, session, WriteType.UPDATE); }
/** * Build and return a database row that contains a foreign key for the specified reference * object. This will be stored in the nested row(s). */ protected XMLRecord extractKeyRowFromReferenceObject(Object object, AbstractSession session, XMLRecord parentRecord) { Element newNode = XPathEngine.getInstance().createUnownedElement(parentRecord.getDOM(), getForeignKeyGroupingElement()); XMLRecord result = new DOMRecord(newNode); result.setSession(session); for (int i = 0; i < this.getSourceForeignKeyFields().size(); i++) { DatabaseField fkField = (DatabaseField)getSourceForeignKeyFields().get(i); if (object == null) { result.add(fkField, null); } else { DatabaseField pkField = (DatabaseField)this.getSourceForeignKeysToTargetKeys().get(fkField); Object value = this.getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(object, pkField, session); result.add(fkField, value); } } return result; }
/** * Build and return a database row that contains a foreign key for the specified reference * object. This will be stored in the nested row(s). */ protected AbstractRecord extractKeyRowFromReferenceObject(Object object, AbstractSession session, AbstractRecord parentRecord) { int size = this.sourceForeignKeyFields.size(); AbstractRecord result; if (((EISDescriptor) this.getDescriptor()).isXMLFormat()) { Element newNode = XPathEngine.getInstance().createUnownedElement(((XMLRecord)parentRecord).getDOM(), (XMLField)getForeignKeyGroupingElement()); result = new DOMRecord(newNode); ((DOMRecord)result).setSession(session); } else { result = this.descriptor.getObjectBuilder().createRecord(size, session); } for (int index = 0; index < size; index++) { DatabaseField fkField = this.sourceForeignKeyFields.get(index); if (object == null) { result.add(fkField, null); } else { DatabaseField pkField = this.sourceForeignKeysToTargetKeys.get(fkField); Object value = this.referenceDescriptor.getObjectBuilder().extractValueFromObjectForField(object, pkField, session); result.add(fkField, value); } } return result; }