Search in sources :

Example 1 with GetRecordCountTask

use of com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask in project cubrid-manager by CUBRID.

the class ColumnSelectCountAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            Object[] obj = getSelectedObj();
            if (!isSupported(obj)) {
                setEnabled(false);
                return;
            }
            ISchemaNode column = (ISchemaNode) obj[0];
            ISchemaNode table = (ISchemaNode) column.getParent().getParent();
            String columnName = column.getName().split(",")[0];
            if ("".equals(columnName)) {
                // FIXME
                return;
            }
            CubridDatabase db = table.getDatabase();
            DatabaseInfo dbInfo = db.getDatabaseInfo();
            GetRecordCountTask task = new GetRecordCountTask(dbInfo);
            int count = task.getRecordCount(table.getName(), columnName, null);
            String[] bindings = new String[] { columnName, table.getName(), String.valueOf(count) };
            if (count > 1) {
                message = Messages.bind(Messages.columnSelectCountResult2, bindings);
            } else {
                message = Messages.bind(Messages.columnSelectCountResult1, bindings);
            }
        }
    });
    CommonUITool.openInformationBox(Messages.selectCountTitle, message);
}
Also used : GetRecordCountTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 2 with GetRecordCountTask

use of com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask in project cubrid-manager by CUBRID.

the class TableSelectCountAction method doRun.

/**
	 * Perform select
	 * 
	 * @param table
	 */
private void doRun(final ISchemaNode table) {
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            CubridDatabase db = table.getDatabase();
            DatabaseInfo dbInfo = db.getDatabaseInfo();
            GetRecordCountTask task = new GetRecordCountTask(dbInfo);
            int count = task.getRecordCount(table.getName(), null);
            if (count > 1) {
                message = Messages.bind(Messages.selectCountResult2, table.getName(), count);
            } else {
                message = Messages.bind(Messages.selectCountResult1, table.getName(), count);
            }
        }
    });
    CommonUITool.openInformationBox(Messages.selectCountTitle, message);
}
Also used : GetRecordCountTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 3 with GetRecordCountTask

use of com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask in project cubrid-manager by CUBRID.

the class ConstraintComparator method getAlterAutoIncrementDDL.

/**
	 *
	 * Depending the change auto increment
	 *
	 * @param tableName String the given table name
	 * @param columnName String the given column name
	 * @param startWith String the given startWith
	 * @param incrementby String the given incrementBy
	 * @param minValue String the given columnName
	 * @return String a string that indicates the DDL of alter auto increment
	 */
public String getAlterAutoIncrementDDL(String tableName, String columnName) {
    StringBuilder ddl = new StringBuilder();
    int autoIncrementSeed = new GetRecordCountTask(databaseInfo).getRecordCount(tableName, columnName, null) + 1;
    boolean isSupportAlterAutoIncrement = CompatibleUtil.isAfter840(databaseInfo);
    if (isSupportAlterAutoIncrement) {
        ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(tableName)).append(" AUTO_INCREMENT=").append(autoIncrementSeed).append(endLineChar).append(StringUtil.NEWLINE);
        return ddl.toString();
    } else {
        ddl.append("--NotSupportAlterAutoIncrement");
        return ddl.toString();
    }
}
Also used : GetRecordCountTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask) Constraint(com.cubrid.common.core.common.model.Constraint)

Aggregations

GetRecordCountTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask)3 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 Constraint (com.cubrid.common.core.common.model.Constraint)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1