use of org.talend.dataquality.indicators.SqlPatternMatchingIndicator in project tdq-studio-se by Talend.
the class SQLPatternExplorerTest method setUp.
/**
* DOC msjian Comment method "setUp".
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
UnitTestBuildHelper.initProjectStructure();
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
ITDQItemService tdqService = (ITDQItemService) GlobalServiceRegister.getDefault().getService(ITDQItemService.class);
tdqService.createDQStructor();
}
sqlPatternExplorer = new SQLPatternExplorer();
// mock setEntity
SqlPatternMatchingIndicator indicator = creatSqlPatternMatchingIndicator();
Analysis ana = UnitTestBuildHelper.createAndInitAnalysis();
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
createAnalysisResult.setResultMetadata(createExecutionInformations);
createAnalysisResult.getIndicators().add(indicator);
ana.setResults(createAnalysisResult);
sqlPatternExplorer.setAnalysis(ana);
// $NON-NLS-1$ //$NON-NLS-2$
ChartDataEntity chartDataEntity = new ChartDataEntity(indicator, "name1", "1");
chartDataEntity.setLabelNull(false);
// $NON-NLS-1$
chartDataEntity.setKey("name1");
sqlPatternExplorer.setEnitty(chartDataEntity);
IndicatorDefinition definition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
TdExpression expression = RelationalFactory.eINSTANCE.createTdExpression();
expression.setBody("SELECT * FROM tbi.customer ");
// $NON-NLS-1$
expression.setLanguage("SQL");
definition.getSqlGenericExpression().add(expression);
indicator.setIndicatorDefinition(definition);
indicator.getInstantiatedExpressions().add(expression);
}
use of org.talend.dataquality.indicators.SqlPatternMatchingIndicator in project tdq-studio-se by Talend.
the class PatternIndicatorFactory method createSqlPatternMatchingIndicator.
/**
* Method "createSqlPatternMatchingIndicator".
*
* @param pattern the pattern from which the SqlPatternMatchingIndicator is created
* @return the new SqlPatternMatchingIndicator with the same name as the pattern
*/
public static SqlPatternMatchingIndicator createSqlPatternMatchingIndicator(Pattern pattern) {
SqlPatternMatchingIndicator patternMatchingIndicator = IndicatorsFactory.eINSTANCE.createSqlPatternMatchingIndicator();
IndicatorParameters indicParams = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
Domain validData = DomainFactory.eINSTANCE.createDomain();
validData.getPatterns().add(pattern);
indicParams.setDataValidDomain(validData);
patternMatchingIndicator.setParameters(indicParams);
patternMatchingIndicator.setName(pattern.getName());
return patternMatchingIndicator;
}
use of org.talend.dataquality.indicators.SqlPatternMatchingIndicator in project tdq-studio-se by Talend.
the class ModelElementAnalysisHandlerTest method testInitializeIndicator.
/**
* Test method for
* {@link org.talend.dq.analysis.ModelElementAnalysisHandler#initializeIndicator(org.talend.dataquality.indicators.Indicator)}
* .
*/
@Test
public void testInitializeIndicator() {
Pattern pattern = PatternFactory.eINSTANCE.createPattern();
// $NON-NLS-1$
pattern.setName("old name");
// give a pattern indicator in the analysis result, which name is different with its pattern's name
SqlPatternMatchingIndicator patternMatchingIndicator = PatternIndicatorFactory.createSqlPatternMatchingIndicator(pattern);
patternMatchingIndicator.setIndicatorDefinition(DefinitionFactory.eINSTANCE.createIndicatorDefinition());
// $NON-NLS-1$
pattern.setName("new name");
// $NON-NLS-1$
assertEquals("old name", patternMatchingIndicator.getName());
// if the pattern's name is changed, then this method should use the newest name for the pattern indicator.
maHandler.initializeIndicator(patternMatchingIndicator);
// $NON-NLS-1$
assertEquals("new name", patternMatchingIndicator.getName());
// user indicator
Indicator userIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
// $NON-NLS-1$
userIndicator.setName("indicator name");
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
// $NON-NLS-1$
indicatorDefinition.setName("definition name");
userIndicator.setIndicatorDefinition(indicatorDefinition);
// $NON-NLS-1$
assertEquals("indicator name", userIndicator.getName());
// if the udi's name is changed, then this method should use the newest name for the udi.
maHandler.initializeIndicator(userIndicator);
// $NON-NLS-1$
assertEquals("definition name", userIndicator.getName());
// should not effect system indicators
SimpleStatIndicator simpleStatIndicator = ColumnsetFactory.eINSTANCE.createSimpleStatIndicator();
// $NON-NLS-1$
simpleStatIndicator.setName("simple stat");
simpleStatIndicator.setIndicatorDefinition(indicatorDefinition);
assertNotSame(indicatorDefinition.getName(), simpleStatIndicator.getName());
maHandler.initializeIndicator(simpleStatIndicator);
assertNotSame(indicatorDefinition.getName(), simpleStatIndicator.getName());
}
use of org.talend.dataquality.indicators.SqlPatternMatchingIndicator in project tdq-studio-se by Talend.
the class SQLPatternExplorerTest method creatSqlPatternMatchingIndicator.
private SqlPatternMatchingIndicator creatSqlPatternMatchingIndicator() {
// create database construction
TdColumn column = UnitTestBuildHelper.createRealTdColumn("lname", "lname", Types.VARCHAR);
// create indicator
SqlPatternMatchingIndicator indicator = IndicatorsFactory.eINSTANCE.createSqlPatternMatchingIndicator();
indicator.setAnalyzedElement(column);
IndicatorParameters indicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
indicatorParameters.setDateParameters(null);
indicator.setParameters(indicatorParameters);
Pattern pattern = PatternFactory.eINSTANCE.createPattern();
// $NON-NLS-1$
pattern.setName("My Pattern");
RegularExpression regularExpr = PatternFactory.eINSTANCE.createRegularExpression();
TdExpression expression = RelationalFactory.eINSTANCE.createTdExpression();
expression.setBody("'su%'");
// $NON-NLS-1$
expression.setLanguage("SQL");
regularExpr.setExpression(expression);
pattern.getComponents().add(regularExpr);
// create Domain
Domain createDomain = DomainFactory.eINSTANCE.createDomain();
indicatorParameters.setDataValidDomain(createDomain);
indicatorParameters.getDataValidDomain().getPatterns().add(pattern);
return indicator;
}
use of org.talend.dataquality.indicators.SqlPatternMatchingIndicator in project tdq-studio-se by Talend.
the class PatternStatisticeStateUtilTest method testGetUnitValueCase3.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticeStateUtil#getUnitValue(org.talend.dataquality.indicators.Indicator, java.lang.Object)}
* .
* case3:normal SqlPatternMatchingIndicator case
*/
@Test
public void testGetUnitValueCase3() {
PatternMatchingExt pMatchExt = null;
SqlPatternMatchingIndicator sqlMatchingIndicator = IndicatorsFactoryImpl.eINSTANCE.createSqlPatternMatchingIndicator();
sqlMatchingIndicator.setComputed(true);
sqlMatchingIndicator.setMatchingValueCount(40l);
sqlMatchingIndicator.setNotMatchingValueCount(50l);
PatternMatchingExt unitValue = PatternStatisticeStateUtil.getUnitValue(sqlMatchingIndicator, pMatchExt);
// $NON-NLS-1$
Assert.assertEquals("Matching count value shoud be 40l", 40l, unitValue.getMatchingValueCount());
// $NON-NLS-1$
Assert.assertEquals("Not matching count value shoud be 50l", 50l, unitValue.getNotMatchingValueCount());
// $NON-NLS-1$
Assert.assertNotEquals("unitValue should not same with pMatchExt but it is not now", pMatchExt, unitValue);
}
Aggregations