use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class UpdateAllIndicators4DefaultTask method doExecute.
@Override
protected boolean doExecute() throws Exception {
boolean result = true;
List<IndicatorDefinition> indiDefinitions = DefinitionHandler.getInstance().getIndicatorsDefinitions();
for (IndicatorDefinition indiDefinition : indiDefinitions) {
if (indiDefinition != null) {
EList<TdExpression> sqlGenericExpression = indiDefinition.getSqlGenericExpression();
for (TdExpression exp : sqlGenericExpression) {
// both "Default" and "Default "
if (Language.equals(exp.getLanguage().trim())) {
exp.setLanguage(newLanguage);
break;
}
}
result = result && IndicatorDefinitionFileHelper.save(indiDefinition);
}
}
DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
return result;
}
use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class UpdateTextStatisticsIndicatorsTask method clearSqlGenericExpression.
/**
* clear the specified language from the IndicatorDefinition.
*
* @param definition
* @param languages the languages which need to be clear
*/
private void clearSqlGenericExpression(IndicatorDefinition definition, Set<String> languages) {
List<TdExpression> expressions = new ArrayList<TdExpression>();
for (TdExpression expression : definition.getSqlGenericExpression()) {
if (expression != null && !languages.contains(expression.getLanguage())) {
expressions.add(expression);
}
}
definition.getSqlGenericExpression().clear();
definition.getSqlGenericExpression().addAll(expressions);
}
use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class UpdateTextStatisticsIndicatorsForSomeDatabasesTask method clearSqlGenericExpression.
/**
* clear the specified language from the IndicatorDefinition.
*
* @param definition
* @param languages the languages which need to be clear
*/
private void clearSqlGenericExpression(IndicatorDefinition definition, Set<String> languages) {
List<TdExpression> expressions = new ArrayList<TdExpression>();
for (TdExpression expression : definition.getSqlGenericExpression()) {
if (expression != null && !languages.contains(expression.getLanguage())) {
expressions.add(expression);
}
}
definition.getSqlGenericExpression().clear();
definition.getSqlGenericExpression().addAll(expressions);
}
use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class MultiColumnAnalysisExecutorTest method setUp.
@Before
public void setUp() throws Exception {
analysis = AnalysisFactory.eINSTANCE.createAnalysis();
AnalysisContext context = AnalysisFactory.eINSTANCE.createAnalysisContext();
analysis.setContext(context);
// mock(Catalog.class);
Package catalog = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
// $NON-NLS-1$
catalog.setName("tbi");
TdTable tdTable = RelationalFactory.eINSTANCE.createTdTable();
// $NON-NLS-1$
tdTable.setName("customer");
tdTable.setNamespace(catalog);
TdColumn tdColumn = RelationalFactory.eINSTANCE.createTdColumn();
tdColumn.setOwner(tdTable);
// $NON-NLS-1$
tdColumn.setName("date_accnt_opened");
tdColumn.setContentType(DataminingType.INTERVAL.getName());
TdColumn tdColumn2 = RelationalFactory.eINSTANCE.createTdColumn();
tdColumn2.setOwner(tdTable);
// $NON-NLS-1$
tdColumn2.setName("product_id");
tdColumn2.setContentType(DataminingType.INTERVAL.getName());
AnalysisParameters analysisPara = AnalysisFactory.eINSTANCE.createAnalysisParameters();
analysisPara.setStoreData(false);
// set analysis type is columnset
analysisPara.setAnalysisType(AnalysisType.COLUMN_SET);
analysis.setParameters(analysisPara);
context.getAnalysedElements().add(tdColumn);
context.getAnalysedElements().add(tdColumn2);
AnalysisResult analysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
ExecutionInformations info = AnalysisFactory.eINSTANCE.createExecutionInformations();
analysisResult.setResultMetadata(info);
simpleStatIndicator = ColumnsetFactory.eINSTANCE.createSimpleStatIndicator();
TdExpression expression = RelationalFactory.eINSTANCE.createTdExpression();
expression.setBody(// $NON-NLS-1$
"SELECT <%=__COLUMN_NAMES__%> FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%> GROUP BY <%=__GROUP_BY_ALIAS__%>");
// $NON-NLS-1$
expression.setLanguage("SQL");
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
indicatorDefinition.getSqlGenericExpression().add(expression);
simpleStatIndicator.setIndicatorDefinition(indicatorDefinition);
// $NON-NLS-1$
simpleStatIndicator.getDateFunctions().add("");
// $NON-NLS-1$
simpleStatIndicator.getNumericFunctions().add("");
simpleStatIndicator.setDataminingType(DataminingType.NOMINAL);
simpleStatIndicator.getAnalyzedColumns().add(tdColumn);
simpleStatIndicator.getAnalyzedColumns().add(tdColumn2);
analysisResult.getIndicators().add(simpleStatIndicator);
analysis.setResults(analysisResult);
}
use of org.talend.cwm.relational.TdExpression in project tdq-studio-se by Talend.
the class TableAnalysisSqlExecutorTest method testCreateSqlStatementCase1.
/**
* Test method for
* {@link org.talend.dq.analysis.TableAnalysisSqlExecutor#createSqlStatement(org.talend.dataquality.analysis.Analysis)}
* . case 1:the where rule have not join conditions
*/
@Test
public void testCreateSqlStatementCase1() {
TdExpression expression = RelationalFactory.eINSTANCE.createTdExpression();
// $NON-NLS-1$
expression.setBody("SELECT COUNT(*) FROM <%=__TABLE_NAME__%> <%=__JOIN_CLAUSE__%> <%=__WHERE_CLAUSE__%>");
// $NON-NLS-1$
expression.setLanguage("SQL");
testWhereRuleIndicatorDefinition.getSqlGenericExpression().add(expression);
TableAnalysisSqlExecutor tableAnalysisSqlExecutor = new TableAnalysisSqlExecutor();
String actualSqlStatement = tableAnalysisSqlExecutor.createSqlStatement(testAnalysis);
Assert.assertEquals(StringUtils.EMPTY, actualSqlStatement);
EList<Expression> instantiatedExpressions = testWhereRuleIndicator.getInstantiatedExpressions();
Assert.assertNotNull(instantiatedExpressions);
Assert.assertEquals(1, instantiatedExpressions.size());
}
Aggregations