Commit a7852aced5f82d4e4da101c663b6ef3cf886b8ef

Authored by Carlos Alberto
1 parent a1745259
Exists in master

Implementação dos recursos de relatório para pentaho

Showing 18 changed files with 349 additions and 313 deletions   Show diff stats
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/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/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&lt;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&lt;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&lt;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/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&lt;Replace&gt; 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/resource/service/impl/PentahoReportManagerImpl.java
... ... @@ -23,7 +23,7 @@ import br.com.centralit.esi.api.resource.model.ReportDataSource;
23 23 import br.com.centralit.esi.api.resource.model.ReportVersion;
24 24 import br.com.centralit.esi.api.resource.service.PentahoReportManager;
25 25 import br.com.centralit.esi.api.util.DefaultConvertUtils;
26   -import br.com.centralit.esi.api.util.PentahooReportUtil;
  26 +import br.com.centralit.esi.api.util.PentahoReportUtil;
27 27 import br.com.centralit.esi.exception.EsiExecutionException;
28 28  
29 29 @Component("pentahoReportManager")
... ... @@ -67,7 +67,7 @@ public class PentahoReportManagerImpl extends ReportManagerImpl implements Penta
67 67 public byte[] execute(ReportVersion report, HashMap<String, Object> inputMap) {
68 68 byte[] buffer = null;
69 69  
70   - String path = ResourceTypeEnum.REPORT.getPath();
  70 + String path = report.buildBasePath();
71 71  
72 72 String pathReport = servletContext.getRealPath(path+"/"+report.getFileName());
73 73  
... ... @@ -76,11 +76,10 @@ public class PentahoReportManagerImpl extends ReportManagerImpl implements Penta
76 76 ReportFormatTypeEnum outType = ReportFormatTypeEnum.PDF;
77 77  
78 78 DefaultConvertUtils.registerDefaultConverts();
79   - PentahooReportUtil pentahooReportUtil = new PentahooReportUtil();
80 79 MasterReport masterReport = null;
81 80 try {
82 81 SQLReportDataFactory dataSource = this.buildDataSource(report, inputMap);
83   - masterReport = pentahooReportUtil.getCompleteReportDefinition(pathReport, params, dataSource);
  82 + masterReport = PentahoReportUtil.getCompleteReportDefinition(pathReport, params, dataSource);
84 83 } catch (MalformedURLException e) {
85 84 e.printStackTrace();
86 85 throw new EsiExecutionException(e);
... ... @@ -89,21 +88,21 @@ public class PentahoReportManagerImpl extends ReportManagerImpl implements Penta
89 88 throw new EsiExecutionException(e);
90 89 }
91 90  
92   - String outputPath = "";
  91 + String outputPath = servletContext.getRealPath(ResourceTypeEnum.REPORT.getPath()+"/"+report.getFileName());
93 92 try{
94 93 switch (outType) {
95 94 case HTML:
96   - outputPath = pathReport.replaceAll(".prpt", ".html");
  95 + outputPath = outputPath.replaceAll(".prpt", ".html");
97 96 HtmlReportUtil.createDirectoryHTML(masterReport, outputPath);
98 97 break;
99 98  
100 99 case PDF:
101   - outputPath = pathReport.replaceAll(".prpt", ".pdf");
  100 + outputPath = outputPath.replaceAll(".prpt", ".pdf");
102 101 PdfReportUtil.createPDF(masterReport, outputPath);
103 102 break;
104 103  
105 104 case EXCEL:
106   - outputPath = pathReport.replaceAll(".prpt", ".xlsx");
  105 + outputPath = outputPath.replaceAll(".prpt", ".xlsx");
107 106 ExcelReportUtil.createXLSX(masterReport, outputPath);
108 107 break;
109 108  
... ... @@ -118,9 +117,8 @@ public class PentahoReportManagerImpl extends ReportManagerImpl implements Penta
118 117 throw new EsiExecutionException(e);
119 118 }
120 119  
121   - String fullPath = servletContext.getRealPath(outputPath);
122 120 try {
123   - FileInputStream is = new FileInputStream(fullPath);
  121 + FileInputStream is = new FileInputStream(outputPath);
124 122 buffer = new byte[is.available()];
125 123 is.read(buffer);
126 124 is.close();
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/util/PentahoReportUtil.java 0 → 100644
... ... @@ -0,0 +1,68 @@
  1 +package br.com.centralit.esi.api.util;
  2 +
  3 +import java.io.File;
  4 +import java.net.MalformedURLException;
  5 +import java.net.URI;
  6 +import java.net.URL;
  7 +import java.util.Map;
  8 +
  9 +import org.pentaho.reporting.engine.classic.core.ClassicEngineBoot;
  10 +import org.pentaho.reporting.engine.classic.core.DataFactory;
  11 +import org.pentaho.reporting.engine.classic.core.MasterReport;
  12 +import org.pentaho.reporting.libraries.resourceloader.Resource;
  13 +import org.pentaho.reporting.libraries.resourceloader.ResourceException;
  14 +import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
  15 +
  16 +public class PentahoReportUtil {
  17 + /**
  18 + * Performs the basic initialization required to generate a report
  19 + */
  20 + private PentahoReportUtil() {
  21 + ClassicEngineBoot.getInstance().start();
  22 + }
  23 +
  24 + public static MasterReport getCompleteReportDefinition(String pathReport, Map<String, Object> parameters, DataFactory dataFactory) throws MalformedURLException, ResourceException {
  25 + MasterReport report = getReportDefinition(pathReport);
  26 + // Add any parameters to the report
  27 + Map<String, Object> reportParameters = null;
  28 + if (parameters != null){
  29 + reportParameters = parameters;
  30 + }
  31 + if (null != reportParameters) {
  32 + for (String key : reportParameters.keySet()) {
  33 + report.getParameterValues().put(key, reportParameters.get(key));
  34 + }
  35 + }
  36 + if (dataFactory != null) {
  37 + report.setDataFactory(dataFactory);
  38 + }
  39 + // Return the completed report
  40 + return report;
  41 + }
  42 +
  43 + /**
  44 + * Returns the report definition which will be used to generate the report.
  45 + * In this case, the report will be loaded and parsed from a file contained
  46 + * in this package.
  47 + *
  48 + * @return the loaded and parsed report definition to be used in report
  49 + * generation.
  50 + * @throws MalformedURLException
  51 + * @throws ResourceException
  52 + */
  53 + private static MasterReport getReportDefinition(String pathReport) throws MalformedURLException, ResourceException {
  54 + // Using the classloader, get the URL to the reportDefinition file
  55 + // NOTE: We will re-use the report definition from SAMPLE1
  56 + //final ClassLoader classloader = this.getClass().getClassLoader();
  57 + //URL reportDefinitionURL = classloader.getResource("org/pentaho/reporting/engine/classic/samples/Sample1.prpt");
  58 + File f = new File(pathReport);
  59 + URI uri = f.toURI();
  60 + URL reportDefinitionURL = uri.toURL();
  61 + // Parse the report file
  62 + final ResourceManager resourceManager = new ResourceManager();
  63 + resourceManager.registerDefaults();
  64 + final Resource directly = resourceManager.createDirectly(reportDefinitionURL, MasterReport.class);
  65 + return (MasterReport) directly.getResource();
  66 + }
  67 +
  68 +}
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/util/PentahooReportUtil.java
... ... @@ -1,69 +0,0 @@
1   -package br.com.centralit.esi.api.util;
2   -
3   -import java.io.File;
4   -import java.net.MalformedURLException;
5   -import java.net.URI;
6   -import java.net.URL;
7   -import java.util.Map;
8   -
9   -import org.pentaho.reporting.engine.classic.core.ClassicEngineBoot;
10   -import org.pentaho.reporting.engine.classic.core.DataFactory;
11   -import org.pentaho.reporting.engine.classic.core.MasterReport;
12   -import org.pentaho.reporting.libraries.resourceloader.Resource;
13   -import org.pentaho.reporting.libraries.resourceloader.ResourceException;
14   -import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
15   -
16   -public class PentahooReportUtil {
17   - /**
18   - * Performs the basic initialization required to generate a report
19   - */
20   - public PentahooReportUtil() {
21   - // Initialize the reporting engine
22   - ClassicEngineBoot.getInstance().start();
23   - }
24   -
25   - public MasterReport getCompleteReportDefinition(String pathReport, Map<String, Object> parameters, DataFactory dataFactory) throws MalformedURLException, ResourceException {
26   - MasterReport report = getReportDefinition(pathReport);
27   - // Add any parameters to the report
28   - Map<String, Object> reportParameters = null;
29   - if (parameters != null){
30   - reportParameters = parameters;
31   - }
32   - if (null != reportParameters) {
33   - for (String key : reportParameters.keySet()) {
34   - report.getParameterValues().put(key, reportParameters.get(key));
35   - }
36   - }
37   - if (dataFactory != null) {
38   - report.setDataFactory(dataFactory);
39   - }
40   - // Return the completed report
41   - return report;
42   - }
43   -
44   - /**
45   - * Returns the report definition which will be used to generate the report.
46   - * In this case, the report will be loaded and parsed from a file contained
47   - * in this package.
48   - *
49   - * @return the loaded and parsed report definition to be used in report
50   - * generation.
51   - * @throws MalformedURLException
52   - * @throws ResourceException
53   - */
54   - private MasterReport getReportDefinition(String pathReport) throws MalformedURLException, ResourceException {
55   - // Using the classloader, get the URL to the reportDefinition file
56   - // NOTE: We will re-use the report definition from SAMPLE1
57   - //final ClassLoader classloader = this.getClass().getClassLoader();
58   - //URL reportDefinitionURL = classloader.getResource("org/pentaho/reporting/engine/classic/samples/Sample1.prpt");
59   - File f = new File(pathReport);
60   - URI uri = f.toURI();
61   - URL reportDefinitionURL = uri.toURL();
62   - // Parse the report file
63   - final ResourceManager resourceManager = new ResourceManager();
64   - resourceManager.registerDefaults();
65   - final Resource directly = resourceManager.createDirectly(reportDefinitionURL, MasterReport.class);
66   - return (MasterReport) directly.getResource();
67   - }
68   -
69   -}
cit-esi-web/src/main/resources/spring/applicationContext.xml
... ... @@ -40,6 +40,7 @@
40 40 <import resource="classpath*:spring/applicationContext-base.xml" />
41 41  
42 42 <bean id="esiAppUtils" class="br.com.centralit.esi.api.util.EsiAppUtils"/>
  43 + <bean id="PentahoReportUtil" class="br.com.centralit.esi.api.util.PentahoReportUtil"/>
43 44 <bean id="runtimeContext" class="br.com.centralit.esi.api.runtime.RuntimeContext"/>
44 45  
45 46 <context:component-scan base-package="br.com.centralit.listener" />
... ...