Search in sources :

Example 11 with ParticularDefaultSurvivorshipDefinitions

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;
}
Also used : ParticularDefaultSurvivorshipDefinitions(org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AlgorithmDefinition(org.talend.dataquality.rules.AlgorithmDefinition) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with ParticularDefaultSurvivorshipDefinitions

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());
                }
            }
        }
    }
}
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 13 with ParticularDefaultSurvivorshipDefinitions

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;
}
Also used : ParticularDefaultSurvivorshipDefinitions(org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions) ReturnCode(org.talend.utils.sugars.ReturnCode) ArrayList(java.util.ArrayList)

Example 14 with ParticularDefaultSurvivorshipDefinitions

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;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) GridLayout(org.eclipse.swt.layout.GridLayout) ParticularDefaultSurvivorshipDefinitions(org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions) Composite(org.eclipse.swt.widgets.Composite) ParticularDefaultSurvivorshipTableComposite(org.talend.dataquality.record.linkage.ui.composite.ParticularDefaultSurvivorshipTableComposite) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList)

Example 15 with ParticularDefaultSurvivorshipDefinitions

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());
    }
}
Also used : ParticularDefaultSurvivorshipDefinitions(org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Aggregations

ParticularDefaultSurvivorshipDefinitions (org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions)20 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 ISelection (org.eclipse.jface.viewers.ISelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 SurvivorShipAlgorithmEnum (org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)3 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)3 Map (java.util.Map)2 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)2 TableItem (org.eclipse.swt.widgets.TableItem)2 RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)2 SurvivorshipFunction (org.talend.dataquality.record.linkage.grouping.swoosh.SurvivorShipAlgorithmParams.SurvivorshipFunction)2 DefaultSurvivorshipDefinition (org.talend.dataquality.rules.DefaultSurvivorshipDefinition)2 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)2 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1