Search in sources :

Example 16 with BlockKeyDefinition

use of org.talend.dataquality.rules.BlockKeyDefinition in project tdq-studio-se by Talend.

the class BlockingKeySection method importMatchRule.

/**
 * if overwrite: need to delete all current keyss, and insert the keys according to the parameter:matchRule; else:
 * only add the keys in the parameter matchrule, to the current keys.
 *
 * @param matchRule
 * @param overwrite
 */
public void importMatchRule(MatchRuleDefinition matchRule, boolean overwrite) {
    if (overwrite) {
        // clear current keys
        this.removeAllBlockingKey();
    }
    List<String> conflictKeys = new ArrayList<String>();
    for (BlockKeyDefinition blockKey : matchRule.getBlockKeys()) {
        if (!overwrite && isKeyDefinitionAdded(blockKey.getName())) {
            // if conflict with current ones, do not import
            conflictKeys.add(blockKey.getName());
            continue;
        }
        BlockKeyDefinition blockKeyDefinition = EcoreUtil.copy(blockKey);
        setColumnValueIfMatch(blockKeyDefinition);
        tableComposite.addKeyDefinition(blockKeyDefinition, this.getMatchRuleDefinition().getBlockKeys());
    }
    // if there are some conflict keys, popup to let the user know
    if (conflictKeys.size() > 0) {
        StringBuffer names = new StringBuffer();
        for (String name : conflictKeys) {
            names.append(name);
            names.append(PluginConstant.COMMA_STRING);
        }
        if (names.length() > 0) {
            names.deleteCharAt(names.lastIndexOf(PluginConstant.COMMA_STRING));
        }
        // $NON-NLS-1$
        MessageDialog.openWarning(// $NON-NLS-1$
        null, // $NON-NLS-1$
        DefaultMessagesImpl.getString("BlockingKeySection.conflictImport"), // $NON-NLS-1$
        DefaultMessagesImpl.getString("BlockingKeySection.conflictImportKeys") + names.toString());
    }
}
Also used : ArrayList(java.util.ArrayList) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition)

Example 17 with BlockKeyDefinition

use of org.talend.dataquality.rules.BlockKeyDefinition in project tdq-studio-se by Talend.

the class BlockingKeySection method checkResultStatus.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#checkResultStatus()
     */
@Override
public ReturnCode checkResultStatus() {
    ReturnCode returnCode = new ReturnCode(false);
    List<String> uniqueNameList = new ArrayList<String>();
    List<String> duplicateNameList = new ArrayList<String>();
    for (BlockKeyDefinition bdk : getBlockKeyDefinitionList()) {
        String currentName = bdk.getName();
        if (currentName.equals(StringUtils.EMPTY)) {
            // $NON-NLS-1$
            returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyKeys.message", getSectionName()));
            return returnCode;
        }
        if (checkColumnNameIsEmpty(bdk)) {
            // $NON-NLS-1$
            returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyColumn.message", getSectionName()));
            return returnCode;
        }
        boolean currentNameIsDuplicate = false;
        for (String uniqueName : uniqueNameList) {
            if (currentName.equals(uniqueName)) {
                duplicateNameList.add(currentName);
                currentNameIsDuplicate = true;
            }
        }
        if (!currentNameIsDuplicate) {
            uniqueNameList.add(currentName);
        }
    }
    if (duplicateNameList.size() > 0) {
        // $NON-NLS-1$
        returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.duplicateKeys.message", getSectionName()));
        return returnCode;
    } else {
        returnCode.setOk(true);
        return returnCode;
    }
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) ArrayList(java.util.ArrayList) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition)

Example 18 with BlockKeyDefinition

use of org.talend.dataquality.rules.BlockKeyDefinition in project tdq-studio-se by Talend.

the class BlockingKeySection method createSubContent.

@Override
protected Composite createSubContent(Composite sectionClient) {
    Composite ruleComp = toolkit.createComposite(sectionClient, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    ruleComp.setLayoutData(data);
    GridLayout gridLayout = new GridLayout(1, true);
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    ruleComp.setLayout(gridLayout);
    tableComposite = createTableComposite(ruleComp);
    tableComposite.addPropertyChangeListener(this);
    tableComposite.setAddColumn(isAddColumn());
    tableComposite.setLayout(gridLayout);
    tableComposite.setLayoutData(data);
    if (columnMap != null) {
        ArrayList<MetadataColumn> columnList = new ArrayList<MetadataColumn>();
        columnList.addAll(columnMap.keySet());
        tableComposite.setColumnList(columnList);
    }
    tableComposite.createContent();
    tableComposite.serViewerSorter(new KeyDefinitionTableViewerSorter<BlockKeyDefinition>(getBlockKeyDefinitionList()));
    initTableInput();
    return ruleComp;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) GridLayout(org.eclipse.swt.layout.GridLayout) BlockingKeyTableComposite(org.talend.dataquality.record.linkage.ui.composite.BlockingKeyTableComposite) AbsMatchAnalysisTableComposite(org.talend.dataquality.record.linkage.ui.composite.AbsMatchAnalysisTableComposite) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition)

Example 19 with BlockKeyDefinition

use of org.talend.dataquality.rules.BlockKeyDefinition in project tdq-studio-se by Talend.

the class BlockingKeySection method moveDownTableItem.

/**
 * /* (non-Javadoc)
 *
 * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#moveDownTableItem()
 */
@Override
public void moveDownTableItem() {
    ISelection selectItems = tableComposite.getSelectItems();
    if (selectItems instanceof StructuredSelection) {
        if (selectItems.isEmpty()) {
            return;
        }
        List<BlockKeyDefinition> currentElements = getMatchRuleDefinition().getBlockKeys();
        List<BlockKeyDefinition> blockKeyDefinitionlist = ((StructuredSelection) selectItems).toList();
        for (int index = blockKeyDefinitionlist.size() - 1; 0 <= index; index--) {
            if (!isSameWithCurrentModel(currentElements.get(currentElements.size() - blockKeyDefinitionlist.size() + index), blockKeyDefinitionlist.get(index))) {
                continue;
            }
            BlockKeyDefinition next = blockKeyDefinitionlist.get(index);
            tableComposite.moveDownKeyDefinition(next, currentElements);
        }
        tableComposite.selectAllItem(((StructuredSelection) selectItems).toList());
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition)

Example 20 with BlockKeyDefinition

use of org.talend.dataquality.rules.BlockKeyDefinition in project tdq-studio-se by Talend.

the class BlockingKeyTableViewer method createNewKeyDefinition.

/**
 * DOC zshen Comment method "createDefaultRow".
 *
 * @param columnName
 * @return
 */
@Override
protected BlockKeyDefinition createNewKeyDefinition(String columnName) {
    BlockKeyDefinition createBlockKeyDefinition = RulesFactory.eINSTANCE.createBlockKeyDefinition();
    createBlockKeyDefinition.setName(columnName);
    createBlockKeyDefinition.setColumn(columnName);
    AlgorithmDefinition createAlgorithmDefinition = RulesFactory.eINSTANCE.createAlgorithmDefinition();
    createAlgorithmDefinition.setAlgorithmType(BlockingKeyPreAlgorithmEnum.getTypeByIndex(0).getComponentValueName());
    createAlgorithmDefinition.setAlgorithmParameters(StringUtils.EMPTY);
    createBlockKeyDefinition.setPreAlgorithm(createAlgorithmDefinition);
    createAlgorithmDefinition = RulesFactory.eINSTANCE.createAlgorithmDefinition();
    createAlgorithmDefinition.setAlgorithmType(BlockingKeyAlgorithmEnum.getTypeByIndex(0).getComponentValueName());
    createAlgorithmDefinition.setAlgorithmParameters(StringUtils.EMPTY);
    createBlockKeyDefinition.setAlgorithm(createAlgorithmDefinition);
    createAlgorithmDefinition = RulesFactory.eINSTANCE.createAlgorithmDefinition();
    createAlgorithmDefinition.setAlgorithmType(BlockingKeyPostAlgorithmEnum.getTypeByIndex(0).getComponentValueName());
    createAlgorithmDefinition.setAlgorithmParameters(StringUtils.EMPTY);
    createBlockKeyDefinition.setPostAlgorithm(createAlgorithmDefinition);
    return createBlockKeyDefinition;
}
Also used : BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) AlgorithmDefinition(org.talend.dataquality.rules.AlgorithmDefinition)

Aggregations

BlockKeyDefinition (org.talend.dataquality.rules.BlockKeyDefinition)21 ArrayList (java.util.ArrayList)11 RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)7 HashMap (java.util.HashMap)6 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)6 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)5 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)5 MatchRule (org.talend.dataquality.rules.MatchRule)5 KeyDefinition (org.talend.dataquality.rules.KeyDefinition)4 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)4 Map (java.util.Map)3 ISelection (org.eclipse.jface.viewers.ISelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 Test (org.junit.Test)3 BlockKeyIndicator (org.talend.dataquality.indicators.columnset.BlockKeyIndicator)3 MatchGroupResultConsumer (org.talend.dataquality.record.linkage.grouping.MatchGroupResultConsumer)3 ExecuteMatchRuleHandler (org.talend.dq.analysis.match.ExecuteMatchRuleHandler)3 AppliedBlockKey (org.talend.dataquality.rules.AppliedBlockKey)2 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1