/** 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())); }
/** 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); }
String[] oneParam = { table.getName().getName() };
/** Returns a List of Strings of "drop constraint" DDL commands. Each * String has the format: * <pre> * DROP TABLE table_name * </pre> * @param table Table for which constraints are to be dropped. * @return List of Strings, one per "drop constraint" command. */ private static List createDropConstraintsDDL(TableElement table) { List alterTbls = new ArrayList(); String[] twoParams = new String[2]; twoParams[0] = table.getName().getName(); ForeignKeyElement[] fkeys = table.getForeignKeys(); if (fkeys != null) { for (int i = 0; i < fkeys.length; i++) { twoParams[1] = fkeys[i].getName().getName(); String alterTblString = DDLTemplateFormatter.formatAlterTableDropConstraint( twoParams); alterTbls.add(alterTblString); } } return alterTbls; }
List alterTblDDL = new ArrayList(); String[] fourParams = new String[4]; String[] oneParam = { table.getName().getName() }; fourParams[0] = fkey.getName().getName(); fourParams[1] = getColumnNames(fkey.getLocalColumns()); fourParams[2] = fkey.getReferencedTable().getName().getName(); fourParams[3] = getColumnNames(fkey.getReferencedColumns());
/** * 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); }
table, mappingPolicy.getPrimaryKeyConstraintName( table.getName().getName())); MappingClassElement mappingClass = createMappingClass( pcClass, table);
private ColumnElement getColumnElement(TableElement sourceTableEl, DBIdentifier sourceColumnName, ConversionHelper helper) throws DBException, ConversionException { ColumnElement aCol = sourceTableEl.getColumn(sourceColumnName); if (null == aCol && !helper.ensureValidation()) { aCol = new ColumnElement(); aCol.setName(DBIdentifier.create(sourceTableEl.getName().toString()+"."+sourceColumnName.toString())); // NOI18N aCol.setDeclaringTable(sourceTableEl); aCol.setNullable(true); } if (aCol == null) { throw new ConversionException( I18NHelper.getMessage( messages, "ERR_INVALID_COLUMN", //NOI18N new Object [] {sourceColumnName, sourceTableEl})); } return aCol; }
/** * Create primary key and add to table. * @param table TableElement for adding primary key. * @return UniqueKeyElement that represents the primary key. * @throws DBException */ static UniqueKeyElement createAndAttachPrimaryKey(TableElement table, String pKeyName) throws DBException { String tableName = table.getName().getName(); String fullName = NameUtil.getAbsoluteMemberName(tableName, pKeyName); // create index for primary key TableElementImpl tableImpl = (TableElementImpl)table.getElementImpl(); IndexElementImpl indexImpl = new IndexElementImpl(tableImpl, fullName, true); IndexElement index = new IndexElement(indexImpl, table); index.setUnique(true); UniqueKeyElementImpl pKeyImpl = new UniqueKeyElementImpl(); UniqueKeyElement pKey = new UniqueKeyElement(pKeyImpl, table, index); pKey.setName(DBIdentifier.create(fullName)); pKey.setPrimaryKey(true); table.addKey(pKey); table.addIndex(pKey.getAssociatedIndex()); return pKey; }
new org.netbeans.modules.dbschema.UniqueKeyElement(); ColumnElement fakeKeyCol = new ColumnElement(); fakeKeyCol.setName(DBIdentifier.create(retVal.getName().getName()+ "."+"fookeyng")); //NOI18N
/** * Create column and add to the table. * @param columnName Name of the column to create. * @param declaringTbl The declaring table to which column gets added. * @return ColumnElement that represents the newly-added column. * @throws DBException */ static ColumnElement createAndAttachColumn(String columnName, TableElement table, JDBCInfo ji) throws DBException { // Create column id String fullName = NameUtil.getAbsoluteMemberName( table.getName().getName(), columnName); DBIdentifier columnId = DBIdentifier.create(columnName); ColumnElementImpl columnImpl = new ColumnElementImpl(); ColumnElement column = new ColumnElement(columnImpl, table); column.setName(columnId); column.setType(ji.getJdbcType()); column.setNullable(ji.getNullable()); column.setPrecision(ji.getPrecision()); column.setScale(ji.getScale()); column.setLength(ji.getLength()); table.addColumn(column); return column; }
String refTblName = refTbl.getName().getName();