public void addLockedWorkflowInstance(WorkflowInstanceImpl lockedWorkflowInstance) { if (lockedWorkflowInstances == null) { lockedWorkflowInstances = new HashMap<>(); } lockedWorkflowInstances.put(lockedWorkflowInstance.getId(), lockedWorkflowInstance); }
public synchronized void lockWorkflowInstance(WorkflowInstanceImpl workflowInstance) { WorkflowInstanceId workflowInstanceId = workflowInstance.getId(); if (lockedWorkflowInstanceIds.contains(workflowInstanceId)) { throw new RuntimeException("Process instance "+workflowInstanceId+" is already locked"); } lockedWorkflowInstanceIds.add(workflowInstanceId); LockImpl lock = new LockImpl(); lock.setTime(Time.now()); lock.setOwner(workflowEngineId); workflowInstance.setLock(lock); if (log.isDebugEnabled()) { log.debug("Locked process instance "+workflowInstanceId); } }
public LinkedHashMap<WorkflowInstanceId, WorkflowInstanceImpl> findWorkflowInstanceMap(Collection<ObjectId> workflowInstanceIds) { LinkedHashMap<WorkflowInstanceId, WorkflowInstanceImpl> workflowInstanceMap = new LinkedHashMap<>(); if (workflowInstanceIds!=null && !workflowInstanceIds.isEmpty()) { Query query = new Query()._ids(workflowInstanceIds); DBCursor workflowInstanceCursor = workflowInstancesCollection.find("find-workflow-instance", query.get()); while (workflowInstanceCursor.hasNext()) { BasicDBObject dbWorkflowInstance = (BasicDBObject) workflowInstanceCursor.next(); WorkflowInstanceImpl workflowInstance = readWorkflowInstanceImpl(dbWorkflowInstance); workflowInstanceMap.put(workflowInstance.getId(), workflowInstance); } } return workflowInstanceMap; }
public LinkedHashMap<WorkflowInstanceId, WorkflowInstanceImpl> findWorkflowInstanceMap(Collection<ObjectId> workflowInstanceIds) { LinkedHashMap<WorkflowInstanceId, WorkflowInstanceImpl> workflowInstanceMap = new LinkedHashMap<>(); if (workflowInstanceIds!=null && !workflowInstanceIds.isEmpty()) { Query query = new Query()._ids(workflowInstanceIds); DBCursor workflowInstanceCursor = workflowInstancesCollection.find("find-workflow-instance", query.get()); while (workflowInstanceCursor.hasNext()) { BasicDBObject dbWorkflowInstance = (BasicDBObject) workflowInstanceCursor.next(); WorkflowInstanceImpl workflowInstance = readWorkflowInstanceImpl(dbWorkflowInstance); workflowInstanceMap.put(workflowInstance.getId(), workflowInstance); } } return workflowInstanceMap; }
protected void initializeTimers() { if (scope.timers!=null) { for (TimerImpl timer: scope.timers) { Job job = timer.createJob(this); job.workflowInstanceId(workflowInstance.getId()); job.activityInstanceId(getActivityInstanceId()); workflowInstance.addJob(job); // workflow.configuration // .get(JobStore.class) // .saveJob(job); } } }
/** * Starts the subworkflow instance. */ protected void startWorkflowInstance(ActivityInstanceImpl activityInstance, TriggerInstance triggerInstance) { Configuration configuration = activityInstance.getConfiguration(); WorkflowEngineImpl workflowEngine = configuration.get(WorkflowEngineImpl.class); WorkflowInstanceImpl calledWorkflowInstance = workflowEngine.startInitialize(triggerInstance); calledWorkflowInstance.addLockedWorkflowInstance(activityInstance.workflowInstance); activityInstance.setCalledWorkflowInstanceId(calledWorkflowInstance.getId()); workflowEngine.startExecute(calledWorkflowInstance); }
public void calledWorkflowInstanceEnded(final ActivityInstanceImpl callingActivityInstance, WorkflowInstanceImpl calledWorkflowInstance) { mapOutputVariables(callingActivityInstance, calledWorkflowInstance); calledWorkflowInstance.workflow.getWorkflowEngine() .send(new Message() .workflowInstanceId(callingActivityInstance.workflowInstance.getId()) .activityInstanceId(callingActivityInstance.getId()), callingActivityInstance.workflowInstance); }
@Override public void unlocked(WorkflowInstanceImpl workflowInstanceImpl) { // When the notification is received, we now check // if the workflow instance store actually is unlocked WorkflowInstanceId workflowInstanceId = workflowInstanceImpl.getId(); WorkflowInstanceQuery workflowInstanceQuery = new WorkflowInstanceQuery().workflowInstanceId(workflowInstanceId); WorkflowInstanceImpl storedWorkflowInstance = cachedConfiguration .get(WorkflowInstanceStore.class) .findWorkflowInstances(workflowInstanceQuery) .get(0); assertNull(storedWorkflowInstance.lock); String notificationMessage = "Activity "+activityInstance.activity.id+" is started "+ "and it's workflow instance unlocked"; notificationsReceived.add(notificationMessage); } }
/** convenience method to set all activity instance related properties in one go */ public Job activityInstance(ActivityInstanceImpl activityInstance) { activityInstanceId(activityInstance.getId()); workflowInstanceId(activityInstance.getWorkflowInstance().getId()); workflowId(activityInstance.getWorkflowInstance().getWorkflow().getId()); sourceWorkflowId(activityInstance.getWorkflowInstance().getWorkflow().getSourceWorkflowId()); return this; }