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 isPairComplete (DBMemberElement member) { return ((member instanceof ColumnPairElement) && (((ColumnPairElement)member).getLocalColumn() != null) && (((ColumnPairElement)member).getReferencedColumn() != null)); } };
private ColumnElement getLocalColumn (String pairName, String databaseRoot) { ColumnPairElement pair = getPair(pairName, databaseRoot); return ((pair != null) ? pair.getLocalColumn() : null); } private boolean isPrimaryKeyColumn (ColumnElement column)
/** * createIndexDDL has been added for Symfoware support. Returns DDL in String form * to create index. The returned string has the format: * <pre> * CREATE INDEX table_name.table_name KEY(id, name) * </pre> * @param table Table for which DDL is to be created. * @return DDL to create index. */ private static String createIndexDDL(TableElement table) { String[] twoParam = { table.getName().getName() , getColumnNames(table.getPrimaryKey().getColumns()) }; return DDLTemplateFormatter.formatCreateIndex(twoParam); }
/** * Creates and returns a schema from give schema name * @param schemaName A name for schema. * @return Newly created schema element. * @throws DBException */ static SchemaElement createSchema(String schemaName) throws DBException { SchemaElementImpl schemaImpl = new SchemaElementImpl(); SchemaElement schema = new SchemaElement(schemaImpl); schema.setName(DBIdentifier.create(schemaName)); schema.setDatabaseProductVersion(TAGLINE + SIGNATURE); return schema; }
private ColumnPairElement getPair (String pairName, String databaseRoot) { String absoluteName = NameUtil.getAbsoluteMemberName( databaseRoot, pairName); TableElement tableElement = TableElement.forName( NameUtil.getTableName(absoluteName)); DBMemberElement pair = ((tableElement == null) ? null : tableElement.getMember(DBIdentifier.create(absoluteName))); return ((pair instanceof ColumnPairElement) ? ((ColumnPairElement)pair) : null); }
/** Check if the table of the column matches one of the list of tables. * @param tableNames A list of table names in which to check for a match * @param column A ColumnElement object to be checked * @return <code>true</code> if the column belongs to a table found * in the supplied list of table names, <code>false</code> otherwise */ private boolean matchesTable (List tableNames, ColumnElement column) { return ((column == null) ? true : tableNames.contains( column.getDeclaringTable().getName().getName())); }
/** * Returns DDL in String form to drop a table. The returned string has * the format: * <pre> * DROP TABLE table_name * </pre> * @param table Table for which dropping DDL is returned. * @return DDL to drop a table. */ private static String createDropTableDDL(TableElement table) { String[] oneParam = { table.getName().getName() }; return DDLTemplateFormatter.formatDropTable(oneParam); }
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,
/** Returns <code>true</code> if the specified FK has at least * one non-nullable column. Please note that the caller is * responsible for passing a non-null fk argument. */ private boolean hasNonNullableColumn (ForeignKeyElement fk) { ColumnElement[] localColumns = fk.getLocalColumns(); int count = ((localColumns != null) ? localColumns.length : 0); for (int i = 0; i < count; i++) { if (!localColumns[i].isNullable()) return true; } return false; }
/** * 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())); }
/** 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; }
private ColumnPairElement getPair (String pairName, String databaseRoot) { String absoluteName = NameUtil.getAbsoluteMemberName( databaseRoot, pairName); TableElement tableElement = TableElement.forName( NameUtil.getTableName(absoluteName)); DBMemberElement pair = ((tableElement == null) ? null : tableElement.getMember(DBIdentifier.create(absoluteName))); return ((pair instanceof ColumnPairElement) ? ((ColumnPairElement)pair) : null); }
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,
/** Check if the table of the column matches one of the list of tables. * @param tableNames A list of table names in which to check for a match * @param column A ColumnElement object to be checked * @return <code>true</code> if the column belongs to a table found * in the supplied list of table names, <code>false</code> otherwise */ private boolean matchesTable (List tableNames, ColumnElement column) { return ((column == null) ? true : tableNames.contains( column.getDeclaringTable().getName().getName())); }
private boolean isPairComplete (DBMemberElement member) { return ((member instanceof ColumnPairElement) && (((ColumnPairElement)member).getLocalColumn() != null) && (((ColumnPairElement)member).getReferencedColumn() != null)); } };
/** Returns <code>true</code> if the specified FK has at least * one non-nullable column. Please note that the caller is * responsible for passing a non-null fk argument. */ private boolean hasNonNullableColumn (ForeignKeyElement fk) { ColumnElement[] localColumns = fk.getLocalColumns(); int count = ((localColumns != null) ? localColumns.length : 0); for (int i = 0; i < count; i++) { if (!localColumns[i].isNullable()) return true; } return false; }
/** 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; }
private ColumnElement getLocalColumn (String pairName, String databaseRoot) { ColumnPairElement pair = getPair(pairName, databaseRoot); return ((pair != null) ? pair.getLocalColumn() : null); } private boolean isPrimaryKeyColumn (ColumnElement column)
private boolean isMappedToBlob (ColumnPairElement pair) { return ((pair == null) ? false : isMappedToBlob(pair.getLocalColumn()) && isMappedToBlob(pair.getReferencedColumn())); } private boolean isMappedToBlob (ColumnElement column)