use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class DateFrequencyStateUtil method getCustomerDataset.
public static ICustomerDataset getCustomerDataset(List<IndicatorUnit> units, int sortType) {
CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
for (IndicatorUnit unit : units) {
if (unit.isExcuted()) {
FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
ComparatorsFactory.sort(frequencyExt, sortType);
int numOfShown = FrequencyTypeStateUtil.getNumberOfShown(unit, frequencyExt);
for (int i = 0; i < numOfShown; i++) {
FrequencyExt freqExt = frequencyExt[i];
String keyLabel = FrequencyTypeStateUtil.getKeyLabel(freqExt, 30);
customerdataset.addValue(freqExt.getValue(), unit.getIndicatorName(), keyLabel);
ChartDataEntity entity = createDataEntity(unit, freqExt, keyLabel);
customerdataset.addDataEntity(entity);
}
}
}
return customerdataset;
}
use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class FrequencyStatisticsExplorerTest method testGetFreqRowsStatement_1.
/**
* Test method for {@link org.talend.dq.analysis.explore.FrequencyStatisticsExplorer#getFreqRowsStatement()} case_1:
* for the column javaType is Date
*/
@Test
public void testGetFreqRowsStatement_1() {
LowFrequencyIndicator indicator = creatFrenquceIndicator("CAL_DATE", "DATE", Types.DATE);
// $NON-NLS-1$ //$NON-NLS-2$
ChartDataEntity chartDataEntity = new ChartDataEntity(indicator, "2012-06-05", "1");
chartDataEntity.setLabelNull(false);
// $NON-NLS-1$
chartDataEntity.setKey("2012-06-05");
assertFalse(chartDataEntity.isLabelNull());
freqExp = new FrequencyStatisticsExplorer();
freqExp.setAnalysis(ana);
freqExp.setEnitty(chartDataEntity);
String clause = freqExp.getFreqRowsStatement();
// $NON-NLS-1$
assertEquals("SELECT * FROM TDQ_CALENDAR WHERE (CAL_DATE = '2012-06-05') ", clause);
}
use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class FrequencyStatisticsExplorerTest method testGetFreqRowsStatement_3.
/**
* Test method for {@link org.talend.dq.analysis.explore.FrequencyStatisticsExplorer#getFreqRowsStatement()} case_3:
* for for the column javaType is Number
*/
@Test
public void testGetFreqRowsStatement_3() {
LowFrequencyIndicator indicator = creatFrenquceIndicator("CAL_NUMBER", "NUMBER", Types.BIGINT);
// $NON-NLS-1$ //$NON-NLS-2$
ChartDataEntity chartDataEntity = new ChartDataEntity(indicator, "12345", "1");
chartDataEntity.setLabelNull(false);
// $NON-NLS-1$
chartDataEntity.setKey("12345");
assertFalse(chartDataEntity.isLabelNull());
freqExp = new FrequencyStatisticsExplorer();
freqExp.setAnalysis(ana);
freqExp.setEnitty(chartDataEntity);
String clause = freqExp.getFreqRowsStatement();
// $NON-NLS-1$
assertEquals("SELECT * FROM TDQ_CALENDAR WHERE (CAL_NUMBER = '12345') ", clause);
}
use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class FrequencyStatisticsExplorerTest method testGetFreqRowsStatement_4.
/**
* Test method for {@link org.talend.dq.analysis.explore.FrequencyStatisticsExplorer#getFreqRowsStatement()} case_3:
* for UDIndicatorDefinition
*/
@Test
public void testGetFreqRowsStatement_4() {
// create database construction
TdTable table = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdTable();
// $NON-NLS-1$
table.setName("TDQ_CALENDAR");
TdColumn column = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdColumn();
// $NON-NLS-1$
column.setName("CAL_DATE");
TdSqlDataType tdsql = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdSqlDataType();
// $NON-NLS-1$
tdsql.setName("DATE");
tdsql.setJavaDataType(Types.DATE);
column.setSqlDataType(tdsql);
table.getOwnedElement().add(column);
column.setOwner(table);
// create indicator
UserDefIndicator userDefIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
UDIndicatorDefinition indicatorDefinition = UserdefineFactory.eINSTANCE.createUDIndicatorDefinition();
// $NON-NLS-1$
indicatorDefinition.setName("user define count");
userDefIndicator.setName(indicatorDefinition.getName());
userDefIndicator.setIndicatorDefinition(indicatorDefinition);
TdExpression newTdExp = // $NON-NLS-1$
BooleanExpressionHelper.createTdExpression(// $NON-NLS-1$
"SQL", "SELECT * FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%>", // $NON-NLS-1$
null);
newTdExp.setModificationDate(DateUtils.getCurrentDate(DateUtils.PATTERN_5));
indicatorDefinition.getViewRowsExpression().add(newTdExp);
// $NON-NLS-1$ //$NON-NLS-2$
ChartDataEntity chartDataEntity = new ChartDataEntity(userDefIndicator, "2012-06-05", "1");
chartDataEntity.setLabelNull(false);
// $NON-NLS-1$
chartDataEntity.setKey("2012-06-05");
assertFalse(chartDataEntity.isLabelNull());
userDefIndicator.setAnalyzedElement(column);
IndicatorParameters indicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
indicatorParameters.setDateParameters(null);
userDefIndicator.setParameters(indicatorParameters);
assertNull(indicatorParameters.getDateParameters());
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
createAnalysisResult.setResultMetadata(createExecutionInformations);
createAnalysisResult.getIndicators().add(userDefIndicator);
userDefIndicator.setAnalyzedElement(column);
ana.setResults(createAnalysisResult);
freqExp = new FrequencyStatisticsExplorer();
freqExp.setAnalysis(ana);
freqExp.setEnitty(chartDataEntity);
String clause = freqExp.getFreqRowsStatement();
// $NON-NLS-1$
assertEquals("SELECT * FROM TDQ_CALENDAR ", clause);
}
use of org.talend.dq.indicators.preview.table.ChartDataEntity in project tdq-studio-se by Talend.
the class PatternExplorerRealTest method setUp.
/**
* DOC zshen Comment method "setUp".
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
patternExplorer = new RegexPatternExplorer();
// mock setEntity
PatternMatchingIndicator indicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
// 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.*`");
ModelElement element = RelationalFactoryImpl.eINSTANCE.createTdColumn();
// $NON-NLS-1$
element.setName("lname");
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);
}
Aggregations