Search in sources :

Example 6 with DefinitionHandler

use of org.talend.dq.indicators.definitions.DefinitionHandler in project tdq-studio-se by Talend.

the class AddTeradataExpressionInPatternFrenquencyIndicatorTask method doExecute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.migration.AMigrationTask#doExecute()
     */
@Override
protected boolean doExecute() throws Exception {
    DefinitionHandler definitionHandler = DefinitionHandler.getInstance();
    boolean isFrequencyAdded = true;
    boolean isLowFrequencyUpdated = true;
    // Add sql of Teradata to pattern frenquency table indicator
    IndicatorDefinition teraDefinition = definitionHandler.getDefinitionById(PATTERN_FREQUENCY_UUID);
    if (teraDefinition != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(teraDefinition, Teradata)) {
        IndicatorDefinitionFileHelper.addSqlExpression(teraDefinition, Teradata, PATTERN_FREQUENCY_SQL);
        IndicatorDefinitionFileHelper.addCharacterMapping(teraDefinition, Teradata, CHAR_NAME, CHAR_TOREPLACE, CHAR_REPLACE);
        isFrequencyAdded = IndicatorDefinitionFileHelper.save(teraDefinition);
    }
    // Update sql of Teradata to pattern low frenquency table indicator
    IndicatorDefinition lowDefinition = definitionHandler.getDefinitionById(PATTERN_LOW_FREQUENCY_UUID);
    if (teraDefinition != null && !IndicatorDefinitionFileHelper.isExistSqlExprWithLanguage(lowDefinition, Teradata)) {
        IndicatorDefinitionFileHelper.addSqlExpression(lowDefinition, Teradata, PATTERN_LOW_FREQUENCY_SQL);
        IndicatorDefinitionFileHelper.addCharacterMapping(lowDefinition, Teradata, CHAR_NAME, CHAR_TOREPLACE, CHAR_REPLACE);
        isLowFrequencyUpdated = IndicatorDefinitionFileHelper.save(lowDefinition);
    }
    DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
    if (!isFrequencyAdded || !isLowFrequencyUpdated) {
        return false;
    }
    return true;
}
Also used : DefinitionHandler(org.talend.dq.indicators.definitions.DefinitionHandler) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 7 with DefinitionHandler

use of org.talend.dq.indicators.definitions.DefinitionHandler in project tdq-studio-se by Talend.

the class UpdateTextStatisticsIndicatorsTask method doExecute.

@Override
protected boolean doExecute() throws Exception {
    boolean result = true;
    DefinitionHandler definitionHandler = DefinitionHandler.getInstance();
    // AVERAGE_LENGTH_WITH_BLANK_AND_NULL
    IndicatorDefinition definition = definitionHandler.getDefinitionById(AVERAGE_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_AVGBN_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_AVGBN_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_AVGBN_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_AVGBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_AVGBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_AVGBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_AVGBN_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // AVERAGE_LENGTH_WITH_BLANK
    definition = definitionHandler.getDefinitionById(AVERAGE_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_AVGB_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_AVGB_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_AVGB_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_AVGB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_AVGB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_AVGB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_AVGB_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // AVERAGE_LENGTH_WITH_NULL
    definition = definitionHandler.getDefinitionById(AVERAGE_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_AVGN_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_AVGN_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_AVGN_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_AVGN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_AVGN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_AVGN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_AVGN_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // AVERAGE_LENGTH
    definition = definitionHandler.getDefinitionById(AVERAGE_LENGTH_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_AVG_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_AVG_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_AVG_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_AVG_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_AVG_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_AVG_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_AVG_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL_LENGTH_WITH_BLANK_AND_NULL
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_MAXBN_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_MAXBN_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_MAXBN_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_MAXBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_MAXBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_MAXBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_MAXBN_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL_LENGTH_WITH_BLANK
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_MAXB_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_MAXB_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_MAXB_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_MAXB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_MAXB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_MAXB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_MAXB_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL_LENGTH_WITH_NULL
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_MAXN_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_MAXN_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_MAXN_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_MAXN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_MAXN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_MAXN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_MAXN_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL_LENGTH
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_MAX_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_MAX_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_MAX_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_MAX_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_MAX_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_MAX_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_MAX_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL_LENGTH_WITH_BLANK_AND_NULL
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_MINBN_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_MINBN_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_MINBN_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_MINBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_MINBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_MINBN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_MINBN_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL_LENGTH_WITH_BLANK
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_MINB_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_MINB_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_MINB_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_MINB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_MINB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_MINB_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_MINB_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL_LENGTH_WITH_NULL
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_MINN_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_MINN_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_MINN_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_MINN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_MINN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_MINN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_MINN_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL_LENGTH
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL, BODY_MIN_SQL);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_ORACLE, BODY_MIN_ORACLE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQL_SERVER, BODY_MIN_SQL_SERVER);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_DB2, BODY_MIN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INGRES, BODY_MIN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SQLITE, BODY_MIN_DISH);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_HIVE, BODY_MIN_DISH);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
    return result;
}
Also used : DefinitionHandler(org.talend.dq.indicators.definitions.DefinitionHandler) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 8 with DefinitionHandler

use of org.talend.dq.indicators.definitions.DefinitionHandler in project tdq-studio-se by Talend.

the class UpdateTextStatisticsIndicatorsForOracle method doExecute.

@Override
protected boolean doExecute() throws Exception {
    DefinitionHandler definitionHandler = DefinitionHandler.getInstance();
    // AVERAGE LENGTH
    IndicatorDefinition definition = definitionHandler.getDefinitionById(AVG_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, AVG_LENGTH_WITH_BLANK_AND_NULL_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definition = definitionHandler.getDefinitionById(AVG_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, AVG_LENGTH_WITH_BLANK_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definition = definitionHandler.getDefinitionById(AVG_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, AVG_LENGTH_WITH_NULL_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL LENGTH
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, MAXIMAL_LENGTH_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, MAXIMAL_LENGTH_WITH_BLANK_AND_NULL_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, MAXIMAL_LENGTH_WITH_BLANK_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, MAXIMAL_LENGTH_WITH_NULL_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL LENGTH
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, MINIMAL_LENGTH_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, MINIMAL_LENGTH_WITH_BLANK_AND_NULL_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, MINIMAL_LENGTH_WITH_BLANK_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        IndicatorDefinitionFileHelper.updateSqlExpression(definition, LANGUAGE, MINIMAL_LENGTH_WITH_NULL_BODY);
        IndicatorDefinitionFileHelper.save(definition);
    }
    definitionHandler.reloadIndicatorsDefinitions();
    return true;
}
Also used : DefinitionHandler(org.talend.dq.indicators.definitions.DefinitionHandler) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 9 with DefinitionHandler

use of org.talend.dq.indicators.definitions.DefinitionHandler in project tdq-studio-se by Talend.

the class UpdateTextStatisticsIndicatorsForSomeDatabasesTask method doExecute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.migration.AMigrationTask#doExecute()
     */
@Override
protected boolean doExecute() throws Exception {
    boolean result = true;
    DefinitionHandler definitionHandler = DefinitionHandler.getInstance();
    // AVERAGE_LENGTH_WITH_BLANK_AND_NULL
    IndicatorDefinition definition = definitionHandler.getDefinitionById(AVERAGE_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_AVGBN_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_AVGBN_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_AVGBN_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_AVGBN_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // AVERAGE_LENGTH_WITH_BLANK
    definition = definitionHandler.getDefinitionById(AVERAGE_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_AVGB_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_AVGB_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_AVGB_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_AVGB_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // AVERAGE_LENGTH_WITH_NULL
    definition = definitionHandler.getDefinitionById(AVERAGE_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_AVGN_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_AVGN_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_AVGN_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_AVGN_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // AVERAGE_LENGTH
    definition = definitionHandler.getDefinitionById(AVERAGE_LENGTH_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_AVG_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_AVG_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_AVG_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_AVG_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL_LENGTH_WITH_BLANK_AND_NULL
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_MAXBN_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_MAXBN_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_MAXBN_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_MAXBN_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL_LENGTH_WITH_BLANK
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_MAXB_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_MAXB_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_MAXB_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_MAXB_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL_LENGTH_WITH_NULL
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_MAXN_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_MAXN_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_MAXN_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_MAXN_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MAXIMAL_LENGTH
    definition = definitionHandler.getDefinitionById(MAXIMAL_LENGTH_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_MAX_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_MAX_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_MAX_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_MAX_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL_LENGTH_WITH_BLANK_AND_NULL
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_BLANK_AND_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_MINBN_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_MINBN_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_MINBN_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_MINBN_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL_LENGTH_WITH_BLANK
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_BLANK_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_MINB_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_MINB_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_MINB_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_MINB_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL_LENGTH_WITH_NULL
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_WITH_NULL_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_MINN_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_MINN_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_MINN_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_MINN_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    // MINIMAL_LENGTH
    definition = definitionHandler.getDefinitionById(MINIMAL_LENGTH_UUID);
    if (definition != null) {
        clearSqlGenericExpression(definition, clearLanguages);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_TERADATA, BODY_MIN_TERADATA);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_SYBASE, BODY_MIN_SYBASE);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_INFORMIX, BODY_MIN_INFORMIX);
        IndicatorDefinitionFileHelper.addSqlExpression(definition, LANG_POSTGRESQL, BODY_MIN_POSTGRESQL);
        result = result && IndicatorDefinitionFileHelper.save(definition);
    }
    DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
    return result;
}
Also used : DefinitionHandler(org.talend.dq.indicators.definitions.DefinitionHandler) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Aggregations

DefinitionHandler (org.talend.dq.indicators.definitions.DefinitionHandler)9 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)8 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)1 CoreException (org.eclipse.core.runtime.CoreException)1 Plugin (org.eclipse.core.runtime.Plugin)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Folder (org.talend.core.model.repository.Folder)1 CoreRuntimePlugin (org.talend.core.runtime.CoreRuntimePlugin)1 TdExpression (org.talend.cwm.relational.TdExpression)1 CorePlugin (org.talend.dataprofiler.core.CorePlugin)1 RepositoryNodeBuilder (org.talend.dataprofiler.core.ui.views.provider.RepositoryNodeBuilder)1