Commit a2722954bd9e7408782bd9b1b69cc8911518420f

Authored by Carlos Alberto
1 parent 56637d87
Exists in master

Melhorias no workflow

cit-esi-api/src/main/java/br/com/centralit/esi/api/business/service/BusinessProcessManager.java
1 1 package br.com.centralit.esi.api.business.service;
2 2  
  3 +import java.util.HashMap;
  4 +
3 5 import br.com.centralit.esi.api.business.model.BusinessProcess;
4 6 import br.com.centralit.esi.api.execution.model.WorkItem;
5 7 import br.com.centralit.esi.api.runtime.RuntimeEnvironment;
... ... @@ -9,6 +11,8 @@ import br.com.centralit.esi.api.runtime.service.RuntimeManagerBase;
9 11 public interface BusinessProcessManager extends RuntimeManagerBase {
10 12  
11 13 RuntimeEnvironmentOutput startBusinessProcess(RuntimeEnvironment ownerEnvironment, WorkItem originWorkItem, String businessProcessName);
  14 +
  15 + RuntimeEnvironmentOutput startBusinessProcess(String businessProcessName, HashMap<String, Object> input);
12 16  
13 17 RuntimeEnvironmentOutput initialize(BusinessProcess businessProcess);
14 18  
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/business/service/impl/BusinessProcessManagerImpl.java
1 1 package br.com.centralit.esi.api.business.service.impl;
2 2  
  3 +import java.util.HashMap;
  4 +
3 5 import org.springframework.beans.factory.annotation.Autowired;
4 6 import org.springframework.stereotype.Service;
5 7 import org.springframework.util.Assert;
... ... @@ -148,4 +150,28 @@ public class BusinessProcessManagerImpl extends RuntimeManagerBaseImpl implement
148 150 }
149 151 }
150 152 }
  153 +
  154 + @Override
  155 + public RuntimeEnvironmentOutput startBusinessProcess(String businessProcessName, HashMap<String, Object> input) {
  156 + BusinessProcess businessProcess = null;
  157 + FlowVersion flowVersion = null;
  158 + RuntimeEnvironmentOutput output = null;
  159 + RuntimeEnvironment runtimeEnvironment = null;
  160 + try {
  161 + businessProcess = businessProcessService.findByName(businessProcessName);
  162 + Assert.notNull(businessProcess, "Processo de negócio não encontrado");
  163 +
  164 + flowVersion = this.retrieveFlowVersion(businessProcess.getFlow().getName());
  165 + runtimeEnvironment = this.newEnvironment(flowVersion, input);
  166 + runtimeEnvironment.getInput().setBusinessProcessId(businessProcess.getId());
  167 + runtimeEnvironment.getInput().addVariable(new RuntimeVariable("businessProcessId",VariableTypeEnum.LONG,businessProcess.getId(),true));
  168 +
  169 + this.initializeVariables(businessProcess, flowVersion, runtimeEnvironment);
  170 +
  171 + output = this.start(runtimeEnvironment, null, flowVersion, true);
  172 + } catch (Exception e) {
  173 + solveException(RuntimeActionEnum.START_BUSINESS_PROCESS, e, runtimeEnvironment, runtimeEnvironment != null ? runtimeEnvironment.getInput() : null, flowVersion);
  174 + }
  175 + return output;
  176 + }
151 177 }
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/service/impl/DataManager.java
... ... @@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
12 12  
13 13 import br.com.centralit.esi.api.business.rule.BusinessRuleBase;
14 14 import br.com.centralit.esi.api.business.rule.BusinessRuleOutput;
  15 +import br.com.centralit.esi.api.business.service.BusinessProcessManager;
15 16 import br.com.centralit.esi.api.business.service.BusinessRuleManager;
16 17 import br.com.centralit.esi.api.data.core.DataObjectParams;
17 18 import br.com.centralit.esi.api.data.core.DataObjectUtil;
... ... @@ -51,6 +52,9 @@ public class DataManager {
51 52 private DataObjectService dataObjectService;
52 53  
53 54 @Autowired
  55 + private BusinessProcessManager runtimeManager;
  56 +
  57 + @Autowired
54 58 private BusinessRuleManager businessRuleManager;
55 59  
56 60 private void restoreRelationship(Relationship relationship, HashMap<String, Object> searchObject, HashMap<String, Object> line) {
... ... @@ -155,6 +159,7 @@ public class DataManager {
155 159 variables.add(new EnvironmentVariable("dataManager", VariableTypeEnum.JAVAOBJECT, this, true));
156 160 variables.add(new EnvironmentVariable("dataObjectService", VariableTypeEnum.JAVAOBJECT, dataObjectService, true));
157 161 variables.add(new EnvironmentVariable("dataSourceService", VariableTypeEnum.JAVAOBJECT, dataSourceService, true));
  162 + variables.add(new EnvironmentVariable("runtimeManager", VariableTypeEnum.JAVAOBJECT, runtimeManager, true));
158 163 variables.add(new EnvironmentVariable("connection", VariableTypeEnum.JAVAOBJECT, connection, true));
159 164 variables.add(new EnvironmentVariable("dataObject", VariableTypeEnum.JAVAOBJECT, dataObject, true));
160 165 variables.add(new EnvironmentVariable(dataObject.getName(), VariableTypeEnum.JSON, data, true));
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/service/impl/FlowVersionServiceImpl.java
... ... @@ -463,10 +463,18 @@ public class FlowVersionServiceImpl extends GenericServiceImpl&lt;FlowVersion, Long
463 463 private void updateFlowVariables(FlowVersion oldFlowVersion, FlowVersion flowVersion) {
464 464 HashMap<String, FlowVariable> mapObj = new HashMap<String, FlowVariable>();
465 465 if (flowVersion.getVariables() != null) {
  466 + List<FlowVariable> variables = new ArrayList<FlowVariable>();
466 467 for (FlowVariable flowVariable : flowVersion.getVariables()) {
467   - flowVariable.setFlowVersion(flowVersion);
468   - mapObj.put(""+flowVariable.getId(), flowVariable);
  468 + if (flowVariable.getStatusVariable() == null) {
  469 + flowVariable.setStatusVariable(false);
  470 + }
  471 + if (!flowVariable.getStatusVariable()) {
  472 + flowVariable.setFlowVersion(flowVersion);
  473 + mapObj.put(""+flowVariable.getId(), flowVariable);
  474 + variables.add(flowVariable);
  475 + }
469 476 }
  477 + flowVersion.setVariables(variables);
470 478 }
471 479 if (oldFlowVersion != null && oldFlowVersion.getVariables() != null) {
472 480 for (FlowVariable flowVariable : oldFlowVersion.getVariables()) {
... ... @@ -761,14 +769,19 @@ public class FlowVersionServiceImpl extends GenericServiceImpl&lt;FlowVersion, Long
761 769 if (oldFlowVersion.getVariables() != null) {
762 770 currentFlowVersion.setVariables(new ArrayList<FlowVariable>());
763 771 for (FlowVariable flowVariable : oldFlowVersion.getVariables()) {
764   - try {
765   - FlowVariable newFlowVariable = (FlowVariable) BeanUtils.cloneBean(flowVariable);
766   - newFlowVariable.setId(null);
767   - newFlowVariable.setFlowVersion(currentFlowVersion);
768   - currentFlowVersion.getVariables().add(newFlowVariable);
769   - } catch (Exception e) {
770   - e.printStackTrace();
771   - throw new EsiBusinessException(e);
  772 + if (flowVariable.getStatusVariable() == null) {
  773 + flowVariable.setStatusVariable(false);
  774 + }
  775 + if (!flowVariable.getStatusVariable()) {
  776 + try {
  777 + FlowVariable newFlowVariable = (FlowVariable) BeanUtils.cloneBean(flowVariable);
  778 + newFlowVariable.setId(null);
  779 + newFlowVariable.setFlowVersion(currentFlowVersion);
  780 + currentFlowVersion.getVariables().add(newFlowVariable);
  781 + } catch (Exception e) {
  782 + e.printStackTrace();
  783 + throw new EsiBusinessException(e);
  784 + }
772 785 }
773 786 }
774 787 }
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/InstanceElementTypeEnum.java
1 1 package br.com.centralit.esi.api.enumerated;
2 2  
3 3 public enum InstanceElementTypeEnum {
4   - SINGLE("ESI.PROPRIEDADE.TIPO_INSTANCIA_UNICA"),
5   - //MULTIPLE("ESI.PROPRIEDADE.TIPO_INSTANCIA_VARIAS"),
  4 + SINGLE("ESI.PROPRIEDADE.TIPO_INSTANCIA_FLUXO"),
6 5 USER("ESI.PROPRIEDADE.TIPO_INSTANCIA_USUARIO");
7 6  
8 7 private String id;
... ...
cit-esi-web/src/main/java/br/com/centralit/listener/StartupListenerEsi.java
... ... @@ -835,7 +835,9 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen
835 835 str.append(uuid+".importPackage(Packages.br.com.centralit.framework.util);\n");
836 836 str.append(uuid+".importPackage(Packages.java.lang);\n");
837 837 str.append(uuid+".importPackage(Packages.org.json);\n");
838   - str.append(uuid+".importPackage(Packages.br.com.centralit.esi.api.enumerated);\n\n");
  838 + str.append(uuid+".importPackage(Packages.br.com.centralit.esi.api.enumerated);\n");
  839 + str.append(uuid+".importPackage(Packages.br.com.centralit.framework.esi.environment);\n");
  840 + str.append(uuid+".importPackage(Packages.br.com.centralit.framework.esi.enumerated);\n\n");
839 841  
840 842 str.append("var JSONArray = "+uuid+".JSONArray;\n");
841 843 str.append("var JSONObject = "+uuid+".JSONObject;\n");
... ... @@ -848,6 +850,9 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen
848 850 str.append("var Calendar = "+uuid+".Calendar;\n");
849 851 str.append("var GregorianCalendar = "+uuid+".GregorianCalendar;\n\n");
850 852 str.append("var parameterService = runtimeEnvironment.getObject(\"parameterService\");\n\n");
  853 + str.append("var EnvironmentVariable = importNames.EnvironmentVariable;\n\n");
  854 + str.append("var VariableTypeEnum = importNames.VariableTypeEnum;\n");
  855 + str.append("var HashMap = importNames.HashMap;\n\n");
851 856  
852 857 str.append("addOrUpdateObject = function(name, value) {\n");
853 858 str.append(" runtimeEnvironment.addOrUpdateObject(name, value);\n");
... ... @@ -2424,8 +2429,8 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen
2424 2429 internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.VARIAVEIS_TAREFA", "Vari&aacute;vel(eis) de entrada/sa&iacute;da da tarefa", dominio, modulo));
2425 2430 internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_ALTERACAO_SITUACAO", "Tipo de alteração da situação", dominio, modulo));
2426 2431 internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.ACAO_SAIDA", "Ação de saída", dominio, modulo));
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", "Uma única instância", dominio, modulo));
  2432 + internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_INSTANCIA_VARIAS", "Várias instâncias", dominio, modulo));
  2433 + internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_INSTANCIA_FLUXO", "Controladas pelo fluxo", dominio, modulo));
2429 2434 internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.TIPO_ESTIMATIVA", "Tipo de estimativa do tempo de execução", dominio, modulo));
2430 2435 internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.ENGINE_EXECUCAO", "Engine", dominio, modulo));
2431 2436 internacionalizacaoList.add(new Internacionalizacao("ESI.PROPRIEDADE.COR_FUNDO", "Cor de fundo", dominio, modulo));
... ...