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

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


    ProcessComment pc = dialog.getProcessComment();
        pc.setAuthor(ctx.getUserDataDAO().loadOrCreateUserByLogin(loggedUser));
        pc.setAuthorSubstitute(substitutingUser != null ? ctx.getUserDataDAO().loadOrCreateUserByLogin(substitutingUser) : null);
        pc.setCreateTime(new Date());
        pc.setProcessState(task.getTaskName());
        ProcessInstance pi = task.getProcessInstance().getRootProcessInstance();
        ProcessComments comments = pi.findAttributeByClass(ProcessComments.class);
        if (comments == null) {
            comments = new ProcessComments();
            comments.setProcessInstance(pi);
            comments.setKey(ProcessComments.class.getName());
            pi.getProcessAttributes().add(comments);
        }
        comments.getComments().add(pc);
        pc.setComments(comments);
        pi.setSimpleAttribute("commentAdded", "true");
    }
View Full Code Here


        });
    }

    private void signalDeadline(ProcessToolContext ctx, String processInstanceId, ProcessDeadline processDeadline) throws Exception {
       
      ProcessInstance pi = ctx.getProcessInstanceDAO().getProcessInstanceByInternalId(processInstanceId);
        ProcessToolBpmSession bpmSession = ctx.getProcessToolSessionFactory().createAutoSession();
        List<BpmTask> tasks = bpmSession.findProcessTasks(pi, ctx);
        for (BpmTask task : tasks) {
            if (task.getTaskName().equals(processDeadline.getTaskName())) {
                String assigneeLogin = task.getAssignee();
        Map<String, UserData> notifyUsers = prepareUsersForNotification(ctx, assigneeLogin, processDeadline);

                // everything is good, unless it’s not
        I18NSource messageSource = getI18NSource();
                ProcessStateConfiguration st = ctx.getProcessDefinitionDAO().getProcessStateConfiguration(task);
                String taskName = messageSource.getMessage(st.getDescription());

                for (UserData user : notifyUsers.values()) {
                    if (processDeadline.getSkipAssignee() != null && processDeadline.getSkipAssignee() && user.getLogin().equals(assigneeLogin)) {
                        logger.info("Skipping deadline signal for assignee: " + assigneeLogin);
                        continue;
                    }
                    Map dataModel = new HashMap();
                    dataModel.put("process", pi);
                    dataModel.put("taskName", taskName);
                    dataModel.put("processVisibleId", Strings.hasText(pi.getExternalKey()) ? pi.getExternalKey() : pi.getInternalId());
                    dataModel.put("notifiedUser", user);
                    dataModel.put("assignedUser", notifyUsers.get(assigneeLogin));

          logger.info("Signaling deadline for task: " + task.getTaskName() + " owned by: " + assigneeLogin + ", mailed to: " + user.getLogin());
         
View Full Code Here

    }

    @Override
  public void saveData(BpmTask task) {
    super.saveData(task);
    ProcessInstance pi = task.getProcessInstance();
   
    pi.setSimpleAttribute("commentAdded", "false");
  }
View Full Code Here

    private static final Logger logger = Logger.getLogger(LogStepTest.class.getName());
   
    @Test
    public void testParse() throws Exception {
        ProcessInstance process = new ProcessInstance();
        process.addAttribute(new ProcessInstanceSimpleAttribute("p1", "my-very-first-param"));
        process.addAttribute(new ProcessInstanceSimpleAttribute("p2", "second_param_123"));

        Map<String, String> properties = new HashMap<String, String>();
        properties.put("message", "${p1} and ${p2} or ${something}");

        String result = processStep(new LogStep(), process, properties);
View Full Code Here

    private String workingDays;
   
    @Override
    public String invoke(BpmStep step, Map<String, String> params) throws Exception
    {
        ProcessInstance processInstance = step.getProcessInstance();
        ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();

        List<String> taskNames = Strings.hasText(taskName) ? Arrays.asList(taskName.split(",")) : step.getOutgoingTransitions();
       
       

        Date dueDate = extractDate("dueDate", processInstance, params);
        if (dueDate == null) {
            Date baseDate = extractDate("baseDate", processInstance, params);
            if (!Strings.hasText(value)) {
                throw new ProcessToolException("Unable to calculate due date");
            }
           
            Calendar cal = Calendar.getInstance();
            cal.setTime(baseDate != null ? baseDate : new Date());
           
            if(useWorkingDays())
            {
            int nv = Integer.valueOf(Integer.valueOf(value));
            nv = getWeekOffset(cal.getTime(),nv);
            cal.add(Calendar.DAY_OF_YEAR, nv);
           
            dueDate = cal.getTime();
             
            }
            else
            {
                cal.add("min".equals(unit) ? Calendar.MINUTE : Calendar.DAY_OF_YEAR, Integer.valueOf(value));
                cal.set(Calendar.HOUR, 0);
                cal.set(Calendar.SECOND, 0);
                if (!"min".equals(unit)) {
                    cal.set(Calendar.MINUTE, 0);
                }
                dueDate = cal.getTime();
            }
        }

        for (String tn : taskNames)
        {
            String attrKey = "deadline_" + tn;
            ProcessDeadline pid = null;
            for (ProcessInstanceAttribute attr : processInstance.getProcessAttributes()) {
                if (attr.getKey() == null) {
                    logger.info("Attribute key is null! Process instance: " + processInstance.getInternalId());
                }
                if (attrKey.equals(attr.getKey())) {
                    pid = (ProcessDeadline) attr;
                    break;
                }
            }
            if (pid == null) {
                pid = new ProcessDeadline();
                pid.setKey("deadline_" + tn);
                pid.setProcessInstance(processInstance);
                processInstance.getProcessAttributes().add(pid);
            }
            pid.setProfileName(profileName);
            pid.setNotifyUsersWithLogin(notifyUsersWithLogin);
            pid.setNotifyUsersWithRole(notifyUsersWithRole);
            pid.setSkipAssignee("true".equalsIgnoreCase(skipAssignee));
View Full Code Here

        final String message = "no message here ${this-is-my-attribute}";
       
        Map<String, String> properties = new HashMap<String, String>();
        properties.put("message", message);

        String result = processStep(new LogStep(), new ProcessInstance(), properties);

        Assert.assertEquals(result, message);
    }
View Full Code Here

    }

    @Override
    public String invoke(BpmStep step, Map params) throws Exception {
        try {
            ProcessInstance processInstance = step.getProcessInstance();
            payload = params.get("payload");
            LocalMuleClient client = mulePluginManager.getMuleContext().getClient();
//            XStream xs = new XStream();
//            xs.registerConverter(new MyPersistentSetConverter(xs.getMapper()), XStream.PRIORITY_VERY_HIGH);
//            xs.omitField(ProcessInstance.class, "definition");
//            xs.omitField(ProcessInstance.class, "processLogs");
//            String input = xs.toXML(processInstance);
            if (asynchronous) {
                client.dispatch(destinationEndpointUrl, processInstance, null);
            } else {
                MuleMessage muleMessage = client.send(destinationEndpointUrl,
                                                      payload != null ? payload : processInstance,
                                                      null, timeout);
                if (muleMessage != null) {
                    ExceptionPayload exceptionPayload = muleMessage.getExceptionPayload();
                    if (exceptionPayload != null) {
                        logger.log(Level.SEVERE, "Mule step has failed: " + exceptionPayload.getMessage(), exceptionPayload.getException());
                        return "FAIL";
                    }
                    Object payload = muleMessage.getPayload();
                    if (payload instanceof String) {
                        return (String)payload;
                    } else if (payload instanceof ProcessInstanceAttribute) {
                        ProcessInstanceAttribute pia = (ProcessInstanceAttribute) payload;
                        ProcessInstanceAttribute attributeByKey = processInstance.findAttributeByKey(pia.getKey());
                        if (attributeByKey != null) {
                            processInstance.removeAttribute(attributeByKey);
                        }
                        processInstance.addAttribute(pia);
                        return pia.toString();
                    } else if (payload instanceof ProcessInstanceAttribute[]) {
                        ProcessInstanceAttribute[] pias = (ProcessInstanceAttribute[]) payload;
                        for (ProcessInstanceAttribute pia : pias) {
                            ProcessInstanceAttribute attributeByKey = processInstance.findAttributeByKey(pia.getKey());
                            if (attributeByKey != null) {
                                processInstance.removeAttribute(attributeByKey);
                            }
                            processInstance.addAttribute(pia);
                        }
                    } else if (payload instanceof Iterable) {
                        Iterable pias = (Iterable) payload;
                        for (Object o : pias) {
                            if (o instanceof ProcessInstanceAttribute) {
                                ProcessInstanceAttribute pia = (ProcessInstanceAttribute) o;
                                ProcessInstanceAttribute attributeByKey = processInstance.findAttributeByKey(pia.getKey());
                                if (attributeByKey != null) {
                                    processInstance.removeAttribute(attributeByKey);
                                }
                                processInstance.addAttribute(pia);
                            }
                        }
                    }

                }
View Full Code Here

        formProperties = form;
        compositionRoot = new VerticalLayout();

        MutableBpmTask task = new MutableBpmTask();
        task.setProcessInstance(new ProcessInstance());
        loadData(task);
        widgetsDefinitionElement = element;
        Component rendered = null;
        try {
            rendered = render();
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.