diff --git a/jbpt-bp/.classpath b/jbpt-bp/.classpath index a021f04a..8e73acc4 100644 --- a/jbpt-bp/.classpath +++ b/jbpt-bp/.classpath @@ -15,12 +15,12 @@ - + - + diff --git a/jbpt-bp/.settings/org.eclipse.jdt.core.prefs b/jbpt-bp/.settings/org.eclipse.jdt.core.prefs index 107056a3..62492222 100644 --- a/jbpt-bp/.settings/org.eclipse.jdt.core.prefs +++ b/jbpt-bp/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/jbpt-bpm/.classpath b/jbpt-bpm/.classpath index f41f2312..dec76317 100644 --- a/jbpt-bpm/.classpath +++ b/jbpt-bpm/.classpath @@ -1,30 +1,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jbpt-bpm/.settings/org.eclipse.core.resources.prefs b/jbpt-bpm/.settings/org.eclipse.core.resources.prefs index b0b81519..13fec6c3 100644 --- a/jbpt-bpm/.settings/org.eclipse.core.resources.prefs +++ b/jbpt-bpm/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 encoding//src/main/java=Cp1252 encoding//src/main/resources=Cp1252 +encoding//src/test/java=Cp1252 encoding/=Cp1252 diff --git a/jbpt-bpm/.settings/org.eclipse.jdt.core.prefs b/jbpt-bpm/.settings/org.eclipse.jdt.core.prefs index 107056a3..62492222 100644 --- a/jbpt-bpm/.settings/org.eclipse.jdt.core.prefs +++ b/jbpt-bpm/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/Event.java b/jbpt-bpm/src/main/java/org/jbpt/pm/Event.java index d6547c3e..5ebe1670 100644 --- a/jbpt-bpm/src/main/java/org/jbpt/pm/Event.java +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/Event.java @@ -8,6 +8,12 @@ */ public class Event extends FlowNode { + public enum EventType { + RECEIVING,SENDING + } + + private EventType type; + /** * Creates a new {@link Event} with an empty name. */ @@ -23,4 +29,12 @@ public Event (String name){ super(name); } + public EventType getType() { + return type; + } + + public void setType(EventType type) { + this.type = type; + } + } diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/IEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/IEvent.java index 44fc7d56..510188f8 100644 --- a/jbpt-bpm/src/main/java/org/jbpt/pm/IEvent.java +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/IEvent.java @@ -1,5 +1,7 @@ package org.jbpt.pm; + + /** * Basic interface for process model events. * @@ -7,5 +9,4 @@ * */ public interface IEvent extends IFlowNode { - } diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/Bpa.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/Bpa.java new file mode 100644 index 00000000..fab57365 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/Bpa.java @@ -0,0 +1,100 @@ +package org.jbpt.pm.bpa; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.jbpt.pm.ControlFlow; +import org.jbpt.pm.FlowNode; +import org.jbpt.pm.ProcessModel; + +public class Bpa extends ProcessModel implements IBpa { + + private String name; + private String organisation; + private String shapeId; + + public Bpa() { + + } + + @Override + public Bpa clone() { + Bpa clone = (Bpa) super.clone(); + clone.setName(this.name); + clone.setOrganisation(this.organisation); + clone.setShapeId(this.shapeId); + + return clone; + } + + private void setShapeId(String shapeId) { + this.shapeId = shapeId; + } + + @Override + public ControlFlow addControlFlow(FlowNode from, FlowNode to, + float probability) { + ControlFlow flow; + if (from instanceof IEvent && + to instanceof IEvent && + ((IEvent)from).getEnclosingProcess().equals(((IEvent) to).getEnclosingProcess())) { + // both events are enclosed by the same BPA process -> internal flow + flow = new InternalFlow<>(this, from, to, probability); + } else { + // all other cases -> external flow + flow = new ExternalFlow(this, from, to, probability); + } + + // link flow nodes to model + from.setModel(this); + to.setModel(this); + Set set = new HashSet(); + set.add(flow.getSource()); + set.add(flow.getTarget()); + this.edges.put(flow, set); + + return flow; + } + + @SuppressWarnings("unchecked") + public Collection getAllProcesses() { + return (Collection) this.filter(BpaProcess.class); + } + + public String getCanvasId() { + return shapeId; + } + + public void setCanvasId(String id) { + this.shapeId = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOrganisation() { + return organisation; + } + + public void setOrganisation(String organisation) { + this.organisation = organisation; + } + + /* (non-Javadoc) + * @see org.jbpt.pm.bpa.IBpa#getAllEvents() + */ + @SuppressWarnings("unchecked") + @Override + public Collection getAllEvents() { + return (Collection) this.filter(Event.class); + } + + +} + diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/BpaFactory.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/BpaFactory.java new file mode 100644 index 00000000..ffe50929 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/BpaFactory.java @@ -0,0 +1,387 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.jbpt.pm.AndGateway; +import org.jbpt.pm.ControlFlow; +import org.jbpt.pm.FlowNode; +import org.jbpt.pm.Gateway; +import org.jbpt.pm.XorGateway; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public class BpaFactory { + + public class BpaFactoryException extends Exception { + + private static final long serialVersionUID = 6630921591700525682L; + + public BpaFactoryException(String message){ + super(message); + } + } + + public enum EventType { + START_EVENT(StartEvent.class), + END_EVENT(EndEvent.class), + INTERMEDIATE_THROWING_EVENT(IntermediateThrowingEvent.class), + INTERMEDIATE_CATCHING_EVENT(IntermediateCatchingEvent.class); + + private Class typeClass; + + EventType(Class type) { + this.typeClass = type; + } + + public Class getType() { + return this.typeClass; + } + } + + private Bpa bpa; + private Map objects; + + public BpaFactory(String name, String organisation) { + this.bpa = new Bpa(); + this.bpa.setOrganisation(organisation); + this.bpa.setName(name); + } + + public String createEvent(String name, String processId, int[] mulitplicity, EventType type) throws BpaFactoryException { + try { + Constructor constructor = type.getType().getConstructor(String.class, BpaProcess.class, int[].class); + BpaProcess process = getObject(processId); + FlowNode event = (FlowNode) constructor.newInstance(name, process, mulitplicity); + if (this.bpa.addFlowNode(event) == null) + throw new BpaFactoryException(String.format("Cannot add event %s", event)); + return addObject(event); + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + throw new BpaFactoryException("Cannot invoke constructor of Bpa"); + } + } + + public String createProcess(String name, String resourceId) throws BpaFactoryException { + BpaProcess process = new BpaProcess(name, resourceId); + if (this.bpa.addNonFlowNode(process) == null) + throw new BpaFactoryException(String.format("Cannot add process %s", process)); + return addObject(process); + } + + public String createProcess(String name) throws BpaFactoryException { + return createProcess(name, UUID.randomUUID().toString()); + } + + public void correctMultiplicity(String eventId, int[] multiplicity) { + Event event = (Event) getObjects().get(eventId); + event.setMultiplicity(multiplicity); + } + + /** + * Fill a BPA process with events, all at once, from first to last + * @param processId + * @param eventIds + * @throws BpaFactoryException + */ + public void fillProcess(String processId, String... eventIds) throws BpaFactoryException { + BpaProcess process = getObject(processId); + // first event must be start event + StartEvent start = getObject(eventIds[0]); + if (start == null) + throw new BpaFactoryException("Cannot find start event"); + process.addEvent(start); + + for (int i = 1; i < eventIds.length; i++) { + if (i == eventIds.length - 1) { + // last must be end event + EndEvent endEvent = getObject(eventIds[i]); + process.addEvent(endEvent); + Event penultimateEvent = getObject(eventIds[i - 1]); + if (this.bpa.addControlFlow(penultimateEvent, endEvent) == null) + throw new BpaFactoryException(String.format("Cannot add flow %s to %s", penultimateEvent, endEvent)); + } else { + Event event = getObject(eventIds[i]); + process.addEvent((IEvent) event); + Event precedingEvent = getObject(eventIds[i - 1]); + if (this.bpa.addControlFlow(precedingEvent, event) == null) + throw new BpaFactoryException(String.format("Cannot add flow %s to %s", precedingEvent, event)); + } + } + } + + public void createControlFlow(String sourceId, String targetId) throws BpaFactoryException { + SendingEvent source = getObject(sourceId); + ReceivingEvent target = getObject(targetId); + + addNewFlow(source, target); + + Collection> targetFlows = this.bpa.getEdgesWithTarget(target); + + if ((target instanceof StartEvent && targetFlows.size() == 2) || + (target instanceof IntermediateCatchingEvent && targetFlows.size() == 3)) { + // event has now multiple predecessors (start event 2 inputs; intermediate 1 internal and 2 external) + correctControlFlowOnReceivingSide(target, targetFlows); + } else if (targetFlows.size() == 0) { + // our newly added flow is not there at all + throw new BpaFactoryException(String.format("Cannot find flow from %s to %s", source, target)); + } + } + + /** + * Checks if a collector net on the target has to be added, or + * if an edge has to be attached to an existing collector net + * @param target + * @param targetFlows + * @throws BpaFactoryException + */ + private void correctControlFlowOnReceivingSide(ReceivingEvent target, + Collection> targetFlows) + throws BpaFactoryException { + XorGateway gateway = null; + ControlFlow probablyNewFlow = null; + + for (ControlFlow flow : targetFlows) { + if (flow.getSource() instanceof XorGateway && + // collector net on the receiving side + (this.bpa.getDirectPredecessors(flow.getSource()).size() > 1)) + gateway = (XorGateway) flow.getSource(); + else + // if the other flow is a collector net, this must be the flow we just added + // if the other flow is no collector net, this variable contains rubbish + probablyNewFlow = flow; + } + + if (gateway == null) { + // no collector net present + createCollectorNet(targetFlows, target); + } else { + // collector net present + FlowNode flowSource = probablyNewFlow.getSource(); + if (this.bpa.removeControlFlow(probablyNewFlow) == null) + throw new BpaFactoryException(String.format("Cannot remove flow from %s to %s", flowSource, target)); + if (this.bpa.addControlFlow(flowSource, gateway) == null) + throw new BpaFactoryException(String.format("Cannot add flow from %s to %s", flowSource, gateway)); + } + } + + /** + * @param source + * @param target + * @throws BpaFactoryException + */ + private void addNewFlow(SendingEvent source, ReceivingEvent target) + throws BpaFactoryException { + Collection> outgoingEdges = this.bpa.getEdgesWithSource(source); + ControlFlow externalFlow = getExternalFlow(outgoingEdges); + + if (externalFlow == null) { + // no external flow yet + ControlFlow flow = this.bpa.addControlFlow(source, target); + if (flow == null) + throw new BpaFactoryException(String.format("Flow creation failed %s to %s", source, target)); + } else { + FlowNode flowTarget = externalFlow.getTarget(); + if (flowTarget instanceof Event || + // a collector net on the receiving side + ((flowTarget instanceof Gateway) && this.bpa.getDirectPredecessors(flowTarget).size() > 1)) { + createSplitterNet(source, externalFlow, (Event) externalFlow.getTarget(), target); + } else if (externalFlow.getTarget() instanceof Gateway) { + // already a gateway on my side + connectToGateway((Gateway) externalFlow.getTarget(), target, false); + } else { + throw new BpaFactoryException(String.format("Unexpected object encountered: %s", externalFlow.getTarget())); + } + } + } + + /** + * @param targetFlows + * @param source + * @param target + * @throws BpaFactoryException + */ + private void createCollectorNet( + Collection> targetFlows, ReceivingEvent target) throws BpaFactoryException { + XorGateway xorGateway = new XorGateway(); + if (this.bpa.addFlowNode(xorGateway) == null) { + throw new BpaFactoryException(String.format("Cannot add gateway %s", xorGateway)); + } + if (this.bpa.addControlFlow(xorGateway, target) == null) { + throw new BpaFactoryException(String.format("Cannot add control flow from %s to %s", xorGateway, target)); + } + + for (ControlFlow flow : targetFlows) { + FlowNode source = flow.getSource(); + if (this.bpa.addControlFlow(source, xorGateway) == null) { + throw new BpaFactoryException(String.format("Cannot add control flow from %s to %s", source, xorGateway)); + } + if (this.bpa.removeControlFlow(flow) == null) { + throw new BpaFactoryException(String.format("Cannot remove flow from %s to %s", source, target)); + } + } + } + + /** + * Connects an additional target event to an existing gateway + * @param gateway + * @param target + * @throws BpaFactoryException + */ + private void connectToGateway(Gateway gateway, FlowNode target, boolean failSilent) throws BpaFactoryException { + ControlFlow flow = this.bpa.addControlFlow(gateway, target); + if (flow == null && !failSilent) + throw new BpaFactoryException(String.format("Flow creation failed %s to %s", gateway, target)); + } + + /** + * @param source + * @param externalFlow + * @param target + * @param target2 + * @throws BpaFactoryException + */ + private void createSplitterNet(FlowNode source, + ControlFlow externalFlow, Event oldTarget, FlowNode additionalTarget) throws BpaFactoryException { + AndGateway gateway = new AndGateway(); + + // remove existing flow to old target + if (this.bpa.removeControlFlow(externalFlow) == null) + throw new BpaFactoryException(String.format("Cannot remove existent flow %s to %s", source, oldTarget)); + + // add gateway + if (this.bpa.addFlowNode(gateway) == null) + throw new BpaFactoryException(String.format("Cannot add gateway")); + + // connect events + if (this.bpa.addControlFlow(source, gateway) == null) + throw new BpaFactoryException(String.format("Cannot add flow %s to gateway", source)); + if (this.bpa.addControlFlow(gateway, oldTarget) == null) + throw new BpaFactoryException(String.format("Cannot add flow gateway to %s", oldTarget)); + if (this.bpa.addControlFlow(gateway, additionalTarget) == null) + throw new BpaFactoryException(String.format("Cannot add flow gateway to %s", additionalTarget)); + } + + /** + * Searches a collection of flows for the first occurence of an + * external flow. + * @param outgoingEdges + * @return + */ + private ExternalFlow getExternalFlow( + Collection> outgoingEdges) { + for (ControlFlow flow : outgoingEdges) { + if (flow instanceof ExternalFlow) { + return (ExternalFlow) flow; + } + } + return null; + } + + /** + * Sets occurrence of flows between multiple pair of events as exclusive. + * Works transitive, but redundant adding of flows is harmless: + * + * and is exclusive, + * and is exclusive, + * -> and also exclusive + * + * BUT: explicit adding of and is harmless + * @param flows + * @throws BpaFactoryException + */ + public void makeFlowsExclusive(String source, String... targets) throws BpaFactoryException { + SendingEvent event = getObject(source); + Gateway andGateway = getGateway(this.bpa.getDirectSuccessors(event)); + + if (andGateway == null || !(andGateway instanceof AndGateway)) + throw new BpaFactoryException(String.format("Cannot find and gateway in succeeding position of %s", event)); + + Gateway xorGateway = getGateway(this.bpa.getDirectSuccessors(andGateway)); + + if (xorGateway == null) { + xorGateway = new XorGateway(); + this.bpa.addFlowNode(xorGateway); + this.bpa.addControlFlow(andGateway, xorGateway); + + // remove old connections from and gateway to event + // and add new from xor gateway to event + for (String target : targets) { + ReceivingEvent receivingEvent = getObject(target); + disconnectFromGateway(andGateway, receivingEvent, false); + connectToGateway(xorGateway, receivingEvent, false); + } + } else if (xorGateway instanceof XorGateway) { + // move edges from and gateway to xor gateway + for (String target : targets) { + ReceivingEvent receivingEvent = getObject(target); + disconnectFromGateway(andGateway, receivingEvent, true); + connectToGateway(xorGateway, receivingEvent, false); + } + } else { + throw new BpaFactoryException(String.format("Encountered unexpected gateway %s", xorGateway)); + } + } + + /** + * @param andGateway + * @param receivingEvent + * @throws BpaFactoryException + */ + private void disconnectFromGateway(Gateway andGateway, + ReceivingEvent receivingEvent, boolean failSilent) throws BpaFactoryException { + if (this.bpa.removeControlFlow(this.bpa.getDirectedEdge(andGateway, receivingEvent)) == null && !failSilent) + throw new BpaFactoryException(String.format("Cannot find control flow from and to %s", receivingEvent)); + } + + /** + * Finds first gateway in a flow node collection + * @param succesors + * @return + */ + private Gateway getGateway(Collection successors) { + for (FlowNode successor : successors) { + if (successor instanceof Gateway) + return (Gateway) successor; + } + return null; + } + + /** + * Returns a new BPA instance + * when called. + * + * @return Bpa + */ + public Bpa getBpa() { + return this.bpa; + } + + private String addObject(Object object) { + String id = UUID.randomUUID().toString(); + getObjects().put(id, object); + return id; + } + + private Map getObjects() { + if (this.objects == null) { + this.objects = new HashMap(); + } + return this.objects; + } + + @SuppressWarnings("unchecked") + private V getObject(String id) { + return (V) getObjects().get(id); + } + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/BpaProcess.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/BpaProcess.java new file mode 100644 index 00000000..d574f85e --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/BpaProcess.java @@ -0,0 +1,44 @@ +package org.jbpt.pm.bpa; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.jbpt.pm.NonFlowNode; + +public class BpaProcess extends NonFlowNode implements IBpaProcess { + + List events = new ArrayList(); + private String shapeId; + + /** + * @param name + * @param description + */ + public BpaProcess(String name, String resourceId) { + super(name); + this.shapeId = resourceId; + } + + public List getEvents() { + return events; + } + + public void addEvent(IEvent e) { + events.add(e); + } + + public void addEvents(List events) { + events.addAll(events); + } + + public UUID getUid() { + //TODO: probably unnecessary + return UUID.fromString(super.getId()); + } + + public String getShapeId() { + return shapeId; + } + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/EndEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/EndEvent.java new file mode 100644 index 00000000..2a256b88 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/EndEvent.java @@ -0,0 +1,29 @@ +/** + * + */ +package org.jbpt.pm.bpa; + + + + +/** + * @author rami.eidsabbagh + * + */ +public class EndEvent extends SendingEvent implements IEndEvent { + + /** + * @param label + * @param mult + */ + public EndEvent(String label, BpaProcess enclosingProcess, int[] mult) { + super(label, enclosingProcess, mult); + } + + /** + * @param label + */ + public EndEvent(String label, BpaProcess enclosingProcess) { + super(label, enclosingProcess); + } +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/Event.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/Event.java new file mode 100644 index 00000000..ec7af801 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/Event.java @@ -0,0 +1,69 @@ +package org.jbpt.pm.bpa; + +import org.jbpt.pm.IEvent; + +/** + * @author rami.eidsabbagh + * + */ +public abstract class Event extends org.jbpt.pm.Event implements IEvent { + + private int[] multiplicity; + private BpaProcess enclosingProcess; + + //protected static Map ids = new HashMap(); + //protected static Integer maxId = 0; + + + public Event clone() { + Event clone = (Event) super.clone(); + clone.setMultiplicity(this.multiplicity); + clone.setEnclosingProcess((BpaProcess) this.enclosingProcess.clone()); + return clone; + } + + public void setEnclosingProcess(BpaProcess enclosingProcess) { + this.enclosingProcess = enclosingProcess; + } + + public Event(String label, BpaProcess enclosingProcess, int[] mult){ + super(label); + this.enclosingProcess = enclosingProcess; + this.multiplicity = mult; + } + + /** + * Constructor with trivial multiplicity. + * @param bpid + * @param label + */ + public Event (String label, BpaProcess enclosingProcess) { + this(label, enclosingProcess, new int[]{1}); + } + + // replaced by setName() in GObject, so far not called + public void setLabel(String newlabel){ + super.setName(newlabel); + } + + public String getLabel(){ + return super.getName(); + } + + public void setMultiplicity(int[] mult){ + this.multiplicity = mult; + } + + public int[] getMultiplicity(){ + return this.multiplicity; + } + + public boolean hasTrivialMultiplicity() { + return (multiplicity.length == 1 && multiplicity[0] == 1); + + } + + public BpaProcess getEnclosingProcess() { + return enclosingProcess; + } +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ExternalFlow.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ExternalFlow.java new file mode 100644 index 00000000..2918f9c5 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ExternalFlow.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import org.jbpt.graph.abs.AbstractDirectedGraph; +import org.jbpt.pm.ControlFlow; +import org.jbpt.pm.FlowNode; + +/** + * @author Dexter + * + */ +public class ExternalFlow extends ControlFlow implements IExternalFlow { + + /** + * @param graph + * @param from + * @param to + * @param probability + */ + public ExternalFlow(AbstractDirectedGraph graph, V from, V to, + float probability) { + super(graph, from, to, probability); + // TODO Auto-generated constructor stub + } + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IBpa.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IBpa.java new file mode 100644 index 00000000..a70493f6 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IBpa.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import java.util.Collection; + +import org.jbpt.pm.ControlFlow; +import org.jbpt.pm.FlowNode; +import org.jbpt.pm.IProcessModel; +import org.jbpt.pm.NonFlowNode; + +/** + * Interface for BPA + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IBpa extends IProcessModel, FlowNode, NonFlowNode> { + + public ControlFlow addControlFlow(FlowNode from, FlowNode to); + + public ControlFlow addControlFlow(FlowNode from, FlowNode to, float probability); + + public Collection getAllProcesses(); + + public Collection getAllEvents(); + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IBpaProcess.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IBpaProcess.java new file mode 100644 index 00000000..95677bd6 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IBpaProcess.java @@ -0,0 +1,22 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import java.util.List; + +import org.jbpt.pm.INonFlowNode; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IBpaProcess extends INonFlowNode { + + /** + * Returns all events inside of this BPA Process + * @return Collection of events + */ + public List getEvents(); + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IEndEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IEndEvent.java new file mode 100644 index 00000000..c3a72b1d --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IEndEvent.java @@ -0,0 +1,12 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IEndEvent extends ISendingEvent { + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IEvent.java new file mode 100644 index 00000000..a6b18120 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IEvent.java @@ -0,0 +1,23 @@ +/** + * + */ +package org.jbpt.pm.bpa; + + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IEvent extends org.jbpt.pm.IEvent { + + public void setEnclosingProcess(BpaProcess enclosingProcess); + + public void setMultiplicity(int[] mult); + + public int[] getMultiplicity(); + + public boolean hasTrivialMultiplicity(); + + public BpaProcess getEnclosingProcess(); + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IExternalFlow.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IExternalFlow.java new file mode 100644 index 00000000..0e30726d --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IExternalFlow.java @@ -0,0 +1,15 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import org.jbpt.pm.IControlFlow; +import org.jbpt.pm.IFlowNode; + +/** + * @author Dexter + * + */ +public interface IExternalFlow extends IControlFlow { + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IIntermediateCatchingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IIntermediateCatchingEvent.java new file mode 100644 index 00000000..279dc00f --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IIntermediateCatchingEvent.java @@ -0,0 +1,12 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IIntermediateCatchingEvent extends IReceivingEvent { + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IIntermediateThrowingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IIntermediateThrowingEvent.java new file mode 100644 index 00000000..0a006632 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IIntermediateThrowingEvent.java @@ -0,0 +1,12 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IIntermediateThrowingEvent extends ISendingEvent { + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IInternalFlow.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IInternalFlow.java new file mode 100644 index 00000000..0d9886ef --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IInternalFlow.java @@ -0,0 +1,15 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import org.jbpt.pm.IControlFlow; +import org.jbpt.pm.IFlowNode; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IInternalFlow extends IControlFlow { + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IReceivingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IReceivingEvent.java new file mode 100644 index 00000000..1245fcd9 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IReceivingEvent.java @@ -0,0 +1,16 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import java.util.Collection; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IReceivingEvent extends IEvent { + + public Collection getPreset(); + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ISendingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ISendingEvent.java new file mode 100644 index 00000000..109e43cd --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ISendingEvent.java @@ -0,0 +1,18 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import java.util.Collection; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface ISendingEvent extends IEvent { + + public Collection getPostset(); + + public Collection getConflictSet(); + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IStartEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IStartEvent.java new file mode 100644 index 00000000..2c70224e --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IStartEvent.java @@ -0,0 +1,14 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public interface IStartEvent extends IReceivingEvent { + + public boolean isInitialPlace(); + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IntermediateCatchingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IntermediateCatchingEvent.java new file mode 100644 index 00000000..eb47e941 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IntermediateCatchingEvent.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.jbpt.pm.bpa; + + +/** + * @author rami.eidsabbagh + * + */ +public class IntermediateCatchingEvent extends ReceivingEvent implements IReceivingEvent { + + /** + * @param label + * @param mult + */ + public IntermediateCatchingEvent(String label, BpaProcess enclosingProcess, int[] mult) { + super(label, enclosingProcess, mult); + } + + /** + * @param label + */ + public IntermediateCatchingEvent(String label, BpaProcess enclosingProcess) { + super(label, enclosingProcess); + } + +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IntermediateThrowingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IntermediateThrowingEvent.java new file mode 100644 index 00000000..b58a0f88 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/IntermediateThrowingEvent.java @@ -0,0 +1,27 @@ +/** + * + */ +package org.jbpt.pm.bpa; + + +/** + * @author rami.eidsabbagh + * + */ +public class IntermediateThrowingEvent extends SendingEvent implements IIntermediateThrowingEvent { + + /** + * @param label + * @param mult + */ + public IntermediateThrowingEvent(String label, BpaProcess enclosingProcess, int[] mult) { + super(label, enclosingProcess, mult); + } + + /** + * @param label + */ + public IntermediateThrowingEvent(String label, BpaProcess enclosingProcess) { + super(label, enclosingProcess); + } +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/InternalFlow.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/InternalFlow.java new file mode 100644 index 00000000..c9271961 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/InternalFlow.java @@ -0,0 +1,27 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import org.jbpt.graph.abs.AbstractDirectedGraph; +import org.jbpt.pm.ControlFlow; +import org.jbpt.pm.IFlowNode; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public class InternalFlow extends ControlFlow implements IInternalFlow { + + /** + * @param graph + * @param from + * @param to + * @param probability + */ + public InternalFlow(AbstractDirectedGraph graph, V from, V to, + float probability) { + super(graph, from, to, probability); + } + // TODO: implement validator +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ReceivingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ReceivingEvent.java new file mode 100644 index 00000000..1729c5d9 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/ReceivingEvent.java @@ -0,0 +1,48 @@ +/** + * + */ +package org.jbpt.pm.bpa; + +import java.util.Collection; +import java.util.LinkedList; + +import org.jbpt.pm.FlowNode; + +/** + * @author rami.eidsabbagh + * + */ +public abstract class ReceivingEvent extends Event implements IReceivingEvent { + + /** + * @param label + * @param mult + */ + public ReceivingEvent(String label, BpaProcess enclosingProcess, int[] mult) { + super(label, enclosingProcess, mult); + } + + /** + * @param label + */ + public ReceivingEvent(String label, BpaProcess enclosingProcess) { + super(label, enclosingProcess); + } + + public Collection getPreset(){ + Collection predecessors = this.getModel().getDirectPredecessors(this); + Collection processEvents = this.getEnclosingProcess().getEvents(); + Collection preset = new LinkedList(); + + // filter events that are not inside of my process + for (FlowNode predecessor : predecessors) { + if (predecessor instanceof ISendingEvent) { + if (!processEvents.contains((IEvent)predecessor)) { + preset.add((ISendingEvent)predecessor); + } + } + } + + return preset; + } +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/SendingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/SendingEvent.java new file mode 100644 index 00000000..f6ba4c5e --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/SendingEvent.java @@ -0,0 +1,78 @@ +package org.jbpt.pm.bpa; + +import java.util.Collection; +import java.util.LinkedList; + +import org.jbpt.pm.FlowNode; +import org.jbpt.pm.XorGateway; + +/** + * @author rami.eidsabbagh + * + */ +public abstract class SendingEvent extends Event implements ISendingEvent { + + Collection postset; + + /** + * @param label + * @param mult + */ + public SendingEvent(String label, BpaProcess enclosingProcess, int[] mult) { + super(label, enclosingProcess, mult); + } + + /** + * @param label + */ + public SendingEvent(String label, BpaProcess enclosingProcess) { + super(label, enclosingProcess); + } + + public Collection getPostset() { + if (this.postset == null) { + this.postset = calculatePostset(new LinkedList(), this); + } + return this.postset; + } + + private Collection calculatePostset(Collection postset, FlowNode node) { + if (node instanceof IReceivingEvent) { + if (!this.getEnclosingProcess().getEvents().contains((IEvent) node)) + postset.add((IReceivingEvent)node); + return postset; + } else { + for (FlowNode successorNode : this.getModel().getDirectSuccessors(node)) { + calculatePostset(postset, successorNode); + } + return postset; + } + } + + @Override + public Collection getConflictSet() { + Collection directSuccessors = getModel().getDirectSuccessors(getModel().getDirectSuccessors(this)); + XorGateway xor = null; + for (FlowNode flowNode : directSuccessors) { + if (flowNode instanceof XorGateway) { + xor = (XorGateway) flowNode; + break; + } + } + + Collection conflictSet = new LinkedList(); + + if (xor != null) { + for (FlowNode node : getModel().getDirectSuccessors(xor)) { + if (node instanceof ReceivingEvent) { + conflictSet.add((IReceivingEvent) node); + } else { + // next element can only be a receiving event according to BPA definition + conflictSet.add((IReceivingEvent) getModel().getDirectSuccessors(node).iterator().next()); + } + } + } + + return conflictSet; + } +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/StartEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/StartEvent.java new file mode 100644 index 00000000..2881d0f3 --- /dev/null +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpa/StartEvent.java @@ -0,0 +1,40 @@ +/** + * + */ +package org.jbpt.pm.bpa; + + + + +/** + * @author rami.eidsabbagh + * + */ +public class StartEvent extends ReceivingEvent implements IStartEvent { + + + /** + * @param label + * @param mult + */ + public StartEvent(String label, BpaProcess enclosingProcess, int[] mult) { + super(label, enclosingProcess, mult); + } + + /** + * @param label + */ + public StartEvent(String label, BpaProcess enclosingProcess) { + super(label, enclosingProcess); + } + + /** + * Checks whether this StartEvent is an initial place, ie. whether + * is has no incoming triggers. In this case its place in the + * PetriNet representation is marked. + * @return + */ + public boolean isInitialPlace() { + return (getPreset() == null || getPreset().isEmpty()); + } +} diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/BpmnControlFlow.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/BpmnControlFlow.java index 4a7b01c4..e3d03120 100644 --- a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/BpmnControlFlow.java +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/BpmnControlFlow.java @@ -9,8 +9,6 @@ import java.util.Set; import org.jbpt.graph.abs.AbstractDirectedGraph; -import org.jbpt.graph.abs.IDirectedEdge; -import org.jbpt.hypergraph.abs.IVertex; import org.jbpt.pm.ControlFlow; import org.jbpt.pm.IDataNode; import org.jbpt.pm.IFlowNode; @@ -46,7 +44,6 @@ public BpmnControlFlow(AbstractDirectedGraph g, V source, V target) { super(g, source, target); } - @SuppressWarnings("unchecked") @Override public void addReadDocument(IDataNode document) { this.readDocuments.add(document); @@ -65,7 +62,6 @@ public void addUnspecifiedDocument(IDataNode document) { this.unspecifiedDocuments.add(document); } - @SuppressWarnings("unchecked") @Override public void addWriteDocument(IDataNode document) { this.writeDocuments.add(document); diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/CatchingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/CatchingEvent.java index 48a0ba58..af02c7da 100644 --- a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/CatchingEvent.java +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/CatchingEvent.java @@ -15,6 +15,7 @@ public class CatchingEvent extends BpmnEvent implements ICatchingEvent{ */ public CatchingEvent() { super(); + setType(EventType.RECEIVING); } /** @@ -22,6 +23,7 @@ public CatchingEvent() { */ public CatchingEvent(String name) { super(name); + setType(EventType.RECEIVING); } } diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/EndEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/EndEvent.java index 304b7858..d4787efc 100644 --- a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/EndEvent.java +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/EndEvent.java @@ -12,6 +12,7 @@ public class EndEvent extends BpmnEvent implements IEndEvent{ */ public EndEvent() { super(); + setType(EventType.SENDING); } /** @@ -20,5 +21,6 @@ public EndEvent() { */ public EndEvent(String name) { super(name); + setType(EventType.SENDING); } } diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/StartEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/StartEvent.java index e4106bd3..c347f91c 100644 --- a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/StartEvent.java +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/StartEvent.java @@ -3,6 +3,7 @@ */ package org.jbpt.pm.bpmn; + /** * Class for BPMN Start Event. * @@ -16,6 +17,7 @@ public class StartEvent extends BpmnEvent implements IStartEvent{ */ public StartEvent() { super(); + setType(EventType.RECEIVING); } /** @@ -24,6 +26,7 @@ public StartEvent() { */ public StartEvent(String name) { super(name); + setType(EventType.RECEIVING); } } diff --git a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/ThrowingEvent.java b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/ThrowingEvent.java index 3afd2345..3d8ffd05 100644 --- a/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/ThrowingEvent.java +++ b/jbpt-bpm/src/main/java/org/jbpt/pm/bpmn/ThrowingEvent.java @@ -15,6 +15,7 @@ public class ThrowingEvent extends BpmnEvent implements IThrowingEvent { */ public ThrowingEvent() { super(); + setType(EventType.SENDING); } /** @@ -22,6 +23,7 @@ public ThrowingEvent() { */ public ThrowingEvent(String name) { super(name); + setType(EventType.SENDING); } } diff --git a/jbpt-core/.classpath b/jbpt-core/.classpath index 4f49d1fb..bb4ae148 100644 --- a/jbpt-core/.classpath +++ b/jbpt-core/.classpath @@ -1,22 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jbpt-core/.settings/org.eclipse.core.resources.prefs b/jbpt-core/.settings/org.eclipse.core.resources.prefs index a11b325e..2c2aa474 100644 --- a/jbpt-core/.settings/org.eclipse.core.resources.prefs +++ b/jbpt-core/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 encoding//src/main/java=Cp1252 +encoding//src/test/java=Cp1252 encoding/=Cp1252 diff --git a/jbpt-core/.settings/org.eclipse.jdt.core.prefs b/jbpt-core/.settings/org.eclipse.jdt.core.prefs index 107056a3..62492222 100644 --- a/jbpt-core/.settings/org.eclipse.jdt.core.prefs +++ b/jbpt-core/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/jbpt-deco/.classpath b/jbpt-deco/.classpath index b332afcc..607aff54 100644 --- a/jbpt-deco/.classpath +++ b/jbpt-deco/.classpath @@ -1,23 +1,27 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jbpt-deco/.settings/org.eclipse.core.resources.prefs b/jbpt-deco/.settings/org.eclipse.core.resources.prefs index a11b325e..2c2aa474 100644 --- a/jbpt-deco/.settings/org.eclipse.core.resources.prefs +++ b/jbpt-deco/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 encoding//src/main/java=Cp1252 +encoding//src/test/java=Cp1252 encoding/=Cp1252 diff --git a/jbpt-deco/.settings/org.eclipse.jdt.core.prefs b/jbpt-deco/.settings/org.eclipse.jdt.core.prefs index 107056a3..62492222 100644 --- a/jbpt-deco/.settings/org.eclipse.jdt.core.prefs +++ b/jbpt-deco/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/jbpt-petri/.classpath b/jbpt-petri/.classpath index 4592f469..95e47de6 100644 --- a/jbpt-petri/.classpath +++ b/jbpt-petri/.classpath @@ -1,24 +1,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jbpt-petri/.settings/org.eclipse.core.resources.prefs b/jbpt-petri/.settings/org.eclipse.core.resources.prefs index a11b325e..2c2aa474 100644 --- a/jbpt-petri/.settings/org.eclipse.core.resources.prefs +++ b/jbpt-petri/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 encoding//src/main/java=Cp1252 +encoding//src/test/java=Cp1252 encoding/=Cp1252 diff --git a/jbpt-petri/.settings/org.eclipse.jdt.core.prefs b/jbpt-petri/.settings/org.eclipse.jdt.core.prefs index 107056a3..62492222 100644 --- a/jbpt-petri/.settings/org.eclipse.jdt.core.prefs +++ b/jbpt-petri/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/jbpt-test/src/test/java/org/jbpt/test/bparc/BparcFactoryTest.java b/jbpt-test/src/test/java/org/jbpt/test/bparc/BparcFactoryTest.java new file mode 100644 index 00000000..901499d2 --- /dev/null +++ b/jbpt-test/src/test/java/org/jbpt/test/bparc/BparcFactoryTest.java @@ -0,0 +1,94 @@ +/** + * + */ +package org.jbpt.test.bparc; + +import org.jbpt.pm.bpa.Bpa; +import org.jbpt.pm.bpa.BpaFactory; +import org.jbpt.pm.bpa.BpaFactory.BpaFactoryException; +import org.jbpt.pm.bpa.BpaFactory.EventType; +import org.junit.Assert; +import org.junit.Test; + + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public class BparcFactoryTest { + + private static final String NAME = "name"; + private static final String ORGANISATION = "organisation"; + + private static final String PROCESS_NAME_1 = "p1"; + private static final String PROCESS_RESSOURCE_ID_1 = "id1"; + private static final String PROCESS_NAME_2 = "p2"; + private static final String PROCESS_RESSOURCE_ID_2 = "id2"; + private static final String PROCESS_NAME_3 = "p3"; + private static final String PROCESS_RESSOURCE_ID_3 = "id3"; + + private static final String EVENT_NAME_1 = "e1"; + private static final String EVENT_NAME_2 = "e2"; + private static final String EVENT_NAME_3 = "e3"; + private static final String EVENT_NAME_4 = "e4"; + private static final String EVENT_NAME_5 = "e5"; + private static final String EVENT_NAME_6 = "e6"; + private static final String EVENT_NAME_8 = "e8"; + private static final String EVENT_NAME_7 = "e7"; + + @Test(expected = ClassCastException.class) + public void createBparcProcessTest() throws BpaFactoryException { + BpaFactory factory = new BpaFactory(NAME, ORGANISATION); + String p1 = factory.createProcess(PROCESS_NAME_1, PROCESS_RESSOURCE_ID_1); + String e2 = factory.createEvent(EVENT_NAME_2, p1, new int[]{1}, EventType.END_EVENT); + factory.fillProcess(p1, e2); + } + + @Test + public void createBparcTest() throws BpaFactoryException { + BpaFactory factory = new BpaFactory(NAME, ORGANISATION); + String p1 = factory.createProcess(PROCESS_NAME_1, PROCESS_RESSOURCE_ID_1); + String e1 = factory.createEvent(EVENT_NAME_1, p1, new int[]{1}, BpaFactory.EventType.START_EVENT); + String e2 = factory.createEvent(EVENT_NAME_2, p1, new int[]{1}, EventType.END_EVENT); + factory.fillProcess(p1, e1, e2); + + verify(factory.getBpa(), 1, 2, 0); + + String p2 = factory.createProcess(PROCESS_NAME_2, PROCESS_RESSOURCE_ID_2); + String e3 = factory.createEvent(EVENT_NAME_3, p2, new int[]{1}, BpaFactory.EventType.START_EVENT); + String e5 = factory.createEvent(EVENT_NAME_5, p2, new int[]{1}, BpaFactory.EventType.INTERMEDIATE_THROWING_EVENT); + String e4 = factory.createEvent(EVENT_NAME_4, p2, new int[]{1}, EventType.END_EVENT); + factory.fillProcess(p2, e3, e5, e4); + factory.createControlFlow(e2, e3); + + verify(factory.getBpa(), 2, 5, 0); + + String p3 = factory.createProcess(PROCESS_NAME_3, PROCESS_RESSOURCE_ID_3); + String e6 = factory.createEvent(EVENT_NAME_6, p2, new int[]{1}, BpaFactory.EventType.START_EVENT); + String e7 = factory.createEvent(EVENT_NAME_7, p2, new int[]{1}, BpaFactory.EventType.INTERMEDIATE_CATCHING_EVENT); + String e8 = factory.createEvent(EVENT_NAME_8, p2, new int[]{1}, EventType.END_EVENT); + factory.fillProcess(p3, e6, e7, e8); + factory.createControlFlow(e2, e6); + + verify(factory.getBpa(), 3, 8, 1); + + factory.makeFlowsExclusive(e2, e3, e6); + + verify(factory.getBpa(), 3, 8, 2); + + factory.createControlFlow(e5, e7); + + verify(factory.getBpa(), 3, 8, 2); + + factory.createControlFlow(e8, e3); + + verify(factory.getBpa(), 3, 8, 3); + } + + private void verify(Bpa bparc, int processes, int events, int gateways) { + Assert.assertEquals(processes, bparc.getAllProcesses().size()); + Assert.assertEquals(events, bparc.getAllEvents().size()); + Assert.assertEquals(gateways, bparc.getGateways().size()); + } + +} diff --git a/jbpt-test/src/test/java/org/jbpt/test/bparc/BparcTest.java b/jbpt-test/src/test/java/org/jbpt/test/bparc/BparcTest.java new file mode 100644 index 00000000..b0c44df6 --- /dev/null +++ b/jbpt-test/src/test/java/org/jbpt/test/bparc/BparcTest.java @@ -0,0 +1,30 @@ +/** + * + */ +package org.jbpt.test.bparc; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public class BparcTest { + + @Test + public void addControlFlowTest() { + Assert.fail(); + } + + @Test + public void getAllEventsTest() { + Assert.fail(); + } + + @Test + public void getAllProcesses() { + Assert.fail(); + } + +} diff --git a/jbpt-test/src/test/java/org/jbpt/test/bparc/EventTest.java b/jbpt-test/src/test/java/org/jbpt/test/bparc/EventTest.java new file mode 100644 index 00000000..27843f59 --- /dev/null +++ b/jbpt-test/src/test/java/org/jbpt/test/bparc/EventTest.java @@ -0,0 +1,34 @@ +/** + * + */ +package org.jbpt.test.bparc; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Robert Breske and Marcin Hewelt + * + */ +public class EventTest { + + @Test + public void getPresetTest() { + Assert.fail(); + } + + @Test + public void getPostsetTest() { + Assert.fail(); + } + + @Test + public void getConflictSetTest() { + Assert.fail(); + } + + @Test + public void getMultiplicityTest() { + Assert.fail(); + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy