use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ModelElementIndicatorImpl method createTempSpecialIndicatorUnit.
private IndicatorUnit createTempSpecialIndicatorUnit(IndicatorEnum indicatorEnum, Indicator indicator) {
Indicator tempIndicator = indicator;
if (tempIndicator == null) {
EFactoryImpl factory = (EFactoryImpl) indicatorEnum.getIndicatorType().getEPackage().getEFactoryInstance();
tempIndicator = (Indicator) factory.create(indicatorEnum.getIndicatorType());
// MOD scorreia 2008-09-18: bug 5131 fixed: set indicator's definition when the indicator is created.
if (!DefinitionHandler.getInstance().setDefaultIndicatorDefinition(tempIndicator)) {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("ModelElementIndicatorImpl_COULDNOTSETDEF_GIVEN_IND0") + tempIndicator.getName());
}
}
// }
if (this.specialIndicatorUnitList == null) {
this.specialIndicatorUnitList = new ArrayList<IndicatorUnit>();
}
for (IndicatorUnit currentUnit : tempSpecialIndicatorUnitList) {
if (tempIndicator.getName().equalsIgnoreCase(currentUnit.getIndicator().getName())) {
return currentUnit;
}
}
IndicatorUnit indicatorUnit = new ColumnIndicatorUnit(indicatorEnum, tempIndicator, this);
tempSpecialIndicatorUnitList.add(indicatorUnit);
this.specialIndicatorUnitMap.put(tempIndicator.getName(), indicatorUnit);
return indicatorUnit;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ModelElementIndicatorImpl method createPlainIndicatorUnit.
/**
* Create a new IndicatorUnit according to indicatorEnum and indicator, if the parameter indicator is null, will
* create a new indicator .
*
* @param indicatorEnum
* @param indicator
* @return
*/
private IndicatorUnit createPlainIndicatorUnit(IndicatorEnum indicatorEnum, Indicator indicator) {
Indicator tempIndicator = indicator;
if (tempIndicator == null) {
EFactoryImpl factory = (EFactoryImpl) indicatorEnum.getIndicatorType().getEPackage().getEFactoryInstance();
tempIndicator = (Indicator) factory.create(indicatorEnum.getIndicatorType());
// MOD scorreia 2008-09-18: bug 5131 fixed: set indicator's definition when the indicator is created.
if (!DefinitionHandler.getInstance().setDefaultIndicatorDefinition(tempIndicator)) {
// $NON-NLS-1$
log.error("Could not set the definition of the given indicator :" + tempIndicator.getName());
}
// for 4225, the frequency indicator need be initialized
int sqlType = getJavaType();
if (tempIndicator instanceof FrequencyIndicator && Java2SqlType.isDateInSQL(sqlType)) {
IndicatorParameters parameters = tempIndicator.getParameters();
if (parameters == null) {
parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
tempIndicator.setParameters(parameters);
}
DateParameters dateParameters = parameters.getDateParameters();
// "Year Frequency Table" when applying on "Time" type
if (dateParameters == null && !(indicatorEnum == IndicatorEnum.PatternFreqIndicatorEnum || indicatorEnum == IndicatorEnum.PatternLowFreqIndicatorEnum || indicatorEnum == IndicatorEnum.FrequencyIndicatorEnum || indicatorEnum == IndicatorEnum.LowFrequencyIndicatorEnum)) {
dateParameters = IndicatorsFactory.eINSTANCE.createDateParameters();
parameters.setDateParameters(dateParameters);
}
// TDQ-5357~
// MOD scorreia 2008-06-19 default is already set in the model
// dateParameters.setDateAggregationType(DateGrain.YEAR);
}
}
IndicatorUnit indicatorUnit = new ColumnIndicatorUnit(indicatorEnum, tempIndicator, this);
this.plainIndicatorUnitMap.put(indicatorEnum, indicatorUnit);
return indicatorUnit;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ModelElementIndicatorImpl method getIndicators.
public Indicator[] getIndicators() {
List<Indicator> indicatorList = new ArrayList<Indicator>();
IndicatorUnit[] indicatorUnits = this.getIndicatorUnits();
for (IndicatorUnit indicatorUnit : indicatorUnits) {
indicatorList.add(indicatorUnit.getIndicator());
}
return indicatorList.toArray(new Indicator[indicatorList.size()]);
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class CompositeIndicatorImpl method getLeafIndicators.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT getLeafIndicators()
*/
public EList<Indicator> getLeafIndicators() {
EList<Indicator> leafIndicators = new BasicEList<Indicator>();
EList<Indicator> childIndicators = getChildIndicators();
for (Indicator indicator : childIndicators) {
if (indicator instanceof CompositeIndicator) {
leafIndicators.addAll(((CompositeIndicator) indicator).getLeafIndicators());
} else {
leafIndicators.add(indicator);
}
}
return leafIndicators;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class FunctionFrequencyStatExplorerTest method testGetInstantiatedClause.
/**
* Test method for {@link org.talend.dq.analysis.explore.FunctionFrequencyStatExplorer#getInstantiatedClause()}.
*/
@Test
public void testGetInstantiatedClause() {
FunctionFrequencyStatExplorer explorer = new FunctionFrequencyStatExplorer();
// init explorer instance
Indicator patternFreqIndicator = IndicatorsFactory.eINSTANCE.createPatternFreqIndicator();
ChartDataEntity entity = new ChartDataEntity(patternFreqIndicator, "entityName", "entityValue");
entity.setKey("entityKey");
Expression tdExpression = RelationalFactory.eINSTANCE.createTdExpression();
// $NON-NLS-1$
tdExpression.setLanguage("MySQL");
tdExpression.setBody("SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(`name`,'a','a'),'b','a'),'c','a'),'d','a'),'e','a'),'f','a'),'g','a'),'h','a'),'i','a'),'j','a'),'k','a'),'l','a'),'m','a'),'n','a'),'o','a'),'p','a'),'q','a'),'r','a'),'s','a'),'t','a'),'u','a'),'v','a'),'w','a'),'x','a'),'y','a'),'z','a'),'ç','a'),'â','a'),'ê','a'),'î','a'),'ô','a'),'û','a'),'é','a'),'è','a'),'ù','a'),'ï','a'),'ö','a'),'ü','a'),'A','A'),'B','A'),'C','A'),'D','A'),'E','A'),'F','A'),'G','A'),'H','A'),'I','A'),'J','A'),'K','A'),'L','A'),'M','A'),'N','A'),'O','A'),'P','A'),'Q','A'),'R','A'),'S','A'),'T','A'),'U','A'),'V','A'),'W','A'),'X','A'),'Y','A'),'Z','A'),'Ç','A'),'Â','A'),'Ê','A'),'Î','A'),'Ô','A'),'Û','A'),'É','A'),'È','A'),'Ù','A'),'Ï','A'),'Ö','A'),'Ü','A'),'0','9'),'1','9'),'2','9'),'3','9'),'4','9'),'5','9'),'6','9'),'7','9'),'8','9'),'9','9'), COUNT(*) c FROM `tbi`.`generatetable` t GROUP BY REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(`name`,'a','a'),'b','a'),'c','a'),'d','a'),'e','a'),'f','a'),'g','a'),'h','a'),'i','a'),'j','a'),'k','a'),'l','a'),'m','a'),'n','a'),'o','a'),'p','a'),'q','a'),'r','a'),'s','a'),'t','a'),'u','a'),'v','a'),'w','a'),'x','a'),'y','a'),'z','a'),'ç','a'),'â','a'),'ê','a'),'î','a'),'ô','a'),'û','a'),'é','a'),'è','a'),'ù','a'),'ï','a'),'ö','a'),'ü','a'),'A','A'),'B','A'),'C','A'),'D','A'),'E','A'),'F','A'),'G','A'),'H','A'),'I','A'),'J','A'),'K','A'),'L','A'),'M','A'),'N','A'),'O','A'),'P','A'),'Q','A'),'R','A'),'S','A'),'T','A'),'U','A'),'V','A'),'W','A'),'X','A'),'Y','A'),'Z','A'),'Ç','A'),'Â','A'),'Ê','A'),'Î','A'),'Ô','A'),'Û','A'),'É','A'),'È','A'),'Ù','A'),'Ï','A'),'Ö','A'),'Ü','A'),'0','9'),'1','9'),'2','9'),'3','9'),'4','9'),'5','9'),'6','9'),'7','9'),'8','9'),'9','9') ORDER BY c ASC LIMIT 10");
patternFreqIndicator.setInstantiatedExpression(tdExpression);
TdColumn column1 = RelationalFactory.eINSTANCE.createTdColumn();
// $NON-NLS-1$
column1.setName("columnName");
TdSqlDataType tdSqlDataType = RelationalFactory.eINSTANCE.createTdSqlDataType();
tdSqlDataType.setJavaDataType(Types.DATE);
column1.setSqlDataType(tdSqlDataType);
patternFreqIndicator.setAnalyzedElement(column1);
Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
AnalysisContext analysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
analysis.setContext(analysisContext);
DatabaseConnection databaseConnection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
analysisContext.setConnection(databaseConnection);
// $NON-NLS-1$
TaggedValueHelper.setTaggedValue(databaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, "MySQL");
// $NON-NLS-1$
TaggedValueHelper.setTaggedValue(databaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "5.0.22-community-nt");
// $NON-NLS-1$
TaggedValueHelper.setTaggedValue(databaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "'");
explorer.setAnalysis(analysis);
explorer.setEnitty(entity);
String instantiatedClause = explorer.getInstantiatedClause();
Assert.assertEquals("REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(`name`,'a','a'),'b','a'),'c','a'),'d','a'),'e','a'),'f','a'),'g','a'),'h','a'),'i','a'),'j','a'),'k','a'),'l','a'),'m','a'),'n','a'),'o','a'),'p','a'),'q','a'),'r','a'),'s','a'),'t','a'),'u','a'),'v','a'),'w','a'),'x','a'),'y','a'),'z','a'),'ç','a'),'â','a'),'ê','a'),'î','a'),'ô','a'),'û','a'),'é','a'),'è','a'),'ù','a'),'ï','a'),'ö','a'),'ü','a'),'A','A'),'B','A'),'C','A'),'D','A'),'E','A'),'F','A'),'G','A'),'H','A'),'I','A'),'J','A'),'K','A'),'L','A'),'M','A'),'N','A'),'O','A'),'P','A'),'Q','A'),'R','A'),'S','A'),'T','A'),'U','A'),'V','A'),'W','A'),'X','A'),'Y','A'),'Z','A'),'Ç','A'),'Â','A'),'Ê','A'),'Î','A'),'Ô','A'),'Û','A'),'É','A'),'È','A'),'Ù','A'),'Ï','A'),'Ö','A'),'Ü','A'),'0','9'),'1','9'),'2','9'),'3','9'),'4','9'),'5','9'),'6','9'),'7','9'),'8','9'),'9','9') = 'entityKey'", instantiatedClause);
}
Aggregations