
prerna.reactor.export.CollectGraphReactor Maven / Gradle / Ivy
The newest version!
package prerna.reactor.export;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import prerna.algorithm.api.ITableDataFrame;
import prerna.ds.export.graph.GraphExporterFactory;
import prerna.ds.export.graph.IGraphExporter;
import prerna.query.querystruct.AbstractQueryStruct;
import prerna.sablecc2.om.GenRowStruct;
import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.PixelOperationType;
import prerna.sablecc2.om.ReactorKeysEnum;
import prerna.sablecc2.om.nounmeta.NounMetadata;
public class CollectGraphReactor extends CollectReactor {
/**
* This class is responsible for collecting all graph data from a frame
*/
public CollectGraphReactor() {
this.keysToGet = new String[] {ReactorKeysEnum.FRAME.getKey()};
}
public NounMetadata execute() {
this.task = getTask();
ITableDataFrame frame = getFrame();
IGraphExporter exporter;
// check if the user has defined their own color scheme in the insight
NounMetadata graphMetadata = this.insight.getVarStore().get("GRAPH_COLORS");
if (graphMetadata != null) {
Map colorsMap = (Map) graphMetadata.getValue();
exporter = GraphExporterFactory.getExporter(frame, colorsMap);
} else {
exporter = GraphExporterFactory.getExporter(frame);
}
Map collectedData = new HashMap(7);
collectedData.put("data", exporter.getData());
Map formatMap = new HashMap();
formatMap.put("type", "GRAPH");
collectedData.put("format", formatMap);
collectedData.put("numCollected", "-1");
collectedData.put("headerInfo", getHeaderInfo(frame));
collectedData.put("taskOptions", this.task.getTaskOptions().getOptions());
collectedData.put("sortInfo", this.task.getSortInfo());
collectedData.put("filterInfo", this.task.getFilterInfo());
collectedData.put("taskId", this.task.getId());
collectedData.put("sources", getSources(frame));
NounMetadata result = new NounMetadata(collectedData, PixelDataType.FORMATTED_DATA_SET, PixelOperationType.TASK_DATA);
return result;
}
private List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy