Search in sources :

Example 36 with IndicatorDefinition

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

the class AnalysisTableTreeViewer method removeUncheckedWhereRuleIndicator.

/**
 * DOC xqliu Comment method "removeUncheckedWhereRuleIndicator". ADD xqliu 2009-04-30 bug 6808
 *
 * @param ownedWhereRuleNodes
 * @param results
 * @param tableIndicator
 */
private void removeUncheckedWhereRuleIndicator(Object[] ownedWhereRuleNodes, Object[] results, TableIndicator tableIndicator) {
    ArrayList<Object> removeList = new ArrayList<Object>();
    for (Object node : ownedWhereRuleNodes) {
        boolean remove = true;
        for (Object result : results) {
            if (node.equals(result)) {
                remove = false;
                break;
            }
        }
        if (remove) {
            removeList.add(node);
        }
    }
    TableIndicatorUnit[] indicatorUnits = tableIndicator.getIndicatorUnits();
    for (TableIndicatorUnit unit : indicatorUnits) {
        IndicatorDefinition indicatorDefinition = unit.getIndicator().getIndicatorDefinition();
        if (indicatorDefinition instanceof WhereRule) {
            WhereRule wr = (WhereRule) indicatorDefinition;
            RuleRepNode recursiveFindNode = RepositoryNodeHelper.recursiveFindRuleSql(wr);
            for (Object obj : removeList) {
                RuleRepNode node = (RuleRepNode) obj;
                if (recursiveFindNode.equals(node)) {
                    // the order can not be changed
                    removeItemBranch(this.indicatorTreeItemMap.get(unit));
                    deleteIndicatorItems(tableIndicator, unit);
                    // ~the order can not be changed
                    break;
                }
            }
        }
    }
}
Also used : WhereRule(org.talend.dataquality.rules.WhereRule) ArrayList(java.util.ArrayList) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 37 with IndicatorDefinition

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

the class IndicatorDefinitionMaterPage method getIndicatorRepNodeFromInput.

/**
 * get PatternRepNode From editorInput
 *
 * @param editorInput
 * @return
 */
private SysIndicatorDefinitionRepNode getIndicatorRepNodeFromInput(IEditorInput editorInput) {
    if (editorInput instanceof FileEditorInput) {
        FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
        IFile file = fileEditorInput.getFile();
        if (file != null) {
            IndicatorDefinition indicatorDefinition = IndicatorResourceFileHelper.getInstance().findIndDefinition(file);
            indicatorDefinition = (IndicatorDefinition) EObjectHelper.resolveObject(indicatorDefinition);
            return RepositoryNodeHelper.recursiveFindIndicatorDefinition(indicatorDefinition);
        }
    } else if (editorInput instanceof IndicatorDefinitionItemEditorInput) {
        return ((IndicatorDefinitionItemEditorInput) editorInput).getRepNode();
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 38 with IndicatorDefinition

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

the class PatternExplorer method getInvalidRowsStatement.

/**
 * get the Invalid Rows Statement.
 *
 * @return
 */
public String getInvalidRowsStatement() {
    // when the indicator is the use define match
    IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
    if (indicatorDefinition instanceof UDIndicatorDefinition) {
        EList<TdExpression> list = ((UDIndicatorDefinition) indicatorDefinition).getViewInvalidRowsExpression();
        return getQueryAfterReplaced(indicatorDefinition, list);
    }
    String regexPatternString = dbmsLanguage.getRegexPatternString(this.indicator);
    String regexCmp = getRegexNotLike(regexPatternString);
    // add null as invalid rows
    String nullClause = dbmsLanguage.or() + columnName + dbmsLanguage.isNull();
    // mzhao TDQ-4967 add "(" and ")" for regex and null clause.
    // $NON-NLS-1$//$NON-NLS-2$
    String pattCondStr = "(" + regexCmp + nullClause + ")";
    return getRowsStatement(pattCondStr);
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Example 39 with IndicatorDefinition

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

the class PatternExplorer method getValidRowsStatement.

/**
 * get the Valid Rows Statement.
 *
 * @return
 */
public String getValidRowsStatement() {
    // when the indicator is the use define match
    IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
    if (indicatorDefinition instanceof UDIndicatorDefinition) {
        EList<TdExpression> list = ((UDIndicatorDefinition) indicatorDefinition).getViewValidRowsExpression();
        return getQueryAfterReplaced(indicatorDefinition, list);
    }
    String regexPatternString = dbmsLanguage.getRegexPatternString(this.indicator);
    String regexCmp = getRegexLike(regexPatternString);
    return getRowsStatement(regexCmp);
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Example 40 with IndicatorDefinition

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

the class UDIUtils method checkUDIDependency.

public static ReturnCode checkUDIDependency(IndicatorDefinition definition, File delFile) {
    ReturnCode result = new ReturnCode(true);
    IPath filePath = new Path(delFile.getPath());
    if (!ResourceManager.getUDIJarFolder().getLocation().isPrefixOf(filePath)) {
        // filePath.makeRelativeTo(ResourceManager.getRootFolderLocation()))) {
        return result;
    }
    for (IRepositoryNode indiDefNode : RepositoryNodeHelper.getUdisRepositoryNodes(true)) {
        IndicatorDefinition indiDef = null;
        Item item = indiDefNode.getObject().getProperty().getItem();
        if (item instanceof TDQIndicatorDefinitionItem) {
            indiDef = ((TDQIndicatorDefinitionItem) item).getIndicatorDefinition();
        } else {
            continue;
        }
        // when it is itself, don't use this check.
        if (indiDef == definition) {
            continue;
        }
        // ADD end
        TaggedValue tv = TaggedValueHelper.getTaggedValue(TaggedValueHelper.JAR_FILE_PATH, indiDef.getTaggedValue());
        if (tv == null) {
            continue;
        }
        // $NON-NLS-1$
        String[] strArray = tv.getValue().split("\\|\\|");
        int index = Arrays.binarySearch(strArray, filePath.lastSegment());
        if (index >= 0) {
            // $NON-NLS-1$ //$NON-NLS-2$
            result.setMessage("The jar file(" + strArray[index] + ") has in use by UDI for " + indiDef.getName());
            result.setOk(false);
            return result;
        }
    }
    return result;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Item(org.talend.core.model.properties.Item) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) ReturnCode(org.talend.utils.sugars.ReturnCode) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) IPath(org.eclipse.core.runtime.IPath) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Aggregations

IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)141 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)37 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)34 TdExpression (org.talend.cwm.relational.TdExpression)31 File (java.io.File)22 Analysis (org.talend.dataquality.analysis.Analysis)16 IFile (org.eclipse.core.resources.IFile)15 Property (org.talend.core.model.properties.Property)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 Indicator (org.talend.dataquality.indicators.Indicator)12 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)12 Path (org.eclipse.core.runtime.Path)10 IFolder (org.eclipse.core.resources.IFolder)9 BasicEList (org.eclipse.emf.common.util.BasicEList)9 TdColumn (org.talend.cwm.relational.TdColumn)9 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)7 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)7