use of org.talend.dq.dbms.GenericSQLHandler in project tdq-studio-se by Talend.
the class ExpressionEditDialog method getAutoGeneratedQuery.
/**
* get the auto generated query.
*/
public String getAutoGeneratedQuery() {
autoGenQuery = UDIHelper.getQueryFromTemplates(selectTabNumber, language, category);
// replace some variables in the auto generate sql
if (isUDIndicatorDefinition) {
GenericSQLHandler genericSQLHandler = new GenericSQLHandler(autoGenQuery);
if (IndicatorCategoryHelper.isUserDefCount(category)) {
// replace <WHERE_TEXT_FIELD>
genericSQLHandler.replaceUDIWhere(tab0_count_where_var.getText().trim());
} else if (IndicatorCategoryHelper.isUserDefRealValue(category)) {
// replace <COLUMN_EXPRESSION_TEXT_FIELD>
genericSQLHandler.replaceUDIColumn(tab0_realvalue_column_var.getText().trim());
// replace <WHERE_TEXT_FIELD>
genericSQLHandler.replaceUDIWhere(tab0_realvalue_where_var.getText().trim());
} else if (IndicatorCategoryHelper.isUserDefFrequency(category)) {
// replace <FIRST_COLUMN_EXPRESSION_TEXT_FIELD>
genericSQLHandler.replaceUDIFirstColumn(tab0_fre_first_var.getText().trim());
// replace <SECOND_COLUMN_EXPRESSION_TEXT_FIELD>
genericSQLHandler.replaceUDISecondColumn(tab0_fre_second_var.getText().trim());
// replace <WHERE_TEXT_FIELD>
genericSQLHandler.replaceUDIWhere(tab0_fre_where_var.getText().trim());
// replace <GROUP_BY_TEXT_FIELD>
genericSQLHandler.replaceUDIGroupBy(tab0_fre_groupby_var.getText().trim());
// replace <ORDER_BY_TEXT_FIELD>
genericSQLHandler.replaceUDIOrderBy(tab0_fre_orderby_var.getText().trim());
} else if (IndicatorCategoryHelper.isUserDefMatching(category)) {
// replace <MATCHING_EXPRESSION_TEXT_FIELD>
genericSQLHandler.replaceUDIMatching(tab0_match_match_var.getText().trim());
// replace <WHERE_TEXT_FIELD>
genericSQLHandler.replaceUDIWhere(tab0_match_where_var.getText().trim());
}
autoGenQuery = genericSQLHandler.replaceUDIQueryToMatch().getSqlString();
}
return autoGenQuery;
}
use of org.talend.dq.dbms.GenericSQLHandler 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;
}
use of org.talend.dq.dbms.GenericSQLHandler in project tdq-studio-se by Talend.
the class ColumnDependencyExplorer method getStatement.
/**
* DOC xqliu Comment method "getStatement".
*
* @param genericSQL
* @return
*/
private String getStatement(String genericSQL) {
ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
TdColumn columnA = cdIndicator.getColumnA();
TdColumn columnB = cdIndicator.getColumnB();
GenericSQLHandler sqlHandler = new GenericSQLHandler(genericSQL);
sqlHandler.replaceColumnA(dbmsLanguage.quote(columnA.getName())).replaceColumnB(dbmsLanguage.quote(columnB.getName())).replaceTable(dbmsLanguage.quote(getFullyQualifiedTableName(columnA)));
String instantiatedSQL = sqlHandler.getSqlString();
List<String> whereClauses = new ArrayList<String>();
String dataFilter = ContextHelper.getDataFilterWithoutContext(this.analysis);
if (!StringUtils.isEmpty(dataFilter)) {
whereClauses.add(dataFilter);
}
instantiatedSQL = dbmsLanguage.addWhereToSqlStringStatement(instantiatedSQL, whereClauses);
return instantiatedSQL;
}
use of org.talend.dq.dbms.GenericSQLHandler in project tdq-studio-se by Talend.
the class UDIUtils method replaceQueryForMatchUDI.
/**
* replace Query For Match UDI.
*
* @param genericSQLHandler
* @return
*/
private static String replaceQueryForMatchUDI(String body) {
GenericSQLHandler genericSQLHandler = new GenericSQLHandler(body);
// replace <MATCHING_EXPRESSION_TEXT_FIELD>
genericSQLHandler.replaceUDIMatching(PluginConstant.EMPTY_STRING);
// replace <WHERE_TEXT_FIELD>
genericSQLHandler.replaceUDIWhere(PluginConstant.EMPTY_STRING);
return genericSQLHandler.replaceUDIQueryToMatch().getSqlString();
}
Aggregations