private boolean isPairComplete (DBMemberElement member) { return ((member instanceof ColumnPairElement) && (((ColumnPairElement)member).getLocalColumn() != null) && (((ColumnPairElement)member).getReferencedColumn() != null)); } };
/** * Create column pair from local column and reference column. * @param column The local column. * @param refColumn The reference column. * @param declaringTbl The declaring table. * @return ColumnPairElement that represents the column pair. * @throws DBException */ static ColumnPairElement createColumnPair(ColumnElement column, ColumnElement refColumn, TableElement declaringTbl) throws DBException { ColumnPairElementImpl pairImpl = new ColumnPairElementImpl(); ColumnPairElement pair = new ColumnPairElement( pairImpl, column, refColumn, declaringTbl); return pair; }
pair.getName().getFullName())) == -1) table.addKeyColumnInternal(pair.getReferencedColumn()); addKeyColumn(pair.getLocalColumn());
ColumnPairElement cpe = new ColumnPairElement(); boolean localSet = false; cpe.setName(DBIdentifier.create(relationId + "_ColumnPair_" + i)); //NOI18N if (cpe.getLocalColumn() == null) { cpe.setLocalColumn(ce); cpe.setReferencedColumn(ce);
/** 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; }
private ColumnElement getLocalColumn (String pairName, String databaseRoot) { ColumnPairElement pair = getPair(pairName, databaseRoot); return ((pair != null) ? pair.getLocalColumn() : null); } private boolean isPrimaryKeyColumn (ColumnElement column)
/** Remove some column pairs from the holder. * @param pairs the column pairs to remove * @throws ModelException if impossible */ public void removeColumnPairs (ColumnPairElement[] pairs) throws ModelException { ArrayList pairNames = new ArrayList(); int i, count = ((pairs != null) ? pairs.length : 0); for (i = 0; i < count ; i++) { ColumnPairElement pair = (ColumnPairElement)pairs[i]; pairNames.add(NameUtil.getRelativeMemberName( pair.getName().getFullName())); } removeColumnPairs(pairNames); }
/** 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; }
pair.getName().getFullName())) == -1) table.addKeyColumnInternal(pair.getReferencedColumn()); addKeyColumn(pair.getLocalColumn());
primary,te); for (int j = 0; null != pairs && j < pairs.length; j++) { ColumnPairElement cpe = new ColumnPairElement(); DBIdentifier dbId = DBIdentifier.create("SecondaryTable"+j); //NOI18N cpe.setName(dbId); ColumnPair pair = pairs[j]; for (int k = 0; k < 2; k++) { dbId, helper); if (k == 0) cpe.setLocalColumn(ce); else cpe.setReferencedColumn(ce);
/** 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; }
private ColumnElement getLocalColumn (String pairName, String databaseRoot) { ColumnPairElement pair = getPair(pairName, databaseRoot); return ((pair != null) ? pair.getLocalColumn() : null); } private boolean isPrimaryKeyColumn (ColumnElement column)
/** Remove some column pairs from the holder. * @param pairs the column pairs to remove * @throws ModelException if impossible */ public void removeColumnPairs (ColumnPairElement[] pairs) throws ModelException { ArrayList pairNames = new ArrayList(); int i, count = ((pairs != null) ? pairs.length : 0); for (i = 0; i < count ; i++) { ColumnPairElement pair = (ColumnPairElement)pairs[i]; pairNames.add(NameUtil.getRelativeMemberName( pair.getName().getFullName())); } removeColumnPairs(pairNames); }
/** 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; }
private boolean isPairComplete (DBMemberElement member) { return ((member instanceof ColumnPairElement) && (((ColumnPairElement)member).getLocalColumn() != null) && (((ColumnPairElement)member).getReferencedColumn() != null)); } };
/** Get the referenced table of the 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 referenced table */ public TableElement getReferencedTable () { ColumnPairElement[] columnPairs = getColumnPairs(); if ((columnPairs != null) && (columnPairs.length > 0)) return columnPairs[0].getReferencedColumn().getDeclaringTable(); return null; }
/** Get all local 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[] getLocalColumns () { 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].getLocalColumn(); return columns; }
/** Returns <code>true</code> if the specified list of column * pair names matches exactly the specified FK. */ private boolean matchesFK (List pairNames, ForeignKeyElement foreignKey) { ColumnPairElement[] fkPairs = foreignKey.getColumnPairs(); int fkCount = ((fkPairs != null) ? fkPairs.length : 0); int count = ((pairNames != null) ? pairNames.size() : 0); // First check whether the list of fk column pairs has the // same size than the specified list of columns. if (fkCount == count) { // Now check whether each fk column is included in the // specified list of columns. for (int i = 0; i < fkCount; i++) { String fkPairName = NameUtil.getRelativeMemberName( fkPairs[i].getName().getFullName()); if (!pairNames.contains(fkPairName)) return false; } return true; } return false; } };
private boolean isMappedToBlob (ColumnPairElement pair) { return ((pair == null) ? false : isMappedToBlob(pair.getLocalColumn()) && isMappedToBlob(pair.getReferencedColumn())); } private boolean isMappedToBlob (ColumnElement column)
/** Get the referenced table of the 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 referenced table */ public TableElement getReferencedTable () { ColumnPairElement[] columnPairs = getColumnPairs(); if ((columnPairs != null) && (columnPairs.length > 0)) return columnPairs[0].getReferencedColumn().getDeclaringTable(); return null; }