Commit 7beefd3e4a0c1df90b04b3f8a9ba1ad1c80b7232
1 parent
f4e62df9
Exists in
master
Criação de uma instância da tarefa para cada ator quando o tipo de instanciacao = USER
Showing
10 changed files
with
84 additions
and
46 deletions
Show diff stats
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/model/FlowActor.java
| ... | ... | @@ -9,6 +9,7 @@ import javax.persistence.GenerationType; |
| 9 | 9 | import javax.persistence.Id; |
| 10 | 10 | import javax.persistence.ManyToOne; |
| 11 | 11 | import javax.persistence.Table; |
| 12 | +import javax.persistence.Transient; | |
| 12 | 13 | |
| 13 | 14 | import br.com.centralit.esi.api.enumerated.ActorTypeEnum; |
| 14 | 15 | import br.com.centralit.framework.json.Views; |
| ... | ... | @@ -45,6 +46,9 @@ public class FlowActor extends PersistentObject { |
| 45 | 46 | @JsonView({ Views.GenericView.class}) |
| 46 | 47 | @Embedded |
| 47 | 48 | private Expression value; |
| 49 | + | |
| 50 | + @Transient | |
| 51 | + private String assignValue; | |
| 48 | 52 | |
| 49 | 53 | @Override |
| 50 | 54 | public Long getId() { |
| ... | ... | @@ -130,5 +134,15 @@ public class FlowActor extends PersistentObject { |
| 130 | 134 | public void setId(Long id) { |
| 131 | 135 | this.id = id; |
| 132 | 136 | } |
| 137 | + | |
| 138 | + | |
| 139 | + public String getAssignValue() { | |
| 140 | + return assignValue; | |
| 141 | + } | |
| 142 | + | |
| 143 | + | |
| 144 | + public void setAssignValue(String assignValue) { | |
| 145 | + this.assignValue = assignValue; | |
| 146 | + } | |
| 133 | 147 | |
| 134 | 148 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/InstanceElementTypeEnum.java
| ... | ... | @@ -2,7 +2,7 @@ package br.com.centralit.esi.api.enumerated; |
| 2 | 2 | |
| 3 | 3 | public enum InstanceElementTypeEnum { |
| 4 | 4 | SINGLE("ESI.PROPRIEDADE.TIPO_INSTANCIA_UNICA"), |
| 5 | - MULTIPLE("ESI.PROPRIEDADE.TIPO_INSTANCIA_VARIAS"), | |
| 5 | + //MULTIPLE("ESI.PROPRIEDADE.TIPO_INSTANCIA_VARIAS"), | |
| 6 | 6 | USER("ESI.PROPRIEDADE.TIPO_INSTANCIA_USUARIO"); |
| 7 | 7 | |
| 8 | 8 | private String id; | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/model/ProcessInstance.java
| ... | ... | @@ -29,7 +29,6 @@ import org.springframework.security.core.context.SecurityContextHolder; |
| 29 | 29 | |
| 30 | 30 | import br.com.centralit.esi.api.design.model.ExecutionTime; |
| 31 | 31 | import br.com.centralit.esi.api.design.model.FlowConnection; |
| 32 | -import br.com.centralit.esi.api.design.model.FlowElement; | |
| 33 | 32 | import br.com.centralit.esi.api.design.model.FlowStatus; |
| 34 | 33 | import br.com.centralit.esi.api.design.model.FlowVariable; |
| 35 | 34 | import br.com.centralit.esi.api.design.model.FlowVersion; |
| ... | ... | @@ -1057,20 +1056,7 @@ public class ProcessInstance extends PersistentObject implements Serializable { |
| 1057 | 1056 | |
| 1058 | 1057 | return allWorkItems; |
| 1059 | 1058 | } |
| 1060 | - | |
| 1061 | - public WorkItem retrieveLastWorkItem(FlowElement flowElement) { | |
| 1062 | - WorkItem result = null; | |
| 1063 | - List<WorkItem> allWorkItems = this.getAllWorkItems(); | |
| 1064 | - | |
| 1065 | - for (WorkItem workItem : allWorkItems) { | |
| 1066 | - if (workItem.getFlowElement().getId().equals(flowElement.getId())) { | |
| 1067 | - result = workItem; | |
| 1068 | - } | |
| 1069 | - } | |
| 1070 | 1059 | |
| 1071 | - return result; | |
| 1072 | - } | |
| 1073 | - | |
| 1074 | 1060 | public List<UserTaskItem> getAvailableUserTask() { |
| 1075 | 1061 | List<WorkItem> allWorkItems = this.getAllWorkItems(); |
| 1076 | 1062 | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/model/WorkItem.java
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/event/WorkItemEndEventServiceImpl.java
| ... | ... | @@ -24,20 +24,17 @@ public class WorkItemEndEventServiceImpl extends WorkItemServiceImpl<EndEvent> i |
| 24 | 24 | |
| 25 | 25 | @Override |
| 26 | 26 | protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { |
| 27 | - boolean bTodosExecutados = true; | |
| 27 | + boolean isAllCompleted = true; | |
| 28 | 28 | List<FlowElement> origens = this.getSourceElements(runtimeEnvironment, flowElement, processInstance); |
| 29 | 29 | if (origens != null) { |
| 30 | - for (FlowElement origem : origens) { | |
| 31 | - WorkItem workItem = processInstance.retrieveLastWorkItem(origem); | |
| 32 | - if (workItem != null) { | |
| 33 | - if (!workItem.isCompleted()) { | |
| 34 | - bTodosExecutados = false; | |
| 35 | - break; | |
| 36 | - } | |
| 30 | + for (FlowElement element : origens) { | |
| 31 | + if (!this.isAllCompletedItems(processInstance, element)) { | |
| 32 | + isAllCompleted = false; | |
| 33 | + break; | |
| 37 | 34 | } |
| 38 | 35 | } |
| 39 | 36 | } |
| 40 | - if (bTodosExecutados) { | |
| 37 | + if (isAllCompleted) { | |
| 41 | 38 | this.registerAndComplete(runtimeEnvironment, processInstance,flowElement); |
| 42 | 39 | this.completeProcessInstance(runtimeEnvironment, processInstance); |
| 43 | 40 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/gateway/WorkItemExclusiveGatewayServiceImpl.java
| ... | ... | @@ -33,12 +33,9 @@ public class WorkItemExclusiveGatewayServiceImpl extends WorkItemServiceImpl<Exc |
| 33 | 33 | List<FlowElement> elements = getSourceElements(runtimeEnvironment,flowElement, processInstance); |
| 34 | 34 | if (elements != null) { |
| 35 | 35 | for (FlowElement element : elements) { |
| 36 | - WorkItem workItem = processInstance.retrieveLastWorkItem(element); | |
| 37 | - if (workItem != null) { | |
| 38 | - if (!workItem.isCompleted()) { | |
| 39 | - isAllCompleted = false; | |
| 40 | - break; | |
| 41 | - } | |
| 36 | + if (!this.isAllCompletedItems(processInstance, element)) { | |
| 37 | + isAllCompleted = false; | |
| 38 | + break; | |
| 42 | 39 | } |
| 43 | 40 | } |
| 44 | 41 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/gateway/WorkItemInclusiveGatewayServiceImpl.java
| ... | ... | @@ -28,12 +28,9 @@ public class WorkItemInclusiveGatewayServiceImpl extends WorkItemServiceImpl<Inc |
| 28 | 28 | List<FlowElement> elements = getSourceElements(runtimeEnvironment,flowElement, processInstance); |
| 29 | 29 | if (elements != null) { |
| 30 | 30 | for (FlowElement element : elements) { |
| 31 | - WorkItem workItem = processInstance.retrieveLastWorkItem(element); | |
| 32 | - if (workItem != null) { | |
| 33 | - if (!workItem.isCompleted()) { | |
| 34 | - isAllCompleted = false; | |
| 35 | - break; | |
| 36 | - } | |
| 31 | + if (!this.isAllCompletedItems(processInstance, element)) { | |
| 32 | + isAllCompleted = false; | |
| 33 | + break; | |
| 37 | 34 | } |
| 38 | 35 | } |
| 39 | 36 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/impl/WorkItemServiceImpl.java
| ... | ... | @@ -85,6 +85,23 @@ public class WorkItemServiceImpl<E extends FlowElement> extends GenericServiceIm |
| 85 | 85 | protected void internalAfterRegistry(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | + protected boolean isAllCompletedItems(ProcessInstance processInstance, FlowElement flowElement) { | |
| 89 | + boolean result = true; | |
| 90 | + | |
| 91 | + List<WorkItem> allWorkItems = processInstance.getAllWorkItems(); | |
| 92 | + | |
| 93 | + for (WorkItem workItem : allWorkItems) { | |
| 94 | + if (workItem.getFlowElement().getId().equals(flowElement.getId())) { | |
| 95 | + if (!workItem.isCompleted()) { | |
| 96 | + result = false; | |
| 97 | + break; | |
| 98 | + } | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 102 | + return result; | |
| 103 | + } | |
| 104 | + | |
| 88 | 105 | protected List<FlowConnection> getCompliedTargetConnections(RuntimeEnvironment runtimeEnvironment, FlowElement flowElement, ProcessInstance processInstance) { |
| 89 | 106 | List<FlowConnection> result = new ArrayList<FlowConnection>(); |
| 90 | 107 | List<FlowConnection> connections = this.flowConnectionService.findBySourceElement(flowElement, processInstance); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemUserTaskServiceImpl.java
| 1 | 1 | package br.com.centralit.esi.api.execution.service.task; |
| 2 | 2 | |
| 3 | +import java.util.ArrayList; | |
| 3 | 4 | import java.util.Calendar; |
| 4 | 5 | import java.util.List; |
| 5 | 6 | |
| ... | ... | @@ -15,6 +16,7 @@ import br.com.centralit.esi.api.design.model.task.UserTask; |
| 15 | 16 | import br.com.centralit.esi.api.enumerated.ActorTypeEnum; |
| 16 | 17 | import br.com.centralit.esi.api.enumerated.AssignmentTypeEnum; |
| 17 | 18 | import br.com.centralit.esi.api.enumerated.EstimateTimeTypeEnum; |
| 19 | +import br.com.centralit.esi.api.enumerated.InstanceElementTypeEnum; | |
| 18 | 20 | import br.com.centralit.esi.api.enumerated.TimeManagementActionEnum; |
| 19 | 21 | import br.com.centralit.esi.api.enumerated.TimeManagementStatusEnum; |
| 20 | 22 | import br.com.centralit.esi.api.enumerated.UserTaskActionEnum; |
| ... | ... | @@ -137,10 +139,10 @@ public class WorkItemUserTaskServiceImpl extends WorkItemServiceImpl<UserTask> i |
| 137 | 139 | |
| 138 | 140 | @Override |
| 139 | 141 | protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { |
| 140 | - UserTaskItem userTaskItem = this.register(runtimeEnvironment, processInstance,flowElement); | |
| 142 | + UserTaskItem userTaskItem = this.register(runtimeEnvironment, processInstance, flowElement); | |
| 141 | 143 | runtimeEnvironment.addOrUpdateObject("userTask", userTaskItem); |
| 142 | 144 | |
| 143 | - this.assign(runtimeEnvironment, userTaskItem); | |
| 145 | + this.assign(runtimeEnvironment, processInstance, userTaskItem); | |
| 144 | 146 | |
| 145 | 147 | return userTaskItem; |
| 146 | 148 | } |
| ... | ... | @@ -200,20 +202,37 @@ public class WorkItemUserTaskServiceImpl extends WorkItemServiceImpl<UserTask> i |
| 200 | 202 | } |
| 201 | 203 | } |
| 202 | 204 | |
| 203 | - protected void assign(RuntimeEnvironment runtimeEnvironment, UserTaskItem userTaskItem) { | |
| 205 | + protected void assign(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, UserTaskItem userTaskItem) { | |
| 204 | 206 | UserTask element = this.getFlowElement(userTaskItem); |
| 205 | 207 | if (element.getActors() != null) { |
| 208 | + List<FlowActor> assignList = new ArrayList<FlowActor>(); | |
| 209 | + | |
| 206 | 210 | for (FlowActor actor : element.getActors()) { |
| 211 | + actor.setAssignValue(null); | |
| 207 | 212 | Object initialValue = runtimeEnvironment.assignInitialValue(new Variable(actor.getName(), VariableTypeEnum.TEXT, null, false), actor.getValue()); |
| 208 | 213 | if (initialValue instanceof List) { |
| 209 | 214 | for (Object value : (List<?>) initialValue) { |
| 210 | - if (value instanceof String) | |
| 211 | - this.assign(runtimeEnvironment, userTaskItem, actor.getActorType(), AssignmentTypeEnum.AUTOMATIC, (String) value); | |
| 215 | + if (value instanceof String) { | |
| 216 | + actor.setAssignValue((String) value); | |
| 217 | + assignList.add(actor); | |
| 218 | + } | |
| 212 | 219 | } |
| 213 | 220 | }else{ |
| 214 | - if (initialValue instanceof String) | |
| 215 | - this.assign(runtimeEnvironment, userTaskItem, actor.getActorType(), AssignmentTypeEnum.AUTOMATIC, (String) initialValue); | |
| 221 | + if (initialValue instanceof String) { | |
| 222 | + actor.setAssignValue((String) initialValue); | |
| 223 | + assignList.add(actor); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + } | |
| 227 | + | |
| 228 | + int i = 0; | |
| 229 | + UserTaskItem assignTask = userTaskItem; | |
| 230 | + for (FlowActor actor : assignList) { | |
| 231 | + if (element.getInstanceType().equals(InstanceElementTypeEnum.USER) && i > 0) { | |
| 232 | + assignTask = this.register(runtimeEnvironment, processInstance, element); | |
| 216 | 233 | } |
| 234 | + i++; | |
| 235 | + this.assign(runtimeEnvironment, assignTask, actor.getActorType(), AssignmentTypeEnum.AUTOMATIC, actor.getAssignValue()); | |
| 217 | 236 | } |
| 218 | 237 | } |
| 219 | 238 | } |
| ... | ... | @@ -250,7 +269,17 @@ public class WorkItemUserTaskServiceImpl extends WorkItemServiceImpl<UserTask> i |
| 250 | 269 | |
| 251 | 270 | complete(runtimeEnvironment, workItem); |
| 252 | 271 | runtimeEnvironment.addOrUpdateObject("userTask", workItem); |
| 253 | - return this.retrieveTargets(runtimeEnvironment, workItem); | |
| 272 | + | |
| 273 | + UserTask element = (UserTask) workItem.getFlowElement(); | |
| 274 | + if (element.getInstanceType().equals(InstanceElementTypeEnum.USER)) { | |
| 275 | + if (this.isAllCompletedItems(workItem.getProcessInstance(), workItem.getFlowElement())) { | |
| 276 | + this.retrieveTargets(runtimeEnvironment, workItem); | |
| 277 | + } | |
| 278 | + }else{ | |
| 279 | + this.retrieveTargets(runtimeEnvironment, workItem); | |
| 280 | + } | |
| 281 | + | |
| 282 | + return workItem; | |
| 254 | 283 | } |
| 255 | 284 | |
| 256 | 285 | @Override | ... | ... |
cit-esi-web/src/main/java/br/com/centralit/listener/StartupListenerEsi.java
| ... | ... | @@ -2420,12 +2420,12 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen |
| 2420 | 2420 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.ESTADO_FINAL", "Estado final", dominio, modulo)); |
| 2421 | 2421 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.NOME_FLUXO", "Nome do fluxo", dominio, modulo)); |
| 2422 | 2422 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.COR_TEXTO", "Cor do texto", dominio, modulo)); |
| 2423 | - internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_INSTANCIA_USUARIO", "Por usuário", dominio, modulo)); | |
| 2423 | + internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_INSTANCIA_USUARIO", "Uma instância p/ cada ator", dominio, modulo)); | |
| 2424 | 2424 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.VARIAVEIS_TAREFA", "Variável(eis) de entrada/saída da tarefa", dominio, modulo)); |
| 2425 | 2425 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_ALTERACAO_SITUACAO", "Tipo de alteração da situação", dominio, modulo)); |
| 2426 | 2426 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.ACAO_SAIDA", "Ação de saída", dominio, modulo)); |
| 2427 | 2427 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_INSTANCIA_VARIAS", "Várias (controlada pelo fluxo)", dominio, modulo)); |
| 2428 | - internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_INSTANCIA_UNICA", "Única", dominio, modulo)); | |
| 2428 | + internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_INSTANCIA_UNICA", "Uma única instância", dominio, modulo)); | |
| 2429 | 2429 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_ESTIMATIVA", "Tipo de estimativa do tempo de execução", dominio, modulo)); |
| 2430 | 2430 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.ENGINE_EXECUCAO", "Engine", dominio, modulo)); |
| 2431 | 2431 | internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.COR_FUNDO", "Cor de fundo", dominio, modulo)); | ... | ... |