Package org.jbpm.api.task

Examples of org.jbpm.api.task.Task


    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      TaskService taskService = this.processEngine.get(TaskService.class);
      Task t0 = taskService.getTask(Long.toString(taskId));
      return ModelAdaptor.adoptTask(t0);
    }
    finally{
      env.close();
    }
View Full Code Here


        }
        return action;
    }

    public void assignTask(String taskId, JahiaUser user) {
        Task task = taskService.getTask(taskId);
        if (user == null) {
            taskService.assignTask(task.getId(), null);
        } else {
            if (user.getUserKey().equals(task.getAssignee())) {
                return;
            }
            taskService.takeTask(task.getId(), user.getUserKey());
        }
    }
View Full Code Here

        if (jbpmTasks == null) {
            return Collections.emptyList();
        }

        for (HistoryTask jbpmHistoryTask : jbpmTasks) {
            final Task task = taskService.getTask(jbpmHistoryTask.getId());
            String name = "";
            if (task != null) {
                name = task != null ? task.getName() : "";
            } else {
                // So nice !
                List<HistoryActivityInstance> l = historyService.createHistoryActivityInstanceQuery().processInstanceId(jbpmHistoryTask.getExecutionId()).list();
                for (HistoryActivityInstance activityInstance : l) {
                    if (activityInstance.getStartTime().equals(jbpmHistoryTask.getCreateTime()) &&
                            activityInstance.getEndTime() != null && activityInstance.getEndTime().equals(jbpmHistoryTask.getEndTime())) {
                        name = activityInstance.getActivityName();
                        break;
                    }
                }
            }
            historyItems
                    .add(new HistoryWorkflowTask(jbpmHistoryTask.getId(), jbpmHistoryTask.getExecutionId(), name,
                            getKey(), jbpmHistoryTask.getAssignee(), jbpmHistoryTask.getCreateTime(), jbpmHistoryTask.getEndTime(),
                            jbpmHistoryTask.getOutcome()));
        }

        WorkflowDefinition def = getHistoryWorkflows(Collections.singletonList(processId), locale).get(0).getWorkflowDefinition();
        for (HistoryWorkflowTask task : historyItems) {
            ResourceBundle resourceBundle = null;
            if (locale != null) {
                resourceBundle = getResourceBundle(locale, def.getKey());
                try {
                    task.setDisplayName(
                            resourceBundle.getString(task.getName().replaceAll(" ", ".").trim().toLowerCase()));
                } catch (Exception e) {
                    task.setDisplayName(task.getName());
                }
            }
            String outcome = task.getOutcome();
            if (outcome != null) {
                String key = task.getName().replaceAll(" ", ".").trim().toLowerCase() + "." +
                        outcome.replaceAll(" ", ".").trim().toLowerCase();
                if (locale != null) {
                    String displayOutcome;
                    try {
                        displayOutcome = resourceBundle.getString(key);
                    } catch (Exception e) {
                        logger.info("Missing ressource : " + key + " in " + resourceBundle);
                        displayOutcome = outcome;
                    }
                    task.setDisplayOutcome(displayOutcome);
                }
            }
        }

View Full Code Here

    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
    try
    {
      TaskService taskService = processEngine.getTaskService();
      Task task = taskService.getTask(id);
      result = (task.getFormResourceName()!=null);
    }
    finally
    {
      env.close();
    }
View Full Code Here

    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();
  
    try
    {
      TaskService taskService = processEngine.getTaskService();
      Task task = taskService.getTask(ref.getReferenceId());

      // access the processdefition
      TaskImpl cast = ((TaskImpl) task);
      ExecutionImpl processInstance = cast.getProcessInstance();
      String processInstanceId =  processInstance.getId();
      String processId =  processInstance.getProcessDefinition().getId();

      RepositoryService repoService = processEngine.getRepositoryService();
      ProcessDefinitionQuery query = repoService.createProcessDefinitionQuery();
      query.processDefinitionId(processId);
      ProcessDefinition procDef = query.uniqueResult();

      // check if a template exists
      String name = task.getFormResourceName();
      InputStream template = repoService.getResourceAsStream(
          procDef.getDeploymentId(), name
      );

      // merge template with process variables
View Full Code Here

     * @return
     */
    public String manager()
    {
        init();
        Task task = taskService.getTask(id);
        String taskId=task.getId();
        Set<String> strSet=new HashSet<String>();
        strSet.add("owner");
        strSet.add("day");
        strSet.add("reason");
        strSet.add("name");
View Full Code Here

     * @return
     */
    public String boss()
    {
        init();
        Task task = taskService.getTask(id);
        String taskId=task.getId();
        Set<String> strSet=new HashSet<String>();
        strSet.add("owner");
        strSet.add("day");
        strSet.add("reason");
        strSet.add("name");
View Full Code Here

   *
   * @return
   */
  public String manager() {
    init();
    Task task = taskService.getTask(id);
    String taskId = task.getId();
    Set<String> strSet = new HashSet<String>();
    strSet.add("owner");
    strSet.add("day");
    strSet.add("reason");
    strSet.add("name");
View Full Code Here

   *
   * @return
   */
  public String boss() {
    init();
    Task task = taskService.getTask(id);
    String taskId = task.getId();
    Set<String> strSet = new HashSet<String>();
    strSet.add("owner");
    strSet.add("day");
    strSet.add("reason");
    strSet.add("name");
View Full Code Here

        List<Task> taskList = processEngine.execute(cmd);
        if (taskList.isEmpty()) {
            loger.warning("No tasks found in queue: " + pq.getName());
            return null;
        }
        Task task = taskList.get(0);
        Execution exec = processEngine.getExecutionService().findExecutionById(task.getExecutionId());
        String internalId = exec.getProcessInstance().getId();
        ProcessInstance pi = getProcessData(internalId, ctx);
        if (pi == null) {
            loger.warning("Process instance not found for instance id: " + internalId);
            return null;
        }

        Calendar snapshotDate = Calendar.getInstance();

        processEngine.getTaskService().assignTask(task.getId(), user.getLogin());
        task = processEngine.getTaskService().getTask(task.getId());
        if (!user.getLogin().equals(task.getAssignee())) {
            loger.warning("Task: + " + bpmTask.getExecutionId() + " not assigned to requesting user: " + user.getLogin());
            return null;
        }

        ProcessInstanceLog log = new ProcessInstanceLog();
        log.setLogType(ProcessInstanceLog.LOG_TYPE_CLAIM_PROCESS);

        ctx.getProcessInstanceDAO().saveProcessInstance(pi);
        bpmTask = collectTask(task, pi, ctx);
        log.setState(ctx.getProcessDefinitionDAO().getProcessStateConfiguration(bpmTask));
        log.setEntryDate(snapshotDate);
        log.setEventI18NKey("process.log.process-assigned");
        log.setLogValue(pq.getName());
        log.setUser(findOrCreateUser(user, ctx));
        log.setAdditionalInfo(pq.getDescription());
        log.setExecutionId(task.getExecutionId());
        log.setOwnProcessInstance(pi);
        pi.getRootProcessInstance().addProcessLog(log);

        if (!ProcessStatus.RUNNING.equals(pi.getStatus())) {
            pi.setStatus(ProcessStatus.RUNNING);
View Full Code Here

TOP

Related Classes of org.jbpm.api.task.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.