Search in sources :

Example 6 with GatewayType

use of de.hpi.bpt.scylla.model.process.node.GatewayType in project scylla by bptlab.

the class InclusiveGatewayEventPlugin method eventRoutine.

// @SuppressWarnings("unchecked")
@Override
public void eventRoutine(GatewayEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
    SimulationModel model = (SimulationModel) desmojEvent.getModel();
    ProcessModel processModel = processInstance.getProcessModel();
    int nodeId = desmojEvent.getNodeId();
    boolean showInTrace = desmojEvent.traceIsOn();
    GatewayType type = processModel.getGateways().get(nodeId);
    try {
        Set<Integer> idsOfNextNodes = processModel.getIdsOfNextNodes(nodeId);
        if (idsOfNextNodes.size() > 1) {
            // split
            if (type == GatewayType.INCLUSIVE) {
            // TODO this is incomplete, must find corresponding join gateway and define behavior for it
            // Map<Integer, Object> branchingDistributions = desmojObjects.getDistributionsExtensional()
            // .get(getName());
            // Map<Integer, BoolDistBernoulli> distributions = (Map<Integer, BoolDistBernoulli>)
            // branchingDistributions
            // .get(nodeId);
            // Set<Integer> idsOfNodesToBeActivated = new HashSet<Integer>();
            // for (Integer nextFlowId : distributions.keySet()) {
            // BoolDistBernoulli distribution = distributions.get(nextFlowId);
            // if (!processModel.getIdentifiers().keySet().contains(nextFlowId)) {
            // throw new ScyllaValidationException("Flow with id " + nextFlowId + " does not exist.");
            // }
            // boolean activateOutgoingFlow = distribution.sample();
            // if (activateOutgoingFlow) {
            // Set<Integer> nodeIds = processModel.getTargetObjectIds(nextFlowId);
            // if (nodeIds.size() != 1) {
            // throw new ScyllaValidationException("Flow " + nextFlowId
            // + " does not connect to 1 node, but" + nodeIds.size() + " .");
            // }
            // int nextNodeId = nodeIds.iterator().next();
            // 
            // idsOfNodesToBeActivated.add(nextNodeId);
            // }
            // // TODO default flow
            // }
            // 
            // Map<Integer, ScyllaEvent> nextEventMap = desmojEvent.getNextEventMap();
            // List<Integer> indicesOfEventsToKeep = new ArrayList<Integer>();
            // for (int index : nextEventMap.keySet()) {
            // ScyllaEvent eventCandidate = nextEventMap.get(index);
            // int nodeIdOfCandidate = eventCandidate.getNodeId();
            // if (idsOfNodesToBeActivated.contains(nodeIdOfCandidate)) {
            // indicesOfEventsToKeep.add(index);
            // }
            // }
            // Map<Integer, TimeSpan> timeSpanToNextEventMap = desmojEvent.getTimeSpanToNextEventMap();
            // nextEventMap.keySet().retainAll(indicesOfEventsToKeep);
            // timeSpanToNextEventMap.keySet().retainAll(indicesOfEventsToKeep);
            }
        }
    } catch (NodeNotFoundException | ScyllaValidationException e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        SimulationUtils.abort(model, processInstance, nodeId, showInTrace);
        return;
    }
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) ScyllaValidationException(de.hpi.bpt.scylla.exception.ScyllaValidationException) NodeNotFoundException(de.hpi.bpt.scylla.model.process.graph.exception.NodeNotFoundException) GatewayType(de.hpi.bpt.scylla.model.process.node.GatewayType) SimulationModel(de.hpi.bpt.scylla.simulation.SimulationModel)

Aggregations

ProcessModel (de.hpi.bpt.scylla.model.process.ProcessModel)6 GatewayType (de.hpi.bpt.scylla.model.process.node.GatewayType)6 ScyllaValidationException (de.hpi.bpt.scylla.exception.ScyllaValidationException)5 SimulationModel (de.hpi.bpt.scylla.simulation.SimulationModel)5 NodeNotFoundException (de.hpi.bpt.scylla.model.process.graph.exception.NodeNotFoundException)4 ArrayList (java.util.ArrayList)3 ScyllaRuntimeException (de.hpi.bpt.scylla.exception.ScyllaRuntimeException)2 EventType (de.hpi.bpt.scylla.model.process.node.EventType)2 ScyllaEvent (de.hpi.bpt.scylla.simulation.event.ScyllaEvent)2 SuspendExecution (co.paralleluniverse.fibers.SuspendExecution)1 Graph (de.hpi.bpt.scylla.model.process.graph.Graph)1 DataObjectType (de.hpi.bpt.scylla.model.process.node.DataObjectType)1 EventDefinitionType (de.hpi.bpt.scylla.model.process.node.EventDefinitionType)1 TaskType (de.hpi.bpt.scylla.model.process.node.TaskType)1 PluginWrapper (de.hpi.bpt.scylla.plugin_loader.PluginLoader.PluginWrapper)1 ProcessSimulationComponents (de.hpi.bpt.scylla.simulation.ProcessSimulationComponents)1 BPMNEndEvent (de.hpi.bpt.scylla.simulation.event.BPMNEndEvent)1 BPMNIntermediateEvent (de.hpi.bpt.scylla.simulation.event.BPMNIntermediateEvent)1 GatewayEvent (de.hpi.bpt.scylla.simulation.event.GatewayEvent)1 TaskEnableEvent (de.hpi.bpt.scylla.simulation.event.TaskEnableEvent)1