Search in sources :

Example 11 with PartitionInfo

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

the class PartitionEditRangePage method init.

/**
	 * 
	 * Initial the page content
	 * 
	 */
private void init() {
    partitionExprTypeCombo.setItems(PartitionUtil.getSupportedDateTypes());
    if (!partitionInfoList.isEmpty() && editedPartitionInfo == null) {
        PartitionInfo partitonInfo = partitionInfoList.get(0);
        String partitionType = partitonInfo.getPartitionType().getText().toUpperCase();
        String partitionExpr = partitonInfo.getPartitionExpr();
        String exprDataType = partitonInfo.getPartitionExprType();
        if (exprDataType == null) {
            partitionExprTypeCombo.setEnabled(true);
            partitionExprTypeCombo.select(0);
        } else {
            partitionExprTypeCombo.setText(PartitionUtil.getMatchType(exprDataType));
            partitionExprTypeCombo.setEnabled(false);
        }
        partitionTypeText.setText(partitionType);
        partitionExprText.setText(partitionExpr);
    }
    if (editedPartitionInfo != null) {
        partitionNameText.setText(editedPartitionInfo.getPartitionName());
        String str = editedPartitionInfo.getPartitionValues().get(1);
        if (str == null) {
            maxValueButton.setSelection(true);
            partitionRangeText.setEnabled(false);
        } else {
            partitionRangeText.setText(str);
        }
    }
    partitionNameText.addModifyListener(this);
    partitionRangeText.addModifyListener(this);
}
Also used : PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo)

Example 12 with PartitionInfo

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

the class PartitionEditRangePage method isExistRangeValue.

/**
	 * 
	 * Check the range value whether exist
	 * 
	 * @param value the range value
	 * @return <code>true</code> if exist;otherwise <code>false</code>
	 */
private boolean isExistRangeValue(String value) {
    if (partitionInfoList.isEmpty()) {
        return false;
    } else {
        String editedValue = null;
        if (this.editedPartitionInfo != null) {
            editedValue = editedPartitionInfo.getPartitionValues().get(1);
        }
        RangePartitionComparator comparator = new RangePartitionComparator(partitionExprTypeCombo.getText());
        for (int i = 0; i < partitionInfoList.size(); i++) {
            PartitionInfo info = partitionInfoList.get(i);
            String str = info.getPartitionValues().get(1);
            if (comparator.compareData(str, value) == 0 && (editedValue == null || comparator.compareData(editedValue, value) != 0)) {
                return true;
            }
        }
    }
    return false;
}
Also used : PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo)

Example 13 with PartitionInfo

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

the class PartitionTableLabelProvider method getColumnText.

/**
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
	 *      int)
	 * @param element the object representing the entire row, or
	 *        <code>null</code> indicating that no input object is set in the
	 *        viewer
	 * @param columnIndex the zero-based index of the column in which the label
	 *        appears
	 * @return String or or <code>null</code> if there is no text for the given
	 *         object at columnIndex
	 */
public String getColumnText(Object element, int columnIndex) {
    PartitionInfo item = (PartitionInfo) element;
    switch(columnIndex) {
        case 0:
            return item.getPartitionClassName();
        case 1:
            return item.getPartitionName();
        case 2:
            return item.getPartitionType().getText().toUpperCase();
        case 3:
            return item.getPartitionExpr();
        case 4:
            String partType = item.getPartitionType().getText().toUpperCase();
            PartitionType partitionType = PartitionType.valueOf(partType);
            if (partitionType == PartitionType.HASH) {
                return "";
            } else if (partitionType == PartitionType.RANGE) {
                boolean isUsingQuote = PartitionUtil.isUsingQuoteForExprValue(item.getPartitionExprType());
                String str = "{";
                if (item.getPartitionValues().get(0) != null) {
                    str += (isUsingQuote ? "'" : "") + item.getPartitionValues().get(0) + (isUsingQuote ? "'" : "");
                }
                if (item.getPartitionValues().get(1) == null) {
                    str += ",MAXVALUE}";
                } else {
                    str += "," + (isUsingQuote ? "'" : "") + item.getPartitionValues().get(1) + (isUsingQuote ? "'" : "") + "}";
                }
                return str;
            } else {
                return "{" + item.getPartitionValuesString(PartitionUtil.isUsingQuoteForExprValue(item.getPartitionExprType())) + "}";
            }
        case 5:
            if (item.getRows() < 0) {
                return "";
            } else {
                return String.valueOf(item.getRows());
            }
        default:
            break;
    }
    return "";
}
Also used : PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo) PartitionType(com.cubrid.common.core.common.model.PartitionType)

Example 14 with PartitionInfo

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

the class CreatePartitionWizard method changePartitionExprDataType.

/**
	 *
	 * Change all partition expression data type
	 *
	 * @param type the partition expression
	 */
private void changePartitionExprDataType(String type) {
    // FIXME move this logic to core module
    for (int i = 0; i < partitionInfoList.size(); i++) {
        PartitionInfo info = partitionInfoList.get(i);
        info.setPartitionExprType(type);
    }
}
Also used : PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo)

Example 15 with PartitionInfo

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

the class CreatePartitionWizard method changePartitionExpr.

/**
	 *
	 * Change all partition information expression
	 *
	 * @param expr the partition expression
	 */
private void changePartitionExpr(String expr) {
    // FIXME move this logic to core module
    for (int i = 0; i < partitionInfoList.size(); i++) {
        PartitionInfo info = partitionInfoList.get(i);
        info.setPartitionExpr(expr);
        info.setRows(-1);
    }
}
Also used : PartitionInfo(com.cubrid.common.core.common.model.PartitionInfo)

Aggregations

PartitionInfo (com.cubrid.common.core.common.model.PartitionInfo)23 Constraint (com.cubrid.common.core.common.model.Constraint)11 ArrayList (java.util.ArrayList)9 PartitionType (com.cubrid.common.core.common.model.PartitionType)8 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)7 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)5 DBResolution (com.cubrid.common.core.common.model.DBResolution)2 HashMap (java.util.HashMap)2 List (java.util.List)2 TableItem (org.eclipse.swt.widgets.TableItem)2 DBMethod (com.cubrid.common.core.common.model.DBMethod)1 SerialInfo (com.cubrid.common.core.common.model.SerialInfo)1 DataCompare (com.cubrid.common.ui.compare.data.model.DataCompare)1 CreatePartitionWizard (com.cubrid.common.ui.cubrid.table.control.CreatePartitionWizard)1 RangePartitionComparator (com.cubrid.common.ui.cubrid.table.control.RangePartitionComparator)1 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)1 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1