cass.rollup.processors.v2.graph.collapser.NodePacketGraph Maven / Gradle / Ivy
package cass.rollup.processors.v2.graph.collapser;
import org.stjs.javascript.Array;
import org.stjs.javascript.JSCollections;
import org.stjs.javascript.Map;
import cass.rollup.processors.v2.graph.util.*;
public class NodePacketGraph {
private Array nodePacketList;
private Map nodePacketMap;
private Array relationList;
public NodePacketGraph() {
nodePacketList = new Array();
nodePacketMap = JSCollections.$map();
relationList = new Array();
}
public void initNodePacketGraph(Array nodes) {
NodePacket np;
Node n;
nodePacketList = new Array();
nodePacketMap = JSCollections.$map();
relationList = new Array();
for (int i=0;i na = packet2.getNodeList();
for (int i=0;i getNodePacketList() {return nodePacketList;}
public void setNodePacketList(Array nodePacketList) {this.nodePacketList = nodePacketList;}
public Array getRelationList() {return relationList;}
public void setRelationList(Array relationList) {this.relationList = relationList;}
public void addNodePacket(NodePacket np) {nodePacketList.push(np);}
//public boolean nodePacketHasRelations(NodePacket np) {return relationMap.containsKey(np);}
//public ArrayList getRelationListForNodePacket(NodePacket np) {return relationMap.get(np);}
public void addRelation(NodePacket sourceNodePacket, NodePacket targetNodePacket, RelationType.RELATION_TYPE relationType) {
// ArrayList packetRelationList;
// if (nodePacketHasRelations(sourceNodePacket)) packetRelationList = getRelationListForNodePacket(sourceNodePacket);
// else {
// packetRelationList = new ArrayList();
// relationMap.put(sourceNodePacket,packetRelationList);
// }
PacketRelation newPacketRelation = new PacketRelation(sourceNodePacket,targetNodePacket,relationType);
//packetRelationList.add(newPacketRelation);
relationList.push(newPacketRelation);
}
public void buildPacketRelationsFromNodeRelations(Array nodeRelationList) {
NodePacket sourceNodePacket;
NodePacket targetNodePacket;
NodeRelation nr;
for (int i=0;i> Packets: " + "\n";
NodePacket np;
for (int i=0;i 0) {
ret = ret + ">>Relationships: >" + "\n";
for (int i=0;i>NO RELATIONS EXIST!";
}
return ret;
}
//cant use StringBuffer with stjs...
// public String toStringGraphByNode() {
// String ret = "";
// for (NodePacket np:nodePacketList) {
// ret = ret + " --> " + np.toString() + "\n";
// if (nodePacketHasRelations(np)) {
// for (PacketRelation pr:getRelationListForNodePacket(np)) ret = ret + "\t\t" + pr.toString() + "\n";
// }
// else ret = ret + "\t\t---------NO RELATIONSHIPS---------" + "\n";
// }
// return ret;
// }
}