Search in sources :

Example 1 with MultipleKey

use of org.talend.utils.collections.MultipleKey in project tdq-studio-se by Talend.

the class GraphBuilder method createVertices.

/**
 * DOC scorreia Comment method "createVertices".
 *
 * @param key2Vertex
 * @param toEdge
 * @param row
 * @param rowIdx
 * @return
 */
private Vertex[] createVertices(Map<MultipleKey, Vertex> key2Vertex, Map<MultipleKey, Edge> toEdge, Object[] row, int rowIdx) {
    // last column is the result of count(*)
    final int nbNominalColumn = row.length - 1;
    // vertices in one row
    Vertex[] verticesInRow = new Vertex[nbNominalColumn];
    for (int colIdx = 0; colIdx < nbNominalColumn; colIdx++) {
        final Object value = row[colIdx];
        Object[] key = { value, String.valueOf(colIdx) };
        MultipleKey mulkey = new MultipleKey(key, 2);
        // search for already created vertex
        Vertex myVertex = key2Vertex.get(mulkey);
        // create the new vertex
        if (myVertex == null) {
            myVertex = newVertex(key2Vertex, colIdx, value, mulkey);
            vertexWeight.setNumber(myVertex, getIntegerValue(row[nbNominalColumn]));
        } else {
            // existing vertex
            vertexWeight.setNumber(myVertex, vertexWeight.getNumber(myVertex).intValue() + getIntegerValue(row[nbNominalColumn]));
        }
        verticesInRow[colIdx] = myVertex;
    }
    for (int i = 0; i < verticesInRow.length; i++) {
        Vertex vi = verticesInRow[i];
        for (int j = 0; j < i; j++) {
            Vertex vj = verticesInRow[j];
            MultipleKey mulkey = new MultipleKey(new Object[] { vi, vj }, 2);
            Edge edge = toEdge.get(mulkey);
            if (edge == null) {
                // either allow parallel edges or avoid create a new edge when it already exists
                edge = newEdge(row, rowIdx, nbNominalColumn, vi, vj);
                toEdge.put(mulkey, edge);
            } else {
                updateEdge(edge, row, rowIdx, nbNominalColumn, vi, vj);
            }
        }
    }
    return verticesInRow;
}
Also used : MultipleKey(org.talend.utils.collections.MultipleKey) UndirectedSparseVertex(edu.uci.ics.jung.graph.impl.UndirectedSparseVertex) Vertex(edu.uci.ics.jung.graph.Vertex) UndirectedSparseEdge(edu.uci.ics.jung.graph.impl.UndirectedSparseEdge) Edge(edu.uci.ics.jung.graph.Edge)

Example 2 with MultipleKey

use of org.talend.utils.collections.MultipleKey in project tdq-studio-se by Talend.

the class ValueAggregator method addSeriesToXYZDataset.

/**
 * Method "addSeriesToXYZDataset" adds a new series of data to the given dataset.
 *
 * @param dataset a dataset
 * @param keyOfDataset the series key of the data series
 */
public void addSeriesToXYZDataset(Object dataset, String keyOfDataset, ITOPChartService chartService) {
    final int size = keyToVal.size();
    double[] xDouble = new double[size];
    double[] yDouble = new double[size];
    double[] zDouble = new double[size];
    // get x,y,z for each key
    int i = 0;
    for (MultipleKey key : keyToVal.keySet()) {
        final Double[] doubles = keyToVal.get(key);
        xDouble[i] = doubles[0];
        yDouble[i] = doubles[1];
        zDouble[i] = doubles[2];
        MultiMapHelper.addUniqueObjectToListMap(keyOfDataset, key.toString(), this.seriesKeyToLabel);
        i++;
    }
    // array of data for jfreechart
    double[][] data = new double[][] { xDouble, yDouble, zDouble };
    chartService.addSeriesToDefaultXYZDataset(dataset, keyOfDataset, data);
}
Also used : MultipleKey(org.talend.utils.collections.MultipleKey)

Example 3 with MultipleKey

use of org.talend.utils.collections.MultipleKey in project tdq-studio-se by Talend.

the class DatasetUtils method getGanttQueryMap.

/**
 * DOC yyin Comment method "getGanttQueryMap".
 *
 * @param createGannttDatasets
 * @param indicator
 * @param column
 * @param analysis
 * @return
 */
public static Map<Integer, Object> getGanttQueryMap(Map<String, DateValueAggregate> gannttMap, ColumnSetMultiValueIndicator indicator, ModelElement column, Analysis analysis) {
    Map<Integer, Object> ganttQueryMap = new HashMap<Integer, Object>();
    Iterator<String> iterator = gannttMap.keySet().iterator();
    EList<ModelElement> nominalList = indicator.getNominalColumns();
    int index = 0;
    while (iterator.hasNext()) {
        final String seriesKey = iterator.next();
        final DateValueAggregate valueAggregator = gannttMap.get(seriesKey);
        Iterator<MultipleKey> keyValueMap = valueAggregator.getKeyValueMap();
        while (keyValueMap.hasNext()) {
            MultipleKey next = keyValueMap.next();
            final String seriesLabel = next.toString();
            final String queryString = MultiColumnSetValueExplorer.getInstance().getQueryStirng(column, analysis, nominalList, seriesKey, seriesLabel);
            ganttQueryMap.put(index++, createSelectAdapter(queryString, column, analysis));
        }
    }
    return ganttQueryMap;
}
Also used : MultipleKey(org.talend.utils.collections.MultipleKey) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) HashMap(java.util.HashMap)

Example 4 with MultipleKey

use of org.talend.utils.collections.MultipleKey in project tdq-studio-se by Talend.

the class DatasetUtils method fillGanttDataset.

/**
 */
private static Map<String, DateValueAggregate> fillGanttDataset(final EList<ModelElement> nominalColumns, final List<Object[]> listRows, final int firstDateColumnIdx) {
    Map<String, DateValueAggregate> valueAggregators = new TreeMap<String, DateValueAggregate>();
    int minPos = firstDateColumnIdx;
    int maxPos = firstDateColumnIdx + 1;
    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 minObj = row[minPos];
                final Date minDate = minObj != null ? (Date) minObj : null;
                final Object maxobj = row[maxPos];
                final Date maxDate = maxobj != null ? (Date) maxobj : null;
                DateValueAggregate valueAggregator = valueAggregators.get(key);
                if (valueAggregator == null) {
                    valueAggregator = new DateValueAggregate();
                    valueAggregators.put(key, valueAggregator);
                }
                MultipleKey multipleKey = new MultipleKey(row, i);
                valueAggregator.addValue(multipleKey, new Date[] { minDate, maxDate });
            }
        }
    }
    return valueAggregators;
}
Also used : MultipleKey(org.talend.utils.collections.MultipleKey) TreeMap(java.util.TreeMap) Date(java.util.Date)

Example 5 with MultipleKey

use of org.talend.utils.collections.MultipleKey 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)

Aggregations

MultipleKey (org.talend.utils.collections.MultipleKey)6 HashMap (java.util.HashMap)3 ValueAggregator (org.talend.dataprofiler.service.utils.ValueAggregator)2 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)2 Edge (edu.uci.ics.jung.graph.Edge)1 Vertex (edu.uci.ics.jung.graph.Vertex)1 UndirectedSparseEdge (edu.uci.ics.jung.graph.impl.UndirectedSparseEdge)1 UndirectedSparseVertex (edu.uci.ics.jung.graph.impl.UndirectedSparseVertex)1 Date (java.util.Date)1 Entry (java.util.Map.Entry)1 TreeMap (java.util.TreeMap)1