use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class PropertyHelperTest method testRealExistDuplicateName.
@Test
public void testRealExistDuplicateName() throws PersistenceException {
// --- create indicators
// Indicator
CountsIndicator createCountsIndicator = IndicatorsFactory.eINSTANCE.createCountsIndicator();
List<IRepositoryViewObject> all = null;
IndicatorDefinition createIndicatorDefinition = null;
try {
all = factory.getAll(ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
for (IRepositoryViewObject indicatorViewObject : all) {
if (indicatorViewObject.getLabel().equalsIgnoreCase("ROW COUNT")) {
createIndicatorDefinition = (IndicatorDefinition) PropertyHelper.getModelElement(indicatorViewObject.getProperty());
break;
}
}
} catch (PersistenceException e1) {
e1.printStackTrace();
Assert.fail(e1.getMessage());
}
createCountsIndicator.setIndicatorDefinition(createIndicatorDefinition);
boolean existDuplicateName = PropertyHelper.existDuplicateName("Copy of Row Count", "Row Count", ERepositoryObjectType.TDQ_INDICATOR_ELEMENT);
assertFalse(existDuplicateName);
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionDB2Case5.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionDB2Case5() {
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
// $NON-NLS-1$
String db2Lang = "DB2";
// $NON-NLS-1$
String db2Body = "DB2 body";
// $NON-NLS-1$
String db2NTLang = "DB2/NT";
// $NON-NLS-1$
String db2NTBody = "DB2/NT body";
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
// $NON-NLS-1$
String language = "unknown";
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
TdExpression tdExpression2 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression2.setLanguage(db2Lang);
tdExpression2.setBody(db2Body);
sqlGenericExpression.add(tdExpression2);
TdExpression tdExpression3 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression3.setLanguage(db2NTLang);
tdExpression3.setBody(db2NTBody);
sqlGenericExpression.add(tdExpression3);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, language, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression1, sqlExpression);
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionDB2Case3.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionDB2Case3() {
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
// $NON-NLS-1$
String db2Lang = "DB2";
// $NON-NLS-1$
String db2Body = "DB2 body";
// $NON-NLS-1$
String db2NTLang = "DB2/NT";
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
String language = db2NTLang;
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
TdExpression tdExpression2 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression2.setLanguage(db2Lang);
tdExpression2.setBody(db2Body);
sqlGenericExpression.add(tdExpression2);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, language, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression2, sqlExpression);
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetPatternFinderFunctionStringEListOfCharactersMappingCase2.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getPatternFinderFunction(java.lang.String, org.eclipse.emf.common.util.EList)}
* .
*
* case 2 : default case
*/
@Test
public void testGetPatternFinderFunctionStringEListOfCharactersMappingCase2() {
// $NON-NLS-1$
String expectedResult = "TRANSLATE(name , \'abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789Default\' , \'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999Default\')";
NetezzaDbmsLanguage netezzaDbmsLanguage = (NetezzaDbmsLanguage) DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.NETEZZADEFAULTURL);
IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
EList<CharactersMapping> charactersMapping = createIndicatorDefinition.getCharactersMapping();
CharactersMapping createCharactersMapping = DefinitionFactory.eINSTANCE.createCharactersMapping();
// mysql
createCharactersMapping.setLanguage(SupportDBUrlType.MYSQLDEFAULTURL.getLanguage());
createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
"abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789MySql");
createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999MySql");
charactersMapping.add(createCharactersMapping);
// ~mysql
// default
createCharactersMapping.setLanguage(DbmsLanguage.SQL);
createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
"abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789Default");
createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999Default");
charactersMapping.add(createCharactersMapping);
// ~default
// $NON-NLS-1$
String patternFinderFunction = netezzaDbmsLanguage.getPatternFinderFunction("name", charactersMapping);
Assert.assertEquals(expectedResult, patternFinderFunction);
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition 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