Commit c4f10fe340c0144a12dfe34e3d061fab79fa3d7b
Exists in
master
Merge branch 'tarefa-4108'
Showing
149 changed files
with
5476 additions
and
1121 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 149 files displayed.
cit-esi-api/pom.xml
| ... | ... | @@ -79,18 +79,6 @@ |
| 79 | 79 | <artifactId>json</artifactId> |
| 80 | 80 | </dependency> |
| 81 | 81 | <dependency> |
| 82 | - <groupId>pentaho-reporting-engine</groupId> | |
| 83 | - <artifactId>pentaho-reporting-engine-classic-core</artifactId> | |
| 84 | - </dependency> | |
| 85 | - <dependency> | |
| 86 | - <groupId>pentaho-library</groupId> | |
| 87 | - <artifactId>libloader</artifactId> | |
| 88 | - </dependency> | |
| 89 | - <dependency> | |
| 90 | - <groupId>pentaho-library</groupId> | |
| 91 | - <artifactId>libbase</artifactId> | |
| 92 | - </dependency> | |
| 93 | - <dependency> | |
| 94 | 82 | <groupId>org.apache.poi</groupId> |
| 95 | 83 | <artifactId>poi</artifactId> |
| 96 | 84 | </dependency> |
| ... | ... | @@ -118,6 +106,59 @@ |
| 118 | 106 | <groupId>org.drools</groupId> |
| 119 | 107 | <artifactId>drools-compiler</artifactId> |
| 120 | 108 | </dependency> |
| 109 | + | |
| 110 | + <dependency> | |
| 111 | + <groupId>pentaho-reporting-engine</groupId> | |
| 112 | + <artifactId>pentaho-reporting-engine-classic-core</artifactId> | |
| 113 | + <type>jar</type> | |
| 114 | + </dependency> | |
| 115 | + <dependency> | |
| 116 | + <groupId>pentaho-reporting-engine</groupId> | |
| 117 | + <artifactId>pentaho-reporting-engine-classic-extensions</artifactId> | |
| 118 | + <type>jar</type> | |
| 119 | + </dependency> | |
| 120 | + <dependency> | |
| 121 | + <groupId>pentaho-library</groupId> | |
| 122 | + <artifactId>libbase</artifactId> | |
| 123 | + </dependency> | |
| 124 | + <dependency> | |
| 125 | + <groupId>pentaho-library</groupId> | |
| 126 | + <artifactId>libdocbundle</artifactId> | |
| 127 | + </dependency> | |
| 128 | + <dependency> | |
| 129 | + <groupId>pentaho-library</groupId> | |
| 130 | + <artifactId>libfonts</artifactId> | |
| 131 | + </dependency> | |
| 132 | + <dependency> | |
| 133 | + <groupId>pentaho-library</groupId> | |
| 134 | + <artifactId>libformat</artifactId> | |
| 135 | + </dependency> | |
| 136 | + <dependency> | |
| 137 | + <groupId>pentaho-library</groupId> | |
| 138 | + <artifactId>libformula</artifactId> | |
| 139 | + </dependency> | |
| 140 | + <dependency> | |
| 141 | + <groupId>pentaho-library</groupId> | |
| 142 | + <artifactId>libloader</artifactId> | |
| 143 | + </dependency> | |
| 144 | + <dependency> | |
| 145 | + <groupId>pentaho-library</groupId> | |
| 146 | + <artifactId>librepository</artifactId> | |
| 147 | + </dependency> | |
| 148 | + <dependency> | |
| 149 | + <groupId>pentaho-library</groupId> | |
| 150 | + <artifactId>libserializer</artifactId> | |
| 151 | + </dependency> | |
| 152 | + <dependency> | |
| 153 | + <groupId>pentaho-library</groupId> | |
| 154 | + <artifactId>libxml</artifactId> | |
| 155 | + </dependency> | |
| 156 | + <dependency> | |
| 157 | + <groupId>pentaho-library</groupId> | |
| 158 | + <artifactId>libswing</artifactId> | |
| 159 | + <version>1.2.4</version> | |
| 160 | + </dependency> | |
| 161 | + | |
| 121 | 162 | </dependencies> |
| 122 | 163 | |
| 123 | 164 | </project> | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/api/service/impl/InicializarEsiServiceImpl.java
| ... | ... | @@ -86,6 +86,8 @@ public class InicializarEsiServiceImpl extends UtilStartup{ |
| 86 | 86 | Pagina pgCss = new Pagina("CSS", "/cit-esi-web/html/css/css.html"); |
| 87 | 87 | Pagina pgPage = new Pagina("Página HTML", "/cit-esi-web/html/page/page.html"); |
| 88 | 88 | Pagina pgFile = new Pagina("Arquivo", "/cit-esi-web/html/file/file.html"); |
| 89 | + Pagina pgReportFile = new Pagina("Arquivo de Relatório", "/cit-esi-web/html/reportFile/reportFile.html"); | |
| 90 | + Pagina pgReport = new Pagina("Configuração de Relatório", "/cit-esi-web/html/report/report.html"); | |
| 89 | 91 | Pagina pgFormWidget = new Pagina("Componente", "/cit-esi-web/html/formWidget/formWidget.html"); |
| 90 | 92 | Pagina pgDataType = new Pagina("Tipo de Dado", "/cit-esi-web/html/dataType/dataType.html"); |
| 91 | 93 | Pagina pgDatabase = new Pagina("Banco de Dados", "/cit-esi-web/html/database/database.html"); |
| ... | ... | @@ -115,6 +117,8 @@ public class InicializarEsiServiceImpl extends UtilStartup{ |
| 115 | 117 | pgCss = this.paginaService.saveIfNotExist(pgCss); |
| 116 | 118 | pgPage = this.paginaService.saveIfNotExist(pgPage); |
| 117 | 119 | pgFile = this.paginaService.saveIfNotExist(pgFile); |
| 120 | + pgReportFile = this.paginaService.saveIfNotExist(pgReportFile); | |
| 121 | + pgReport = this.paginaService.saveIfNotExist(pgReport); | |
| 118 | 122 | pgFormWidget = this.paginaService.saveIfNotExist(pgFormWidget); |
| 119 | 123 | pgDataSource = this.paginaService.saveIfNotExist(pgDataSource); |
| 120 | 124 | pgDataObject = this.paginaService.saveIfNotExist(pgDataObject); |
| ... | ... | @@ -238,11 +242,22 @@ public class InicializarEsiServiceImpl extends UtilStartup{ |
| 238 | 242 | Menu menuDataObject = new Menu("Objeto de Banco", pgDataObject, menuData, null, 4, corBuilder, cssMenuBuilder, opacidadeMenuBuilder, classeBuilder, moduloSelecionado); |
| 239 | 243 | menuDataObject.setIncludes(this.gerarArquivosMenu(menuDataObject, CIT_ESI_WEB_ANGULAR, "DataObject", true, true, true)); |
| 240 | 244 | |
| 245 | + // menuReport - Report | |
| 246 | + Menu menuReport = new Menu("Relatórios", null, menuBuilder, 2, 1, corBuilder, cssMenuBuilder, opacidadeMenuBuilder, classeBuilder, moduloSelecionado); | |
| 247 | + | |
| 248 | + Menu menuReportFile = new Menu("Arquivo", pgReportFile, menuReport, null, 1, corBuilder, cssMenuBuilder, opacidadeMenuBuilder, classeBuilder, moduloSelecionado); | |
| 249 | + menuReportFile.setChave("ARQUIVO_RELATORIO"); | |
| 250 | + menuReportFile.setIncludes(this.gerarArquivosMenu(menuReportFile, CIT_ESI_WEB_ANGULAR, "ReportFile", true, true, false)); | |
| 251 | + | |
| 252 | + Menu menuReportConfig = new Menu("Configuração", pgReport, menuReport, null, 2, corBuilder, cssMenuBuilder, opacidadeMenuBuilder, classeBuilder, moduloSelecionado); | |
| 253 | + menuReportConfig.setChave("CONFIGURACAO_RELATORIO"); | |
| 254 | + menuReportConfig.setIncludes(this.gerarArquivosMenu(menuReportConfig, CIT_ESI_WEB_ANGULAR, "Report", true, true, true)); | |
| 255 | + | |
| 241 | 256 | // menuBuilder - Implantação |
| 242 | - Menu menuImplantacao = new Menu("Implantação", null, menuBuilder, 2, 1, corBuilder, cssMenuBuilder, opacidadeMenuBuilder, classeBuilder, moduloSelecionado); | |
| 257 | + Menu menuImplantacao = new Menu("Implantação", null, menuBuilder, 3, 1, corBuilder, cssMenuBuilder, opacidadeMenuBuilder, classeBuilder, moduloSelecionado); | |
| 243 | 258 | |
| 244 | - Menu menuPack = new Menu("Pacote", pgPack, menuData, null, 1, corBuilder, cssMenuBuilder, opacidadeMenuBuilder, classeBuilder, moduloSelecionado); | |
| 245 | - menuPack.setIncludes(this.gerarArquivosMenu(menuDataType, CIT_ESI_WEB_ANGULAR, "Pack", true, true, false)); | |
| 259 | + Menu menuPack = new Menu("Pacote", pgPack, menuImplantacao, null, 1, corBuilder, cssMenuBuilder, opacidadeMenuBuilder, classeBuilder, moduloSelecionado); | |
| 260 | + menuPack.setIncludes(this.gerarArquivosMenu(menuPack, CIT_ESI_WEB_ANGULAR, "Pack", true, true, false)); | |
| 246 | 261 | |
| 247 | 262 | // MenuEsi |
| 248 | 263 | menuEsi = this.menuService.mergeIfNotExist(menuEsi); |
| ... | ... | @@ -352,6 +367,15 @@ public class InicializarEsiServiceImpl extends UtilStartup{ |
| 352 | 367 | menuForm.setParent(menuFormBuilder); |
| 353 | 368 | menuForm = this.menuService.mergeIfNotExist(menuForm); |
| 354 | 369 | |
| 370 | + menuReport.setParent(menuBuilder); | |
| 371 | + menuReport = this.menuService.mergeIfNotExist(menuReport); | |
| 372 | + | |
| 373 | + menuReportFile.setParent(menuReport); | |
| 374 | + menuReportFile = this.menuService.mergeIfNotExist(menuReportFile); | |
| 375 | + | |
| 376 | + menuReportConfig.setParent(menuReport); | |
| 377 | + menuReportConfig = this.menuService.mergeIfNotExist(menuReportConfig); | |
| 378 | + | |
| 355 | 379 | menuImplantacao.setParent(menuBuilder); |
| 356 | 380 | menuImplantacao = this.menuService.mergeIfNotExist(menuImplantacao); |
| 357 | 381 | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/business/service/impl/BusinessProcessServiceImpl.java
| ... | ... | @@ -194,16 +194,13 @@ public class BusinessProcessServiceImpl extends GenericServiceImpl<BusinessProce |
| 194 | 194 | |
| 195 | 195 | EnvironmentOutput output = this.delegateUserTask(new Long(137), groups, null); |
| 196 | 196 | |
| 197 | - output = this.removeUserTaskDelegation(new Long(137), groups, null); | |
| 197 | + output = this.removeUserTaskDelegation(new Long(137), groups, null); | |
| 198 | 198 | |
| 199 | 199 | List<EnvironmentVariable> variaveis = new ArrayList<EnvironmentVariable>(); |
| 200 | 200 | |
| 201 | - variaveis.add(new EnvironmentVariable("idProcesso", VariableTypeEnum.LONG, new Long(1), false)); | |
| 202 | - variaveis.add(new EnvironmentVariable("solicitante", VariableTypeEnum.TEXT, "carlos.alberto", false)); | |
| 203 | - | |
| 204 | - EnvironmentOutput processoNegocio = this.startBusinessProcess("sigad", variaveis); | |
| 201 | + EnvironmentOutput output = this.startNodeWithSignalEvent("FinalizacaoSolicitacaoServico", new Long(7), false, variaveis); | |
| 205 | 202 | |
| 206 | - List<EnvironmentVariable> variaveis = new ArrayList<EnvironmentVariable>(); | |
| 203 | + /*List<EnvironmentVariable> variaveis = new ArrayList<EnvironmentVariable>(); | |
| 207 | 204 | |
| 208 | 205 | variaveis.add(new EnvironmentVariable("solicitante", VariableTypeEnum.TEXT, "admin", false)); |
| 209 | 206 | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/business/service/impl/BusinessRuleManagerImpl.java
| ... | ... | @@ -11,15 +11,19 @@ import br.com.centralit.esi.api.business.rule.BusinessRule; |
| 11 | 11 | import br.com.centralit.esi.api.business.rule.BusinessRuleOutput; |
| 12 | 12 | import br.com.centralit.esi.api.business.service.BusinessRuleManager; |
| 13 | 13 | import br.com.centralit.esi.api.design.model.FlowVersion; |
| 14 | +import br.com.centralit.esi.api.document.service.DocumentService; | |
| 14 | 15 | import br.com.centralit.esi.api.enumerated.BusinessRuleEngineEnum; |
| 15 | 16 | import br.com.centralit.esi.api.execution.component.ExecuteDrools; |
| 16 | 17 | import br.com.centralit.esi.api.execution.component.ExecuteScript; |
| 17 | 18 | import br.com.centralit.esi.api.execution.model.WorkItem; |
| 19 | +import br.com.centralit.esi.api.parameter.service.ParameterService; | |
| 18 | 20 | import br.com.centralit.esi.api.runtime.RuntimeEnvironment; |
| 19 | 21 | import br.com.centralit.esi.api.runtime.RuntimeEnvironmentImpl; |
| 20 | 22 | import br.com.centralit.esi.api.runtime.RuntimeEnvironmentInput; |
| 21 | 23 | import br.com.centralit.esi.api.runtime.RuntimeEnvironmentOutput; |
| 22 | 24 | import br.com.centralit.esi.api.runtime.service.RuntimeManager; |
| 25 | +import br.com.centralit.esi.api.security.model.User; | |
| 26 | +import br.com.centralit.esi.api.security.service.SecurityService; | |
| 23 | 27 | import br.com.centralit.esi.api.util.EsiAppUtils; |
| 24 | 28 | import br.com.centralit.esi.exception.EsiBusinessException; |
| 25 | 29 | import br.com.centralit.framework.esi.environment.EnvironmentVariable; |
| ... | ... | @@ -30,11 +34,20 @@ import br.com.centralit.framework.util.UtilString; |
| 30 | 34 | public class BusinessRuleManagerImpl implements BusinessRuleManager { |
| 31 | 35 | |
| 32 | 36 | @Autowired |
| 37 | + protected SecurityService securityService; | |
| 38 | + | |
| 39 | + @Autowired | |
| 40 | + protected ParameterService parameterService; | |
| 41 | + | |
| 42 | + @Autowired | |
| 33 | 43 | private RuntimeManager runtimeManager; |
| 34 | 44 | |
| 35 | 45 | @Autowired |
| 36 | 46 | private BusinessRuleVersionDao businessRuleVersionDao; |
| 37 | 47 | |
| 48 | + @Autowired | |
| 49 | + private DocumentService documentService; | |
| 50 | + | |
| 38 | 51 | protected void initialize(RuntimeEnvironment runtimeEnvironment, BusinessRuleVersion businessRuleVersion) { |
| 39 | 52 | BusinessRule businessRule = (BusinessRule) (runtimeEnvironment.hasObject("businessRule") ? runtimeEnvironment.getObject("businessRule") : null); |
| 40 | 53 | if (businessRule == null) { |
| ... | ... | @@ -43,6 +56,21 @@ public class BusinessRuleManagerImpl implements BusinessRuleManager { |
| 43 | 56 | } |
| 44 | 57 | |
| 45 | 58 | runtimeEnvironment.addOrUpdateObject(businessRuleVersion.getName(), businessRule); |
| 59 | + runtimeEnvironment.addOrUpdateObject("businessRuleManager", this); | |
| 60 | + runtimeEnvironment.addObject("securityService", securityService); | |
| 61 | + runtimeEnvironment.addObject("parameterService", parameterService); | |
| 62 | + runtimeEnvironment.addObject("documentService", documentService); | |
| 63 | + if (runtimeEnvironment.getUser() != null) { | |
| 64 | + User user = runtimeEnvironment.getUser(); | |
| 65 | + if (user.getId() != null && !runtimeEnvironment.getFlowName().equalsIgnoreCase(securityService.getUsersFlowName())) { | |
| 66 | + User userAux = securityService.getUser(user.getId()); | |
| 67 | + if (userAux != null) { | |
| 68 | + user.setName(userAux.getName()); | |
| 69 | + user.setCode(userAux.getCode()); | |
| 70 | + } | |
| 71 | + } | |
| 72 | + runtimeEnvironment.addOrUpdateObject("user", user); | |
| 73 | + } | |
| 46 | 74 | } |
| 47 | 75 | |
| 48 | 76 | protected RuntimeEnvironment newEnvironment(RuntimeEnvironment ownerEnvironment, BusinessRuleVersion businessRuleVersion) { | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/core/DataObjectUtil.java
| ... | ... | @@ -510,7 +510,7 @@ public final class DataObjectUtil { |
| 510 | 510 | |
| 511 | 511 | public static StringBuilder selectQueryPiece(DataObject dataObject, DataObjectParams searchParams) { |
| 512 | 512 | StringBuilder sql = new StringBuilder(); |
| 513 | - if (UtilString.isNullOrEmpty(searchParams.getSQLName())) { | |
| 513 | + if (searchParams != null && UtilString.isNullOrEmpty(searchParams.getSQLName())) { | |
| 514 | 514 | int i = 0; |
| 515 | 515 | |
| 516 | 516 | sql.append("SELECT "); |
| ... | ... | @@ -534,7 +534,7 @@ public final class DataObjectUtil { |
| 534 | 534 | public static StringBuilder fromWhereQueryPiece(DataObject dataObject, DataObjectParams searchParams) { |
| 535 | 535 | StringBuilder sql = new StringBuilder(); |
| 536 | 536 | |
| 537 | - if (UtilString.isNullOrEmpty(searchParams.getSQLName())) { | |
| 537 | + if (searchParams == null || UtilString.isNullOrEmpty(searchParams.getSQLName())) { | |
| 538 | 538 | sql.append(" FROM "+dataObject.getFullName()); |
| 539 | 539 | if (searchParams != null && !UtilString.isNullOrEmpty(searchParams.getWhereCustomize())) { |
| 540 | 540 | sql.append(" WHERE "+searchParams.getWhereCustomize()); |
| ... | ... | @@ -586,7 +586,7 @@ public final class DataObjectUtil { |
| 586 | 586 | public static StringBuilder buildFilters(DataObject dataObject, DataObjectParams searchParams) { |
| 587 | 587 | StringBuilder sql = new StringBuilder(); |
| 588 | 588 | |
| 589 | - if (searchParams.getFilters() != null) { | |
| 589 | + if (searchParams != null && searchParams.getFilters() != null) { | |
| 590 | 590 | int i = 0; |
| 591 | 591 | SearchSeven search = new SearchSeven(searchParams); |
| 592 | 592 | if (UtilString.isNullOrEmpty(searchParams.getKeywordValue())) { |
| ... | ... | @@ -747,7 +747,7 @@ public final class DataObjectUtil { |
| 747 | 747 | if (rsColumns.getString("DECIMAL_DIGITS") != null) { |
| 748 | 748 | dataColumn.setPrecision(Integer.parseInt(rsColumns.getString("DECIMAL_DIGITS"))); |
| 749 | 749 | } |
| 750 | - if (dataColumn.getType() != null && dataColumn.getType().getAllowSize() && rsColumns.getString("COLUMN_SIZE") != null) { | |
| 750 | + if (!type.equalsIgnoreCase("text") && dataColumn.getType() != null && dataColumn.getType().getAllowSize() && rsColumns.getString("COLUMN_SIZE") != null) { | |
| 751 | 751 | dataColumn.setSize(Integer.parseInt(rsColumns.getString("COLUMN_SIZE"))); |
| 752 | 752 | } |
| 753 | 753 | dataColumn.setMandatory(rsColumns.getString("NULLABLE") != null && rsColumns.getString("NULLABLE").trim().equals("0")); |
| ... | ... | @@ -757,23 +757,16 @@ public final class DataObjectUtil { |
| 757 | 757 | // + " " + rsColumns.getString("NULLABLE") + " " + rsColumns.getString("COLUMN_DEF")); |
| 758 | 758 | } |
| 759 | 759 | rsColumns.close(); |
| 760 | + ResultSet rsPK = meta.getPrimaryKeys(rs.getString("TABLE_CAT"), rs.getString("TABLE_SCHEM"), rs.getString("TABLE_NAME")); | |
| 761 | + while (rsPK.next()) { | |
| 762 | + for (DataColumn dataColumn : columns) { | |
| 763 | + if (rsPK.getString("COLUMN_NAME").equalsIgnoreCase(dataColumn.getName()) && rsPK.getString("TABLE_NAME").equalsIgnoreCase(tableName)) { | |
| 764 | + dataColumn.setPk(true); | |
| 765 | + } | |
| 766 | + } | |
| 767 | + } | |
| 768 | + rsPK.close(); | |
| 760 | 769 | } |
| 761 | - ResultSet rsPK = meta.getPrimaryKeys(rs.getString("TABLE_CAT"), rs.getString("TABLE_SCHEM"), rs.getString("TABLE_NAME")); | |
| 762 | - while (rsPK.next()) { | |
| 763 | - for (DataColumn dataColumn : columns) { | |
| 764 | - if (rsPK.getString("COLUMN_NAME").equalsIgnoreCase(dataColumn.getName()) && rsPK.getString("TABLE_NAME").equalsIgnoreCase(tableName)) { | |
| 765 | - dataColumn.setPk(true); | |
| 766 | - } | |
| 767 | - } | |
| 768 | - } | |
| 769 | - rsPK.close(); | |
| 770 | -/* ResultSet rsFK = meta.getCrossReference(rs.getString("TABLE_CAT"), rs.getString("TABLE_SCHEM"), rs.getString("TABLE_NAME"), null, null, null); | |
| 771 | - while (rsFK.next()) { | |
| 772 | - for (DataColumn dataColumn : columns) { | |
| 773 | - | |
| 774 | - } | |
| 775 | - } | |
| 776 | - rsFK.close();*/ | |
| 777 | 770 | } |
| 778 | 771 | } |
| 779 | 772 | finally { | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/dao/ReportDataSourceDao.java
0 → 100644
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/dao/ReportParameterDao.java
0 → 100644
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/model/CustomSQL.java
| ... | ... | @@ -36,7 +36,7 @@ public class CustomSQL extends PersistentObject { |
| 36 | 36 | |
| 37 | 37 | @Id |
| 38 | 38 | @GeneratedValue(strategy = GenerationType.AUTO) |
| 39 | - @JsonView({Views.EsiDataObjectListView.class, Views.EsiDataObjectEditView.class }) | |
| 39 | + @JsonView({Views.GenericView.class }) | |
| 40 | 40 | protected Long id; |
| 41 | 41 | |
| 42 | 42 | @ManyToOne(fetch=FetchType.LAZY, optional=false) |
| ... | ... | @@ -44,15 +44,15 @@ public class CustomSQL extends PersistentObject { |
| 44 | 44 | protected DataObject dataObject; |
| 45 | 45 | |
| 46 | 46 | @Column(nullable = false) |
| 47 | - @JsonView({ Views.EsiDataObjectListView.class, Views.EsiDataObjectEditView.class, Views.EsiPackageExportView.class}) | |
| 47 | + @JsonView({ Views.GenericView.class}) | |
| 48 | 48 | private SqlClauseTypeEnum type; |
| 49 | 49 | |
| 50 | 50 | @Column(nullable = true, length=100) |
| 51 | - @JsonView({ Views.EsiDataObjectListView.class, Views.EsiDataObjectEditView.class, Views.EsiPackageExportView.class}) | |
| 51 | + @JsonView({ Views.GenericView.class}) | |
| 52 | 52 | private String name; |
| 53 | 53 | |
| 54 | 54 | @Column(nullable = true, length=255) |
| 55 | - @JsonView({ Views.EsiDataObjectListView.class, Views.EsiDataObjectEditView.class, Views.EsiPackageExportView.class}) | |
| 55 | + @JsonView({ Views.GenericView.class}) | |
| 56 | 56 | private String description; |
| 57 | 57 | |
| 58 | 58 | @Column(nullable = false) |
| ... | ... | @@ -85,7 +85,7 @@ public class CustomSQL extends PersistentObject { |
| 85 | 85 | |
| 86 | 86 | @PrePersist |
| 87 | 87 | protected void onPrePersist() { |
| 88 | - if (UtilString.isNullOrEmpty(this.sql)) { | |
| 88 | + if (UtilString.isNullOrEmpty(this.sql) && this.type.equals(SqlClauseTypeEnum.SELECT)) { | |
| 89 | 89 | this.sql = this.selectQueryPiece != null ? this.selectQueryPiece : ""; |
| 90 | 90 | this.sql += this.fromWhereQueryPiece != null ? " " + this.fromWhereQueryPiece : ""; |
| 91 | 91 | this.sql += this.orderQueryPiece != null ? " " + this.orderQueryPiece : ""; | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/model/DataObject.java
| ... | ... | @@ -43,7 +43,7 @@ public class DataObject extends PersistentObjectAudit { |
| 43 | 43 | |
| 44 | 44 | @Id |
| 45 | 45 | @GeneratedValue(strategy = GenerationType.AUTO) |
| 46 | - @JsonView({Views.EsiDataObjectListView.class, Views.EsiDataObjectEditView.class }) | |
| 46 | + @JsonView({Views.GenericView.class}) | |
| 47 | 47 | protected Long id; |
| 48 | 48 | |
| 49 | 49 | @ManyToOne(fetch=FetchType.LAZY, optional=false) |
| ... | ... | @@ -71,7 +71,7 @@ public class DataObject extends PersistentObjectAudit { |
| 71 | 71 | protected Resource form; |
| 72 | 72 | |
| 73 | 73 | @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "dataObject", fetch = FetchType.LAZY) |
| 74 | - @JsonView({ Views.EsiDataObjectEditView.class, Views.EsiPackageExportView.class}) | |
| 74 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiDataObjectEditView.class, Views.EsiPackageExportView.class}) | |
| 75 | 75 | private List<CustomSQL> sqls; |
| 76 | 76 | |
| 77 | 77 | @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "dataObject", fetch = FetchType.LAZY) | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/model/DataSource.java
| ... | ... | @@ -30,7 +30,7 @@ public class DataSource extends PersistentObjectAudit { |
| 30 | 30 | |
| 31 | 31 | @Id |
| 32 | 32 | @GeneratedValue(strategy = GenerationType.AUTO) |
| 33 | - @JsonView({Views.EsiDataObjectListView.class, Views.EsiDataObjectEditView.class }) | |
| 33 | + @JsonView({Views.GenericView.class }) | |
| 34 | 34 | protected Long id; |
| 35 | 35 | |
| 36 | 36 | @Column(nullable = false, length=100) | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/data/service/impl/DataManager.java
| ... | ... | @@ -6,6 +6,7 @@ import java.util.ArrayList; |
| 6 | 6 | import java.util.HashMap; |
| 7 | 7 | import java.util.List; |
| 8 | 8 | |
| 9 | +import org.json.JSONObject; | |
| 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | 11 | import org.springframework.stereotype.Component; |
| 11 | 12 | |
| ... | ... | @@ -29,11 +30,14 @@ import br.com.centralit.esi.api.design.model.Flow; |
| 29 | 30 | import br.com.centralit.esi.api.enumerated.DatabaseTypeEnum; |
| 30 | 31 | import br.com.centralit.esi.api.enumerated.RelationshipTypeEnum; |
| 31 | 32 | import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum; |
| 33 | +import br.com.centralit.esi.api.util.ConvertUtilsESI; | |
| 32 | 34 | import br.com.centralit.esi.exception.EsiBusinessException; |
| 33 | 35 | import br.com.centralit.esi.exception.EsiControlledException; |
| 34 | 36 | import br.com.centralit.esi.exception.EsiExecutionException; |
| 35 | 37 | import br.com.centralit.framework.esi.enumerated.VariableTypeEnum; |
| 36 | 38 | import br.com.centralit.framework.esi.environment.EnvironmentVariable; |
| 39 | +import br.com.centralit.framework.model.Filter; | |
| 40 | +import br.com.centralit.framework.util.ConstantsQuery; | |
| 37 | 41 | import br.com.centralit.framework.util.UtilString; |
| 38 | 42 | |
| 39 | 43 | @Component("dataManager") |
| ... | ... | @@ -45,28 +49,49 @@ public class DataManager { |
| 45 | 49 | @Autowired |
| 46 | 50 | private BusinessRuleManager businessRuleManager; |
| 47 | 51 | |
| 48 | - private void restoreRelationship(Relationship relationship, HashMap<String, Object> line) { | |
| 49 | - if (relationship.getSearchObject() != null) { | |
| 50 | - HashMap<String, Object> object = this.executeDefaultRestore(relationship.getReferencedObject(), relationship.getSearchObject()); | |
| 51 | - if (object != null) { | |
| 52 | - for (String key : object.keySet()) { | |
| 53 | - line.put(relationship.getReferencedObject().getName()+"."+key, object.get(key)); | |
| 52 | + private void restoreRelationship(Relationship relationship, HashMap<String, Object> searchObject, HashMap<String, Object> line) { | |
| 53 | + if (searchObject != null) { | |
| 54 | + if (relationship.getType().equals(RelationshipTypeEnum.MANY_TO_ONE)) { | |
| 55 | + HashMap<String, Object> object = this.executeDefaultRestore(relationship.getReferencedObject(), searchObject); | |
| 56 | + if (object != null) { | |
| 57 | + for (String key : object.keySet()) { | |
| 58 | + line.put(relationship.getReferencedObject().getName()+"."+key, object.get(key)); | |
| 59 | + } | |
| 60 | + } | |
| 61 | + }else if (relationship.getType().equals(RelationshipTypeEnum.ONE_TO_MANY)) { | |
| 62 | + DataObjectParams searchParams = new DataObjectParams(); | |
| 63 | + searchParams.setStart(1); | |
| 64 | + searchParams.setLimit(99999); | |
| 65 | + List<Filter> filters = new ArrayList<Filter>(); | |
| 66 | + | |
| 67 | + for (String key : searchObject.keySet()) { | |
| 68 | + DataColumn dataColumn = relationship.getReferencedObject().getColumn(key); | |
| 69 | + if (dataColumn != null) { | |
| 70 | + filters.add(new Filter(key, dataColumn.getSearchType(), searchObject.get(key).toString(), ConstantsQuery.COMPARE_EQUALS)); | |
| 71 | + } | |
| 54 | 72 | } |
| 73 | + searchParams.setFilters(filters); | |
| 74 | + Page<HashMap<String, Object>> page = this.executePagedQuery(relationship.getReferencedObject(), searchObject, searchParams); | |
| 75 | + line.put(relationship.getAttributeName(), page.getContent()); | |
| 55 | 76 | } |
| 56 | 77 | } |
| 57 | 78 | } |
| 79 | + | |
| 80 | + public void restoreAllRelationships(DataObject dataObject, List<HashMap<String, Object>> lines) { | |
| 81 | + this.restoreRelationships(dataObject, RelationshipTypeEnum.MANY_TO_ONE, lines); | |
| 82 | + this.restoreRelationships(dataObject, RelationshipTypeEnum.ONE_TO_MANY, lines); | |
| 83 | + } | |
| 58 | 84 | |
| 59 | - private void findRelationships(DataObject dataObject, List<HashMap<String, Object>> lines) { | |
| 85 | + public void restoreRelationships(DataObject dataObject, RelationshipTypeEnum relationshipType, List<HashMap<String, Object>> lines) { | |
| 60 | 86 | if (dataObject.getRelationships() != null) { |
| 61 | 87 | for (HashMap<String, Object> line : lines) { |
| 62 | 88 | for (Relationship relationship : dataObject.getRelationships()) { |
| 63 | - if (relationship.getType().equals(RelationshipTypeEnum.MANY_TO_ONE)) { | |
| 89 | + if (relationship.getType().equals(relationshipType)) { | |
| 64 | 90 | HashMap<String, Object> searchObject = new HashMap<String, Object>(); |
| 65 | 91 | for (RelationshipColumn relationshipColumn : relationship.getColumns()) { |
| 66 | 92 | searchObject.put(relationshipColumn.getReferencedColumn().getName(), line.get(relationshipColumn.getObjectColumn().getName())); |
| 67 | 93 | } |
| 68 | - relationship.setSearchObject(searchObject); | |
| 69 | - restoreRelationship(relationship, line); | |
| 94 | + this.restoreRelationship(relationship, searchObject, line); | |
| 70 | 95 | } |
| 71 | 96 | } |
| 72 | 97 | } |
| ... | ... | @@ -107,32 +132,37 @@ public class DataManager { |
| 107 | 132 | } |
| 108 | 133 | |
| 109 | 134 | String action = (String) objectInArray.get("relationshipAction"); |
| 110 | - if (action != null) { | |
| 111 | - if (action.equalsIgnoreCase("insert")) { | |
| 112 | - this.executeDefaultInsert(relationship.getReferencedObject(), objectInArray); | |
| 113 | - }else if (action.equalsIgnoreCase("update")) { | |
| 114 | - this.executeDefaultUpdate(relationship.getReferencedObject(), objectInArray); | |
| 115 | - } | |
| 116 | - } | |
| 135 | + if (action == null) { | |
| 136 | + action = "insert"; | |
| 137 | + } | |
| 138 | + if (action.equalsIgnoreCase("insert")) { | |
| 139 | + this.executeDefaultInsert(relationship.getReferencedObject(), objectInArray); | |
| 140 | + }else if (action.equalsIgnoreCase("update")) { | |
| 141 | + this.executeDefaultUpdate(relationship.getReferencedObject(), objectInArray); | |
| 142 | + } | |
| 117 | 143 | } |
| 118 | 144 | } |
| 119 | 145 | } |
| 120 | 146 | } |
| 121 | 147 | } |
| 122 | 148 | |
| 123 | - private void executeBusinessRule(Connection connection, DataObject dataObject, HashMap<String, Object> data, Flow businessRuleFlow) { | |
| 149 | + private HashMap<String, Object> executeBusinessRule(Connection connection, DataObject dataObject, HashMap<String, Object> data, Flow businessRuleFlow) { | |
| 124 | 150 | List<EnvironmentVariable> variables = new ArrayList<EnvironmentVariable>(); |
| 125 | - variables.add(new EnvironmentVariable("dataManager", VariableTypeEnum.JAVAOBJECT, this, false)); | |
| 126 | - variables.add(new EnvironmentVariable("connection", VariableTypeEnum.JAVAOBJECT, connection, false)); | |
| 127 | - variables.add(new EnvironmentVariable("dataObject", VariableTypeEnum.JAVAOBJECT, dataObject, false)); | |
| 128 | - variables.add(new EnvironmentVariable("data", VariableTypeEnum.JSON, data, false)); | |
| 129 | - variables.add(new EnvironmentVariable(dataObject.getName(), VariableTypeEnum.JSON, data, false)); | |
| 151 | + variables.add(new EnvironmentVariable("dataManager", VariableTypeEnum.JAVAOBJECT, this, true)); | |
| 152 | + variables.add(new EnvironmentVariable("connection", VariableTypeEnum.JAVAOBJECT, connection, true)); | |
| 153 | + variables.add(new EnvironmentVariable("dataObject", VariableTypeEnum.JAVAOBJECT, dataObject, true)); | |
| 154 | + variables.add(new EnvironmentVariable(dataObject.getName(), VariableTypeEnum.JSON, data, true)); | |
| 130 | 155 | |
| 131 | - BusinessRuleBase businessRule = ((BusinessRuleOutput) businessRuleManager.execute(businessRuleFlow.getName(), variables)).getBusinessRule(); | |
| 156 | + BusinessRuleOutput output = businessRuleManager.execute(businessRuleFlow.getName(), variables); | |
| 157 | + BusinessRuleBase businessRule = output.getBusinessRule(); | |
| 132 | 158 | |
| 133 | 159 | if (!businessRule.isValid()) { |
| 134 | 160 | throw new EsiControlledException(businessRule.formatHtmlMessages()); |
| 135 | 161 | } |
| 162 | + | |
| 163 | + JSONObject jsonObject = (JSONObject) output.getRuntimeEnvironment().getObject(dataObject.getName()); | |
| 164 | + | |
| 165 | + return ConvertUtilsESI.convertJsonToMap(jsonObject); | |
| 136 | 166 | } |
| 137 | 167 | |
| 138 | 168 | public List<HashMap<String, Object>> executeQuery(DataObject dataObject, String SQLName, HashMap<String, Object> map) { |
| ... | ... | @@ -193,7 +223,7 @@ public class DataManager { |
| 193 | 223 | } |
| 194 | 224 | |
| 195 | 225 | if (searchParams.isFindRelationships()) { |
| 196 | - this.findRelationships(dataObject, result); | |
| 226 | + this.restoreRelationships(dataObject, RelationshipTypeEnum.MANY_TO_ONE, result); | |
| 197 | 227 | } |
| 198 | 228 | return new PageImpl<HashMap<String, Object>>(result, pageable, totalElements); |
| 199 | 229 | } |
| ... | ... | @@ -211,7 +241,7 @@ public class DataManager { |
| 211 | 241 | |
| 212 | 242 | try{ |
| 213 | 243 | if (dataObject.getInsertRule() != null) { |
| 214 | - this.executeBusinessRule(connection, dataObject, map, dataObject.getInsertRule()); | |
| 244 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getInsertRule()); | |
| 215 | 245 | } |
| 216 | 246 | |
| 217 | 247 | DataObjectUtil.executeSQL(dataObject, connection, sql, map); |
| ... | ... | @@ -241,7 +271,7 @@ public class DataManager { |
| 241 | 271 | |
| 242 | 272 | try{ |
| 243 | 273 | if (dataObject.getUpdateRule() != null) { |
| 244 | - this.executeBusinessRule(connection, dataObject, map, dataObject.getUpdateRule()); | |
| 274 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getUpdateRule()); | |
| 245 | 275 | } |
| 246 | 276 | |
| 247 | 277 | DataObjectUtil.executeSQL(dataObject, connection, sql, map); |
| ... | ... | @@ -267,7 +297,7 @@ public class DataManager { |
| 267 | 297 | |
| 268 | 298 | try{ |
| 269 | 299 | if (dataObject.getDeleteRule() != null) { |
| 270 | - this.executeBusinessRule(connection, dataObject, map, dataObject.getDeleteRule()); | |
| 300 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getDeleteRule()); | |
| 271 | 301 | } |
| 272 | 302 | |
| 273 | 303 | DataObjectUtil.executeSQL(dataObject, connection, sql, map); |
| ... | ... | @@ -292,7 +322,7 @@ public class DataManager { |
| 292 | 322 | |
| 293 | 323 | try{ |
| 294 | 324 | if (dataObject.getInsertRule() != null) { |
| 295 | - this.executeBusinessRule(connection, dataObject, map, dataObject.getInsertRule()); | |
| 325 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getInsertRule()); | |
| 296 | 326 | } |
| 297 | 327 | |
| 298 | 328 | DataObjectUtil.executeSQL(dataObject, connection, sql, map); |
| ... | ... | @@ -323,7 +353,7 @@ public class DataManager { |
| 323 | 353 | |
| 324 | 354 | try{ |
| 325 | 355 | if (dataObject.getUpdateRule() != null) { |
| 326 | - this.executeBusinessRule(connection, dataObject, map, dataObject.getUpdateRule()); | |
| 356 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getUpdateRule()); | |
| 327 | 357 | } |
| 328 | 358 | |
| 329 | 359 | DataObjectUtil.executeSQL(dataObject, connection, sql, map); |
| ... | ... | @@ -373,7 +403,7 @@ public class DataManager { |
| 373 | 403 | |
| 374 | 404 | try{ |
| 375 | 405 | if (dataObject.getDeleteRule() != null) { |
| 376 | - this.executeBusinessRule(connection, dataObject, map, dataObject.getDeleteRule()); | |
| 406 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getDeleteRule()); | |
| 377 | 407 | } |
| 378 | 408 | |
| 379 | 409 | DataObjectUtil.executeSQL(dataObject, connection, sql, map); |
| ... | ... | @@ -386,8 +416,8 @@ public class DataManager { |
| 386 | 416 | } |
| 387 | 417 | } |
| 388 | 418 | |
| 389 | - public List<HashMap<String, Object>> executeTransaction(SqlClauseTypeEnum SQLType, String SQLName, DataObject dataObject, HashMap<String, Object> map) { | |
| 390 | - List<HashMap<String, Object>> result = null; | |
| 419 | + public Object executeTransaction(SqlClauseTypeEnum SQLType, String SQLName, DataObject dataObject, HashMap<String, Object> map) { | |
| 420 | + Object result = null; | |
| 391 | 421 | |
| 392 | 422 | boolean defaultSQL = UtilString.isNullOrEmpty(SQLName) || SQLName.equalsIgnoreCase("Default"); |
| 393 | 423 | String sql = DataObjectUtil.buildSQL(dataObject, SQLType, defaultSQL, SQLName); |
| ... | ... | @@ -400,8 +430,25 @@ public class DataManager { |
| 400 | 430 | if (SQLType.equals(SqlClauseTypeEnum.SELECT)) { |
| 401 | 431 | result = DataObjectUtil.executeQuery(dataObject, connection, sql, map); |
| 402 | 432 | }else { |
| 433 | + if (SQLType.equals(SqlClauseTypeEnum.INSERT) && dataObject.getInsertRule() != null) { | |
| 434 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getInsertRule()); | |
| 435 | + }else if (SQLType.equals(SqlClauseTypeEnum.UPDATE) && dataObject.getUpdateRule() != null) { | |
| 436 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getUpdateRule()); | |
| 437 | + }else if (SQLType.equals(SqlClauseTypeEnum.DELETE) && dataObject.getDeleteRule() != null) { | |
| 438 | + map = this.executeBusinessRule(connection, dataObject, map, dataObject.getDeleteRule()); | |
| 439 | + } | |
| 440 | + | |
| 403 | 441 | DataObjectUtil.executeSQL(dataObject, connection, sql, map); |
| 442 | + if (SQLType.equals(SqlClauseTypeEnum.INSERT)) { | |
| 443 | + DataObjectUtil.verifyIdentity(dataObject, connection, map); | |
| 444 | + } | |
| 404 | 445 | this.dataSourceService.commit(connection); |
| 446 | + | |
| 447 | + if (!SQLType.equals(SqlClauseTypeEnum.DELETE)) { | |
| 448 | + this.updateRelationships(dataObject, map); | |
| 449 | + } | |
| 450 | + | |
| 451 | + result = map; | |
| 405 | 452 | } |
| 406 | 453 | } catch (Exception e) { |
| 407 | 454 | this.dataSourceService.rollback(connection); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/model/FlowElement.java
| ... | ... | @@ -39,7 +39,6 @@ import br.com.centralit.esi.api.design.model.connector.DatabaseCommit; |
| 39 | 39 | import br.com.centralit.esi.api.design.model.connector.DatabaseConnector; |
| 40 | 40 | import br.com.centralit.esi.api.design.model.connector.DatabaseRollback; |
| 41 | 41 | import br.com.centralit.esi.api.design.model.connector.DatabaseSql; |
| 42 | -import br.com.centralit.esi.api.design.model.connector.DatabaseTransaction; | |
| 43 | 42 | import br.com.centralit.esi.api.design.model.event.CatchLinkEvent; |
| 44 | 43 | import br.com.centralit.esi.api.design.model.event.ConditionalStartEvent; |
| 45 | 44 | import br.com.centralit.esi.api.design.model.event.EndEvent; |
| ... | ... | @@ -61,6 +60,7 @@ import br.com.centralit.esi.api.design.model.itsm.ItsmDataRequest; |
| 61 | 60 | import br.com.centralit.esi.api.design.model.itsm.ItsmServiceRequest; |
| 62 | 61 | import br.com.centralit.esi.api.design.model.task.BpeSubProcess; |
| 63 | 62 | import br.com.centralit.esi.api.design.model.task.BusinessRuleSubProcess; |
| 63 | +import br.com.centralit.esi.api.design.model.task.DatabaseTransaction; | |
| 64 | 64 | import br.com.centralit.esi.api.design.model.task.EmailTask; |
| 65 | 65 | import br.com.centralit.esi.api.design.model.task.EsiSubProcess; |
| 66 | 66 | import br.com.centralit.esi.api.design.model.task.JavaScriptTask; | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/model/FlowVariable.java
| ... | ... | @@ -62,6 +62,9 @@ public class FlowVariable extends PersistentObject { |
| 62 | 62 | |
| 63 | 63 | @JsonView({ Views.GenericView.class}) |
| 64 | 64 | private Boolean input; |
| 65 | + | |
| 66 | + @JsonView({ Views.GenericView.class}) | |
| 67 | + private Boolean statusVariable; | |
| 65 | 68 | |
| 66 | 69 | @Override |
| 67 | 70 | public Long getId() { |
| ... | ... | @@ -213,6 +216,16 @@ public class FlowVariable extends PersistentObject { |
| 213 | 216 | this.input = false; |
| 214 | 217 | if (this.output == null) |
| 215 | 218 | this.output = false; |
| 219 | + if (this.statusVariable == null) | |
| 220 | + this.statusVariable = false; | |
| 221 | + } | |
| 222 | + | |
| 223 | + public Boolean getStatusVariable() { | |
| 224 | + return statusVariable; | |
| 225 | + } | |
| 226 | + | |
| 227 | + public void setStatusVariable(Boolean statusVariable) { | |
| 228 | + this.statusVariable = statusVariable; | |
| 216 | 229 | } |
| 217 | 230 | |
| 218 | 231 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/model/connector/DatabaseTransaction.java
| ... | ... | @@ -1,111 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.design.model.connector; | |
| 2 | - | |
| 3 | -import javax.persistence.Column; | |
| 4 | -import javax.persistence.Entity; | |
| 5 | -import javax.persistence.PrimaryKeyJoinColumn; | |
| 6 | -import javax.persistence.Table; | |
| 7 | - | |
| 8 | -import br.com.centralit.esi.api.annotation.FlowElementDesign; | |
| 9 | -import br.com.centralit.esi.api.annotation.FlowElementProperty; | |
| 10 | -import br.com.centralit.esi.api.design.model.task.Activity; | |
| 11 | -import br.com.centralit.esi.api.enumerated.FlowElementGroupEnum; | |
| 12 | -import br.com.centralit.esi.api.enumerated.PropertyElementTypeEnum; | |
| 13 | -import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum; | |
| 14 | -import br.com.centralit.framework.json.Views; | |
| 15 | - | |
| 16 | -import com.fasterxml.jackson.annotation.JsonView; | |
| 17 | - | |
| 18 | -@Entity | |
| 19 | -@Table(name="ESI_DatabaseTransaction") | |
| 20 | -@PrimaryKeyJoinColumn(name = "id") | |
| 21 | -@FlowElementDesign( name = "Objeto de Banco de Dados", shortName="Objeto de Banco", | |
| 22 | - forBusinessProcesses = false, | |
| 23 | - group = FlowElementGroupEnum.CONNECTORS, hasBoundary = true, | |
| 24 | - groupSequence=6, | |
| 25 | - displayIdentifier=true) | |
| 26 | -public class DatabaseTransaction extends Activity { | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * | |
| 30 | - */ | |
| 31 | - private static final long serialVersionUID = -8036918100153568266L; | |
| 32 | - | |
| 33 | - @FlowElementProperty(tab=1, title="Nome da conexão BD", type=PropertyElementTypeEnum.TEXT, maxLength=100, isRequired=true) | |
| 34 | - @Column(nullable = false, length=100) | |
| 35 | - @JsonView({ Views.GenericView.class}) | |
| 36 | - private String dataSourceName; | |
| 37 | - | |
| 38 | - @FlowElementProperty(tab=1, title="Nome do objeto BD", type=PropertyElementTypeEnum.TEXT, maxLength=100, isRequired=true, isIdentifier=true) | |
| 39 | - @Column(nullable = false, length=120) | |
| 40 | - @JsonView({ Views.GenericView.class}) | |
| 41 | - private String dataObjectName; | |
| 42 | - | |
| 43 | - @FlowElementProperty(tab=1, title="Tipo de SQL", type=PropertyElementTypeEnum.COMBO, options=SqlClauseTypeEnum.class, maxLength=3, isRequired=true) | |
| 44 | - @Column(nullable = false) | |
| 45 | - @JsonView({ Views.GenericView.class}) | |
| 46 | - private SqlClauseTypeEnum SQLType; | |
| 47 | - | |
| 48 | - @FlowElementProperty(tab=1, title="Identificação do SQL", type=PropertyElementTypeEnum.TEXT, maxLength=100) | |
| 49 | - @Column(nullable = true, length=100) | |
| 50 | - @JsonView({ Views.GenericView.class}) | |
| 51 | - private String SQLName; | |
| 52 | - | |
| 53 | - @FlowElementProperty(tab=1, title="Variável JSON de entrada", type=PropertyElementTypeEnum.VARIABLE_NAME, maxLength=100) | |
| 54 | - @Column(nullable = true, length=100) | |
| 55 | - @JsonView({ Views.GenericView.class}) | |
| 56 | - private String inputVariableName; | |
| 57 | - | |
| 58 | - @FlowElementProperty(tab=1, title="Variável JSON de saída", type=PropertyElementTypeEnum.VARIABLE_NAME, maxLength=100) | |
| 59 | - @Column(nullable = true, length=100) | |
| 60 | - @JsonView({ Views.GenericView.class}) | |
| 61 | - private String outuptVariableName; | |
| 62 | - | |
| 63 | - public String getDataSourceName() { | |
| 64 | - return dataSourceName; | |
| 65 | - } | |
| 66 | - | |
| 67 | - public void setDataSourceName(String dataSourceName) { | |
| 68 | - this.dataSourceName = dataSourceName; | |
| 69 | - } | |
| 70 | - | |
| 71 | - public String getDataObjectName() { | |
| 72 | - return dataObjectName; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public void setDataObjectName(String dataObjectName) { | |
| 76 | - this.dataObjectName = dataObjectName; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public String getSQLName() { | |
| 80 | - return SQLName; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public void setSQLName(String sQLName) { | |
| 84 | - SQLName = sQLName; | |
| 85 | - } | |
| 86 | - | |
| 87 | - public SqlClauseTypeEnum getSQLType() { | |
| 88 | - return SQLType; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public void setSQLType(SqlClauseTypeEnum sQLType) { | |
| 92 | - SQLType = sQLType; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public String getInputVariableName() { | |
| 96 | - return inputVariableName; | |
| 97 | - } | |
| 98 | - | |
| 99 | - public void setInputVariableName(String inputVariableName) { | |
| 100 | - this.inputVariableName = inputVariableName; | |
| 101 | - } | |
| 102 | - | |
| 103 | - public String getOutuptVariableName() { | |
| 104 | - return outuptVariableName; | |
| 105 | - } | |
| 106 | - | |
| 107 | - public void setOutuptVariableName(String outuptVariableName) { | |
| 108 | - this.outuptVariableName = outuptVariableName; | |
| 109 | - } | |
| 110 | - | |
| 111 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/model/task/DatabaseTransaction.java
0 → 100644
| ... | ... | @@ -0,0 +1,133 @@ |
| 1 | +package br.com.centralit.esi.api.design.model.task; | |
| 2 | + | |
| 3 | +import javax.persistence.Column; | |
| 4 | +import javax.persistence.Entity; | |
| 5 | +import javax.persistence.PrimaryKeyJoinColumn; | |
| 6 | +import javax.persistence.Table; | |
| 7 | + | |
| 8 | +import br.com.centralit.esi.api.annotation.FlowElementDesign; | |
| 9 | +import br.com.centralit.esi.api.annotation.FlowElementProperty; | |
| 10 | +import br.com.centralit.esi.api.enumerated.FlowElementGroupEnum; | |
| 11 | +import br.com.centralit.esi.api.enumerated.PropertyElementTypeEnum; | |
| 12 | +import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum; | |
| 13 | +import br.com.centralit.framework.json.Views; | |
| 14 | + | |
| 15 | +import com.fasterxml.jackson.annotation.JsonView; | |
| 16 | + | |
| 17 | +@Entity | |
| 18 | +@Table(name="ESI_DatabaseTransaction") | |
| 19 | +@PrimaryKeyJoinColumn(name = "id") | |
| 20 | +@FlowElementDesign( name = "Transação de banco de Dados", shortName="Transação BD", | |
| 21 | + group = FlowElementGroupEnum.TASKS, hasBoundary = true, | |
| 22 | + groupSequence=98, | |
| 23 | + displayIdentifier=true) | |
| 24 | +public class DatabaseTransaction extends Activity { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * | |
| 28 | + */ | |
| 29 | + private static final long serialVersionUID = -8036918100153568266L; | |
| 30 | + | |
| 31 | + @FlowElementProperty(tab=1, title="Nome da conexão BD", type=PropertyElementTypeEnum.TEXT, maxLength=100, isRequired=true) | |
| 32 | + @Column(nullable = false, length=100) | |
| 33 | + @JsonView({ Views.GenericView.class}) | |
| 34 | + private String dataSourceName; | |
| 35 | + | |
| 36 | + @FlowElementProperty(tab=1, title="Nome do objeto BD", type=PropertyElementTypeEnum.TEXT, maxLength=100, isRequired=true) | |
| 37 | + @Column(nullable = false, length=120) | |
| 38 | + @JsonView({ Views.GenericView.class}) | |
| 39 | + private String dataObjectName; | |
| 40 | + | |
| 41 | + @FlowElementProperty(tab=1, title="Tipo de SQL", type=PropertyElementTypeEnum.COMBO, options=SqlClauseTypeEnum.class, maxLength=3, isRequired=true) | |
| 42 | + @Column(nullable = false) | |
| 43 | + @JsonView({ Views.GenericView.class}) | |
| 44 | + private SqlClauseTypeEnum SQLType; | |
| 45 | + | |
| 46 | + @FlowElementProperty(tab=1, title="Identificação do SQL", type=PropertyElementTypeEnum.TEXT, maxLength=100) | |
| 47 | + @Column(nullable = true, length=100) | |
| 48 | + @JsonView({ Views.GenericView.class}) | |
| 49 | + private String SQLName; | |
| 50 | + | |
| 51 | + @FlowElementProperty(tab=1, title="Variável JSON de entrada", type=PropertyElementTypeEnum.VARIABLE_NAME, maxLength=100) | |
| 52 | + @Column(nullable = true, length=100) | |
| 53 | + @JsonView({ Views.GenericView.class}) | |
| 54 | + private String inputVariableName; | |
| 55 | + | |
| 56 | + @FlowElementProperty(tab=1, title="Variável JSON de saída", type=PropertyElementTypeEnum.VARIABLE_NAME, maxLength=100) | |
| 57 | + @Column(nullable = true, length=100) | |
| 58 | + @JsonView({ Views.GenericView.class}) | |
| 59 | + private String outuptVariableName; | |
| 60 | + | |
| 61 | + @FlowElementProperty(tab=1, title="ESI.RESTORE_MANY_TO_ONE", type=PropertyElementTypeEnum.BOOLEAN) | |
| 62 | + @JsonView({ Views.GenericView.class}) | |
| 63 | + private Boolean restoreManyToOne; | |
| 64 | + | |
| 65 | + @FlowElementProperty(tab=1, title="ESI.RESTORE_ONE_TO_MANY", type=PropertyElementTypeEnum.BOOLEAN) | |
| 66 | + @JsonView({ Views.GenericView.class}) | |
| 67 | + private Boolean restoreOneToMany; | |
| 68 | + | |
| 69 | + public String getDataSourceName() { | |
| 70 | + return dataSourceName; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setDataSourceName(String dataSourceName) { | |
| 74 | + this.dataSourceName = dataSourceName; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public String getDataObjectName() { | |
| 78 | + return dataObjectName; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setDataObjectName(String dataObjectName) { | |
| 82 | + this.dataObjectName = dataObjectName; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public String getSQLName() { | |
| 86 | + return SQLName; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setSQLName(String sQLName) { | |
| 90 | + SQLName = sQLName; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public SqlClauseTypeEnum getSQLType() { | |
| 94 | + return SQLType; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setSQLType(SqlClauseTypeEnum sQLType) { | |
| 98 | + SQLType = sQLType; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public String getInputVariableName() { | |
| 102 | + return inputVariableName; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setInputVariableName(String inputVariableName) { | |
| 106 | + this.inputVariableName = inputVariableName; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public String getOutuptVariableName() { | |
| 110 | + return outuptVariableName; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setOutuptVariableName(String outuptVariableName) { | |
| 114 | + this.outuptVariableName = outuptVariableName; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public Boolean getRestoreManyToOne() { | |
| 118 | + return restoreManyToOne; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public void setRestoreManyToOne(Boolean restoreManyToOne) { | |
| 122 | + this.restoreManyToOne = restoreManyToOne; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public Boolean getRestoreOneToMany() { | |
| 126 | + return restoreOneToMany; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public void setRestoreOneToMany(Boolean restoreOneToMany) { | |
| 130 | + this.restoreOneToMany = restoreOneToMany; | |
| 131 | + } | |
| 132 | + | |
| 133 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/design/service/impl/FlowVersionServiceImpl.java
| ... | ... | @@ -20,6 +20,7 @@ import br.com.centralit.esi.api.design.model.FlowStatus; |
| 20 | 20 | import br.com.centralit.esi.api.design.model.FlowVariable; |
| 21 | 21 | import br.com.centralit.esi.api.design.model.FlowVersion; |
| 22 | 22 | import br.com.centralit.esi.api.design.model.UserInterface; |
| 23 | +import br.com.centralit.esi.api.design.model.Variable; | |
| 23 | 24 | import br.com.centralit.esi.api.design.service.FlowActionService; |
| 24 | 25 | import br.com.centralit.esi.api.design.service.FlowActorService; |
| 25 | 26 | import br.com.centralit.esi.api.design.service.FlowConnectionService; |
| ... | ... | @@ -35,6 +36,7 @@ import br.com.centralit.esi.api.scheduler.service.EventJobService; |
| 35 | 36 | import br.com.centralit.esi.api.util.EsiAppUtils; |
| 36 | 37 | import br.com.centralit.esi.exception.EsiBusinessException; |
| 37 | 38 | import br.com.centralit.esi.exception.EsiExecutionException; |
| 39 | +import br.com.centralit.framework.esi.enumerated.VariableTypeEnum; | |
| 38 | 40 | import br.com.centralit.framework.model.WorkCalendar; |
| 39 | 41 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
| 40 | 42 | import br.com.centralit.framework.util.UtilDate; |
| ... | ... | @@ -149,6 +151,7 @@ public class FlowVersionServiceImpl extends GenericServiceImpl<FlowVersion, Long |
| 149 | 151 | this.updateFlowActions(null, flowVersion); |
| 150 | 152 | this.updateFlowActors(null, flowVersion); |
| 151 | 153 | this.cloneFlowElements(flowVersion, flowVersion.getElements(), flowVersion.getConnections()); |
| 154 | + this.verifyStatusVariables(flowVersion); | |
| 152 | 155 | |
| 153 | 156 | try { |
| 154 | 157 | flowVersion = super.save(flowVersion); |
| ... | ... | @@ -176,6 +179,8 @@ public class FlowVersionServiceImpl extends GenericServiceImpl<FlowVersion, Long |
| 176 | 179 | newFlowVersion = this.createNewVersion(flowVersion); |
| 177 | 180 | |
| 178 | 181 | this.cloneFlowElements(newFlowVersion, flowVersion.getElements(), flowVersion.getConnections()); |
| 182 | + | |
| 183 | + this.verifyStatusVariables(newFlowVersion); | |
| 179 | 184 | |
| 180 | 185 | newFlowVersion = super.save(newFlowVersion); |
| 181 | 186 | |
| ... | ... | @@ -192,6 +197,8 @@ public class FlowVersionServiceImpl extends GenericServiceImpl<FlowVersion, Long |
| 192 | 197 | this.updateFlowActions(oldFlowVersion, flowVersion); |
| 193 | 198 | this.updateFlowActors(oldFlowVersion, flowVersion); |
| 194 | 199 | this.checkFlowElements(oldFlowVersion, flowVersion); |
| 200 | + | |
| 201 | + this.verifyStatusVariables(flowVersion); | |
| 195 | 202 | |
| 196 | 203 | flowVersion = super.merge(flowVersion); |
| 197 | 204 | |
| ... | ... | @@ -868,6 +875,77 @@ public class FlowVersionServiceImpl extends GenericServiceImpl<FlowVersion, Long |
| 868 | 875 | } |
| 869 | 876 | } |
| 870 | 877 | |
| 878 | + | |
| 879 | + /** | |
| 880 | + * Verifica se existe um status do fluxo com determinado nome | |
| 881 | + * @param flowVersion | |
| 882 | + * @param name | |
| 883 | + * @return | |
| 884 | + */ | |
| 885 | + private boolean hasFlowStatus(FlowVersion flowVersion, String name) { | |
| 886 | + for (FlowStatus flowStatus : flowVersion.getStatusList()) { | |
| 887 | + if (flowStatus.getAcronym() != null && flowStatus.getAcronym().equalsIgnoreCase(name)) { | |
| 888 | + return true; | |
| 889 | + } | |
| 890 | + } | |
| 891 | + return false; | |
| 892 | + } | |
| 893 | + | |
| 894 | + /** | |
| 895 | + * Verifica se existe uma variável do fluxo com determinado nome | |
| 896 | + * @param flowVersion | |
| 897 | + * @param name | |
| 898 | + * @return | |
| 899 | + */ | |
| 900 | + private boolean hasStatusVariable(FlowVersion flowVersion, String name) { | |
| 901 | + for (FlowVariable flowVariable : flowVersion.getVariables()) { | |
| 902 | + if (flowVariable.getStatusVariable() && flowVariable.getVariable().getName().equalsIgnoreCase(name)) { | |
| 903 | + return true; | |
| 904 | + } | |
| 905 | + } | |
| 906 | + return false; | |
| 907 | + } | |
| 908 | + | |
| 909 | + /** | |
| 910 | + * Verifica se as variáveis de status foram criadas | |
| 911 | + * @param flowVersion | |
| 912 | + */ | |
| 913 | + private void verifyStatusVariables(FlowVersion flowVersion) { | |
| 914 | + List<FlowVariable> newList = new ArrayList<FlowVariable>(); | |
| 915 | + for (FlowVariable flowVariable : flowVersion.getVariables()) { | |
| 916 | + if (flowVariable.getStatusVariable() == null) { | |
| 917 | + flowVariable.setStatusVariable(false); | |
| 918 | + } | |
| 919 | + if (flowVariable.getStatusVariable()) { | |
| 920 | + if (this.hasFlowStatus(flowVersion, flowVariable.getVariable().getName())) { | |
| 921 | + flowVariable.setOutput(true); | |
| 922 | + flowVariable.setPersistentVariable(true); | |
| 923 | + flowVariable.setReturnVariable(true); | |
| 924 | + flowVariable.setStatusVariable(true); | |
| 925 | + newList.add(flowVariable); | |
| 926 | + } | |
| 927 | + }else{ | |
| 928 | + newList.add(flowVariable); | |
| 929 | + } | |
| 930 | + } | |
| 931 | + flowVersion.setVariables(newList); | |
| 932 | + for (FlowStatus flowStatus : flowVersion.getStatusList()) { | |
| 933 | + if (flowStatus.getAcronym() != null) { | |
| 934 | + if (!this.hasStatusVariable(flowVersion, flowStatus.getAcronym())) { | |
| 935 | + Variable variable = new Variable(flowStatus.getAcronym(), VariableTypeEnum.BOOLEAN, null, false); | |
| 936 | + FlowVariable flowVariable = new FlowVariable(); | |
| 937 | + flowVariable.setFlowVersion(flowVersion); | |
| 938 | + flowVariable.setOutput(true); | |
| 939 | + flowVariable.setPersistentVariable(true); | |
| 940 | + flowVariable.setReturnVariable(true); | |
| 941 | + flowVariable.setStatusVariable(true); | |
| 942 | + flowVariable.setVariable(variable); | |
| 943 | + flowVersion.getVariables().add(flowVariable); | |
| 944 | + } | |
| 945 | + } | |
| 946 | + } | |
| 947 | + } | |
| 948 | + | |
| 871 | 949 | @Override |
| 872 | 950 | public List<FlowVersion> getAllVersions(FlowVersion flowVersion) { |
| 873 | 951 | return ((FlowVersionDao) dao).getAllVersions(flowVersion); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/ReportDataSourceEnum.java
0 → 100644
| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | +package br.com.centralit.esi.api.enumerated; | |
| 2 | + | |
| 3 | +public enum ReportDataSourceEnum { | |
| 4 | + NONE("ESI.ENUMERADO.DATASOURCE_NENHUM"), | |
| 5 | + CONNECTION("ESI.ENUMERADO.DATASOURCE_CONEXAO"), | |
| 6 | + DATAOBJECT("ESI.ENUMERADO.DATASOURCE_OBJETO_DADOS"), | |
| 7 | + FLOW("ESI.ENUMERADO.DATASOURCE_FLUXO_ESI"), | |
| 8 | + SCRIPT("ESI.ENUMERADO.DATASOURCE_SCRIPT"); | |
| 9 | + | |
| 10 | + private String id; | |
| 11 | + private String description; | |
| 12 | + | |
| 13 | + private ReportDataSourceEnum(String description) { | |
| 14 | + this.id = name(); | |
| 15 | + this.description = description; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public static ReportDataSourceEnum parse(String value) { | |
| 19 | + for (ReportDataSourceEnum item : ReportDataSourceEnum.values()) { | |
| 20 | + if (item.id.equals(value)) { | |
| 21 | + return item; | |
| 22 | + } | |
| 23 | + } | |
| 24 | + return null; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public String getId() { | |
| 28 | + return this.id; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public String getDescription() { | |
| 32 | + return description; | |
| 33 | + } | |
| 34 | +}; | |
| 0 | 35 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/ReportEngineEnum.java
0 → 100644
| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | +package br.com.centralit.esi.api.enumerated; | |
| 2 | + | |
| 3 | +public enum ReportEngineEnum { | |
| 4 | + JASPER("Jasper"), | |
| 5 | + PENTAHO("Pentaho"); | |
| 6 | + | |
| 7 | + private String id; | |
| 8 | + private String description; | |
| 9 | + | |
| 10 | + private ReportEngineEnum(String description) { | |
| 11 | + this.id = name(); | |
| 12 | + this.description = description; | |
| 13 | + } | |
| 14 | + | |
| 15 | + public static ReportEngineEnum parse(String value) { | |
| 16 | + for (ReportEngineEnum item : ReportEngineEnum.values()) { | |
| 17 | + if (item.id.equals(value)) { | |
| 18 | + return item; | |
| 19 | + } | |
| 20 | + } | |
| 21 | + return null; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getId() { | |
| 25 | + return this.id; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public String getDescription() { | |
| 29 | + return description; | |
| 30 | + } | |
| 31 | +}; | |
| 0 | 32 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/ReportParameterTypeEnum.java
0 → 100644
| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | +package br.com.centralit.esi.api.enumerated; | |
| 2 | + | |
| 3 | +public enum ReportParameterTypeEnum { | |
| 4 | + DATAOBJECT("ESI.ENUMERADO.DATASOURCE_OBJETO_DADOS"), | |
| 5 | + FLOW("ESI.ENUMERADO.DATASOURCE_FLUXO_ESI"), | |
| 6 | + SCRIPT("ESI.ENUMERADO.DATASOURCE_SCRIPT"), | |
| 7 | + IMAGE("ESI.ENUMERADO.DATASOURCE_IMAGEM"), | |
| 8 | + CONSTANT("ESI.ENUMERADO.DATASOURCE_CONSTANTE"); | |
| 9 | + | |
| 10 | + private String id; | |
| 11 | + private String description; | |
| 12 | + | |
| 13 | + private ReportParameterTypeEnum(String description) { | |
| 14 | + this.id = name(); | |
| 15 | + this.description = description; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public static ReportParameterTypeEnum parse(String value) { | |
| 19 | + for (ReportParameterTypeEnum item : ReportParameterTypeEnum.values()) { | |
| 20 | + if (item.id.equals(value)) { | |
| 21 | + return item; | |
| 22 | + } | |
| 23 | + } | |
| 24 | + return null; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public String getId() { | |
| 28 | + return this.id; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public String getDescription() { | |
| 32 | + return description; | |
| 33 | + } | |
| 34 | +}; | |
| 0 | 35 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/ResourceTypeEnum.java
| ... | ... | @@ -6,7 +6,8 @@ public enum ResourceTypeEnum { |
| 6 | 6 | JAVASCRIPT("Java Script", "js"), |
| 7 | 7 | CSS("Css", "css"), |
| 8 | 8 | FILE("File", "files"), |
| 9 | - PAGE("Page", "pages"); | |
| 9 | + PAGE("Page", "pages"), | |
| 10 | + REPORT("Report", "reports"); | |
| 10 | 11 | |
| 11 | 12 | private String id; |
| 12 | 13 | private String description; | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteCloseConnectionDBSql.java
| ... | ... | @@ -1,26 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.component; | |
| 2 | - | |
| 3 | -import java.sql.Connection; | |
| 4 | -import java.sql.SQLException; | |
| 5 | - | |
| 6 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 7 | -import br.com.centralit.esi.exception.EsiExecutionException; | |
| 8 | - | |
| 9 | -public class ExecuteCloseConnectionDBSql { | |
| 10 | - public static void execute(RuntimeEnvironment runtimeEnvironment) { | |
| 11 | - String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); | |
| 12 | - if (connName != null){ | |
| 13 | - Connection connection = (Connection) runtimeEnvironment.getObject(connName); | |
| 14 | - if (connection != null){ | |
| 15 | - try { | |
| 16 | - connection.close(); | |
| 17 | - } catch (SQLException e) { | |
| 18 | - e.printStackTrace(); | |
| 19 | - throw new EsiExecutionException(e); | |
| 20 | - } | |
| 21 | - connection = null; | |
| 22 | - } | |
| 23 | - runtimeEnvironment.addOrUpdateObject(connName, null); | |
| 24 | - } | |
| 25 | - } | |
| 26 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteCommitTransactionSql.java
| ... | ... | @@ -1,32 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.component; | |
| 2 | - | |
| 3 | -import java.sql.Connection; | |
| 4 | -import java.sql.SQLException; | |
| 5 | - | |
| 6 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 7 | -import br.com.centralit.esi.exception.EsiExecutionException; | |
| 8 | - | |
| 9 | -public class ExecuteCommitTransactionSql { | |
| 10 | - public static void execute(RuntimeEnvironment runtimeEnvironment) { | |
| 11 | - String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); | |
| 12 | - if (connName != null){ | |
| 13 | - Connection connection = (Connection) runtimeEnvironment.getObject(connName); | |
| 14 | - if (connection != null){ | |
| 15 | - try { | |
| 16 | - connection.commit(); | |
| 17 | - } catch (SQLException e) { | |
| 18 | - e.printStackTrace(); | |
| 19 | - throw new EsiExecutionException(e); | |
| 20 | - } finally{ | |
| 21 | - try { | |
| 22 | - connection.close(); | |
| 23 | - } catch (SQLException e) { | |
| 24 | - e.printStackTrace(); | |
| 25 | - } | |
| 26 | - connection = null; | |
| 27 | - } | |
| 28 | - } | |
| 29 | - runtimeEnvironment.addOrUpdateObject(connName, null); | |
| 30 | - } | |
| 31 | - } | |
| 32 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteConectaIniciaTransactionSql.java
| ... | ... | @@ -1,85 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.component; | |
| 2 | - | |
| 3 | -import java.sql.Connection; | |
| 4 | -import java.sql.DriverManager; | |
| 5 | -import java.sql.SQLException; | |
| 6 | - | |
| 7 | -import javax.naming.Context; | |
| 8 | -import javax.naming.InitialContext; | |
| 9 | -import javax.naming.NamingException; | |
| 10 | -import javax.sql.DataSource; | |
| 11 | - | |
| 12 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 13 | -import br.com.centralit.esi.exception.EsiExecutionException; | |
| 14 | - | |
| 15 | -public class ExecuteConectaIniciaTransactionSql { | |
| 16 | - public static void execute(RuntimeEnvironment runtimeEnvironment) { | |
| 17 | - String driverClassName = (String) runtimeEnvironment.getObject("DRIVERCLASSNAME"); | |
| 18 | - String pathConnection = (String) runtimeEnvironment.getObject("PATHCONNECTION"); | |
| 19 | - String userName = (String) runtimeEnvironment.getObject("USERNAME"); | |
| 20 | - String password = (String) runtimeEnvironment.getObject("PASSWORD"); | |
| 21 | - | |
| 22 | - String connType = (String) runtimeEnvironment.getObject("CONNTYPE"); | |
| 23 | - String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); | |
| 24 | - | |
| 25 | - String autoCommit = (String) runtimeEnvironment.getObject("AUTOCOMMIT"); | |
| 26 | - if (autoCommit == null){ | |
| 27 | - autoCommit = "S"; | |
| 28 | - } | |
| 29 | - if (connType == null){ | |
| 30 | - connType = ""; | |
| 31 | - } | |
| 32 | - | |
| 33 | - | |
| 34 | - Connection connection = null; | |
| 35 | - | |
| 36 | - try { | |
| 37 | - if (connType.trim().equalsIgnoreCase("JNDI")){ | |
| 38 | - String contexto = (String) runtimeEnvironment.getObject("JNDICONTEXT"); | |
| 39 | - String tipo = (String) runtimeEnvironment.getObject("JNDITYPE"); | |
| 40 | - | |
| 41 | - Context cnx = new InitialContext(); | |
| 42 | - DataSource ds; | |
| 43 | - ds = (DataSource) cnx.lookup(contexto + tipo); | |
| 44 | - connection = ds.getConnection(); | |
| 45 | - }else{ | |
| 46 | - try { | |
| 47 | - Class.forName(driverClassName); | |
| 48 | - } catch (ClassNotFoundException e) { | |
| 49 | - e.printStackTrace(); | |
| 50 | - throw new EsiExecutionException(e); | |
| 51 | - } | |
| 52 | - connection = DriverManager.getConnection(pathConnection, userName, password); | |
| 53 | - } | |
| 54 | - } catch (SQLException e) { | |
| 55 | - e.printStackTrace(); | |
| 56 | - throw new EsiExecutionException(e); | |
| 57 | - } catch (NamingException e) { | |
| 58 | - e.printStackTrace(); | |
| 59 | - throw new EsiExecutionException(e); | |
| 60 | - } | |
| 61 | - | |
| 62 | - if (connection != null) { | |
| 63 | - try { | |
| 64 | - if (autoCommit.trim().toUpperCase().equalsIgnoreCase("S") || autoCommit.trim().toUpperCase().equalsIgnoreCase("Y") | |
| 65 | - || autoCommit.trim().toUpperCase().equalsIgnoreCase("TRUE")){ | |
| 66 | - connection.setAutoCommit(true); | |
| 67 | - }else{ | |
| 68 | - connection.setAutoCommit(false); | |
| 69 | - } | |
| 70 | - } catch (SQLException e) { | |
| 71 | - e.printStackTrace(); | |
| 72 | - try { | |
| 73 | - connection.close(); | |
| 74 | - } catch (SQLException e1) { | |
| 75 | - } | |
| 76 | - connection = null; | |
| 77 | - throw new EsiExecutionException(e); | |
| 78 | - } | |
| 79 | - runtimeEnvironment.addOrUpdateObject(connName, connection); | |
| 80 | - } else { | |
| 81 | - System.out.println("ExecutaIniciaTransactionSql: Failed to make connection!"); | |
| 82 | - throw new EsiExecutionException(); | |
| 83 | - } | |
| 84 | - } | |
| 85 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteDBClose.java
0 → 100644
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +package br.com.centralit.esi.api.execution.component; | |
| 2 | + | |
| 3 | +import java.sql.Connection; | |
| 4 | +import java.sql.SQLException; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 7 | +import br.com.centralit.esi.exception.EsiExecutionException; | |
| 8 | + | |
| 9 | +public class ExecuteDBClose { | |
| 10 | + public static void execute(RuntimeEnvironment runtimeEnvironment) { | |
| 11 | + String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); | |
| 12 | + if (connName != null){ | |
| 13 | + Connection connection = (Connection) runtimeEnvironment.getObject(connName); | |
| 14 | + if (connection != null){ | |
| 15 | + try { | |
| 16 | + connection.close(); | |
| 17 | + } catch (SQLException e) { | |
| 18 | + e.printStackTrace(); | |
| 19 | + throw new EsiExecutionException(e); | |
| 20 | + } | |
| 21 | + connection = null; | |
| 22 | + } | |
| 23 | + runtimeEnvironment.addOrUpdateObject(connName, null); | |
| 24 | + } | |
| 25 | + } | |
| 26 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteDBCommit.java
0 → 100644
| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | +package br.com.centralit.esi.api.execution.component; | |
| 2 | + | |
| 3 | +import java.sql.Connection; | |
| 4 | +import java.sql.SQLException; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 7 | +import br.com.centralit.esi.exception.EsiExecutionException; | |
| 8 | + | |
| 9 | +public class ExecuteDBCommit { | |
| 10 | + public static void execute(RuntimeEnvironment runtimeEnvironment) { | |
| 11 | + String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); | |
| 12 | + if (connName != null){ | |
| 13 | + Connection connection = (Connection) runtimeEnvironment.getObject(connName); | |
| 14 | + if (connection != null){ | |
| 15 | + try { | |
| 16 | + connection.commit(); | |
| 17 | + } catch (SQLException e) { | |
| 18 | + e.printStackTrace(); | |
| 19 | + throw new EsiExecutionException(e); | |
| 20 | + } finally{ | |
| 21 | + try { | |
| 22 | + connection.close(); | |
| 23 | + } catch (SQLException e) { | |
| 24 | + e.printStackTrace(); | |
| 25 | + } | |
| 26 | + connection = null; | |
| 27 | + } | |
| 28 | + } | |
| 29 | + runtimeEnvironment.addOrUpdateObject(connName, null); | |
| 30 | + } | |
| 31 | + } | |
| 32 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteDBConnect.java
0 → 100644
| ... | ... | @@ -0,0 +1,85 @@ |
| 1 | +package br.com.centralit.esi.api.execution.component; | |
| 2 | + | |
| 3 | +import java.sql.Connection; | |
| 4 | +import java.sql.DriverManager; | |
| 5 | +import java.sql.SQLException; | |
| 6 | + | |
| 7 | +import javax.naming.Context; | |
| 8 | +import javax.naming.InitialContext; | |
| 9 | +import javax.naming.NamingException; | |
| 10 | +import javax.sql.DataSource; | |
| 11 | + | |
| 12 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 13 | +import br.com.centralit.esi.exception.EsiExecutionException; | |
| 14 | + | |
| 15 | +public class ExecuteDBConnect { | |
| 16 | + public static void execute(RuntimeEnvironment runtimeEnvironment) { | |
| 17 | + String driverClassName = (String) runtimeEnvironment.getObject("DRIVERCLASSNAME"); | |
| 18 | + String pathConnection = (String) runtimeEnvironment.getObject("PATHCONNECTION"); | |
| 19 | + String userName = (String) runtimeEnvironment.getObject("USERNAME"); | |
| 20 | + String password = (String) runtimeEnvironment.getObject("PASSWORD"); | |
| 21 | + | |
| 22 | + String connType = (String) runtimeEnvironment.getObject("CONNTYPE"); | |
| 23 | + String connName = (String) runtimeEnvironment.getObject("CONNECTIONNAME"); | |
| 24 | + | |
| 25 | + String autoCommit = (String) runtimeEnvironment.getObject("AUTOCOMMIT"); | |
| 26 | + if (autoCommit == null){ | |
| 27 | + autoCommit = "S"; | |
| 28 | + } | |
| 29 | + if (connType == null){ | |
| 30 | + connType = ""; | |
| 31 | + } | |
| 32 | + | |
| 33 | + | |
| 34 | + Connection connection = null; | |
| 35 | + | |
| 36 | + try { | |
| 37 | + if (connType.trim().equalsIgnoreCase("JNDI")){ | |
| 38 | + String contexto = (String) runtimeEnvironment.getObject("JNDICONTEXT"); | |
| 39 | + String tipo = (String) runtimeEnvironment.getObject("JNDITYPE"); | |
| 40 | + | |
| 41 | + Context cnx = new InitialContext(); | |
| 42 | + DataSource ds; | |
| 43 | + ds = (DataSource) cnx.lookup(contexto + tipo); | |
| 44 | + connection = ds.getConnection(); | |
| 45 | + }else{ | |
| 46 | + try { | |
| 47 | + Class.forName(driverClassName); | |
| 48 | + } catch (ClassNotFoundException e) { | |
| 49 | + e.printStackTrace(); | |
| 50 | + throw new EsiExecutionException(e); | |
| 51 | + } | |
| 52 | + connection = DriverManager.getConnection(pathConnection, userName, password); | |
| 53 | + } | |
| 54 | + } catch (SQLException e) { | |
| 55 | + e.printStackTrace(); | |
| 56 | + throw new EsiExecutionException(e); | |
| 57 | + } catch (NamingException e) { | |
| 58 | + e.printStackTrace(); | |
| 59 | + throw new EsiExecutionException(e); | |
| 60 | + } | |
| 61 | + | |
| 62 | + if (connection != null) { | |
| 63 | + try { | |
| 64 | + if (autoCommit.trim().toUpperCase().equalsIgnoreCase("S") || autoCommit.trim().toUpperCase().equalsIgnoreCase("Y") | |
| 65 | + || autoCommit.trim().toUpperCase().equalsIgnoreCase("TRUE")){ | |
| 66 | + connection.setAutoCommit(true); | |
| 67 | + }else{ | |
| 68 | + connection.setAutoCommit(false); | |
| 69 | + } | |
| 70 | + } catch (SQLException e) { | |
| 71 | + e.printStackTrace(); | |
| 72 | + try { | |
| 73 | + connection.close(); | |
| 74 | + } catch (SQLException e1) { | |
| 75 | + } | |
| 76 | + connection = null; | |
| 77 | + throw new EsiExecutionException(e); | |
| 78 | + } | |
| 79 | + runtimeEnvironment.addOrUpdateObject(connName, connection); | |
| 80 | + } else { | |
| 81 | + System.out.println("ExecutaIniciaTransactionSql: Failed to make connection!"); | |
| 82 | + throw new EsiExecutionException(); | |
| 83 | + } | |
| 84 | + } | |
| 85 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecutePentahoReport.java
| ... | ... | @@ -13,6 +13,7 @@ import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQ |
| 13 | 13 | import org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.PdfReportUtil; |
| 14 | 14 | import org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlReportUtil; |
| 15 | 15 | import org.pentaho.reporting.engine.classic.core.modules.output.table.xls.ExcelReportUtil; |
| 16 | +import org.pentaho.reporting.engine.classic.core.wizard.RelationalAutoGeneratorPreProcessor; | |
| 16 | 17 | import org.pentaho.reporting.libraries.resourceloader.ResourceException; |
| 17 | 18 | |
| 18 | 19 | import br.com.centralit.esi.api.enumerated.DataSourceTypeEnum; |
| ... | ... | @@ -20,7 +21,7 @@ import br.com.centralit.esi.api.enumerated.ReportFormatTypeEnum; |
| 20 | 21 | import br.com.centralit.esi.api.runtime.RuntimeEnvironment; |
| 21 | 22 | import br.com.centralit.esi.api.util.ConvertUtilsESI; |
| 22 | 23 | import br.com.centralit.esi.api.util.DefaultConvertUtils; |
| 23 | -import br.com.centralit.esi.api.util.PentahooReportUtil; | |
| 24 | +import br.com.centralit.esi.api.util.PentahoReportUtil; | |
| 24 | 25 | import br.com.centralit.esi.exception.EsiExecutionException; |
| 25 | 26 | |
| 26 | 27 | public class ExecutePentahoReport { |
| ... | ... | @@ -89,8 +90,9 @@ public class ExecutePentahoReport { |
| 89 | 90 | driverConnectionProvider.setUrl(pathConnection); |
| 90 | 91 | driverConnectionProvider.setProperty("user", username); |
| 91 | 92 | driverConnectionProvider.setProperty("password", password); |
| 92 | - dataFactory = new SQLReportDataFactory(driverConnectionProvider); | |
| 93 | + dataFactory = new SQLReportDataFactory(driverConnectionProvider); | |
| 93 | 94 | } |
| 95 | + | |
| 94 | 96 | sqlQueries = sqlQueries.replaceAll("\r", "\n"); |
| 95 | 97 | sqlQueries = sqlQueries.replaceAll(";", "\n"); |
| 96 | 98 | String[] linesQueries = sqlQueries.split("\n"); |
| ... | ... | @@ -105,9 +107,9 @@ public class ExecutePentahoReport { |
| 105 | 107 | } |
| 106 | 108 | } |
| 107 | 109 | } |
| 108 | - PentahooReportUtil pentahooReportUtil = new PentahooReportUtil(); | |
| 109 | 110 | try { |
| 110 | - MasterReport report = pentahooReportUtil.getCompleteReportDefinition(pathReport, mapParms, dataFactory); | |
| 111 | + MasterReport report = PentahoReportUtil.getCompleteReportDefinition(pathReport, mapParms, dataFactory); | |
| 112 | + report.addPreProcessor(new RelationalAutoGeneratorPreProcessor()); | |
| 111 | 113 | if (outType.equalsIgnoreCase(ReportFormatTypeEnum.HTML.getId())){ |
| 112 | 114 | try { |
| 113 | 115 | HtmlReportUtil.createDirectoryHTML(report, outPathReport); |
| ... | ... | @@ -116,12 +118,7 @@ public class ExecutePentahoReport { |
| 116 | 118 | throw new EsiExecutionException(e); |
| 117 | 119 | } |
| 118 | 120 | }else if (outType.equalsIgnoreCase(ReportFormatTypeEnum.PDF.getId())){ |
| 119 | - try { | |
| 120 | - PdfReportUtil.createPDF(report, outPathReport); | |
| 121 | - } catch (IOException | ReportProcessingException e) { | |
| 122 | - e.printStackTrace(); | |
| 123 | - throw new EsiExecutionException(e); | |
| 124 | - } | |
| 121 | + PdfReportUtil.createPDF(report, outPathReport); | |
| 125 | 122 | }else if (outType.equalsIgnoreCase(ReportFormatTypeEnum.EXCEL.getId())){ |
| 126 | 123 | try { |
| 127 | 124 | ExcelReportUtil.createXLSX(report, outPathReport); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteReplace.java
0 → 100644
| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | +package br.com.centralit.esi.api.execution.component; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.enumerated.ReplacementTypeEnum; | |
| 4 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 5 | + | |
| 6 | +public class ExecuteReplace { | |
| 7 | + public static void execute(RuntimeEnvironment runtimeEnvironment) { | |
| 8 | + String valuesReplace = (String) runtimeEnvironment.getObject("VALUESREPLACE"); | |
| 9 | + String typeReplace = (String) runtimeEnvironment.getObject("TYPEREPLACE"); | |
| 10 | + if (valuesReplace == null){ | |
| 11 | + valuesReplace = ""; | |
| 12 | + } | |
| 13 | + if (typeReplace == null){ | |
| 14 | + typeReplace = ""; | |
| 15 | + } | |
| 16 | + valuesReplace = valuesReplace.replaceAll("\r", "\n"); | |
| 17 | + valuesReplace = valuesReplace.replaceAll(";", "\n"); | |
| 18 | + | |
| 19 | + String[] linesParms = valuesReplace.split("\n"); | |
| 20 | + if (linesParms != null){ | |
| 21 | + for(int i = 0; i < linesParms.length; i++){ | |
| 22 | + if (linesParms[i] != null && !linesParms[i].trim().equalsIgnoreCase("")){ | |
| 23 | + String[] prop = linesParms[i].split("->"); | |
| 24 | + if (prop != null && prop.length > 2){ | |
| 25 | + if (prop[0] != null){ | |
| 26 | + String nomeVariavel = prop[0].trim(); | |
| 27 | + String value = (String) runtimeEnvironment.getObject(nomeVariavel); | |
| 28 | + if (value == null){ | |
| 29 | + value = ""; | |
| 30 | + } | |
| 31 | + String nomeRegex = null; | |
| 32 | + if (prop[1] != null){ | |
| 33 | + nomeRegex = prop[1].trim(); | |
| 34 | + } | |
| 35 | + if (nomeRegex == null){ | |
| 36 | + nomeRegex = "##NULL##"; //Se entrar aqui eh que tem alguma coisa errada. | |
| 37 | + } | |
| 38 | + String nomeRepl = null; | |
| 39 | + if (prop[2] != null){ | |
| 40 | + nomeRepl = prop[2].trim(); | |
| 41 | + } | |
| 42 | + if (nomeRepl == null){ | |
| 43 | + nomeRepl = "##NULL##"; | |
| 44 | + } | |
| 45 | + | |
| 46 | + if (typeReplace.equalsIgnoreCase(ReplacementTypeEnum.REPLACEALL.getId())){ | |
| 47 | + value = value.replaceAll(nomeRegex, nomeRepl); | |
| 48 | + }else if (typeReplace.equalsIgnoreCase(ReplacementTypeEnum.REPLACEFIRST.getId())){ | |
| 49 | + value = value.replaceFirst(nomeRegex, nomeRepl); | |
| 50 | + }else{ | |
| 51 | + value = value.replaceAll(nomeRegex, nomeRepl); | |
| 52 | + } | |
| 53 | + runtimeEnvironment.addOrUpdateObject(nomeVariavel, value); | |
| 54 | + } | |
| 55 | + } | |
| 56 | + } | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + } | |
| 61 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/component/ExecuteSubstituir.java
| ... | ... | @@ -1,61 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.component; | |
| 2 | - | |
| 3 | -import br.com.centralit.esi.api.enumerated.ReplacementTypeEnum; | |
| 4 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 5 | - | |
| 6 | -public class ExecuteSubstituir { | |
| 7 | - public static void execute(RuntimeEnvironment runtimeEnvironment) { | |
| 8 | - String valuesReplace = (String) runtimeEnvironment.getObject("VALUESREPLACE"); | |
| 9 | - String typeReplace = (String) runtimeEnvironment.getObject("TYPEREPLACE"); | |
| 10 | - if (valuesReplace == null){ | |
| 11 | - valuesReplace = ""; | |
| 12 | - } | |
| 13 | - if (typeReplace == null){ | |
| 14 | - typeReplace = ""; | |
| 15 | - } | |
| 16 | - valuesReplace = valuesReplace.replaceAll("\r", "\n"); | |
| 17 | - valuesReplace = valuesReplace.replaceAll(";", "\n"); | |
| 18 | - | |
| 19 | - String[] linesParms = valuesReplace.split("\n"); | |
| 20 | - if (linesParms != null){ | |
| 21 | - for(int i = 0; i < linesParms.length; i++){ | |
| 22 | - if (linesParms[i] != null && !linesParms[i].trim().equalsIgnoreCase("")){ | |
| 23 | - String[] prop = linesParms[i].split("->"); | |
| 24 | - if (prop != null && prop.length > 2){ | |
| 25 | - if (prop[0] != null){ | |
| 26 | - String nomeVariavel = prop[0].trim(); | |
| 27 | - String value = (String) runtimeEnvironment.getObject(nomeVariavel); | |
| 28 | - if (value == null){ | |
| 29 | - value = ""; | |
| 30 | - } | |
| 31 | - String nomeRegex = null; | |
| 32 | - if (prop[1] != null){ | |
| 33 | - nomeRegex = prop[1].trim(); | |
| 34 | - } | |
| 35 | - if (nomeRegex == null){ | |
| 36 | - nomeRegex = "##NULL##"; //Se entrar aqui eh que tem alguma coisa errada. | |
| 37 | - } | |
| 38 | - String nomeRepl = null; | |
| 39 | - if (prop[2] != null){ | |
| 40 | - nomeRepl = prop[2].trim(); | |
| 41 | - } | |
| 42 | - if (nomeRepl == null){ | |
| 43 | - nomeRepl = "##NULL##"; | |
| 44 | - } | |
| 45 | - | |
| 46 | - if (typeReplace.equalsIgnoreCase(ReplacementTypeEnum.REPLACEALL.getId())){ | |
| 47 | - value = value.replaceAll(nomeRegex, nomeRepl); | |
| 48 | - }else if (typeReplace.equalsIgnoreCase(ReplacementTypeEnum.REPLACEFIRST.getId())){ | |
| 49 | - value = value.replaceFirst(nomeRegex, nomeRepl); | |
| 50 | - }else{ | |
| 51 | - value = value.replaceAll(nomeRegex, nomeRepl); | |
| 52 | - } | |
| 53 | - runtimeEnvironment.addOrUpdateObject(nomeVariavel, value); | |
| 54 | - } | |
| 55 | - } | |
| 56 | - } | |
| 57 | - } | |
| 58 | - } | |
| 59 | - | |
| 60 | - } | |
| 61 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/dao/impl/WorkItemAssignmentDaoHibernate.java
| ... | ... | @@ -24,6 +24,7 @@ public class WorkItemAssignmentDaoHibernate extends CitGenericDAOImpl implements |
| 24 | 24 | public List<WorkItemAssignment> listTasksAssignedAsPotentialOwner(User user) { |
| 25 | 25 | String queryString = "select atribuicao from WorkItemAssignment atribuicao " |
| 26 | 26 | + "where atribuicao.user.id = :actorId " |
| 27 | + + " and dataInativo is null " | |
| 27 | 28 | + " and atribuicao.workItem.status not in (:suspended, :cancelled, :completed, :error) " |
| 28 | 29 | + "order by atribuicao.assignmentTimestamp"; |
| 29 | 30 | |
| ... | ... | @@ -42,6 +43,7 @@ public class WorkItemAssignmentDaoHibernate extends CitGenericDAOImpl implements |
| 42 | 43 | public List<WorkItemAssignment> findByAssignment(WorkItemAssignment workItemAssignment) { |
| 43 | 44 | String queryString = "select atribuicao from WorkItemAssignment atribuicao " |
| 44 | 45 | + "where atribuicao.workItem.id = :workItemId " |
| 46 | + + " and dataInativo is null " | |
| 45 | 47 | + " and assignmentType <> :type"; |
| 46 | 48 | |
| 47 | 49 | if (workItemAssignment.getUser() != null) { | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/model/ProcessInstanceVariableValue.java
| ... | ... | @@ -83,13 +83,13 @@ public class ProcessInstanceVariableValue extends PersistentObject { |
| 83 | 83 | if (value instanceof String) |
| 84 | 84 | this.setStringValue((String)value); |
| 85 | 85 | else |
| 86 | - this.setStringValue(ConvertUtilsESI.toJson(value)); | |
| 86 | + this.setStringValue(ConvertUtilsESI.toJSONString(value)); | |
| 87 | 87 | break; |
| 88 | 88 | case BUSINESSRULE: |
| 89 | 89 | if (value instanceof String) |
| 90 | 90 | this.setStringValue((String)value); |
| 91 | 91 | else |
| 92 | - this.setStringValue(ConvertUtilsESI.toJson(value)); | |
| 92 | + this.setStringValue(ConvertUtilsESI.toJSONString(value)); | |
| 93 | 93 | break; |
| 94 | 94 | case JSON: |
| 95 | 95 | if (value instanceof String) |
| ... | ... | @@ -130,11 +130,11 @@ public class ProcessInstanceVariableValue extends PersistentObject { |
| 130 | 130 | break; |
| 131 | 131 | case JAVAOBJECT: |
| 132 | 132 | if (this.getStringValue() != null && flowVariable.getVariable().getClassName() != null) |
| 133 | - result = ConvertUtilsESI.fromJson(this.getStringValue(), flowVariable.getVariable().getClassName()); | |
| 133 | + result = ConvertUtilsESI.fromJSONString(this.getStringValue(), flowVariable.getVariable().getClassName()); | |
| 134 | 134 | break; |
| 135 | 135 | case BUSINESSRULE: |
| 136 | 136 | if (this.getStringValue() != null) |
| 137 | - result = ConvertUtilsESI.fromJson(this.getStringValue(), BusinessRule.class.getName()); | |
| 137 | + result = ConvertUtilsESI.fromJSONString(this.getStringValue(), BusinessRule.class.getName()); | |
| 138 | 138 | break; |
| 139 | 139 | default: |
| 140 | 140 | result = this.getStringValue(); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemBpeSubProcessService.java
| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import br.com.centralit.esi.api.design.model.task.BpeSubProcess; | |
| 4 | -import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | - | |
| 6 | -public interface WorkItemBpeSubProcessService extends WorkItemService<BpeSubProcess> { | |
| 7 | - | |
| 8 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemBpeSubProcessServiceImpl.java
| ... | ... | @@ -1,42 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | -import org.springframework.stereotype.Service; | |
| 5 | - | |
| 6 | -import br.com.centralit.esi.api.business.service.BusinessProcessManager; | |
| 7 | -import br.com.centralit.esi.api.design.model.FlowElement; | |
| 8 | -import br.com.centralit.esi.api.design.model.task.BpeSubProcess; | |
| 9 | -import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 10 | -import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 11 | -import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 12 | -import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 13 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 14 | - | |
| 15 | -@Service("workItemBpeSubProcessService") | |
| 16 | - | |
| 17 | -public class WorkItemBpeSubProcessServiceImpl extends WorkItemServiceImpl<BpeSubProcess> implements WorkItemBpeSubProcessService { | |
| 18 | - | |
| 19 | - @Autowired | |
| 20 | - private BusinessProcessManager businessProcessManager; | |
| 21 | - | |
| 22 | - @Autowired | |
| 23 | - public WorkItemBpeSubProcessServiceImpl(WorkItemDao workItemDao) { | |
| 24 | - super(workItemDao); | |
| 25 | - } | |
| 26 | - | |
| 27 | - @Override | |
| 28 | - protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 29 | - WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 30 | - BpeSubProcess element = this.getFlowElement(workItem); | |
| 31 | - | |
| 32 | - businessProcessManager.startBusinessProcess(runtimeEnvironment, workItem, element.getBusinessProcessName()); | |
| 33 | - return null; | |
| 34 | - } | |
| 35 | - | |
| 36 | - @Override | |
| 37 | - public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 38 | - complete(runtimeEnvironment, workItem); | |
| 39 | - return retrieveTargets(runtimeEnvironment,workItem); | |
| 40 | - } | |
| 41 | - | |
| 42 | -} | |
| 43 | 0 | \ No newline at end of file |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemBusinessRuleSubProcessService.java
| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import br.com.centralit.esi.api.design.model.task.BusinessRuleSubProcess; | |
| 4 | -import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | - | |
| 6 | -public interface WorkItemBusinessRuleSubProcessService extends WorkItemService<BusinessRuleSubProcess> { | |
| 7 | - | |
| 8 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemBusinessRuleSubProcessServiceImpl.java
| ... | ... | @@ -1,52 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | -import org.springframework.stereotype.Service; | |
| 5 | - | |
| 6 | -import br.com.centralit.esi.api.business.model.BusinessRuleVersion; | |
| 7 | -import br.com.centralit.esi.api.business.service.BusinessRuleManager; | |
| 8 | -import br.com.centralit.esi.api.design.model.FlowElement; | |
| 9 | -import br.com.centralit.esi.api.design.model.task.BusinessRuleSubProcess; | |
| 10 | -import br.com.centralit.esi.api.enumerated.BusinessRuleEngineEnum; | |
| 11 | -import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 12 | -import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 13 | -import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 14 | -import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 15 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 16 | - | |
| 17 | -@Service("workItemBusinessRuleSubProcessService") | |
| 18 | - | |
| 19 | -public class WorkItemBusinessRuleSubProcessServiceImpl extends WorkItemServiceImpl<BusinessRuleSubProcess> implements WorkItemBusinessRuleSubProcessService { | |
| 20 | - | |
| 21 | - @Autowired | |
| 22 | - private BusinessRuleManager businessRuleManager; | |
| 23 | - | |
| 24 | - @Autowired | |
| 25 | - public WorkItemBusinessRuleSubProcessServiceImpl(WorkItemDao workItemDao) { | |
| 26 | - super(workItemDao); | |
| 27 | - } | |
| 28 | - | |
| 29 | - @Override | |
| 30 | - protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 31 | - WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 32 | - | |
| 33 | - BusinessRuleSubProcess element = this.getFlowElement(workItem); | |
| 34 | - | |
| 35 | - BusinessRuleVersion businessRule = businessRuleManager.findBusinessRule(element.getFlowName()); | |
| 36 | - | |
| 37 | - businessRuleManager.execute(runtimeEnvironment, workItem, businessRule); | |
| 38 | - | |
| 39 | - if (!businessRule.getType().equals(BusinessRuleEngineEnum.FLOW)) { | |
| 40 | - return execute(runtimeEnvironment, workItem); | |
| 41 | - }else{ | |
| 42 | - return null; | |
| 43 | - } | |
| 44 | - } | |
| 45 | - | |
| 46 | - @Override | |
| 47 | - public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 48 | - complete(runtimeEnvironment, workItem); | |
| 49 | - return retrieveTargets(runtimeEnvironment,workItem); | |
| 50 | - } | |
| 51 | - | |
| 52 | -} | |
| 53 | 0 | \ No newline at end of file |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemDatabaseCloseServiceImpl.java
| ... | ... | @@ -5,7 +5,7 @@ import org.springframework.stereotype.Service; |
| 5 | 5 | |
| 6 | 6 | import br.com.centralit.esi.api.design.model.FlowElement; |
| 7 | 7 | import br.com.centralit.esi.api.design.model.connector.DatabaseClose; |
| 8 | -import br.com.centralit.esi.api.execution.component.ExecuteCloseConnectionDBSql; | |
| 8 | +import br.com.centralit.esi.api.execution.component.ExecuteDBClose; | |
| 9 | 9 | import br.com.centralit.esi.api.execution.dao.WorkItemDao; |
| 10 | 10 | import br.com.centralit.esi.api.execution.model.ProcessInstance; |
| 11 | 11 | import br.com.centralit.esi.api.execution.model.WorkItem; |
| ... | ... | @@ -36,7 +36,7 @@ public class WorkItemDatabaseCloseServiceImpl extends WorkItemServiceImpl<Databa |
| 36 | 36 | runtimeEnvironment.addOrUpdateObject("CONNECTIONNAME", |
| 37 | 37 | element.getConnectionName()); |
| 38 | 38 | |
| 39 | - ExecuteCloseConnectionDBSql.execute(runtimeEnvironment); | |
| 39 | + ExecuteDBClose.execute(runtimeEnvironment); | |
| 40 | 40 | |
| 41 | 41 | complete(runtimeEnvironment, workItem); |
| 42 | 42 | return retrieveTargets(runtimeEnvironment,workItem); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemDatabaseCommitServiceImpl.java
| ... | ... | @@ -5,7 +5,7 @@ import org.springframework.stereotype.Service; |
| 5 | 5 | |
| 6 | 6 | import br.com.centralit.esi.api.design.model.FlowElement; |
| 7 | 7 | import br.com.centralit.esi.api.design.model.connector.DatabaseCommit; |
| 8 | -import br.com.centralit.esi.api.execution.component.ExecuteCommitTransactionSql; | |
| 8 | +import br.com.centralit.esi.api.execution.component.ExecuteDBCommit; | |
| 9 | 9 | import br.com.centralit.esi.api.execution.dao.WorkItemDao; |
| 10 | 10 | import br.com.centralit.esi.api.execution.model.ProcessInstance; |
| 11 | 11 | import br.com.centralit.esi.api.execution.model.WorkItem; |
| ... | ... | @@ -36,7 +36,7 @@ public class WorkItemDatabaseCommitServiceImpl extends WorkItemServiceImpl<Datab |
| 36 | 36 | runtimeEnvironment.addOrUpdateObject("CONNECTIONNAME", |
| 37 | 37 | element.getConnectionName()); |
| 38 | 38 | |
| 39 | - ExecuteCommitTransactionSql.execute(runtimeEnvironment); | |
| 39 | + ExecuteDBCommit.execute(runtimeEnvironment); | |
| 40 | 40 | |
| 41 | 41 | complete(runtimeEnvironment, workItem); |
| 42 | 42 | return retrieveTargets(runtimeEnvironment,workItem); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemDatabaseConnectorServiceImpl.java
| ... | ... | @@ -6,7 +6,7 @@ import org.springframework.stereotype.Service; |
| 6 | 6 | import br.com.centralit.esi.api.design.model.FlowElement; |
| 7 | 7 | import br.com.centralit.esi.api.design.model.connector.DatabaseConnector; |
| 8 | 8 | import br.com.centralit.esi.api.enumerated.DatabaseConectorTypeEnum; |
| 9 | -import br.com.centralit.esi.api.execution.component.ExecuteConectaIniciaTransactionSql; | |
| 9 | +import br.com.centralit.esi.api.execution.component.ExecuteDBConnect; | |
| 10 | 10 | import br.com.centralit.esi.api.execution.dao.WorkItemDao; |
| 11 | 11 | import br.com.centralit.esi.api.execution.model.ProcessInstance; |
| 12 | 12 | import br.com.centralit.esi.api.execution.model.WorkItem; |
| ... | ... | @@ -60,7 +60,7 @@ public class WorkItemDatabaseConnectorServiceImpl extends WorkItemServiceImpl<Da |
| 60 | 60 | runtimeEnvironment.addOrUpdateObject("JNDITYPE", |
| 61 | 61 | element.getJNDIName()); |
| 62 | 62 | |
| 63 | - ExecuteConectaIniciaTransactionSql.execute(runtimeEnvironment); | |
| 63 | + ExecuteDBConnect.execute(runtimeEnvironment); | |
| 64 | 64 | |
| 65 | 65 | complete(runtimeEnvironment, workItem); |
| 66 | 66 | return retrieveTargets(runtimeEnvironment,workItem); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemDatabaseTransactionService.java
| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import br.com.centralit.esi.api.design.model.connector.DatabaseTransaction; | |
| 4 | -import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | - | |
| 6 | -public interface WorkItemDatabaseTransactionService extends WorkItemService<DatabaseTransaction> { | |
| 7 | - | |
| 8 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemDatabaseTransactionServiceImpl.java
| ... | ... | @@ -1,81 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import java.util.HashMap; | |
| 4 | -import java.util.List; | |
| 5 | - | |
| 6 | -import org.json.JSONObject; | |
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | -import org.springframework.stereotype.Service; | |
| 9 | - | |
| 10 | -import br.com.centralit.esi.api.data.model.DataObject; | |
| 11 | -import br.com.centralit.esi.api.data.service.DataObjectService; | |
| 12 | -import br.com.centralit.esi.api.data.service.impl.DataManager; | |
| 13 | -import br.com.centralit.esi.api.design.model.FlowElement; | |
| 14 | -import br.com.centralit.esi.api.design.model.connector.DatabaseTransaction; | |
| 15 | -import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum; | |
| 16 | -import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 17 | -import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 18 | -import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 19 | -import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 20 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 21 | -import br.com.centralit.esi.api.util.ConvertUtilsESI; | |
| 22 | -import br.com.centralit.esi.exception.EsiBusinessException; | |
| 23 | -import br.com.centralit.framework.util.UtilString; | |
| 24 | - | |
| 25 | -@Service("workItemDatabaseTransactionService") | |
| 26 | - | |
| 27 | -public class WorkItemDatabaseTransactionServiceImpl extends WorkItemServiceImpl<DatabaseTransaction> implements WorkItemDatabaseTransactionService { | |
| 28 | - | |
| 29 | - @Autowired | |
| 30 | - private DataObjectService dataObjectService; | |
| 31 | - | |
| 32 | - @Autowired | |
| 33 | - private DataManager dataManager; | |
| 34 | - | |
| 35 | - @Autowired | |
| 36 | - public WorkItemDatabaseTransactionServiceImpl(WorkItemDao workItemDao) { | |
| 37 | - super(workItemDao); | |
| 38 | - } | |
| 39 | - | |
| 40 | - protected DataObject findDataObject(String dataSourceName, String dataObjectName) { | |
| 41 | - DataObject dataObject = dataObjectService.findByDataSourceAndName(dataSourceName, dataObjectName); | |
| 42 | - if (dataObject == null) { | |
| 43 | - throw new EsiBusinessException("Objeto de banco de dados '"+dataObjectName+"' não encontrado"); | |
| 44 | - } | |
| 45 | - | |
| 46 | - return dataObject; | |
| 47 | - } | |
| 48 | - | |
| 49 | - @Override | |
| 50 | - protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 51 | - WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 52 | - return execute(runtimeEnvironment, workItem); | |
| 53 | - } | |
| 54 | - | |
| 55 | - @Override | |
| 56 | - public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 57 | - DatabaseTransaction databaseTransaction = this.getFlowElement(workItem); | |
| 58 | - | |
| 59 | - DataObject dataObject = this.findDataObject(databaseTransaction.getDataSourceName(), databaseTransaction.getDataObjectName()); | |
| 60 | - | |
| 61 | - Object input = runtimeEnvironment.getObject(databaseTransaction.getInputVariableName()); | |
| 62 | - if (input == null || !(input instanceof JSONObject)) { | |
| 63 | - throw new EsiBusinessException("Variável de entrada não definida"); | |
| 64 | - } | |
| 65 | - | |
| 66 | - if (databaseTransaction.getSQLType().equals(SqlClauseTypeEnum.SELECT) && (UtilString.isNullOrEmpty(databaseTransaction.getOutuptVariableName()))) { | |
| 67 | - throw new EsiBusinessException("Variável de saída não definida"); | |
| 68 | - } | |
| 69 | - | |
| 70 | - HashMap<String, Object> map = ConvertUtilsESI.buildMapFromJSON((JSONObject) input); | |
| 71 | - | |
| 72 | - List<HashMap<String, Object>> result = this.dataManager.executeTransaction(databaseTransaction.getSQLType(), databaseTransaction.getSQLName(), dataObject, map); | |
| 73 | - if (databaseTransaction.getSQLType().equals(SqlClauseTypeEnum.SELECT) && result != null) { | |
| 74 | - runtimeEnvironment.addOrUpdateObject(databaseTransaction.getOutuptVariableName(), ConvertUtilsESI.buildJSONArray(result)); | |
| 75 | - } | |
| 76 | - | |
| 77 | - complete(runtimeEnvironment, workItem); | |
| 78 | - return retrieveTargets(runtimeEnvironment,workItem); | |
| 79 | - } | |
| 80 | - | |
| 81 | -} | |
| 82 | 0 | \ No newline at end of file |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemEmailTaskService.java
| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import br.com.centralit.esi.api.design.model.task.EmailTask; | |
| 4 | -import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | - | |
| 6 | -public interface WorkItemEmailTaskService extends WorkItemService<EmailTask> { | |
| 7 | - | |
| 8 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemEmailTaskServiceImpl.java
| ... | ... | @@ -1,187 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import java.io.File; | |
| 4 | -import java.util.ArrayList; | |
| 5 | -import java.util.List; | |
| 6 | - | |
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | -import org.springframework.stereotype.Service; | |
| 9 | - | |
| 10 | -import br.com.centralit.esi.api.design.model.FlowActor; | |
| 11 | -import br.com.centralit.esi.api.design.model.FlowElement; | |
| 12 | -import br.com.centralit.esi.api.design.model.Variable; | |
| 13 | -import br.com.centralit.esi.api.design.model.task.EmailTask; | |
| 14 | -import br.com.centralit.esi.api.enumerated.ActorTypeEnum; | |
| 15 | -import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 16 | -import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 17 | -import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 18 | -import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 19 | -import br.com.centralit.esi.api.notification.model.Message; | |
| 20 | -import br.com.centralit.esi.api.notification.model.NotificationTemplate; | |
| 21 | -import br.com.centralit.esi.api.notification.service.NotificationTemplateService; | |
| 22 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 23 | -import br.com.centralit.esi.api.security.model.Group; | |
| 24 | -import br.com.centralit.esi.api.security.model.User; | |
| 25 | -import br.com.centralit.esi.api.security.service.SecurityService; | |
| 26 | -import br.com.centralit.esi.api.util.EsiAppUtils; | |
| 27 | -import br.com.centralit.framework.esi.enumerated.VariableTypeEnum; | |
| 28 | -import br.com.centralit.framework.util.UtilString; | |
| 29 | - | |
| 30 | -@Service("workItemEmailTaskService") | |
| 31 | - | |
| 32 | -public class WorkItemEmailTaskServiceImpl extends WorkItemServiceImpl<EmailTask> implements WorkItemEmailTaskService { | |
| 33 | - | |
| 34 | - @Autowired | |
| 35 | - private SecurityService securityService; | |
| 36 | - | |
| 37 | - @Autowired | |
| 38 | - private NotificationTemplateService notificationTemplateService; | |
| 39 | - | |
| 40 | - @Autowired | |
| 41 | - public WorkItemEmailTaskServiceImpl(WorkItemDao workItemDao) { | |
| 42 | - super(workItemDao); | |
| 43 | - } | |
| 44 | - | |
| 45 | - @Override | |
| 46 | - protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 47 | - WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 48 | - return execute(runtimeEnvironment, workItem); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @Override | |
| 52 | - public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 53 | - EmailTask element = this.getFlowElement(workItem); | |
| 54 | - | |
| 55 | - NotificationTemplate template = null; | |
| 56 | - String text = null; | |
| 57 | - String HTMLText = null; | |
| 58 | - String from = null; | |
| 59 | - String subject = null; | |
| 60 | - | |
| 61 | - if (!UtilString.isNullOrEmpty(element.getTemplateName())) { | |
| 62 | - template = notificationTemplateService.findByName(element.getTemplateName()); | |
| 63 | - } | |
| 64 | - | |
| 65 | - if (template != null && !UtilString.isNullOrEmpty(template.getText())) { | |
| 66 | - text = runtimeEnvironment.parseString(template.getText()); | |
| 67 | - HTMLText = runtimeEnvironment.parseString(template.getHTMLText()); | |
| 68 | - from = runtimeEnvironment.parseString(EsiAppUtils.BPE_EMAIL_FROM); | |
| 69 | - subject = runtimeEnvironment.parseString(template.getSubject()); | |
| 70 | - }else{ | |
| 71 | - text = runtimeEnvironment.parseString(element.getEmailText()); | |
| 72 | - HTMLText = text; | |
| 73 | - from = runtimeEnvironment.parseString(element.getAuthor()); | |
| 74 | - subject = runtimeEnvironment.parseString(element.getSubject()); | |
| 75 | - } | |
| 76 | - | |
| 77 | - workItem.getProcessInstance().addMessage(new Message(this.getTo(runtimeEnvironment, element) | |
| 78 | - , from | |
| 79 | - , subject | |
| 80 | - , text | |
| 81 | - , HTMLText | |
| 82 | - , this.getUsers(runtimeEnvironment, element) | |
| 83 | - , this.getGroups(runtimeEnvironment, element) | |
| 84 | - , this.getFiles(runtimeEnvironment, element))); | |
| 85 | - | |
| 86 | - complete(runtimeEnvironment, workItem); | |
| 87 | - return retrieveTargets(runtimeEnvironment,workItem); | |
| 88 | - } | |
| 89 | - | |
| 90 | - private List<File> getFiles(RuntimeEnvironment runtimeEnvironment, EmailTask element) { | |
| 91 | - List<File> files = new ArrayList<File>(); | |
| 92 | - if (element.getAttachments() != null) { | |
| 93 | - for (String name : element.getAttachments()) { | |
| 94 | - try { | |
| 95 | - File file = new File(runtimeEnvironment.parseString(name)); | |
| 96 | - files.add(file); | |
| 97 | - } catch (Exception e) { | |
| 98 | - e.printStackTrace(); | |
| 99 | - } | |
| 100 | - } | |
| 101 | - } | |
| 102 | - | |
| 103 | - return files; | |
| 104 | - } | |
| 105 | - | |
| 106 | - private User[] getUsers(RuntimeEnvironment runtimeEnvironment, EmailTask element) { | |
| 107 | - List<User> users = new ArrayList<User>(); | |
| 108 | - if (element.getActors() != null) { | |
| 109 | - for (FlowActor actor : element.getActors()) { | |
| 110 | - if (actor.getActorType().equals(ActorTypeEnum.USER)) { | |
| 111 | - Object initialValue = runtimeEnvironment.assignInitialValue(new Variable(actor.getName(), VariableTypeEnum.TEXT, null, false), actor.getValue()); | |
| 112 | - if (initialValue instanceof List) { | |
| 113 | - for (Object value : (List<?>) initialValue) { | |
| 114 | - if (value instanceof String) | |
| 115 | - this.assignUser(users, (String) value); | |
| 116 | - } | |
| 117 | - }else{ | |
| 118 | - if (initialValue instanceof String) | |
| 119 | - this.assignUser(users, (String) initialValue); | |
| 120 | - } | |
| 121 | - } | |
| 122 | - } | |
| 123 | - } | |
| 124 | - | |
| 125 | - User[] result = new User[users.size()]; | |
| 126 | - users.toArray(result); | |
| 127 | - | |
| 128 | - return result; | |
| 129 | - } | |
| 130 | - | |
| 131 | - private Group[] getGroups(RuntimeEnvironment runtimeEnvironment, EmailTask element) { | |
| 132 | - List<Group> groups = new ArrayList<Group>(); | |
| 133 | - if (element.getActors() != null) { | |
| 134 | - for (FlowActor actor : element.getActors()) { | |
| 135 | - if (actor.getActorType().equals(ActorTypeEnum.GROUP)) { | |
| 136 | - Object initialValue = runtimeEnvironment.assignInitialValue(new Variable(actor.getName(), VariableTypeEnum.TEXT, null, false), actor.getValue()); | |
| 137 | - if (initialValue instanceof List) { | |
| 138 | - for (Object value : (List<?>) initialValue) { | |
| 139 | - if (value instanceof String) | |
| 140 | - this.assignGroup(groups, (String) value); | |
| 141 | - } | |
| 142 | - }else{ | |
| 143 | - if (initialValue instanceof String) | |
| 144 | - this.assignGroup(groups, (String) initialValue); | |
| 145 | - } | |
| 146 | - } | |
| 147 | - } | |
| 148 | - } | |
| 149 | - | |
| 150 | - Group[] result = new Group[groups.size()]; | |
| 151 | - groups.toArray(result); | |
| 152 | - | |
| 153 | - return result; | |
| 154 | - } | |
| 155 | - | |
| 156 | - private String[] getTo(RuntimeEnvironment runtimeEnvironment, EmailTask element) { | |
| 157 | - List<String> toList = new ArrayList<String>(); | |
| 158 | - | |
| 159 | - if (element.getRecipients() != null) { | |
| 160 | - for (String recipient : element.getRecipients()) { | |
| 161 | - toList.add(runtimeEnvironment.parseString(recipient)); | |
| 162 | - } | |
| 163 | - } | |
| 164 | - | |
| 165 | - String[] result = new String[toList.size()]; | |
| 166 | - int i = 0; | |
| 167 | - for (String to : toList) { | |
| 168 | - result[i] = to; | |
| 169 | - i++; | |
| 170 | - } | |
| 171 | - return result; | |
| 172 | - } | |
| 173 | - | |
| 174 | - private void assignGroup(List<Group> groups, String id) { | |
| 175 | - Group group = securityService.getGroup(id); | |
| 176 | - if (groups != null) { | |
| 177 | - groups.add(group); | |
| 178 | - } | |
| 179 | - } | |
| 180 | - | |
| 181 | - private void assignUser(List<User> users, String id) { | |
| 182 | - User user = securityService.getUser(id); | |
| 183 | - if (user != null) { | |
| 184 | - users.add(user); | |
| 185 | - } | |
| 186 | - } | |
| 187 | -} | |
| 188 | 0 | \ No newline at end of file |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemEsiSubProcessService.java
| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import br.com.centralit.esi.api.design.model.task.EsiSubProcess; | |
| 4 | -import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | - | |
| 6 | -public interface WorkItemEsiSubProcessService extends WorkItemService<EsiSubProcess> { | |
| 7 | - | |
| 8 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemEsiSubProcessServiceImpl.java
| ... | ... | @@ -1,46 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | -import org.springframework.stereotype.Service; | |
| 5 | - | |
| 6 | -import br.com.centralit.esi.api.design.model.FlowElement; | |
| 7 | -import br.com.centralit.esi.api.design.model.FlowVersion; | |
| 8 | -import br.com.centralit.esi.api.design.model.task.EsiSubProcess; | |
| 9 | -import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 10 | -import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 11 | -import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 12 | -import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 13 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 14 | -import br.com.centralit.esi.api.runtime.service.RuntimeManager; | |
| 15 | - | |
| 16 | -@Service("workItemEsiSubProcessService") | |
| 17 | - | |
| 18 | -public class WorkItemEsiSubProcessServiceImpl extends WorkItemServiceImpl<EsiSubProcess> implements WorkItemEsiSubProcessService { | |
| 19 | - | |
| 20 | - @Autowired | |
| 21 | - private RuntimeManager runtimeManager; | |
| 22 | - | |
| 23 | - @Autowired | |
| 24 | - public WorkItemEsiSubProcessServiceImpl(WorkItemDao workItemDao) { | |
| 25 | - super(workItemDao); | |
| 26 | - } | |
| 27 | - | |
| 28 | - @Override | |
| 29 | - protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 30 | - WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 31 | - | |
| 32 | - EsiSubProcess element = this.getFlowElement(workItem); | |
| 33 | - FlowVersion flowVersion = runtimeManager.retrieveFlowVersion(runtimeEnvironment.parseString(element.getFlowName())); | |
| 34 | - | |
| 35 | - runtimeManager.start(runtimeEnvironment, workItem, flowVersion); | |
| 36 | - | |
| 37 | - return null; | |
| 38 | - } | |
| 39 | - | |
| 40 | - @Override | |
| 41 | - public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 42 | - complete(runtimeEnvironment, workItem); | |
| 43 | - return retrieveTargets(runtimeEnvironment,workItem); | |
| 44 | - } | |
| 45 | - | |
| 46 | -} | |
| 47 | 0 | \ No newline at end of file |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemJavaScriptTaskService.java
| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import br.com.centralit.esi.api.design.model.task.JavaScriptTask; | |
| 4 | -import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | - | |
| 6 | -public interface WorkItemJavaScriptTaskService extends WorkItemService<JavaScriptTask> { | |
| 7 | - | |
| 8 | -} |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemJavaScriptTaskServiceImpl.java
| ... | ... | @@ -1,58 +0,0 @@ |
| 1 | -package br.com.centralit.esi.api.execution.service.component; | |
| 2 | - | |
| 3 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | -import org.springframework.stereotype.Service; | |
| 5 | - | |
| 6 | -import br.com.centralit.esi.api.design.model.FlowElement; | |
| 7 | -import br.com.centralit.esi.api.design.model.task.JavaScriptTask; | |
| 8 | -import br.com.centralit.esi.api.enumerated.ScriptEngineTypeEnum; | |
| 9 | -import br.com.centralit.esi.api.execution.component.ExecuteNashorn; | |
| 10 | -import br.com.centralit.esi.api.execution.component.ExecuteRhino; | |
| 11 | -import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 12 | -import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 13 | -import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 14 | -import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 15 | -import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 16 | - | |
| 17 | -@Service("workItemJavaScriptTaskService") | |
| 18 | - | |
| 19 | -public class WorkItemJavaScriptTaskServiceImpl extends WorkItemServiceImpl<JavaScriptTask> implements WorkItemJavaScriptTaskService { | |
| 20 | - | |
| 21 | - @Autowired | |
| 22 | - public WorkItemJavaScriptTaskServiceImpl(WorkItemDao workItemDao) { | |
| 23 | - super(workItemDao); | |
| 24 | - } | |
| 25 | - | |
| 26 | - @Override | |
| 27 | - protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 28 | - WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 29 | - return execute(runtimeEnvironment, workItem); | |
| 30 | - } | |
| 31 | - | |
| 32 | - @Override | |
| 33 | - public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 34 | - //runtimeEnvironment.addOrUpdateObject("workItem", workItem); | |
| 35 | - | |
| 36 | - JavaScriptTask element = this.getFlowElement(workItem); | |
| 37 | - | |
| 38 | - if (element.getScriptCode().getEngineType().equals(ScriptEngineTypeEnum.RHINO)) { | |
| 39 | - Object result = ExecuteRhino.execute(runtimeEnvironment, element.getName(), element.getScriptCode().getScript()); | |
| 40 | - if (element.getReturnVariable() != null && element.getReturnVariable().length() > 0) { | |
| 41 | - runtimeEnvironment.addOrUpdateObject(element.getReturnVariable(), result); | |
| 42 | - } | |
| 43 | - }else{ | |
| 44 | - runtimeEnvironment.addOrUpdateObject("SCRIPTJAVASCRIPT", | |
| 45 | - element.getScriptCode().getScript()); | |
| 46 | - runtimeEnvironment.addOrUpdateObject("PARAMETERSJAVASCRIPT", | |
| 47 | - element.getParameters()); | |
| 48 | - runtimeEnvironment.addOrUpdateObject("NAMERETURNJAVASCRIPT", | |
| 49 | - element.getReturnVariable()); | |
| 50 | - runtimeEnvironment.addOrUpdateObject("SCRIPTCOMMAND", | |
| 51 | - element.getCommand()); | |
| 52 | - ExecuteNashorn.execute(runtimeEnvironment); | |
| 53 | - } | |
| 54 | - complete(runtimeEnvironment, workItem); | |
| 55 | - return retrieveTargets(runtimeEnvironment,workItem); | |
| 56 | - } | |
| 57 | - | |
| 58 | -} | |
| 59 | 0 | \ No newline at end of file |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/component/WorkItemReplaceServiceImpl.java
| ... | ... | @@ -5,7 +5,7 @@ import org.springframework.stereotype.Service; |
| 5 | 5 | |
| 6 | 6 | import br.com.centralit.esi.api.design.model.FlowElement; |
| 7 | 7 | import br.com.centralit.esi.api.design.model.component.Replace; |
| 8 | -import br.com.centralit.esi.api.execution.component.ExecuteSubstituir; | |
| 8 | +import br.com.centralit.esi.api.execution.component.ExecuteReplace; | |
| 9 | 9 | import br.com.centralit.esi.api.execution.dao.WorkItemDao; |
| 10 | 10 | import br.com.centralit.esi.api.execution.model.ProcessInstance; |
| 11 | 11 | import br.com.centralit.esi.api.execution.model.WorkItem; |
| ... | ... | @@ -36,7 +36,7 @@ public class WorkItemReplaceServiceImpl extends WorkItemServiceImpl<Replace> imp |
| 36 | 36 | runtimeEnvironment.addOrUpdateObject("VALUESREPLACE", element.getReplaceValues()); |
| 37 | 37 | runtimeEnvironment.addOrUpdateObject("TYPEREPLACE", element.getReplacementType().getId()); |
| 38 | 38 | |
| 39 | - ExecuteSubstituir.execute(runtimeEnvironment); | |
| 39 | + ExecuteReplace.execute(runtimeEnvironment); | |
| 40 | 40 | |
| 41 | 41 | complete(runtimeEnvironment, workItem); |
| 42 | 42 | return retrieveTargets(runtimeEnvironment,workItem); | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/event/WorkItemSignalEndEventServiceImpl.java
| ... | ... | @@ -53,7 +53,8 @@ public class WorkItemSignalEndEventServiceImpl extends WorkItemServiceImpl<Signa |
| 53 | 53 | //.setProcessInstanceId(processInstanceId); |
| 54 | 54 | signalInput.setUuid(runtimeEnvironment.getInput().getUuid()); |
| 55 | 55 | |
| 56 | - this.signalEvent(signalInput); | |
| 56 | + br.com.centralit.framework.esi.runtime.RuntimeManager.setBaseUrl(esiBaseUrl); | |
| 57 | + br.com.centralit.framework.esi.runtime.RuntimeManager.signalEvent(signalInput); | |
| 57 | 58 | |
| 58 | 59 | return null; |
| 59 | 60 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/event/WorkItemSignalIntermediateThrowEventServiceImpl.java
| ... | ... | @@ -61,7 +61,10 @@ public class WorkItemSignalIntermediateThrowEventServiceImpl extends WorkItemSer |
| 61 | 61 | //.setProcessInstanceId(processInstanceId); |
| 62 | 62 | |
| 63 | 63 | signalInput.setUuid(runtimeEnvironment.getInput().getUuid()); |
| 64 | - this.signalEvent(signalInput); | |
| 64 | + | |
| 65 | + br.com.centralit.framework.esi.runtime.RuntimeManager.setBaseUrl(esiBaseUrl); | |
| 66 | + br.com.centralit.framework.esi.runtime.RuntimeManager.signalEvent(signalInput); | |
| 67 | + | |
| 65 | 68 | return retrieveTargets(runtimeEnvironment,workItem); |
| 66 | 69 | } |
| 67 | 70 | } |
| 68 | 71 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/impl/ProcessInstanceServiceBaseImpl.java
| ... | ... | @@ -241,7 +241,6 @@ public abstract class ProcessInstanceServiceBaseImpl extends GenericServiceImpl< |
| 241 | 241 | instanceVariable = processInstanceVariableService.save(instanceVariable); |
| 242 | 242 | } |
| 243 | 243 | processInstance.addVariable(instanceVariable); |
| 244 | - | |
| 245 | 244 | } |
| 246 | 245 | } |
| 247 | 246 | } |
| ... | ... | @@ -414,10 +413,18 @@ public abstract class ProcessInstanceServiceBaseImpl extends GenericServiceImpl< |
| 414 | 413 | private void updateStatusVariable(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowStatus flowStatus) { |
| 415 | 414 | if (processInstance.getFlowVersion().getStatusList() != null) { |
| 416 | 415 | String acronym = flowStatus != null && flowStatus.getAcronym() != null ? flowStatus.getAcronym() : null; |
| 416 | + if (acronym != null) { | |
| 417 | + for (FlowStatus status : processInstance.getFlowVersion().getStatusList()) { | |
| 418 | + if (status.getAcronym() != null && status.getAcronym().equals(acronym)) { | |
| 419 | + runtimeEnvironment.addOrUpdateObject(status.getAcronym(), true); | |
| 420 | + } | |
| 421 | + } | |
| 422 | + } | |
| 417 | 423 | for (FlowStatus status : processInstance.getFlowVersion().getStatusList()) { |
| 418 | 424 | if (status.getAcronym() != null) { |
| 419 | - Boolean value = acronym != null && status.getAcronym().equals(acronym); | |
| 420 | - runtimeEnvironment.addOrUpdateObject(status.getAcronym(), value); | |
| 425 | + if (!runtimeEnvironment.hasObject(status.getAcronym())) { | |
| 426 | + runtimeEnvironment.addOrUpdateObject(status.getAcronym(), false); | |
| 427 | + } | |
| 421 | 428 | } |
| 422 | 429 | } |
| 423 | 430 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/impl/WorkItemServiceImpl.java
| ... | ... | @@ -283,10 +283,10 @@ public class WorkItemServiceImpl<E extends FlowElement> extends GenericServiceIm |
| 283 | 283 | |
| 284 | 284 | if ((signalEventInput.getProcessInstanceId() == null || signalEventInput.getProcessInstanceId().longValue() == 0) && (UtilString.isNullOrEmpty(signalEventInput.getFlowName()))) { |
| 285 | 285 | return workItemDao.retrieveAvailabeEvents(signalEventInput.getEventName()); |
| 286 | - }else if (!UtilString.isNullOrEmpty(signalEventInput.getFlowName())) { | |
| 287 | - return workItemDao.retrieveAvailabeEventsByFlowName(signalEventInput.getEventName(), signalEventInput.getFlowName()); | |
| 288 | 286 | }else if (signalEventInput.getProcessInstanceId() != null && signalEventInput.getProcessInstanceId().longValue() > 0) { |
| 289 | 287 | return workItemDao.retrieveAvailabeEventsInstanceId(signalEventInput.getEventName(), signalEventInput.getProcessInstanceId()); |
| 288 | + }else if (!UtilString.isNullOrEmpty(signalEventInput.getFlowName())) { | |
| 289 | + return workItemDao.retrieveAvailabeEventsByFlowName(signalEventInput.getEventName(), signalEventInput.getFlowName()); | |
| 290 | 290 | }else{ |
| 291 | 291 | return null; |
| 292 | 292 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemBpeSubProcessService.java
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.design.model.task.BpeSubProcess; | |
| 4 | +import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | + | |
| 6 | +public interface WorkItemBpeSubProcessService extends WorkItemService<BpeSubProcess> { | |
| 7 | + | |
| 8 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemBpeSubProcessServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,42 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.business.service.BusinessProcessManager; | |
| 7 | +import br.com.centralit.esi.api.design.model.FlowElement; | |
| 8 | +import br.com.centralit.esi.api.design.model.task.BpeSubProcess; | |
| 9 | +import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 10 | +import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 11 | +import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 12 | +import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 13 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 14 | + | |
| 15 | +@Service("workItemBpeSubProcessService") | |
| 16 | + | |
| 17 | +public class WorkItemBpeSubProcessServiceImpl extends WorkItemServiceImpl<BpeSubProcess> implements WorkItemBpeSubProcessService { | |
| 18 | + | |
| 19 | + @Autowired | |
| 20 | + private BusinessProcessManager businessProcessManager; | |
| 21 | + | |
| 22 | + @Autowired | |
| 23 | + public WorkItemBpeSubProcessServiceImpl(WorkItemDao workItemDao) { | |
| 24 | + super(workItemDao); | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 29 | + WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 30 | + BpeSubProcess element = this.getFlowElement(workItem); | |
| 31 | + | |
| 32 | + businessProcessManager.startBusinessProcess(runtimeEnvironment, workItem, element.getBusinessProcessName()); | |
| 33 | + return null; | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 38 | + complete(runtimeEnvironment, workItem); | |
| 39 | + return retrieveTargets(runtimeEnvironment,workItem); | |
| 40 | + } | |
| 41 | + | |
| 42 | +} | |
| 0 | 43 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemBusinessRuleSubProcessService.java
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.design.model.task.BusinessRuleSubProcess; | |
| 4 | +import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | + | |
| 6 | +public interface WorkItemBusinessRuleSubProcessService extends WorkItemService<BusinessRuleSubProcess> { | |
| 7 | + | |
| 8 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemBusinessRuleSubProcessServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.business.model.BusinessRuleVersion; | |
| 7 | +import br.com.centralit.esi.api.business.service.BusinessRuleManager; | |
| 8 | +import br.com.centralit.esi.api.design.model.FlowElement; | |
| 9 | +import br.com.centralit.esi.api.design.model.task.BusinessRuleSubProcess; | |
| 10 | +import br.com.centralit.esi.api.enumerated.BusinessRuleEngineEnum; | |
| 11 | +import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 12 | +import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 13 | +import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 14 | +import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 15 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 16 | + | |
| 17 | +@Service("workItemBusinessRuleSubProcessService") | |
| 18 | + | |
| 19 | +public class WorkItemBusinessRuleSubProcessServiceImpl extends WorkItemServiceImpl<BusinessRuleSubProcess> implements WorkItemBusinessRuleSubProcessService { | |
| 20 | + | |
| 21 | + @Autowired | |
| 22 | + private BusinessRuleManager businessRuleManager; | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + public WorkItemBusinessRuleSubProcessServiceImpl(WorkItemDao workItemDao) { | |
| 26 | + super(workItemDao); | |
| 27 | + } | |
| 28 | + | |
| 29 | + @Override | |
| 30 | + protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 31 | + WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 32 | + | |
| 33 | + BusinessRuleSubProcess element = this.getFlowElement(workItem); | |
| 34 | + | |
| 35 | + BusinessRuleVersion businessRule = businessRuleManager.findBusinessRule(element.getFlowName()); | |
| 36 | + | |
| 37 | + businessRuleManager.execute(runtimeEnvironment, workItem, businessRule); | |
| 38 | + | |
| 39 | + if (!businessRule.getType().equals(BusinessRuleEngineEnum.FLOW)) { | |
| 40 | + return execute(runtimeEnvironment, workItem); | |
| 41 | + }else{ | |
| 42 | + return null; | |
| 43 | + } | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 48 | + complete(runtimeEnvironment, workItem); | |
| 49 | + return retrieveTargets(runtimeEnvironment,workItem); | |
| 50 | + } | |
| 51 | + | |
| 52 | +} | |
| 0 | 53 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemDatabaseTransactionService.java
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.design.model.task.DatabaseTransaction; | |
| 4 | +import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | + | |
| 6 | +public interface WorkItemDatabaseTransactionService extends WorkItemService<DatabaseTransaction> { | |
| 7 | + | |
| 8 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemDatabaseTransactionServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,95 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import java.util.HashMap; | |
| 4 | +import java.util.List; | |
| 5 | + | |
| 6 | +import org.json.JSONObject; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | + | |
| 10 | +import br.com.centralit.esi.api.data.model.DataObject; | |
| 11 | +import br.com.centralit.esi.api.data.service.DataObjectService; | |
| 12 | +import br.com.centralit.esi.api.data.service.impl.DataManager; | |
| 13 | +import br.com.centralit.esi.api.design.model.FlowElement; | |
| 14 | +import br.com.centralit.esi.api.design.model.task.DatabaseTransaction; | |
| 15 | +import br.com.centralit.esi.api.enumerated.RelationshipTypeEnum; | |
| 16 | +import br.com.centralit.esi.api.enumerated.SqlClauseTypeEnum; | |
| 17 | +import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 18 | +import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 19 | +import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 20 | +import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 21 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 22 | +import br.com.centralit.esi.api.util.ConvertUtilsESI; | |
| 23 | +import br.com.centralit.esi.exception.EsiBusinessException; | |
| 24 | +import br.com.centralit.framework.util.UtilString; | |
| 25 | + | |
| 26 | +@Service("workItemDatabaseTransactionService") | |
| 27 | + | |
| 28 | +public class WorkItemDatabaseTransactionServiceImpl extends WorkItemServiceImpl<DatabaseTransaction> implements WorkItemDatabaseTransactionService { | |
| 29 | + | |
| 30 | + @Autowired | |
| 31 | + private DataObjectService dataObjectService; | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + private DataManager dataManager; | |
| 35 | + | |
| 36 | + @Autowired | |
| 37 | + public WorkItemDatabaseTransactionServiceImpl(WorkItemDao workItemDao) { | |
| 38 | + super(workItemDao); | |
| 39 | + } | |
| 40 | + | |
| 41 | + protected DataObject findDataObject(String dataSourceName, String dataObjectName) { | |
| 42 | + DataObject dataObject = dataObjectService.findByDataSourceAndName(dataSourceName, dataObjectName); | |
| 43 | + if (dataObject == null) { | |
| 44 | + throw new EsiBusinessException("Objeto de banco de dados '"+dataObjectName+"' não encontrado"); | |
| 45 | + } | |
| 46 | + | |
| 47 | + return dataObject; | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 52 | + WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 53 | + return execute(runtimeEnvironment, workItem); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @SuppressWarnings("unchecked") | |
| 57 | + @Override | |
| 58 | + public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 59 | + DatabaseTransaction databaseTransaction = this.getFlowElement(workItem); | |
| 60 | + | |
| 61 | + DataObject dataObject = this.findDataObject(databaseTransaction.getDataSourceName(), databaseTransaction.getDataObjectName()); | |
| 62 | + | |
| 63 | + Object input = runtimeEnvironment.getObject(databaseTransaction.getInputVariableName()); | |
| 64 | + if (input == null || !(input instanceof JSONObject)) { | |
| 65 | + throw new EsiBusinessException("Variável de entrada não definida"); | |
| 66 | + } | |
| 67 | + | |
| 68 | + if (databaseTransaction.getSQLType().equals(SqlClauseTypeEnum.SELECT) && (UtilString.isNullOrEmpty(databaseTransaction.getOutuptVariableName()))) { | |
| 69 | + throw new EsiBusinessException("Variável de saída não definida"); | |
| 70 | + } | |
| 71 | + | |
| 72 | + HashMap<String, Object> map = ConvertUtilsESI.convertJsonToMap((JSONObject) input); | |
| 73 | + | |
| 74 | + Object result = this.dataManager.executeTransaction(databaseTransaction.getSQLType(), databaseTransaction.getSQLName(), dataObject, map); | |
| 75 | + if (result != null) { | |
| 76 | + if (databaseTransaction.getSQLType().equals(SqlClauseTypeEnum.SELECT)) { | |
| 77 | + List<HashMap<String, Object>> resultSet = (List<HashMap<String, Object>>) result; | |
| 78 | + if (databaseTransaction.getRestoreManyToOne() != null && databaseTransaction.getRestoreManyToOne()) { | |
| 79 | + dataManager.restoreRelationships(dataObject, RelationshipTypeEnum.MANY_TO_ONE, resultSet); | |
| 80 | + } | |
| 81 | + if (databaseTransaction.getRestoreOneToMany() != null && databaseTransaction.getRestoreOneToMany()) { | |
| 82 | + dataManager.restoreRelationships(dataObject, RelationshipTypeEnum.ONE_TO_MANY, resultSet); | |
| 83 | + } | |
| 84 | + | |
| 85 | + runtimeEnvironment.addOrUpdateObject(databaseTransaction.getOutuptVariableName(), ConvertUtilsESI.buildJSONArray(resultSet)); | |
| 86 | + }else if (!databaseTransaction.getSQLType().equals(SqlClauseTypeEnum.DELETE)) { | |
| 87 | + runtimeEnvironment.addOrUpdateObject(databaseTransaction.getOutuptVariableName(), new JSONObject(ConvertUtilsESI.toJSONString(result))); | |
| 88 | + } | |
| 89 | + } | |
| 90 | + | |
| 91 | + complete(runtimeEnvironment, workItem); | |
| 92 | + return retrieveTargets(runtimeEnvironment,workItem); | |
| 93 | + } | |
| 94 | + | |
| 95 | +} | |
| 0 | 96 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemEmailTaskService.java
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.design.model.task.EmailTask; | |
| 4 | +import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | + | |
| 6 | +public interface WorkItemEmailTaskService extends WorkItemService<EmailTask> { | |
| 7 | + | |
| 8 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemEmailTaskServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,187 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import java.io.File; | |
| 4 | +import java.util.ArrayList; | |
| 5 | +import java.util.List; | |
| 6 | + | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | + | |
| 10 | +import br.com.centralit.esi.api.design.model.FlowActor; | |
| 11 | +import br.com.centralit.esi.api.design.model.FlowElement; | |
| 12 | +import br.com.centralit.esi.api.design.model.Variable; | |
| 13 | +import br.com.centralit.esi.api.design.model.task.EmailTask; | |
| 14 | +import br.com.centralit.esi.api.enumerated.ActorTypeEnum; | |
| 15 | +import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 16 | +import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 17 | +import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 18 | +import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 19 | +import br.com.centralit.esi.api.notification.model.Message; | |
| 20 | +import br.com.centralit.esi.api.notification.model.NotificationTemplate; | |
| 21 | +import br.com.centralit.esi.api.notification.service.NotificationTemplateService; | |
| 22 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 23 | +import br.com.centralit.esi.api.security.model.Group; | |
| 24 | +import br.com.centralit.esi.api.security.model.User; | |
| 25 | +import br.com.centralit.esi.api.security.service.SecurityService; | |
| 26 | +import br.com.centralit.esi.api.util.EsiAppUtils; | |
| 27 | +import br.com.centralit.framework.esi.enumerated.VariableTypeEnum; | |
| 28 | +import br.com.centralit.framework.util.UtilString; | |
| 29 | + | |
| 30 | +@Service("workItemEmailTaskService") | |
| 31 | + | |
| 32 | +public class WorkItemEmailTaskServiceImpl extends WorkItemServiceImpl<EmailTask> implements WorkItemEmailTaskService { | |
| 33 | + | |
| 34 | + @Autowired | |
| 35 | + private SecurityService securityService; | |
| 36 | + | |
| 37 | + @Autowired | |
| 38 | + private NotificationTemplateService notificationTemplateService; | |
| 39 | + | |
| 40 | + @Autowired | |
| 41 | + public WorkItemEmailTaskServiceImpl(WorkItemDao workItemDao) { | |
| 42 | + super(workItemDao); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 47 | + WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 48 | + return execute(runtimeEnvironment, workItem); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 53 | + EmailTask element = this.getFlowElement(workItem); | |
| 54 | + | |
| 55 | + NotificationTemplate template = null; | |
| 56 | + String text = null; | |
| 57 | + String HTMLText = null; | |
| 58 | + String from = null; | |
| 59 | + String subject = null; | |
| 60 | + | |
| 61 | + if (!UtilString.isNullOrEmpty(element.getTemplateName())) { | |
| 62 | + template = notificationTemplateService.findByName(element.getTemplateName()); | |
| 63 | + } | |
| 64 | + | |
| 65 | + if (template != null && !UtilString.isNullOrEmpty(template.getText())) { | |
| 66 | + text = runtimeEnvironment.parseString(template.getText()); | |
| 67 | + HTMLText = runtimeEnvironment.parseString(template.getHTMLText()); | |
| 68 | + from = runtimeEnvironment.parseString(EsiAppUtils.BPE_EMAIL_FROM); | |
| 69 | + subject = runtimeEnvironment.parseString(template.getSubject()); | |
| 70 | + }else{ | |
| 71 | + text = runtimeEnvironment.parseString(element.getEmailText()); | |
| 72 | + HTMLText = text; | |
| 73 | + from = runtimeEnvironment.parseString(element.getAuthor()); | |
| 74 | + subject = runtimeEnvironment.parseString(element.getSubject()); | |
| 75 | + } | |
| 76 | + | |
| 77 | + workItem.getProcessInstance().addMessage(new Message(this.getTo(runtimeEnvironment, element) | |
| 78 | + , from | |
| 79 | + , subject | |
| 80 | + , text | |
| 81 | + , HTMLText | |
| 82 | + , this.getUsers(runtimeEnvironment, element) | |
| 83 | + , this.getGroups(runtimeEnvironment, element) | |
| 84 | + , this.getFiles(runtimeEnvironment, element))); | |
| 85 | + | |
| 86 | + complete(runtimeEnvironment, workItem); | |
| 87 | + return retrieveTargets(runtimeEnvironment,workItem); | |
| 88 | + } | |
| 89 | + | |
| 90 | + private List<File> getFiles(RuntimeEnvironment runtimeEnvironment, EmailTask element) { | |
| 91 | + List<File> files = new ArrayList<File>(); | |
| 92 | + if (element.getAttachments() != null) { | |
| 93 | + for (String name : element.getAttachments()) { | |
| 94 | + try { | |
| 95 | + File file = new File(runtimeEnvironment.parseString(name)); | |
| 96 | + files.add(file); | |
| 97 | + } catch (Exception e) { | |
| 98 | + e.printStackTrace(); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + } | |
| 102 | + | |
| 103 | + return files; | |
| 104 | + } | |
| 105 | + | |
| 106 | + private User[] getUsers(RuntimeEnvironment runtimeEnvironment, EmailTask element) { | |
| 107 | + List<User> users = new ArrayList<User>(); | |
| 108 | + if (element.getActors() != null) { | |
| 109 | + for (FlowActor actor : element.getActors()) { | |
| 110 | + if (actor.getActorType().equals(ActorTypeEnum.USER)) { | |
| 111 | + Object initialValue = runtimeEnvironment.assignInitialValue(new Variable(actor.getName(), VariableTypeEnum.TEXT, null, false), actor.getValue()); | |
| 112 | + if (initialValue instanceof List) { | |
| 113 | + for (Object value : (List<?>) initialValue) { | |
| 114 | + if (value instanceof String) | |
| 115 | + this.assignUser(users, (String) value); | |
| 116 | + } | |
| 117 | + }else{ | |
| 118 | + if (initialValue instanceof String) | |
| 119 | + this.assignUser(users, (String) initialValue); | |
| 120 | + } | |
| 121 | + } | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + User[] result = new User[users.size()]; | |
| 126 | + users.toArray(result); | |
| 127 | + | |
| 128 | + return result; | |
| 129 | + } | |
| 130 | + | |
| 131 | + private Group[] getGroups(RuntimeEnvironment runtimeEnvironment, EmailTask element) { | |
| 132 | + List<Group> groups = new ArrayList<Group>(); | |
| 133 | + if (element.getActors() != null) { | |
| 134 | + for (FlowActor actor : element.getActors()) { | |
| 135 | + if (actor.getActorType().equals(ActorTypeEnum.GROUP)) { | |
| 136 | + Object initialValue = runtimeEnvironment.assignInitialValue(new Variable(actor.getName(), VariableTypeEnum.TEXT, null, false), actor.getValue()); | |
| 137 | + if (initialValue instanceof List) { | |
| 138 | + for (Object value : (List<?>) initialValue) { | |
| 139 | + if (value instanceof String) | |
| 140 | + this.assignGroup(groups, (String) value); | |
| 141 | + } | |
| 142 | + }else{ | |
| 143 | + if (initialValue instanceof String) | |
| 144 | + this.assignGroup(groups, (String) initialValue); | |
| 145 | + } | |
| 146 | + } | |
| 147 | + } | |
| 148 | + } | |
| 149 | + | |
| 150 | + Group[] result = new Group[groups.size()]; | |
| 151 | + groups.toArray(result); | |
| 152 | + | |
| 153 | + return result; | |
| 154 | + } | |
| 155 | + | |
| 156 | + private String[] getTo(RuntimeEnvironment runtimeEnvironment, EmailTask element) { | |
| 157 | + List<String> toList = new ArrayList<String>(); | |
| 158 | + | |
| 159 | + if (element.getRecipients() != null) { | |
| 160 | + for (String recipient : element.getRecipients()) { | |
| 161 | + toList.add(runtimeEnvironment.parseString(recipient)); | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 165 | + String[] result = new String[toList.size()]; | |
| 166 | + int i = 0; | |
| 167 | + for (String to : toList) { | |
| 168 | + result[i] = to; | |
| 169 | + i++; | |
| 170 | + } | |
| 171 | + return result; | |
| 172 | + } | |
| 173 | + | |
| 174 | + private void assignGroup(List<Group> groups, String id) { | |
| 175 | + Group group = securityService.getGroup(id); | |
| 176 | + if (groups != null) { | |
| 177 | + groups.add(group); | |
| 178 | + } | |
| 179 | + } | |
| 180 | + | |
| 181 | + private void assignUser(List<User> users, String id) { | |
| 182 | + User user = securityService.getUser(id); | |
| 183 | + if (user != null) { | |
| 184 | + users.add(user); | |
| 185 | + } | |
| 186 | + } | |
| 187 | +} | |
| 0 | 188 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemEsiSubProcessService.java
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.design.model.task.EsiSubProcess; | |
| 4 | +import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | + | |
| 6 | +public interface WorkItemEsiSubProcessService extends WorkItemService<EsiSubProcess> { | |
| 7 | + | |
| 8 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemEsiSubProcessServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.design.model.FlowElement; | |
| 7 | +import br.com.centralit.esi.api.design.model.FlowVersion; | |
| 8 | +import br.com.centralit.esi.api.design.model.task.EsiSubProcess; | |
| 9 | +import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 10 | +import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 11 | +import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 12 | +import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 13 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 14 | +import br.com.centralit.esi.api.runtime.service.RuntimeManager; | |
| 15 | + | |
| 16 | +@Service("workItemEsiSubProcessService") | |
| 17 | + | |
| 18 | +public class WorkItemEsiSubProcessServiceImpl extends WorkItemServiceImpl<EsiSubProcess> implements WorkItemEsiSubProcessService { | |
| 19 | + | |
| 20 | + @Autowired | |
| 21 | + private RuntimeManager runtimeManager; | |
| 22 | + | |
| 23 | + @Autowired | |
| 24 | + public WorkItemEsiSubProcessServiceImpl(WorkItemDao workItemDao) { | |
| 25 | + super(workItemDao); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 30 | + WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 31 | + | |
| 32 | + EsiSubProcess element = this.getFlowElement(workItem); | |
| 33 | + FlowVersion flowVersion = runtimeManager.retrieveFlowVersion(runtimeEnvironment.parseString(element.getFlowName())); | |
| 34 | + | |
| 35 | + runtimeManager.start(runtimeEnvironment, workItem, flowVersion); | |
| 36 | + | |
| 37 | + return null; | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 42 | + complete(runtimeEnvironment, workItem); | |
| 43 | + return retrieveTargets(runtimeEnvironment,workItem); | |
| 44 | + } | |
| 45 | + | |
| 46 | +} | |
| 0 | 47 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemJavaScriptTaskService.java
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.design.model.task.JavaScriptTask; | |
| 4 | +import br.com.centralit.esi.api.execution.service.WorkItemService; | |
| 5 | + | |
| 6 | +public interface WorkItemJavaScriptTaskService extends WorkItemService<JavaScriptTask> { | |
| 7 | + | |
| 8 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/execution/service/task/WorkItemJavaScriptTaskServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,58 @@ |
| 1 | +package br.com.centralit.esi.api.execution.service.task; | |
| 2 | + | |
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.design.model.FlowElement; | |
| 7 | +import br.com.centralit.esi.api.design.model.task.JavaScriptTask; | |
| 8 | +import br.com.centralit.esi.api.enumerated.ScriptEngineTypeEnum; | |
| 9 | +import br.com.centralit.esi.api.execution.component.ExecuteNashorn; | |
| 10 | +import br.com.centralit.esi.api.execution.component.ExecuteRhino; | |
| 11 | +import br.com.centralit.esi.api.execution.dao.WorkItemDao; | |
| 12 | +import br.com.centralit.esi.api.execution.model.ProcessInstance; | |
| 13 | +import br.com.centralit.esi.api.execution.model.WorkItem; | |
| 14 | +import br.com.centralit.esi.api.execution.service.impl.WorkItemServiceImpl; | |
| 15 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 16 | + | |
| 17 | +@Service("workItemJavaScriptTaskService") | |
| 18 | + | |
| 19 | +public class WorkItemJavaScriptTaskServiceImpl extends WorkItemServiceImpl<JavaScriptTask> implements WorkItemJavaScriptTaskService { | |
| 20 | + | |
| 21 | + @Autowired | |
| 22 | + public WorkItemJavaScriptTaskServiceImpl(WorkItemDao workItemDao) { | |
| 23 | + super(workItemDao); | |
| 24 | + } | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + protected WorkItem internalSolve(RuntimeEnvironment runtimeEnvironment, ProcessInstance processInstance, FlowElement flowElement) { | |
| 28 | + WorkItem workItem = register(runtimeEnvironment, processInstance,flowElement); | |
| 29 | + return execute(runtimeEnvironment, workItem); | |
| 30 | + } | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public WorkItem internalExecute(RuntimeEnvironment runtimeEnvironment, WorkItem workItem) { | |
| 34 | + //runtimeEnvironment.addOrUpdateObject("workItem", workItem); | |
| 35 | + | |
| 36 | + JavaScriptTask element = this.getFlowElement(workItem); | |
| 37 | + | |
| 38 | + if (element.getScriptCode().getEngineType().equals(ScriptEngineTypeEnum.RHINO)) { | |
| 39 | + Object result = ExecuteRhino.execute(runtimeEnvironment, element.getName(), element.getScriptCode().getScript()); | |
| 40 | + if (element.getReturnVariable() != null && element.getReturnVariable().length() > 0) { | |
| 41 | + runtimeEnvironment.addOrUpdateObject(element.getReturnVariable(), result); | |
| 42 | + } | |
| 43 | + }else{ | |
| 44 | + runtimeEnvironment.addOrUpdateObject("SCRIPTJAVASCRIPT", | |
| 45 | + element.getScriptCode().getScript()); | |
| 46 | + runtimeEnvironment.addOrUpdateObject("PARAMETERSJAVASCRIPT", | |
| 47 | + element.getParameters()); | |
| 48 | + runtimeEnvironment.addOrUpdateObject("NAMERETURNJAVASCRIPT", | |
| 49 | + element.getReturnVariable()); | |
| 50 | + runtimeEnvironment.addOrUpdateObject("SCRIPTCOMMAND", | |
| 51 | + element.getCommand()); | |
| 52 | + ExecuteNashorn.execute(runtimeEnvironment); | |
| 53 | + } | |
| 54 | + complete(runtimeEnvironment, workItem); | |
| 55 | + return retrieveTargets(runtimeEnvironment,workItem); | |
| 56 | + } | |
| 57 | + | |
| 58 | +} | |
| 0 | 59 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/parameter/model/Parameter.java
| ... | ... | @@ -53,6 +53,10 @@ public class Parameter extends PersistentObjectAudit { |
| 53 | 53 | public static final String DATAOBJECT_CRUD_CONTROLLER = "DATAOBJECT_CRUD_CONTROLLER"; |
| 54 | 54 | public static final String DATAOBJECT_CRUD_DEPENDENCIES = "DATAOBJECT_CRUD_DEPENDENCIES"; |
| 55 | 55 | |
| 56 | + public static final String RESOURCE_REPORT_HTML = "RESOURCE_REPORT_HTML"; | |
| 57 | + public static final String RESOURCE_REPORT_CONTROLLER = "RESOURCE_REPORT_CONTROLLER"; | |
| 58 | + public static final String RESOURCE_REPORT_DEPENDENCIES = "RESOURCE_REPORT_DEPENDENCIES"; | |
| 59 | + | |
| 56 | 60 | public static final String BPE_SEND_MAIL = "BPE_SEND_MAIL"; |
| 57 | 61 | public static final String BPE_SEND_NOTIFICATION = "BPE_SEND_NOTIFICATION"; |
| 58 | 62 | public static final String BPE_EMAIL_FROM = "BPE_EMAIL_FROM"; | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/ReportDataSourceDao.java
0 → 100644
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/ReportParameterDao.java
0 → 100644
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/ReportVersionDao.java
0 → 100644
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/CssVersionDaoHibernate.java
| ... | ... | @@ -2,8 +2,11 @@ package br.com.centralit.esi.api.resource.dao.impl; |
| 2 | 2 | |
| 3 | 3 | import org.springframework.stereotype.Repository; |
| 4 | 4 | |
| 5 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 5 | 6 | import br.com.centralit.esi.api.resource.dao.CssVersionDao; |
| 6 | 7 | import br.com.centralit.esi.api.resource.model.CssVersion; |
| 8 | +import br.com.centralit.esi.api.resource.model.ResourceVersion; | |
| 9 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
| 7 | 10 | |
| 8 | 11 | @Repository("cssVersionDao") |
| 9 | 12 | public class CssVersionDaoHibernate extends ResourceVersionDaoHibernate implements CssVersionDao { |
| ... | ... | @@ -12,4 +15,20 @@ public class CssVersionDaoHibernate extends ResourceVersionDaoHibernate implemen |
| 12 | 15 | super(CssVersion.class); |
| 13 | 16 | } |
| 14 | 17 | |
| 18 | + @Override | |
| 19 | + public ResourceVersion findByName(String resourceName) { | |
| 20 | + SearchSeven search = new SearchSeven(); | |
| 21 | + | |
| 22 | + search.addFilterEqual("resource.name", resourceName); | |
| 23 | + | |
| 24 | + search.addFilterEqual("resource.type", ResourceTypeEnum.CSS); | |
| 25 | + | |
| 26 | + search.addFilterEmpty("resource.dataInativo"); | |
| 27 | + search.addFilterEmpty("dataInativo"); | |
| 28 | + | |
| 29 | + search.setMaxResults(1); | |
| 30 | + | |
| 31 | + return this.searchUnique(search, CssVersion.class); | |
| 32 | + } | |
| 33 | + | |
| 15 | 34 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/FileVersionDaoHibernate.java
| ... | ... | @@ -2,8 +2,11 @@ package br.com.centralit.esi.api.resource.dao.impl; |
| 2 | 2 | |
| 3 | 3 | import org.springframework.stereotype.Repository; |
| 4 | 4 | |
| 5 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 5 | 6 | import br.com.centralit.esi.api.resource.dao.FileVersionDao; |
| 6 | 7 | import br.com.centralit.esi.api.resource.model.FileVersion; |
| 8 | +import br.com.centralit.esi.api.resource.model.ResourceVersion; | |
| 9 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
| 7 | 10 | |
| 8 | 11 | @Repository("fileVersionDao") |
| 9 | 12 | public class FileVersionDaoHibernate extends ResourceVersionDaoHibernate implements FileVersionDao { |
| ... | ... | @@ -11,5 +14,21 @@ public class FileVersionDaoHibernate extends ResourceVersionDaoHibernate impleme |
| 11 | 14 | public FileVersionDaoHibernate() { |
| 12 | 15 | super(FileVersion.class); |
| 13 | 16 | } |
| 14 | - | |
| 17 | + | |
| 18 | + @Override | |
| 19 | + public ResourceVersion findByName(String resourceName) { | |
| 20 | + SearchSeven search = new SearchSeven(); | |
| 21 | + | |
| 22 | + search.addFilterEqual("resource.name", resourceName); | |
| 23 | + | |
| 24 | + search.addFilterEqual("resource.type", ResourceTypeEnum.FILE); | |
| 25 | + | |
| 26 | + search.addFilterEmpty("resource.dataInativo"); | |
| 27 | + search.addFilterEmpty("dataInativo"); | |
| 28 | + | |
| 29 | + search.setMaxResults(1); | |
| 30 | + | |
| 31 | + return this.searchUnique(search, FileVersion.class); | |
| 32 | + } | |
| 33 | + | |
| 15 | 34 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/FormVersionDaoHibernate.java
| ... | ... | @@ -2,8 +2,11 @@ package br.com.centralit.esi.api.resource.dao.impl; |
| 2 | 2 | |
| 3 | 3 | import org.springframework.stereotype.Repository; |
| 4 | 4 | |
| 5 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 5 | 6 | import br.com.centralit.esi.api.resource.dao.FormVersionDao; |
| 6 | 7 | import br.com.centralit.esi.api.resource.model.FormVersion; |
| 8 | +import br.com.centralit.esi.api.resource.model.ResourceVersion; | |
| 9 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
| 7 | 10 | |
| 8 | 11 | @Repository("formVersionDao") |
| 9 | 12 | public class FormVersionDaoHibernate extends ResourceVersionDaoHibernate implements FormVersionDao { |
| ... | ... | @@ -12,4 +15,20 @@ public class FormVersionDaoHibernate extends ResourceVersionDaoHibernate impleme |
| 12 | 15 | super(FormVersion.class); |
| 13 | 16 | } |
| 14 | 17 | |
| 18 | + @Override | |
| 19 | + public ResourceVersion findByName(String resourceName) { | |
| 20 | + SearchSeven search = new SearchSeven(); | |
| 21 | + | |
| 22 | + search.addFilterEqual("resource.name", resourceName); | |
| 23 | + | |
| 24 | + search.addFilterEqual("resource.type", ResourceTypeEnum.FORM); | |
| 25 | + | |
| 26 | + search.addFilterEmpty("resource.dataInativo"); | |
| 27 | + search.addFilterEmpty("dataInativo"); | |
| 28 | + | |
| 29 | + search.setMaxResults(1); | |
| 30 | + | |
| 31 | + return this.searchUnique(search, FormVersion.class); | |
| 32 | + } | |
| 33 | + | |
| 15 | 34 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/ImageVersionDaoHibernate.java
| ... | ... | @@ -2,8 +2,11 @@ package br.com.centralit.esi.api.resource.dao.impl; |
| 2 | 2 | |
| 3 | 3 | import org.springframework.stereotype.Repository; |
| 4 | 4 | |
| 5 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 5 | 6 | import br.com.centralit.esi.api.resource.dao.ImageVersionDao; |
| 6 | 7 | import br.com.centralit.esi.api.resource.model.ImageVersion; |
| 8 | +import br.com.centralit.esi.api.resource.model.ResourceVersion; | |
| 9 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
| 7 | 10 | |
| 8 | 11 | @Repository("imageVersionDao") |
| 9 | 12 | public class ImageVersionDaoHibernate extends ResourceVersionDaoHibernate implements ImageVersionDao { |
| ... | ... | @@ -12,4 +15,20 @@ public class ImageVersionDaoHibernate extends ResourceVersionDaoHibernate implem |
| 12 | 15 | super(ImageVersion.class); |
| 13 | 16 | } |
| 14 | 17 | |
| 18 | + @Override | |
| 19 | + public ResourceVersion findByName(String resourceName) { | |
| 20 | + SearchSeven search = new SearchSeven(); | |
| 21 | + | |
| 22 | + search.addFilterEqual("resource.name", resourceName); | |
| 23 | + | |
| 24 | + search.addFilterEqual("resource.type", ResourceTypeEnum.IMAGE); | |
| 25 | + | |
| 26 | + search.addFilterEmpty("resource.dataInativo"); | |
| 27 | + search.addFilterEmpty("dataInativo"); | |
| 28 | + | |
| 29 | + search.setMaxResults(1); | |
| 30 | + | |
| 31 | + return this.searchUnique(search, ImageVersion.class); | |
| 32 | + } | |
| 33 | + | |
| 15 | 34 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/JavaScriptVersionDaoHibernate.java
| ... | ... | @@ -2,8 +2,11 @@ package br.com.centralit.esi.api.resource.dao.impl; |
| 2 | 2 | |
| 3 | 3 | import org.springframework.stereotype.Repository; |
| 4 | 4 | |
| 5 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 5 | 6 | import br.com.centralit.esi.api.resource.dao.JavaScriptVersionDao; |
| 6 | 7 | import br.com.centralit.esi.api.resource.model.JavaScriptVersion; |
| 8 | +import br.com.centralit.esi.api.resource.model.ResourceVersion; | |
| 9 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
| 7 | 10 | |
| 8 | 11 | @Repository("javaScriptVersionDao") |
| 9 | 12 | public class JavaScriptVersionDaoHibernate extends ResourceVersionDaoHibernate implements JavaScriptVersionDao { |
| ... | ... | @@ -12,4 +15,21 @@ public class JavaScriptVersionDaoHibernate extends ResourceVersionDaoHibernate i |
| 12 | 15 | super(JavaScriptVersion.class); |
| 13 | 16 | } |
| 14 | 17 | |
| 18 | + @Override | |
| 19 | + public ResourceVersion findByName(String resourceName) { | |
| 20 | + SearchSeven search = new SearchSeven(); | |
| 21 | + | |
| 22 | + search.addFilterEqual("resource.name", resourceName); | |
| 23 | + | |
| 24 | + search.addFilterEqual("resource.type", ResourceTypeEnum.JAVASCRIPT); | |
| 25 | + | |
| 26 | + search.addFilterEmpty("resource.dataInativo"); | |
| 27 | + search.addFilterEmpty("dataInativo"); | |
| 28 | + | |
| 29 | + search.setMaxResults(1); | |
| 30 | + | |
| 31 | + return this.searchUnique(search, JavaScriptVersion.class); | |
| 32 | + } | |
| 33 | + | |
| 34 | + | |
| 15 | 35 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/PageVersionDaoHibernate.java
| ... | ... | @@ -2,8 +2,11 @@ package br.com.centralit.esi.api.resource.dao.impl; |
| 2 | 2 | |
| 3 | 3 | import org.springframework.stereotype.Repository; |
| 4 | 4 | |
| 5 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 5 | 6 | import br.com.centralit.esi.api.resource.dao.PageVersionDao; |
| 6 | 7 | import br.com.centralit.esi.api.resource.model.PageVersion; |
| 8 | +import br.com.centralit.esi.api.resource.model.ResourceVersion; | |
| 9 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
| 7 | 10 | |
| 8 | 11 | @Repository("pageVersionDao") |
| 9 | 12 | public class PageVersionDaoHibernate extends ResourceVersionDaoHibernate implements PageVersionDao { |
| ... | ... | @@ -12,4 +15,20 @@ public class PageVersionDaoHibernate extends ResourceVersionDaoHibernate impleme |
| 12 | 15 | super(PageVersion.class); |
| 13 | 16 | } |
| 14 | 17 | |
| 18 | + @Override | |
| 19 | + public ResourceVersion findByName(String resourceName) { | |
| 20 | + SearchSeven search = new SearchSeven(); | |
| 21 | + | |
| 22 | + search.addFilterEqual("resource.name", resourceName); | |
| 23 | + | |
| 24 | + search.addFilterEqual("resource.type", ResourceTypeEnum.PAGE); | |
| 25 | + | |
| 26 | + search.addFilterEmpty("resource.dataInativo"); | |
| 27 | + search.addFilterEmpty("dataInativo"); | |
| 28 | + | |
| 29 | + search.setMaxResults(1); | |
| 30 | + | |
| 31 | + return this.searchUnique(search, PageVersion.class); | |
| 32 | + } | |
| 33 | + | |
| 15 | 34 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/ReportDataSourceDaoHibernate.java
0 → 100644
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +package br.com.centralit.esi.api.resource.dao.impl; | |
| 2 | + | |
| 3 | +import org.springframework.stereotype.Repository; | |
| 4 | + | |
| 5 | +import br.com.centralit.esi.api.resource.dao.ReportDataSourceDao; | |
| 6 | +import br.com.centralit.esi.api.resource.model.ReportDataSource; | |
| 7 | +import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; | |
| 8 | +import br.com.centralit.framework.model.arquitetura.PersistentObject; | |
| 9 | + | |
| 10 | +@Repository("reportDataSourceDao") | |
| 11 | +public class ReportDataSourceDaoHibernate extends CitGenericDAOImpl implements ReportDataSourceDao { | |
| 12 | + public ReportDataSourceDaoHibernate() { | |
| 13 | + super(ReportDataSource.class); | |
| 14 | + } | |
| 15 | + | |
| 16 | + @Override | |
| 17 | + public boolean remove(PersistentObject entity) { | |
| 18 | + em().remove(entity); | |
| 19 | + return true; | |
| 20 | + } | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public void remove(Long id, @SuppressWarnings("rawtypes") Class classs) { | |
| 24 | + em().remove(getReference(id, classs)); | |
| 25 | + } | |
| 26 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/ReportParameterDaoHibernate.java
0 → 100644
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +package br.com.centralit.esi.api.resource.dao.impl; | |
| 2 | + | |
| 3 | +import org.springframework.stereotype.Repository; | |
| 4 | + | |
| 5 | +import br.com.centralit.esi.api.resource.dao.ReportParameterDao; | |
| 6 | +import br.com.centralit.esi.api.resource.model.ReportParameter; | |
| 7 | +import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; | |
| 8 | +import br.com.centralit.framework.model.arquitetura.PersistentObject; | |
| 9 | + | |
| 10 | +@Repository("reportParameterDao") | |
| 11 | +public class ReportParameterDaoHibernate extends CitGenericDAOImpl implements ReportParameterDao { | |
| 12 | + public ReportParameterDaoHibernate() { | |
| 13 | + super(ReportParameter.class); | |
| 14 | + } | |
| 15 | + | |
| 16 | + @Override | |
| 17 | + public boolean remove(PersistentObject entity) { | |
| 18 | + em().remove(entity); | |
| 19 | + return true; | |
| 20 | + } | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public void remove(Long id, @SuppressWarnings("rawtypes") Class classs) { | |
| 24 | + em().remove(getReference(id, classs)); | |
| 25 | + } | |
| 26 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/dao/impl/ReportVersionDaoHibernate.java
0 → 100644
| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | +package br.com.centralit.esi.api.resource.dao.impl; | |
| 2 | + | |
| 3 | +import org.springframework.stereotype.Repository; | |
| 4 | + | |
| 5 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 6 | +import br.com.centralit.esi.api.resource.dao.ReportVersionDao; | |
| 7 | +import br.com.centralit.esi.api.resource.model.ReportVersion; | |
| 8 | +import br.com.centralit.esi.api.resource.model.ResourceVersion; | |
| 9 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
| 10 | + | |
| 11 | +@Repository("reportVersionDao") | |
| 12 | +public class ReportVersionDaoHibernate extends ResourceVersionDaoHibernate implements ReportVersionDao { | |
| 13 | + | |
| 14 | + public ReportVersionDaoHibernate() { | |
| 15 | + super(ReportVersion.class); | |
| 16 | + } | |
| 17 | + | |
| 18 | + @Override | |
| 19 | + public ResourceVersion findByName(String resourceName) { | |
| 20 | + SearchSeven search = new SearchSeven(); | |
| 21 | + | |
| 22 | + search.addFilterEqual("resource.name", resourceName); | |
| 23 | + | |
| 24 | + search.addFilterEqual("resource.type", ResourceTypeEnum.REPORT); | |
| 25 | + | |
| 26 | + search.addFilterEmpty("resource.dataInativo"); | |
| 27 | + search.addFilterEmpty("dataInativo"); | |
| 28 | + | |
| 29 | + search.setMaxResults(1); | |
| 30 | + | |
| 31 | + return this.searchUnique(search, ReportVersion.class); | |
| 32 | + } | |
| 33 | + | |
| 34 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/FormComponent.java
| ... | ... | @@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonView; |
| 27 | 27 | |
| 28 | 28 | @Entity |
| 29 | 29 | @Table(name="RES_FormComponent") |
| 30 | -@JsonIgnoreProperties({ "$type", "rowIndex" }) | |
| 30 | +@JsonIgnoreProperties({ "$type", "rowIndex", "rowIndexInput" }) | |
| 31 | 31 | public class FormComponent extends PersistentObject { |
| 32 | 32 | |
| 33 | 33 | /** | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/FormVersion.java
| ... | ... | @@ -80,6 +80,9 @@ public class FormVersion extends ResourceVersion { |
| 80 | 80 | private Boolean showTabs; |
| 81 | 81 | |
| 82 | 82 | @JsonView({ Views.GenericView.class}) |
| 83 | + private Boolean verticalTabs; | |
| 84 | + | |
| 85 | + @JsonView({ Views.GenericView.class}) | |
| 83 | 86 | private Boolean forBusinessProcess; |
| 84 | 87 | |
| 85 | 88 | @JsonView({ Views.GenericView.class}) |
| ... | ... | @@ -328,4 +331,12 @@ public class FormVersion extends ResourceVersion { |
| 328 | 331 | public void setGenerateDefaultPage(Boolean generateDefaultPage) { |
| 329 | 332 | this.generateDefaultPage = generateDefaultPage; |
| 330 | 333 | } |
| 334 | + | |
| 335 | + public Boolean getVerticalTabs() { | |
| 336 | + return verticalTabs; | |
| 337 | + } | |
| 338 | + | |
| 339 | + public void setVerticalTabs(Boolean verticalTabs) { | |
| 340 | + this.verticalTabs = verticalTabs; | |
| 341 | + } | |
| 331 | 342 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ReportDataSource.java
0 → 100644
| ... | ... | @@ -0,0 +1,170 @@ |
| 1 | +package br.com.centralit.esi.api.resource.model; | |
| 2 | + | |
| 3 | +import javax.persistence.Column; | |
| 4 | +import javax.persistence.Embedded; | |
| 5 | +import javax.persistence.Entity; | |
| 6 | +import javax.persistence.FetchType; | |
| 7 | +import javax.persistence.GeneratedValue; | |
| 8 | +import javax.persistence.GenerationType; | |
| 9 | +import javax.persistence.Id; | |
| 10 | +import javax.persistence.ManyToOne; | |
| 11 | +import javax.persistence.Table; | |
| 12 | + | |
| 13 | +import br.com.centralit.esi.api.data.model.CustomSQL; | |
| 14 | +import br.com.centralit.esi.api.data.model.DataObject; | |
| 15 | +import br.com.centralit.esi.api.data.model.DataSource; | |
| 16 | +import br.com.centralit.esi.api.design.model.Flow; | |
| 17 | +import br.com.centralit.esi.api.design.model.ScriptCode; | |
| 18 | +import br.com.centralit.esi.api.enumerated.ReportDataSourceEnum; | |
| 19 | +import br.com.centralit.framework.json.Views; | |
| 20 | +import br.com.centralit.framework.model.arquitetura.PersistentObject; | |
| 21 | + | |
| 22 | +import com.fasterxml.jackson.annotation.JsonView; | |
| 23 | + | |
| 24 | +@Entity | |
| 25 | +@Table(name="RES_ReportDataSource") | |
| 26 | +public class ReportDataSource extends PersistentObject { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * | |
| 30 | + */ | |
| 31 | + private static final long serialVersionUID = -1378383432960623032L; | |
| 32 | + | |
| 33 | + @Id | |
| 34 | + @GeneratedValue(strategy = GenerationType.AUTO) | |
| 35 | + @JsonView({Views.GenericView.class }) | |
| 36 | + protected Long id; | |
| 37 | + | |
| 38 | + @Column(nullable = false) | |
| 39 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 40 | + private ReportDataSourceEnum type; | |
| 41 | + | |
| 42 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 43 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 44 | + protected DataSource connection; | |
| 45 | + | |
| 46 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 47 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 48 | + protected DataObject dataObject; | |
| 49 | + | |
| 50 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 51 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 52 | + protected CustomSQL customSQL; | |
| 53 | + | |
| 54 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 55 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 56 | + private Flow flow; | |
| 57 | + | |
| 58 | + @Embedded | |
| 59 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 60 | + private ScriptCode scriptCode; | |
| 61 | + | |
| 62 | + @Column(nullable = true) | |
| 63 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 64 | + private String outputAttributeName; | |
| 65 | + | |
| 66 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 67 | + private Boolean restoreManyToOne; | |
| 68 | + | |
| 69 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 70 | + private Boolean restoreOneToMany; | |
| 71 | + | |
| 72 | + public ReportDataSource() { | |
| 73 | + // TODO Auto-generated constructor stub | |
| 74 | + } | |
| 75 | + | |
| 76 | + public ReportDataSource(ReportDataSource reportDataSource) { | |
| 77 | + this.type = reportDataSource.getType(); | |
| 78 | + this.connection = reportDataSource.getConnection(); | |
| 79 | + this.dataObject = reportDataSource.getDataObject(); | |
| 80 | + this.flow = reportDataSource.getFlow(); | |
| 81 | + this.scriptCode = reportDataSource.getScriptCode(); | |
| 82 | + this.outputAttributeName = reportDataSource.getOutputAttributeName(); | |
| 83 | + this.restoreManyToOne = reportDataSource.getRestoreManyToOne(); | |
| 84 | + this.restoreOneToMany = reportDataSource.getRestoreOneToMany(); | |
| 85 | + this.customSQL = reportDataSource.getCustomSQL(); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + public Long getId() { | |
| 90 | + return this.id; | |
| 91 | + } | |
| 92 | + | |
| 93 | + | |
| 94 | + public ReportDataSourceEnum getType() { | |
| 95 | + return type; | |
| 96 | + } | |
| 97 | + | |
| 98 | + public void setType(ReportDataSourceEnum type) { | |
| 99 | + this.type = type; | |
| 100 | + } | |
| 101 | + | |
| 102 | + public DataObject getDataObject() { | |
| 103 | + return dataObject; | |
| 104 | + } | |
| 105 | + | |
| 106 | + public void setDataObject(DataObject dataObject) { | |
| 107 | + this.dataObject = dataObject; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public Flow getFlow() { | |
| 111 | + return flow; | |
| 112 | + } | |
| 113 | + | |
| 114 | + public void setFlow(Flow flow) { | |
| 115 | + this.flow = flow; | |
| 116 | + } | |
| 117 | + | |
| 118 | + public String getOutputAttributeName() { | |
| 119 | + return outputAttributeName; | |
| 120 | + } | |
| 121 | + | |
| 122 | + public void setOutputAttributeName(String outputAttributeName) { | |
| 123 | + this.outputAttributeName = outputAttributeName; | |
| 124 | + } | |
| 125 | + | |
| 126 | + public void setId(Long id) { | |
| 127 | + this.id = id; | |
| 128 | + } | |
| 129 | + | |
| 130 | + public ScriptCode getScriptCode() { | |
| 131 | + return scriptCode; | |
| 132 | + } | |
| 133 | + | |
| 134 | + public void setScriptCode(ScriptCode scriptCode) { | |
| 135 | + this.scriptCode = scriptCode; | |
| 136 | + } | |
| 137 | + | |
| 138 | + public DataSource getConnection() { | |
| 139 | + return connection; | |
| 140 | + } | |
| 141 | + | |
| 142 | + public void setConnection(DataSource connection) { | |
| 143 | + this.connection = connection; | |
| 144 | + } | |
| 145 | + | |
| 146 | + public CustomSQL getCustomSQL() { | |
| 147 | + return customSQL; | |
| 148 | + } | |
| 149 | + | |
| 150 | + public void setCustomSQL(CustomSQL customSQL) { | |
| 151 | + this.customSQL = customSQL; | |
| 152 | + } | |
| 153 | + | |
| 154 | + public Boolean getRestoreManyToOne() { | |
| 155 | + return restoreManyToOne; | |
| 156 | + } | |
| 157 | + | |
| 158 | + public void setRestoreManyToOne(Boolean restoreManyToOne) { | |
| 159 | + this.restoreManyToOne = restoreManyToOne; | |
| 160 | + } | |
| 161 | + | |
| 162 | + public Boolean getRestoreOneToMany() { | |
| 163 | + return restoreOneToMany; | |
| 164 | + } | |
| 165 | + | |
| 166 | + public void setRestoreOneToMany(Boolean restoreOneToMany) { | |
| 167 | + this.restoreOneToMany = restoreOneToMany; | |
| 168 | + } | |
| 169 | + | |
| 170 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ReportParameter.java
0 → 100644
| ... | ... | @@ -0,0 +1,192 @@ |
| 1 | +package br.com.centralit.esi.api.resource.model; | |
| 2 | + | |
| 3 | +import javax.persistence.Basic; | |
| 4 | +import javax.persistence.Column; | |
| 5 | +import javax.persistence.Embedded; | |
| 6 | +import javax.persistence.Entity; | |
| 7 | +import javax.persistence.FetchType; | |
| 8 | +import javax.persistence.GeneratedValue; | |
| 9 | +import javax.persistence.GenerationType; | |
| 10 | +import javax.persistence.Id; | |
| 11 | +import javax.persistence.Lob; | |
| 12 | +import javax.persistence.ManyToOne; | |
| 13 | +import javax.persistence.Table; | |
| 14 | + | |
| 15 | +import org.hibernate.annotations.Type; | |
| 16 | + | |
| 17 | +import br.com.centralit.esi.api.data.model.CustomSQL; | |
| 18 | +import br.com.centralit.esi.api.data.model.DataObject; | |
| 19 | +import br.com.centralit.esi.api.design.model.Flow; | |
| 20 | +import br.com.centralit.esi.api.design.model.ScriptCode; | |
| 21 | +import br.com.centralit.esi.api.enumerated.ReportParameterTypeEnum; | |
| 22 | +import br.com.centralit.framework.json.Views; | |
| 23 | +import br.com.centralit.framework.model.arquitetura.PersistentObject; | |
| 24 | + | |
| 25 | +import com.fasterxml.jackson.annotation.JsonIgnore; | |
| 26 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
| 27 | +import com.fasterxml.jackson.annotation.JsonView; | |
| 28 | + | |
| 29 | +@Entity | |
| 30 | +@Table(name="RES_ReportParameter") | |
| 31 | +@JsonIgnoreProperties({ "$index" }) | |
| 32 | +public class ReportParameter extends PersistentObject { | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * | |
| 36 | + */ | |
| 37 | + private static final long serialVersionUID = -7632995826475698705L; | |
| 38 | + | |
| 39 | + @Id | |
| 40 | + @GeneratedValue(strategy = GenerationType.AUTO) | |
| 41 | + @JsonView({Views.GenericView.class }) | |
| 42 | + protected Long id; | |
| 43 | + | |
| 44 | + @Column(nullable = false) | |
| 45 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 46 | + private ReportParameterTypeEnum type; | |
| 47 | + | |
| 48 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 49 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 50 | + protected DataObject dataObject; | |
| 51 | + | |
| 52 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 53 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 54 | + protected CustomSQL customSQL; | |
| 55 | + | |
| 56 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 57 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 58 | + private Flow flow; | |
| 59 | + | |
| 60 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 61 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 62 | + private Resource image; | |
| 63 | + | |
| 64 | + @Embedded | |
| 65 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 66 | + private ScriptCode scriptCode; | |
| 67 | + | |
| 68 | + @Lob | |
| 69 | + @Basic(fetch = FetchType.LAZY) | |
| 70 | + @Type(type="org.hibernate.type.StringClobType") | |
| 71 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 72 | + private String constant; | |
| 73 | + | |
| 74 | + @Column(nullable = true) | |
| 75 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 76 | + private String outputAttributeName; | |
| 77 | + | |
| 78 | + @ManyToOne(fetch=FetchType.LAZY, optional=false) | |
| 79 | + @JsonIgnore | |
| 80 | + protected ReportVersion report; | |
| 81 | + | |
| 82 | + @Column(nullable = false) | |
| 83 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 84 | + private String name; | |
| 85 | + | |
| 86 | + public ReportParameter() { | |
| 87 | + | |
| 88 | + } | |
| 89 | + | |
| 90 | + public ReportParameter(ReportVersion report, ReportParameter reportParameter) { | |
| 91 | + this.name = reportParameter.getName(); | |
| 92 | + this.report = report; | |
| 93 | + this.type = reportParameter.getType(); | |
| 94 | + this.dataObject = reportParameter.getDataObject(); | |
| 95 | + this.flow = reportParameter.getFlow(); | |
| 96 | + this.image = reportParameter.getImage(); | |
| 97 | + this.scriptCode = reportParameter.getScriptCode(); | |
| 98 | + this.outputAttributeName = reportParameter.getOutputAttributeName(); | |
| 99 | + this.constant = reportParameter.getConstant(); | |
| 100 | + this.customSQL = reportParameter.getCustomSQL(); | |
| 101 | + } | |
| 102 | + | |
| 103 | + public ReportVersion getReport() { | |
| 104 | + return report; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public void setReport(ReportVersion report) { | |
| 108 | + this.report = report; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public String getName() { | |
| 112 | + return name; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public void setName(String name) { | |
| 116 | + this.name = name; | |
| 117 | + } | |
| 118 | + | |
| 119 | + @Override | |
| 120 | + public Long getId() { | |
| 121 | + return this.id; | |
| 122 | + } | |
| 123 | + | |
| 124 | + public ReportParameterTypeEnum getType() { | |
| 125 | + return type; | |
| 126 | + } | |
| 127 | + | |
| 128 | + public void setType(ReportParameterTypeEnum type) { | |
| 129 | + this.type = type; | |
| 130 | + } | |
| 131 | + | |
| 132 | + public DataObject getDataObject() { | |
| 133 | + return dataObject; | |
| 134 | + } | |
| 135 | + | |
| 136 | + public void setDataObject(DataObject dataObject) { | |
| 137 | + this.dataObject = dataObject; | |
| 138 | + } | |
| 139 | + | |
| 140 | + public Flow getFlow() { | |
| 141 | + return flow; | |
| 142 | + } | |
| 143 | + | |
| 144 | + public void setFlow(Flow flow) { | |
| 145 | + this.flow = flow; | |
| 146 | + } | |
| 147 | + | |
| 148 | + public Resource getImage() { | |
| 149 | + return image; | |
| 150 | + } | |
| 151 | + | |
| 152 | + public void setImage(Resource image) { | |
| 153 | + this.image = image; | |
| 154 | + } | |
| 155 | + | |
| 156 | + public ScriptCode getScriptCode() { | |
| 157 | + return scriptCode; | |
| 158 | + } | |
| 159 | + | |
| 160 | + public void setScriptCode(ScriptCode scriptCode) { | |
| 161 | + this.scriptCode = scriptCode; | |
| 162 | + } | |
| 163 | + | |
| 164 | + public String getOutputAttributeName() { | |
| 165 | + return outputAttributeName; | |
| 166 | + } | |
| 167 | + | |
| 168 | + public void setOutputAttributeName(String outputAttributeName) { | |
| 169 | + this.outputAttributeName = outputAttributeName; | |
| 170 | + } | |
| 171 | + | |
| 172 | + public void setId(Long id) { | |
| 173 | + this.id = id; | |
| 174 | + } | |
| 175 | + | |
| 176 | + public CustomSQL getCustomSQL() { | |
| 177 | + return customSQL; | |
| 178 | + } | |
| 179 | + | |
| 180 | + public void setCustomSQL(CustomSQL customSQL) { | |
| 181 | + this.customSQL = customSQL; | |
| 182 | + } | |
| 183 | + | |
| 184 | + public String getConstant() { | |
| 185 | + return constant; | |
| 186 | + } | |
| 187 | + | |
| 188 | + public void setConstant(String constant) { | |
| 189 | + this.constant = constant; | |
| 190 | + } | |
| 191 | + | |
| 192 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ReportVersion.java
0 → 100644
| ... | ... | @@ -0,0 +1,100 @@ |
| 1 | +package br.com.centralit.esi.api.resource.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import javax.persistence.CascadeType; | |
| 6 | +import javax.persistence.Column; | |
| 7 | +import javax.persistence.Entity; | |
| 8 | +import javax.persistence.FetchType; | |
| 9 | +import javax.persistence.ManyToOne; | |
| 10 | +import javax.persistence.OneToMany; | |
| 11 | +import javax.persistence.PrimaryKeyJoinColumn; | |
| 12 | +import javax.persistence.Table; | |
| 13 | +import javax.persistence.Transient; | |
| 14 | + | |
| 15 | +import br.com.centralit.esi.api.enumerated.ReportEngineEnum; | |
| 16 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 17 | +import br.com.centralit.framework.json.Views; | |
| 18 | + | |
| 19 | +import com.fasterxml.jackson.annotation.JsonView; | |
| 20 | + | |
| 21 | +@Entity | |
| 22 | +@Table(name="RES_ReportVersion") | |
| 23 | +@PrimaryKeyJoinColumn(name = "id") | |
| 24 | +public class ReportVersion extends ResourceVersion { | |
| 25 | + | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + private static final long serialVersionUID = -1095473041588484440L; | |
| 31 | + | |
| 32 | + @Column(nullable = false) | |
| 33 | + @JsonView({ Views.GenericView.class}) | |
| 34 | + private ReportEngineEnum engine; | |
| 35 | + | |
| 36 | + @ManyToOne(fetch=FetchType.LAZY, optional=true) | |
| 37 | + @JsonView({ Views.EsiResourceEditView.class}) | |
| 38 | + protected Resource form; | |
| 39 | + | |
| 40 | + @ManyToOne(cascade = { CascadeType.ALL }, fetch=FetchType.LAZY, optional=true) | |
| 41 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 42 | + protected ReportDataSource dataSource; | |
| 43 | + | |
| 44 | + @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "report", fetch = FetchType.LAZY) | |
| 45 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 46 | + private List<ReportParameter> parameters; | |
| 47 | + | |
| 48 | + @Transient | |
| 49 | + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) | |
| 50 | + private FormVersion formVersion; | |
| 51 | + | |
| 52 | + public ReportVersion() { | |
| 53 | + super(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + public ReportVersion(String name, String description, String path) { | |
| 57 | + super(ResourceTypeEnum.REPORT, name, description, path); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public ReportDataSource getDataSource() { | |
| 61 | + return dataSource; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void setDataSource(ReportDataSource dataSource) { | |
| 65 | + this.dataSource = dataSource; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public List<ReportParameter> getParameters() { | |
| 69 | + return parameters; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public void setParameters(List<ReportParameter> parameters) { | |
| 73 | + this.parameters = parameters; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public ReportEngineEnum getEngine() { | |
| 77 | + return engine; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public void setEngine(ReportEngineEnum engine) { | |
| 81 | + this.engine = engine; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public Resource getForm() { | |
| 85 | + return form; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public void setForm(Resource form) { | |
| 89 | + this.form = form; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public FormVersion getFormVersion() { | |
| 93 | + return formVersion; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void setFormVersion(FormVersion formVersion) { | |
| 97 | + this.formVersion = formVersion; | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/Resource.java
| 1 | 1 | package br.com.centralit.esi.api.resource.model; |
| 2 | 2 | |
| 3 | 3 | import java.util.Calendar; |
| 4 | +import java.util.HashMap; | |
| 4 | 5 | |
| 5 | 6 | import javax.persistence.Column; |
| 6 | 7 | import javax.persistence.Entity; |
| ... | ... | @@ -8,6 +9,7 @@ import javax.persistence.GeneratedValue; |
| 8 | 9 | import javax.persistence.GenerationType; |
| 9 | 10 | import javax.persistence.Id; |
| 10 | 11 | import javax.persistence.Table; |
| 12 | +import javax.persistence.Transient; | |
| 11 | 13 | |
| 12 | 14 | import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; |
| 13 | 15 | import br.com.centralit.framework.json.Views; |
| ... | ... | @@ -44,6 +46,14 @@ public class Resource extends PersistentObject { |
| 44 | 46 | @JsonView({ Views.GenericView.class}) |
| 45 | 47 | protected Boolean internalResource; |
| 46 | 48 | |
| 49 | + @Transient | |
| 50 | + @JsonView({ Views.GenericView.class}) | |
| 51 | + private HashMap<String, Object> inputMap; | |
| 52 | + | |
| 53 | + @Transient | |
| 54 | + @JsonView({ Views.GenericView.class}) | |
| 55 | + private String path; | |
| 56 | + | |
| 47 | 57 | public Resource() { |
| 48 | 58 | } |
| 49 | 59 | |
| ... | ... | @@ -111,5 +121,21 @@ public class Resource extends PersistentObject { |
| 111 | 121 | |
| 112 | 122 | public void setInternalResource(Boolean internalResource) { |
| 113 | 123 | this.internalResource = internalResource; |
| 124 | + } | |
| 125 | + | |
| 126 | + public HashMap<String, Object> getInputMap() { | |
| 127 | + return inputMap; | |
| 128 | + } | |
| 129 | + | |
| 130 | + public void setInputMap(HashMap<String, Object> inputMap) { | |
| 131 | + this.inputMap = inputMap; | |
| 132 | + } | |
| 133 | + | |
| 134 | + public String getPath() { | |
| 135 | + return path; | |
| 136 | + } | |
| 137 | + | |
| 138 | + public void setPath(String path) { | |
| 139 | + this.path = path; | |
| 114 | 140 | } |
| 115 | 141 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ResourceVersion.java
| ... | ... | @@ -48,6 +48,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| 48 | 48 | @JsonSubTypes.Type(value=ImageVersion.class, name="ImageVersion"), |
| 49 | 49 | @JsonSubTypes.Type(value=FileVersion.class, name="FileVersion"), |
| 50 | 50 | @JsonSubTypes.Type(value=PageVersion.class, name="PageVersion"), |
| 51 | + @JsonSubTypes.Type(value=ReportVersion.class, name="ReportVersion"), | |
| 51 | 52 | }) |
| 52 | 53 | public class ResourceVersion extends PersistentObject { |
| 53 | 54 | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/JasperReportManager.java
0 → 100644
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/PentahoReportManager.java
0 → 100644
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/ReportDataSourceService.java
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.resource.model.ReportDataSource; | |
| 4 | +import br.com.centralit.framework.service.arquitetura.GenericService; | |
| 5 | + | |
| 6 | +public interface ReportDataSourceService extends GenericService<ReportDataSource, Long> { | |
| 7 | + | |
| 8 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/ReportManager.java
0 → 100644
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service; | |
| 2 | + | |
| 3 | +import java.io.Serializable; | |
| 4 | +import java.util.HashMap; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.resource.model.ReportVersion; | |
| 7 | + | |
| 8 | +public interface ReportManager extends Serializable { | |
| 9 | + | |
| 10 | + public byte[] execute(ReportVersion reportVersion, HashMap<String, Object> inputMap); | |
| 11 | + | |
| 12 | + public void compile(ReportVersion reportVersion); | |
| 13 | + | |
| 14 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/ReportParameterService.java
0 → 100644
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service; | |
| 2 | + | |
| 3 | +import br.com.centralit.esi.api.resource.model.ReportParameter; | |
| 4 | +import br.com.centralit.framework.service.arquitetura.GenericService; | |
| 5 | + | |
| 6 | +public interface ReportParameterService extends GenericService<ReportParameter, Long> { | |
| 7 | + | |
| 8 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/ReportVersionService.java
0 → 100644
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service; | |
| 2 | + | |
| 3 | +import java.util.HashMap; | |
| 4 | + | |
| 5 | +import br.com.centralit.esi.api.resource.model.Resource; | |
| 6 | + | |
| 7 | + | |
| 8 | +public interface ReportVersionService extends ResourceVersionService { | |
| 9 | + | |
| 10 | + byte[] execute(Resource report, HashMap<String, Object> parameters); | |
| 11 | + | |
| 12 | +} | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/ResourceService.java
| ... | ... | @@ -2,12 +2,15 @@ package br.com.centralit.esi.api.resource.service; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | 4 | |
| 5 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 5 | 6 | import br.com.centralit.esi.api.resource.model.Resource; |
| 6 | 7 | import br.com.centralit.framework.service.arquitetura.GenericService; |
| 7 | 8 | |
| 8 | 9 | public interface ResourceService extends GenericService<Resource, Long> { |
| 9 | 10 | |
| 10 | 11 | public Resource findByName(String name); |
| 12 | + | |
| 13 | + public Resource findByNameAndType(String name, ResourceTypeEnum type); | |
| 11 | 14 | |
| 12 | 15 | public List<Resource> findByDescription(String description); |
| 13 | 16 | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/FormPageServiceImpl.java
| ... | ... | @@ -96,8 +96,8 @@ public class FormPageServiceImpl extends GenericServiceImpl<FormPage, Long> impl |
| 96 | 96 | String pageCode = this.replaceTags(formVersion, formPage.getPageCode()); |
| 97 | 97 | pageCode = pageCode.replaceAll("\\$\\{controllerName\\}", formPage.getControllerName()); |
| 98 | 98 | |
| 99 | - String headerLine1 = "'use strict';\n\ncitApp.controller('"+formPage.getControllerName()+"', ['$scope', 'appService', 'environmentService', 'userInterfaceService', 'subscriberService', 'flowService', 'documentService', 'businessProcessService', 'businessRuleService', 'notificationService', 'formService', 'userTaskService', 'dataService', '$timeout', '$translate', '$compile', '$injector', '$rootScope', '$modal'"; | |
| 100 | - String headerLine2 = " function "+formPage.getControllerName()+"($scope, appService, environmentService, userInterfaceService, subscriberService, flowService, documentService, businessProcessService, businessRuleService, notificationService, formService, userTaskService, dataService, $timeout, $translate, $compile, $injector, $rootScope, $modal"; | |
| 99 | + String headerLine1 = "'use strict';\n\ncitApp.controller('"+formPage.getControllerName()+"', ['$scope', 'appService', 'environmentService', 'userInterfaceService', 'subscriberService', 'flowService', 'documentService', 'businessProcessService', 'businessRuleService', 'notificationService', 'formService', 'userTaskService', 'dataService', '$timeout', '$translate', '$compile', '$injector', '$rootScope', '$modal', '$filter'"; | |
| 100 | + String headerLine2 = " function "+formPage.getControllerName()+"($scope, appService, environmentService, userInterfaceService, subscriberService, flowService, documentService, businessProcessService, businessRuleService, notificationService, formService, userTaskService, dataService, $timeout, $translate, $compile, $injector, $rootScope, $modal, $filter"; | |
| 101 | 101 | if (formPage.getDependencies() != null) { |
| 102 | 102 | for (String dependency : formPage.getDependencies()) { |
| 103 | 103 | if (headerLine1.indexOf(dependency.trim()) < 0) { | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/FormVersionServiceImpl.java
| ... | ... | @@ -136,6 +136,9 @@ public class FormVersionServiceImpl extends ResourceVersionServiceImpl implement |
| 136 | 136 | if (formVersion.getShowTabs() == null) { |
| 137 | 137 | formVersion.setShowTabs(false); |
| 138 | 138 | } |
| 139 | + if (formVersion.getVerticalTabs() == null) { | |
| 140 | + formVersion.setVerticalTabs(false); | |
| 141 | + } | |
| 139 | 142 | |
| 140 | 143 | if (!formVersion.getShowTabs()) { |
| 141 | 144 | formVersion.setTabs(new ArrayList<FormTab>()); |
| ... | ... | @@ -412,6 +415,7 @@ public class FormVersionServiceImpl extends ResourceVersionServiceImpl implement |
| 412 | 415 | newResourceVersion.setDefaultPage(new FormPage(oldResourceVersion.getDefaultPage())); |
| 413 | 416 | newResourceVersion.setPreviewJS(oldResourceVersion.getPreviewJS()); |
| 414 | 417 | newResourceVersion.setShowTabs(oldResourceVersion.getShowTabs()); |
| 418 | + newResourceVersion.setVerticalTabs(oldResourceVersion.getVerticalTabs()); | |
| 415 | 419 | newResourceVersion.setMenu(oldResourceVersion.getMenu()); |
| 416 | 420 | newResourceVersion.setMenuName(oldResourceVersion.getMenuName()); |
| 417 | 421 | |
| ... | ... | @@ -473,7 +477,9 @@ public class FormVersionServiceImpl extends ResourceVersionServiceImpl implement |
| 473 | 477 | |
| 474 | 478 | if (formVersion.getRows() != null) { |
| 475 | 479 | if (formVersion.getShowTabs() != null && formVersion.getShowTabs() && formVersion.getTabs() != null) { |
| 476 | - htmlCode += "<tabset class=\"tabbable\" >\n"; | |
| 480 | + String vertical = formVersion.getVerticalTabs() != null ? formVersion.getVerticalTabs().toString() : "false"; | |
| 481 | + String tabsLeft = vertical.equalsIgnoreCase("true") ? "tabs-left" : ""; | |
| 482 | + htmlCode += "<tabset class=\"tabbable "+tabsLeft+"\" vertical=\""+vertical+"\" >\n"; | |
| 477 | 483 | for (FormTab formTab : formVersion.getTabs()) { |
| 478 | 484 | htmlCode += " <tab "; |
| 479 | 485 | if (!UtilString.isNullOrEmpty(formTab.getNgShowHtml())) { | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/JasperReportManagerImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,161 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service.impl; | |
| 2 | + | |
| 3 | +import java.io.File; | |
| 4 | +import java.io.FileOutputStream; | |
| 5 | +import java.sql.Connection; | |
| 6 | +import java.util.HashMap; | |
| 7 | +import java.util.List; | |
| 8 | +import java.util.Map; | |
| 9 | + | |
| 10 | +import net.sf.jasperreports.engine.JRDataSource; | |
| 11 | +import net.sf.jasperreports.engine.JRException; | |
| 12 | +import net.sf.jasperreports.engine.JasperCompileManager; | |
| 13 | +import net.sf.jasperreports.engine.JasperExportManager; | |
| 14 | +import net.sf.jasperreports.engine.JasperFillManager; | |
| 15 | +import net.sf.jasperreports.engine.JasperPrint; | |
| 16 | +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; | |
| 17 | + | |
| 18 | +import org.json.JSONArray; | |
| 19 | +import org.springframework.stereotype.Component; | |
| 20 | + | |
| 21 | +import br.com.centralit.esi.api.enumerated.RelationshipTypeEnum; | |
| 22 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 23 | +import br.com.centralit.esi.api.execution.component.ExecuteScript; | |
| 24 | +import br.com.centralit.esi.api.resource.model.ReportDataSource; | |
| 25 | +import br.com.centralit.esi.api.resource.model.ReportVersion; | |
| 26 | +import br.com.centralit.esi.api.resource.service.JasperReportManager; | |
| 27 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 28 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironmentImpl; | |
| 29 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironmentOutput; | |
| 30 | +import br.com.centralit.esi.exception.EsiExecutionException; | |
| 31 | + | |
| 32 | +@Component("jasperReportManager") | |
| 33 | +public class JasperReportManagerImpl extends ReportManagerImpl implements JasperReportManager { | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + private static final long serialVersionUID = 1L; | |
| 39 | + | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + public void compile(ReportVersion reportVersion) { | |
| 43 | + String pathReport = servletContext.getRealPath(reportVersion.buildBasePath()+"/"+reportVersion.getFileName()); | |
| 44 | + | |
| 45 | + String pathReportJasper = servletContext.getRealPath(ResourceTypeEnum.REPORT.getPath())+ "/"+reportVersion.getFileName().replaceAll(".jrxml", ".jasper"); | |
| 46 | + | |
| 47 | + try { | |
| 48 | + JasperCompileManager.compileReportToFile(pathReport, pathReportJasper); | |
| 49 | + } catch (JRException e1) { | |
| 50 | + e1.printStackTrace(); | |
| 51 | + throw new EsiExecutionException(e1); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + public byte[] execute(ReportVersion report, HashMap<String, Object> inputMap) { | |
| 57 | + JasperPrint print = null; | |
| 58 | + byte[] buffer = null; | |
| 59 | + | |
| 60 | + String path = ResourceTypeEnum.REPORT.getPath(); | |
| 61 | + | |
| 62 | + String pathReport = servletContext.getRealPath(path+"/"+report.getFileName()); | |
| 63 | + | |
| 64 | + pathReport = pathReport.replaceAll(".jrxml", ".jasper"); | |
| 65 | + | |
| 66 | + Map<String, Object> params = this.buildParams(report, inputMap); | |
| 67 | + params.put("SUBREPORT_DIR", servletContext.getRealPath(path)+"/"); | |
| 68 | + | |
| 69 | + switch (report.getDataSource().getType()) { | |
| 70 | + case CONNECTION: | |
| 71 | + Connection connection = dataSourceService.connect(report.getDataSource().getConnection()); | |
| 72 | + | |
| 73 | + try { | |
| 74 | + print = JasperFillManager.fillReport(pathReport, params, connection); | |
| 75 | + } catch (JRException e) { | |
| 76 | + e.printStackTrace(); | |
| 77 | + try { | |
| 78 | + connection.close(); | |
| 79 | + } catch (Exception e1) { | |
| 80 | + } | |
| 81 | + connection = null; | |
| 82 | + throw new EsiExecutionException(e); | |
| 83 | + } | |
| 84 | + break; | |
| 85 | + | |
| 86 | + default: | |
| 87 | + try { | |
| 88 | + print = JasperFillManager.fillReport(pathReport, params, this.buildDataSource(report, inputMap)); | |
| 89 | + } catch (JRException e) { | |
| 90 | + throw new EsiExecutionException(e); | |
| 91 | + } | |
| 92 | + break; | |
| 93 | + } | |
| 94 | + | |
| 95 | + if (print != null) { | |
| 96 | + try { | |
| 97 | + buffer = JasperExportManager.exportReportToPdf(print); | |
| 98 | + | |
| 99 | + String pathPDF = pathReport.replaceAll(".jasper", ".pdf"); | |
| 100 | + | |
| 101 | + File file = new File(pathPDF); | |
| 102 | + FileOutputStream in = new FileOutputStream(file); | |
| 103 | + in.write(buffer); | |
| 104 | + in.close(); | |
| 105 | + | |
| 106 | + } catch (Exception e) { | |
| 107 | + e.printStackTrace(); | |
| 108 | + throw new EsiExecutionException(e); | |
| 109 | + } | |
| 110 | + } | |
| 111 | + | |
| 112 | + return buffer; | |
| 113 | + | |
| 114 | + } | |
| 115 | + | |
| 116 | + @Override | |
| 117 | + protected JRDataSource buildDataSource(ReportVersion report, HashMap<String, Object> inputMap) { | |
| 118 | + ReportDataSource reportDataSource = report.getDataSource(); | |
| 119 | + JRDataSource dataSource = null; | |
| 120 | + | |
| 121 | + switch (reportDataSource.getType()) { | |
| 122 | + case DATAOBJECT: | |
| 123 | + String SQLName = reportDataSource.getCustomSQL() != null ? reportDataSource.getCustomSQL().getName() : null; | |
| 124 | + List<HashMap<String, Object>> resultSet = dataManager.executeQuery(reportDataSource.getDataObject(), SQLName, inputMap); | |
| 125 | + | |
| 126 | + if (reportDataSource.getRestoreManyToOne()) { | |
| 127 | + dataManager.restoreRelationships(reportDataSource.getDataObject(), RelationshipTypeEnum.MANY_TO_ONE, resultSet); | |
| 128 | + } | |
| 129 | + if (reportDataSource.getRestoreOneToMany()) { | |
| 130 | + dataManager.restoreRelationships(reportDataSource.getDataObject(), RelationshipTypeEnum.ONE_TO_MANY, resultSet); | |
| 131 | + } | |
| 132 | + | |
| 133 | + dataSource = new JRBeanCollectionDataSource(net.sf.json.JSONArray.fromObject(resultSet)); | |
| 134 | + break; | |
| 135 | + | |
| 136 | + case FLOW: | |
| 137 | + RuntimeEnvironmentOutput output = runtimeManager.execute(reportDataSource.getFlow().getName(), inputMap); | |
| 138 | + if (output.getOutputVariables() != null) { | |
| 139 | + Object value = output.getValue(reportDataSource.getOutputAttributeName()); | |
| 140 | + if (value != null && value instanceof JSONArray) { | |
| 141 | + dataSource = new JRBeanCollectionDataSource(net.sf.json.JSONArray.fromObject(value.toString())); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + break; | |
| 145 | + | |
| 146 | + case SCRIPT: | |
| 147 | + RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironmentImpl(null, inputMap); | |
| 148 | + Object value = ExecuteScript.execute(runtimeEnvironment, report.getResource().getName(), reportDataSource.getScriptCode()); | |
| 149 | + if (value != null && value instanceof JSONArray) { | |
| 150 | + dataSource = new JRBeanCollectionDataSource(net.sf.json.JSONArray.fromObject(value.toString())); | |
| 151 | + } | |
| 152 | + break; | |
| 153 | + | |
| 154 | + default: | |
| 155 | + break; | |
| 156 | + } | |
| 157 | + | |
| 158 | + return dataSource; | |
| 159 | + } | |
| 160 | + | |
| 161 | +} | |
| 0 | 162 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/PentahoReportManagerImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,136 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service.impl; | |
| 2 | + | |
| 3 | +import java.io.FileInputStream; | |
| 4 | +import java.io.IOException; | |
| 5 | +import java.net.MalformedURLException; | |
| 6 | +import java.sql.Connection; | |
| 7 | +import java.util.HashMap; | |
| 8 | +import java.util.Map; | |
| 9 | + | |
| 10 | +import org.pentaho.reporting.engine.classic.core.MasterReport; | |
| 11 | +import org.pentaho.reporting.engine.classic.core.ReportProcessingException; | |
| 12 | +import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLReportDataFactory; | |
| 13 | +import org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.PdfReportUtil; | |
| 14 | +import org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlReportUtil; | |
| 15 | +import org.pentaho.reporting.engine.classic.core.modules.output.table.xls.ExcelReportUtil; | |
| 16 | +import org.pentaho.reporting.libraries.resourceloader.ResourceException; | |
| 17 | +import org.springframework.stereotype.Component; | |
| 18 | + | |
| 19 | +import br.com.centralit.esi.api.data.core.DataObjectUtil; | |
| 20 | +import br.com.centralit.esi.api.enumerated.ReportFormatTypeEnum; | |
| 21 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 22 | +import br.com.centralit.esi.api.resource.model.ReportDataSource; | |
| 23 | +import br.com.centralit.esi.api.resource.model.ReportVersion; | |
| 24 | +import br.com.centralit.esi.api.resource.service.PentahoReportManager; | |
| 25 | +import br.com.centralit.esi.api.util.DefaultConvertUtils; | |
| 26 | +import br.com.centralit.esi.api.util.PentahoReportUtil; | |
| 27 | +import br.com.centralit.esi.exception.EsiExecutionException; | |
| 28 | + | |
| 29 | +@Component("pentahoReportManager") | |
| 30 | +public class PentahoReportManagerImpl extends ReportManagerImpl implements PentahoReportManager { | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * | |
| 34 | + */ | |
| 35 | + private static final long serialVersionUID = 1L; | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + protected SQLReportDataFactory buildDataSource(ReportVersion report, HashMap<String, Object> parameters) { | |
| 39 | + ReportDataSource reportDataSource = report.getDataSource(); | |
| 40 | + SQLReportDataFactory dataSource = null; | |
| 41 | + Connection connection = null; | |
| 42 | + | |
| 43 | + switch (reportDataSource.getType()) { | |
| 44 | + case CONNECTION: | |
| 45 | + connection = dataSourceService.connect(report.getDataSource().getConnection()); | |
| 46 | + dataSource = new SQLReportDataFactory(connection); | |
| 47 | + break; | |
| 48 | + | |
| 49 | + case DATAOBJECT: | |
| 50 | + connection = dataSourceService.connect(reportDataSource.getDataObject().getDataSource()); | |
| 51 | + dataSource = new SQLReportDataFactory(connection); | |
| 52 | + if (reportDataSource.getCustomSQL() != null) { | |
| 53 | + dataSource.setQuery(reportDataSource.getDataObject().getName(), reportDataSource.getCustomSQL().getSql()); | |
| 54 | + }else{ | |
| 55 | + dataSource.setQuery(reportDataSource.getDataObject().getName(), DataObjectUtil.buildSelectSQL(reportDataSource.getDataObject())); | |
| 56 | + } | |
| 57 | + break; | |
| 58 | + | |
| 59 | + default: | |
| 60 | + break; | |
| 61 | + } | |
| 62 | + | |
| 63 | + return dataSource; | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public byte[] execute(ReportVersion report, HashMap<String, Object> inputMap) { | |
| 68 | + byte[] buffer = null; | |
| 69 | + | |
| 70 | + String path = report.buildBasePath(); | |
| 71 | + | |
| 72 | + String pathReport = servletContext.getRealPath(path+"/"+report.getFileName()); | |
| 73 | + | |
| 74 | + Map<String, Object> params = this.buildParams(report, inputMap); | |
| 75 | + | |
| 76 | + ReportFormatTypeEnum outType = ReportFormatTypeEnum.PDF; | |
| 77 | + | |
| 78 | + DefaultConvertUtils.registerDefaultConverts(); | |
| 79 | + MasterReport masterReport = null; | |
| 80 | + try { | |
| 81 | + SQLReportDataFactory dataSource = this.buildDataSource(report, inputMap); | |
| 82 | + masterReport = PentahoReportUtil.getCompleteReportDefinition(pathReport, params, dataSource); | |
| 83 | + } catch (MalformedURLException e) { | |
| 84 | + e.printStackTrace(); | |
| 85 | + throw new EsiExecutionException(e); | |
| 86 | + } catch (ResourceException e) { | |
| 87 | + e.printStackTrace(); | |
| 88 | + throw new EsiExecutionException(e); | |
| 89 | + } | |
| 90 | + | |
| 91 | + String outputPath = servletContext.getRealPath(ResourceTypeEnum.REPORT.getPath()+"/"+report.getFileName()); | |
| 92 | + try{ | |
| 93 | + switch (outType) { | |
| 94 | + case HTML: | |
| 95 | + outputPath = outputPath.replaceAll(".prpt", ".html"); | |
| 96 | + HtmlReportUtil.createDirectoryHTML(masterReport, outputPath); | |
| 97 | + break; | |
| 98 | + | |
| 99 | + case PDF: | |
| 100 | + outputPath = outputPath.replaceAll(".prpt", ".pdf"); | |
| 101 | + PdfReportUtil.createPDF(masterReport, outputPath); | |
| 102 | + break; | |
| 103 | + | |
| 104 | + case EXCEL: | |
| 105 | + outputPath = outputPath.replaceAll(".prpt", ".xlsx"); | |
| 106 | + ExcelReportUtil.createXLSX(masterReport, outputPath); | |
| 107 | + break; | |
| 108 | + | |
| 109 | + default: | |
| 110 | + break; | |
| 111 | + } | |
| 112 | + } catch (IOException e) { | |
| 113 | + e.printStackTrace(); | |
| 114 | + throw new EsiExecutionException(e); | |
| 115 | + } catch (ReportProcessingException e) { | |
| 116 | + e.printStackTrace(); | |
| 117 | + throw new EsiExecutionException(e); | |
| 118 | + } | |
| 119 | + | |
| 120 | + try { | |
| 121 | + FileInputStream is = new FileInputStream(outputPath); | |
| 122 | + buffer = new byte[is.available()]; | |
| 123 | + is.read(buffer); | |
| 124 | + is.close(); | |
| 125 | + } catch (Exception e) { | |
| 126 | + e.printStackTrace(); | |
| 127 | + } | |
| 128 | + | |
| 129 | + return buffer; | |
| 130 | + } | |
| 131 | + | |
| 132 | + @Override | |
| 133 | + public void compile(ReportVersion reportVersion) { | |
| 134 | + } | |
| 135 | + | |
| 136 | +} | |
| 0 | 137 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ReportDataSourceServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service.impl; | |
| 2 | + | |
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.resource.dao.ReportDataSourceDao; | |
| 7 | +import br.com.centralit.esi.api.resource.model.ReportDataSource; | |
| 8 | +import br.com.centralit.esi.api.resource.service.ReportDataSourceService; | |
| 9 | +import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; | |
| 10 | + | |
| 11 | +@Service("reportDataSourceService") | |
| 12 | +public class ReportDataSourceServiceImpl extends GenericServiceImpl<ReportDataSource, Long> implements ReportDataSourceService { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * Responsável pela criação de novas instâncias desta classe. | |
| 16 | + * | |
| 17 | + * @param dominioDao | |
| 18 | + * @param validator | |
| 19 | + */ | |
| 20 | + @Autowired | |
| 21 | + public ReportDataSourceServiceImpl( ReportDataSourceDao dao ) { | |
| 22 | + | |
| 23 | + this.dao = dao; | |
| 24 | + } | |
| 25 | +} | |
| 0 | 26 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ReportManagerImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,120 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service.impl; | |
| 2 | + | |
| 3 | +import java.util.HashMap; | |
| 4 | +import java.util.List; | |
| 5 | +import java.util.Map; | |
| 6 | + | |
| 7 | +import javax.servlet.ServletContext; | |
| 8 | + | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import br.com.centralit.esi.api.data.service.DataSourceService; | |
| 13 | +import br.com.centralit.esi.api.data.service.impl.DataManager; | |
| 14 | +import br.com.centralit.esi.api.execution.component.ExecuteScript; | |
| 15 | +import br.com.centralit.esi.api.resource.model.ImageVersion; | |
| 16 | +import br.com.centralit.esi.api.resource.model.ReportParameter; | |
| 17 | +import br.com.centralit.esi.api.resource.model.ReportVersion; | |
| 18 | +import br.com.centralit.esi.api.resource.service.ImageVersionService; | |
| 19 | +import br.com.centralit.esi.api.resource.service.ReportManager; | |
| 20 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironment; | |
| 21 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironmentImpl; | |
| 22 | +import br.com.centralit.esi.api.runtime.RuntimeEnvironmentOutput; | |
| 23 | +import br.com.centralit.esi.api.runtime.service.RuntimeManager; | |
| 24 | + | |
| 25 | +@Component("reportManager") | |
| 26 | +public abstract class ReportManagerImpl implements ReportManager { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * | |
| 30 | + */ | |
| 31 | + private static final long serialVersionUID = 1L; | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + protected DataSourceService dataSourceService; | |
| 35 | + | |
| 36 | + @Autowired | |
| 37 | + protected DataManager dataManager; | |
| 38 | + | |
| 39 | + @Autowired | |
| 40 | + protected RuntimeManager runtimeManager; | |
| 41 | + | |
| 42 | + @Autowired | |
| 43 | + protected ServletContext servletContext; | |
| 44 | + | |
| 45 | + @Autowired | |
| 46 | + protected ImageVersionService imageVersionService; | |
| 47 | + | |
| 48 | + protected abstract Object buildDataSource(ReportVersion report, HashMap<String, Object> inputMap); | |
| 49 | + | |
| 50 | + protected Map<String, Object> buildParams(ReportVersion report, HashMap<String, Object> inputMap) { | |
| 51 | + HashMap<String, Object> outputMap = inputMap; | |
| 52 | + | |
| 53 | + if (report.getParameters() != null) { | |
| 54 | + for (ReportParameter parameter : report.getParameters()) { | |
| 55 | + this.buildParam(parameter, inputMap, outputMap); | |
| 56 | + } | |
| 57 | + } | |
| 58 | + | |
| 59 | + return outputMap; | |
| 60 | + } | |
| 61 | + | |
| 62 | + protected void addMapValue(HashMap<String, Object> map, String name, Object value) { | |
| 63 | + if (map.containsKey(name)) { | |
| 64 | + map.remove(map.get(name)); | |
| 65 | + } | |
| 66 | + | |
| 67 | + map.put(name, value); | |
| 68 | + } | |
| 69 | + | |
| 70 | + protected void buildParam(ReportParameter parameter, HashMap<String, Object> inputMap, HashMap<String, Object> outputMap) { | |
| 71 | + switch (parameter.getType()) { | |
| 72 | + case DATAOBJECT: | |
| 73 | + String SQLName = parameter.getCustomSQL() != null ? parameter.getCustomSQL().getName() : null; | |
| 74 | + List<HashMap<String, Object>> resultSet = dataManager.executeQuery(parameter.getDataObject(), SQLName, inputMap); | |
| 75 | + if (resultSet != null) { | |
| 76 | + for (HashMap<String, Object> map : resultSet) { | |
| 77 | + Object value = map.get(parameter.getOutputAttributeName()); | |
| 78 | + if (value != null) { | |
| 79 | + addMapValue(outputMap, parameter.getName(), value); | |
| 80 | + break; | |
| 81 | + } | |
| 82 | + } | |
| 83 | + } | |
| 84 | + break; | |
| 85 | + | |
| 86 | + case FLOW: | |
| 87 | + RuntimeEnvironmentOutput output = runtimeManager.execute(parameter.getFlow().getName(), inputMap); | |
| 88 | + if (output.getOutputVariables() != null) { | |
| 89 | + Object value = output.getValue(parameter.getOutputAttributeName()); | |
| 90 | + if (value != null) { | |
| 91 | + addMapValue(outputMap, parameter.getName(), value); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + break; | |
| 95 | + | |
| 96 | + case SCRIPT: | |
| 97 | + RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironmentImpl(null, inputMap); | |
| 98 | + Object value = ExecuteScript.execute(runtimeEnvironment, parameter.getName(), parameter.getScriptCode()); | |
| 99 | + if (value != null) { | |
| 100 | + addMapValue(outputMap, parameter.getName(), value); | |
| 101 | + } | |
| 102 | + break; | |
| 103 | + | |
| 104 | + case IMAGE: | |
| 105 | + ImageVersion imageVersion = (ImageVersion) imageVersionService.findByName(parameter.getImage().getName()); | |
| 106 | + | |
| 107 | + String path = servletContext.getRealPath(imageVersion.getFullPath()); | |
| 108 | + addMapValue(outputMap, parameter.getName(), path); | |
| 109 | + break; | |
| 110 | + | |
| 111 | + case CONSTANT: | |
| 112 | + addMapValue(outputMap, parameter.getName(), parameter.getConstant()); | |
| 113 | + break; | |
| 114 | + | |
| 115 | + default: | |
| 116 | + break; | |
| 117 | + } | |
| 118 | + } | |
| 119 | + | |
| 120 | +} | |
| 0 | 121 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ReportParameterServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service.impl; | |
| 2 | + | |
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | + | |
| 6 | +import br.com.centralit.esi.api.resource.dao.ReportParameterDao; | |
| 7 | +import br.com.centralit.esi.api.resource.model.ReportParameter; | |
| 8 | +import br.com.centralit.esi.api.resource.service.ReportParameterService; | |
| 9 | +import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; | |
| 10 | + | |
| 11 | +@Service("reportParameterService") | |
| 12 | +public class ReportParameterServiceImpl extends GenericServiceImpl<ReportParameter, Long> implements ReportParameterService { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * Responsável pela criação de novas instâncias desta classe. | |
| 16 | + * | |
| 17 | + * @param dominioDao | |
| 18 | + * @param validator | |
| 19 | + */ | |
| 20 | + @Autowired | |
| 21 | + public ReportParameterServiceImpl( ReportParameterDao dao ) { | |
| 22 | + | |
| 23 | + this.dao = dao; | |
| 24 | + } | |
| 25 | +} | |
| 0 | 26 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ReportVersionServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,280 @@ |
| 1 | +package br.com.centralit.esi.api.resource.service.impl; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.HashMap; | |
| 5 | +import java.util.List; | |
| 6 | + | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | +import org.springframework.web.multipart.MultipartFile; | |
| 10 | + | |
| 11 | +import br.com.centralit.esi.api.data.service.CustomSQLService; | |
| 12 | +import br.com.centralit.esi.api.data.service.DataObjectService; | |
| 13 | +import br.com.centralit.esi.api.data.service.DataSourceService; | |
| 14 | +import br.com.centralit.esi.api.design.service.FlowService; | |
| 15 | +import br.com.centralit.esi.api.enumerated.ReportEngineEnum; | |
| 16 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 17 | +import br.com.centralit.esi.api.resource.dao.ReportVersionDao; | |
| 18 | +import br.com.centralit.esi.api.resource.model.FormVersion; | |
| 19 | +import br.com.centralit.esi.api.resource.model.ReportDataSource; | |
| 20 | +import br.com.centralit.esi.api.resource.model.ReportParameter; | |
| 21 | +import br.com.centralit.esi.api.resource.model.ReportVersion; | |
| 22 | +import br.com.centralit.esi.api.resource.model.Resource; | |
| 23 | +import br.com.centralit.esi.api.resource.model.ResourceVersion; | |
| 24 | +import br.com.centralit.esi.api.resource.service.FormVersionService; | |
| 25 | +import br.com.centralit.esi.api.resource.service.JasperReportManager; | |
| 26 | +import br.com.centralit.esi.api.resource.service.PentahoReportManager; | |
| 27 | +import br.com.centralit.esi.api.resource.service.ReportDataSourceService; | |
| 28 | +import br.com.centralit.esi.api.resource.service.ReportParameterService; | |
| 29 | +import br.com.centralit.esi.api.resource.service.ReportVersionService; | |
| 30 | +import br.com.centralit.esi.api.resource.service.ResourceService; | |
| 31 | +import br.com.centralit.framework.util.UtilString; | |
| 32 | + | |
| 33 | +@Service("reportVersionService") | |
| 34 | +public class ReportVersionServiceImpl extends ResourceVersionServiceImpl implements ReportVersionService { | |
| 35 | + | |
| 36 | + @Autowired | |
| 37 | + private JasperReportManager jasperReportManager; | |
| 38 | + | |
| 39 | + @Autowired | |
| 40 | + private PentahoReportManager pentahoReportManager; | |
| 41 | + | |
| 42 | + @Autowired | |
| 43 | + private ReportDataSourceService reportDataSourceService; | |
| 44 | + | |
| 45 | + @Autowired | |
| 46 | + private ReportParameterService reportParameterService; | |
| 47 | + | |
| 48 | + @Autowired | |
| 49 | + private FormVersionService formVersionService; | |
| 50 | + | |
| 51 | + @Autowired | |
| 52 | + private DataSourceService dataSourceService; | |
| 53 | + | |
| 54 | + @Autowired | |
| 55 | + private DataObjectService dataObjectService; | |
| 56 | + | |
| 57 | + @Autowired | |
| 58 | + private FlowService flowService; | |
| 59 | + | |
| 60 | + @Autowired | |
| 61 | + private ResourceService resourceService; | |
| 62 | + | |
| 63 | + @Autowired | |
| 64 | + private CustomSQLService customSQLService; | |
| 65 | + | |
| 66 | + @Autowired | |
| 67 | + public ReportVersionServiceImpl(ReportVersionDao reportVersionDao) { | |
| 68 | + super(reportVersionDao); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + protected ResourceVersion create(String name, String description, String path) { | |
| 73 | + return new ReportVersion(name, description, path); | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + protected void deleteRelationships(ResourceVersion resourceVersion) { | |
| 78 | + ReportVersion oldReportVersion = (ReportVersion) this.getReference(resourceVersion.getId()); | |
| 79 | + if (oldReportVersion != null) { | |
| 80 | + reportParameterService.removeList(oldReportVersion.getParameters()); | |
| 81 | + | |
| 82 | + oldReportVersion.setParameters(null); | |
| 83 | + } | |
| 84 | + reportDataSourceService.remove(oldReportVersion.getDataSource()); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 88 | + protected void build(ResourceVersion resourceVersion) { | |
| 89 | + ReportVersion reportVersion = (ReportVersion) resourceVersion; | |
| 90 | + | |
| 91 | + if (!UtilString.isNullOrEmpty(reportVersion.getFileName())) { | |
| 92 | + if (reportVersion.getFileName().toUpperCase().indexOf(".JRXML") > 0) { | |
| 93 | + reportVersion.setEngine(ReportEngineEnum.JASPER); | |
| 94 | + }else{ | |
| 95 | + reportVersion.setEngine(ReportEngineEnum.PENTAHO); | |
| 96 | + } | |
| 97 | + } | |
| 98 | + | |
| 99 | + if (reportVersion.getParameters() != null) { | |
| 100 | + for (ReportParameter parameter : reportVersion.getParameters()) { | |
| 101 | + parameter.setId(null); | |
| 102 | + parameter.setReport(reportVersion); | |
| 103 | + switch (parameter.getType()) { | |
| 104 | + case DATAOBJECT: | |
| 105 | + if (parameter.getDataObject() != null) { | |
| 106 | + parameter.setDataObject(dataObjectService.find(parameter.getDataObject().getId())); | |
| 107 | + } | |
| 108 | + if (parameter.getCustomSQL() != null) { | |
| 109 | + parameter.setCustomSQL(customSQLService.find(parameter.getCustomSQL().getId())); | |
| 110 | + } | |
| 111 | + parameter.setFlow(null); | |
| 112 | + parameter.setImage(null); | |
| 113 | + break; | |
| 114 | + case FLOW: | |
| 115 | + if (parameter.getFlow() != null) { | |
| 116 | + parameter.setFlow(flowService.find(parameter.getFlow().getId())); | |
| 117 | + } | |
| 118 | + parameter.setDataObject(null); | |
| 119 | + parameter.setCustomSQL(null); | |
| 120 | + parameter.setImage(null); | |
| 121 | + break; | |
| 122 | + case IMAGE: | |
| 123 | + parameter.setFlow(null); | |
| 124 | + parameter.setDataObject(null); | |
| 125 | + parameter.setCustomSQL(null); | |
| 126 | + if (parameter.getImage() != null) { | |
| 127 | + parameter.setImage(resourceService.find(parameter.getImage().getId())); | |
| 128 | + } | |
| 129 | + break; | |
| 130 | + default: | |
| 131 | + parameter.setFlow(null); | |
| 132 | + parameter.setDataObject(null); | |
| 133 | + parameter.setCustomSQL(null); | |
| 134 | + parameter.setImage(null); | |
| 135 | + break; | |
| 136 | + } | |
| 137 | + } | |
| 138 | + } | |
| 139 | + | |
| 140 | + if (reportVersion.getDataSource() != null) { | |
| 141 | + ReportDataSource reportDataSource = reportVersion.getDataSource(); | |
| 142 | + reportDataSource.setId(null); | |
| 143 | + if (reportDataSource.getRestoreManyToOne() == null) { | |
| 144 | + reportDataSource.setRestoreManyToOne(false); | |
| 145 | + } | |
| 146 | + if (reportDataSource.getRestoreOneToMany() == null) { | |
| 147 | + reportDataSource.setRestoreOneToMany(false); | |
| 148 | + } | |
| 149 | + | |
| 150 | + switch (reportDataSource.getType()) { | |
| 151 | + case CONNECTION: | |
| 152 | + reportDataSource.setConnection(dataSourceService.find(reportDataSource.getConnection().getId())); | |
| 153 | + reportDataSource.setDataObject(null); | |
| 154 | + reportDataSource.setFlow(null); | |
| 155 | + break; | |
| 156 | + case DATAOBJECT: | |
| 157 | + reportDataSource.setDataObject(dataObjectService.find(reportDataSource.getDataObject().getId())); | |
| 158 | + if (reportDataSource.getCustomSQL() != null) { | |
| 159 | + reportDataSource.setCustomSQL(customSQLService.find(reportDataSource.getCustomSQL().getId())); | |
| 160 | + } | |
| 161 | + reportDataSource.setConnection(null); | |
| 162 | + reportDataSource.setFlow(null); | |
| 163 | + break; | |
| 164 | + case FLOW: | |
| 165 | + reportDataSource.setFlow(flowService.find(reportDataSource.getFlow().getId())); | |
| 166 | + reportDataSource.setDataObject(null); | |
| 167 | + reportDataSource.setConnection(null); | |
| 168 | + break; | |
| 169 | + default: | |
| 170 | + reportDataSource.setConnection(null); | |
| 171 | + reportDataSource.setFlow(null); | |
| 172 | + reportDataSource.setDataObject(null); | |
| 173 | + reportDataSource.setCustomSQL(null); | |
| 174 | + break; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + FormVersion formVersion = reportVersion.getFormVersion(); | |
| 179 | + if (formVersion != null) { | |
| 180 | + formVersion.setPath(reportVersion.getPath()); | |
| 181 | + formVersion.setGenerateDefaultPage(true); | |
| 182 | + if (formVersion.isNew()) { | |
| 183 | + formVersion = (FormVersion) formVersionService.save(reportVersion.getFormVersion()); | |
| 184 | + }else{ | |
| 185 | + formVersion = (FormVersion) formVersionService.merge(reportVersion.getFormVersion()); | |
| 186 | + } | |
| 187 | + reportVersion.setForm(formVersion.getResource()); | |
| 188 | + } | |
| 189 | + } | |
| 190 | + | |
| 191 | + @Override | |
| 192 | + protected ResourceVersion clone(ResourceVersion resourceVersion) { | |
| 193 | + ReportVersion oldResourceVersion = (ReportVersion) resourceVersion; | |
| 194 | + | |
| 195 | + ReportVersion newResourceVersion = new ReportVersion(); | |
| 196 | + newResourceVersion.setEngine(oldResourceVersion.getEngine()); | |
| 197 | + newResourceVersion.setForm(oldResourceVersion.getForm()); | |
| 198 | + newResourceVersion.setFormVersion(oldResourceVersion.getFormVersion()); | |
| 199 | + | |
| 200 | + if (oldResourceVersion.getDataSource() != null) { | |
| 201 | + newResourceVersion.setDataSource(new ReportDataSource(oldResourceVersion.getDataSource())); | |
| 202 | + } | |
| 203 | + | |
| 204 | + if (oldResourceVersion.getParameters() != null) { | |
| 205 | + List<ReportParameter> parameters = new ArrayList<ReportParameter>(); | |
| 206 | + | |
| 207 | + for (ReportParameter param : oldResourceVersion.getParameters()) { | |
| 208 | + ReportParameter newParam = new ReportParameter(newResourceVersion, param); | |
| 209 | + parameters.add(newParam); | |
| 210 | + } | |
| 211 | + | |
| 212 | + newResourceVersion.setParameters(parameters); | |
| 213 | + } | |
| 214 | + | |
| 215 | + return newResourceVersion; | |
| 216 | + } | |
| 217 | + | |
| 218 | + | |
| 219 | + @Override | |
| 220 | + protected String getPath() { | |
| 221 | + return this.getType().getPath(); | |
| 222 | + } | |
| 223 | + | |
| 224 | + @Override | |
| 225 | + public ResourceTypeEnum getType() { | |
| 226 | + return ResourceTypeEnum.REPORT; | |
| 227 | + } | |
| 228 | + | |
| 229 | + @Override | |
| 230 | + public byte[] execute(Resource report, HashMap<String, Object> parameters) { | |
| 231 | + ReportVersion reportVersion = (ReportVersion) this.findByName(report.getName()); | |
| 232 | + | |
| 233 | + if (reportVersion.getEngine().equals(ReportEngineEnum.JASPER)) { | |
| 234 | + return jasperReportManager.execute(reportVersion, parameters); | |
| 235 | + }else if (reportVersion.getEngine().equals(ReportEngineEnum.PENTAHO)) { | |
| 236 | + return pentahoReportManager.execute(reportVersion, parameters); | |
| 237 | + }else{ | |
| 238 | + return null; | |
| 239 | + } | |
| 240 | + } | |
| 241 | + | |
| 242 | + @Override | |
| 243 | + public ResourceVersion save(Long id, String name, String description, String path, MultipartFile file, Boolean replace) { | |
| 244 | + ReportVersion reportVersion = (ReportVersion) super.save(id, name, description, path, file, replace); | |
| 245 | + this.compile(reportVersion); | |
| 246 | + return reportVersion; | |
| 247 | + } | |
| 248 | + | |
| 249 | + @Override | |
| 250 | + public ResourceVersion merge(ResourceVersion resourceVersion) { | |
| 251 | + if (resourceVersion.getFile() == null) { | |
| 252 | + ResourceVersion oldResource = this.find(resourceVersion.getId()); | |
| 253 | + resourceVersion.setFile(oldResource.getFile()); | |
| 254 | + } | |
| 255 | + return super.merge(resourceVersion); | |
| 256 | + } | |
| 257 | + | |
| 258 | + private void compile(ReportVersion reportVersion) { | |
| 259 | + if (reportVersion != null && reportVersion.getFile() != null) { | |
| 260 | + if (reportVersion.getEngine().equals(ReportEngineEnum.JASPER)) { | |
| 261 | + jasperReportManager.compile(reportVersion); | |
| 262 | + }else if (reportVersion.getEngine().equals(ReportEngineEnum.PENTAHO)) { | |
| 263 | + pentahoReportManager.compile(reportVersion); | |
| 264 | + } | |
| 265 | + } | |
| 266 | + } | |
| 267 | + | |
| 268 | + @Override | |
| 269 | + public void uploadAll() { | |
| 270 | + List<ResourceVersion> resources = this.findAll(); | |
| 271 | + if (resources != null) { | |
| 272 | + for (ResourceVersion resourceVersion : resources) { | |
| 273 | + upload(resourceVersion); | |
| 274 | + } | |
| 275 | + for (ResourceVersion resourceVersion : resources) { | |
| 276 | + compile((ReportVersion) resourceVersion); | |
| 277 | + } | |
| 278 | + } | |
| 279 | + } | |
| 280 | +} | |
| 0 | 281 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ResourceServiceImpl.java
| ... | ... | @@ -5,6 +5,7 @@ import java.util.List; |
| 5 | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | 6 | import org.springframework.stereotype.Service; |
| 7 | 7 | |
| 8 | +import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; | |
| 8 | 9 | import br.com.centralit.esi.api.resource.dao.ResourceDao; |
| 9 | 10 | import br.com.centralit.esi.api.resource.model.Resource; |
| 10 | 11 | import br.com.centralit.esi.api.resource.service.ResourceService; |
| ... | ... | @@ -52,5 +53,20 @@ public class ResourceServiceImpl extends GenericServiceImpl<Resource, Long> impl |
| 52 | 53 | Resource auxResource = super.getReference(resource.getId()); |
| 53 | 54 | auxResource.setDataBloqueio(resource.getDataBloqueio() == null ? UtilDate.getDataAtualCalendar() : resource.getDataBloqueio()); |
| 54 | 55 | return super.merge(auxResource); |
| 56 | + } | |
| 57 | + | |
| 58 | + @Override | |
| 59 | + public Resource findByNameAndType(String name, ResourceTypeEnum type) { | |
| 60 | + Resource result = null; | |
| 61 | + | |
| 62 | + List<Resource> lista = this.resourceDao.listByName(name); | |
| 63 | + if (lista != null) { | |
| 64 | + for (Resource resource : lista) { | |
| 65 | + if (resource.getType().equals(type)) { | |
| 66 | + result = resource; | |
| 67 | + } | |
| 68 | + } | |
| 69 | + } | |
| 70 | + return result; | |
| 55 | 71 | } |
| 56 | 72 | } |
| 57 | 73 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ResourceVersionServiceImpl.java
| ... | ... | @@ -42,7 +42,7 @@ public class ResourceVersionServiceImpl extends GenericServiceImpl<ResourceVersi |
| 42 | 42 | protected DefaultFileService defaultFileService; |
| 43 | 43 | |
| 44 | 44 | protected Resource findResource(ResourceVersion resourceVersion) { |
| 45 | - return resourceService.findByName(resourceVersion.getResource().getName()); | |
| 45 | + return resourceService.findByNameAndType(resourceVersion.getResource().getName(), resourceVersion.getResource().getType()); | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | protected String getPath() { |
| ... | ... | @@ -66,8 +66,11 @@ public class ResourceVersionServiceImpl extends GenericServiceImpl<ResourceVersi |
| 66 | 66 | @Override |
| 67 | 67 | public ResourceVersion save(ResourceVersion resourceVersion) { |
| 68 | 68 | Resource resource = this.findResource(resourceVersion); |
| 69 | - if (resource != null) | |
| 70 | - throw new EsiBusinessException("Já existe um recurso '"+resourceVersion.getResource().getName()+"' cadastrado no sistema"); | |
| 69 | + if (resource != null) { | |
| 70 | + if (resourceVersion.getResource() != null && !resourceVersion.getResource().isNew() && !resourceVersion.getResource().getId().equals(resource.getId())) { | |
| 71 | + throw new EsiBusinessException("Já existe um recurso '"+resourceVersion.getResource().getName()+"' cadastrado no sistema"); | |
| 72 | + } | |
| 73 | + } | |
| 71 | 74 | |
| 72 | 75 | this.validate(resourceVersion); |
| 73 | 76 | |
| ... | ... | @@ -152,8 +155,6 @@ public class ResourceVersionServiceImpl extends GenericServiceImpl<ResourceVersi |
| 152 | 155 | if (path.charAt(path.length() - 1) == '/') { |
| 153 | 156 | path = path.substring(0,path.length() - 1); |
| 154 | 157 | } |
| 155 | - }else{ | |
| 156 | - | |
| 157 | 158 | } |
| 158 | 159 | resourceVersion.setPath(path); |
| 159 | 160 | |
| ... | ... | @@ -294,7 +295,7 @@ public class ResourceVersionServiceImpl extends GenericServiceImpl<ResourceVersi |
| 294 | 295 | return file; |
| 295 | 296 | } |
| 296 | 297 | |
| 297 | - private void loadFile(ResourceVersion resourceVersion, MultipartFile file) { | |
| 298 | + protected void loadFile(ResourceVersion resourceVersion, MultipartFile file) { | |
| 298 | 299 | try { |
| 299 | 300 | resourceVersion.setFile(file.getBytes()); |
| 300 | 301 | resourceVersion.setFileName(file.getOriginalFilename()); |
| ... | ... | @@ -328,15 +329,15 @@ public class ResourceVersionServiceImpl extends GenericServiceImpl<ResourceVersi |
| 328 | 329 | |
| 329 | 330 | this.save(resourceVersion); |
| 330 | 331 | }else{ |
| 331 | - ResourceVersion resourceVersionAux = (ResourceVersion) this.getReference(id); | |
| 332 | - if (resourceVersionAux == null) { | |
| 332 | + resourceVersion = (ResourceVersion) this.getReference(id); | |
| 333 | + if (resourceVersion == null) { | |
| 333 | 334 | throw new EsiBusinessException("Arquivo não encontrado"); |
| 334 | 335 | } |
| 335 | 336 | |
| 336 | - resourceVersion = this.create(name, description, path); | |
| 337 | + resourceVersion.getResource().setName(name); | |
| 338 | + resourceVersion.getResource().setDescription(description); | |
| 339 | + resourceVersion.setPath(path); | |
| 337 | 340 | this.loadFile(resourceVersion, file); |
| 338 | - resourceVersion.setId(id); | |
| 339 | - resourceVersion.getResource().setId(resourceVersionAux.getResource().getId()); | |
| 340 | 341 | this.merge(resourceVersion); |
| 341 | 342 | } |
| 342 | 343 | ... | ... |