public static void executeHooks(List<JavaHook> javaHooks, XpdlExecution execution, String activityId, JavaHook.Type type) { if (javaHooks != null) { for (JavaHook javaHook : javaHooks) { if (javaHook.getType().equals(type)) { executeHook(execution, activityId, javaHook); } } } } }
@Override protected boolean executeBusinessLogic(Execution execution) { XpdlExecution xpdlExecution = (XpdlExecution) execution; if (activityType.equals(ActivityType.task)) { addTaskToRepository(taskRuntime); return false; } //noImpl must have a hook if it is not a task HookExecutor.executeHooks(javaHooks, xpdlExecution, activityId, JavaHook.Type.automaticOnEnter); return true; }
this.activityId, this.iterationId, this.activityInstanceId); try { this.userId = EngineEnvTool.getHookExecutor().executePerformerAssign( performerAssign, activityInst, this.candidates); } catch (final Exception e) {
protected void executeRoleMapper(final Performer performer) { final ClassInfo rolemapperInfo = performer.getRoleMapper(); if (rolemapperInfo != null) { final RoleMapper roleMapper = ClassDataLoader.getInstance(RoleMapper.class, this.packageUUID, rolemapperInfo); try { this.candidates = EngineEnvTool.getHookExecutor().executeRoleMapper( roleMapper, this.instanceUUID, performer.getParticipantId()); } catch (final Exception e) { throw new BonitaWrapperException( new RoleMapperInvocationException(rolemapperInfo.toString(), e) ); } } }
try { actInstDescr = EngineEnvTool.getHookExecutor() .executeMultiInstantiator(xpdlExecution, this.activityId, actInstantiator); if (actInstDescr == null) { throw new BonitaRuntimeException("MultiInstantiator execution returned null in activity " + this.activityId);
public void suspend(String userId, boolean assignTask) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Suspending task : " + taskUUID + " on activity " + activityId); } final Recorder recorder = EnvTool.getRecorder(); if (assignTask) { this.userId = userId; recorder.recordTaskAssigned(this, userId, candidates, userId); } this.stateBeforeSuspend = this.state; this.state = TaskState.SUSPENDED; recorder.recordTaskSuspended(this, userId); HookExecutor.executeHooks(activityDef.getJavaHooks(), xpdlExecution, activityId, JavaHook.Type.taskOnSuspend); }
public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) { XpdlExecution xpdlExecution = (XpdlExecution) execution; if (BODY_FINISHED.equals(signal)) { end(xpdlExecution); } else if (ACT_INSTANCE_FINISHED.equals(signal)) { xpdlExecution.setWaitingForActivityInstanceNb(xpdlExecution.getWaitingForActivityInstanceNb() - 1); if (xpdlExecution.getWaitingForActivityInstanceNb() == 0) { // TODO: cancel remaining activity instances executeSplit(xpdlExecution, false); } } else if (signal != null && deadlines != null) { for (String deadline : deadlines) { if (deadline.equals(signal)) { Authentication.setUserId("SYSTEM"); // By default, a deadline does not propagate execution xpdlExecution.waitForSignal(); String activityId = xpdlExecution.getNode().getName(); JavaHook javaHook = new JavaHook(signal, JavaHook.Type.onDeadline, true); HookExecutor.executeHook(xpdlExecution, activityId, javaHook); return; } } } }
public void resume(String resumeUserId, boolean taskAssign) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Resuming task : " + taskUUID + " on activity " + activityId); } final Recorder recorder = EnvTool.getRecorder(); if (taskAssign) { this.userId = resumeUserId; recorder.recordTaskAssigned(this, resumeUserId, candidates, resumeUserId); } this.state = this.stateBeforeSuspend; recorder.recordTaskResumed(this, resumeUserId); HookExecutor.executeHooks(activityDef.getJavaHooks(), xpdlExecution, activityId, JavaHook.Type.taskOnResume); }
public void signal(final ActivityExecution execution, final String signal, final Map<String, Object> parameters) { final XpdlExecution xpdlExecution = (XpdlExecution) execution; if (AbstractActivity.BODY_FINISHED.equals(signal)) { this.end(xpdlExecution); } else if (AbstractActivity.ACT_INSTANCE_FINISHED.equals(signal)) { xpdlExecution.setWaitingForActivityInstanceNb(xpdlExecution.getWaitingForActivityInstanceNb() - 1); if (xpdlExecution.getWaitingForActivityInstanceNb() == 0) { if (xpdlExecution.getExecutions() != null) { for (final OpenExecution execToAbort : new ArrayList<OpenExecution>(xpdlExecution.getExecutions())) { ((XpdlExecution) execToAbort).abort(); } } this.executeSplit(xpdlExecution, false); } } else if (signal != null && this.deadlines != null) { for (final String deadline : this.deadlines) { if (deadline.equals(signal)) { Authentication.setUserId(BonitaConstants.SYSTEM_USER); // By default, a deadline does not propagate execution xpdlExecution.waitForSignal(); final String activityId = xpdlExecution.getNode().getName(); final JavaHook javaHook = new JavaHook(signal, JavaHook.Type.onDeadline, true); EngineEnvTool.getHookExecutor() .executeHook(xpdlExecution, activityId, javaHook); return; } } } }
public void start(String userId, boolean assignTask) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Task : " + taskUUID + " on activity " + activityId + " is ready"); } final Recorder recorder = EnvTool.getRecorder(); if (assignTask) { this.userId = userId; recorder.recordTaskAssigned(this, userId, candidates, userId); } this.state = TaskState.EXECUTING; recorder.recordTaskStarted(this, userId); recorder.recordBodyStarted(activityDef, xpdlExecution); HookExecutor.executeHooks(activityDef.getJavaHooks(), xpdlExecution, activityId, JavaHook.Type.taskOnStart); }
@Override protected boolean executeBusinessLogic(final Execution execution) { final XpdlExecution xpdlExecution = (XpdlExecution) execution; if (this.activityType.equals(ActivityType.task)) { addTaskToRepository(getTask(xpdlExecution)); return false; } //noImpl must have a hook if it is not a task EngineEnvTool.getHookExecutor() .executeHooks(this.javaHooks, xpdlExecution, this.activityId, JavaHook.Type.automaticOnEnter); return true; }
public void finish(String userId, boolean assignTask) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Finishing task : " + taskUUID + " on activity " + activityId); } final Recorder recorder = EnvTool.getRecorder(); if (assignTask) { this.userId = userId; recorder.recordTaskAssigned(this, userId, candidates, userId); } this.state = TaskState.FINISHED; recorder.recordTaskFinished(this, EnvTool.getUserId()); HookExecutor.executeHooks(activityDef.getJavaHooks(), xpdlExecution, activityId, JavaHook.Type.taskOnFinish); activityDef.signal(xpdlExecution, AbstractActivity.BODY_FINISHED, null); this.xpdlExecution = null; }
public void ready() { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Ready task : " + taskUUID + " on activity " + activityId); } this.state = TaskState.READY; // get performer (aka participant/swimlane) Performer performer = activityDef.getPerformer(); Set<String> ar = new HashSet<String>(); //if human set userId and candidates if (performer.getParticipantType().equals(ParticipantType.HUMAN)) { this.userId = performer.getParticipantId(); ar.add(performer.getParticipantId()); this.candidates = ar; } //Only ROLE and ORGANIZATIONAL_UNIT can have Role mapper (ParticipantBinding) if (performer.getRoleMapper() != null) { mapRole(performer); } else { // no role mapper: set an empty candidates list this.candidates = ar; } // performer assignment associated to this task assign(performer); EnvTool.getRecorder().recordTaskReady(this); HookExecutor.executeHooks(activityDef.getJavaHooks(), xpdlExecution, activityId, JavaHook.Type.taskOnReady); }
); EngineEnvTool.getHookExecutor().executeHooks(this.activityDef.getJavaHooks(), this.xpdlExecution, this.activityId, JavaHook.Type.taskOnReady);
public void resume(final String resumeUserId, final boolean taskAssign) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Resuming task : " + this.taskUUID + " on activity " + this.activityId); } final Recorder recorder = EngineEnvTool.getRecorder(); if (taskAssign) { this.userId = resumeUserId; recorder.recordTaskAssigned(new TaskCurrentInfo( this.getUUID(), this.getUserId(), this.getCandidates(), this.getDueDate(), EngineEnvTool.getUserId(), this.getState() ) ); } this.state = this.stateBeforeSuspend; recorder.recordTaskResumed( new TaskCurrentInfo( this.getUUID(), this.getUserId(), this.getCandidates(), this.getDueDate(), EngineEnvTool.getUserId(), this.getState()) ); EngineEnvTool.getHookExecutor().executeHooks(this.activityDef.getJavaHooks(), this.xpdlExecution, this.activityId, JavaHook.Type.taskOnResume); }
this.getState()) ); EngineEnvTool.getHookExecutor().executeHooks(this.activityDef.getJavaHooks(), this.xpdlExecution, this.activityId, JavaHook.Type.taskOnSuspend);
this.getState()) ); EngineEnvTool.getHookExecutor().executeHooks(this.activityDef.getJavaHooks(), this.xpdlExecution, this.activityId, JavaHook.Type.taskOnFinish); this.activityDef.signal(this.xpdlExecution, AbstractActivity.BODY_FINISHED, null);
); EngineEnvTool.getHookExecutor().executeHooks(this.activityDef.getJavaHooks(), this.xpdlExecution, this.activityId, JavaHook.Type.taskOnStart);