use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class TestComparisonLevelFactoryTest method createCatalog.
private Catalog createCatalog(String catalogName) {
Connection connection = databaseConnectionItem.getConnection();
Catalog createCatalog = CatalogHelper.createCatalog(catalogName);
ConnectionHelper.addCatalog(createCatalog, connection);
return createCatalog;
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class TableAnalysisSqlExecutorTest method setUp.
/**
* DOC xqliu Comment method "setUp".
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
// create TdTable
TdTable testTdTable = RelationalFactory.eINSTANCE.createTdTable();
// $NON-NLS-1$
testTdTable.setName("generateTable");
// create connection
DatabaseConnection testDatabaseConnection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
TaggedValueHelper.setTaggedValue(testDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.MYSQLDEFAULTURL.getDBKey());
// create catalog
Catalog testCatalog = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
// $NON-NLS-1$
testCatalog.setName("TBI");
testTdTable.setNamespace(testCatalog);
testCatalog.setNamespace(testDatabaseConnection);
testCatalog.getDataManager().add(testDatabaseConnection);
// create analysis
testAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
// create Analaysis result
AnalysisResult testAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
testAnalysis.setResults(testAnalysisResult);
// create analysis parameter
AnalysisParameters testAnalysisParameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
testAnalysis.setParameters(testAnalysisParameters);
// create analysis Content
AnalysisContext testAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
testAnalysis.setContext(testAnalysisContext);
testAnalysisContext.setConnection(testDatabaseConnection);
// create WhereRuleAide indicatorDefinition
testWhereRuleIndicatorDefinition = RulesFactory.eINSTANCE.createWhereRule();
// $NON-NLS-1$
testWhereRuleIndicatorDefinition.setLabel("rule1");
// create WhereRule indicator
testWhereRuleIndicator = IndicatorSqlFactory.eINSTANCE.createWhereRuleIndicator();
testAnalysisResult.getIndicators().add(testWhereRuleIndicator);
testWhereRuleIndicator.setAnalyzedElement(testTdTable);
testWhereRuleIndicator.setIndicatorDefinition(testWhereRuleIndicatorDefinition);
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class PatternExplorerRealTest method testGetValidValuesStatement_2.
/**
* Test method for {@link org.talend.dq.analysis.explore.PatternExplorer#getValidValuesStatement()}. when the test
* for indicator is user define indicator
*/
@Test
public void testGetValidValuesStatement_2() {
patternExplorer = new RegexPatternExplorer();
// mock setEntity
PatternMatchingIndicator indicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
UDIndicatorDefinition indicatorDef = UserdefineFactoryImpl.eINSTANCE.createUDIndicatorDefinition();
indicator.setIndicatorDefinition(indicatorDef);
TdExpression udiTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
udiTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
udiTdExpression.setBody(ViewValidValues);
indicatorDef.getViewValidValuesExpression().add(udiTdExpression);
// create pattern parameter
IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
indicator.setParameters(createIndicatorParameters);
Domain createDomain = DomainFactoryImpl.eINSTANCE.createDomain();
createIndicatorParameters.setDataValidDomain(createDomain);
Pattern createPattern = PatternFactoryImpl.eINSTANCE.createPattern();
createDomain.getPatterns().add(createPattern);
RegularExpression createPatternComponent = PatternFactoryImpl.eINSTANCE.createRegularExpression();
createPattern.getComponents().add(createPatternComponent);
TdExpression createTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
createPatternComponent.setExpression(createTdExpression);
createTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
// $NON-NLS-1$
createTdExpression.setBody("`su.*`");
TdColumn element = RelationalFactoryImpl.eINSTANCE.createTdColumn();
// $NON-NLS-1$
element.setName("lname");
TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
// $NON-NLS-1$
createTdTable.setName("table1");
TableHelper.addColumn(createTdTable, element);
Catalog createCatalog = orgomg.cwm.resource.relational.impl.RelationalFactoryImpl.eINSTANCE.createCatalog();
// $NON-NLS-1$
createCatalog.setName("catalog1");
List<TdTable> tableList = new ArrayList<TdTable>();
tableList.add(createTdTable);
CatalogHelper.addTables(tableList, createCatalog);
indicator.setAnalyzedElement(element);
Expression createIndiExpression = CoreFactoryImpl.eINSTANCE.createExpression();
createIndiExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
// $NON-NLS-1$
createIndiExpression.setBody("SELECT * FROM `tbi`.`customer` WHERE (customer.lname = \"sunny\")");
indicator.setInstantiatedExpression(createIndiExpression);
Analysis analysis = AnalysisFactoryImpl.eINSTANCE.createAnalysis();
AnalysisContext createAnalysisContext = AnalysisFactoryImpl.eINSTANCE.createAnalysisContext();
analysis.setContext(createAnalysisContext);
DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
// $NON-NLS-1$
TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "1.0");
// $NON-NLS-1$
TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "`");
createAnalysisContext.setConnection(createDatabaseConnection);
patternExplorer.setAnalysis(analysis);
ChartDataEntity cdEntity = new ChartDataEntity();
cdEntity.setIndicator(indicator);
patternExplorer.setEnitty(cdEntity);
Assert.assertTrue(patternExplorer.setAnalysis(analysis));
String clause = patternExplorer.getValidValuesStatement();
// $NON-NLS-1$
assertEquals("SELECT `lname` FROM `catalog1`.`table1` ", clause);
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class PatternExplorerRealTest method testGetInvalidRowsStatement_4.
/**
* Test method for {@link org.talend.dq.analysis.explore.PatternExplorer#getInvalidRowsStatement()}. when the test
* for indicator is user define indicator
*/
@Test
public void testGetInvalidRowsStatement_4() {
patternExplorer = new RegexPatternExplorer();
// mock setEntity
PatternMatchingIndicator indicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
UDIndicatorDefinition indicatorDef = UserdefineFactoryImpl.eINSTANCE.createUDIndicatorDefinition();
indicator.setIndicatorDefinition(indicatorDef);
TdExpression udiTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
udiTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
udiTdExpression.setBody(ViewInvalidRows);
indicatorDef.getViewInvalidRowsExpression().add(udiTdExpression);
// create pattern parameter
IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
indicator.setParameters(createIndicatorParameters);
Domain createDomain = DomainFactoryImpl.eINSTANCE.createDomain();
createIndicatorParameters.setDataValidDomain(createDomain);
Pattern createPattern = PatternFactoryImpl.eINSTANCE.createPattern();
createDomain.getPatterns().add(createPattern);
RegularExpression createPatternComponent = PatternFactoryImpl.eINSTANCE.createRegularExpression();
createPattern.getComponents().add(createPatternComponent);
TdExpression createTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
createPatternComponent.setExpression(createTdExpression);
createTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
// $NON-NLS-1$
createTdExpression.setBody("`su.*`");
TdColumn element = RelationalFactoryImpl.eINSTANCE.createTdColumn();
// $NON-NLS-1$
element.setName("lname");
TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
// $NON-NLS-1$
createTdTable.setName("table1");
TableHelper.addColumn(createTdTable, element);
Catalog createCatalog = orgomg.cwm.resource.relational.impl.RelationalFactoryImpl.eINSTANCE.createCatalog();
// $NON-NLS-1$
createCatalog.setName("catalog1");
List<TdTable> tableList = new ArrayList<TdTable>();
tableList.add(createTdTable);
CatalogHelper.addTables(tableList, createCatalog);
indicator.setAnalyzedElement(element);
Expression createIndiExpression = CoreFactoryImpl.eINSTANCE.createExpression();
createIndiExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
// $NON-NLS-1$
createIndiExpression.setBody("SELECT * FROM `tbi`.`customer` WHERE (customer.lname = \"sunny\")");
indicator.setInstantiatedExpression(createIndiExpression);
Analysis analysis = AnalysisFactoryImpl.eINSTANCE.createAnalysis();
AnalysisContext createAnalysisContext = AnalysisFactoryImpl.eINSTANCE.createAnalysisContext();
analysis.setContext(createAnalysisContext);
DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
// $NON-NLS-1$
TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "1.0");
// $NON-NLS-1$
TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "`");
createAnalysisContext.setConnection(createDatabaseConnection);
ChartDataEntity cdEntity = new ChartDataEntity();
cdEntity.setIndicator(indicator);
Assert.assertTrue(patternExplorer.setAnalysis(analysis));
patternExplorer.setEnitty(cdEntity);
String clause = patternExplorer.getInvalidRowsStatement();
// $NON-NLS-1$
assertEquals("SELECT * FROM `catalog1`.`table1` WHERE NOT (id>=1) ", clause);
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class RowMatchExplorerTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
// analysis
analysis = AnalysisFactory.eINSTANCE.createAnalysis();
AnalysisContext context = AnalysisFactory.eINSTANCE.createAnalysisContext();
analysis.setContext(context);
AnalysisResult mockResults = AnalysisFactory.eINSTANCE.createAnalysisResult();
analysis.setResults(mockResults);
// connection
connection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
analysis.getContext().setConnection(connection);
TaggedValueHelper.setTaggedValue(connection, TaggedValueHelper.DB_PRODUCT_NAME, TaggedValueHelper.DB_PRODUCT_NAME);
// ------------------------- table A ------------------------------
Catalog catalogA = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
// $NON-NLS-1$
catalogA.setName("catalogA");
Schema schemaA = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createSchema();
// $NON-NLS-1$
schemaA.setName("schemaA");
catalogA.getOwnedElement().add(schemaA);
TdTable tableA = RelationalFactory.eINSTANCE.createTdTable();
// $NON-NLS-1$
tableA.setName("tableA");
schemaA.getOwnedElement().add(tableA);
TdColumn tdColumnA = RelationalFactory.eINSTANCE.createTdColumn();
// $NON-NLS-1$
tdColumnA.setName("columnA");
tableA.getFeature().add(tdColumnA);
// ------------------------- table B ------------------------------
Catalog catalogB = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
// $NON-NLS-1$
catalogB.setName("catalogB");
Schema schemaB = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createSchema();
// $NON-NLS-1$
schemaB.setName("schemaB");
catalogB.getOwnedElement().add(schemaB);
TdTable tableB = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdTable();
// $NON-NLS-1$
tableB.setName("tableB");
schemaB.getOwnedElement().add(tableB);
TdColumn tdColumnB = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdColumn();
// $NON-NLS-1$
tdColumnB.setName("columnB");
tableB.getFeature().add(tdColumnB);
// indicator
RowMatchingIndicator rowMatchingIndicator = ColumnsetFactory.eINSTANCE.createRowMatchingIndicator();
// create indicatorDefinition
IndicatorDefinition testIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
// $NON-NLS-1$
testIndicatorDefinition.setName("RowMatchingIndicator");
rowMatchingIndicator.setIndicatorDefinition(testIndicatorDefinition);
analysis.getResults().getIndicators().add(rowMatchingIndicator);
TaggedValueHelper.setTaggedValue(analysis, TaggedValueHelper.PURPOSE, TaggedValueHelper.PURPOSE);
TaggedValueHelper.setTaggedValue(analysis, TaggedValueHelper.DESCRIPTION, TaggedValueHelper.DESCRIPTION);
rowMatchingIndicator.setAnalyzedElement(tableA);
rowMatchingIndicator.getColumnSetA().add(tdColumnA);
rowMatchingIndicator.getColumnSetB().add(tdColumnB);
explorer = new RowMatchExplorer();
entity = new ChartDataEntity();
entity.setIndicator(rowMatchingIndicator);
}
Aggregations