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;
}
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);
}
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);
}
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;
}
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);
}
}
}
Aggregations