public Object getAttributeValueFromObject(Object object) { Map sourceToTargetKeyFields = ((EISOneToOneMapping)object).getSourceToTargetKeyFields(); List associations = new ArrayList(sourceToTargetKeyFields.size()); Iterator iterator = sourceToTargetKeyFields.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); associations.add(new Association(entry.getKey(), entry.getValue())); } return associations; }
public Object getAttributeValueFromObject(Object object) { Map sourceToTargetKeyFields = ((EISOneToOneMapping)object).getSourceToTargetKeyFields(); List associations = new ArrayList(sourceToTargetKeyFields.size()); Iterator iterator = sourceToTargetKeyFields.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); associations.add(new Association(entry.getKey(), entry.getValue())); } return associations; }
public Object getAttributeValueFromObject(Object object) { Map sourceToTargetKeyFields = ((EISOneToOneMapping)object).getSourceToTargetKeyFields(); List associations = new ArrayList(sourceToTargetKeyFields.size()); Iterator iterator = sourceToTargetKeyFields.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); associations.add(new Association(entry.getKey(), entry.getValue())); } return associations; }
/** * INTERNAL: * Extract the key value from the reference object. */ protected Vector extractKeyFromReferenceObject(Object object, AbstractSession session) { Vector key = new Vector(); Iterator sourceKeyIterator = getSourceToTargetKeyFields().keySet().iterator(); while (sourceKeyIterator.hasNext()) { DatabaseField field = (DatabaseField)sourceKeyIterator.next(); if (object == null) { key.addElement(null); } else { key.addElement(getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(object, field, session)); } } return key; }
/** * PUBLIC: * Define the source foreign key relationship in the one-to-one mapping. * This method is used to add foreign key relationships to the mapping. * Both the source foreign key field name and the corresponding * target primary key field name must be specified. */ public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetKeyField) { this.getSourceToTargetKeyFields().put(sourceForeignKeyField, targetKeyField); this.getTargetToSourceKeyFields().put(targetKeyField, sourceForeignKeyField); this.getForeignKeyFields().add(sourceForeignKeyField); this.setIsForeignKeyRelationship(true); }
/** * PUBLIC: * Define the source foreign key relationship in the one-to-one mapping. * This method is used to add foreign key relationships to the mapping. * Both the source foreign key field name and the corresponding * target primary key field name must be specified. */ @Override public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetKeyField) { getSourceToTargetKeyFields().put(sourceForeignKeyField, targetKeyField); getTargetToSourceKeyFields().put(targetKeyField, sourceForeignKeyField); getForeignKeyFields().add(sourceForeignKeyField); setIsForeignKeyRelationship(true); }
/** * PUBLIC: * Define the source foreign key relationship in the one-to-one mapping. * This method is used to add foreign key relationships to the mapping. * Both the source foreign key field name and the corresponding * target primary key field name must be specified. */ @Override public void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetKeyField) { getSourceToTargetKeyFields().put(sourceForeignKeyField, targetKeyField); getTargetToSourceKeyFields().put(targetKeyField, sourceForeignKeyField); getForeignKeyFields().add(sourceForeignKeyField); setIsForeignKeyRelationship(true); }
public void setAttributeValueInObject(Object object, Object value) { EISOneToOneMapping mapping = (EISOneToOneMapping)object; List associations = (List)value; mapping.setSourceToTargetKeyFields(new HashMap(associations.size() + 1)); mapping.setTargetToSourceKeyFields(new HashMap(associations.size() + 1)); Iterator iterator = associations.iterator(); while (iterator.hasNext()) { Association association = (Association)iterator.next(); mapping.getSourceToTargetKeyFields().put((DatabaseField)association.getKey(), (DatabaseField)association.getValue()); mapping.getTargetToSourceKeyFields().put((DatabaseField)association.getValue(), (DatabaseField)association.getKey()); } } });
/** * INTERNAL: * The foreign keys primary keys are stored as database fields in the hashtable. */ protected void initializeForeignKeys(AbstractSession session) { HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size()); HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); DatabaseField sourceField = (DatabaseField)entry.getKey(); DatabaseField targetField = (DatabaseField)entry.getValue(); sourceField = getDescriptor().buildField(sourceField); targetField = getReferenceDescriptor().buildField(targetField); newSourceToTargetKeyFields.put(sourceField, targetField); newTargetToSourceKeyFields.put(targetField, sourceField); } setSourceToTargetKeyFields(newSourceToTargetKeyFields); setTargetToSourceKeyFields(newTargetToSourceKeyFields); }
public void setAttributeValueInObject(Object object, Object value) { EISOneToOneMapping mapping = (EISOneToOneMapping)object; List associations = (List)value; mapping.setSourceToTargetKeyFields(new HashMap(associations.size() + 1)); mapping.setTargetToSourceKeyFields(new HashMap(associations.size() + 1)); Iterator iterator = associations.iterator(); while (iterator.hasNext()) { Association association = (Association)iterator.next(); mapping.getSourceToTargetKeyFields().put((DatabaseField)association.getKey(), (DatabaseField)association.getValue()); mapping.getTargetToSourceKeyFields().put((DatabaseField)association.getValue(), (DatabaseField)association.getKey()); } } });
/** * INTERNAL: * The foreign keys primary keys are stored as database fields in the hashtable. */ protected void initializeForeignKeys(AbstractSession session) { HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size()); HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); DatabaseField sourceField = (DatabaseField)entry.getKey(); DatabaseField targetField = (DatabaseField)entry.getValue(); sourceField = getDescriptor().buildField(sourceField); targetField = getReferenceDescriptor().buildField(targetField); newSourceToTargetKeyFields.put(sourceField, targetField); newTargetToSourceKeyFields.put(targetField, sourceField); } setSourceToTargetKeyFields(newSourceToTargetKeyFields); setTargetToSourceKeyFields(newTargetToSourceKeyFields); }
public void setAttributeValueInObject(Object object, Object value) { EISOneToOneMapping mapping = (EISOneToOneMapping)object; List associations = (List)value; mapping.setSourceToTargetKeyFields(new HashMap(associations.size() + 1)); mapping.setTargetToSourceKeyFields(new HashMap(associations.size() + 1)); Iterator iterator = associations.iterator(); while (iterator.hasNext()) { Association association = (Association)iterator.next(); mapping.getSourceToTargetKeyFields().put(association.getKey(), association.getValue()); mapping.getTargetToSourceKeyFields().put(association.getValue(), association.getKey()); } } });
/** * INTERNAL: * The foreign keys primary keys are stored as database fields in the hashtable. */ protected void initializeForeignKeys(AbstractSession session) { HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size()); HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size()); Iterator iterator = getSourceToTargetKeyFields().entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); DatabaseField sourceField = (DatabaseField)entry.getKey(); DatabaseField targetField = (DatabaseField)entry.getValue(); sourceField = getDescriptor().buildField(sourceField); targetField = getReferenceDescriptor().buildField(targetField); newSourceToTargetKeyFields.put(sourceField, targetField); newTargetToSourceKeyFields.put(targetField, sourceField); } setSourceToTargetKeyFields(newSourceToTargetKeyFields); setTargetToSourceKeyFields(newTargetToSourceKeyFields); }
/** * 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.getSourceToTargetKeyFields().isEmpty()) { throw DescriptorException.noForeignKeysAreSpecified(this); } Expression criteria; Expression builder = new ExpressionBuilder(); Iterator keyIterator = getSourceToTargetKeyFields().keySet().iterator(); while (keyIterator.hasNext()) { DatabaseField foreignKey = (DatabaseField)keyIterator.next(); DatabaseField targetKey = (DatabaseField)getSourceToTargetKeyFields().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.getSourceToTargetKeyFields().isEmpty()) { throw DescriptorException.noForeignKeysAreSpecified(this); } Expression criteria; Expression builder = new ExpressionBuilder(); Iterator keyIterator = getSourceToTargetKeyFields().keySet().iterator(); while (keyIterator.hasNext()) { DatabaseField foreignKey = (DatabaseField)keyIterator.next(); DatabaseField targetKey = getSourceToTargetKeyFields().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.getSourceToTargetKeyFields().isEmpty()) { throw DescriptorException.noForeignKeysAreSpecified(this); } Expression criteria; Expression builder = new ExpressionBuilder(); Iterator keyIterator = getSourceToTargetKeyFields().keySet().iterator(); while (keyIterator.hasNext()) { DatabaseField foreignKey = (DatabaseField)keyIterator.next(); DatabaseField targetKey = getSourceToTargetKeyFields().get(foreignKey); Expression expression = builder.getField(targetKey).equal(builder.getParameter(foreignKey)); criteria = expression.and(getSelectionCriteria()); setSelectionCriteria(criteria); } }
/** * INTERNAL: * Return the classifiction for the field contained in the mapping. * This is used to convert the row value to a consistent java value. */ public Class getFieldClassification(DatabaseField fieldToClassify) throws DescriptorException { DatabaseField fieldInTarget = (DatabaseField)getSourceToTargetKeyFields().get(fieldToClassify); if (fieldInTarget == null) { return null;// Can be registered as multiple table secondary field mapping } DatabaseMapping mapping = getReferenceDescriptor().getObjectBuilder().getMappingForField(fieldInTarget); if (mapping == null) { return null;// Means that the mapping is read-only } return mapping.getFieldClassification(fieldInTarget); }
/** * INTERNAL: * Return the classifiction for the field contained in the mapping. * This is used to convert the row value to a consistent java value. */ @Override public Class getFieldClassification(DatabaseField fieldToClassify) throws DescriptorException { DatabaseField fieldInTarget = getSourceToTargetKeyFields().get(fieldToClassify); if (fieldInTarget == null) { return null;// Can be registered as multiple table secondary field mapping } DatabaseMapping mapping = getReferenceDescriptor().getObjectBuilder().getMappingForField(fieldInTarget); if (mapping == null) { return null;// Means that the mapping is read-only } return mapping.getFieldClassification(fieldInTarget); }
/** * INTERNAL: * Return the classifiction for the field contained in the mapping. * This is used to convert the row value to a consistent java value. */ @Override public Class getFieldClassification(DatabaseField fieldToClassify) throws DescriptorException { DatabaseField fieldInTarget = getSourceToTargetKeyFields().get(fieldToClassify); if (fieldInTarget == null) { return null;// Can be registered as multiple table secondary field mapping } DatabaseMapping mapping = getReferenceDescriptor().getObjectBuilder().getMappingForField(fieldInTarget); if (mapping == null) { return null;// Means that the mapping is read-only } return mapping.getFieldClassification(fieldInTarget); }
/** * INTERNAL: * Extract the foreign key value from the source row. */ protected Vector extractForeignKeyFromRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(); Iterator sourceKeyIterator = getSourceToTargetKeyFields().keySet().iterator(); while (sourceKeyIterator.hasNext()) { DatabaseField field = (DatabaseField)sourceKeyIterator.next(); Object value = row.get(field); // Must ensure the classification gets a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(field)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }