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());
}
}
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;
}
}
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;
}
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());
}
}
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;
}
Aggregations