use of org.talend.dataquality.indicators.MaxValueIndicator in project tdq-studio-se by Talend.
the class RangeIndicatorImpl method basicSetUpperValue.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetUpperValue(MaxValueIndicator newUpperValue, NotificationChain msgs) {
MaxValueIndicator oldUpperValue = upperValue;
upperValue = newUpperValue;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IndicatorsPackage.RANGE_INDICATOR__UPPER_VALUE, oldUpperValue, newUpperValue);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.talend.dataquality.indicators.MaxValueIndicator in project tdq-studio-se by Talend.
the class SummaryStastictisExplorerRealTest method testGetQueryMap.
/**
* Test method for {@link org.talend.dq.analysis.explore.SummaryStastictisExplorer#getQueryMap()}.
*/
@Test
public void testGetQueryMap() {
// testing code for SQL Engine here
SummaryStastictisExplorer summaryExplorerSql = new SummaryStastictisExplorer();
Analysis analysisReal = AnalysisFactory.eINSTANCE.createAnalysis();
AnalysisParameters analysisParametersReal = AnalysisFactory.eINSTANCE.createAnalysisParameters();
analysisParametersReal.setExecutionLanguage(ExecutionLanguage.SQL);
analysisReal.setParameters(analysisParametersReal);
AnalysisContext analysisContextReal = AnalysisFactory.eINSTANCE.createAnalysisContext();
DataManager dataManagerReal = SoftwaredeploymentFactory.eINSTANCE.createDataManager();
analysisContextReal.setConnection(dataManagerReal);
analysisReal.setContext(analysisContextReal);
summaryExplorerSql.setAnalysis(analysisReal);
TdColumn tdColumnReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdColumn();
TdTable tdTableReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdTable();
// $NON-NLS-1$
tdTableReal.setName("tableName");
tdColumnReal.setOwner(tdTableReal);
// $NON-NLS-1$
tdColumnReal.setName("id");
TdSqlDataType tdsqlReal = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdSqlDataType();
// $NON-NLS-1$
tdsqlReal.setName("Integer");
tdColumnReal.setSqlDataType(tdsqlReal);
// test for MeanIndicator
MeanIndicator meanIndicator = IndicatorsFactory.eINSTANCE.createMeanIndicator();
meanIndicator.setAnalyzedElement(tdColumnReal);
IndicatorDefinition meanIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
meanIndicatorDef.setName("Mean");
meanIndicator.setIndicatorDefinition(meanIndicatorDef);
ChartDataEntity entityReal = new ChartDataEntity();
// $NON-NLS-1$
entityReal.setValue("0");
entityReal.setIndicator(meanIndicator);
summaryExplorerSql.setEnitty(entityReal);
Map<String, String> queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
// test for MedianIndicator
MedianIndicator medianIndicator = IndicatorsFactory.eINSTANCE.createMedianIndicator();
medianIndicator.setAnalyzedElement(tdColumnReal);
IndicatorDefinition medianIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
medianIndicatorDef.setName("Median");
medianIndicator.setIndicatorDefinition(medianIndicatorDef);
entityReal.setIndicator(medianIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.size() == 1);
// test for IQRIndicator
MaxValueIndicator maxValueIndicator = IndicatorsFactory.eINSTANCE.createMaxValueIndicator();
// $NON-NLS-1$
maxValueIndicator.setValue("80");
IndicatorDefinition maxValueIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
maxValueIndicatorDef.setName("Maximum");
maxValueIndicator.setIndicatorDefinition(maxValueIndicatorDef);
MinValueIndicator minValueIndicator = IndicatorsFactory.eINSTANCE.createMinValueIndicator();
// $NON-NLS-1$
minValueIndicator.setValue("20");
IndicatorDefinition minValueIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
minValueIndicatorDef.setName("Minimum");
minValueIndicator.setIndicatorDefinition(minValueIndicatorDef);
IQRIndicator iqrIndicator = IndicatorsFactory.eINSTANCE.createIQRIndicator();
iqrIndicator.setUpperValue(maxValueIndicator);
iqrIndicator.setLowerValue(minValueIndicator);
iqrIndicator.setAnalyzedElement(tdColumnReal);
IndicatorDefinition iqrIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
iqrIndicatorDef.setName("Inter Quartile Range");
iqrIndicator.setIndicatorDefinition(iqrIndicatorDef);
entityReal.setIndicator(iqrIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.size() == 2);
// test for LowerQuartileIndicator
LowerQuartileIndicator lowerQuartileIndicator = IndicatorsFactory.eINSTANCE.createLowerQuartileIndicator();
lowerQuartileIndicator.setAnalyzedElement(tdColumnReal);
IndicatorDefinition lowerQuartileIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
lowerQuartileIndicatorDef.setName("Lower Quartile");
lowerQuartileIndicator.setIndicatorDefinition(lowerQuartileIndicatorDef);
entityReal.setIndicator(lowerQuartileIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.size() == 1);
// test for UpperQuartileIndicator
UpperQuartileIndicator upperQuartileIndicator = IndicatorsFactory.eINSTANCE.createUpperQuartileIndicator();
upperQuartileIndicator.setAnalyzedElement(tdColumnReal);
IndicatorDefinition upperQuartileIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
upperQuartileIndicatorDef.setName("Upper Quartile");
upperQuartileIndicator.setIndicatorDefinition(upperQuartileIndicatorDef);
entityReal.setIndicator(upperQuartileIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.size() == 1);
// test for RangeIndicator
RangeIndicator rangeIndicator = IndicatorsFactory.eINSTANCE.createRangeIndicator();
rangeIndicator.setUpperValue(maxValueIndicator);
rangeIndicator.setLowerValue(minValueIndicator);
rangeIndicator.setAnalyzedElement(tdColumnReal);
IndicatorDefinition rangeIndicatorDef = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
rangeIndicatorDef.setName("Range");
rangeIndicator.setIndicatorDefinition(rangeIndicatorDef);
entityReal.setIndicator(rangeIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.size() == 2);
// test for MinValueIndicator
minValueIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(minValueIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.size() == 1);
// test for MaxValueIndicator
maxValueIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(maxValueIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.size() == 1);
// testing code for Java Engine here
analysisParametersReal.setExecutionLanguage(ExecutionLanguage.JAVA);
analysisReal.setParameters(analysisParametersReal);
summaryExplorerSql.setAnalysis(analysisReal);
// test for MeanIndicator
meanIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(meanIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
// test for MedianIndicator
medianIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(medianIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
// test for IQRIndicator
iqrIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(iqrIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
// test for LowerQuartileIndicator
lowerQuartileIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(lowerQuartileIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
// test for UpperQuartileIndicator
upperQuartileIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(upperQuartileIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
// test for RangeIndicator
rangeIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(rangeIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
// test for MinValueIndicator
minValueIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(minValueIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
// test for MaxValueIndicator
maxValueIndicator.setAnalyzedElement(tdColumnReal);
entityReal.setIndicator(maxValueIndicator);
summaryExplorerSql.setEnitty(entityReal);
queryMap = summaryExplorerSql.getQueryMap();
Assert.assertTrue(queryMap.isEmpty());
}
use of org.talend.dataquality.indicators.MaxValueIndicator in project tdq-studio-se by Talend.
the class IndicatorCommonUtil method getIndicatorValue.
public static Object getIndicatorValue(Indicator indicator) {
Object value = null;
IndicatorEnum type = IndicatorEnum.findIndicatorEnum(indicator.eClass());
if (type != null) {
try {
if (type == IndicatorEnum.RangeIndicatorEnum || type == IndicatorEnum.IQRIndicatorEnum) {
value = ((RangeIndicator) indicator).getRange();
((RangeIndicator) indicator).setComputed(true);
} else if (indicator.isComputed()) {
switch(type) {
case RowCountIndicatorEnum:
value = ((RowCountIndicator) indicator).getCount();
break;
case NullCountIndicatorEnum:
value = ((NullCountIndicator) indicator).getNullCount();
break;
case DistinctCountIndicatorEnum:
value = ((DistinctCountIndicator) indicator).getDistinctValueCount();
break;
case UniqueIndicatorEnum:
value = (((UniqueCountIndicator) indicator).getUniqueValueCount());
break;
case DuplicateCountIndicatorEnum:
value = ((DuplicateCountIndicator) indicator).getDuplicateValueCount();
break;
case BlankCountIndicatorEnum:
value = ((BlankCountIndicator) indicator).getBlankCount();
break;
case DefValueCountIndicatorEnum:
value = ((DefValueCountIndicator) indicator).getDefaultValCount();
break;
case MinLengthIndicatorEnum:
value = ((MinLengthIndicator) indicator).getLength();
break;
case MinLengthWithNullIndicatorEnum:
value = ((MinLengthWithNullIndicator) indicator).getLength();
break;
case MinLengthWithBlankIndicatorEnum:
value = ((MinLengthWithBlankIndicator) indicator).getLength();
break;
case MinLengthWithBlankNullIndicatorEnum:
value = ((MinLengthWithBlankNullIndicator) indicator).getLength();
break;
case MaxLengthIndicatorEnum:
value = ((MaxLengthIndicator) indicator).getLength();
break;
case MaxLengthWithNullIndicatorEnum:
value = ((MaxLengthWithNullIndicator) indicator).getLength();
break;
case MaxLengthWithBlankIndicatorEnum:
value = ((MaxLengthWithBlankIndicator) indicator).getLength();
break;
case MaxLengthWithBlankNullIndicatorEnum:
value = ((MaxLengthWithBlankNullIndicator) indicator).getLength();
break;
case AverageLengthIndicatorEnum:
value = ((AverageLengthIndicator) indicator).getAverageLength();
break;
case AverageLengthWithNullIndicatorEnum:
value = ((AvgLengthWithNullIndicator) indicator).getAverageLength();
break;
case AverageLengthWithBlankIndicatorEnum:
value = ((AvgLengthWithBlankIndicator) indicator).getAverageLength();
break;
case AverageLengthWithNullBlankIndicatorEnum:
value = ((AvgLengthWithBlankNullIndicator) indicator).getAverageLength();
break;
case FrequencyIndicatorEnum:
case DateFrequencyIndicatorEnum:
case WeekFrequencyIndicatorEnum:
case MonthFrequencyIndicatorEnum:
case QuarterFrequencyIndicatorEnum:
case YearFrequencyIndicatorEnum:
case BinFrequencyIndicatorEnum:
case LowFrequencyIndicatorEnum:
case DateLowFrequencyIndicatorEnum:
case WeekLowFrequencyIndicatorEnum:
case MonthLowFrequencyIndicatorEnum:
case QuarterLowFrequencyIndicatorEnum:
case YearLowFrequencyIndicatorEnum:
case BinLowFrequencyIndicatorEnum:
case PatternFreqIndicatorEnum:
case PatternLowFreqIndicatorEnum:
case EastAsiaPatternFreqIndicatorEnum:
case EastAsiaPatternLowFreqIndicatorEnum:
case DatePatternFreqIndicatorEnum:
case SoundexIndicatorEnum:
case SoundexLowIndicatorEnum:
case BenfordLawFrequencyIndicatorEnum:
value = handleFrequency(indicator);
break;
case MeanIndicatorEnum:
value = ((MeanIndicator) indicator).getMean();
break;
case MedianIndicatorEnum:
value = ((MedianIndicator) indicator).getMedian();
break;
case MinValueIndicatorEnum:
value = ((MinValueIndicator) indicator).getValue();
break;
case MaxValueIndicatorEnum:
value = ((MaxValueIndicator) indicator).getValue();
break;
case LowerQuartileIndicatorEnum:
value = ((LowerQuartileIndicator) indicator).getValue();
break;
case UpperQuartileIndicatorEnum:
value = ((UpperQuartileIndicator) indicator).getValue();
break;
case RegexpMatchingIndicatorEnum:
case SqlPatternMatchingIndicatorEnum:
case AllMatchIndicatorEnum:
value = handleMatchingValue(indicator);
break;
case ModeIndicatorEnum:
value = ((ModeIndicator) indicator).getMode();
break;
case UserDefinedIndicatorEnum:
value = handleUDIValue(indicator);
break;
case WhereRuleIndicatorEnum:
Long userCount = ((WhereRuleIndicator) indicator).getUserCount();
value = userCount == null ? 0 : userCount;
break;
// MOD qiongli 2011-7-21 feature 22362
case ValidPhoneCountIndicatorEnum:
value = ((ValidPhoneCountIndicator) indicator).getValidPhoneNumCount();
break;
case ValidRegCodeCountIndicatorEnum:
value = ((ValidRegCodeCountIndicator) indicator).getValidRegCount();
break;
case InvalidRegCodeCountIndicatorEnum:
value = ((InvalidRegCodeCountIndicator) indicator).getInvalidRegCount();
break;
case WellFormE164PhoneCountIndicatorEnum:
value = ((WellFormE164PhoneCountIndicator) indicator).getWellFormE164PhoneCount();
break;
case WellFormIntePhoneCountIndicatorEnum:
value = ((WellFormIntePhoneCountIndicator) indicator).getWellFormIntePhoneCount();
break;
case WellFormNationalPhoneCountIndicatorEnum:
value = ((WellFormNationalPhoneCountIndicator) indicator).getWellFormNatiPhoneCount();
break;
case PossiblePhoneCountIndicatorEnum:
value = ((PossiblePhoneCountIndicator) indicator).getPossiblePhoneCount();
break;
case FormatFreqPieIndictorEnum:
value = handleFreqPie(indicator);
default:
}
if (value == null || "null".equalsIgnoreCase(value.toString())) {
// $NON-NLS-1$
indicator.setComputed(false);
}
}
} catch (Exception e) {
// $NON-NLS-1$
log.error(Messages.getString("IndicatorCommonUtil.FailValue", e.getMessage()), e);
}
}
return value;
}
use of org.talend.dataquality.indicators.MaxValueIndicator in project tdq-studio-se by Talend.
the class IndicatorHelper method setDataThresholds.
/**
* DOC scorreia Comment method "setDataThresholds".
*
* @param rangeIndicator
* @param dataThreshold
*/
private static void setDataThresholds(RangeIndicator rangeIndicator, String[] dataThreshold) {
if (rangeIndicator != null) {
IndicatorHelper.setDataThreshold(rangeIndicator, dataThreshold[0], dataThreshold[1]);
MinValueIndicator lowerValue = rangeIndicator.getLowerValue();
// MOD qiongli 2011-11-25,propgate the parameter to children ,convert the dataThreshold to
// IndicatorThreshold for MaxValueIndicator/MinValueIndicator.
IndicatorParameters parameters = rangeIndicator.getParameters();
if (parameters != null) {
if (lowerValue != null) {
IndicatorParameters lowParameters = lowerValue.getParameters();
if (lowParameters == null) {
lowParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
lowerValue.setParameters(lowParameters);
}
IndicatorHelper.setIndicatorThreshold(lowParameters, dataThreshold[0], dataThreshold[1]);
// IndicatorHelper.setDataThreshold(lowerValue, dataThreshold[0], dataThreshold[1]);
}
MaxValueIndicator upperValue = rangeIndicator.getUpperValue();
if (upperValue != null) {
IndicatorParameters upperParameters = upperValue.getParameters();
if (upperParameters == null) {
upperParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
upperValue.setParameters(upperParameters);
}
IndicatorHelper.setIndicatorThreshold(upperParameters, dataThreshold[0], dataThreshold[1]);
// IndicatorHelper.setDataThreshold(lowerValue, dataThreshold[0], dataThreshold[1]);
}
}
}
}
use of org.talend.dataquality.indicators.MaxValueIndicator in project tdq-studio-se by Talend.
the class MaxValueIndicatorImplTest method testHandleObject.
/**
* Test method for {@link org.talend.dataquality.indicators.impl.MaxValueIndicatorImpl#handle(java.lang.Object)}.
*/
@Test
public void testHandleObject() {
MaxValueIndicator maxValueIndicator = IndicatorsFactory.eINSTANCE.createMaxValueIndicator();
Object data = null;
Assert.assertTrue(maxValueIndicator.handle(data));
}
Aggregations