Commit c1821579ccf36551de564c48141ae11abdcac74b
1 parent
b1888b30
Exists in
master
Implementação dos recursos de relatório
Showing
11 changed files
with
206 additions
and
66 deletions
Show diff stats
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/enumerated/ReportDataSourceEnum.java
0 → 100644
... | ... | @@ -0,0 +1,32 @@ |
1 | +package br.com.centralit.esi.api.enumerated; | |
2 | + | |
3 | +public enum ReportDataSourceEnum { | |
4 | + DATAOBJECT("ESI.ENUMERADO.DATASOURCE_OBJETO_DADOS"), | |
5 | + FLOW("ESI.ENUMERADO.DATASOURCE_FLUXO_ESI"), | |
6 | + VARIABLE("ESI.ENUMERADO.DATASOURCE_VARIAVEL"); | |
7 | + | |
8 | + private String id; | |
9 | + private String description; | |
10 | + | |
11 | + private ReportDataSourceEnum(String description) { | |
12 | + this.id = name(); | |
13 | + this.description = description; | |
14 | + } | |
15 | + | |
16 | + public static ReportDataSourceEnum parse(String value) { | |
17 | + for (ReportDataSourceEnum item : ReportDataSourceEnum.values()) { | |
18 | + if (item.id.equals(value)) { | |
19 | + return item; | |
20 | + } | |
21 | + } | |
22 | + return null; | |
23 | + } | |
24 | + | |
25 | + public String getId() { | |
26 | + return this.id; | |
27 | + } | |
28 | + | |
29 | + public String getDescription() { | |
30 | + return description; | |
31 | + } | |
32 | +}; | |
0 | 33 | \ 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/ReportParameterEnum.java
0 → 100644
... | ... | @@ -0,0 +1,33 @@ |
1 | +package br.com.centralit.esi.api.enumerated; | |
2 | + | |
3 | +public enum ReportParameterEnum { | |
4 | + DATAOBJECT("ESI.ENUMERADO.DATASOURCE_OBJETO_DADOS"), | |
5 | + FLOW("ESI.ENUMERADO.DATASOURCE_FLUXO_ESI"), | |
6 | + VARIABLE("ESI.ENUMERADO.DATASOURCE_VARIAVEL"), | |
7 | + IMAGE("ESI.ENUMERADO.DATASOURCE_IMAGEM"); | |
8 | + | |
9 | + private String id; | |
10 | + private String description; | |
11 | + | |
12 | + private ReportParameterEnum(String description) { | |
13 | + this.id = name(); | |
14 | + this.description = description; | |
15 | + } | |
16 | + | |
17 | + public static ReportParameterEnum parse(String value) { | |
18 | + for (ReportParameterEnum item : ReportParameterEnum.values()) { | |
19 | + if (item.id.equals(value)) { | |
20 | + return item; | |
21 | + } | |
22 | + } | |
23 | + return null; | |
24 | + } | |
25 | + | |
26 | + public String getId() { | |
27 | + return this.id; | |
28 | + } | |
29 | + | |
30 | + public String getDescription() { | |
31 | + return description; | |
32 | + } | |
33 | +}; | |
0 | 34 | \ No newline at end of file | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/ReportTypeEnum.java
... | ... | @@ -1,32 +0,0 @@ |
1 | -package br.com.centralit.esi.api.enumerated; | |
2 | - | |
3 | -public enum ReportTypeEnum { | |
4 | - BUSINESS_PROCESS("ESI.ENUMERADO.APLICACAO_FLUXO_PROCESSOS"), | |
5 | - SERVICE_INTEGRATION("ESI.ENUMERADO.APLICACAO_FLUXO_SERVICOS"), | |
6 | - BUSINESS_RULE("ESI.ENUMERADO.APLICACAO_FLUXO_REGRA"); | |
7 | - | |
8 | - private String id; | |
9 | - private String description; | |
10 | - | |
11 | - private ReportTypeEnum(String description) { | |
12 | - this.id = name(); | |
13 | - this.description = description; | |
14 | - } | |
15 | - | |
16 | - public static ReportTypeEnum parse(String value) { | |
17 | - for (ReportTypeEnum item : ReportTypeEnum.values()) { | |
18 | - if (item.id.equals(value)) { | |
19 | - return item; | |
20 | - } | |
21 | - } | |
22 | - return null; | |
23 | - } | |
24 | - | |
25 | - public String getId() { | |
26 | - return this.id; | |
27 | - } | |
28 | - | |
29 | - public String getDescription() { | |
30 | - return description; | |
31 | - } | |
32 | -}; | |
33 | 0 | \ No newline at end of file |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ReportDataSource.java
... | ... | @@ -14,7 +14,7 @@ import javax.persistence.Table; |
14 | 14 | |
15 | 15 | import br.com.centralit.esi.api.data.model.DataObject; |
16 | 16 | import br.com.centralit.esi.api.design.model.Flow; |
17 | -import br.com.centralit.esi.api.domain.model.Domain; | |
17 | +import br.com.centralit.esi.api.enumerated.ReportDataSourceEnum; | |
18 | 18 | import br.com.centralit.framework.json.Views; |
19 | 19 | import br.com.centralit.framework.model.arquitetura.PersistentObject; |
20 | 20 | |
... | ... | @@ -34,9 +34,9 @@ public class ReportDataSource extends PersistentObject { |
34 | 34 | @JsonView({Views.GenericView.class }) |
35 | 35 | protected Long id; |
36 | 36 | |
37 | - @ManyToOne(fetch = FetchType.LAZY, optional = false) | |
37 | + @Column(nullable = false) | |
38 | 38 | @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) |
39 | - private Domain type; | |
39 | + private ReportDataSourceEnum type; | |
40 | 40 | |
41 | 41 | @ManyToOne(fetch=FetchType.LAZY, optional=true) |
42 | 42 | @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) |
... | ... | @@ -64,8 +64,12 @@ public class ReportDataSource extends PersistentObject { |
64 | 64 | // TODO Auto-generated constructor stub |
65 | 65 | } |
66 | 66 | |
67 | - public ReportDataSource() { | |
68 | - // TODO Auto-generated constructor stub | |
67 | + public ReportDataSource(ReportDataSource reportDataSource) { | |
68 | + this.type = reportDataSource.type; | |
69 | + this.dataObject = reportDataSource.dataObject; | |
70 | + this.flow = reportDataSource.flow; | |
71 | + this.expression = reportDataSource.expression; | |
72 | + this.outputAttributeName = reportDataSource.outputAttributeName; | |
69 | 73 | } |
70 | 74 | |
71 | 75 | @Override |
... | ... | @@ -73,11 +77,12 @@ public class ReportDataSource extends PersistentObject { |
73 | 77 | return this.id; |
74 | 78 | } |
75 | 79 | |
76 | - public Domain getType() { | |
80 | + | |
81 | + public ReportDataSourceEnum getType() { | |
77 | 82 | return type; |
78 | 83 | } |
79 | 84 | |
80 | - public void setType(Domain type) { | |
85 | + public void setType(ReportDataSourceEnum type) { | |
81 | 86 | this.type = type; |
82 | 87 | } |
83 | 88 | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ReportParameter.java
... | ... | @@ -14,7 +14,7 @@ import javax.persistence.Table; |
14 | 14 | |
15 | 15 | import br.com.centralit.esi.api.data.model.DataObject; |
16 | 16 | import br.com.centralit.esi.api.design.model.Flow; |
17 | -import br.com.centralit.esi.api.domain.model.Domain; | |
17 | +import br.com.centralit.esi.api.enumerated.ReportParameterEnum; | |
18 | 18 | import br.com.centralit.framework.json.Views; |
19 | 19 | import br.com.centralit.framework.model.arquitetura.PersistentObject; |
20 | 20 | |
... | ... | @@ -35,9 +35,9 @@ public class ReportParameter extends PersistentObject { |
35 | 35 | @JsonView({Views.GenericView.class }) |
36 | 36 | protected Long id; |
37 | 37 | |
38 | - @ManyToOne(fetch = FetchType.LAZY, optional = false) | |
38 | + @Column(nullable = false) | |
39 | 39 | @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) |
40 | - private Domain type; | |
40 | + private ReportParameterEnum type; | |
41 | 41 | |
42 | 42 | @ManyToOne(fetch=FetchType.LAZY, optional=true) |
43 | 43 | @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) |
... | ... | @@ -73,6 +73,21 @@ public class ReportParameter extends PersistentObject { |
73 | 73 | @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) |
74 | 74 | private String name; |
75 | 75 | |
76 | + public ReportParameter() { | |
77 | + | |
78 | + } | |
79 | + | |
80 | + public ReportParameter(ReportVersion report, ReportParameter reportParameter) { | |
81 | + this.name = reportParameter.name; | |
82 | + this.report = report; | |
83 | + this.type = reportParameter.type; | |
84 | + this.dataObject = reportParameter.dataObject; | |
85 | + this.flow = reportParameter.flow; | |
86 | + this.image = reportParameter.image; | |
87 | + this.expression = reportParameter.expression; | |
88 | + this.outputAttributeName = reportParameter.outputAttributeName; | |
89 | + } | |
90 | + | |
76 | 91 | public ReportVersion getReport() { |
77 | 92 | return report; |
78 | 93 | } |
... | ... | @@ -94,11 +109,11 @@ public class ReportParameter extends PersistentObject { |
94 | 109 | return this.id; |
95 | 110 | } |
96 | 111 | |
97 | - public Domain getType() { | |
112 | + public ReportParameterEnum getType() { | |
98 | 113 | return type; |
99 | 114 | } |
100 | 115 | |
101 | - public void setType(Domain type) { | |
116 | + public void setType(ReportParameterEnum type) { | |
102 | 117 | this.type = type; |
103 | 118 | } |
104 | 119 | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ReportVersion.java
... | ... | @@ -11,6 +11,7 @@ import javax.persistence.OneToMany; |
11 | 11 | import javax.persistence.PrimaryKeyJoinColumn; |
12 | 12 | import javax.persistence.Table; |
13 | 13 | |
14 | +import br.com.centralit.esi.api.enumerated.ReportEngineEnum; | |
14 | 15 | import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; |
15 | 16 | import br.com.centralit.framework.json.Views; |
16 | 17 | import br.com.centralit.framework.model.Menu; |
... | ... | @@ -28,6 +29,10 @@ public class ReportVersion extends ResourceVersion { |
28 | 29 | */ |
29 | 30 | private static final long serialVersionUID = -1095473041588484440L; |
30 | 31 | |
32 | + @Column(nullable = false) | |
33 | + @JsonView({ Views.GenericView.class}) | |
34 | + private ReportEngineEnum engine; | |
35 | + | |
31 | 36 | @ManyToOne(fetch=FetchType.LAZY, optional=true) |
32 | 37 | @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class}) |
33 | 38 | private Menu menu; |
... | ... | @@ -83,5 +88,13 @@ public class ReportVersion extends ResourceVersion { |
83 | 88 | public void setMenuName(String menuName) { |
84 | 89 | this.menuName = menuName; |
85 | 90 | } |
91 | + | |
92 | + public ReportEngineEnum getEngine() { | |
93 | + return engine; | |
94 | + } | |
95 | + | |
96 | + public void setEngine(ReportEngineEnum engine) { | |
97 | + this.engine = engine; | |
98 | + } | |
86 | 99 | |
87 | 100 | } | ... | ... |
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ReportVersionServiceImpl.java
1 | 1 | package br.com.centralit.esi.api.resource.service.impl; |
2 | 2 | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
3 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
4 | 7 | import org.springframework.stereotype.Service; |
5 | 8 | |
9 | +import br.com.centralit.api.service.MenuService; | |
10 | +import br.com.centralit.esi.api.enumerated.ReportEngineEnum; | |
6 | 11 | import br.com.centralit.esi.api.enumerated.ResourceTypeEnum; |
7 | 12 | import br.com.centralit.esi.api.resource.dao.ReportVersionDao; |
8 | -import br.com.centralit.esi.api.resource.model.FormPage; | |
13 | +import br.com.centralit.esi.api.resource.model.ReportDataSource; | |
14 | +import br.com.centralit.esi.api.resource.model.ReportParameter; | |
9 | 15 | import br.com.centralit.esi.api.resource.model.ReportVersion; |
10 | 16 | import br.com.centralit.esi.api.resource.model.Resource; |
11 | 17 | import br.com.centralit.esi.api.resource.model.ResourceVersion; |
... | ... | @@ -28,6 +34,9 @@ public class ReportVersionServiceImpl extends ResourceVersionServiceImpl impleme |
28 | 34 | |
29 | 35 | @Autowired |
30 | 36 | private ReportParameterService reportParameterService; |
37 | + | |
38 | + @Autowired | |
39 | + private MenuService menuService; | |
31 | 40 | |
32 | 41 | @Autowired |
33 | 42 | public ReportVersionServiceImpl(ReportVersionDao reportVersionDao) { |
... | ... | @@ -49,7 +58,27 @@ public class ReportVersionServiceImpl extends ResourceVersionServiceImpl impleme |
49 | 58 | } |
50 | 59 | } |
51 | 60 | |
52 | - | |
61 | + @Override | |
62 | + protected void build(ResourceVersion resourceVersion) { | |
63 | + ReportVersion reportVersion = (ReportVersion) resourceVersion; | |
64 | + | |
65 | + if (reportVersion.getParameters() != null) { | |
66 | + for (ReportParameter parameter : reportVersion.getParameters()) { | |
67 | + parameter.setId(null); | |
68 | + parameter.setReport(reportVersion); | |
69 | + } | |
70 | + } | |
71 | + | |
72 | + if (reportVersion.getDataSource() != null) { | |
73 | + reportVersion.getDataSource().setId(null); | |
74 | + } | |
75 | + | |
76 | + if (reportVersion.getMenu() != null) { | |
77 | + reportVersion.setMenu(menuService.getReference(reportVersion.getMenu().getId())); | |
78 | + } | |
79 | + | |
80 | + } | |
81 | + | |
53 | 82 | @Override |
54 | 83 | protected ResourceVersion clone(ResourceVersion resourceVersion) { |
55 | 84 | ReportVersion oldResourceVersion = (ReportVersion) resourceVersion; |
... | ... | @@ -61,13 +90,18 @@ public class ReportVersionServiceImpl extends ResourceVersionServiceImpl impleme |
61 | 90 | |
62 | 91 | newResourceVersion.setMenu(oldResourceVersion.getMenu()); |
63 | 92 | newResourceVersion.setMenuName(oldResourceVersion.getMenuName()); |
64 | - newResourceVersion.setMenuName(oldResourceVersion.getMenuName()); | |
65 | - | |
93 | + newResourceVersion.setDataSource(new ReportDataSource(oldResourceVersion.getDataSource())); | |
66 | 94 | |
67 | - this.cloneTabs(oldResourceVersion, newResourceVersion); | |
68 | - this.cloneRows(oldResourceVersion, newResourceVersion); | |
69 | - this.cloneActions(oldResourceVersion, newResourceVersion); | |
70 | - this.cloneFiles(oldResourceVersion, newResourceVersion); | |
95 | + if (oldResourceVersion.getParameters() != null) { | |
96 | + List<ReportParameter> parameters = new ArrayList<ReportParameter>(); | |
97 | + | |
98 | + for (ReportParameter param : oldResourceVersion.getParameters()) { | |
99 | + ReportParameter newParam = new ReportParameter(newResourceVersion, param); | |
100 | + parameters.add(newParam); | |
101 | + } | |
102 | + | |
103 | + newResourceVersion.setParameters(parameters); | |
104 | + } | |
71 | 105 | |
72 | 106 | return newResourceVersion; |
73 | 107 | } |
... | ... | @@ -87,7 +121,11 @@ public class ReportVersionServiceImpl extends ResourceVersionServiceImpl impleme |
87 | 121 | public void execute(Resource report) { |
88 | 122 | ReportVersion reportVersion = (ReportVersion) this.findByName(report.getName()); |
89 | 123 | |
90 | - reportManager.execute(reportVersion); | |
124 | + if (reportVersion.getEngine().equals(ReportEngineEnum.JASPER)) { | |
125 | + jasperReportManager.execute(reportVersion); | |
126 | + }else if (reportVersion.getEngine().equals(ReportEngineEnum.PENTAHO)) { | |
127 | + pentahoReportManager.execute(reportVersion); | |
128 | + } | |
91 | 129 | } |
92 | 130 | |
93 | 131 | } |
94 | 132 | \ No newline at end of file | ... | ... |
cit-esi-web/src/main/java/br/com/centralit/listener/StartupListenerEsi.java
... | ... | @@ -276,15 +276,6 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen |
276 | 276 | |
277 | 277 | list.add(new Dominio("dataObjectType", "Tabela", "TABLE", 1L)); |
278 | 278 | list.add(new Dominio("dataObjectType", "View", "VIEW", 2L)); |
279 | - | |
280 | - list.add(new Dominio("reportDataSourceType", "ESI.DOMINIO.OBJETO_DADOS", "DATAOBJECT", 1L)); | |
281 | - list.add(new Dominio("reportDataSourceType", "ESI.DOMINIO.FLUXO_ESI", "FLOW", 2L)); | |
282 | - list.add(new Dominio("reportParameterType", "ESI.DOMINIO.VARIAVEL", "VARIABLE", 3L)); | |
283 | - | |
284 | - list.add(new Dominio("reportParameterType", "ESI.DOMINIO.OBJETO_DADOS", "DATAOBJECT", 1L)); | |
285 | - list.add(new Dominio("reportParameterType", "ESI.DOMINIO.FLUXO_ESI", "FLOW", 2L)); | |
286 | - list.add(new Dominio("reportParameterType", "ESI.DOMINIO.VARIAVEL", "VARIABLE", 3L)); | |
287 | - list.add(new Dominio("reportParameterType", "ESI.DOMINIO.IMAGEM", "IMAGE", 4L)); | |
288 | 279 | |
289 | 280 | this.dominioService.saveListIfNotExist(list); |
290 | 281 | |
... | ... | @@ -2130,10 +2121,10 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen |
2130 | 2121 | internacionalizacaoList.add(new Internacionalizacao("ESI.TAREFA", "Tarefa", dominio, modulo)); |
2131 | 2122 | internacionalizacaoList.add(new Internacionalizacao("ESI.ATUALIZADO", "atualizado", dominio, modulo)); |
2132 | 2123 | |
2133 | - internacionalizacaoList.add(new Internacionalizacao("ESI.DOMINIO.OBJETO_DADOS", "Objeto de dados", dominio, modulo)); | |
2134 | - internacionalizacaoList.add(new Internacionalizacao("ESI.DOMINIO.FLUXO_ESI", "Fluxo ESI", dominio, modulo)); | |
2135 | - internacionalizacaoList.add(new Internacionalizacao("ESI.DOMINIO.VARIAVEL", "Variável", dominio, modulo)); | |
2136 | - internacionalizacaoList.add(new Internacionalizacao("ESI.DOMINIO.IMAGEM", "Imagem", dominio, modulo)); | |
2124 | + internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_OBJETO_DADOS", "Objeto de dados", dominio, modulo)); | |
2125 | + internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_FLUXO_ESI", "Fluxo ESI", dominio, modulo)); | |
2126 | + internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_VARIAVEL", "Variável", dominio, modulo)); | |
2127 | + internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_IMAGEM", "Imagem", dominio, modulo)); | |
2137 | 2128 | |
2138 | 2129 | internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.TIPO_ENGINE_REGRA_DROOLS", "Drools", dominio, modulo)); |
2139 | 2130 | internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.TIPO_ESTIMATIVA_TEMPO", "Tempo", dominio, modulo)); | ... | ... |