Package pl.net.bluesoft.rnd.processtool.model

Examples of pl.net.bluesoft.rnd.processtool.model.ProcessInstance


      List<Task> processTasks = entry.getValue();

         result.addAll(new Mapcar<Task, BpmTask>(processTasks) {
           @Override
           public BpmTask lambda(Task task) {
             ProcessInstance pi = instances.get(processId);
             if (pi == null) {
               loger.warning("process " + processId + " not found");
               return null;
             }
             return collectTask(task, pi, ctx);
View Full Code Here


          
           if (bpmTask == null || bpmTask.isFinished())

               return bpmTask;
          
           ProcessInstance processInstance = bpmTask.getProcessInstance();
           ProcessInstanceLog log = addActionLogEntry(action, task, ctx);
           Map<String, Object> vars = new HashMap<String, Object>();
           vars.put("ACTION", action.getBpmName());
           processInstance.setSimpleAttribute("ACTION", action.getBpmName());
           List<String> outgoingTransitionNames = getOutgoingTransitionNames(task.getInternalTaskId(), ctx);

           ProcessEngine processEngine = getProcessEngine(ctx);

           Task bpmTaskInstance = processEngine.getTaskService().getTask(task.getInternalTaskId());
           String executionId = bpmTaskInstance.getExecutionId();


           Set<String> taskIdsBeforeCompletion = new HashSet<String>();

           pl.net.bluesoft.util.lang.Collections.collect(findProcessTasksWithUser(processInstance, ctx), new Transformer<BpmTask, String>() {

               @Override
               public String transform(BpmTask obj) {
                   return obj.getInternalTaskId()
               }
           }, taskIdsBeforeCompletion);

          
          
          if (outgoingTransitionNames.size() == 1)
              processEngine.getTaskService().completeTask(task.getInternalTaskId(), outgoingTransitionNames.get(0), vars); //BPMN2.0 style, decision is taken on the XOR gateway
          else
              processEngine.getTaskService().completeTask(task.getInternalTaskId(), action.getBpmName(), vars);
         
          broadcastEvent(ctx, new BpmEvent(BpmEvent.Type.TASK_FINISHED, task, user));
         
       /* Inform queue manager about task finish and process state change */
       ctx.getUserProcessQueueManager().onTaskFinished(task);        
  
          String processState = getProcessState(processInstance, ctx);
         
          /* Check if new subProcess is created */
          boolean startsSubprocess = updateSubprocess(processInstance, executionId, ctx);

          fillProcessAssignmentData(processEngine, processInstance, ctx);
          processInstance.setState(processState);
          if (startsSubprocess == false && processState == null && processInstance.getRunning() && !isProcessRunning(processInstance.getInternalId(), ctx)) {
              processInstance.setRunning(false);
          }
         
         
         
           if (log.getUserSubstitute() == null)
               broadcastEvent(ctx, new BpmEvent(BpmEvent.Type.SIGNAL_PROCESS, bpmTask, user));
           else
               broadcastEvent(ctx, new BpmEvent(BpmEvent.Type.SIGNAL_PROCESS, bpmTask, log.getUserSubstitute()));

           if (Strings.hasText(action.getAssignProcessStatus())) {
               String processStatus = action.getAssignProcessStatus();
               ProcessStatus ps = processStatus.length() == 1 ? ProcessStatus.fromChar(processStatus.charAt(0)) : ProcessStatus.fromString(processStatus);
               processInstance.setStatus(ps);
           }
           else
           {
             boolean isProcessRunning = processInstance.isProcessRunning();
             //boolean isProcessRunning = isProcessRunning(pi.getInternalId(), ctx);
            
             /* Process is not running and no new suprocesses are created, so process should
              * be finished by now
              */
             if(!isProcessRunning && !startsSubprocess)
             {
               broadcastEvent(ctx, new BpmEvent(BpmEvent.Type.END_PROCESS, bpmTask, user));
              
               /* Inform queue manager about process ending. Only main process is stored */
               if(!processInstance.isSubprocess())
                 ctx.getUserProcessQueueManager().onProcessFinished(processInstance, bpmTask);
              
               processInstance.setStatus(ProcessStatus.FINISHED);
             }
            
             /* Process is running or is halted, but new subprocess are created */
             else if(!isProcessRunning && startsSubprocess
             {
               broadcastEvent(ctx, new BpmEvent(BpmEvent.Type.PROCESS_HALTED, bpmTask, user));
              
               /* Inform queue manager about process halt */
               ctx.getUserProcessQueueManager().onProcessHalted(processInstance, bpmTask);
              
               processInstance.setStatus(ProcessStatus.RUNNING);
             }
             else
             {
               processInstance.setStatus(ProcessStatus.RUNNING);
             }
           }
          
           ctx.getProcessInstanceDAO().saveProcessInstance(processInstance);

           BpmTask userTask = null;

           BpmTask autoSkipTask = null;
          
           /* Is process finished */
           boolean isProcessFinished = processInstance.getStatus().equals(ProcessStatus.FINISHED);
           boolean isSubProcess = processInstance.getParent() != null;

           List<BpmTask> tasksAfterCompletion = null;
           if(startsSubprocess && processInstance.getChildren() != null) {
             for(ProcessInstance child : processInstance.getChildren()) {
               tasksAfterCompletion = findProcessTasks(child, ctx);
               if(tasksAfterCompletion != null && tasksAfterCompletion.size() > 0)
                 break;
             }
           }
           if(tasksAfterCompletion == null || tasksAfterCompletion.size() == 0) {
               tasksAfterCompletion = findProcessTasks(processInstance, ctx);
           }
           if(processInstance.getParent() != null && (tasksAfterCompletion == null || tasksAfterCompletion.size() == 0)) {
               tasksAfterCompletion = findProcessTasks(processInstance.getParent(), ctx);
           }
           if(tasksAfterCompletion != null) {
             for (BpmTask createdTask : tasksAfterCompletion) {
                 if (!taskIdsBeforeCompletion.contains(createdTask.getInternalTaskId()))
                 {
                     broadcastEvent(ctx, new BpmEvent(BpmEvent.Type.ASSIGN_TASK, createdTask, user));
                    
                 /* Inform queue manager about task assigne */
                 ctx.getUserProcessQueueManager().onTaskAssigne(createdTask);
                 }
                 if (Lang.equals(user.getId(), createdTask.getOwner().getId())) {
                     userTask = createdTask;
                 }
                 if(createdTask.getTaskName().toLowerCase().startsWith(AUTO_SKIP_TASK_NAME_PREFIX.toLowerCase())) {
                   autoSkipTask = createdTask;
                 }
             }
           }
          
           if(autoSkipTask != null) {
             ProcessStateAction skipAction = new ProcessStateAction();
             skipAction.setBpmName(AUTO_SKIP_ACTION_NAME);
             return performAction(skipAction, autoSkipTask, ctx);
           }
          
           /* Task assigned to queue */
           if (userTask == null)
           {
             /* Process is finished, ask about parent process queues */
             if(isProcessFinished && isSubProcess)
               processInstance = processInstance.getParent();
            
             /* Get task assigned to queues */
             Collection<BpmTask> queueTasks = getProcessTaskInQueues(ctx, processInstance);
            
             for(BpmTask queueTask: queueTasks)
View Full Code Here

          String processDefinitionId = subprocess.getProcessDefinitionId().replaceFirst("-\\d+$", "");
          ProcessDefinitionConfig config = ctx.getProcessDefinitionDAO().getActiveConfigurationByKey(
              processDefinitionId);

          /* Create new instance of parent process' subprocess */
          ProcessInstance subProcessInstance = createSubprocessInstance(config, ctx, parentPi, "parent_process", subprocess.getId());
           
          long subPiId = ctx.getProcessInstanceDAO().saveProcessInstance(subProcessInstance);
         
          executionService.createVariable(subprocess.getId(), "processInstanceId", String.valueOf(subPiId),
              false);
View Full Code Here

                                    logger.info("SVG request");

                                    ProcessToolBpmSession session = ctx.getProcessToolSessionFactory()
                                            .createSession(new UserData("admin", "admin@aperteworkflow.org", "Admin admin"),
                                                    new ArrayList<String>());
                                    ProcessInstance pi = session.getProcessData(rr.getParameter("svg"), ctx);
                                    List<GraphElement> processHistory = session.getProcessHistory(pi);
//                                    final StringBuffer svg = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
                                    final StringBuffer svg = new StringBuffer("<html><body style=\"margin:0; padding:0\">\n\n");
                                   
                                    final byte[] png = session.getProcessMapImage(pi);
                                    if (png != null) {
                                        BufferedImage read;
                                        try {
                                            read = ImageIO.read(new ByteArrayInputStream(png));
                                            ResourceURL resourceURL = resp.createResourceURL();
                                            resourceURL.setParameter("instanceId", pi.getInternalId());
                                            String url = resourceURL.toString();
                                            url = StringEscapeUtils.escapeXml(url);
                                            svg.append(String.format("<svg xmlns=\"http://www.w3.org/2000/svg\"\n" + "   viewBox='0 0 %d %d'  " +
                                                    "     xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
                                                    read.getWidth(),
View Full Code Here

        Component res = impl != null ? impl.createTaskPaneProcessId(params) : null;
        if (res != null) {
            return res;
        }

       ProcessInstance pi = params.getProcessInstance();
       return createOpenProcessInstanceButton(getProcessId(pi), getTaskPaneStyleName(params), params, false);
     }
View Full Code Here

        Component res = impl != null ? impl.getQueuePane(params) : null;
        if (res != null) {
            return res;
        }

    final ProcessInstance pi = params.getProcessInstance();
    Panel p = new Panel(getQueuePaneHeader(params));
    VerticalLayout vl = new VerticalLayout();
    Component titleLabel = createQueuePaneTitle(params);
    HorizontalLayout hl = horizontalLayout("100%", titleLabel);
    hl.setExpandRatio(titleLabel, 1.0f);
    vl.addComponent(hl);

    Component button = createQueuePaneAssignButton(params);
    Component comment = createQueuePaneStateCommentary(params);
    vl.addComponent(horizontalLayout(comment, button));

    Component processInfo = createQueuePaneProcessInfo(params);
    if (processInfo != null) {
      vl.addComponent(processInfo);
    }

    vl.setWidth("100%");
    if (pi.getKeyword() != null) {
      vl.addComponent(createQueuePaneKeyword(params));
    }
    if (pi.getDescription() != null) {
      vl.addComponent(createQueuePaneDescription(params));
    }
    p.setWidth("100%");
    p.addComponent(vl);
    return p;
View Full Code Here

       for (final String processId : tasksByProcessId.keySet()) {
         List<Task> processTasks = tasksByProcessId.get(processId);
         result.addAll(new Mapcar<Task, BpmTask>(processTasks) {
           @Override
           public BpmTask lambda(Task task) {
             ProcessInstance pi = instances.get(processId);
             if (pi == null) {
               log.warning("process " + processId + " not found");
               return null;
             }
             return collectTask(task, pi, ctx);
View Full Code Here

     }

    @Override
    public BpmTask getPastOrActualTask(ProcessInstanceLog log, ProcessToolContext ctx) {
        final UserData user = log.getUser();
        final ProcessInstance pi = log.getProcessInstance();
        final Calendar minDate = log.getEntryDate();
        final Set<String> taskNames = new HashSet<String>();
        if (log.getState() != null && Strings.hasText(log.getState().getName())) {
            taskNames.add(log.getState().getName());
        }

        HistoryService hs = getProcessEngine().getHistoryService();

        HistoricTaskInstanceQuery q = hs.createHistoricTaskInstanceQuery()
                .taskAssignee(user.getLogin())
                .processInstanceId(pi.getInternalId());
        if (!taskNames.isEmpty()) //TODO what if there is > 1 task. Activiti API does not support such operation (e.g. in clause in SQL)?
            q = q.taskName(taskNames.iterator().next());

        q = q.orderByHistoricTaskInstanceEndTime().asc();
View Full Code Here



    @Override
    public BpmTask getPastEndTask(ProcessInstanceLog log, ProcessToolContext ctx) {
        final ProcessInstance pi = log.getProcessInstance();
       String endTaskName = findEndActivityName(pi, ctx);
       if (Strings.hasText(endTaskName)) {
           MutableBpmTask t = new MutableBpmTask();
           t.setProcessInstance(pi);
           t.setAssignee(user.getLogin());
View Full Code Here

        final Map<String, ProcessInstance> instances = ctx.getProcessInstanceDAO().getProcessInstanceByInternalIdMap(ids);
        return new Mapcar<Task, ProcessInstance>(taskList) {

            @Override
            public ProcessInstance lambda(Task task) {
                ProcessInstance pi = instances.get(task.getProcessInstanceId());
                if (pi == null) {
                    log.warning("process " + task.getProcessInstanceId() + " not found");
                    return null;
                }
                pi.setState(task.getName());
                pi.setTaskId(task.getId());
                return pi;
            }
        }.go();
    }
View Full Code Here

TOP

Related Classes of pl.net.bluesoft.rnd.processtool.model.ProcessInstance

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.