use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class FrequencyDynamicChartEventReceiver method setFrequecyToDataset.
private void setFrequecyToDataset(Object customerdataset, FrequencyExt[] frequencyExt, Indicator indicator) {
int numOfShown = frequencyExt.length;
IndicatorParameters parameters = indicator.getParameters();
if (parameters != null) {
if (parameters.getTopN() < numOfShown) {
numOfShown = parameters.getTopN();
}
}
FrequencyExt[] tempFreq = handleFrequency(frequencyExt);
clearDataEntity(customerdataset);
boolean withRowCountIndicator = FrequencyTypeStateUtil.isWithRowCountIndicator(indicator);
// Added TDQ-12870
List columnKeys = TOPChartUtils.getInstance().getColumnKeys(customerdataset);
FrequencyExt freqE = tempFreq[0];
if (!columnKeys.contains(String.valueOf(freqE.getKey()))) {
// columnKeys.clear();
TOPChartUtils.getInstance().clearDataset(customerdataset);
ICustomerDataset customerDataset = TOPChartUtils.getInstance().getCustomerDataset(customerdataset);
if (customerDataset != null && customerDataset instanceof CustomerDefaultCategoryDataset) {
((CustomerDefaultCategoryDataset) customerDataset).clearAll();
}
}
for (int i = 0; i < numOfShown; i++) {
FrequencyExt freqExt = tempFreq[i];
String keyLabel = String.valueOf(freqExt.getKey());
if ("null".equals(keyLabel)) {
// $NON-NLS-1$
keyLabel = SpecialValueDisplay.NULL_FIELD;
}
if ("".equals(keyLabel)) {
// $NON-NLS-1$
keyLabel = SpecialValueDisplay.EMPTY_FIELD;
}
ChartDataEntity entity = FrequencyTypeStateUtil.createChartEntity(indicator, freqExt, keyLabel, withRowCountIndicator);
if (customerdataset instanceof CustomerDefaultCategoryDataset) {
((CustomerDefaultCategoryDataset) customerdataset).addDataEntity(entity);
addValueToDataset(((CustomerDefaultCategoryDataset) customerdataset).getDataset(), freqExt, keyLabel);
} else {
ICustomerDataset customerDataset = TOPChartUtils.getInstance().getCustomerDataset(customerdataset);
if (customerDataset != null && customerDataset instanceof CustomerDefaultCategoryDataset) {
customerDataset.addDataEntity(entity);
addValueToDataset(((CustomerDefaultCategoryDataset) customerDataset).getDataset(), freqExt, keyLabel);
}
}
}
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class PieStatisticsTableState method getDataEntity.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.preview.model.states.table.AbstractTableTypeStates#getDataEntity()
*/
@Override
public ChartDataEntity[] getDataEntity() {
List<ChartDataEntity> dataEnities = new ArrayList<ChartDataEntity>();
for (IndicatorUnit unit : units) {
if (unit.isExcuted()) {
FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
int numOfShown = PieStatisticsStateUtil.getNumberOfShown(unit, frequencyExt);
for (int i = 0; i < numOfShown; i++) {
FrequencyExt freqExt = frequencyExt[i];
ChartDataEntity entity = PieStatisticsStateUtil.createDataEntity(unit, freqExt, PieStatisticsStateUtil.getkeyLabel(freqExt));
dataEnities.add(entity);
}
}
}
return dataEnities.toArray(new ChartDataEntity[dataEnities.size()]);
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class IndicatorCommonUtil method handleFrequency.
/**
* DOC xqliu Comment method "handleFrequency".
*
* @param indicator
* @return
*/
private static Object handleFrequency(Indicator indicator) {
FrequencyExt[] frequencyExt = null;
if (UDIHelper.isUDI(indicator)) {
UserDefIndicator udi = (UserDefIndicator) indicator;
Set<Object> valueSet = udi.getDistinctValues();
if (valueSet == null) {
return null;
}
frequencyExt = new FrequencyExt[valueSet.size()];
int i = 0;
for (Object o : valueSet) {
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(o);
frequencyExt[i].setValue(udi.getCount(o));
frequencyExt[i].setFrequency(udi.getFrequency(o));
i++;
}
} else if (IndicatorEnum.DatePatternFreqIndicatorEnum.getIndicatorType().isInstance(indicator)) {
DatePatternFreqIndicator datePatternFrequency = (DatePatternFreqIndicator) indicator;
Map<String, Long> results = datePatternFrequency.getResult();
frequencyExt = new FrequencyExt[results.size()];
int i = 0;
for (String key : results.keySet()) {
Long value = results.get(key);
Double frequency = datePatternFrequency.getFrequency(key);
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(key);
frequencyExt[i].setValue(value);
frequencyExt[i].setFrequency(frequency);
i++;
}
} else {
FrequencyIndicator frequency = (FrequencyIndicator) indicator;
Set<Object> valueSet = frequency.getDistinctValues();
if (valueSet == null) {
return null;
}
frequencyExt = new FrequencyExt[valueSet.size()];
int i = 0;
for (Object o : valueSet) {
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(o);
if (IndicatorsPackage.eINSTANCE.getSoundexFreqIndicator().equals(frequency.eClass()) || IndicatorsPackage.eINSTANCE.getSoundexLowFreqIndicator().equals(frequency.eClass())) {
// MOD scorreia 2009-03-23 display distinct count when working with Soundex
frequencyExt[i].setValue(((SoundexFreqIndicator) frequency).getDistinctCount(o));
} else {
frequencyExt[i].setValue(frequency.getCount(o));
}
frequencyExt[i].setFrequency(frequency.getFrequency(o));
i++;
}
}
return frequencyExt;
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class FrequencyDynamicChartEventReceiver method handle.
@Override
public boolean handle(Object value) {
Object indValue = value;
if (value == null) {
indValue = 0;
}
if (dataset != null) {
// no sort needed here
if (indValue instanceof FrequencyExt[]) {
FrequencyExt[] frequencyExt = (FrequencyExt[]) indValue;
setFrequecyToDataset(dataset, frequencyExt, indicator);
}
}
if (tableViewer != null && dataset != null) {
TableWithData input = (TableWithData) tableViewer.getInput();
if (input != null) {
if (this.indicator instanceof ModeIndicator) {
ChartDataEntity entity = new ChartDataEntity();
entity.setIndicator(indicator);
entity.setLabel(this.indicatorName);
entity.setValue(String.valueOf(indValue));
// mode indicator has not a chart so that no dataset too
input.setEntities(new ChartDataEntity[] { entity });
} else {
ICustomerDataset customerDataset = TOPChartUtils.getInstance().getCustomerDataset(dataset);
if (customerDataset != null) {
input.setEntities((customerDataset).getDataEntities());
} else {
input.setEntities(((ICustomerDataset) dataset).getDataEntities());
}
}
}
if (!tableViewer.getTable().isDisposed()) {
tableViewer.getTable().clearAll();
tableViewer.setInput(input);
}
}
if (registerChart != TOPChartUtils.getInstance().getChartFromChartComposite(parentChartComposite)) {
restoreChart();
}
// need to refresh the parent composite of the chart to show the changes
if (!(indicator instanceof ModeIndicator)) {
EventManager.getInstance().publish(chartComposite, EventEnum.DQ_DYNAMIC_REFRESH_DYNAMIC_CHART, null);
}
return true;
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class FrequencyTableState method getDataEntity.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.preview.model.states.table.AbstractTableTypeStates#getDataEntity()
*/
@Override
public ChartDataEntity[] getDataEntity() {
List<ChartDataEntity> dataEnities = new ArrayList<ChartDataEntity>();
boolean withRowCountIndicator = isWithRowCountIndicator();
for (IndicatorUnit unit : units) {
if (unit.isExcuted()) {
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, 30);
dataEnities.add(FrequencyTypeStateUtil.createChartEntity(unit.getIndicator(), freqExt, keyLabel, withRowCountIndicator));
}
} else {
// TDQ-11422: before analysis run turn to Analysis Results page, there should show nothing data
// dataEnities.add(FrequencyTypeStateUtil.createChartEntity(unit.getIndicator(), null, null, false));
}
}
return dataEnities.toArray(new ChartDataEntity[dataEnities.size()]);
}
Aggregations