public void relocateTask(SUser author, SUser user, boolean notify, String relocationCause) { relocateTask(author, user, notify, relocationCause, null); }
default void saveVariableHistoric(Date dateHour, PROCESS_INSTANCE instance, TaskInstance originTask, TaskInstance destinationTask, VarInstanceMap<?> instanceMap) { saveVariableHistoric(dateHour, instance, originTask != null ? originTask.<TASK_INSTANCE> getEntityTaskInstance() : null, destinationTask != null ? destinationTask.<TASK_INSTANCE> getEntityTaskInstance() : null, instanceMap); }
/** Adiciona as informações sobre a task na exception. */ public SingularFlowException add(@Nullable TaskInstance task) { if (task != null) { add("task.id", task.getId()); add("task.fullId", () -> task.getFullId()); add("task.name", task.getName()); add("task.abbreviation", task.getAbbreviation()); add(task.getFlowInstance()); } return this; }
public void endLastAllocation() { if (isAllocated()) { getPersistenceService().endLastAllocation(getEntityTaskInstance()); } }
@SuppressWarnings("unchecked") public List<MUser> getDirectlyResponsibles() { if (getAllocatedUser() != null) { return ImmutableList.of(getAllocatedUser()); } if (getFlowTask() != null && (getFlowTask().isPeople() || (getFlowTask().isWait() && getFlowTask().getAccessStrategy() != null))) { Set<Integer> codPessoas = getFirstLevelUsersCodWithAccess(); return (List<MUser>) getPersistenceService().retrieveUsersByCod(codPessoas); } return Collections.emptyList(); }
public void setTargetEndDate(Date targetEndDate) { getPersistenceService().updateTargetEndDate(getEntityTaskInstance(), targetEndDate); }
public void relocateTask(SUser author, SUser user, boolean notify, String relocationCause, Integer versionStamp) { if (user != null && !isPeople()) { throw new SingularFlowException( "A tarefa '" + getName() + "' não pode ser realocada, pois não é do tipo pessoa", this); } SUser userAllocatedBefore = getAllocatedUser(); if (Objects.equals(user, userAllocatedBefore)) { return; } IEntityTaskInstance entityTaskInstance = getEntityTaskInstance(versionStamp); endLastAllocation(); getPersistenceService().relocateTask(entityTaskInstance, user); String trimmedRelocationCause = StringUtils.trimToNull(relocationCause); String action = (user == null) ? DEALLOCATE : ALLOCATE; if (author == null) { log(action + " Automática", trimmedRelocationCause, user, null, new Date()); } else { log(action, trimmedRelocationCause, user, author, new Date()); } if (notify) { Flow.notifyListeners(n -> n.notifyUserTaskRelocation(this, author, userAllocatedBefore, user, userAllocatedBefore)); Flow.notifyListeners(n -> n.notifyUserTaskAllocation(this, author, user, user, userAllocatedBefore, trimmedRelocationCause)); } notifyStateUpdate(); }
public void createSubTask(String historyType, FlowInstance childFlowInstance) { IEntityFlowInstance childFlowInstanceEntity = childFlowInstance.getEntity(); getPersistenceService().setParentTask(childFlowInstanceEntity, getEntity()); if (historyType != null) { log(historyType, childFlowInstanceEntity.getDescription(), childFlowInstance.getCurrentTaskOrException().getAllocatedUser()).sendEmail(); } notifyStateUpdate(); }
public String getTaskName() { return getName(); }
public TaskHistoricLog log(String logType, String description, SUser allocatedUser, SUser author, Date dateTime) { return log(logType, description, allocatedUser, author, dateTime, null); }
public StringBuilder getExtendedDescription(boolean addAllocated) { StringBuilder sb = new StringBuilder(250); sb.append(getFlowInstance().getFlowName()).append(" - ").append(getName()); String description = getFlowInstance().getDescription(); if (description != null) { sb.append(" - ").append(description); } if (addAllocated) { SUser p = getAllocatedUser(); if (p != null) { sb.append(" (").append(p.getSimpleName()).append(')'); } } return sb; }
public String getName() { if (getFlowTask() != null) { return getFlowTask().getName(); } return getTaskVersion().getName(); }
public StringBuilder getDescricaoExtendida(boolean adicionarAlocado) { StringBuilder sb = new StringBuilder(250); sb.append(getProcessInstance().getProcessName()).append(" - ").append(getName()); String descricao = getProcessInstance().getDescription(); if (descricao != null) { sb.append(" - ").append(descricao); } if (adicionarAlocado) { MUser p = getAllocatedUser(); if (p != null) { sb.append(" (").append(p.getSimpleName()).append(")"); } } return sb; }
public void saveRequirementHistory(RequirementInstance requirement, List<FormEntity> newEntities) { Optional<TaskInstance> taskInstance = requirement.getFlowInstance().getTasksNewerFirstAsStream() .filter(i -> i.isFinished() && !i.getFlowTaskOrException().isEnd()) .findFirst(); FormEntity formEntity = requirement.getEntity().getMainForm(); getLogger().info("Atualizando histórico da petição."); final RequirementContentHistoryEntity contentHistoryEntity = new RequirementContentHistoryEntity(); contentHistoryEntity.setRequirementEntity(requirement.getEntity()); if (taskInstance.isPresent()) { Actor actor = getActorOfAction(taskInstance.get()); contentHistoryEntity.setActor(actor); contentHistoryEntity.setTaskInstanceEntity(taskInstance.get().getEntityTaskInstance()); } if (CollectionUtils.isNotEmpty(formEntity.getCurrentFormVersionEntity().getFormAnnotations())) { contentHistoryEntity.setFormAnnotationsVersions(formEntity.getCurrentFormVersionEntity().getFormAnnotations().stream().map(FormAnnotationEntity::getAnnotationCurrentVersion).collect(Collectors.toList())); } contentHistoryEntity.setApplicantEntity(requirement.getApplicant()); contentHistoryEntity.setHistoryDate(new Date()); requirementContentHistoryDAO.saveOrUpdate(contentHistoryEntity); contentHistoryEntity.setFormVersionHistoryEntities( requirement.getEntity() .getFormRequirementEntities() .stream() .filter(fpe -> newEntities.contains(fpe.getForm())) .map(f -> formRequirementService.createFormVersionHistory(contentHistoryEntity, f)) .collect(Collectors.toList()) ); }
SingularFlowInvalidParametersException(@Nonnull TaskInstance taskInstance, @Nonnull STransition transition, ValidationResult result) { this(taskInstance.getFlowInstance().getFlowDefinition(), result, "Erro ao validar os parametros da transição '" + transition.getName() + "' a partir da tarefa '" + taskInstance.getName() + "'"); add(taskInstance); }
/** Retorna a instância de fluxo a que pertence essa potencia transição. */ @Nonnull public FlowInstance getFlowInstance() { return originTaskInstance.getFlowInstance(); }
private TaskInstance getFinishedTask(String abbreviation) { return getLatestTask(t -> t.isFinished() && t.getAbbreviation().equalsIgnoreCase(abbreviation)); }
protected String generateID(TaskInstance taskInstance) { FlowInstance flowInstance = taskInstance.getFlowInstance(); return new StringBuilder(generateID(flowInstance)) .append('.') .append(taskInstance.getId()) .toString(); }
@Nonnull public Optional<STask<?>> getFlowTask() { if (flowTask == null) { flowTask = getFlowInstance().getFlowDefinition().getFlowMap().getTaskByAbbreviation(getTaskVersion().getAbbreviation()).orElse(null); } return Optional.ofNullable(flowTask); }
public static IConditionalTaskAction executeTransition(final ITaskPredicate predicate, final String transitionName, final String destinationTaskAbbreviation) { TaskActionImpl executeTransition = new TaskActionImpl("Executar Transicao", taskInstance ->{ taskInstance.log("Transição Automática", "motivo: " + predicate.getDescription(taskInstance)); taskInstance.prepareTransition(transitionName).go(); }); executeTransition.setCompleteDescription("Executar Transicao '" + transitionName + "'"); return conditionalAction(predicate, executeTransition, destinationTaskAbbreviation); }