use of org.talend.dq.dbms.DbmsLanguage in project tdq-studio-se by Talend.
the class AbstractSchemaEvaluatorTest method testgetCatalogNameWithQuote_oracle.
@Test
public void testgetCatalogNameWithQuote_oracle() {
SchemaEvaluator schemaEvaluate = new SchemaEvaluator();
analysisElements.clear();
analysisElements.add(schema);
// $NON-NLS-1$
stub(method(Evaluator.class, "getAnalyzedElements")).toReturn(analysisElements);
when(schemarIndicator.getAnalyzedElement()).thenReturn(schema);
DbmsLanguage mysqlDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.ORACLEWITHSIDDEFAULTURL.getLanguage(), dbVersion);
// $NON-NLS-1$
stub(method(DbmsLanguageFactory.class, "createDbmsLanguage", DataManager.class, ExecutionLanguage.class)).toReturn(mysqlDbmsLanguage);
String catalogNameWithQuote = schemaEvaluate.getCatalogNameWithQuote(schemarIndicator);
assertNull(catalogNameWithQuote);
}
use of org.talend.dq.dbms.DbmsLanguage in project tdq-studio-se by Talend.
the class ModelElementIndicatorRuleTest method testPatternRule_3.
/**
* test for Hive connection and some indicators should be disabled.
*/
@Test
public void testPatternRule_3() {
when(tdsql.getJavaDataType()).thenReturn(Types.VARCHAR);
DatabaseConnection connection = mock(DatabaseConnection.class);
PowerMockito.mockStatic(ConnectionHelper.class);
when(ConnectionHelper.getTdDataProvider(me)).thenReturn(connection);
when(ConnectionHelper.isHive(connection)).thenReturn(true);
DbmsLanguage dbmsLanguage = mock(DbmsLanguage.class);
// $NON-NLS-1$
when(dbmsLanguage.getDbmsName()).thenReturn("MySQL");
when(dbmsLanguage.getDbVersion()).thenReturn(null);
PowerMockito.mockStatic(DbmsLanguageFactory.class);
when(DbmsLanguageFactory.createDbmsLanguage(connection)).thenReturn(dbmsLanguage);
Assert.assertFalse(ModelElementIndicatorRule.patternRule(IndicatorEnum.SoundexIndicatorEnum, me, ExecutionLanguage.SQL));
Assert.assertFalse(ModelElementIndicatorRule.patternRule(IndicatorEnum.SoundexLowIndicatorEnum, me, ExecutionLanguage.SQL));
Assert.assertTrue(ModelElementIndicatorRule.patternRule(IndicatorEnum.PatternFreqIndicatorEnum, me, ExecutionLanguage.SQL));
Assert.assertTrue(ModelElementIndicatorRule.patternRule(IndicatorEnum.PatternLowFreqIndicatorEnum, me, ExecutionLanguage.SQL));
when(tdsql.getJavaDataType()).thenReturn(Types.INTEGER);
Assert.assertFalse(ModelElementIndicatorRule.patternRule(IndicatorEnum.MedianIndicatorEnum, me, ExecutionLanguage.SQL));
Assert.assertFalse(ModelElementIndicatorRule.patternRule(IndicatorEnum.UpperQuartileIndicatorEnum, me, ExecutionLanguage.SQL));
Assert.assertFalse(ModelElementIndicatorRule.patternRule(IndicatorEnum.LowerQuartileIndicatorEnum, me, ExecutionLanguage.SQL));
}
use of org.talend.dq.dbms.DbmsLanguage in project tdq-studio-se by Talend.
the class FunctionalDependencyExecutor method createSqlStatement.
@Override
public String createSqlStatement(Analysis analysis) {
this.cachedAnalysis = analysis;
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(analysis);
EList<Indicator> indicators = analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
instantiateQuery(indicator, dbmsLanguage);
}
// no query to return, here we only instantiate several SQL queries
return PluginConstant.EMPTY_STRING;
}
use of org.talend.dq.dbms.DbmsLanguage in project tdq-studio-se by Talend.
the class AnalysisTableTreeViewer method isExpressionNull.
private String isExpressionNull(TreeItem item) {
String expressContent = null;
TableIndicatorUnit indicatorUnit = (TableIndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
TableIndicator tableIndicator = (TableIndicator) item.getData(TABLE_INDICATOR_KEY);
NamedColumnSet set = tableIndicator.getColumnSet();
Connection dataprovider = ConnectionHelper.getTdDataProvider(ColumnSetHelper.getParentCatalogOrSchema(set));
DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
if (expression != null) {
expressContent = expression.getBody();
}
return expressContent;
}
use of org.talend.dq.dbms.DbmsLanguage in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method viewQueryForSelectedElement.
/**
* DOC mzhao Comment method "viewQueryForSelectedElement".
*
* @param newTree
*/
private void viewQueryForSelectedElement(Tree newTree) {
TreeItem[] selection = newTree.getSelection();
for (TreeItem item : selection) {
ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(AbstractColumnDropTree.MODELELEMENT_INDICATOR_KEY);
ConnectionItem connItem = (ConnectionItem) meIndicator.getModelElementRepositoryNode().getObject().getProperty().getItem();
Connection dataprovider = connItem.getConnection();
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(AbstractColumnDropTree.INDICATOR_UNIT_KEY);
DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
if (expression == null) {
MessageDialogWithToggle.openWarning(null, DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.Warn"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.NoQueryDefined"));
return;
}
SqlExplorerUtils.getDefault().runInDQViewer(dataprovider, expression.getBody(), meIndicator.getModelElementRepositoryNode().getObject().getProperty().getLabel());
}
}
Aggregations