Search in sources :

Example 6 with MatchRuleDefinition

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

the class MatchRuleMasterDetailsPage method getMatchRuleRepNodeFromInput.

/**
 * get PatternRepNode From editorInput
 *
 * @param editorInput
 * @return
 */
private RuleRepNode getMatchRuleRepNodeFromInput(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
        IFile file = fileEditorInput.getFile();
        if (file != null) {
            MatchRuleDefinition matchRuleDefinition = DQRuleResourceFileHelper.getInstance().findMatchRule(file);
            matchRuleDefinition = (MatchRuleDefinition) EObjectHelper.resolveObject(matchRuleDefinition);
            return RepositoryNodeHelper.recursiveFindMatcherRule(matchRuleDefinition);
        }
    } else if (editorInput instanceof BusinessRuleItemEditorInput) {
        return ((BusinessRuleItemEditorInput) editorInput).getRepNode();
    } else if (editorInput instanceof MatchRuleItemEditorInput) {
        // this is only comes from MDM team
        matchRuleDefiniton = (MatchRuleDefinition) ((MatchRuleItemEditorInput) editorInput).getMatchRule();
        item = ((MatchRuleItemEditorInput) editorInput).getItem();
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) BusinessRuleItemEditorInput(org.talend.dataprofiler.core.ui.editor.dqrules.BusinessRuleItemEditorInput) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition)

Example 7 with MatchRuleDefinition

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

the class ItemRecord method includeCustomMatcherJarDependencies.

/**
 * DOC zshen Comment method "includeCustomMatcherJarDependencies".
 *
 * @param matchAnalysis
 */
private void includeCustomMatcherJarDependencies(Analysis matchAnalysis) {
    RecordMatchingIndicator recordMatchIndicatorFromAna = AnalysisHelper.getRecordMatchIndicatorFromAna(matchAnalysis);
    MatchRuleDefinition builtInMatchRuleDefinition = recordMatchIndicatorFromAna.getBuiltInMatchRuleDefinition();
    includeCustomMatcherJarDependencies(builtInMatchRuleDefinition);
}
Also used : MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)

Example 8 with MatchRuleDefinition

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

the class ItemRecord method computeDependencies.

/**
 * DOC bZhou Comment method "computeDependencies".
 */
private void computeDependencies(ModelElement mElement) {
    if (isJRXml()) {
        Collection<TdReport> allReports = (Collection<TdReport>) RepResourceFileHelper.getInstance().getAllElement();
        for (TdReport report : allReports) {
            // MOD yyi 2012-02-20 TDQ-4545 TDQ-4701: Change to relative path comparing.
            IPath pathRepFile = RepResourceFileHelper.findCorrespondingFile(report).getLocation();
            IPath pathJrxmlFile = new Path(file.getPath());
            String path = pathJrxmlFile.makeRelativeTo(pathRepFile).toString();
            for (AnalysisMap anaMap : report.getAnalysisMap()) {
                if (StringUtils.equals(path, anaMap.getJrxmlSource())) {
                    // TODO the File is jrxml, but the ModelElement is report ???
                    this.dependencySet.add(file);
                }
            }
        }
    } else if (mElement != null) {
        if (mElement instanceof Connection) {
            includeContextDependency((Connection) mElement);
            return;
        }
        List<File> dependencyFile = getClintDependencyForExport(mElement);
        for (File df : dependencyFile) {
            ModelElement modelElement = getElement(df);
            if (modelElement != null) {
                File depFile = EObjectHelper.modelElement2File(modelElement);
                if (depFile != null) {
                    this.dependencySet.add(depFile);
                }
                // MOD sizhaoliu 2013-04-13 TDQ-7082
                if (modelElement instanceof IndicatorDefinition) {
                    if (modelElement instanceof UDIndicatorDefinition) {
                        includeJUDIDependencies((IndicatorDefinition) modelElement);
                    } else {
                        for (IndicatorDefinition definition : ((IndicatorDefinition) modelElement).getAggregatedDefinitions()) {
                            includeAggregatedDependencies(definition);
                        }
                    }
                }
            }
        }
        // MOD yyi 2012-02-20 TDQ-4545 TDQ-4701: Map user define jrxm templates with report.
        if (mElement instanceof TdReport) {
            TdReport rep = (TdReport) mElement;
            for (AnalysisMap anaMap : rep.getAnalysisMap()) {
                ReportType reportType = ReportHelper.ReportType.getReportType(anaMap.getAnalysis(), anaMap.getReportType());
                boolean isUserMade = ReportHelper.ReportType.USER_MADE.equals(reportType);
                if (isUserMade) {
                    traverseFolderAndAddJrxmlDependencies(getJrxmlFolderFromReport(rep, ResourceManager.getJRXMLFolder()));
                }
            }
        } else if (mElement instanceof IndicatorDefinition) {
            // MOD sizhaoliu 2013-04-13 TDQ-7082
            IndicatorDefinition definition = (IndicatorDefinition) mElement;
            if (definition instanceof UDIndicatorDefinition) {
                includeJUDIDependencies(definition);
            } else {
                for (IndicatorDefinition defInd : definition.getAggregatedDefinitions()) {
                    includeAggregatedDependencies(defInd);
                }
            }
            // folder
            if (mElement instanceof MatchRuleDefinition) {
                includeCustomMatcherJarDependencies((MatchRuleDefinition) mElement);
            }
        } else if (mElement instanceof Analysis && AnalysisType.MATCH_ANALYSIS == AnalysisHelper.getAnalysisType((Analysis) mElement)) {
            includeCustomMatcherJarDependencies((Analysis) mElement);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdReport(org.talend.dataquality.reports.TdReport) Connection(org.talend.core.model.metadata.builder.connection.Connection) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) Collection(java.util.Collection) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) File(java.io.File) ReportType(org.talend.dataquality.helpers.ReportHelper.ReportType)

Example 9 with MatchRuleDefinition

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

the class MatchWizard method initCWMResourceBuilder.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnSetWizard#initCWMResourceBuilder()
     */
@Override
public ModelElement initCWMResourceBuilder() {
    Analysis analysis = (Analysis) super.initCWMResourceBuilder();
    // New blocking key indicator.
    Indicator blockKeyIndicator = ColumnsetFactory.eINSTANCE.createBlockKeyIndicator();
    analysis.getResults().getIndicators().add(blockKeyIndicator);
    // Match rule indicator
    RecordMatchingIndicator matchRuleIndicator = ColumnsetFactory.eINSTANCE.createRecordMatchingIndicator();
    MatchRuleDefinition matchRuleDefinition = RulesFactory.eINSTANCE.createMatchRuleDefinition();
    matchRuleIndicator.setBuiltInMatchRuleDefinition(matchRuleDefinition);
    analysis.getResults().getIndicators().add(matchRuleIndicator);
    // default loaded row count
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    int maxRows = preferenceStore.getInt(PluginConstant.MAX_NB_ROWS_ANALYSIS_EDITOR);
    TaggedValueHelper.setTaggedValue(analysis, TaggedValueHelper.PREVIEW_ROW_NUMBER, String.valueOf(maxRows));
    return analysis;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 10 with MatchRuleDefinition

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

the class RuleFolderFliter method select.

@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
    // MOD klliu bug TDQ-3202 filter Parser Rule folder and item.
    if (element instanceof IFile) {
        IFile file = (IFile) element;
        if (FactoriesUtil.DQRULE.equals(file.getFileExtension())) {
            // add support for match rule
            ModelElement modelElement = DQRuleResourceFileHelper.getInstance().getModelElement(file);
            if (modelElement == null) {
                return false;
            }
            ModelElement rule = DQRuleResourceFileHelper.getInstance().doSwitch(modelElement);
            if (rule != null && rule instanceof MatchRuleDefinition) {
                return true;
            }
            // ~
            WhereRule findWhereRule = DQRuleResourceFileHelper.getInstance().findWhereRule(file);
            if (findWhereRule == null) {
                return false;
            }
            return true;
        }
    } else if (element instanceof IFolder) {
        IFolder folder = (IFolder) element;
        boolean subFolder = ResourceService.isSubFolder(ResourceManager.getRulesFolder(), folder);
        if (subFolder) {
            return !folder.getFullPath().equals(ResourceManager.getRulesParserFolder().getFullPath());
        }
        return subFolder;
    }
    // ~
    return isShowFile;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IFile(org.eclipse.core.resources.IFile) WhereRule(org.talend.dataquality.rules.WhereRule) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) IFolder(org.eclipse.core.resources.IFolder)

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