use of org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions in project tdq-studio-se by Talend.
the class MatchRuleElementTreeSelectionDialog method getParticularSurvivorshipRulesFromRules.
private List<Map<String, String>> getParticularSurvivorshipRulesFromRules(MatchRuleDefinition matchRuleDefinition, boolean retrieveDisplayValue) {
if (matchRuleDefinition != null) {
List<Map<String, String>> ruleValues = new ArrayList<Map<String, String>>();
for (ParticularDefaultSurvivorshipDefinitions pdsd : matchRuleDefinition.getParticularDefaultSurvivorshipDefinitions()) {
Map<String, String> pr = new HashMap<String, String>();
String matchedColumnName = matchExistingColumnForKey(pdsd);
pr.put(MatchRulesTableLabelProvider.INPUT_COLUMN, matchedColumnName);
// set survivorship function and parameter
AlgorithmDefinition algorithmDefinition = pdsd.getFunction();
String functionType = algorithmDefinition != null && algorithmDefinition.getAlgorithmType() != null ? algorithmDefinition.getAlgorithmType() : StringUtils.EMPTY;
pr.put(MatchRulesTableLabelProvider.SURVIVORSHIP_FUNCTION, functionType);
pr.put(MatchRulesTableLabelProvider.PARAMETER, algorithmDefinition != null && algorithmDefinition.getAlgorithmParameters() != null ? algorithmDefinition.getAlgorithmParameters() : StringUtils.EMPTY);
ruleValues.add(pr);
}
return ruleValues;
}
return null;
}
use of org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions in project tdq-studio-se by Talend.
the class ImportMatchRuleAction method run.
@Override
public void run() {
MatchRuleElementTreeSelectionDialog dialog = new MatchRuleElementTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider(), MatchRuleElementTreeSelectionDialog.MATCH_ANALYSIS_TYPE);
List<String> inputColumnNames = new ArrayList<String>();
Map<String, String> columnName2Type = new HashMap<String, String>();
Analysis analysis = masterPage.getCurrentModelElement();
EList<ModelElement> elements = analysis.getContext().getAnalysedElements();
for (ModelElement me : elements) {
inputColumnNames.add(me.getName());
if (me instanceof MetadataColumn) {
columnName2Type.put(me.getName(), ((MetadataColumn) me).getTalendType());
}
}
dialog.setInputColumnNames(inputColumnNames);
dialog.setColumnName2Type(columnName2Type);
AnalysisResult anaResults = analysis.getResults();
if (anaResults != null) {
for (Indicator ind : anaResults.getIndicators()) {
if (ind != null && ind instanceof RecordMatchingIndicator) {
RecordMatchingIndicator rmInd = (RecordMatchingIndicator) ind;
MatchRuleDefinition builtInMatchRuleDefinition = rmInd.getBuiltInMatchRuleDefinition();
if (builtInMatchRuleDefinition != null) {
if (builtInMatchRuleDefinition.getBlockKeys() != null && builtInMatchRuleDefinition.getBlockKeys().size() > 0) {
List<String> blockKeyName = new ArrayList<String>();
for (BlockKeyDefinition blockKey : builtInMatchRuleDefinition.getBlockKeys()) {
blockKeyName.add(blockKey.getName());
}
dialog.setCurrentAnaBlockKeys(blockKeyName);
}
List<String> matchKeysName = new ArrayList<String>();
for (MatchRule matchRule : builtInMatchRuleDefinition.getMatchRules()) {
EList<MatchKeyDefinition> matchKeys = matchRule.getMatchKeys();
for (MatchKeyDefinition mkd : matchKeys) {
// same
if (!matchKeysName.contains(mkd.getName())) {
matchKeysName.add(mkd.getName());
}
}
}
dialog.setAnalysisCurrentMatchKeys(matchKeysName);
List<String> pdsdKeysName = new ArrayList<String>();
for (ParticularDefaultSurvivorshipDefinitions pdsd : builtInMatchRuleDefinition.getParticularDefaultSurvivorshipDefinitions()) {
pdsdKeysName.add(pdsd.getColumn());
}
dialog.setAnalysisCurrentParticularColumns(pdsdKeysName);
}
}
}
}
dialog.create();
if (dialog.open() == Window.OK) {
Object[] results = dialog.getResult();
for (Object obj : results) {
if (obj instanceof RuleRepNode) {
RuleRepNode node = (RuleRepNode) obj;
MatchRuleDefinition matchRule = (MatchRuleDefinition) node.getRule();
if (matchRule != null) {
updateMatchRule(matchRule, dialog.isOverwrite());
}
}
}
}
}
use of org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions in project tdq-studio-se by Talend.
the class ParticularDefSurshipDefinitionSection method checkResultStatus.
/*
* (non-Javadoc)
*
* @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#checkResultStatus()
*/
@Override
public ReturnCode checkResultStatus() {
ReturnCode returnCode = new ReturnCode(true);
List<String> uniqueNameList = new ArrayList<String>();
List<ParticularDefaultSurvivorshipDefinitions> particularDefaultSurvivorshipKeys = this.getParticularDefaultSurvivorshipKeys();
for (ParticularDefaultSurvivorshipDefinitions pdsd : particularDefaultSurvivorshipKeys) {
String currentName = pdsd.getColumn();
if (uniqueNameList.contains(currentName)) {
returnCode.setOk(false);
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.duplicateKeys.message", // $NON-NLS-1$ //$NON-NLS-2$
getSectionName() + "--" + currentName));
return returnCode;
}
uniqueNameList.add(currentName);
if (checkColumnNameIsEmpty(pdsd)) {
returnCode.setOk(false);
// $NON-NLS-1$
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyColumn.message", getSectionName()));
return returnCode;
}
}
return returnCode;
}
use of org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions in project tdq-studio-se by Talend.
the class ParticularDefSurshipDefinitionSection 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 = getTableComposite(ruleComp);
tableComposite.addPropertyChangeListener(this);
tableComposite.setLayout(gridLayout);
tableComposite.setLayoutData(data);
if (columnMap != null) {
ArrayList<MetadataColumn> columnList = new ArrayList<MetadataColumn>();
columnList.addAll(columnMap.keySet());
tableComposite.setColumnList(columnList);
}
tableComposite.createContent();
section.setExpanded(true);
tableComposite.serViewerSorter(new KeyDefinitionTableViewerSorter<ParticularDefaultSurvivorshipDefinitions>(this.matchRuleDef.getParticularDefaultSurvivorshipDefinitions()));
initTableInput();
return ruleComp;
}
use of org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions in project tdq-studio-se by Talend.
the class ParticularDefSurshipDefinitionSection 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<ParticularDefaultSurvivorshipDefinitions> currentElements = this.matchRuleDef.getParticularDefaultSurvivorshipDefinitions();
List<ParticularDefaultSurvivorshipDefinitions> particularDefaultSurvivorshipKeyDefinitionlist = ((StructuredSelection) selectItems).toList();
for (int index = particularDefaultSurvivorshipKeyDefinitionlist.size() - 1; 0 <= index; index--) {
if (!isSameWithCurrentModel(currentElements.get(currentElements.size() - particularDefaultSurvivorshipKeyDefinitionlist.size() + index), particularDefaultSurvivorshipKeyDefinitionlist.get(index))) {
continue;
}
ParticularDefaultSurvivorshipDefinitions next = particularDefaultSurvivorshipKeyDefinitionlist.get(index);
tableComposite.moveDownKeyDefinition(next, currentElements);
}
tableComposite.selectAllItem(((StructuredSelection) selectItems).toList());
}
}
Aggregations