Search in sources :

Example 6 with GetAllSchemaTask

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

the class ERSchemaEditor method getUpdateDescriptionTaskList.

/**
	 * Get UpdateDescriptionTaskList
	 *
	 * @param dbInfo
	 * @return
	 */
private List<UpdateDescriptionTask> getUpdateDescriptionTaskList(DatabaseInfo dbInfo) {
    List<UpdateDescriptionTask> updateDescriptionTaskList = new ArrayList<UpdateDescriptionTask>();
    Map<String, SchemaInfo> schemaInfos = erSchema.getAllSchemaInfo();
    Collection<SchemaInfo> erdSchemaInfos = schemaInfos.values();
    GetAllSchemaTask task = new GetAllSchemaTask(dbInfo);
    task.execute();
    Map<String, SchemaInfo> dbSchemaInfoMap = task.getSchemas();
    String taskName = com.cubrid.common.ui.cubrid.table.Messages.updateDescriptionTask;
    for (SchemaInfo newSchemaInfo : erdSchemaInfos) {
        String tableName = newSchemaInfo.getClassname();
        SchemaInfo dbSchemaInfo = dbSchemaInfoMap.get(tableName);
        if (dbSchemaInfo == null) {
            continue;
        }
        for (DBAttribute newAttr : newSchemaInfo.getAttributes()) {
            DBAttribute oldAttr = dbSchemaInfo.getDBAttributeByName(newAttr.getName(), newAttr.isClassAttribute());
            if (oldAttr == null || StringUtil.isEqual(oldAttr.getDescription(), newAttr.getDescription())) {
                continue;
            }
            updateDescriptionTaskList.add(new UpdateDescriptionTask(taskName, dbInfo, tableName, newAttr.getName(), newAttr.getDescription()));
        }
        if (!StringUtil.isEqual(dbSchemaInfo.getDescription(), newSchemaInfo.getDescription())) {
            updateDescriptionTaskList.add(new UpdateDescriptionTask(taskName, dbInfo, tableName, "", newSchemaInfo.getDescription()));
        }
    }
    return updateDescriptionTaskList;
}
Also used : DBAttribute(com.cubrid.common.core.common.model.DBAttribute) ArrayList(java.util.ArrayList) GetAllSchemaTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllSchemaTask) UpdateDescriptionTask(com.cubrid.cubridmanager.core.cubrid.table.task.UpdateDescriptionTask) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Aggregations

GetAllSchemaTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllSchemaTask)6 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)3 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 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 PartitionInfo (com.cubrid.common.core.common.model.PartitionInfo)1 TableDetailInfo (com.cubrid.common.core.common.model.TableDetailInfo)1 SchemaComment (com.cubrid.common.core.schemacomment.model.SchemaComment)1 ITask (com.cubrid.common.core.task.ITask)1 DataCompare (com.cubrid.common.ui.compare.data.model.DataCompare)1 TableSchema (com.cubrid.common.ui.compare.schema.model.TableSchema)1 TableSchemaCompareModel (com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel)1 WrappedDatabaseInfo (com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo)1 ExportSchemaTask (com.cubrid.common.ui.cubrid.database.erwin.task.ExportSchemaTask)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1