
prerna.reactor.planner.GraphPlanReactor Maven / Gradle / Ivy
The newest version!
package prerna.reactor.planner;
import static prerna.reactor.PixelPlanner.TINKER_NAME;
import static prerna.reactor.PixelPlanner.TINKER_TYPE;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import prerna.om.SEMOSSEdge;
import prerna.om.SEMOSSVertex;
import prerna.reactor.AbstractReactor;
import prerna.reactor.PixelPlanner;
import prerna.sablecc2.om.GenRowStruct;
import prerna.sablecc2.om.PixelDataType;
import prerna.sablecc2.om.ReactorKeysEnum;
import prerna.sablecc2.om.nounmeta.NounMetadata;
import prerna.util.Utility;
public class GraphPlanReactor extends AbstractReactor {
public GraphPlanReactor() {
this.keysToGet = new String[]{ReactorKeysEnum.PLANNER.getKey()};
}
@Override
public NounMetadata execute() {
Map map = createVertStores2(getPlanner());
planner.addProperty("DATA", "DATA", map);
return null;
}
private Map createVertStores2(PixelPlanner planner) {
Map vertStore = new HashMap();
Map edgeStore = new HashMap();
//get all edges
GraphTraversal edgesIt = planner.g.traversal().E();//.not(__.or(__.has(TINKER_TYPE, TINKER_FILTER), __.bothV().in().has(TINKER_TYPE, TINKER_FILTER), __.V().has(PRIM_KEY, true)));
while(edgesIt.hasNext()) {
Edge e = edgesIt.next();
Vertex outV = e.outVertex();
Vertex inV = e.inVertex();
SEMOSSVertex outVert = getSEMOSSVertex(vertStore, outV);
SEMOSSVertex inVert = getSEMOSSVertex(vertStore, inV);
String edgeString = "EDGE/"+e.property("ID").value() + "";
SEMOSSEdge semossE = new SEMOSSEdge(outVert, inVert, edgeString);
edgeStore.put(edgeString, semossE);
// need to add edge properties
Iterator> edgeProperties = e.properties();
while(edgeProperties.hasNext()) {
Property
© 2015 - 2025 Weber Informatics LLC | Privacy Policy