use of org.talend.dataquality.indicators.columnset.RecordMatchingIndicator in project tdq-studio-se by Talend.
the class MatchAnalysisHandler method clearAllKeys.
/**
* when the columns is empty, clear all keys.
*/
public void clearAllKeys() {
EList<Indicator> indicators = this.analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
if (indicator instanceof RecordMatchingIndicator) {
RecordMatchingIndicator matchIndicator = (RecordMatchingIndicator) indicator;
matchIndicator.getBuiltInMatchRuleDefinition().getBlockKeys().clear();
matchIndicator.getBuiltInMatchRuleDefinition().getMatchRules().clear();
}
}
}
use of org.talend.dataquality.indicators.columnset.RecordMatchingIndicator 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.indicators.columnset.RecordMatchingIndicator in project tdq-studio-se by Talend.
the class AbstractMatchKeyWithChartTableSection method computeMatchResult.
protected TypedReturnCode<RecordMatchingIndicator> computeMatchResult() {
TypedReturnCode<RecordMatchingIndicator> rc = new TypedReturnCode<RecordMatchingIndicator>(false);
final Object[] IndicatorList = MatchRuleAnlaysisUtils.getNeedIndicatorFromAna(analysis);
final RecordMatchingIndicator recordMatchingIndicator = EcoreUtil.copy((RecordMatchingIndicator) IndicatorList[0]);
BlockKeyIndicator blockKeyIndicator = EcoreUtil.copy((BlockKeyIndicator) IndicatorList[1]);
ExecuteMatchRuleHandler execHandler = new ExecuteMatchRuleHandler();
MatchGroupResultConsumer matchResultConsumer = createMatchGroupResultConsumer(recordMatchingIndicator);
// Set match key schema to the record matching indicator.
MetadataColumn[] completeColumnSchema = AnalysisRecordGroupingUtils.getCompleteColumnSchema(columnMap);
String[] colSchemaString = new String[completeColumnSchema.length];
int idx = 0;
for (MetadataColumn metadataCol : completeColumnSchema) {
colSchemaString[idx++] = metadataCol.getName();
}
recordMatchingIndicator.setMatchRowSchema(colSchemaString);
recordMatchingIndicator.reset();
TypedReturnCode<MatchGroupResultConsumer> execute = execHandler.execute(columnMap, recordMatchingIndicator, matchRows, blockKeyIndicator, matchResultConsumer);
if (!execute.isOk()) {
rc.setMessage(DefaultMessagesImpl.getString("RunAnalysisAction.failRunAnalysis", analysis.getName(), // $NON-NLS-1$
execute.getMessage()));
return rc;
} else {
if (execute.getObject().getFullMatchResult() == null) {
return rc;
}
// TDQ-9741, the "chart" result must be stored for hiding group(not compute again)
tableResult = execute.getObject().getFullMatchResult();
groupSize2groupFrequency = recordMatchingIndicator.getGroupSize2groupFrequency();
}
rc.setOk(true);
rc.setObject(recordMatchingIndicator);
return rc;
}
use of org.talend.dataquality.indicators.columnset.RecordMatchingIndicator in project tdq-studio-se by Talend.
the class GroupStatisticsSection method refreshChart.
/*
* (non-Javadoc)
*
* @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#refreshChart()
*/
@Override
public void refreshChart() {
setGroupStatisticsTableInput();
RecordMatchingIndicator recordMatchingIndicator = MatchRuleAnlaysisUtils.getRecordMatchIndicatorFromAna(analysis);
matchRuleChartComp.refresh(recordMatchingIndicator.getGroupSize2groupFrequency());
}
use of org.talend.dataquality.indicators.columnset.RecordMatchingIndicator in project tdq-studio-se by Talend.
the class GroupStatisticsSection method setGroupStatisticsTableInput.
/**
* DOC zhao Comment method "setGroupStatisticsTableInput".
*/
private void setGroupStatisticsTableInput() {
RecordMatchingIndicator recordMatchingIndicator = MatchRuleAnlaysisUtils.getRecordMatchIndicatorFromAna(analysis);
// Row count
Long rowCount = recordMatchingIndicator.getCount();
Map<Object, Long> groupSize2GroupFreq = recordMatchingIndicator.getGroupSize2groupFrequency();
Iterator<Object> groupSizeIterator = groupSize2GroupFreq.keySet().iterator();
List<GroupStatisticsRow> groups = new ArrayList<GroupStatisticsRow>();
while (groupSizeIterator.hasNext()) {
Object groupSize = groupSizeIterator.next();
Long groupFreq = groupSize2GroupFreq.get(groupSize);
GroupStatisticsRow groupStatsRow = new GroupStatisticsRow();
groupStatsRow.setGroupSize(Long.valueOf(groupSize.toString()));
groupStatsRow.setGroupCount(groupFreq);
groupStatsRow.setRecordCount(groupStatsRow.getGroupSize() * groupStatsRow.getGroupCount());
setPercentage(groupStatsRow.getRecordCount(), rowCount, groupStatsRow);
groups.add(groupStatsRow);
}
groupStatisticsTableViewer.setInput(groups);
}
Aggregations