Search in sources :

Example 16 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class MatchRuleElementTreeSelectionDialog method getMatchRulesFromNodes.

/**
 * DOC sizhaoliu Comment method "getMatchRulesFromNodes".
 *
 * @param nodes
 * @param retrieveDisplayValue get the display value when this parameter is set to true, otherwise, get the
 * component value.
 * @return
 */
public List<Map<String, String>> getMatchRulesFromNodes(Object[] nodes, boolean retrieveDisplayValue) {
    List<Map<String, String>> ruleValues = new ArrayList<Map<String, String>>();
    for (Object rule : nodes) {
        if (rule instanceof RuleRepNode) {
            RuleRepNode node = (RuleRepNode) rule;
            MatchRuleDefinition matchRuleDefinition = (MatchRuleDefinition) node.getRule();
            ruleValues.addAll(getMatchRulesFromRules(matchRuleDefinition, retrieveDisplayValue));
        }
    }
    return ruleValues;
}
Also used : ArrayList(java.util.ArrayList) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) RuleRepNode(org.talend.dq.nodes.RuleRepNode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 17 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class TreeMessageInfoDialog method getLabelProvider.

protected ILabelProvider getLabelProvider() {
    if (labelProvider == null) {
        labelProvider = new LabelProvider() {

            @Override
            public String getText(Object obj) {
                if (obj == null) {
                    // $NON-NLS-1$
                    return "";
                }
                if (obj instanceof ImpactNode) {
                    return ((ImpactNode) obj).toString();
                } else if (obj instanceof IFile) {
                    IFile file = (IFile) obj;
                    ModelElement modelElement = ModelElementFileFactory.getModelElement(file);
                    // MOD msjian TDQ-5909: modify to displayName
                    return modelElement != null ? PropertyHelper.getProperty(modelElement).getDisplayName() : file.getName();
                } else if (obj instanceof RepositoryViewObject) {
                    // Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
                    return ((IRepositoryViewObject) obj).getLabel();
                } else if (obj instanceof MetadataTable) {
                    // ADD TDQ-7146: for all type's connection table/view node
                    return ((ModelElement) obj).getName();
                }
                Property property = PropertyHelper.getProperty((ModelElement) obj);
                return property == null ? ((ModelElement) obj).getName() : property.getDisplayName();
            }

            @Override
            public Image getImage(Object obj) {
                ModelElement modelElement = null;
                if (obj instanceof ModelElement) {
                    modelElement = (ModelElement) obj;
                } else if (obj instanceof ImpactNode) {
                    modelElement = ((ImpactNode) obj).getNodeElement();
                } else if (obj instanceof IFile) {
                    modelElement = ModelElementFileFactory.getModelElement((IFile) obj);
                } else if (obj instanceof RepositoryViewObject) {
                    // Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
                    return ImageLib.getImage(ImageLib.JRXML_ICON);
                }
                // ~
                if (modelElement == null) {
                    if (((ImpactNode) obj).getNode() != null) {
                        return ImageLib.getImage(ImageLib.JRXML_ICON);
                    }
                    return super.getImage(obj);
                }
                Image modelElementImage = null;
                String imgName = null;
                if (modelElement instanceof Analysis) {
                    imgName = ImageLib.ANALYSIS_OBJECT;
                } else if (modelElement instanceof TdReport) {
                    imgName = ImageLib.REPORT_OBJECT;
                } else if (modelElement instanceof DatabaseConnection) {
                    imgName = ImageLib.CONNECTION;
                } else if (modelElement instanceof DelimitedFileConnection) {
                    imgName = ImageLib.FILE_DELIMITED;
                } else if (modelElement instanceof Pattern) {
                    imgName = ImageLib.PATTERN_REG;
                } else if (modelElement instanceof IndicatorDefinition) {
                    // IndicatorDefinition
                    if (modelElement instanceof DQRule) {
                        imgName = ImageLib.DQ_RULE;
                    } else if (modelElement instanceof MatchRuleDefinition) {
                        imgName = ImageLib.MATCH_RULE_ICON;
                    } else {
                        imgName = ImageLib.IND_DEFINITION;
                    }
                // TDQ-8550~
                } else if (modelElement instanceof MetadataTable) {
                    imgName = ImageLib.TABLE;
                }
                if (imgName != null) {
                    modelElementImage = ImageLib.getImage(imgName);
                }
                // add lock icon on the image
                if (modelElementImage != null) {
                    if (modelElement != null) {
                        Property property = PropertyHelper.getProperty(modelElement);
                        if (property != null) {
                            Item item = property.getItem();
                            if (item != null) {
                                if (ProxyRepositoryManager.getInstance().isLockByUserOwn(item)) {
                                    modelElementImage = ImageLib.createLockedByOwnIcon(imgName);
                                } else if (ProxyRepositoryManager.getInstance().isLockByOthers(item)) {
                                    modelElementImage = ImageLib.createLockedByOtherIcon(imgName);
                                }
                            }
                        }
                    }
                    return modelElementImage;
                }
                return super.getImage(obj);
            }
        };
    }
    return labelProvider;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) IFile(org.eclipse.core.resources.IFile) ImpactNode(org.talend.dataprofiler.core.ui.dialog.message.DeleteModelElementConfirmDialog.ImpactNode) TdReport(org.talend.dataquality.reports.TdReport) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) Image(org.eclipse.swt.graphics.Image) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DQRule(org.talend.dataquality.rules.DQRule) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Item(org.talend.core.model.properties.Item) Analysis(org.talend.dataquality.analysis.Analysis) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 18 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class RecordMatchingIndicatorImpl method basicSetBuiltInMatchRuleDefinition.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetBuiltInMatchRuleDefinition(MatchRuleDefinition newBuiltInMatchRuleDefinition, NotificationChain msgs) {
    MatchRuleDefinition oldBuiltInMatchRuleDefinition = builtInMatchRuleDefinition;
    builtInMatchRuleDefinition = newBuiltInMatchRuleDefinition;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ColumnsetPackage.RECORD_MATCHING_INDICATOR__BUILT_IN_MATCH_RULE_DEFINITION, oldBuiltInMatchRuleDefinition, newBuiltInMatchRuleDefinition);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition)

Example 19 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class FileTreeLabelProvider method getImage.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
     */
@Override
public Image getImage(Object element) {
    Image image = null;
    if (element instanceof ItemRecord) {
        ItemRecord record = (ItemRecord) element;
        File file = record.getFile();
        String fileName = file.getName();
        if (file.isDirectory()) {
            image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
            EResourceConstant constant = resolveResourceConstant(fileName);
            if (constant != null) {
                switch(constant) {
                    case DATA_PROFILING:
                        image = ImageLib.getImage(ImageLib.DATA_PROFILING);
                        break;
                    case METADATA:
                        image = ImageLib.getImage(ImageLib.METADATA);
                        break;
                    case LIBRARIES:
                        image = ImageLib.getImage(ImageLib.LIBRARIES);
                        break;
                    case ANALYSIS:
                        break;
                    case REPORTS:
                        break;
                    case EXCHANGE:
                        image = ImageLib.getImage(ImageLib.EXCHANGE);
                        break;
                    case DB_CONNECTIONS:
                        image = ImageLib.getImage(ImageLib.CONNECTION);
                        break;
                    case FILEDELIMITED:
                        image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
                        break;
                    case HADOOP_CLUSTER:
                        image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
                        break;
                    case CONTEXT:
                        image = ImageLib.getImage(ImageLib.CONTEXT);
                        break;
                    default:
                        break;
                }
            }
        } else {
            if (fileName.endsWith(FactoriesUtil.ANA)) {
                image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
            } else if (fileName.endsWith(FactoriesUtil.REP)) {
                image = ImageLib.getImage(ImageLib.REPORT_OBJECT);
            } else if (fileName.endsWith(FactoriesUtil.PATTERN)) {
                image = ImageLib.getImage(ImageLib.PATTERN_REG);
            } else if (fileName.endsWith(FactoriesUtil.DQRULE)) {
                if (record.getElement() instanceof MatchRuleDefinition) {
                    image = ImageLib.getImage(ImageLib.MATCH_RULE_ICON);
                } else {
                    image = ImageLib.getImage(ImageLib.DQ_RULE);
                }
            } else if (fileName.endsWith(FactoriesUtil.ITEM_EXTENSION)) {
                if (record.getElement() instanceof DelimitedFileConnection) {
                    image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
                } else if (record.getElement() instanceof DatabaseConnection) {
                    image = ImageLib.getImage(ImageLib.TD_DATAPROVIDER);
                } else {
                    image = ImageLib.getImage(ImageLib.CONTEXT);
                }
            } else if (fileName.endsWith(FactoriesUtil.DEFINITION)) {
                image = ImageLib.getImage(ImageLib.IND_DEFINITION);
            } else if (fileName.endsWith(FactoriesUtil.SQL)) {
                image = ImageLib.getImage(ImageLib.SOURCE_FILE);
            } else if (fileName.endsWith(FactoriesUtil.JAR)) {
                image = ImageLib.getImage(ImageLib.JAR_FILE);
            } else if (fileName.endsWith(FactoriesUtil.JRXML)) {
                image = ImageLib.getImage(ImageLib.JRXML_ICON);
            }
        }
    }
    return image != null ? image : super.getImage(element);
}
Also used : EResourceConstant(org.talend.resource.EResourceConstant) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Image(org.eclipse.swt.graphics.Image) File(java.io.File)

Example 20 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class MatchAnalysisExecutorTest method createMatchIndicatorWithOneMathRule.

/**
 * DOC zhao Comment method "createMatchIndicatorWithOneMathRule".
 *
 * @param nameVar
 * @param matchIndicator
 * @param groupQualityThreshold
 * @param matchInterval
 */
private void createMatchIndicatorWithOneMathRule(String nameVar, RecordMatchingIndicator matchIndicator, double groupQualityThreshold, double matchInterval) {
    MatchRuleDefinition matchRuleDefinition = RulesPackage.eINSTANCE.getRulesFactory().createMatchRuleDefinition();
    matchRuleDefinition.setMatchGroupQualityThreshold(groupQualityThreshold);
    MatchRule matchRule = RulesPackage.eINSTANCE.getRulesFactory().createMatchRule();
    matchRule.setMatchInterval(matchInterval);
    matchRule.setName("match rule 1");
    MatchKeyDefinition matchkeyDef = RulesPackage.eINSTANCE.getRulesFactory().createMatchKeyDefinition();
    matchkeyDef.setName(nameVar);
    matchkeyDef.setColumn(nameVar);
    AlgorithmDefinition algoDef = RulesPackage.eINSTANCE.getRulesFactory().createAlgorithmDefinition();
    algoDef.setAlgorithmType(AttributeMatcherType.LEVENSHTEIN.name());
    matchkeyDef.setAlgorithm(algoDef);
    matchkeyDef.setConfidenceWeight(1);
    matchRule.getMatchKeys().add(matchkeyDef);
    matchRuleDefinition.getMatchRules().add(matchRule);
    matchIndicator.setBuiltInMatchRuleDefinition(matchRuleDefinition);
}
Also used : MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) AlgorithmDefinition(org.talend.dataquality.rules.AlgorithmDefinition) MatchRule(org.talend.dataquality.rules.MatchRule)

Aggregations

MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)35 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)9 RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)8 MatchRule (org.talend.dataquality.rules.MatchRule)8 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)6 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)6 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)6 RuleRepNode (org.talend.dq.nodes.RuleRepNode)6 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 Test (org.junit.Test)5 Analysis (org.talend.dataquality.analysis.Analysis)5 MatchGroupResultConsumer (org.talend.dataquality.record.linkage.grouping.MatchGroupResultConsumer)5 Map (java.util.Map)4 IFile (org.eclipse.core.resources.IFile)4 BlockKeyIndicator (org.talend.dataquality.indicators.columnset.BlockKeyIndicator)4 TDQMatchRuleItem (org.talend.dataquality.properties.TDQMatchRuleItem)4 ExecuteMatchRuleHandler (org.talend.dq.analysis.match.ExecuteMatchRuleHandler)4 IFolder (org.eclipse.core.resources.IFolder)3 BlockKeyDefinition (org.talend.dataquality.rules.BlockKeyDefinition)3