Search in sources :

Example 26 with RecordMatchingIndicator

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();
        }
    }
}
Also used : RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 27 with RecordMatchingIndicator

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());
                }
            }
        }
    }
}
Also used : ParticularDefaultSurvivorshipDefinitions(org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions) HashMap(java.util.HashMap) MatchRuleElementTreeSelectionDialog(org.talend.dataprofiler.core.ui.dialog.MatchRuleElementTreeSelectionDialog) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) ArrayList(java.util.ArrayList) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) MatchRule(org.talend.dataquality.rules.MatchRule) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) RuleRepNode(org.talend.dq.nodes.RuleRepNode) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) Analysis(org.talend.dataquality.analysis.Analysis) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 28 with RecordMatchingIndicator

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;
}
Also used : ExecuteMatchRuleHandler(org.talend.dq.analysis.match.ExecuteMatchRuleHandler) BlockKeyIndicator(org.talend.dataquality.indicators.columnset.BlockKeyIndicator) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MatchGroupResultConsumer(org.talend.dataquality.record.linkage.grouping.MatchGroupResultConsumer) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode)

Example 29 with RecordMatchingIndicator

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());
}
Also used : RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)

Example 30 with RecordMatchingIndicator

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);
}
Also used : ArrayList(java.util.ArrayList) GroupStatisticsRow(org.talend.dataquality.record.linkage.ui.composite.tableviewer.provider.GroupStatisticsRow) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)

Aggregations

RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)32 ArrayList (java.util.ArrayList)9 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)8 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)8 BlockKeyIndicator (org.talend.dataquality.indicators.columnset.BlockKeyIndicator)7 MatchGroupResultConsumer (org.talend.dataquality.record.linkage.grouping.MatchGroupResultConsumer)7 BlockKeyDefinition (org.talend.dataquality.rules.BlockKeyDefinition)7 HashMap (java.util.HashMap)6 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)6 MatchRule (org.talend.dataquality.rules.MatchRule)6 Test (org.junit.Test)5 Indicator (org.talend.dataquality.indicators.Indicator)5 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)5 ExecuteMatchRuleHandler (org.talend.dq.analysis.match.ExecuteMatchRuleHandler)5 ReturnCode (org.talend.utils.sugars.ReturnCode)3 TypedReturnCode (org.talend.utils.sugars.TypedReturnCode)3 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Analysis (org.talend.dataquality.analysis.Analysis)2 KeyDefinition (org.talend.dataquality.rules.KeyDefinition)2