public ProcessStateConfiguration getProcessStateConfiguration(BpmTask task) { // HibernateTemplate ht = getHibernateTemplate(); List res = getSession().createCriteria(ProcessStateConfiguration.class) .add(Restrictions.eq("definition", task.getProcessInstance().getDefinition())) .add(Restrictions.eq("name", task.getTaskName())).list(); if (res.isEmpty()) return null; return (ProcessStateConfiguration) res.get(0); }
private BpmTask findProcessTask(String internalId,String userLogin,String bpmTaskName ) throws AperteWsWrongArgumentException{ List<BpmTask> findProcessTasks = findProcessTasks(internalId, userLogin); if(findProcessTasks.isEmpty()){ AperteWrongArgumentCodes.NOTASK.throwAperteWebServiceException(); } if(bpmTaskName == null || bpmTaskName.isEmpty()){ return findProcessTasks.get(0); } for (BpmTask bpmTaskTemp : findProcessTasks) { if(bpmTaskTemp.getTaskName().equals(bpmTaskName)){ return bpmTaskTemp; } AperteWrongArgumentCodes.BPMTASK.throwAperteWebServiceException(); } AperteWrongArgumentCodes.PROCESS.throwAperteWebServiceException(); return null; }
@Override public Collection<String> validateData(BpmTask task, boolean skipRequired) { if ("true".equals(getAttributeValue("mustAddComment"))) { //look for a fresh comment or added in this state for (ProcessComment pc : bic.getItemIds()) { if (pc.getId() == null) return null; if (task.getTaskName().equals(pc.getProcessState())) { return null; } } return Arrays.asList(getMessage("please.add.comment")); } else { return null; } }
@Override public void loadData(BpmTask task) { ProcessInstance pi = task.getProcessInstance().getRootProcessInstance(); ProcessComments comments = pi.findAttributeByClass(ProcessComments.class); if (comments != null) { List<ProcessComment> lst = new ArrayList<ProcessComment>(comments.getComments()); Collections.sort(lst, new Comparator<ProcessComment>() { @Override public int compare(ProcessComment o1, ProcessComment o2) { return -o1.getCreateTime().compareTo(o2.getCreateTime()); } }); for (ProcessComment cmt : lst) { bic.addBean(cmt); } } processState = task.getTaskName(); }
@Override public List<ProcessStateAction> processWithContext(ProcessToolContext ctx) { String state = instance.getState(); if(state==null || state.isEmpty()){//TODO its for compatibility with 1.X aperte data. In future its should be removed if(instance.getStatus().equals(ProcessStatus.NEW)){ List<BpmTask> bpmTasks = getSession(ctx).findProcessTasks(instance, ctx); state=bpmTasks.get(0).getTaskName(); } } return fetchHibernateData(ctx.getProcessStateActionDAO().getActionsBasedOnStateAndDefinitionId(state, definition.getId())); } });
@Override public List<ProcessStateAction> processWithContext(ProcessToolContext ctx) { final ProcessDefinitionConfig definition = processData.getDefinition(); String state = processData.getState(); if(state==null || state.isEmpty()){//TODO its for compatibility with 1.X aperte data. In future its should be removed if(processData.getStatus().equals(ProcessStatus.NEW)){ List<BpmTask> bpmTasks = getSession(ctx).findProcessTasks(processData, ctx); state=bpmTasks.get(0).getTaskName(); } } List<ProcessStateAction> actionsBasedOnStatus = ctx.getProcessStateActionDAO().getActionsBasedOnStateAndDefinitionId(state, definition.getId()); return actionsBasedOnStatus; } });
public static BpmTask createBpmTask(BpmTask task, String taskId) { String extractActionName = extractActionName(taskId); String actionPseudoStateName = getActionPseudoStateName(task.getTaskName(), extractActionName); ProcessStateConfiguration actionPseudoState = task.getProcessDefinition().getProcessStateConfigurationByName(actionPseudoStateName); BpmPseudoTask result = new BpmPseudoTask(task); result.setCurrentProcessStateConfiguration(actionPseudoState); result.setInternalTaskId(taskId); return result; }
String actionPseudoStateName = ActionPseudoTaskBean.getActionPseudoStateName(task.getTaskName(), actionName); ProcessStateConfiguration actionPseudoState = task.getProcessDefinition().getProcessStateConfigurationByName(actionPseudoStateName);
public BpmTask(BpmTask task) { this.assignee = task.getAssignee(); this.owner = task.getOwner(); this.taskName = task.getTaskName(); this.internalTaskId = task.getInternalTaskId(); this.executionId = task.getExecutionId(); this.createDate = task.getCreateDate(); this.finishDate = task.getFinishDate(); this.processInstance = task.getProcessInstance(); this.isFinished = task.isFinished(); }
@Override public BpmTask refreshTaskData(BpmTask task, ProcessToolContext ctx) { MutableBpmTask bpmTask = task instanceof MutableBpmTask ? (MutableBpmTask) task : new MutableBpmTask(task); bpmTask.setProcessInstance(getProcessData(task.getProcessInstance().getInternalId(), ctx)); List<Task> tasks = getProcessEngine().getTaskService().createTaskQuery() // .notSuspended() .taskName(task.getTaskName()) .executionId(task.getExecutionId()) .taskAssignee(user.getLogin()) .listPage(0, 1); if (tasks.isEmpty()) { log.warning("Task " + task.getExecutionId() + " not found"); bpmTask.setFinished(true); } return bpmTask; }
private void saveComment() { if (skipAddingComment) { return; } ProcessToolContext ctx = getCurrentContext(); 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"); } }
@Override public void evaluate(Property component, WidgetElement element) throws Exception { if (!component.isReadOnly()) { ProcessInstanceAttribute attribute = fetchOrCreateAttribute(element); if (component instanceof FileUploadComponent) { ProcessInstanceAttachmentAttribute attachment = (ProcessInstanceAttachmentAttribute) component.getValue(); if (attachment==null) return; attachment.setProcessState(task.getTaskName()); attachment.setProcessInstance(task.getProcessInstance()); attachment.setKey(attribute.getKey()); PropertyUtils.setProperty(processAttributes, element.getBind(), component.getValue()); } else if (attribute instanceof ProcessInstanceSimpleAttribute) { if (element instanceof DateWidgetElement) { String dateString = null; if (component.getValue() != null) dateString = new SimpleDateFormat(((DateWidgetElement) element).getFormat()).format(component.getValue()); ((ProcessInstanceSimpleAttribute) attribute).setValue(dateString); } else if (component.getValue() != null) { ((ProcessInstanceSimpleAttribute) attribute).setValue(component.getValue().toString()); } } else { PropertyUtils.setProperty(processAttributes, element.getBind(), component.getValue()); } } } };
processComment.setProcessState(task.getTaskName()); processComment.setBody(comment); processComment.setAuthorLogin(authorLogin);