public void afterCompletion(int status) { synchronizationRegistered = false; if ( !Contexts.isEventContextActive() ) { //in calls to MDBs and remote calls to SBs, the //transaction doesn't commit until after contexts //are destroyed, so wait until the transaction //completes before closing the session //on the other hand, if we still have an active //event context, leave it open closeContext(); } }
protected JbpmContext getJbpmContext() { return ManagedJbpmContext.instance(); }
@Unwrap public JbpmContext getJbpmContext() throws NamingException, RollbackException, SystemException { joinTransaction(); return jbpmContext; }
@Create public void create() throws NamingException, RollbackException, SystemException { jbpmContext = Jbpm.instance().getJbpmConfiguration().createJbpmContext(); assertNoTransactionManagement(); log.debug( "created seam managed jBPM context"); }
private List<TaskInstance> getTaskInstanceList(String actorId) { if ( actorId == null ) return null; return ManagedJbpmContext.instance().getTaskList(actorId); }
@Destroy public void destroy() { if ( !synchronizationRegistered ) { //in requests that come through SeamPhaseListener, //there can be multiple transactions per request, //but they are all completed by the time contexts //are dstroyed //so wait until the end of the request to close //the session //on the other hand, if we are still waiting for //the transaction to commit, leave it open closeContext(); } }
private Map<String,List<TaskInstance>> getTaskInstanceList(String actorId) { if ( actorId == null ) return null; Map<String, List<TaskInstance>> map = new HashMap<String, List<TaskInstance>>(); List<TaskInstance> taskInstances = ManagedJbpmContext.instance().getTaskList(actorId); for ( TaskInstance task: taskInstances ) { String name = task.getName(); List<TaskInstance> list = map.get(name); if (list==null) { list = new ArrayList<TaskInstance>(); map.put(name, list); } list.add(task); } return map; }
/** * Create a process instance and associate it with the * current conversation. * * @param processDefinitionName the jBPM process definition name */ public void createProcess(String processDefinitionName, boolean shouldSignalProcess) { ProcessInstance process = ManagedJbpmContext.instance().newProcessInstanceForUpdate(processDefinitionName); afterCreateProcess(processDefinitionName, process, shouldSignalProcess); }
private List<TaskInstance> getTaskInstanceList(String actorId) { if ( actorId == null ) return null; return ManagedJbpmContext.instance().getSession() .createCriteria(TaskInstance.class) .add( Restrictions.eq("actorId", actorId) ) .add( Restrictions.eq("isOpen", true) ) .add( Restrictions.ne("isSuspended", true) ) .addOrder( Order.asc("priority") ) .setCacheable(true) .list(); }
/** * @return the TaskInstance with the id passed * in the request parameter named "taskId". */ @Transactional public TaskInstance getTaskInstance() { String[] values = Parameters.instance().getRequestParameters().get("taskId"); if ( values==null || values.length!=1 ) { return null; } else { String taskId = values[0]; return taskId==null ? null : ManagedJbpmContext.instance().getTaskInstanceForUpdate( Long.parseLong(taskId) ); } }
@Override protected org.jbpm.taskmgmt.exe.TaskInstance work() throws Exception { Long taskId = BusinessProcess.instance().getTaskId(); if (taskId!=null) { //TODO: do we need to cache this?? return ManagedJbpmContext.instance().getTaskInstanceForUpdate(taskId); } else { return null; } }
@Unwrap @Transactional public List<TaskInstance> getPooledTaskInstanceList() { Actor actor = Actor.instance(); String actorId = actor.getId(); if ( actorId == null ) return null; ArrayList groupIds = new ArrayList( actor.getGroupActorIds() ); groupIds.add(actorId); return ManagedJbpmContext.instance().getGroupTaskList(groupIds); }
/** * Create a process instance and associate it with the * current conversation. * * @param processDefinitionName the jBPM process definition name * @param businessKey the business key of the new process definition */ public void createProcess(String processDefinitionName, String businessKey) { /*ProcessInstance process = ManagedJbpmContext.instance().getGraphSession() .findLatestProcessDefinition(processDefinitionName) .createProcessInstance(Collections.EMPTY_MAP, businessKey);*/ ProcessInstance process = ManagedJbpmContext.instance().newProcessInstanceForUpdate(processDefinitionName); process.setKey(businessKey); afterCreateProcess(processDefinitionName, process, true); }
@Override protected org.jbpm.graph.exe.ProcessInstance work() throws Exception { Long processId = BusinessProcess.instance().getProcessId(); if (processId!=null) { //TODO: do we need to cache this?? //return ManagedJbpmContext.instance().getProcessInstanceForUpdate(processId); //JBSEAM-4629: return ManagedJbpmContext.instance().getProcessInstance(processId); } else { return null; } }
/** * Associate the process instance with the given business key * with the current conversation. * * @param processDefinition the jBPM process definition name * @param key the jBPM process instance key * @return true if the process was found and was not ended */ public boolean resumeProcess(String processDefinition, String key) { ProcessDefinition definition = ManagedJbpmContext.instance().getGraphSession().findLatestProcessDefinition(processDefinition); ProcessInstance process = definition==null ? null : ManagedJbpmContext.instance().getProcessInstanceForUpdate(definition, key); if (process!=null) setProcessId( process.getId() ); return afterResumeProcess(key, process); }
@Factory(value="org.jboss.seam.bpm.processInstanceList", autoCreate=true) @Transactional public List<ProcessInstance> getProcessInstanceList() { Criteria query = ManagedJbpmContext.instance().getSession() .createCriteria(ProcessInstance.class); if ( processInstanceEnded!=null ) { query.add( processInstanceEnded ? isNotNull("end") : isNull("end") ); } if (processDefinitionName!=null) { query.createCriteria("processDefinition") .add( Restrictions.eq("name", processDefinitionName) ); } query = query.createCriteria("rootToken"); if (sortDescending!=null) { query.addOrder( sortDescending ? desc("nodeEnter") : asc("nodeEnter") ); } if (nodeName!=null) { query.createCriteria("node") .add( Restrictions.eq("name", nodeName) ); } return query.list(); }