Search in sources :

Example 6 with UDIndicatorDefinition

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

the class UDIMasterPage method initExpresstionEditDialog.

@Override
protected ExpressionEditDialog initExpresstionEditDialog(final CCombo combo, final String version, String patternText) {
    TdExpression tdExpression = getTdExpression(combo, version);
    String language = tdExpression.getLanguage();
    ExpressionEditDialog editDialog = new ExpressionEditDialog(null, patternText, true, cloneExpression(tdExpression));
    editDialog.setVersion(version);
    editDialog.setLanguage(language);
    editDialog.setCategory(category);
    if (IndicatorCategoryHelper.isUserDefMatching(category)) {
        EList<TdExpression> viewValidRowsExpression = ((UDIndicatorDefinition) getCurrentModelElement()).getViewValidRowsExpression();
        TdExpression viewValidRows = getCurrentLanguageExp(viewValidRowsExpression, language, version);
        if (isDirty()) {
            viewValidRows = tempViewValidRowsExpressionMap.get(combo);
        }
        editDialog.setTempViewValidRowsExp(cloneExpression(viewValidRows));
        EList<TdExpression> viewInvalidRowsExpression = ((UDIndicatorDefinition) getCurrentModelElement()).getViewInvalidRowsExpression();
        TdExpression viewInvalidRows = getCurrentLanguageExp(viewInvalidRowsExpression, language, version);
        if (isDirty()) {
            viewInvalidRows = tempViewInvalidRowsExpressionMap.get(combo);
        }
        editDialog.setTempViewInvalidRowsExp(cloneExpression(viewInvalidRows));
        EList<TdExpression> viewValidValuesExpression = ((UDIndicatorDefinition) getCurrentModelElement()).getViewValidValuesExpression();
        TdExpression viewValidValues = getCurrentLanguageExp(viewValidValuesExpression, language, version);
        if (isDirty()) {
            viewValidValues = tempViewValidValuesExpressionMap.get(combo);
        }
        editDialog.setTempViewValidValuesExp(cloneExpression(viewValidValues));
        EList<TdExpression> viewInvalidValuesExpression = ((UDIndicatorDefinition) getCurrentModelElement()).getViewInvalidValuesExpression();
        TdExpression viewInvalidValues = getCurrentLanguageExp(viewInvalidValuesExpression, language, version);
        if (isDirty()) {
            viewInvalidValues = tempViewInvalidValuesExpressionMap.get(combo);
        }
        editDialog.setTempViewInvalidValuesExp(cloneExpression(viewInvalidValues));
    } else {
        EList<TdExpression> viewRowsExpression = ((UDIndicatorDefinition) getCurrentModelElement()).getViewRowsExpression();
        TdExpression viewRows = getCurrentLanguageExp(viewRowsExpression, language, version);
        if (isDirty()) {
            viewRows = tempViewRowsExpressionMap.get(combo);
        }
        editDialog.setTempViewRowsExp(cloneExpression(viewRows));
    }
    return editDialog;
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) ExpressionEditDialog(org.talend.dataprofiler.core.ui.dialog.ExpressionEditDialog)

Example 7 with UDIndicatorDefinition

use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition 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 8 with UDIndicatorDefinition

use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition 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 9 with UDIndicatorDefinition

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

the class SimpleStatisticsExplorer method getQueryForViewRows.

/**
 * get Query For View Rows.
 *
 * @param indicatorDefinition
 * @return
 */
private String getQueryForViewRows(IndicatorDefinition indicatorDefinition) {
    String sql = PluginConstant.EMPTY_STRING;
    IndicatorCategory category = IndicatorCategoryHelper.getCategory(indicatorDefinition);
    EList<TdExpression> list = ((UDIndicatorDefinition) indicatorDefinition).getViewRowsExpression();
    TdExpression tdExp = DbmsLanguage.getSqlExpression(indicatorDefinition, dbmsLanguage.getDbmsName(), list, dbmsLanguage.getDbVersion());
    sql = tdExp.getBody();
    String dataFilterClause = getDataFilterClause();
    if (!dataFilterClause.equals(PluginConstant.EMPTY_STRING)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        sql = sql.replace(GenericSQLHandler.WHERE_CLAUSE, dbmsLanguage.where() + "(" + dataFilterClause + ")");
        // $NON-NLS-1$ //$NON-NLS-2$
        sql = sql.replace(GenericSQLHandler.AND_WHERE_CLAUSE, dbmsLanguage.and() + "(" + dataFilterClause + ")");
    } else {
        sql = sql.replace(GenericSQLHandler.WHERE_CLAUSE, PluginConstant.EMPTY_STRING);
        sql = sql.replace(GenericSQLHandler.AND_WHERE_CLAUSE, PluginConstant.EMPTY_STRING);
    }
    String tableName = getFullyQualifiedTableName(this.indicator.getAnalyzedElement());
    sql = sql.replace(GenericSQLHandler.TABLE_NAME, tableName);
    // TDQ-12398 msjian: add quote for the column
    sql = sql.replace(GenericSQLHandler.COLUMN_NAMES, dbmsLanguage.quote(this.indicator.getAnalyzedElement().getName()));
    if (sql.indexOf(GenericSQLHandler.UDI_INDICATOR_VALUE) != -1) {
        if (IndicatorCategoryHelper.isUserDefRealValue(category)) {
            // replace <%=__INDICATOR_VALUE__%>
            Double realValue = this.indicator.getRealValue();
            // $NON-NLS-1$
            sql = sql.replace(GenericSQLHandler.UDI_INDICATOR_VALUE, realValue == null ? "0" : realValue.toString());
        } else {
            sql = sql.replace(GenericSQLHandler.UDI_INDICATOR_VALUE, (String.valueOf(this.indicator.getIntegerValue().intValue())));
        }
    }
    return sql;
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory)

Example 10 with UDIndicatorDefinition

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

the class ItemRecord method computeDependencies.

/**
 * DOC bZhou Comment method "computeDependencies".
 */
private void computeDependencies(ModelElement mElement) {
    if (isJRXml()) {
        Collection<TdReport> allReports = (Collection<TdReport>) RepResourceFileHelper.getInstance().getAllElement();
        for (TdReport report : allReports) {
            // MOD yyi 2012-02-20 TDQ-4545 TDQ-4701: Change to relative path comparing.
            IPath pathRepFile = RepResourceFileHelper.findCorrespondingFile(report).getLocation();
            IPath pathJrxmlFile = new Path(file.getPath());
            String path = pathJrxmlFile.makeRelativeTo(pathRepFile).toString();
            for (AnalysisMap anaMap : report.getAnalysisMap()) {
                if (StringUtils.equals(path, anaMap.getJrxmlSource())) {
                    // TODO the File is jrxml, but the ModelElement is report ???
                    this.dependencySet.add(file);
                }
            }
        }
    } else if (mElement != null) {
        if (mElement instanceof Connection) {
            includeContextDependency((Connection) mElement);
            return;
        }
        List<File> dependencyFile = getClintDependencyForExport(mElement);
        for (File df : dependencyFile) {
            ModelElement modelElement = getElement(df);
            if (modelElement != null) {
                File depFile = EObjectHelper.modelElement2File(modelElement);
                if (depFile != null) {
                    this.dependencySet.add(depFile);
                }
                // MOD sizhaoliu 2013-04-13 TDQ-7082
                if (modelElement instanceof IndicatorDefinition) {
                    if (modelElement instanceof UDIndicatorDefinition) {
                        includeJUDIDependencies((IndicatorDefinition) modelElement);
                    } else {
                        for (IndicatorDefinition definition : ((IndicatorDefinition) modelElement).getAggregatedDefinitions()) {
                            includeAggregatedDependencies(definition);
                        }
                    }
                }
            }
        }
        // MOD yyi 2012-02-20 TDQ-4545 TDQ-4701: Map user define jrxm templates with report.
        if (mElement instanceof TdReport) {
            TdReport rep = (TdReport) mElement;
            for (AnalysisMap anaMap : rep.getAnalysisMap()) {
                ReportType reportType = ReportHelper.ReportType.getReportType(anaMap.getAnalysis(), anaMap.getReportType());
                boolean isUserMade = ReportHelper.ReportType.USER_MADE.equals(reportType);
                if (isUserMade) {
                    traverseFolderAndAddJrxmlDependencies(getJrxmlFolderFromReport(rep, ResourceManager.getJRXMLFolder()));
                }
            }
        } else if (mElement instanceof IndicatorDefinition) {
            // MOD sizhaoliu 2013-04-13 TDQ-7082
            IndicatorDefinition definition = (IndicatorDefinition) mElement;
            if (definition instanceof UDIndicatorDefinition) {
                includeJUDIDependencies(definition);
            } else {
                for (IndicatorDefinition defInd : definition.getAggregatedDefinitions()) {
                    includeAggregatedDependencies(defInd);
                }
            }
            // folder
            if (mElement instanceof MatchRuleDefinition) {
                includeCustomMatcherJarDependencies((MatchRuleDefinition) mElement);
            }
        } else if (mElement instanceof Analysis && AnalysisType.MATCH_ANALYSIS == AnalysisHelper.getAnalysisType((Analysis) mElement)) {
            includeCustomMatcherJarDependencies((Analysis) mElement);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdReport(org.talend.dataquality.reports.TdReport) Connection(org.talend.core.model.metadata.builder.connection.Connection) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) Collection(java.util.Collection) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) File(java.io.File) ReportType(org.talend.dataquality.helpers.ReportHelper.ReportType)

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