Search in sources :

Example 6 with PatternMatchingIndicator

use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.

the class ModelElementTreeMenuProvider method editPattern.

private void editPattern(Tree tree) {
    TreeItem[] selection = tree.getSelection();
    if (selection.length > 0) {
        TreeItem treeItem = selection[0];
        IndicatorUnit indicatorUnit = (IndicatorUnit) treeItem.getData(AbstractColumnDropTree.INDICATOR_UNIT_KEY);
        PatternMatchingIndicator indicator = (PatternMatchingIndicator) indicatorUnit.getIndicator();
        Pattern pattern = indicator.getParameters().getDataValidDomain().getPatterns().get(0);
        RepositoryNode patternRecursiveFind = RepositoryNodeHelper.recursiveFind(pattern);
        PatternItemEditorInput patternItemEditorInput = new PatternItemEditorInput(patternRecursiveFind);
        CorePlugin.getDefault().openEditor(patternItemEditorInput, PatternEditor.class.getName());
    }
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) PatternEditor(org.talend.dataprofiler.core.ui.editor.pattern.PatternEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ColumnIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit) PatternItemEditorInput(org.talend.dataprofiler.core.ui.editor.pattern.PatternItemEditorInput) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 7 with PatternMatchingIndicator

use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.

the class PatternMouseAdapter method mouseDown.

@Override
public void mouseDown(MouseEvent e) {
    DataManager dm = analysis.getContext().getConnection();
    if (dm == null) {
        masterPage.doSave(null);
    }
    // MOD gdbu 2011-8-26 bug : TDQ-2169
    IRepositoryNode patternFolderNode = getPatternSelectDialogInputData();
    if (patternFolderNode == null) {
        return;
    }
    CheckedTreeSelectionDialog dialog = PatternUtilities.createPatternCheckedTreeSelectionDialog(patternFolderNode);
    if (null != filters) {
        for (ViewerFilter filter : filters) {
            dialog.addFilter(filter);
        }
    }
    // ~TDQ-2169
    Object[] selectedRepNodes = PatternUtilities.getPatternRepNodesByIndicator(meIndicator);
    dialog.setInitialSelections(selectedRepNodes);
    dialog.create();
    if (dialog.open() == Window.OK) {
        // MOD qiongli 2012-10-17 TDQ-5923,just remove some deselected indicatorUnit,just create new indicatorUnit
        // for some new added pattern nodes.
        List<PatternRepNode> allSelectedPatternNodes = new ArrayList<PatternRepNode>();
        Set<String> allSelectedNodeNames = new HashSet<String>();
        for (Object obj : dialog.getResult()) {
            if (obj instanceof PatternRepNode) {
                PatternRepNode patternNode = (PatternRepNode) obj;
                allSelectedPatternNodes.add(patternNode);
                allSelectedNodeNames.add(patternNode.getLabel());
            }
        }
        Set<String> oldSelectedNodeNames = new HashSet<String>();
        Map<String, IndicatorUnit> oldSelectedUnits = new HashMap<String, IndicatorUnit>();
        for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
            Indicator indicator = indicatorUnit.getIndicator();
            if (indicator instanceof PatternMatchingIndicator) {
                if (!allSelectedNodeNames.contains(indicator.getName())) {
                    // this method will deal dependency with same time
                    columnDropTree.deleteIndicatorItems(meIndicator, indicatorUnit);
                    if (!columnDropTree.isDirty()) {
                        columnDropTree.setDirty(true);
                    }
                } else {
                    oldSelectedNodeNames.add(indicator.getName());
                    oldSelectedUnits.put(indicator.getName(), indicatorUnit);
                }
            }
        }
        // Added yyin 20121121 TDQ-6329: after remove all, should also add the old selected patterns
        // because the columnset does not have pagination, can not refresh automatically
        boolean addOldSelected = false;
        if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
            addOldSelected = true;
        }
        if (addOldSelected) {
            for (TreeItem child : treeItem.getItems()) {
                masterPage.getTreeViewer().removeItemBranch(child);
            }
        }
        // ~
        treeItem.removeAll();
        for (PatternRepNode patternNode : allSelectedPatternNodes) {
            if (oldSelectedNodeNames.contains(patternNode.getLabel()) && !addOldSelected) {
                continue;
            }
            TypedReturnCode<IndicatorUnit> trc = PatternUtilities.createIndicatorUnit(patternNode.getPattern(), meIndicator, analysis);
            if (trc.isOk()) {
                createOneUnit(trc.getObject());
                // TDQ-8860 add msjian 2014-4-30:check whether show allmatchindicator in the indicators section
                if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
                    EventManager.getInstance().publish(analysis, EventEnum.DQ_COLUMNSET_SHOW_MATCH_INDICATORS, null);
                }
            // TDQ-8860~
            }
        }
        treeItem.setExpanded(true);
        if (masterPage instanceof ColumnAnalysisDetailsPage) {
            ColumnAnalysisDetailsPage page = (ColumnAnalysisDetailsPage) masterPage;
            page.refreshTheTree(page.getCurrentModelElementIndicators());
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) CheckedTreeSelectionDialog(org.eclipse.ui.dialogs.CheckedTreeSelectionDialog) HashMap(java.util.HashMap) TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) ColumnSetAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.ColumnSetAnalysisDetailsPage) ColumnAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.ColumnAnalysisDetailsPage) PatternRepNode(org.talend.dq.nodes.PatternRepNode) HashSet(java.util.HashSet)

Example 8 with PatternMatchingIndicator

use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.

the class DbmsLanguage method getRegexPatternString.

/**
 * Method "getRegexPatternString".
 *
 * @param indicator
 * @return the regular expression or null if none was found
 */
public String getRegexPatternString(Indicator indicator) {
    if (indicator instanceof PatternMatchingIndicator || (indicator instanceof UserDefIndicator && IndicatorCategoryHelper.isUserDefMatching(IndicatorCategoryHelper.getCategory(indicator.getIndicatorDefinition())))) {
        IndicatorParameters parameters = indicator.getParameters();
        if (parameters == null) {
            return null;
        }
        Domain dataValidDomain = parameters.getDataValidDomain();
        if (dataValidDomain == null) {
            return null;
        }
        EList<Pattern> patterns = dataValidDomain.getPatterns();
        for (Pattern pattern : patterns) {
            Expression expression = this.getRegexp(pattern);
            return expression == null ? null : expression.getBody();
        }
    }
    return null;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) Domain(org.talend.dataquality.domain.Domain) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 9 with PatternMatchingIndicator

use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.

the class FileSystemImportWriter method updatePatternInAnaParams.

/**
 * if there is a same name pattern in current workspace,update the pattern in imported analysis IndicatorParameters.
 *
 * @param systemSupplyModelElement
 * @param analysis
 */
private void updatePatternInAnaParams(ModelElement systemSupplyModelElement, Analysis analysis) {
    if (analysis.getResults() != null) {
        EList<Indicator> indicators = analysis.getResults().getIndicators();
        IndicatorParameters parameters = null;
        for (Indicator indicator : indicators) {
            // AllMatchIndicator is in column set analysis.
            if (indicator instanceof AllMatchIndicator) {
                EList<RegexpMatchingIndicator> list = ((AllMatchIndicator) indicator).getCompositeRegexMatchingIndicators();
                for (RegexpMatchingIndicator regMatchIndicator : list) {
                    parameters = regMatchIndicator.getParameters();
                    removOldAddSysPatternInAnaParams(parameters, (Pattern) systemSupplyModelElement, analysis);
                }
            } else if (indicator instanceof PatternMatchingIndicator) {
                parameters = ((PatternMatchingIndicator) indicator).getParameters();
                removOldAddSysPatternInAnaParams(parameters, (Pattern) systemSupplyModelElement, analysis);
            }
        }
    }
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator)

Example 10 with PatternMatchingIndicator

use of org.talend.dataquality.indicators.PatternMatchingIndicator in project tdq-studio-se by Talend.

the class IndicatorCommonUtil method handleMatchingValue.

/**
 * DOC xqliu Comment method "handleMatchingValue".
 *
 * @param indicator
 * @return
 */
public static PatternMatchingExt handleMatchingValue(Indicator indicator) {
    PatternMatchingExt patternExt = new PatternMatchingExt();
    if (UDIHelper.isUDI(indicator)) {
        UserDefIndicator udi = (UserDefIndicator) indicator;
        if (udi.getMatchingValueCount() != null) {
            patternExt.setMatchingValueCount(udi.getMatchingValueCount());
        }
        if (udi.getNotMatchingValueCount() != null) {
            patternExt.setNotMatchingValueCount(udi.getNotMatchingValueCount());
        }
    } else {
        // TDQ-12282 msjian : fix a NPE
        Long matchingValueCount = ((PatternMatchingIndicator) indicator).getMatchingValueCount();
        patternExt.setMatchingValueCount(matchingValueCount == null ? 0l : matchingValueCount);
        Long notMatchingValueCount = ((PatternMatchingIndicator) indicator).getNotMatchingValueCount();
        patternExt.setNotMatchingValueCount(notMatchingValueCount == null ? 0l : notMatchingValueCount);
    }
    return patternExt;
}
Also used : PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) PatternMatchingExt(org.talend.dq.indicators.ext.PatternMatchingExt) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Aggregations

PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)18 Pattern (org.talend.dataquality.domain.pattern.Pattern)12 ArrayList (java.util.ArrayList)8 Analysis (org.talend.dataquality.analysis.Analysis)8 Indicator (org.talend.dataquality.indicators.Indicator)8 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)8 Expression (orgomg.cwm.objectmodel.core.Expression)7 Test (org.junit.Test)6 TdExpression (org.talend.cwm.relational.TdExpression)6 Domain (org.talend.dataquality.domain.Domain)6 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)5 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)5 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)5 TdColumn (org.talend.cwm.relational.TdColumn)4 TdTable (org.talend.cwm.relational.TdTable)4 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)4 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)4 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)4 Catalog (orgomg.cwm.resource.relational.Catalog)4