Search in sources :

Example 1 with TableSchemaCompareModelInputLazy

use of com.cubrid.common.ui.compare.schema.control.TableSchemaCompareModelInputLazy in project cubrid-manager by CUBRID.

the class ImportERwinAction method createCompareModel.

/**
	 *
	 * @param tableSchema
	 * @param schemaInfos
	 */
private void createCompareModel(final String modelName, final Map<String, TableSchema> tableSchema, final Map<String, ERWinSchemaInfo> schemaInfos) {
    final List<TableSchemaCompareModelInputLazy> input = new ArrayList<TableSchemaCompareModelInputLazy>();
    ITask reportBugTask = new AbstractUITask() {

        private boolean success = false;

        public void cancel() {
        }

        public void finish() {
        }

        public boolean isCancel() {
            return false;
        }

        public boolean isSuccess() {
            return success;
        }

        public void execute(IProgressMonitor monitor) {
            List<TableDetailInfo> leftDbTableInfoList = TableSchemaCompareUtil.getTableInfoList(database);
            final CubridDatabase virtualDb = new CubridDatabase(modelName, modelName);
            virtualDb.setVirtual(true);
            DatabaseInfo info = database.getDatabaseInfo();
            virtualDb.setDatabaseInfo(info);
            WrappedDatabaseInfo wrappedDatabaseInfo = new WrappedDatabaseInfo(info);
            Map<String, SchemaInfo> dbSchemaInfos = new HashMap<String, SchemaInfo>();
            Collection<ERWinSchemaInfo> erwinSchemas = schemaInfos.values();
            for (ERWinSchemaInfo erwinSchema : erwinSchemas) {
                SchemaInfo schemaInfo = (SchemaInfo) erwinSchema;
                dbSchemaInfos.put(schemaInfo.getClassname(), schemaInfo);
            }
            wrappedDatabaseInfo.addSchemaInfos(dbSchemaInfos);
            wrappedDatabaseInfo.addTableSchemas(tableSchema);
            ERXmlDatabaseInfoMapper.addWrappedDatabaseInfo(info, wrappedDatabaseInfo);
            TableSchemaModel leftModel = TableSchemaCompareUtil.createTableSchemaModel(leftDbTableInfoList);
            TableSchemaModel rightModel = new TableSchemaModel();
            rightModel.getTableSchemaMap().putAll(tableSchema);
            TableSchemaComparator comparator = new TableSchemaComparator(database, virtualDb);
            TableSchemaCompareModel model = comparator.compare(leftModel, rightModel);
            model.setSourceDB(database);
            model.setTargetDB(virtualDb);
            // TODO rename class to ErwinCompareModelInput
            input.add(new TableSchemaCompareModelInputLazy(model));
            success = true;
        }
    };
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.titleSchemaComparison);
    taskExecutor.addTask(reportBugTask);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        try {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input.get(0), TableSchemaCompareInfoPart.ID);
        } catch (Exception e) {
        }
    }
}
Also used : TableSchemaCompareModelInputLazy(com.cubrid.common.ui.compare.schema.control.TableSchemaCompareModelInputLazy) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) HashMap(java.util.HashMap) TableSchemaComparator(com.cubrid.common.ui.compare.schema.TableSchemaComparator) ArrayList(java.util.ArrayList) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) TableSchemaModel(com.cubrid.common.ui.compare.schema.model.TableSchemaModel) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) TableSchemaCompareModel(com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ERWinSchemaInfo(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) ERWinSchemaInfo(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)

Example 2 with TableSchemaCompareModelInputLazy

use of com.cubrid.common.ui.compare.schema.control.TableSchemaCompareModelInputLazy in project cubrid-manager by CUBRID.

the class ERSchemaEditor method compareTableSchemas.

public void compareTableSchemas(final String modelName, final Map<String, TableSchema> tableSchema, final Map<String, SchemaInfo> schemaInfos) {
    final List<TableSchemaCompareModelInputLazy> input = new ArrayList<TableSchemaCompareModelInputLazy>();
    ITask reportBugTask = new AbstractUITask() {

        private boolean success = false;

        public void cancel() {
        }

        public void finish() {
        }

        public boolean isCancel() {
            return false;
        }

        public boolean isSuccess() {
            return success;
        }

        public void execute(IProgressMonitor monitor) {
            CubridDatabase database = erSchema.getCubridDatabase();
            List<TableDetailInfo> leftDbTableInfoList = TableSchemaCompareUtil.getTableInfoList(database);
            final CubridDatabase virtualDb = new CubridDatabase(modelName, modelName);
            virtualDb.setVirtual(true);
            DatabaseInfo info = database.getDatabaseInfo();
            virtualDb.setDatabaseInfo(info);
            WrappedDatabaseInfo wrappedDatabaseInfo = new WrappedDatabaseInfo(info);
            wrappedDatabaseInfo.addSchemaInfos(schemaInfos);
            wrappedDatabaseInfo.addTableSchemas(tableSchema);
            ERXmlDatabaseInfoMapper.addWrappedDatabaseInfo(info, wrappedDatabaseInfo);
            TableSchemaModel leftModel = TableSchemaCompareUtil.createTableSchemaModel(leftDbTableInfoList);
            TableSchemaModel rightModel = new TableSchemaModel();
            rightModel.getTableSchemaMap().putAll(tableSchema);
            TableSchemaComparator comparator = new TableSchemaComparator(database, virtualDb);
            TableSchemaCompareModel model = comparator.compare(leftModel, rightModel);
            model.setSourceDB(database);
            model.setTargetDB(virtualDb);
            input.add(new TableSchemaCompareModelInputLazy(model));
            success = true;
        }
    };
    TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.common.ui.common.Messages.titleSchemaComparison);
    taskExecutor.addTask(reportBugTask);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        try {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input.get(0), TableSchemaCompareInfoPart.ID);
        } catch (Exception e) {
        }
    }
}
Also used : TableSchemaCompareModelInputLazy(com.cubrid.common.ui.compare.schema.control.TableSchemaCompareModelInputLazy) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ITask(com.cubrid.common.core.task.ITask) ERVirtualDatabaseInfo(com.cubrid.common.ui.er.model.ERVirtualDatabaseInfo) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) TableSchemaComparator(com.cubrid.common.ui.compare.schema.TableSchemaComparator) ArrayList(java.util.ArrayList) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) TableSchemaModel(com.cubrid.common.ui.compare.schema.model.TableSchemaModel) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) PartInitException(org.eclipse.ui.PartInitException) SQLException(java.sql.SQLException) TableSchemaCompareModel(com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

TableDetailInfo (com.cubrid.common.core.common.model.TableDetailInfo)2 AbstractUITask (com.cubrid.common.core.task.AbstractUITask)2 ITask (com.cubrid.common.core.task.ITask)2 TableSchemaComparator (com.cubrid.common.ui.compare.schema.TableSchemaComparator)2 TableSchemaCompareModelInputLazy (com.cubrid.common.ui.compare.schema.control.TableSchemaCompareModelInputLazy)2 TableSchemaCompareModel (com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel)2 TableSchemaModel (com.cubrid.common.ui.compare.schema.model.TableSchemaModel)2 WrappedDatabaseInfo (com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 ArrayList (java.util.ArrayList)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)1 ERWinSchemaInfo (com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)1 ERVirtualDatabaseInfo (com.cubrid.common.ui.er.model.ERVirtualDatabaseInfo)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1