Search in sources :

Example 1 with SerialInfo

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

the class ERXmlContainer method parseAttributes.

private void parseAttributes() {
    NodeList attributes = doc.getElementsByTagName("Attribute");
    for (int i = 0; i < attributes.getLength(); i++) {
        Node attribute = attributes.item(i);
        ERWinDBAttribute erwinAttribute = new ERWinDBAttribute();
        String attrId = attribute.getAttributes().getNamedItem("id").getNodeValue().trim();
        //logical name
        String attrName = attribute.getAttributes().getNamedItem("Name").getNodeValue().trim();
        erwinAttribute.setLogicalName(attrName);
        attributeMap.put(attrId, erwinAttribute);
        String physicalName = "";
        String fkAttrName = "";
        int attributeType = -1;
        boolean duplicate = false;
        Node pNode = findPNode(attribute, "Entity");
        if (pNode == null) {
            continue;
        }
        String pId = pNode.getAttributes().getNamedItem("id").getNodeValue().trim();
        String tableName = physicalNameMap.get(pId);
        if (tableName == null) {
            tableName = pNode.getAttributes().getNamedItem("Name").getNodeValue().trim();
        }
        ERWinSchemaInfo schemaInfo = schemaInfos.get(tableName);
        for (int ii = 0; ii < attribute.getChildNodes().getLength(); ii++) {
            Node tempNode = attribute.getChildNodes().item(ii);
            if (tempNode.getNodeName().equals("AttributeProps")) {
                physicalName = handler.getChildValueByProperty(tempNode, "Physical_Name");
                if (physicalName == null) {
                    physicalName = attrName;
                }
                DBAttribute duplicateAttr = schemaInfo.getDBAttributeByName(physicalName, false);
                if (duplicateAttr != null) {
                    duplicate = true;
                    break;
                }
                erwinAttribute.setName(physicalName);
                columnIdMap.put(attrId, physicalName);
                Node attributePropsChild = tempNode.getFirstChild();
                while (attributePropsChild != null) {
                    String attributeName = attributePropsChild.getNodeName();
                    if (attributeName.equals("Datatype")) {
                        String dataType = attributePropsChild.getFirstChild().getNodeValue().trim();
                        if (dataType.startsWith(DataType.getUpperEnumType())) {
                            //convert to show type
                            dataType = dataType.replaceFirst(DataType.getUpperEnumType(), DataType.getLowerEnumType());
                        }
                        String enumeration = DataType.getEnumeration(dataType);
                        if (!StringUtil.isEmpty(enumeration)) {
                            dataType = DataType.getUpperEnumType();
                            erwinAttribute.setEnumeration(enumeration);
                        }
                        erwinAttribute.setType(dataType);
                        erwinAttribute.setDefault(updateData(dataType, erwinAttribute.getDefault()));
                    } else if (attributeName.equals("Type")) {
                        attributeType = Integer.parseInt(attributePropsChild.getFirstChild().getNodeValue().trim());
                    } else if (attributeName.equals("Null_Option")) {
                        int value = Integer.parseInt(attributePropsChild.getFirstChild().getNodeValue().trim());
                        switch(value) {
                            case 1:
                            case 8:
                                erwinAttribute.setNotNull(true);
                                break;
                            default:
                                break;
                        }
                    } else if (attributeName.equals("Default")) {
                        String id = attributePropsChild.getFirstChild().getNodeValue().trim();
                        Node defaultValueNode = getNodeById(id, "Default_Value");
                        if (defaultValueNode == null) {
                            attributePropsChild = attributePropsChild.getNextSibling();
                            continue;
                        }
                        String value = handler.getChildValueByProperty(defaultValueNode, "Default_ValueProps.Server_Value");
                        if (erwinAttribute.getType() != null) {
                            value = updateData(erwinAttribute.getType(), value);
                        }
                        erwinAttribute.setDefault(value);
                    } else if (attributeName.equals("Identity_Seed")) {
                        SerialInfo serialInfo = new SerialInfo();
                        serialInfo.setIncrementValue(attributePropsChild.getFirstChild().getNodeValue().trim());
                        erwinAttribute.setAutoIncrement(serialInfo);
                    } else if (attributeName.equals("Parent_Domain")) {
                        String id = attributePropsChild.getFirstChild().getNodeValue();
                        String value = handler.getNodeChildValueById("Domain", id, "DomainProps.Datatype");
                        if (value == null) {
                            // if it has reference-id (DomainProps.Parent_Domain)
                            String refId = handler.getNodeChildValueById("Domain", id, "DomainProps.Parent_Domain");
                            value = handler.getNodeChildValueById("Domain", refId, "DomainProps.Datatype");
                        }
                        if (StringUtil.isEmpty(erwinAttribute.getType())) {
                            erwinAttribute.setType(DataType.getRealType(StringUtil.toUpper(value)));
                        }
                    } else if (attributeName.equals("Parent_Relationship")) {
                        String id = attributePropsChild.getFirstChild().getNodeValue().trim();
                        Constraint relType = foreignKeyMap.get(id);
                        if (relType != null) {
                            boolean isPk = relType.getType().equals(Constraint.ConstraintType.PRIMARYKEY.getText());
                            boolean isFk = relType.getType().equals(Constraint.ConstraintType.FOREIGNKEY.getText());
                            if (isPk || isFk) {
                                erwinAttribute.setNotNull(true);
                                erwinAttribute.setUnique(true);
                            }
                        }
                    } else if (attributeName.equals("Physical_Name")) {
                        physicalName = attributePropsChild.getFirstChild().getNodeValue().trim();
                    } else if (attributeName.equals("Logical_Datatype")) {
                        String logicalDataType = attributePropsChild.getFirstChild().getNodeValue().trim();
                        erwinAttribute.setLogicalDataType(logicalDataType);
                    } else if (attributeName.equals("Parent_Attribute")) {
                        String id = attributePropsChild.getFirstChild().getNodeValue().trim();
                        Node fkAttrNode = getNodeById(id, "Attribute");
                        if (fkAttrNode == null) {
                            attributePropsChild = attributePropsChild.getNextSibling();
                            continue;
                        }
                        fkAttrName = handler.getChildValueByProperty(fkAttrNode, "AttributeProps.Physical_Name");
                        if (fkAttrName == null) {
                            fkAttrName = fkAttrNode.getAttributes().getNamedItem("Name").getNodeValue().trim();
                        }
                        Node fkTableNode = findPNode(fkAttrNode, "Entity");
                        String fkTableId = fkTableNode.getAttributes().getNamedItem("id").getNodeValue().trim();
                        String fkTableName = physicalNameMap.get(fkTableId);
                        erwinAttribute.setInherit(fkTableName);
                    // SchemaInfo schemaInfo = schemaInfos.get(tName);
                    // schemaInfo.addSuperClass(tableName);
                    } else if (attributeName.equals("View_Expression")) {
                        fkAttrName = attributePropsChild.getFirstChild().getNodeValue().trim();
                    }
                    attributePropsChild = attributePropsChild.getNextSibling();
                }
            }
        }
        if (duplicate) {
            continue;
        }
        if (attributeType != ERXmlModelConstant.ATTRIBUTE_TYPE_VIEW) {
            if (attributeType == ERXmlModelConstant.ATTRIBUTE_TYPE_PK) {
                erwinAttribute.setUnique(true);
                erwinAttribute.setNotNull(true);
            }
            erwinAttribute.setInherit(tableName);
            schemaInfo.addAttribute(erwinAttribute);
        } else {
            String viewName = tableName;
            if (viewName == null) {
                viewName = pNode.getAttributes().getNamedItem("Name").getNodeValue().trim();
            }
            ViewModel model = viewModelMap.get(viewName);
            String pTable = erwinAttribute.getInherit();
            if (pTable == null) {
                pTable = "DEFAULT";
            }
            model.addTableColumnAlias(pTable, fkAttrName, erwinAttribute.getName());
        }
    }
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) ERWinDBAttribute(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinDBAttribute) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ERWinSchemaInfo(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo) ERWinDBAttribute(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinDBAttribute) SerialInfo(com.cubrid.common.core.common.model.SerialInfo) Constraint(com.cubrid.common.core.common.model.Constraint)

Example 2 with SerialInfo

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

the class EditSerialAction method run.

/**
	 * Open the editSerial dialog and edit serial
	 */
public int run(CubridDatabase database, final ISchemaNode node) {
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.loadSerialTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                SerialInfo serialInfo = null;
                if (task instanceof GetSerialInfoTask) {
                    GetSerialInfoTask getSerialInfoTask = (GetSerialInfoTask) task;
                    serialInfo = getSerialInfoTask.getSerialInfo(node.getLabel());
                }
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (serialInfo == null) {
                    openErrorBox(shell, Messages.errNameNotExist, monitor);
                    return false;
                }
                node.setModelObj(serialInfo);
            }
            return true;
        }
    };
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    GetSerialInfoTask task = new GetSerialInfoTask(databaseInfo);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return IDialogConstants.CANCEL_ID;
    }
    boolean isEditorAble = ActionSupportUtil.isSupportSinSelCheckDbUser(node, NodeType.SERIAL);
    CreateOrEditSerialDialog dialog = new CreateOrEditSerialDialog(getShell(), isEditorAble);
    dialog.setEditedNode(node);
    dialog.setDatabase(database);
    if (dialog.open() == IDialogConstants.OK_ID) {
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REFRESH));
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        return IDialogConstants.OK_ID;
    }
    return IDialogConstants.CANCEL_ID;
}
Also used : CreateOrEditSerialDialog(com.cubrid.common.ui.cubrid.serial.dialog.CreateOrEditSerialDialog) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) SerialInfo(com.cubrid.common.core.common.model.SerialInfo) GetSerialInfoTask(com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoTask)

Example 3 with SerialInfo

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

the class ERAttributeLabelProvider method getColumnText.

public String getColumnText(Object element, int columnIndex) {
    if (element == null) {
        return null;
    }
    ERTableColumn erColumn = (ERTableColumn) element;
    DBAttribute dbAttribute = erColumn.getAttr();
    if (dbAttribute == null || dbAttribute.getInherit() == null || schema == null) {
        return null;
    }
    String property = editorAdaptor.getColumnProperty(columnIndex);
    if (StringUtil.isEqual(property, IAttributeColumn.COL_FLAG)) {
        if (StringUtil.isEmpty(dbAttribute.getName())) {
            return "*";
        }
    } else if (StringUtil.isEqual(property, IAttributeColumn.COL_NAME)) {
        return erColumn.getName(isPhysical);
    } else if (StringUtil.isEqual(property, IAttributeColumn.COL_DATATYPE)) {
        if (isPhysical) {
            if (DataType.DATATYPE_ENUM.equalsIgnoreCase(dbAttribute.getType())) {
                String type = StringUtil.toUpper(dbAttribute.getType()) + dbAttribute.getEnumeration();
                return DataType.getShownType(type);
            } else {
                return DataType.getShownType(dbAttribute.getType());
            }
        } else {
            return erColumn.getShowType(false).toUpperCase();
        }
    } else if (StringUtil.isEqual(property, IAttributeColumn.COL_DEFAULT)) {
        String defaultValue = dbAttribute.getDefault();
        if (defaultValue == null) {
            return DataType.NULL_EXPORT_FORMAT;
        }
        if (defaultValue.length() == 0 && DataType.isStringType(dbAttribute.getType())) {
            return "";
        }
        return defaultValue;
    } else if (StringUtil.isEqual(property, IAttributeColumn.COL_AUTO_INCREMENT)) {
        SerialInfo serial = dbAttribute.getAutoIncrement();
        if (serial == null) {
            return "";
        }
        return serial.getMinValue() + "," + serial.getIncrementValue();
    } else if (StringUtil.isEqual(property, IAttributeColumn.COL_MEMO)) {
        return dbAttribute.getDescription();
    } else if (StringUtil.isEqual(property, IAttributeColumn.COL_COLLATION)) {
        return dbAttribute.getCollation();
    }
    return null;
}
Also used : DBAttribute(com.cubrid.common.core.common.model.DBAttribute) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) SerialInfo(com.cubrid.common.core.common.model.SerialInfo)

Example 4 with SerialInfo

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

the class SchemaDDLTest method testdata.

/**
	 * test data()
	 * 
	 */
@SuppressWarnings("unused")
public void testdata() throws Exception {
    boolean success = createTestTable();
    assertTrue(success);
    SchemaInfo sup1 = databaseInfo.getSchemaInfo("sup1");
    SchemaInfo sup2 = databaseInfo.getSchemaInfo("sup2");
    SchemaInfo test = databaseInfo.getSchemaInfo("test");
    SchemaInfo testSuperTableName = databaseInfo.getSchemaInfo("testSuperTableName");
    SchemaInfo testTableName = databaseInfo.getSchemaInfo("testTableName");
    SchemaChangeManager changeList = new SchemaChangeManager(databaseInfo, true);
    List<SchemaChangeLog> changeListNoAuto = new ArrayList<SchemaChangeLog>();
    //SchemeChangeLog schemeChangeLog= new SchemeChangeLog();
    changeList.addSchemeChangeLog(new SchemaChangeLog("a", null, SchemeInnerType.TYPE_CLASSATTRIBUTE));
    changeList.addSchemeChangeLog(new SchemaChangeLog("a", null, SchemeInnerType.TYPE_ATTRIBUTE));
    changeList.addSchemeChangeLog(new SchemaChangeLog(null, "fk", SchemeInnerType.TYPE_FK));
    changeList.addSchemeChangeLog(new SchemaChangeLog("fk", null, SchemeInnerType.TYPE_FK));
    Constraint index = testTableName.getConstraintByName("index", "UNIQUE");
    changeList.addSchemeChangeLog(new SchemaChangeLog(index.getDefaultName(testTableName.getClassname()) + "$" + //$NON-NLS-1$
    index.getName(), //$NON-NLS-1$
    null, SchemeInnerType.TYPE_INDEX));
    changeList.addSchemeChangeLog(new SchemaChangeLog("a", "a", SchemeInnerType.TYPE_ATTRIBUTE));
    changeList.addSchemeChangeLog(new SchemaChangeLog("a", "a", SchemeInnerType.TYPE_ATTRIBUTE));
    //changeListNoAuto.add(o)
    changeList.setChangeList(changeListNoAuto);
    SchemaDDL ddl = new SchemaDDL(changeList, databaseInfo);
    SchemaChangeManager changeList2 = new SchemaChangeManager(databaseInfo, false);
    SchemaDDL ddl2 = new SchemaDDL(changeList2, databaseInfo);
    List<String[]> columnConflicts = SuperClassUtil.getColumnConflicts(databaseInfo, testTableName, testTableName.getSuperClasses(), true);
    String[][] classConflicts = columnConflicts.toArray(new String[columnConflicts.size()][]);
    columnConflicts = SuperClassUtil.getColumnConflicts(databaseInfo, testTableName, testTableName.getSuperClasses(), false);
    String[][] conflicts = columnConflicts.toArray(new String[columnConflicts.size()][]);
    ddl.getSchemaDDL(sup1);
    ddl.getSchemaDDL(sup2);
    ddl.getSchemaDDL(sup1, sup2);
    ddl.getAlterDDL(sup1, sup2);
    ddl.getSchemaDDL(testTableName);
    ddl.getSchemaDDL(testTableName, testTableName);
    ddl.getAlterDDL(testTableName, testTableName);
    ddl.getSchemaDDL(testTableName, sup1);
    ddl.getSchemaDDL(sup1, testTableName);
    ddl2.getSchemaDDL(sup1);
    ddl2.getSchemaDDL(sup2);
    ddl2.getSchemaDDL(sup1, sup2);
    ddl2.getAlterDDL(sup1, sup2);
    ddl2.getSchemaDDL(testTableName);
    ddl2.getSchemaDDL(testTableName, testTableName);
    ddl2.getAlterDDL(testTableName, testTableName);
    ddl2.getSchemaDDL(testTableName, sup1);
    ddl2.getSchemaDDL(sup1, testTableName);
    String name = "name";
    String className = "className";
    String alias = "alias";
    boolean isClassResolution = true;
    DBResolution oldResolutions = new DBResolution(name, className, alias);
    oldResolutions.setName(name);
    oldResolutions.setClassName(className);
    oldResolutions.setAlias(alias);
    oldResolutions.setClassResolution(isClassResolution);
    DBResolution newResolutions = new DBResolution(name, className, alias);
    newResolutions.setName(name);
    newResolutions.setClassName(className);
    newResolutions.setAlias(alias);
    newResolutions.setClassResolution(isClassResolution);
    List<DBResolution> oldResolution = new ArrayList<DBResolution>();
    oldResolution.add(oldResolutions);
    List<DBResolution> newResolution = new ArrayList<DBResolution>();
    newResolution.add(newResolutions);
    ddl.getResolutionChanges(oldResolution, newResolution);
    List<String> oldSupers = new ArrayList<String>();
    oldSupers.add("oldstring");
    List<String> newSupers = new ArrayList<String>();
    newSupers.add("newstring");
    ddl.getSuperclassChanges(oldSupers, newSupers);
    ddl.getAddSuperClassDDL("tableName", newSupers, oldResolution, newResolution);
    ddl.getDropSuperClassesDDL("tableName", newSupers);
    ddl.getChangeOwnerDDL("tableName", "newOwner");
    String aname = "name";
    String type = "type";
    // it belongs to which class
    String inherit = "inherit";
    boolean indexed = true;
    boolean notNull = true;
    boolean shared = true;
    boolean unique = true;
    String defaultValue = "defaultValue";
    SerialInfo autoIncrement = null;
    String domainClassName = "domainClassName";
    boolean isClassAttribute = true;
    DBAttribute dbAttribute = new DBAttribute(aname, type, inherit, indexed, notNull, shared, unique, defaultValue, "iso88591_bin");
    ddl.getAddColumnDDL("tableName", dbAttribute, newSupers, sup1);
    ddl.setEndLineChar("endLineChar");
    String aclassName = "className";
    String partitionName = "partitionName";
    String partitionClassName = "partitionClassName";
    PartitionType partitionType = PartitionType.HASH;
    String partitionExpr = "partitionExpr";
    final List<String> partitionValues = new ArrayList<String>();
    partitionValues.add("str");
    partitionValues.add("str1");
    final List<String> partitionValues2 = new ArrayList<String>();
    partitionValues.add("str");
    partitionValues.add(null);
    int rows = -1;
    PartitionInfo partitionInfo4 = new PartitionInfo(aclassName, partitionName, partitionClassName, PartitionType.LIST, partitionExpr, partitionValues, rows);
    PartitionInfo partitionInfo6 = new PartitionInfo(aclassName, partitionName, partitionClassName, partitionType, partitionExpr, partitionValues2, rows);
    PartitionInfo partitionInfo7 = new PartitionInfo(aclassName, partitionName, partitionClassName, PartitionType.RANGE, partitionExpr, partitionValues, rows);
    List<PartitionInfo> partInfoList = new ArrayList<PartitionInfo>();
    partInfoList.add(partitionInfo4);
    ddl.getTransformToPartitionDDL(partInfoList);
    List<PartitionInfo> partInfoListRange = new ArrayList<PartitionInfo>();
    partInfoListRange.add(partitionInfo7);
    ddl.getTransformToPartitionDDL(partInfoListRange);
    ddl.getTransformToGenericDDL("tableName");
    ddl.getAddPartitionDDL(partitionInfo4);
    ddl.getDelPartitionDDL("tableName", "partName");
    PartitionInfo partitionInfo5 = new PartitionInfo(aclassName, partitionName, partitionClassName, partitionType, "partitionExpr1", partitionValues, -1);
    List<PartitionInfo> newPartInfoList = new ArrayList<PartitionInfo>();
    newPartInfoList.add(partitionInfo5);
    newPartInfoList.add(partitionInfo7);
    ddl.getCoalescePartitionDDL(partInfoList, newPartInfoList);
    ddl.getCoalescePartitionDDL(newPartInfoList, partInfoList);
    ddl.getCoalescePartitionDDL(newPartInfoList, partInfoListRange);
    ddl.getSplitPartitionDDL(partInfoList, newPartInfoList);
    partInfoList.clear();
    partInfoList.add(partitionInfo6);
    ddl.getSplitPartitionDDL(partInfoList, newPartInfoList);
    ddl.getAlterAutoIncrementDDL("tableName", "columnName");
    partInfoList.clear();
    partitionInfo4 = new PartitionInfo(aclassName, partitionName, partitionClassName, PartitionType.RANGE, partitionExpr, partitionValues, rows);
    partInfoList.add(partitionInfo4);
    ddl.getSplitPartitionDDL(partInfoList, newPartInfoList);
    partInfoList.clear();
    partitionInfo4 = new PartitionInfo(aclassName, partitionName, partitionClassName, PartitionType.LIST, partitionExpr, partitionValues, rows);
    partInfoList.add(partitionInfo4);
    ddl.getSplitPartitionDDL(partInfoList, newPartInfoList);
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) ArrayList(java.util.ArrayList) PartitionType(com.cubrid.common.core.common.model.PartitionType) Constraint(com.cubrid.common.core.common.model.Constraint) DBResolution(com.cubrid.common.core.common.model.DBResolution) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo) SerialInfo(com.cubrid.common.core.common.model.SerialInfo) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 5 with SerialInfo

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

the class SerialTaskTest method testSerialTask.

public void testSerialTask() {
    //test create serial
    CreateOrEditSerialTask createOrEditSerialTask = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask.createSerial("serial1", "1", "1", "100", "1", true, false, false, "10", false);
    assertTrue(createOrEditSerialTask.getErrorMsg() == null || createOrEditSerialTask.getErrorMsg().trim().length() <= 0);
    GetSerialInfoTask getSerialInfoTask = new GetSerialInfoTask(databaseInfo);
    SerialInfo serialInfo = getSerialInfoTask.getSerialInfo("serial1");
    boolean isOk = serialInfo != null && serialInfo.getName().equals("serial1") && serialInfo.getCurrentValue().equals("1") && serialInfo.getIncrementValue().equals("1") && serialInfo.getMaxValue().equals("100") && serialInfo.getMinValue().equals("1") && serialInfo.isCyclic();
    assertTrue(isOk);
    CreateOrEditSerialTask createOrEditSerialTask2 = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask2.createSerial("serial2", null, null, "100", "1", true, false, false, "100", true);
    CreateOrEditSerialTask createOrEditSerialTask3 = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask3.createSerial("serial3", null, null, "100", "1", true, true, true, "100", true);
    CreateOrEditSerialTask createOrEditSerialTask4 = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask4.createSerial("serial4", "1", "1", "100", "1", true, true, true, "100", true);
    CreateOrEditSerialTask createOrEditSerialTask5 = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask5.createSerial("serial5", null, null, null, null, false, false, false, "100", true);
    createOrEditSerialTask5.createSerial("serial6", null, null, null, null, false, false, false, "100", true);
    createOrEditSerialTask5.createSerial("serial6", null, null, null, null, false, false, false, "100", true);
    //test edit serial
    createOrEditSerialTask = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask.editSerial("serial1", "2", "2", "102", "2", false, false, false, "10", false);
    assertTrue(createOrEditSerialTask.getErrorMsg() == null || createOrEditSerialTask.getErrorMsg().trim().length() <= 0);
    getSerialInfoTask = new GetSerialInfoTask(databaseInfo);
    serialInfo = getSerialInfoTask.getSerialInfo("serial1");
    isOk = serialInfo != null && serialInfo.getName().equals("serial1") && serialInfo.getCurrentValue().equals("2") && serialInfo.getIncrementValue().equals("2") && serialInfo.getMaxValue().equals("102") && serialInfo.getMinValue().equals("2") && !serialInfo.isCyclic();
    assertTrue(isOk);
    createOrEditSerialTask2 = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask2.editSerial("serial2", null, null, "100", "1", true, false, false, "100", true);
    createOrEditSerialTask3 = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask3.editSerial("serial3", null, null, "100", "1", true, true, true, "100", true);
    createOrEditSerialTask4 = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask4.editSerial("serial4", "1", "1", "100", "1", true, true, true, "100", true);
    createOrEditSerialTask5 = new CreateOrEditSerialTask(databaseInfo);
    createOrEditSerialTask5.editSerial("serial5", null, null, null, null, false, false, false, "100", true);
    createOrEditSerialTask5.editSerial("serial6", null, null, null, null, false, false, false, "100", true);
    createOrEditSerialTask5.editSerial("serial6", null, null, null, null, false, false, false, "100", true);
    //test get serial information list
    GetSerialInfoListTask getSerialInfoListTask = new GetSerialInfoListTask(databaseInfo);
    getSerialInfoListTask.execute();
    assertTrue(getSerialInfoListTask.getSerialInfoList().size() > 0);
    getSerialInfoListTask.setErrorMsg("err");
    getSerialInfoListTask.execute();
    getSerialInfoListTask.setErrorMsg(null);
    getSerialInfoListTask.execute();
    //test get serial information
    getSerialInfoTask = new GetSerialInfoTask(databaseInfo);
    serialInfo = getSerialInfoTask.getSerialInfo("serial1");
    assertTrue(serialInfo != null && serialInfo.getName().equals("serial1"));
    getSerialInfoTask.setErrorMsg("err");
    getSerialInfoTask.getSerialInfo("serial1");
    getSerialInfoTask.setErrorMsg(null);
    getSerialInfoTask.getSerialInfo("serial1");
    //test delete serial
    DeleteSerialTask deleteSerialTask = new DeleteSerialTask(databaseInfo);
    deleteSerialTask.deleteSerial(new String[] { "serial1", "serial2", "serial3", "serial4", "serial5" });
    assertTrue(createOrEditSerialTask.getErrorMsg() == null || createOrEditSerialTask.getErrorMsg().trim().length() <= 0);
    getSerialInfoTask = new GetSerialInfoTask(databaseInfo);
    serialInfo = getSerialInfoTask.getSerialInfo("serial1");
    assertTrue(serialInfo == null);
    deleteSerialTask.setErrorMsg("err");
    deleteSerialTask.deleteSerial(new String[] { "serial1", "serial2", "serial3", "serial4", "serial5" });
    deleteSerialTask.setErrorMsg(null);
    deleteSerialTask.deleteSerial(new String[] { "serial1", "serial2", "serial3", "serial4", "serial5" });
}
Also used : SerialInfo(com.cubrid.common.core.common.model.SerialInfo)

Aggregations

SerialInfo (com.cubrid.common.core.common.model.SerialInfo)34 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)14 Constraint (com.cubrid.common.core.common.model.Constraint)12 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)9 ArrayList (java.util.ArrayList)8 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 TableItem (org.eclipse.swt.widgets.TableItem)4 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)3 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 CreateOrEditSerialDialog (com.cubrid.common.ui.cubrid.serial.dialog.CreateOrEditSerialDialog)2 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 GetSerialInfoListTask (com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoListTask)2 BufferedWriter (java.io.BufferedWriter)2 Connection (java.sql.Connection)2 List (java.util.List)2 Table (org.eclipse.swt.widgets.Table)2 DBResolution (com.cubrid.common.core.common.model.DBResolution)1