/** * Returns a comma-separated list of column names. * @param columns Array of ColumnElements * @return String of form "columnA, columnB", with as many named columns * as there are in given array. */ private static String getColumnNames(ColumnElement[] columns) { StringBuffer columnNames = new StringBuffer(); for (int i = 0; i < columns.length; i++) { if (i > 0) { columnNames.append(COLUMN_SEPARATOR); } columnNames.append(columns[i].getName().getName()); } return columnNames.toString(); } }
private List getRelativeColumnNames (ColumnElement[] columns) { int i, count = ((columns != null) ? columns.length : 0); List columnNames = new ArrayList(count); for (i = 0; i < count; i++) { columnNames.add(NameUtil.getRelativeMemberName( columns[i].getName().getFullName())); } return columnNames; } private boolean isKeyField (MappingFieldElement field)
private List getRelativeColumnNames (ColumnElement[] columns) { int i, count = ((columns != null) ? columns.length : 0); List columnNames = new ArrayList(count); for (i = 0; i < count; i++) { columnNames.add(NameUtil.getRelativeMemberName( columns[i].getName().getFullName())); } return columnNames; } private boolean isKeyField (MappingFieldElement field)
private boolean testColumn (ColumnElement column, ArrayList masterList) { if ((column != null) && !isPrimaryKeyColumn(column)) { return !masterList.contains(NameUtil. getRelativeMemberName(column.getName().getFullName())); } return true; } private ColumnElement getLocalColumn (String pairName,
private boolean testColumn (ColumnElement column, ArrayList masterList) { if ((column != null) && !isPrimaryKeyColumn(column)) { return !masterList.contains(NameUtil. getRelativeMemberName(column.getName().getFullName())); } return true; } private ColumnElement getLocalColumn (String pairName,
/** * Checks, if the column <code>ce</code> is part of the * primary key <code>pk</code>. * RESOLVE: Method isPrimaryKeyColumn in ModelValidator * implements similar functionality. * * @param ce Column element for the column to be tested. * @param pk Primary key element. The column to be tested * <b>must</b> be defined in the same table. * @return True, if the column is part of the primary key, * false otherwise. * @see com.sun.jdo.api.persistence.model.util.ModelValidator */ private boolean isPartOfPrimaryKey(ColumnElement ce, UniqueKeyElement pk) { return null != pk && ce.equals(pk.getColumn(ce.getName())); }
private boolean isPrimaryKeyColumn (ColumnElement column) { if (column != null) { KeyElement key = column.getDeclaringTable().getPrimaryKey(); return ((key != null) && (key.getColumn(column.getName()) != null)); } return false; } private boolean isExactMatch (ArrayList columns1,
private boolean isPrimaryKeyColumn (ColumnElement column) { if (column != null) { KeyElement key = column.getDeclaringTable().getPrimaryKey(); return ((key != null) && (key.getColumn(column.getName()) != null)); } return false; } private boolean isExactMatch (ArrayList columns1,
/** * Checks, if the column <code>ce</code> is part of one * of the foreign key constraints defined in <code>fks</code>. * RESOLVE: Method matchesFK in ModelValidator implements similar * functionality. * * @param ce Column element for the column to be tested. * @param fks Array of foreign key elements. The column to be * tested <b>must</b> be defined in the same table. * @return True, if the column is part of one of the foreign keys, * false otherwise. * @see com.sun.jdo.api.persistence.model.util.ModelValidator */ private boolean isPartOfForeignKey(ColumnElement ce, ForeignKeyElement[] fks) { // RESOLVE: Column ce might be included in multiple foreign // keys. The foreign key check applies to ALL relationships // mapped to column ce. How can we find out, that a foreign // key matches exactly the relationship being checked here? if (fks != null) { for (int index = 0; index < fks.length; index++) { if (ce.equals(fks[index].getColumn(ce.getName()))) { // The current ce is part of the foreign key. return true; } } } return false; }
/** 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); } }
/** 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); } }
/** 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); } }
/** 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); } }
/** 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 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 } }
getModel().getField(className, fieldName), I18NHelper.getMessage(getMessages(), keyName, new Object[]{column.getName(), fieldName, className}));
messages, "MESSAGE_CANDIDATE_PK", //NOI18N candidatePK.getName()));
public void validate () throws ModelValidationException { ColumnPairElement pair = getPair(pairName, getSchemaForClass(relatedClass)); if (pair != null) { ColumnElement column = pair.getReferencedColumn(); if (!matchesTable(tableNames, column)) { String fieldName = relatedField.getName(); throw new ModelValidationException( getModel().getField(getClassName(), fieldName), I18NHelper.getMessage(getMessages(), getKey( "util.validation.table_mismatch", //NOI18N relatedField), new Object[]{column.getName().getFullName(), fieldName, relatedClass})); } } } };
public void validate () throws ModelValidationException { ColumnPairElement pair = getPair(pairName, getSchemaForClass(relatedClass)); if (pair != null) { ColumnElement column = pair.getReferencedColumn(); if (!matchesTable(tableNames, column)) { String fieldName = relatedField.getName(); throw new ModelValidationException( getModel().getField(getClassName(), fieldName), I18NHelper.getMessage(getMessages(), getKey( "util.validation.table_mismatch", //NOI18N relatedField), new Object[]{column.getName().getFullName(), fieldName, relatedClass})); } } } };
refTblName, refColumn.getName().getName());