public String getTaskName() { return getName(); }
public String getTaskName() { return getName(); }
private boolean matchesReferenceTask(TaskInstance t) { for(ITaskDefinition ref : referenceTasks){ if (ref.getName().equalsIgnoreCase(t.getName())) { return true; } } return false; }
private boolean matchesReferenceTask(TaskInstance t) { for(ITaskDefinition ref : referenceTasks){ if (ref.getName().equalsIgnoreCase(t.getName())) { return true; } } return false; }
private boolean matchesReferenceTask(TaskInstance t) { for(ITaskDefinition ref : referenceTasks){ if (ref.getName().equalsIgnoreCase(t.getName())) { return true; } } return false; }
public String getCurrentTaskNameOrException() { return getFlowInstance().getCurrentTaskOrException().getName(); }
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 getCurrentTaskNameOrException() { return getFlowInstance().getCurrentTaskOrException().getName(); }
public String getCurrentTaskNameOrException() { return getFlowInstance().getCurrentTaskOrException().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; }
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); }
private static <P extends FlowInstance> void checkUpdateState(@Nonnull P flowInstance, TaskInstance currentOrigin, STransition currentTransition) { if (isCurrentTransitionNotNullAndCurrentOriginNull(currentOrigin, currentTransition)) { throw new SingularFlowException( "Não pode ser solicitada execução de uma transição específica (transition=" + currentTransition.getName() + ") sem uma instancia de tarefa de origem (tarefaOrigem null)", flowInstance); } else if (isCurrentOriginNotNullAndIsntActive(currentOrigin)) { throw new SingularFlowException( "Não pode ser executada uma transição a partir da task '" + currentOrigin.getName() + "', pois a mesma já está concluida.", currentOrigin); } }
/** * <p> * Retorna o nome da tarefa atual desta instância de processo. * </p> * * @return o nome da tarefa atual; ou {@code null} caso não haja uma tarefa * atual. */ public String getCurrentTaskName() { if (getEstado() != null) { return getEstado().getName(); } TaskInstance tarefaAtual = getCurrentTask(); if (tarefaAtual != null) { // Uma situação legada, que não existe mais no fluxo mapeado return tarefaAtual.getName(); } return null; }
/** 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; }
/** * Realiza uma transição manual da tarefa atual para a tarefa especificada. * * @param task a tarefa especificada. */ public final void forceStateUpdate(@Nonnull STask<?> task) { Objects.requireNonNull(task); final TaskInstance originTask = getLastTaskOrException(); List<SUser> previousUsers = getDirectlyResponsibles(); final Date now = new Date(); TaskInstance newTask = updateState(originTask, null, task, now); originTask.log("Alteração Manual de Estado", "de '" + originTask.getName() + "' para '" + task.getName() + "'", null, Flow.getUserIfAvailable(), now).sendEmail(previousUsers); FlowEngine.initTask(this, task, newTask); ExecutionContext executionContext = new ExecutionContext(this, newTask, null); TaskInstance taskNew2 = getNewestTask(task).orElseThrow(() -> new SingularFlowException("Erro Interno", this)); task.notifyTaskStart(taskNew2, executionContext); if (task.isImmediateExecution()) { prepareTransition().go(); } }
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 relocateTask(MUser author, MUser user, boolean notify, String relocationCause, Integer versionStamp) { if (user != null && !isPeople()) { throw new SingularFlowException( getProcessInstance().createErrorMsg("A tarefa '" + getName() + "' não pode ser realocada, pois não é do tipo pessoa")); } MUser pessoaAlocadaAntes = getAllocatedUser(); if (Objects.equals(user, pessoaAlocadaAntes)) { return; } IEntityTaskInstance entityTaskInstance = getEntityTaskInstance(versionStamp); endLastAllocation(); getPersistenceService().relocateTask(entityTaskInstance, user); String trimmedRelocationCause = StringUtils.trimToNull(relocationCause); String acao = (user == null) ? DESALOCACAO : ALOCACAO; if (author == null) { log(acao + " Automática", trimmedRelocationCause, user, null, new Date()); } else { log(acao, trimmedRelocationCause, user, author, new Date()); } if (notify) { Flow.notifyListeners(n -> n.notifyUserTaskRelocation(this, author, pessoaAlocadaAntes, user, pessoaAlocadaAntes)); Flow.notifyListeners(n -> n.notifyUserTaskAllocation(this, author, user, user, pessoaAlocadaAntes, trimmedRelocationCause)); } notifyStateUpdate(); }
/** * Realiza uma transição manual da tarefa atual para a tarefa especificada. * * @param task a tarefa especificada. */ public final void forceStateUpdate(MTask<?> task) { final TaskInstance tarefaOrigem = getLatestTask(); List<MUser> pessoasAnteriores = getResponsaveisDiretos(); final Date agora = new Date(); TaskInstance tarefaNova = updateState(tarefaOrigem, null, task, agora); if (tarefaOrigem != null) { tarefaOrigem.log("Alteração Manual de Estado", "de '" + tarefaOrigem.getName() + "' para '" + task.getName() + "'", null, Flow.getUserIfAvailable(), agora).sendEmail(pessoasAnteriores); } FlowEngine.initTask(this, task, tarefaNova); ExecutionContext execucaoMTask = new ExecutionContext(this, tarefaNova, null); task.notifyTaskStart(getLatestTask(task), execucaoMTask); if (task.isImmediateExecution()) { executeTransition(); } }