use of org.talend.cwm.relational.TdExpression 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.cwm.relational.TdExpression 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.cwm.relational.TdExpression 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.cwm.relational.TdExpression 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.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class UDIUtils method createDefaultDrillDownList.
/**
* create Default Drill Down List for UDI.
*
* @param indiDefinition
* @return
*/
public static UDIndicatorDefinition createDefaultDrillDownList(UDIndicatorDefinition indiDefinition) {
IndicatorCategory category = IndicatorCategoryHelper.getCategory(indiDefinition);
if (IndicatorCategoryHelper.isUserDefMatching(category)) {
// set default value from templates
EList<TdExpression> viewValidRowsList = indiDefinition.getViewValidRowsExpression();
EList<TdExpression> viewInvalidRowsList = indiDefinition.getViewInvalidRowsExpression();
EList<TdExpression> viewValidValuesList = indiDefinition.getViewValidValuesExpression();
EList<TdExpression> viewInvalidValuesList = indiDefinition.getViewInvalidValuesExpression();
EList<TdExpression> sqlGenericExpression = indiDefinition.getSqlGenericExpression();
if (sqlGenericExpression != null) {
for (TdExpression tdExp : sqlGenericExpression) {
String language = tdExp.getLanguage();
String version = tdExp.getVersion();
// if not exist, add one.(when do migration more than one time, will add one)
if (!UDIUtils.checkExistInList(viewValidRowsList, language, version)) {
// for match is View Valid Rows template
String body = UDIHelper.getQueryFromTemplates(2, language, category);
viewValidRowsList.add(UDIUtils.createNewTdExpression(language, version, replaceQueryForMatchUDI(body)));
}
if (!UDIUtils.checkExistInList(viewInvalidRowsList, language, version)) {
// for match is View Invalid Rows Template
String body = UDIHelper.getQueryFromTemplates(3, language, category);
viewInvalidRowsList.add(UDIUtils.createNewTdExpression(language, version, replaceQueryForMatchUDI(body)));
}
if (!UDIUtils.checkExistInList(viewValidValuesList, language, version)) {
// for match is View Valid Values Template
String body = UDIHelper.getQueryFromTemplates(4, language, category);
viewValidValuesList.add(UDIUtils.createNewTdExpression(language, version, replaceQueryForMatchUDI(body)));
}
if (!UDIUtils.checkExistInList(viewInvalidValuesList, language, version)) {
// for match is View Invalid Values Template
String body = UDIHelper.getQueryFromTemplates(5, language, category);
viewInvalidValuesList.add(UDIUtils.createNewTdExpression(language, version, replaceQueryForMatchUDI(body)));
}
}
}
} else {
// for others is view rows template
EList<TdExpression> viewRowsList = indiDefinition.getViewRowsExpression();
EList<TdExpression> sqlGenericExpression = indiDefinition.getSqlGenericExpression();
if (sqlGenericExpression != null) {
for (TdExpression tdExp : sqlGenericExpression) {
String language = tdExp.getLanguage();
String version = tdExp.getVersion();
// if not exist, add one.(when do migration more than one time, will add one)
if (!UDIUtils.checkExistInList(viewRowsList, language, version)) {
String body = UDIHelper.getQueryFromTemplates(2, language, category);
GenericSQLHandler genericSQLHandler = new GenericSQLHandler(body);
if (IndicatorCategoryHelper.isUserDefRealValue(category)) {
// replace <COLUMN_EXPRESSION_TEXT_FIELD>
genericSQLHandler.replaceUDIColumn(PluginConstant.EMPTY_STRING);
} else if (IndicatorCategoryHelper.isUserDefFrequency(category)) {
// replace <FIRST_COLUMN_EXPRESSION_TEXT_FIELD>
// replace <SECOND_COLUMN_EXPRESSION_TEXT_FIELD>
genericSQLHandler.replaceUDIFirstColumn(PluginConstant.EMPTY_STRING).replaceUDISecondColumn(PluginConstant.EMPTY_STRING);
}
viewRowsList.add(UDIUtils.createNewTdExpression(language, version, genericSQLHandler.replaceUDIQueryToMatch().getSqlString()));
}
}
}
}
return indiDefinition;
}
Aggregations