/** Set the column pairs for this holder. * Previous column pairs are removed. * @param pairs the new column pairs * @throws ModelException if impossible */ public void setColumnPairs (ColumnPairElement[] pairs) throws ModelException { removeColumnPairs(getColumnPairNames()); // remove the old ones addColumnPairs(pairs); // add the new ones }
/** Set the mapping table for this referencing key to the supplied table. * @param table mapping table element to be used with this key. * @exception ModelException if impossible */ public void setTable (MappingTableElement table) throws ModelException { MappingTableElement old = getTable(); try { fireVetoableChange(PROP_TABLE, old, table); setTableInternal(table); firePropertyChange(PROP_TABLE, old, table); } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
/** Get all referenced columns in this reference key. This method is * provided as part of the implementation of the ReferenceKey interface * but should only be used when a ReferenceKey object is used or by * the runtime. * @return the columns */ public ColumnElement[] getReferencedColumns () { ColumnPairElement[] columnPairs = getColumnPairs(); int i, count = ((columnPairs != null) ? columnPairs.length : 0); ColumnElement[] columns = new ColumnElement[count]; for (i = 0; i < count ; i++) columns[i] = columnPairs[i].getReferencedColumn(); return columns; }
ArrayList refKey = getReferencingKey(); ArrayList key = getTable().getKey(); int i, count = ((pairNames != null) ? pairNames.size() : 0); int index = getIndexOfColumnPair(pairName); fireVetoableChange(PROP_KEY_COLUMNS, null, null); getMessages(), "mapping.element.element_not_removed", // NOI18N pairName)); firePropertyChange(PROP_KEY_COLUMNS, null, null);
MappingTableElementImpl table = (MappingTableElementImpl)getTable(); int i, count = ((pairs != null) ? pairs.length : 0); if (getIndexOfColumnPair(NameUtil.getRelativeMemberName( pair.getName().getFullName())) == -1) addKeyColumn(pair.getLocalColumn()); throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N
/** Get all column pairs in this holder. * @return the column pairs */ public ColumnPairElement[] getColumnPairs () { ArrayList pairNames = getColumnPairNames(); TableElement table = getDeclaringTable(); int i, count = ((pairNames != null) ? pairNames.size() : 0); ColumnPairElement[] pairs = new ColumnPairElement[count]; String databaseRoot = getDeclaringClass().getDatabaseRoot(); for (i = 0; i < count; i++) { String absoluteName = NameUtil.getAbsoluteMemberName( databaseRoot, (String)pairNames.get(i)); pairs[i] = (ColumnPairElement)table.getMember( DBIdentifier.create(absoluteName)); } return pairs; }
/** Adds a column to the list of key columns in this referencing key. * This method is only called privately from addColumnPairs and assumes * that the column is not <code>null</code>. * @param column column element to be added * @exception ModelException if impossible */ private void addKeyColumn (ColumnElement column) throws ModelException { ArrayList referencingKey = getReferencingKey(); String columnName = NameUtil.getRelativeMemberName( column.getName().getFullName()); try { fireVetoableChange(PROP_KEY_COLUMNS, null, null); referencingKey.add(columnName); firePropertyChange(PROP_KEY_COLUMNS, null, null); } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
/** Set the mapping table for this referencing key to the supplied table * without firing any property change events. * @param table mapping table element to be used with this key. * @exception ModelException if impossible */ private void setTableInternal (MappingTableElement table) throws ModelException { if (table == null) { throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N } _table = table; if (null == getDeclaringClass()) _declaringClass = table.getDeclaringClass(); if (null == getName()) _name = table.getName(); }
/** Find a column pair by name. * @param name the name of the column pair for which to look * @return the column pair or <code>null</code> if not found */ public ColumnPairElement getColumnPair (DBIdentifier name) { ColumnPairElement[] myPairs = getColumnPairs(); int count = ((myPairs != null) ? myPairs.length : 0); String databaseRoot = getDeclaringClass().getDatabaseRoot(); if (count > 0) { String absoluteTableName = NameUtil.getAbsoluteTableName( databaseRoot, getTable().getName()); ColumnPairElement searchPair = (ColumnPairElement) TableElement.forName(absoluteTableName).getMember(name); int i; for (i = 0; i < count; i++) { if (myPairs[i].equals(searchPair)) return searchPair; } } return null; }
/** Get the declaring table. This method is provided as part of * the implementation of the ReferenceKey interface but should only * be used when a ReferenceKey object is used or by the runtime. * @return the table that owns this reference key element, or * <code>null</code> if the element is not attached to any table */ public TableElement getDeclaringTable () { ArrayList locals = getReferencingKey(); if ((locals != null) && (locals.size() > 0)) { String absoluteName = NameUtil.getAbsoluteMemberName( getDeclaringClass().getDatabaseRoot(), locals.get(0).toString()); return TableElement.forName(NameUtil.getTableName(absoluteName)); } return null; }
/** Add a new column pair to the holder. * @param pair the pair to add * @throws ModelException if impossible */ public void addColumnPair (ColumnPairElement pair) throws ModelException { addColumnPairs(new ColumnPairElement[]{pair}); }
/** Convenience method which takes a pair and returns its index. * @param searchPairName the relative name of the column pair for * which to look * @return the index of the column pair or -1 if not found */ private int getIndexOfColumnPair (String searchPairName) { ArrayList myPairs = getColumnPairNames(); int count = ((myPairs != null) ? myPairs.size() : 0); if (count > 0) { int i; for (i = 0; i < count; i++) { if (myPairs.get(i).equals(searchPairName)) return i; } } return -1; }
new MappingTableElementImpl(table, this); MappingReferenceKeyElement key = new MappingReferenceKeyElementImpl(mappingTable);
ArrayList refKey = getReferencingKey(); ArrayList key = getTable().getKey(); int i, count = ((pairNames != null) ? pairNames.size() : 0); int index = getIndexOfColumnPair(pairName); fireVetoableChange(PROP_KEY_COLUMNS, null, null); getMessages(), "mapping.element.element_not_removed", // NOI18N pairName)); firePropertyChange(PROP_KEY_COLUMNS, null, null);
MappingTableElementImpl table = (MappingTableElementImpl)getTable(); int i, count = ((pairs != null) ? pairs.length : 0); if (getIndexOfColumnPair(NameUtil.getRelativeMemberName( pair.getName().getFullName())) == -1) addKeyColumn(pair.getLocalColumn()); throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N
/** Get all column pairs in this holder. * @return the column pairs */ public ColumnPairElement[] getColumnPairs () { ArrayList pairNames = getColumnPairNames(); TableElement table = getDeclaringTable(); int i, count = ((pairNames != null) ? pairNames.size() : 0); ColumnPairElement[] pairs = new ColumnPairElement[count]; String databaseRoot = getDeclaringClass().getDatabaseRoot(); for (i = 0; i < count; i++) { String absoluteName = NameUtil.getAbsoluteMemberName( databaseRoot, (String)pairNames.get(i)); pairs[i] = (ColumnPairElement)table.getMember( DBIdentifier.create(absoluteName)); } return pairs; }
/** Adds a column to the list of key columns in this referencing key. * This method is only called privately from addColumnPairs and assumes * that the column is not <code>null</code>. * @param column column element to be added * @exception ModelException if impossible */ private void addKeyColumn (ColumnElement column) throws ModelException { ArrayList referencingKey = getReferencingKey(); String columnName = NameUtil.getRelativeMemberName( column.getName().getFullName()); try { fireVetoableChange(PROP_KEY_COLUMNS, null, null); referencingKey.add(columnName); firePropertyChange(PROP_KEY_COLUMNS, null, null); } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
/** Set the mapping table for this referencing key to the supplied table * without firing any property change events. * @param table mapping table element to be used with this key. * @exception ModelException if impossible */ private void setTableInternal (MappingTableElement table) throws ModelException { if (table == null) { throw new ModelException(I18NHelper.getMessage(getMessages(), "mapping.element.null_argument")); // NOI18N } _table = table; if (null == getDeclaringClass()) _declaringClass = table.getDeclaringClass(); if (null == getName()) _name = table.getName(); }
/** Find a column pair by name. * @param name the name of the column pair for which to look * @return the column pair or <code>null</code> if not found */ public ColumnPairElement getColumnPair (DBIdentifier name) { ColumnPairElement[] myPairs = getColumnPairs(); int count = ((myPairs != null) ? myPairs.length : 0); String databaseRoot = getDeclaringClass().getDatabaseRoot(); if (count > 0) { String absoluteTableName = NameUtil.getAbsoluteTableName( databaseRoot, getTable().getName()); ColumnPairElement searchPair = (ColumnPairElement) TableElement.forName(absoluteTableName).getMember(name); int i; for (i = 0; i < count; i++) { if (myPairs[i].equals(searchPair)) return searchPair; } } return null; }
/** Get the declaring table. This method is provided as part of * the implementation of the ReferenceKey interface but should only * be used when a ReferenceKey object is used or by the runtime. * @return the table that owns this reference key element, or * <code>null</code> if the element is not attached to any table */ public TableElement getDeclaringTable () { ArrayList locals = getReferencingKey(); if ((locals != null) && (locals.size() > 0)) { String absoluteName = NameUtil.getAbsoluteMemberName( getDeclaringClass().getDatabaseRoot(), locals.get(0).toString()); return TableElement.forName(NameUtil.getTableName(absoluteName)); } return null; }