Search in sources :

Example 1 with ValueAggregator

use of org.talend.dataprofiler.service.utils.ValueAggregator in project tdq-studio-se by Talend.

the class DatasetUtils method getQueryMap.

public static Map<Integer, Object> getQueryMap(final Map<String, ValueAggregator> xyzMap, final ColumnSetMultiValueIndicator indicator, ModelElement column, Analysis analysis) {
    Map<Integer, Object> queryMap = new HashMap<Integer, Object>();
    EList<ModelElement> nominalList = indicator.getNominalColumns();
    Iterator<String> iterator = xyzMap.keySet().iterator();
    while (iterator.hasNext()) {
        final String seriesKey = iterator.next();
        final ValueAggregator valueAggregator = xyzMap.get(seriesKey);
        Iterator<Entry<MultipleKey, Double[]>> keyValueMap = valueAggregator.getKeyValueMap();
        int index = 0;
        while (keyValueMap.hasNext()) {
            Entry<MultipleKey, Double[]> next = keyValueMap.next();
            final String queryString = MultiColumnSetValueExplorer.getInstance().getQueryStirng(column, analysis, nominalList, seriesKey, next.getKey().toString());
            queryMap.put(Integer.valueOf(index++), createSelectAdapter(queryString, column, analysis));
        }
    }
    return queryMap;
}
Also used : MultipleKey(org.talend.utils.collections.MultipleKey) HashMap(java.util.HashMap) ValueAggregator(org.talend.dataprofiler.service.utils.ValueAggregator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Entry(java.util.Map.Entry)

Example 2 with ValueAggregator

use of org.talend.dataprofiler.service.utils.ValueAggregator in project tdq-studio-se by Talend.

the class DatasetUtils method fillDataset.

/**
 * Method "fillDataset" fills in the data sets.
 *
 * @param nominalColumns the nominal columns
 * @param listRows the rows (=result set)
 * @param firstNumericColumnIdx the index of the first numeric column
 * @return a map [key -> aggregated values] where identifies a level of aggregation
 */
private static Map<String, ValueAggregator> fillDataset(final List<ModelElement> nominalColumns, final List<Object[]> listRows, final int firstNumericColumnIdx) {
    Map<String, ValueAggregator> valueAggregators = new HashMap<String, ValueAggregator>();
    int xPos = firstNumericColumnIdx;
    int yPos = firstNumericColumnIdx + 1;
    int zPos = firstNumericColumnIdx + 2;
    for (int i = nominalColumns.size(); i > 0; i--) {
        String key = createKey(nominalColumns, i);
        // ADD msjian 2011-5-30 17479: Excel Odbc connection can not run well on the correlation analysis
        if (null != listRows) {
            for (Object[] row : listRows) {
                final Object xobj = row[xPos];
                final Double xValue = xobj != null ? Double.valueOf(String.valueOf(xobj)) : null;
                final Object yobj = row[yPos];
                final Double yValue = yobj != null ? Double.valueOf(String.valueOf(yobj)) : null;
                final Object zobj = row[zPos];
                final Double zValue = zobj != null ? Double.valueOf(String.valueOf(zobj)) : null;
                ValueAggregator valueAggregator = valueAggregators.get(key);
                if (valueAggregator == null) {
                    valueAggregator = new ValueAggregator();
                    valueAggregators.put(key, valueAggregator);
                }
                MultipleKey multipleKey = new MultipleKey(row, i);
                valueAggregator.addValue(multipleKey, new Double[] { xValue, yValue, zValue });
            }
        }
    }
    return valueAggregators;
}
Also used : MultipleKey(org.talend.utils.collections.MultipleKey) HashMap(java.util.HashMap) ValueAggregator(org.talend.dataprofiler.service.utils.ValueAggregator)

Example 3 with ValueAggregator

use of org.talend.dataprofiler.service.utils.ValueAggregator in project tdq-studio-se by Talend.

the class TopChartFactory method createBubbleChart.

/**
 * Method "createBubbleChart".
 *
 * @param indic the indicator
 * @param numericColumn the analyzed numeric column
 * @return the bubble chart
 */
public static JFreeChart createBubbleChart(String chartName, Object dataset, Map<String, ValueAggregator> xyzDatasets) {
    final Map<String, ValueAggregator> xyzDatasetsFinal = xyzDatasets;
    JFreeChart chart = TopChartFactory.createBubbleChart(chartName, // $NON-NLS-1$ //$NON-NLS-2$
    Messages.getString("TopChartFactory.average"), // $NON-NLS-1$ //$NON-NLS-2$
    Messages.getString("TopChartFactory.count"), // $NON-NLS-1$ //$NON-NLS-2$
    (DefaultXYZDataset) dataset, // $NON-NLS-1$ //$NON-NLS-2$
    PlotOrientation.HORIZONTAL, true, true, true);
    final XYPlot plot = (XYPlot) chart.getPlot();
    final XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator() {

        private static final long serialVersionUID = 1L;

        /*
             * (non-Javadoc)
             * 
             * @see org.jfree.chart.labels.StandardXYZToolTipGenerator#createItemArray(org.jfree.data.xy.XYZDataset,
             * int, int)
             */
        @Override
        protected Object[] createItemArray(XYZDataset dset, int series, int item) {
            final Comparable<?> seriesKey = dset.getSeriesKey(series);
            final String seriesK = String.valueOf(seriesKey);
            String label = seriesK;
            if (xyzDatasetsFinal != null) {
                ValueAggregator valueAggregator = xyzDatasetsFinal.get(seriesKey);
                label = valueAggregator.getLabels(seriesK).get(item);
            }
            final Object[] itemArray = super.createItemArray(dset, series, item);
            // label;
            itemArray[0] = label;
            // $NON-NLS-1$
            itemArray[1] = "avg=" + itemArray[1];
            // $NON-NLS-1$
            itemArray[2] = "record count=" + itemArray[2];
            // $NON-NLS-1$
            itemArray[3] = "null count=" + itemArray[3];
            return itemArray;
        }
    });
    return chart;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) ValueAggregator(org.talend.dataprofiler.service.utils.ValueAggregator) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) JFreeChart(org.jfree.chart.JFreeChart) DefaultXYZDataset(org.jfree.data.xy.DefaultXYZDataset) XYZDataset(org.jfree.data.xy.XYZDataset) Paint(java.awt.Paint) StandardXYZToolTipGenerator(org.jfree.chart.labels.StandardXYZToolTipGenerator)

Aggregations

ValueAggregator (org.talend.dataprofiler.service.utils.ValueAggregator)3 HashMap (java.util.HashMap)2 MultipleKey (org.talend.utils.collections.MultipleKey)2 Paint (java.awt.Paint)1 Entry (java.util.Map.Entry)1 JFreeChart (org.jfree.chart.JFreeChart)1 StandardXYZToolTipGenerator (org.jfree.chart.labels.StandardXYZToolTipGenerator)1 XYPlot (org.jfree.chart.plot.XYPlot)1 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)1 DefaultXYZDataset (org.jfree.data.xy.DefaultXYZDataset)1 XYZDataset (org.jfree.data.xy.XYZDataset)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1