@Override protected IAttributesConsumer getConsumer() { return task.getProcessInstance(); }
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); }
@Override public void saveData(BpmTask task) { task.getProcessInstance().getRootProcessInstance().setSimpleAttribute("markedImportant", String.valueOf(markProcessImportant)); // override }
public BpmTask performAction(ProcessStateAction action, BpmTask task, ProcessToolContext ctx) { List<Task> tasks = findUserTask(task.getProcessInstance(), ctx); if (tasks.isEmpty()) { throw new IllegalArgumentException("process.not.owner"); } return performAction(action, ctx, task); }
@Override public void saveData(BpmTask task) { super.saveData(task); ProcessInstance pi = task.getProcessInstance(); pi.setSimpleAttribute("commentAdded", "false"); }
@Override public void loadData(BpmTask task) { ProcessInstance pi = task.getProcessInstance().getRootProcessInstance(); List<ProcessInstanceLog> processLogs = new ArrayList(pi.getProcessLogs()); Collections.sort(processLogs, ProcessInstanceLog.DEFAULT_COMPARATOR); for (ProcessInstanceLog pl : processLogs) { logInfos.add(getProcessLogInfo(pl)); } }
@Override public List<ProcessStateWidget> filterChildren(BpmTask task, List<ProcessStateWidget> sortedList) { String key = task.getProcessInstance().getSimpleAttributeValue(selectorKey); if (key == null) { key = task.getProcessInstance().getRootProcessInstance().getSimpleAttributeValue(selectorKey); } if(key == null){ Map<String, Object> variables = ProcessToolContext.Util.getThreadProcessToolContext().getBpmVariables(task.getProcessInstance()); key = (String) variables.get(selectorKey); } if(key == null) return new ArrayList<ProcessStateWidget>(0); String[] conditionsArray = conditions.split("[,; ]+"); int index = -1; for (int i = 0; i < conditionsArray.length; i++) { if (key.equals(conditionsArray[i].trim())) index = i; } try { return Arrays.asList(sortedList.get(index)); } catch (IndexOutOfBoundsException e) { return new ArrayList<ProcessStateWidget>(0); } } }
@Override public void loadData(final BpmTask task) { boundProperties.clear(); dictContainers.clear(); if (Strings.hasText(widgetsDefinition)) { widgetsDefinitionElement = (WidgetsDefinitionElement) definitionLoader.unmarshall(widgetsDefinition); } this.processInstance = task.getProcessInstance(); processAttributes.clear(); for (ProcessInstanceAttribute attribute : processInstance.getProcessAttributes()) { processAttributes.put(attribute.getKey(), attribute); } }
@Override public void saveData(BpmTask task) { ProcessInstance pi = task.getProcessInstance(); setSimpleAttribute(localeKey, nvl(lbl.getApplication().getLocale(), Locale.getDefault()).toString(), pi); }
@Override public void loadData(BpmTask task) { ProcessInstance pi = task.getProcessInstance().getRootProcessInstance(); if (mode.equalsIgnoreCase(MODE_SMART)) { if (!"true".equalsIgnoreCase(pi.getSimpleAttributeValue("commentAdded", "false"))) { showContent = false; } } bic.removeAllItems(); 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 o2.getCreateTime().compareTo(o1.getCreateTime()); } }); for (int i = 0; i < displayedComments && i < lst.size(); ++i) { bic.addBean(lst.get(i)); } } }
@Override protected void showValidationErrorsOrSave(final WidgetContextSupport support, final Map<ProcessToolDataWidget, Collection<String>> validationErrors) { if(url.matches("#\\{.*\\}")){ String urlKey = url.replaceAll("#\\{(.*)\\}", "$1"); ProcessInstanceAttribute attr = task.getProcessInstance().findAttributeByKey(urlKey); if(attr != null) url = ((ProcessInstanceSimpleAttribute)attr).getValue(); } getApplication().getMainWindow().open(new ExternalResource(url), "_new"); }
@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 void saveData(BpmTask task) { 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.setComments(new HashSet()); for (ProcessComment pc : bic.getItemIds()) { comments.getComments().add(pc); pc.setComments(comments); } }
@Override protected void doShowValidationErrorsOrSave(PerformedActionParams params) { if (hasText(askForCommentKey)) { task = params.getSupport().refreshTask(bpmSession, task); if ("true".equals(task.getProcessInstance().getSimpleAttributeValue(askForCommentKey, "false"))) { showAddCommentDialog(params); } else { skipAddingComment = true; super.doShowValidationErrorsOrSave(params); } } else { showAddCommentDialog(params); } }
@Override public void loadData(BpmTask task) { sessionFacade = new CmisAtomSessionFacade(repositoryUser, repositoryPassword, repositoryAtomUrl, repositoryId); mainFolder = sessionFacade.createFolderIfNecessary(newFolderPrefix + task.getProcessInstance().getInternalId(), rootFolderPath); if (StringUtil.hasText(subFolder)) mainFolder = sessionFacade.createFolderIfNecessary(subFolder, mainFolder.getPath()); folderId = mainFolder.getId(); }
public BpmTask performAction(ProcessStateAction action, ProcessToolContext ctx, BpmTask bpmTask) { return performAction(action, bpmTask.getProcessInstance(),ctx, getProcessEngine().getTaskService().createTaskQuery() .taskId(bpmTask.getInternalTaskId()).singleResult()); }
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()); } } } };