/** * INTERNAL: * Clone the appropriate attributes. */ public Object clone() { EISOneToManyMapping clone = (EISOneToManyMapping)super.clone(); clone.setSourceForeignKeysToTargetKeys((Map)((HashMap)getSourceForeignKeysToTargetKeys()).clone()); return clone; }
/** * INTERNAL: * Clone the appropriate attributes. */ @Override public Object clone() { EISOneToManyMapping clone = (EISOneToManyMapping)super.clone(); clone.setSourceForeignKeysToTargetKeys((Map)((HashMap)getSourceForeignKeysToTargetKeys()).clone()); return clone; }
/** * INTERNAL: * Clone the appropriate attributes. */ @Override public Object clone() { EISOneToManyMapping clone = (EISOneToManyMapping)super.clone(); clone.setSourceForeignKeysToTargetKeys((Map)((HashMap)getSourceForeignKeysToTargetKeys()).clone()); return clone; }
/** * INTERNAL: * Selection criteria is created with source foreign keys and target keys. * This criteria is then used to read target records from the table. * * CR#3922 - This method is almost the same as buildSelectionCriteria() the difference * is that getSelectionCriteria() is called */ protected void initializeSelectionCriteria(AbstractSession session) { if (this.getSourceForeignKeysToTargetKeys().isEmpty()) { throw DescriptorException.noForeignKeysAreSpecified(this); } Expression criteria; Expression builder = new ExpressionBuilder(); Iterator keyIterator = getSourceForeignKeysToTargetKeys().keySet().iterator(); while (keyIterator.hasNext()) { DatabaseField foreignKey = (DatabaseField)keyIterator.next(); DatabaseField targetKey = getSourceForeignKeysToTargetKeys().get(foreignKey); Expression expression = builder.getField(targetKey).equal(builder.getParameter(foreignKey)); criteria = expression.and(getSelectionCriteria()); setSelectionCriteria(criteria); } }
/** * INTERNAL: * Selection criteria is created with source foreign keys and target keys. * This criteria is then used to read target records from the table. * * CR#3922 - This method is almost the same as buildSelectionCriteria() the difference * is that getSelectionCriteria() is called */ protected void initializeSelectionCriteria(AbstractSession session) { if (this.getSourceForeignKeysToTargetKeys().isEmpty()) { throw DescriptorException.noForeignKeysAreSpecified(this); } Expression criteria; Expression builder = new ExpressionBuilder(); Iterator keyIterator = getSourceForeignKeysToTargetKeys().keySet().iterator(); while (keyIterator.hasNext()) { DatabaseField foreignKey = (DatabaseField)keyIterator.next(); DatabaseField targetKey = getSourceForeignKeysToTargetKeys().get(foreignKey); Expression expression = builder.getField(targetKey).equal(builder.getParameter(foreignKey)); criteria = expression.and(getSelectionCriteria()); setSelectionCriteria(criteria); } }
protected void initializeSourceForeignKeysToTargetKeys() throws DescriptorException { // Since we require a custom selection query, these keys are optional. if (getSourceForeignKeyFields().size() != getTargetForeignKeyFields().size()) { throw DescriptorException.sizeMismatchOfForeignKeys(this); } for (int i = 0; i < getTargetForeignKeyFields().size(); i++) { DatabaseField field = getReferenceDescriptor().buildField(getTargetForeignKeyFields().get(i)); getTargetForeignKeyFields().set(i, field); } for (int i = 0; i < getSourceForeignKeyFields().size(); i++) { DatabaseField field = getDescriptor().buildField(getSourceForeignKeyFields().get(i)); getSourceForeignKeyFields().set(i, field); getSourceForeignKeysToTargetKeys().put(field, getTargetForeignKeyFields().get(i)); } }
protected void initializeSourceForeignKeysToTargetKeys() throws DescriptorException { // Since we require a custom selection query, these keys are optional. if (getSourceForeignKeyFields().size() != getTargetForeignKeyFields().size()) { throw DescriptorException.sizeMismatchOfForeignKeys(this); } for (int i = 0; i < getTargetForeignKeyFields().size(); i++) { DatabaseField field = getReferenceDescriptor().buildField((DatabaseField)getTargetForeignKeyFields().get(i)); getTargetForeignKeyFields().set(i, field); } for (int i = 0; i < getSourceForeignKeyFields().size(); i++) { DatabaseField field = getReferenceDescriptor().buildField((DatabaseField)getSourceForeignKeyFields().get(i)); getSourceForeignKeyFields().set(i, field); getSourceForeignKeysToTargetKeys().put(field, getTargetForeignKeyFields().get(i)); } }
protected void initializeSourceForeignKeysToTargetKeys() throws DescriptorException { // Since we require a custom selection query, these keys are optional. if (getSourceForeignKeyFields().size() != getTargetForeignKeyFields().size()) { throw DescriptorException.sizeMismatchOfForeignKeys(this); } for (int i = 0; i < getTargetForeignKeyFields().size(); i++) { DatabaseField field = getReferenceDescriptor().buildField(getTargetForeignKeyFields().get(i)); getTargetForeignKeyFields().set(i, field); } for (int i = 0; i < getSourceForeignKeyFields().size(); i++) { DatabaseField field = getDescriptor().buildField(getSourceForeignKeyFields().get(i)); getSourceForeignKeyFields().set(i, field); getSourceForeignKeysToTargetKeys().put(field, getTargetForeignKeyFields().get(i)); } }
/** * 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; }
if (((getSourceForeignKeysToTargetKeys()) == null) || (getSourceForeignKeysToTargetKeys().size() == 0)) { return; } else { DatabaseField singleField = getSourceForeignKeyFields().get(0); DatabaseField pkField = getSourceForeignKeysToTargetKeys().get(singleField); List foreignKeys = new ArrayList(cp.sizeFor(attributeValue)); for (Object iter = cp.iteratorFor(attributeValue); cp.hasNext(iter);) {
if (((getSourceForeignKeysToTargetKeys()) == null) || (getSourceForeignKeysToTargetKeys().size() == 0)) { return; } else { DatabaseField singleField = getSourceForeignKeyFields().get(0); DatabaseField pkField = getSourceForeignKeysToTargetKeys().get(singleField); List foreignKeys = new ArrayList(cp.sizeFor(attributeValue)); for (Object iter = cp.iteratorFor(attributeValue); cp.hasNext(iter);) {
if (((getSourceForeignKeysToTargetKeys()) == null) || (getSourceForeignKeysToTargetKeys().size() == 0)) { return; } else { DatabaseField singleField = (DatabaseField)getSourceForeignKeyFields().get(0); DatabaseField pkField = (DatabaseField)getSourceForeignKeysToTargetKeys().get(singleField); for (Object iter = cp.iteratorFor(attributeValue); cp.hasNext(iter);) { Object singleValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(cp.next(iter, session), pkField, session);
/** * 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: * 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(); }