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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations