use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class PieStatisticsState method getPieDataset.
@Override
public Object getPieDataset() {
Map<String, Double> valueMap = new HashMap<String, Double>();
for (IndicatorUnit unit : units) {
if (unit.isExcuted()) {
FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
ComparatorsFactory.sort(frequencyExt, ComparatorsFactory.FREQUENCY_COMPARATOR_ID);
int numOfShown = frequencyExt.length;
for (int i = 0; i < numOfShown; i++) {
FrequencyExt freqExt = frequencyExt[i];
String keyLabel = PieStatisticsStateUtil.getkeyLabel(freqExt);
Double percent = freqExt.getFrequency();
valueMap.put(keyLabel, percent);
}
}
}
return TOPChartUtils.getInstance().createPieDataset(valueMap);
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class FrequencyTypeStates method getCustomerDataset.
public ICustomerDataset getCustomerDataset() {
CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
boolean withRowCountIndicator = isWithRowCountIndicator();
for (IndicatorUnit unit : units) {
if (unit.isExcuted() && !this.isSupportDynamicChart) {
FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
sortIndicator(frequencyExt);
int numOfShown = FrequencyTypeStateUtil.getNumberOfShown(unit, frequencyExt);
for (int i = 0; i < numOfShown; i++) {
FrequencyExt freqExt = frequencyExt[i];
String keyLabel = FrequencyTypeStateUtil.getKeyLabel(freqExt, 200);
setValueToDataset(customerdataset, freqExt, keyLabel);
ChartDataEntity entity = FrequencyTypeStateUtil.createChartEntity(unit.getIndicator(), freqExt, keyLabel, withRowCountIndicator);
customerdataset.addDataEntity(entity);
}
} else {
ChartDataEntity entity = FrequencyTypeStateUtil.createChartEntity(unit.getIndicator(), null, SpecialValueDisplay.EMPTY_FIELD, false);
FrequencyExt fre = new FrequencyExt();
fre.setValue(0l);
fre.setFrequency(0d);
setValueToDataset(customerdataset, fre, unit.getIndicatorName());
customerdataset.addDataEntity(entity);
}
}
return customerdataset;
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class IndicatorCommonUtil method handleFreqPie.
/**
* DOC qiongli Comment method "handleFreqPie".
*
* @param indicator
* @return
*/
@SuppressWarnings("rawtypes")
private static Object handleFreqPie(Indicator indicator) {
FrequencyExt[] frequencyExt = null;
FormatFreqPieIndicator formatFreqIndicator = (FormatFreqPieIndicator) indicator;
HashMap<Object, Long> valueToFreq = formatFreqIndicator.getValueToFreq();
if (valueToFreq == null) {
return null;
}
int i = 0;
frequencyExt = new FrequencyExt[valueToFreq.size()];
Iterator iter = valueToFreq.entrySet().iterator();
while (iter.hasNext()) {
Entry entry = (Entry) iter.next();
frequencyExt[i] = new FrequencyExt();
Object key = entry.getKey();
long value = Long.valueOf(entry.getValue().toString());
frequencyExt[i].setKey(key.toString());
frequencyExt[i].setValue(value);
frequencyExt[i].setFrequency(formatFreqIndicator.getFrequency(key));
i++;
}
return frequencyExt;
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class BenfordLawFrequencyStateUtil method recomputerForBenfordLaw.
public static FrequencyExt[] recomputerForBenfordLaw(FrequencyExt[] frequencyExt) {
FrequencyExt[] tempFreq = frequencyExt;
// get the sum
double sum = 0d;
for (FrequencyExt ext : frequencyExt) {
sum += ext.getValue();
}
// set the values from count to percentage
for (FrequencyExt ext : tempFreq) {
ext.setFrequency(ext.getValue() / sum);
}
return tempFreq;
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class DateFrequencyStateUtil method getDataEntity.
public static ChartDataEntity[] getDataEntity(List<IndicatorUnit> units, int sortType) {
List<ChartDataEntity> dataEnities = new ArrayList<ChartDataEntity>();
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);
dataEnities.add(DateFrequencyStateUtil.createDataEntity(unit, freqExt, keyLabel));
}
}
}
return dataEnities.toArray(new ChartDataEntity[dataEnities.size()]);
}
Aggregations