/** Set the table element for this mapping table to the supplied table. * @param table table element to be used by the mapping table. * @exception ModelException if impossible */ public void setTable (TableElement table) throws ModelException { String old = getTable(); String newName = table.toString(); try { fireVetoableChange(PROP_TABLE, old, newName); _table = newName; firePropertyChange(PROP_TABLE, old, newName); setName(_table); // sync up runtime's object too: force next // access to getTableObject to recompute it _tableObject = null; } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
/** Returns the list of columns (ColumnElements) in the primary key for * this mapping table. This method should only be used by the runtime. * @return the column elements in the primary key for this mapping table */ public ArrayList getKeyObjects () { if (_keyObjects == null) { //@olsen: calculate the key objects based on // the key names as stored in _key //_keyObjects = new ArrayList(); _keyObjects = MappingClassElementImpl.toColumnObjects( getDeclaringClass().getDatabaseRoot(), getKey()); } return _keyObjects; }
public static void printMappingTableElements(int tabs, ArrayList tables) { final int count = ((tables != null) ? tables.size() : 0); if (count > 0) { println(tabs, "--> tables "); //NOI18N for (int i = 0; i < count; i++) { MappingTableElementImpl mte = (MappingTableElementImpl) tables.get(i); println(tabs, "[" + i + "] " + mte.getClass()); //NOI18N println(tabs+1, "table = " + mte.getTable()); //NOI18N println(tabs+1, "tableObject = " + mte.getTableObject()); //NOI18N println(tabs+1, "key = " + mte.getKey()); //NOI18N println(tabs+1, "keyObjects = " + mte.getKeyObjects()); //NOI18N printMappingRefKeyElements(tabs+1, mte.getReferencingKeys()); } println(tabs, "<-- tables "); //NOI18N } }
/** Adds a referencing key to the list of keys in this mapping table. * @param referencingKey referencing key element to be added * @exception ModelException if impossible */ public void addReferencingKey (MappingReferenceKeyElement referencingKey) throws ModelException { try { fireVetoableChange(PROP_REFERENCING_KEYS, null, null); getReferencingKeys().add(referencingKey); firePropertyChange(PROP_REFERENCING_KEYS, null, null); } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
Iterator keyIterator = getReferencingKeys().iterator(); fireVetoableChange(PROP_REFERENCING_KEYS, null, null); keyIterator.remove(); firePropertyChange(PROP_REFERENCING_KEYS, null, null); throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N
fireVetoableChange(PROP_KEY_COLUMNS, null, null); if (!getKey().remove(columnName)) I18NHelper.getMessage(getMessages(), "mapping.element.element_not_removed", // NOI18N columnName)); firePropertyChange(PROP_KEY_COLUMNS, null, null);
/** Adds a column to the primary key of columns in this mapping table. * This method should only be used to manipulate the key columns of the * primary table. The secondary table key columns should be manipulated * using MappingReferenceKeyElement methods for pairs. * @param column column element to be added * @exception ModelException if impossible */ public void addKeyColumn (ColumnElement column) throws ModelException { if (column != null) { String columnName = NameUtil.getRelativeMemberName( column.getName().getFullName()); if (!getKey().contains(columnName)) addKeyColumnInternal(column); else { // this part was blank -- do we want an error or skip here? } } else { throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N } }
/** Adds a column to the primary key of columns in this mapping table. * This method is used internally to manipulate primary key columns * that have passed the null and duplicate tests in addKeyColumn and * secondary table key columns when pairs are being set up and ignoring * duplicates is done at the pair level. * @param column column element to be added * @exception ModelException if impossible */ protected void addKeyColumnInternal (ColumnElement column) throws ModelException { ArrayList key = getKey(); String columnName = NameUtil.getRelativeMemberName( column.getName().getFullName()); try { fireVetoableChange(PROP_KEY_COLUMNS, null, null); key.add(columnName); firePropertyChange(PROP_KEY_COLUMNS, null, null); // sync up runtime's object list too //@olsen: rather clear objects instead of maintaining them //getKeyObjects().add(column); _keyObjects = null; } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
new MappingTableElementImpl(table, this); MappingReferenceKeyElement key = new MappingReferenceKeyElementImpl(mappingTable);
/** Creates new MappingTableElementImpl with a corresponding * table and declaring class. * @param table table element to be used by the mapping table. * @param declaringClass the class to attach to */ public MappingTableElementImpl (TableElement table, MappingClassElement declaringClass) throws ModelException { this(table.toString(), declaringClass); // don't use setTable so as not to fire property change events _table = getName(); }
/** Returns the table element (TableElement) used by this mapping * table. This method should only be used by the runtime. * @return the table element for this mapping table */ public TableElement getTableObject () { if (_tableObject == null) { String absoluteTableName = NameUtil.getAbsoluteTableName( getDeclaringClass().getDatabaseRoot(), _table); _tableObject = TableElement.forName(absoluteTableName); } return _tableObject; }
pair.getName().getFullName())) == -1) table.addKeyColumnInternal(pair.getReferencedColumn()); addKeyColumn(pair.getLocalColumn());
Iterator keyIterator = getReferencingKeys().iterator(); fireVetoableChange(PROP_REFERENCING_KEYS, null, null); keyIterator.remove(); firePropertyChange(PROP_REFERENCING_KEYS, null, null); throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N
fireVetoableChange(PROP_KEY_COLUMNS, null, null); if (!getKey().remove(columnName)) I18NHelper.getMessage(getMessages(), "mapping.element.element_not_removed", // NOI18N columnName)); firePropertyChange(PROP_KEY_COLUMNS, null, null);
/** Adds a referencing key to the list of keys in this mapping table. * @param referencingKey referencing key element to be added * @exception ModelException if impossible */ public void addReferencingKey (MappingReferenceKeyElement referencingKey) throws ModelException { try { fireVetoableChange(PROP_REFERENCING_KEYS, null, null); getReferencingKeys().add(referencingKey); firePropertyChange(PROP_REFERENCING_KEYS, null, null); } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
/** Adds a column to the primary key of columns in this mapping table. * This method should only be used to manipulate the key columns of the * primary table. The secondary table key columns should be manipulated * using MappingReferenceKeyElement methods for pairs. * @param column column element to be added * @exception ModelException if impossible */ public void addKeyColumn (ColumnElement column) throws ModelException { if (column != null) { String columnName = NameUtil.getRelativeMemberName( column.getName().getFullName()); if (!getKey().contains(columnName)) addKeyColumnInternal(column); else { // this part was blank -- do we want an error or skip here? } } else { throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N } }
/** Adds a column to the primary key of columns in this mapping table. * This method is used internally to manipulate primary key columns * that have passed the null and duplicate tests in addKeyColumn and * secondary table key columns when pairs are being set up and ignoring * duplicates is done at the pair level. * @param column column element to be added * @exception ModelException if impossible */ protected void addKeyColumnInternal (ColumnElement column) throws ModelException { ArrayList key = getKey(); String columnName = NameUtil.getRelativeMemberName( column.getName().getFullName()); try { fireVetoableChange(PROP_KEY_COLUMNS, null, null); key.add(columnName); firePropertyChange(PROP_KEY_COLUMNS, null, null); // sync up runtime's object list too //@olsen: rather clear objects instead of maintaining them //getKeyObjects().add(column); _keyObjects = null; } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
new MappingTableElementImpl(table, this); MappingReferenceKeyElement key = new MappingReferenceKeyElementImpl(mappingTable);
/** Creates new MappingTableElementImpl with a corresponding * table and declaring class. * @param table table element to be used by the mapping table. * @param declaringClass the class to attach to */ public MappingTableElementImpl (TableElement table, MappingClassElement declaringClass) throws ModelException { this(table.toString(), declaringClass); // don't use setTable so as not to fire property change events _table = getName(); }
/** Returns the table element (TableElement) used by this mapping * table. This method should only be used by the runtime. * @return the table element for this mapping table */ public TableElement getTableObject () { if (_tableObject == null) { String absoluteTableName = NameUtil.getAbsoluteTableName( getDeclaringClass().getDatabaseRoot(), _table); _tableObject = TableElement.forName(absoluteTableName); } return _tableObject; }