Methods Summary |
---|
public void | addKeyColumn(org.netbeans.modules.dbschema.ColumnElement column)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.
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
}
|
protected void | addKeyColumnInternal(org.netbeans.modules.dbschema.ColumnElement column)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.
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);
}
|
public void | addReferencingKey(MappingReferenceKeyElement referencingKey)Adds a referencing key to the list of keys in this mapping table.
try
{
fireVetoableChange(PROP_REFERENCING_KEYS, null, null);
getReferencingKeys().add(referencingKey);
firePropertyChange(PROP_REFERENCING_KEYS, null, null);
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
|
public java.util.ArrayList | getKey()Returns the list of column names in the primary key for this
mapping table.
if (_key == null)
_key = new ArrayList();
return _key;
|
public java.util.ArrayList | getKeyObjects()Returns the list of columns (ColumnElements) in the primary key for
this mapping table. This method should only be used by the runtime.
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 java.util.ArrayList | getReferencingKeys()Returns the list of keys (MappingReferenceKeyElements) for this
mapping table. There will be keys for foreign keys and "fake" foreign
keys.
if (_referencingKeys == null)
_referencingKeys = new ArrayList();
return _referencingKeys;
|
public java.lang.String | getTable()Returns the name of the table element used by this mapping table. return _table;
|
public org.netbeans.modules.dbschema.TableElement | getTableObject()Returns the table element (TableElement) used by this mapping
table. This method should only be used by the runtime.
if (_tableObject == null)
{
String absoluteTableName = NameUtil.getAbsoluteTableName(
getDeclaringClass().getDatabaseRoot(), _table);
_tableObject = TableElement.forName(absoluteTableName);
}
return _tableObject;
|
public boolean | isEqual(org.netbeans.modules.dbschema.TableElement table)Returns true if the table element used by this mapping table is equal
to the supplied table.
return ((table != null) ? getTable().equals(table.toString()) : false);
|
public void | removeKeyColumn(java.lang.String columnName)Removes a column from 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.
if (columnName != null)
{
try
{
fireVetoableChange(PROP_KEY_COLUMNS, null, null);
if (!getKey().remove(columnName))
{
throw new ModelException(
I18NHelper.getMessage(getMessages(),
"mapping.element.element_not_removed", // NOI18N
columnName));
}
firePropertyChange(PROP_KEY_COLUMNS, null, null);
// sync up runtime's object list too
//@olsen: rather clear objects instead of maintaining them
//getKeyObjects().remove(column);
_keyObjects = null;
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
}
|
public void | removeReference(MappingTableElement table)Removes the referencing key for the supplied table element from list
of keys in this mapping table.
if (table != null)
{
Iterator keyIterator = getReferencingKeys().iterator();
while (keyIterator.hasNext())
{
MappingReferenceKeyElement nextKey =
(MappingReferenceKeyElement)keyIterator.next();
if (nextKey.getTable().equals(table))
{
try
{
fireVetoableChange(PROP_REFERENCING_KEYS, null, null);
keyIterator.remove();
firePropertyChange(PROP_REFERENCING_KEYS, null, null);
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
}
}
}
else
{
throw new ModelException(I18NHelper.getMessage(getMessages(),
"mapping.element.null_argument")); // NOI18N
}
|
public void | setKey(java.util.ArrayList key)Set the list of column names in the primary key for this mapping
table. This method should only be used internally and for cloning
and archiving. _key = key;
|
public void | setName(java.lang.String name)Override method in MappingElementImpl to set the _table variable
if necessary (used for unarchiving).
super.setName(name);
if (getTable() == null)
_table = name;
|
public void | setReferencingKeys(java.util.ArrayList referencingKeys)Set the list of keys (MappingReferenceKeyElements) for this mapping
table. This method should only be used internally and for cloning
and archiving.
_referencingKeys = referencingKeys;
|
public void | setTable(java.lang.String table)Set the name of the table element used by this mapping table. This
method should only be used internally and for cloning and archiving.
_table = table;
|
public void | setTable(org.netbeans.modules.dbschema.TableElement table)Set the table element for this mapping table to the supplied table.
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);
}
|
protected void | stripSchemaName()Boston to Pilsen conversion. This method converts the absolute db
element names to relative names. This affects the name of the
MappingTableElement itself and the column names stored in _keys.
The method is recursively called for all MappingReferenceKeyElements
attached to this MappingTableElement.
// handle _name
_name = NameUtil.getRelativeTableName(_name);
// handle _table
_table = NameUtil.getRelativeTableName(_table);
// handle _referencingKeys
// call method stripSchemaName on the MappingReferenceKeyElementImpl
// objects
if (_referencingKeys != null)
{
Iterator i = _referencingKeys.iterator();
while (i.hasNext())
{
MappingReferenceKeyElementImpl refKey =
(MappingReferenceKeyElementImpl)i.next();
refKey.stripSchemaName();
}
}
// handle _key
if (_key != null)
{
// Use ListIterator here, because I want to replace the value
// stored in the ArrayList. The ListIterator returned by
// ArrayList.listIterator() supports the set method.
ListIterator i = _key.listIterator();
while (i.hasNext())
i.set(NameUtil.getRelativeMemberName((String)i.next()));
}
|