Search in sources :

Example 86 with SchemaInfo

use of com.cubrid.common.core.common.model.SchemaInfo in project cubrid-manager by CUBRID.

the class TableDashboardDetailContentProvider method getElements.

/**
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
	 * @param inputElement the input element
	 * @return the array of elements to display in the viewer
	 */
public Object[] getElements(Object inputElement) {
    if (inputElement instanceof SchemaInfo) {
        SchemaInfo schema = (SchemaInfo) inputElement;
        List<DBAttribute> list = new ArrayList<DBAttribute>();
        if (showClassAttribute) {
            list.addAll(schema.getClassAttributes());
        }
        list.addAll(schema.getAttributes());
        return list.toArray();
    } else {
        return new Object[0];
    }
}
Also used : DBAttribute(com.cubrid.common.core.common.model.DBAttribute) ArrayList(java.util.ArrayList) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 87 with SchemaInfo

use of com.cubrid.common.core.common.model.SchemaInfo in project cubrid-manager by CUBRID.

the class CubridIndexNavigatorContentProvider method getElements.

public Object[] getElements(Object inputElement) {
    if (inputElement instanceof SchemaInfo) {
        SchemaInfo schema = (SchemaInfo) inputElement;
        List<Constraint> list = new ArrayList<Constraint>();
        List<Constraint> constraints = schema.getConstraints();
        for (Constraint constraint : constraints) {
            if (constraint.getType().equals(Constraint.ConstraintType.INDEX.getText()) || constraint.getType().equals(Constraint.ConstraintType.UNIQUE.getText()) || constraint.getType().equals(Constraint.ConstraintType.REVERSEINDEX.getText()) || constraint.getType().equals(Constraint.ConstraintType.REVERSEUNIQUE.getText()) || constraint.getType().equals(Constraint.ConstraintType.PRIMARYKEY.getText())) {
                list.add(constraint);
            }
        }
        return list.toArray();
    } else {
        return new Object[0];
    }
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) ArrayList(java.util.ArrayList) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 88 with SchemaInfo

use of com.cubrid.common.core.common.model.SchemaInfo in project cubrid-manager by CUBRID.

the class CubridIndexNavigatorView method setFocus.

public void setFocus() {
    CubridNavigatorView mainNav = CubridNavigatorView.findNavigationView();
    if (mainNav != null) {
        SchemaInfo schemaInfo = mainNav.getCurrentSchemaInfo();
        updateView(schemaInfo);
    }
}
Also used : SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 89 with SchemaInfo

use of com.cubrid.common.core.common.model.SchemaInfo 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)

Example 90 with SchemaInfo

use of com.cubrid.common.core.common.model.SchemaInfo in project cubrid-manager by CUBRID.

the class ERSchemaEditor method compareDDL2DB.

public void compareDDL2DB() {
    DatabaseInfo info = database.getDatabaseInfo();
    if (info == null) {
        CommonUITool.openErrorBox(Messages.errNoDatabase);
        return;
    }
    if (!info.isLogined()) {
        CommonUITool.openErrorBox(Messages.msgDBNotLogin);
        return;
    }
    ServerInfo serverInfo = info.getServerInfo();
    if (serverInfo != null && !serverInfo.isConnected()) {
        CommonUITool.openErrorBox(Messages.msgDBNotLogin);
        return;
    }
    Map<String, SchemaInfo> schemaInfos = erSchema.getAllSchemaInfo();
    Map<String, TableSchema> tableSchemas = new HashMap<String, TableSchema>();
    WrappedDatabaseInfo wrappedDatabaseInfo = new WrappedDatabaseInfo(info.getDbName(), info.getServerInfo());
    ERXmlDatabaseInfoMapper.addWrappedDatabaseInfo(info, wrappedDatabaseInfo);
    wrappedDatabaseInfo.addSchemaInfos(schemaInfos);
    SchemaDDL ddl = new SchemaDDL(null, wrappedDatabaseInfo);
    for (String tableName : schemaInfos.keySet()) {
        SchemaInfo schemaInfo = schemaInfos.get(tableName);
        if (schemaInfo == null || !tableName.equals(schemaInfo.getClassname())) {
            continue;
        }
        // now do not support view table
        String strDDL = ddl.getSchemaDDL(schemaInfo, true, true);
        TableSchema tableSchema = new TableSchema(tableName, "");
        tableSchema.setSchemaInfo(strDDL);
        tableSchemas.put(tableSchema.getName(), tableSchema);
    }
    wrappedDatabaseInfo.addTableSchemas(tableSchemas);
    compareTableSchemas(getEditorInput().getName(), tableSchemas, schemaInfos);
}
Also used : TableSchema(com.cubrid.common.ui.compare.schema.model.TableSchema) 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) HashMap(java.util.HashMap) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SchemaDDL(com.cubrid.cubridmanager.core.cubrid.table.model.SchemaDDL) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Aggregations

SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)136 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)57 Constraint (com.cubrid.common.core.common.model.Constraint)56 ArrayList (java.util.ArrayList)47 HashMap (java.util.HashMap)15 List (java.util.List)15 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)11 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)11 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)10 Connection (java.sql.Connection)10 SerialInfo (com.cubrid.common.core.common.model.SerialInfo)9 SQLException (java.sql.SQLException)9 TableItem (org.eclipse.swt.widgets.TableItem)9 SchemaComment (com.cubrid.common.core.schemacomment.model.SchemaComment)8 SchemaDDL (com.cubrid.cubridmanager.core.cubrid.table.model.SchemaDDL)8 PartitionInfo (com.cubrid.common.core.common.model.PartitionInfo)7 ERWinSchemaInfo (com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 DBResolution (com.cubrid.common.core.common.model.DBResolution)6 Map (java.util.Map)5