Search in sources :

Example 26 with UDIndicatorDefinition

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

the class PatternExplorer method getInvalidValuesStatement.

/**
 * get the Valid Values Statement.
 *
 * @return SELECT statement for the invalid Value of select column
 */
public String getInvalidValuesStatement() {
    // when the indicator is the use define match
    IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
    if (indicatorDefinition instanceof UDIndicatorDefinition) {
        EList<TdExpression> list = ((UDIndicatorDefinition) indicatorDefinition).getViewInvalidValuesExpression();
        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 getValuesStatement(columnName, 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 27 with UDIndicatorDefinition

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

the class SimpleStatisticsExplorer method getSubClassQueryMap.

@Override
public Map<String, String> getSubClassQueryMap() {
    Map<String, String> map = new HashMap<String, String>();
    // MOD zshen feature 12919 adapt to pop-menu for Jave engin on result page
    boolean isSqlEngine = ExecutionLanguage.SQL.equals(this.analysis.getParameters().getExecutionLanguage());
    // MOD qiongli 2011-3-4,feature 19192:filter menue 'view rows' for columSet AnalysisType.
    AnalysisType analysisType = this.analysis.getParameters().getAnalysisType();
    // MOD qiongli 2012-8-29 hive don't support 'where in...'
    boolean isHive = dbmsLanguage instanceof HiveDbmsLanguage;
    switch(this.indicatorEnum) {
        case RowCountIndicatorEnum:
            // for columnset/column and jave engine, we didn't show the view rows menu
            if (isSqlEngine) {
                // when user define indicator
                map.put(MENU_VIEW_ROWS, getComment(MENU_VIEW_ROWS) + getRowsStatement());
            }
            break;
        case NullCountIndicatorEnum:
        case BlankCountIndicatorEnum:
        case DefValueCountIndicatorEnum:
        case UserDefinedIndicatorEnum:
            // when user define indicator
            IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
            map.put(MENU_VIEW_ROWS, isSqlEngine ? getComment(MENU_VIEW_ROWS) + (indicatorDefinition instanceof UDIndicatorDefinition ? getQueryForViewRows(indicatorDefinition) : getRowsStatement()) : null);
            break;
        case UniqueIndicatorEnum:
        case DuplicateCountIndicatorEnum:
            if (analysisType != AnalysisType.COLUMN_SET) {
                if (!isHive) {
                    map.put(MENU_VIEW_ROWS, isSqlEngine ? getComment(MENU_VIEW_ROWS) + getRowsStatementWithSubQuery() : null);
                } else if (!isSqlEngine) {
                    map.put(MENU_VIEW_ROWS, null);
                }
            }
            map.put(MENU_VIEW_VALUES, isSqlEngine ? getComment(MENU_VIEW_VALUES) + getValuesStatement(this.columnName) : null);
            break;
        case DistinctCountIndicatorEnum:
            map.put(MENU_VIEW_VALUES, isSqlEngine ? getComment(MENU_VIEW_VALUES) + getDistinctValuesStatement(this.columnName) : null);
            break;
        default:
    }
    return map;
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) HiveDbmsLanguage(org.talend.dq.dbms.HiveDbmsLanguage) HashMap(java.util.HashMap) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 28 with UDIndicatorDefinition

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

the class IndicatorEditor method isSystemIndicator.

/**
 * Judge if the current indicator definition is a system indicator
 *
 * @return true if it is system indicator false if it is UDI
 */
private boolean isSystemIndicator() {
    IEditorInput editorInput = this.getEditorInput();
    IndicatorDefinition definition = null;
    if (editorInput instanceof IndicatorEditorInput) {
        // from DQRespositoryView double click
        definition = ((IndicatorEditorInput) editorInput).getIndicatorDefinition();
    } else if (editorInput instanceof IndicatorDefinitionItemEditorInput) {
        // from OpenItemEditorAction
        definition = (IndicatorDefinition) ((IndicatorDefinitionItemEditorInput) editorInput).getModel();
    } else if (editorInput instanceof FileEditorInput) {
        // when open the indicator inside an analysis
        FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
        IFile file = fileEditorInput.getFile();
        if (FactoriesUtil.isUDIFile(file.getFileExtension())) {
            definition = IndicatorResourceFileHelper.getInstance().findIndDefinition(file);
        }
    }
    if (definition instanceof UDIndicatorDefinition) {
        return false;
    } else {
        return true;
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) FileEditorInput(org.eclipse.ui.part.FileEditorInput) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) IEditorInput(org.eclipse.ui.IEditorInput)

Example 29 with UDIndicatorDefinition

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

the class UDIMasterPage method putTdExpressToTempMap.

@Override
public void putTdExpressToTempMap(final CCombo combo, final TdExpression expression) {
    super.putTdExpressToTempMap(combo, expression);
    UDIndicatorDefinition definition2 = (UDIndicatorDefinition) getCurrentModelElement();
    if (IndicatorCategoryHelper.isUserDefMatching(category)) {
        tempViewValidRowsExpressionMap = setToTempMap(expression, combo, definition2.getViewValidRowsExpression(), tempViewValidRowsExpressionMap);
        tempViewInvalidRowsExpressionMap = setToTempMap(expression, combo, definition2.getViewInvalidRowsExpression(), tempViewInvalidRowsExpressionMap);
        tempViewValidValuesExpressionMap = setToTempMap(expression, combo, definition2.getViewValidValuesExpression(), tempViewValidValuesExpressionMap);
        tempViewInvalidValuesExpressionMap = setToTempMap(expression, combo, definition2.getViewInvalidValuesExpression(), tempViewInvalidValuesExpressionMap);
    } else {
        // get view rows tdExpress list, and set currect tdexpress to temp map
        tempViewRowsExpressionMap = setToTempMap(expression, combo, definition2.getViewRowsExpression(), tempViewRowsExpressionMap);
    }
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Example 30 with UDIndicatorDefinition

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

the class UpdateUDIIndicatorsWithNewModelTask method doExecute.

@Override
protected boolean doExecute() throws Exception {
    boolean result = true;
    File udiIndicatorFolder = getWorkspacePath().append(EResourceConstant.USER_DEFINED_INDICATORS.getPath()).toFile();
    String[] indicatorFileExtentionName = { FactoriesUtil.DEFINITION };
    try {
        result &= FilesUtils.migrateFolder(udiIndicatorFolder, indicatorFileExtentionName, initIndicatorReplaceMap(), log);
        if (isWorksapcePath()) {
            for (IRepositoryViewObject viewObject : ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS)) {
                ProxyRepositoryFactory.getInstance().reload(viewObject.getProperty());
            }
        }
        ResourceService.refreshStructure();
    } catch (Exception e) {
        result = false;
        log.error(e, e);
    }
    List<IndicatorDefinition> indiDefinitions = DefinitionHandler.getInstance().getUserDefinedIndicatorDefinitions();
    for (IndicatorDefinition indiDefinition : indiDefinitions) {
        if (indiDefinition != null) {
            if (indiDefinition instanceof UDIndicatorDefinition) {
                UDIndicatorDefinition udi = (UDIndicatorDefinition) indiDefinition;
                udi = UDIUtils.createDefaultDrillDownList(udi);
                result &= ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(udi).isOk();
            }
        }
    }
    DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
    return result;
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) File(java.io.File) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Aggregations

UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)31 TdExpression (org.talend.cwm.relational.TdExpression)18 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)13 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)7 TdColumn (org.talend.cwm.relational.TdColumn)7 Analysis (org.talend.dataquality.analysis.Analysis)7 TdTable (org.talend.cwm.relational.TdTable)6 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)6 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)6 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)6 Expression (orgomg.cwm.objectmodel.core.Expression)6 Domain (org.talend.dataquality.domain.Domain)5 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)5 File (java.io.File)4 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)4 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)4 Pattern (org.talend.dataquality.domain.pattern.Pattern)4 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)4 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4