Exemplo n.º 1
0
 @FromState("Started")
 @OnMessage(performative = "QueryRef")
 @PossibleOutcome("Completed")
 public WorkflowStateConstant onQueryRef(Message msg) throws Throwable {
   traversal = getPart(msg, CONTENT);
   CopyGraphTraversal copyTraversal = null;
   if (traversal instanceof CopyGraphTraversal) copyTraversal = (CopyGraphTraversal) traversal;
   else if (traversal instanceof HyperTraversal) {
     ((HyperTraversal) traversal).setHyperGraph(getThisPeer().getGraph());
     copyTraversal = (CopyGraphTraversal) ((HyperTraversal) traversal).getFlatTraversal();
   } else throw new Exception("Expecting a CopyGraphTraversal or a HyperTraversal.");
   if (trace)
     getThisPeer()
         .getGraph()
         .getLogger()
         .trace("Recevied request for traversal : " + copyTraversal);
   ((DefaultALGenerator) copyTraversal.getAdjListGenerator()).setGraph(getThisPeer().getGraph());
   Message reply = getReply(msg, Performative.InformRef);
   Object subgraph =
       SubgraphManager.getTransferGraphRepresentation(getThisPeer().getGraph(), traversal);
   combine(reply, struct(CONTENT, subgraph));
   send(getSender(msg), reply);
   if (trace)
     getThisPeer().getGraph().getLogger().trace("Sent response to traversal : " + copyTraversal);
   return WorkflowState.Completed;
 }
Exemplo n.º 2
0
 @FromState("Started")
 @OnMessage(performative = "InformRef")
 @PossibleOutcome("Completed")
 public WorkflowStateConstant onInformRef(Message msg) throws ClassNotFoundException {
   if (trace)
     getThisPeer().getGraph().getLogger().trace("Received response for traversal : " + traversal);
   SubgraphManager.writeTransferedGraph(
       getPart(msg, CONTENT), getThisPeer().getGraph(), atomFinder);
   if (trace)
     getThisPeer().getGraph().getLogger().trace("Successfully stored graph for : " + traversal);
   return WorkflowState.Completed;
 }