Search in sources :

Example 6 with IndicatorDefinition

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

the class UpdateOracleAverageLengthTask method doExecute.

/*
     * (non-Jsdoc)
     * 
     * @see org.talend.dataprofiler.core.migration.AMigrationTask#doExecute()
     */
@Override
protected boolean doExecute() throws Exception {
    // $NON-NLS-1$
    IndicatorDefinition aveWithBlank = IndicatorDefinitionFileHelper.getSystemIndicatorByName("Average Length With Blank");
    // $NON-NLS-1$
    IndicatorDefinition aveWithNull = IndicatorDefinitionFileHelper.getSystemIndicatorByName("Average Length With Null");
    IndicatorDefinition aveWithBlankNull = IndicatorDefinitionFileHelper.getSystemIndicatorByName(// $NON-NLS-1$
    "Average Length With Blank and Null");
    // $NON-NLS-1$
    String newExpWithBlank = "SELECT SUM(LENGTH(<%=__COLUMN_NAMES__%>)), COUNT(*) FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%>";
    setNewExpression(aveWithBlank, newExpWithBlank);
    setNewExpression(aveWithNull, newExpWithBlank);
    setNewExpression(aveWithBlankNull, newExpWithBlank);
    return true;
}
Also used : IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 7 with IndicatorDefinition

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

the class UpdateRegularExpressionMatchingMysqlExpressionTask method doExecute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.migration.AMigrationTask#doExecute()
     */
@Override
protected boolean doExecute() throws Exception {
    IndicatorDefinition indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(REGULAR_EXPRESSION_MATCHING_LABEL);
    if (indicatorDefinition != null) {
        EList<TdExpression> sqlGenericExpression = indicatorDefinition.getSqlGenericExpression();
        if (sqlGenericExpression != null && sqlGenericExpression.size() > 0) {
            boolean notFoundMysqlExpression = true;
            for (TdExpression expression : sqlGenericExpression) {
                if (expression != null && SupportDBUrlType.MYSQLDEFAULTURL.getLanguage().equals(expression.getLanguage())) {
                    notFoundMysqlExpression = false;
                    expression.setBody(MYSQL_EXPRESSION);
                    break;
                }
            }
            if (notFoundMysqlExpression) {
                TdExpression newExpression = BooleanExpressionHelper.createTdExpression(SupportDBUrlType.MYSQLDEFAULTURL.getLanguage(), MYSQL_EXPRESSION);
                sqlGenericExpression.add(newExpression);
            } else {
            // mysql expression have exist, so needn't to create a new mysql expression
            }
        }
    }
    return true;
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 8 with IndicatorDefinition

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

the class UpdateDependenciesFileTask method updateDependencies.

/**
 * Method "updateDependencies" updates dependencies between elements in TOP.
 *
 * @param analysesSubFolder
 * @throws CoreException
 */
private void updateDependencies(IFolder analysesSubFolder) throws CoreException {
    for (IResource resource : analysesSubFolder.members()) {
        if (resource instanceof IFolder) {
            IFolder folder = (IFolder) resource;
            updateDependencies(folder);
        }
        if (resource instanceof IFile) {
            IFile file = (IFile) resource;
            final Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(file);
            // update dependency between analyses and patterns
            if (analysis != null) {
                final List<Pattern> patterns = AnalysisHelper.getPatterns(analysis);
                for (Pattern pattern : patterns) {
                    DependenciesHandler.getInstance().setDependencyOn(analysis, pattern);
                    AnaResourceFileHelper.getInstance().save(analysis);
                }
                // update dependency between analyses and dq rules
                final List<IndicatorDefinition> userDefinedIndicators = AnalysisHelper.getUserDefinedIndicators(analysis);
                for (IndicatorDefinition indicatorDefinition : userDefinedIndicators) {
                    DependenciesHandler.getInstance().setDependencyOn(analysis, indicatorDefinition);
                    AnaResourceFileHelper.getInstance().save(analysis);
                }
            }
        }
    }
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) IFile(org.eclipse.core.resources.IFile) Analysis(org.talend.dataquality.analysis.Analysis) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 9 with IndicatorDefinition

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

the class UpdateIndicatorsForVertica method doExecute.

/**
 * migrate these indicators for Vertica database:Pattern Frequency Table,Pattern Low Frequency Table,Regular
 * Expression Matching.
 */
@Override
protected boolean doExecute() throws Exception {
    DefinitionHandler definitionHandler = DefinitionHandler.getInstance();
    IndicatorDefinition patternMatchIndDef = definitionHandler.getDefinitionById(patternMatchIndiDefId);
    IndicatorDefinition patternFreqIndDef = definitionHandler.getDefinitionById(patternFreqIndiDefId);
    IndicatorDefinition patternLowPatternFreqIndDef = definitionHandler.getDefinitionById(lowPatternFreqIndiDefId);
    IndicatorDefinition benFordIndDef = definitionHandler.getDefinitionById(benfordId);
    boolean isNeedReload = false;
    if (patternMatchIndDef != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(patternMatchIndDef, language)) {
        IndicatorDefinitionFileHelper.addSqlExpression(patternMatchIndDef, language, patternMatchSQL);
        IndicatorDefinitionFileHelper.save(patternMatchIndDef);
        isNeedReload = true;
    }
    if (patternFreqIndDef != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(patternFreqIndDef, language)) {
        IndicatorDefinitionFileHelper.addSqlExpression(patternFreqIndDef, language, patternFreqSQL);
        IndicatorDefinitionFileHelper.addCharacterMapping(patternFreqIndDef, language, name, charToReplace, newReplaceChar);
        IndicatorDefinitionFileHelper.save(patternFreqIndDef);
        if (!isNeedReload) {
            isNeedReload = true;
        }
    }
    if (patternLowPatternFreqIndDef != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(patternLowPatternFreqIndDef, language)) {
        IndicatorDefinitionFileHelper.addSqlExpression(patternLowPatternFreqIndDef, language, lowPatternFreqSQL);
        IndicatorDefinitionFileHelper.addCharacterMapping(patternLowPatternFreqIndDef, language, name, charToReplace, newReplaceChar);
        IndicatorDefinitionFileHelper.save(patternLowPatternFreqIndDef);
        if (!isNeedReload) {
            isNeedReload = true;
        }
    }
    if (benFordIndDef != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(benFordIndDef, language)) {
        IndicatorDefinitionFileHelper.addSqlExpression(benFordIndDef, language, benFordSQL);
        IndicatorDefinitionFileHelper.save(benFordIndDef);
        if (!isNeedReload) {
            isNeedReload = true;
        }
    }
    if (isNeedReload) {
        definitionHandler.reloadIndicatorsDefinitions();
    }
    return true;
}
Also used : DefinitionHandler(org.talend.dq.indicators.definitions.DefinitionHandler) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 10 with IndicatorDefinition

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

the class UpdateLowerUpperQuartileForDB2Task method updateSqlForDB2.

private boolean updateSqlForDB2(String indicatorName, String sqlExpression) {
    IndicatorDefinition indiDefinition = IndicatorDefinitionFileHelper.getSystemIndicatorByName(indicatorName);
    if (indiDefinition != null && IndicatorDefinitionFileHelper.removeSqlExpression(indiDefinition, DB2)) {
        List<TdExpression> remainExpLs = new ArrayList<TdExpression>();
        remainExpLs.addAll(indiDefinition.getSqlGenericExpression());
        indiDefinition.getSqlGenericExpression().clear();
        IndicatorDefinitionFileHelper.addSqlExpression(indiDefinition, DB2, sqlExpression);
        indiDefinition.getSqlGenericExpression().addAll(remainExpLs);
        return IndicatorDefinitionFileHelper.save(indiDefinition);
    }
    return true;
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) ArrayList(java.util.ArrayList) 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