public static ActivityDefinitionImpl createReceiveEventActivity(final ProcessDefinitionUUID processUUID, final String name, final String eventName, final String expression) { return new ActivityDefinitionImpl(processUUID, name, Type.ReceiveEvent, null, null, null, null, eventName, expression); }
/** * Add a timer boundary event onto an activity. * * @param eventName * the name of the event. * @param condition * the condition of the timer event. * @return the ProcessBuilder in order to add BPM elements. */ public ProcessBuilder addTimerBoundaryEvent(final String eventName, final String condition) { Misc.checkArgsNotNull(eventName, condition); final Object obj = peek(ActivityDefinitionImpl.class); if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; if (canAddBoundaryEvent(activity, "timer")) { final TimerBoundaryEventImpl timer = new TimerBoundaryEventImpl(eventName, activity.getProcessDefinitionUUID(), activity.getUUID(), null, condition); activity.addBoundaryEvent(timer); push(timer); } else { problems.add(new Problem("Unable to add a boundary timer event on an activity of type: " + activity.getType(), Problem.SEVERITY_ERROR)); } } else { problems.add(new Problem("Unable to add a boundary timer event on an object of type: " + getClass(obj), Problem.SEVERITY_ERROR)); } return this; }
if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; if (activity.isTimer()) { if (!Event.onTimer.equals(event)) { problems.add(new Problem("A timer task accepts only a connector with an " + Event.onTimer + " event" + " ", Problem.SEVERITY_ERROR)); } else if (activity.isAutomatic()) { if (!(Event.automaticOnEnter.equals(event) || Event.automaticOnExit.equals(event))) { problems.add(new Problem("An automatic activity accepts only a connector with an " + Event.automaticOnEnter + " or an " + Event.automaticOnExit + " event" + " ", Problem.SEVERITY_ERROR)); } else if (activity.isSubflow()) { if (!(Event.automaticOnEnter.equals(event) || Event.automaticOnExit.equals(event))) { problems.add(new Problem("A sub process accepts only a connector with an " + Event.automaticOnEnter connector.setEvent(event); connector.setThrowingException(throwingException); activity.addConnector(connector); push(connector); } else {
if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; data = new DataFieldDefinitionImpl(activity.getProcessDefinitionUUID(), activity.getUUID(), dataName, dataTypeClassName); activity.addData(data); push(data); } else if (isProcess(obj)) {
final TransitionDefinitionImpl transition = new TransitionDefinitionImpl(process.getUUID(), transitionName, fromActivityName, toActivityName); ((ActivityDefinitionImpl) toActivity).addIncomingTransition(transition); if (boundaryEventName != null) { transition.setFromBoundaryEvent(boundaryEventName); ((ActivityDefinitionImpl) fromActivity).addExceptionTransition(boundaryEventName, transition); } else { ((ActivityDefinitionImpl) fromActivity).addOutgoingTransition(transition);
/** * Adds a connector to the current received event. * * @param className * the connector class name * @param throwingException * if the connector throws exception. * @return the ProcessBuilder in order to add BPM elements */ public ProcessBuilder addReceiveEventConnector(final String className, final boolean throwingException) { Misc.checkArgsNotNull(className); if ("".equals(className.trim())) { problems.add(new Problem("Class name is an empty string.", Problem.SEVERITY_ERROR)); } final Object obj = peek(ActivityDefinitionImpl.class); if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; final ConnectorDefinitionImpl connector = new ConnectorDefinitionImpl(className); connector.setEvent(Event.onEvent); connector.setThrowingException(throwingException); activity.addConnector(connector); push(connector); } else { problems.add(new Problem("Unable to add an event connector with class " + className + " on an object of type: " + getClass(obj), Problem.SEVERITY_ERROR)); } return this; }
/** * Adds an input parameter on the current sub-process entity. * * @param parentProcessDatafieldName * the parent process variable name * @param subProcessDatafieldName * the sub-process variable name * @return the ProcessBuilder in order to add BPM elements */ public ProcessBuilder addSubProcessInParameter(final String parentProcessDatafieldName, final String subProcessDatafieldName) { Misc.checkArgsNotNull(parentProcessDatafieldName, subProcessDatafieldName); if ("".equals(parentProcessDatafieldName.trim())) { problems.add(new Problem("Parent process datafield name is an empty string.", Problem.SEVERITY_ERROR)); } if ("".equals(subProcessDatafieldName.trim())) { problems.add(new Problem("Sub process datafield name is an empty string.", Problem.SEVERITY_ERROR)); } final Object obj = peek(ActivityDefinitionImpl.class); if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; activity.addSubflowInParameter(new SubflowParameterDefinitionImpl(parentProcessDatafieldName, subProcessDatafieldName)); } else { problems.add(new Problem("Unable to add sub process parameter {" + parentProcessDatafieldName + ", " + subProcessDatafieldName + "} on an object of type: " + getClass(obj), Problem.SEVERITY_ERROR)); } return this; }
final OutgoingEventDefinitionImpl outgoingEvent = new OutgoingEventDefinitionImpl(eventName, destProcessName, destActivityName, parameters, timeToLive); activity.addOutgoingEvent(outgoingEvent); this.outgoingEvent = outgoingEvent; } else {
deadline.setCondition(condition); deadline.setThrowingException(throwingException); activity.addDeadline(deadline); push(deadline); } else {
/** * Add a timer boundary event onto an activity. * * @param eventName * the name of the event. * @param condition * the condition of the timer event. * @return the ProcessBuilder in order to add BPM elements. */ public ProcessBuilder addTimerBoundaryEvent(final String eventName, final String condition) { Misc.checkArgsNotNull(eventName, condition); final Object obj = peek(ActivityDefinitionImpl.class); if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; if (canAddBoundaryEvent(activity, "timer")) { final TimerBoundaryEventImpl timer = new TimerBoundaryEventImpl(eventName, activity.getProcessDefinitionUUID(), activity.getUUID(), null, condition); activity.addBoundaryEvent(timer); push(timer); } else { problems.add(new Problem("Unable to add a boundary timer event on an activity of type: " + activity.getType(), Problem.SEVERITY_ERROR)); } } else { problems.add(new Problem("Unable to add a boundary timer event on an object of type: " + getClass(obj), Problem.SEVERITY_ERROR)); } return this; }
if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; if (activity.isTimer()) { if (!Event.onTimer.equals(event)) { problems.add(new Problem("A timer task accepts only a connector with an " + Event.onTimer + " event" + " ", Problem.SEVERITY_ERROR)); } else if (activity.isAutomatic()) { if (!(Event.automaticOnEnter.equals(event) || Event.automaticOnExit.equals(event))) { problems.add(new Problem("An automatic activity accepts only a connector with an " + Event.automaticOnEnter + " or an " + Event.automaticOnExit + " event" + " ", Problem.SEVERITY_ERROR)); } else if (activity.isSubflow()) { if (!(Event.automaticOnEnter.equals(event) || Event.automaticOnExit.equals(event))) { problems.add(new Problem("A sub process accepts only a connector with an " + Event.automaticOnEnter connector.setEvent(event); connector.setThrowingException(throwingException); activity.addConnector(connector); push(connector); } else {
if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; data = new DataFieldDefinitionImpl(activity.getProcessDefinitionUUID(), activity.getUUID(), dataName, dataTypeClassName); activity.addData(data); push(data); } else if (isProcess(obj)) {
final TransitionDefinitionImpl transition = new TransitionDefinitionImpl(process.getUUID(), transitionName, fromActivityName, toActivityName); ((ActivityDefinitionImpl) toActivity).addIncomingTransition(transition); if (boundaryEventName != null) { transition.setFromBoundaryEvent(boundaryEventName); ((ActivityDefinitionImpl) fromActivity).addExceptionTransition(boundaryEventName, transition); } else { ((ActivityDefinitionImpl) fromActivity).addOutgoingTransition(transition);
/** * Adds a connector to the current received event. * * @param className * the connector class name * @param throwingException * if the connector throws exception. * @return the ProcessBuilder in order to add BPM elements */ public ProcessBuilder addReceiveEventConnector(final String className, final boolean throwingException) { Misc.checkArgsNotNull(className); if ("".equals(className.trim())) { problems.add(new Problem("Class name is an empty string.", Problem.SEVERITY_ERROR)); } final Object obj = peek(ActivityDefinitionImpl.class); if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; final ConnectorDefinitionImpl connector = new ConnectorDefinitionImpl(className); connector.setEvent(Event.onEvent); connector.setThrowingException(throwingException); activity.addConnector(connector); push(connector); } else { problems.add(new Problem("Unable to add an event connector with class " + className + " on an object of type: " + getClass(obj), Problem.SEVERITY_ERROR)); } return this; }
/** * Adds an input parameter on the current sub-process entity. * * @param parentProcessDatafieldName * the parent process variable name * @param subProcessDatafieldName * the sub-process variable name * @return the ProcessBuilder in order to add BPM elements */ public ProcessBuilder addSubProcessInParameter(final String parentProcessDatafieldName, final String subProcessDatafieldName) { Misc.checkArgsNotNull(parentProcessDatafieldName, subProcessDatafieldName); if ("".equals(parentProcessDatafieldName.trim())) { problems.add(new Problem("Parent process datafield name is an empty string.", Problem.SEVERITY_ERROR)); } if ("".equals(subProcessDatafieldName.trim())) { problems.add(new Problem("Sub process datafield name is an empty string.", Problem.SEVERITY_ERROR)); } final Object obj = peek(ActivityDefinitionImpl.class); if (isActivity(obj)) { final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; activity.addSubflowInParameter(new SubflowParameterDefinitionImpl(parentProcessDatafieldName, subProcessDatafieldName)); } else { problems.add(new Problem("Unable to add sub process parameter {" + parentProcessDatafieldName + ", " + subProcessDatafieldName + "} on an object of type: " + getClass(obj), Problem.SEVERITY_ERROR)); } return this; }
final OutgoingEventDefinitionImpl outgoingEvent = new OutgoingEventDefinitionImpl(eventName, destProcessName, destActivityName, parameters, timeToLive); activity.addOutgoingEvent(outgoingEvent); this.outgoingEvent = outgoingEvent; } else {
deadline.setCondition(condition); deadline.setThrowingException(throwingException); activity.addDeadline(deadline); push(deadline); } else {
final ActivityDefinitionImpl activity = (ActivityDefinitionImpl) obj; if (canAddBoundaryEvent(activity, "error")) { final ErrorBoundaryEventImpl error = new ErrorBoundaryEventImpl(eventName, activity.getProcessDefinitionUUID(), activity.getUUID(), null, errorCode); activity.addBoundaryEvent(error); push(error); } else { problems.add(new Problem("Unable to add a boundary message event on an object of type: " + activity.getType(), Problem.SEVERITY_ERROR));
public static ActivityDefinitionImpl createSubflowActivity(final ProcessDefinitionUUID processUUID, final String name, final String subflowProcessName, final String subflowProcessVersion) { return new ActivityDefinitionImpl(processUUID, name, Type.Subflow, null, subflowProcessName, subflowProcessVersion, null, null, null); }
if (canAddBoundaryEvent(activity, "signal")) { final SignalBoundaryEventImpl message = new SignalBoundaryEventImpl(eventName, activity.getProcessDefinitionUUID(), activity.getUUID(), null, signalCode); activity.addBoundaryEvent(message); push(message); } else { problems.add(new Problem( "Unable to add a boundary message event on an activity of type: " + activity.getType(), Problem.SEVERITY_ERROR));