Commit 35cf4af1dd686093edad1ce07cee959ed1b2fa0d

Authored by carlos.alberto
1 parent 563c503d
Exists in master

Implementação dos recursos de relatório

cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/ReportDataSourceEnum.java
... ... @@ -4,7 +4,7 @@ public enum ReportDataSourceEnum {
4 4 CONNECTION("ESI.ENUMERADO.DATASOURCE_CONEXAO"),
5 5 DATAOBJECT("ESI.ENUMERADO.DATASOURCE_OBJETO_DADOS"),
6 6 FLOW("ESI.ENUMERADO.DATASOURCE_FLUXO_ESI"),
7   - EXPRESSION("ESI.ENUMERADO.DATASOURCE_EXPRESSAO");
  7 + SCRIPT("ESI.ENUMERADO.DATASOURCE_SCRIPT");
8 8  
9 9 private String id;
10 10 private String description;
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/enumerated/ReportParameterEnum.java
... ... @@ -1,33 +0,0 @@
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   - EXPRESSION("ESI.ENUMERADO.DATASOURCE_EXPRESSAO"),
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   -};
34 0 \ 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,33 @@
  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 +
  9 + private String id;
  10 + private String description;
  11 +
  12 + private ReportParameterTypeEnum(String description) {
  13 + this.id = name();
  14 + this.description = description;
  15 + }
  16 +
  17 + public static ReportParameterTypeEnum parse(String value) {
  18 + for (ReportParameterTypeEnum item : ReportParameterTypeEnum.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/resource/model/ReportDataSource.java
1 1 package br.com.centralit.esi.api.resource.model;
2 2  
3   -import javax.persistence.AttributeOverride;
4   -import javax.persistence.AttributeOverrides;
5 3 import javax.persistence.Column;
6 4 import javax.persistence.Embedded;
7 5 import javax.persistence.Entity;
... ... @@ -16,6 +14,7 @@ import br.com.centralit.esi.api.data.model.CustomSQL;
16 14 import br.com.centralit.esi.api.data.model.DataObject;
17 15 import br.com.centralit.esi.api.data.model.DataSource;
18 16 import br.com.centralit.esi.api.design.model.Flow;
  17 +import br.com.centralit.esi.api.design.model.ScriptCode;
19 18 import br.com.centralit.esi.api.enumerated.ReportDataSourceEnum;
20 19 import br.com.centralit.framework.json.Views;
21 20 import br.com.centralit.framework.model.arquitetura.PersistentObject;
... ... @@ -56,20 +55,9 @@ public class ReportDataSource extends PersistentObject {
56 55 @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
57 56 private Flow flow;
58 57  
59   - @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
60 58 @Embedded
61   - @AttributeOverrides({
62   - @AttributeOverride(name="expressionType", column = @Column(name="expression_type")),
63   - @AttributeOverride(name="constant", column = @Column(name="expression_constant")),
64   - @AttributeOverride(name="scriptCode.script", column = @Column(name="expression_script")),
65   - @AttributeOverride(name="scriptCode.engineType", column = @Column(name="expression_engineType")),
66   - @AttributeOverride(name="variable.name", column = @Column(name="variable_name")),
67   - @AttributeOverride(name="variable.description", column = @Column(name="variable_description")),
68   - @AttributeOverride(name="variable.variableType", column = @Column(name="variable_variableType")),
69   - @AttributeOverride(name="variable.className", column = @Column(name="variable_className")),
70   - @AttributeOverride(name="variable.multiple", column = @Column(name="variable_multiple"))
71   - })
72   - private ReportExpression expression;
  59 + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
  60 + private ScriptCode scriptCode;
73 61  
74 62 @Column(nullable = true)
75 63 @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
... ... @@ -83,7 +71,7 @@ public class ReportDataSource extends PersistentObject {
83 71 this.type = reportDataSource.type;
84 72 this.dataObject = reportDataSource.dataObject;
85 73 this.flow = reportDataSource.flow;
86   - this.expression = reportDataSource.expression;
  74 + this.scriptCode = reportDataSource.scriptCode;
87 75 this.outputAttributeName = reportDataSource.outputAttributeName;
88 76 }
89 77  
... ... @@ -128,13 +116,13 @@ public class ReportDataSource extends PersistentObject {
128 116 public void setId(Long id) {
129 117 this.id = id;
130 118 }
131   -
132   - public ReportExpression getExpression() {
133   - return expression;
  119 +
  120 + public ScriptCode getScriptCode() {
  121 + return scriptCode;
134 122 }
135 123  
136   - public void setExpression(ReportExpression expression) {
137   - this.expression = expression;
  124 + public void setScriptCode(ScriptCode scriptCode) {
  125 + this.scriptCode = scriptCode;
138 126 }
139 127  
140 128 public DataSource getConnection() {
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ReportExpression.java
... ... @@ -1,102 +0,0 @@
1   -package br.com.centralit.esi.api.resource.model;
2   -
3   -import java.io.Serializable;
4   -
5   -import javax.persistence.Basic;
6   -import javax.persistence.Embeddable;
7   -import javax.persistence.Embedded;
8   -import javax.persistence.FetchType;
9   -import javax.persistence.Lob;
10   -
11   -import org.hibernate.annotations.Type;
12   -
13   -import br.com.centralit.esi.api.design.model.ScriptCode;
14   -import br.com.centralit.esi.api.design.model.Variable;
15   -import br.com.centralit.esi.api.enumerated.ExpressionTypeEnum;
16   -import br.com.centralit.framework.json.Views;
17   -
18   -import com.fasterxml.jackson.annotation.JsonView;
19   -
20   -@Embeddable
21   -public class ReportExpression implements Serializable {
22   -
23   - /**
24   - *
25   - */
26   - private static final long serialVersionUID = 1795388490044351994L;
27   -
28   - @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
29   - private ExpressionTypeEnum expressionType;
30   -
31   - @Embedded
32   - @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
33   - private Variable variable;
34   -
35   - @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
36   - @Lob
37   - @Basic(fetch = FetchType.LAZY)
38   - @Type(type="org.hibernate.type.StringClobType")
39   - private String constantValue;
40   -
41   - @Embedded
42   - @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
43   - private ScriptCode scriptCode;
44   -
45   - /**
46   - * @return the expressionType
47   - */
48   - public ExpressionTypeEnum getExpressionType() {
49   - return expressionType;
50   - }
51   -
52   - /**
53   - * @param expressionType the expressionType to set
54   - */
55   - public void setExpressionType(ExpressionTypeEnum expressionType) {
56   - this.expressionType = expressionType;
57   - }
58   -
59   - /**
60   - * @return the constantValue
61   - */
62   - public String getConstantValue() {
63   - return constantValue;
64   - }
65   -
66   - /**
67   - * @param constantValue the constantValue to set
68   - */
69   - public void setConstantValue(String constantValue) {
70   - this.constantValue = constantValue;
71   - }
72   -
73   - /**
74   - * @return the scriptCode
75   - */
76   - public ScriptCode getScriptCode() {
77   - return scriptCode;
78   - }
79   -
80   - /**
81   - * @param scriptCode the scriptCode to set
82   - */
83   - public void setScriptCode(ScriptCode scriptCode) {
84   - this.scriptCode = scriptCode;
85   - }
86   -
87   - /**
88   - * @return the serialversionuid
89   - */
90   - public static long getSerialversionuid() {
91   - return serialVersionUID;
92   - }
93   -
94   - public Variable getVariable() {
95   - return variable;
96   - }
97   -
98   - public void setVariable(Variable variable) {
99   - this.variable = variable;
100   - }
101   -
102   -}
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/ReportParameter.java
1 1 package br.com.centralit.esi.api.resource.model;
2 2  
3   -import javax.persistence.AttributeOverride;
4   -import javax.persistence.AttributeOverrides;
5 3 import javax.persistence.Column;
6 4 import javax.persistence.Embedded;
7 5 import javax.persistence.Entity;
... ... @@ -15,7 +13,8 @@ import javax.persistence.Table;
15 13 import br.com.centralit.esi.api.data.model.CustomSQL;
16 14 import br.com.centralit.esi.api.data.model.DataObject;
17 15 import br.com.centralit.esi.api.design.model.Flow;
18   -import br.com.centralit.esi.api.enumerated.ReportParameterEnum;
  16 +import br.com.centralit.esi.api.design.model.ScriptCode;
  17 +import br.com.centralit.esi.api.enumerated.ReportParameterTypeEnum;
19 18 import br.com.centralit.framework.json.Views;
20 19 import br.com.centralit.framework.model.arquitetura.PersistentObject;
21 20  
... ... @@ -38,7 +37,7 @@ public class ReportParameter extends PersistentObject {
38 37  
39 38 @Column(nullable = false)
40 39 @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
41   - private ReportParameterEnum type;
  40 + private ReportParameterTypeEnum type;
42 41  
43 42 @ManyToOne(fetch=FetchType.LAZY, optional=true)
44 43 @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
... ... @@ -56,20 +55,9 @@ public class ReportParameter extends PersistentObject {
56 55 @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
57 56 private Resource image;
58 57  
59   - @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
60 58 @Embedded
61   - @AttributeOverrides({
62   - @AttributeOverride(name="expressionType", column = @Column(name="expression_type")),
63   - @AttributeOverride(name="constant", column = @Column(name="expression_constant")),
64   - @AttributeOverride(name="scriptCode.script", column = @Column(name="expression_script")),
65   - @AttributeOverride(name="scriptCode.engineType", column = @Column(name="expression_engineType")),
66   - @AttributeOverride(name="variable.name", column = @Column(name="variable_name")),
67   - @AttributeOverride(name="variable.description", column = @Column(name="variable_description")),
68   - @AttributeOverride(name="variable.variableType", column = @Column(name="variable_variableType")),
69   - @AttributeOverride(name="variable.className", column = @Column(name="variable_className")),
70   - @AttributeOverride(name="variable.multiple", column = @Column(name="variable_multiple"))
71   - })
72   - private ReportExpression expression;
  59 + @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
  60 + private ScriptCode scriptCode;
73 61  
74 62 @Column(nullable = true)
75 63 @JsonView({ Views.EsiResourceEditView.class, Views.EsiPackageExportView.class})
... ... @@ -94,7 +82,7 @@ public class ReportParameter extends PersistentObject {
94 82 this.dataObject = reportParameter.dataObject;
95 83 this.flow = reportParameter.flow;
96 84 this.image = reportParameter.image;
97   - this.expression = reportParameter.expression;
  85 + this.scriptCode = reportParameter.scriptCode;
98 86 this.outputAttributeName = reportParameter.outputAttributeName;
99 87 }
100 88  
... ... @@ -119,11 +107,11 @@ public class ReportParameter extends PersistentObject {
119 107 return this.id;
120 108 }
121 109  
122   - public ReportParameterEnum getType() {
  110 + public ReportParameterTypeEnum getType() {
123 111 return type;
124 112 }
125 113  
126   - public void setType(ReportParameterEnum type) {
  114 + public void setType(ReportParameterTypeEnum type) {
127 115 this.type = type;
128 116 }
129 117  
... ... @@ -150,13 +138,13 @@ public class ReportParameter extends PersistentObject {
150 138 public void setImage(Resource image) {
151 139 this.image = image;
152 140 }
153   -
154   - public ReportExpression getExpression() {
155   - return expression;
  141 +
  142 + public ScriptCode getScriptCode() {
  143 + return scriptCode;
156 144 }
157 145  
158   - public void setExpression(ReportExpression expression) {
159   - this.expression = expression;
  146 + public void setScriptCode(ScriptCode scriptCode) {
  147 + this.scriptCode = scriptCode;
160 148 }
161 149  
162 150 public String getOutputAttributeName() {
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/JasperReportManagerImpl.java
... ... @@ -14,16 +14,13 @@ import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
14 14  
15 15 import org.springframework.stereotype.Component;
16 16  
17   -import br.com.centralit.esi.api.enumerated.ExpressionTypeEnum;
18 17 import br.com.centralit.esi.api.execution.component.ExecuteScript;
19 18 import br.com.centralit.esi.api.resource.model.ReportDataSource;
20   -import br.com.centralit.esi.api.resource.model.ReportExpression;
21 19 import br.com.centralit.esi.api.resource.model.ReportVersion;
22 20 import br.com.centralit.esi.api.resource.service.JasperReportManager;
23 21 import br.com.centralit.esi.api.runtime.RuntimeEnvironment;
24 22 import br.com.centralit.esi.api.runtime.RuntimeEnvironmentImpl;
25 23 import br.com.centralit.esi.api.runtime.RuntimeEnvironmentOutput;
26   -import br.com.centralit.esi.api.util.ConvertUtilsESI;
27 24 import br.com.centralit.esi.exception.EsiExecutionException;
28 25  
29 26 @Component("jasperReportManager")
... ... @@ -58,7 +55,7 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper
58 55  
59 56 default:
60 57 try {
61   - print = JasperFillManager.fillReport(report.getFileName(), this.buildParams(report, inputMap), this.buildDataSource(report.getDataSource(), inputMap));
  58 + print = JasperFillManager.fillReport(report.getFileName(), this.buildParams(report, inputMap), this.buildDataSource(report, inputMap));
62 59 } catch (JRException e) {
63 60 throw new EsiExecutionException(e);
64 61 }
... ... @@ -79,7 +76,8 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper
79 76 }
80 77  
81 78 @Override
82   - protected JRDataSource buildDataSource(ReportDataSource reportDataSource, HashMap<String, Object> inputMap) {
  79 + protected JRDataSource buildDataSource(ReportVersion report, HashMap<String, Object> inputMap) {
  80 + ReportDataSource reportDataSource = report.getDataSource();
83 81 JRDataSource dataSource = null;
84 82  
85 83 switch (reportDataSource.getType()) {
... ... @@ -99,16 +97,10 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper
99 97 }
100 98 break;
101 99  
102   - case EXPRESSION:
103   - ReportExpression expression = reportDataSource.getExpression();
104   - if (expression.getExpressionType().equals(ExpressionTypeEnum.CONSTANT) && expression.getConstantValue() != null) {
105   - Object object = ConvertUtilsESI.convertVariable(expression.getVariable().getVariableType(), false, expression.getVariable().getClassName(), expression.getConstantValue());
106   - dataSource = new JRBeanArrayDataSource(new Object[]{object});
107   - }else if (expression.getExpressionType().equals(ExpressionTypeEnum.SCRIPT) && expression.getScriptCode() != null) {
108   - RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironmentImpl(null, inputMap);
109   - Object object = ExecuteScript.execute(runtimeEnvironment, expression.getVariable().getName(), expression.getScriptCode());
110   - dataSource = new JRBeanArrayDataSource(new Object[]{object});
111   - }
  100 + case SCRIPT:
  101 + RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironmentImpl(null, inputMap);
  102 + Object object = ExecuteScript.execute(runtimeEnvironment, report.getResource().getName(), reportDataSource.getScriptCode());
  103 + dataSource = new JRBeanArrayDataSource(new Object[]{object});
112 104 break;
113 105  
114 106 default:
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/PentahoReportManagerImpl.java
... ... @@ -4,7 +4,6 @@ import java.util.HashMap;
4 4  
5 5 import org.springframework.stereotype.Component;
6 6  
7   -import br.com.centralit.esi.api.resource.model.ReportDataSource;
8 7 import br.com.centralit.esi.api.resource.model.ReportVersion;
9 8 import br.com.centralit.esi.api.resource.service.PentahoReportManager;
10 9  
... ... @@ -17,7 +16,7 @@ public class PentahoReportManagerImpl extends ReportManagerImpl implements Penta
17 16 private static final long serialVersionUID = 1L;
18 17  
19 18 @Override
20   - protected Object buildDataSource(ReportDataSource reportDataSource, HashMap<String, Object> parameters) {
  19 + protected Object buildDataSource(ReportVersion report, HashMap<String, Object> parameters) {
21 20 // TODO Auto-generated method stub
22 21 return null;
23 22 }
... ...
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/ReportManagerImpl.java
... ... @@ -9,10 +9,7 @@ import org.springframework.stereotype.Component;
9 9  
10 10 import br.com.centralit.esi.api.data.service.DataSourceService;
11 11 import br.com.centralit.esi.api.data.service.impl.DataManager;
12   -import br.com.centralit.esi.api.enumerated.ExpressionTypeEnum;
13 12 import br.com.centralit.esi.api.execution.component.ExecuteScript;
14   -import br.com.centralit.esi.api.resource.model.ReportDataSource;
15   -import br.com.centralit.esi.api.resource.model.ReportExpression;
16 13 import br.com.centralit.esi.api.resource.model.ReportParameter;
17 14 import br.com.centralit.esi.api.resource.model.ReportVersion;
18 15 import br.com.centralit.esi.api.resource.service.ReportManager;
... ... @@ -20,7 +17,6 @@ import br.com.centralit.esi.api.runtime.RuntimeEnvironment;
20 17 import br.com.centralit.esi.api.runtime.RuntimeEnvironmentImpl;
21 18 import br.com.centralit.esi.api.runtime.RuntimeEnvironmentOutput;
22 19 import br.com.centralit.esi.api.runtime.service.RuntimeManager;
23   -import br.com.centralit.esi.api.util.ConvertUtilsESI;
24 20  
25 21 @Component("reportManager")
26 22 public abstract class ReportManagerImpl implements ReportManager {
... ... @@ -39,7 +35,7 @@ public abstract class ReportManagerImpl implements ReportManager {
39 35 @Autowired
40 36 protected RuntimeManager runtimeManager;
41 37  
42   - protected abstract Object buildDataSource(ReportDataSource reportDataSource, HashMap<String, Object> inputMap);
  38 + protected abstract Object buildDataSource(ReportVersion report, HashMap<String, Object> inputMap);
43 39  
44 40 protected Map<String, Object> buildParams(ReportVersion report, HashMap<String, Object> inputMap) {
45 41 HashMap<String, Object> outputMap = new HashMap<String, Object>();
... ... @@ -79,19 +75,11 @@ public abstract class ReportManagerImpl implements ReportManager {
79 75 }
80 76 break;
81 77  
82   - case EXPRESSION:
83   - ReportExpression expression = parameter.getExpression();
84   - if (expression.getExpressionType().equals(ExpressionTypeEnum.CONSTANT) && expression.getConstantValue() != null) {
85   - Object value = ConvertUtilsESI.convertVariable(expression.getVariable().getVariableType(), false, expression.getVariable().getClassName(), expression.getConstantValue());
86   - if (value != null) {
87   - outputMap.put(expression.getVariable().getName(), value);
88   - }
89   - }else if (expression.getExpressionType().equals(ExpressionTypeEnum.SCRIPT) && expression.getScriptCode() != null) {
90   - RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironmentImpl(null, inputMap);
91   - Object value = ExecuteScript.execute(runtimeEnvironment, expression.getVariable().getName(), expression.getScriptCode());
92   - if (value != null) {
93   - outputMap.put(expression.getVariable().getName(), value);
94   - }
  78 + case SCRIPT:
  79 + RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironmentImpl(null, inputMap);
  80 + Object value = ExecuteScript.execute(runtimeEnvironment, parameter.getName(), parameter.getScriptCode());
  81 + if (value != null) {
  82 + outputMap.put(parameter.getName(), value);
95 83 }
96 84 break;
97 85  
... ...
cit-esi-web/src/main/java/br/com/centralit/listener/StartupListenerEsi.java
... ... @@ -1865,6 +1865,7 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen
1865 1865 internacionalizacaoList.add(new Internacionalizacao("ESI.IMPORTAR", "Importar", dominio, modulo));
1866 1866 internacionalizacaoList.add(new Internacionalizacao("ESI.PROCESSOS_NEGOCIO", "Processos de negócio", dominio, modulo));
1867 1867 internacionalizacaoList.add(new Internacionalizacao("ESI.PARAMETROS", "Parâmetros", dominio, modulo));
  1868 + internacionalizacaoList.add(new Internacionalizacao("ESI.PARAMETRO", "Parâmetro", dominio, modulo));
1868 1869 internacionalizacaoList.add(new Internacionalizacao("ESI.VALOR_INICIAL", "Valor inicial", dominio, modulo));
1869 1870 internacionalizacaoList.add(new Internacionalizacao("ESI.VARIAVEL_FLUXO", "Variável", dominio, modulo));
1870 1871 internacionalizacaoList.add(new Internacionalizacao("ESI.REGRA_NEGOCIO", "Regra de negócio", dominio, modulo));
... ... @@ -2171,7 +2172,7 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen
2171 2172 internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_CONEXAO", "Conexão de dados", dominio, modulo));
2172 2173 internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_OBJETO_DADOS", "Objeto de dados", dominio, modulo));
2173 2174 internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_FLUXO_ESI", "Fluxo ESI", dominio, modulo));
2174   - internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_EXPRESSAO", "Expressão", dominio, modulo));
  2175 + internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_SCRIPT", "Script", dominio, modulo));
2175 2176 internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.DATASOURCE_IMAGEM", "Imagem", dominio, modulo));
2176 2177  
2177 2178 internacionalizacaoList.add(new Internacionalizacao("ESI.ENUMERADO.TIPO_ENGINE_REGRA_DROOLS", "Drools", dominio, modulo));
... ...
cit-esi-web/src/main/webapp/assets/js/angular/custom/controller/ReportController.js
... ... @@ -36,6 +36,10 @@ citApp.controller(&#39;ReportController&#39;, [&quot;$scope&quot;, &quot;appService&quot;, &quot;ReportRepository
36 36 $scope.reportDataSourceList = result;
37 37 });
38 38  
  39 + DomainRepository.getEnumeratedDomain('ReportParameterTypeEnum').then(function(result) {
  40 + $scope.parameterTypeList = result;
  41 + });
  42 +
39 43 DomainRepository.getEnumeratedDomain('ExpressionTypeEnum').then(function(result) {
40 44 $scope.expressionTypeList = [];
41 45 for (var i = 0; i < result.length; i++) {
... ... @@ -84,6 +88,16 @@ citApp.controller(&#39;ReportController&#39;, [&quot;$scope&quot;, &quot;appService&quot;, &quot;ReportRepository
84 88 }
85 89 };
86 90  
  91 + $scope.clearParameterDataSource = function() {
  92 + $scope.parameter.connection = null;
  93 + };
  94 +
  95 + $scope.setParameterDataSource = function (item) {
  96 + if(item && item.id) {
  97 + $scope.parameter.connection = item;
  98 + }
  99 + };
  100 +
87 101 $scope.findDataObject = function(value) {
88 102 var dataObjectVH = {
89 103 nome : value
... ... @@ -103,6 +117,16 @@ citApp.controller(&#39;ReportController&#39;, [&quot;$scope&quot;, &quot;appService&quot;, &quot;ReportRepository
103 117 }
104 118 };
105 119  
  120 + $scope.clearParameterDataObject = function() {
  121 + $scope.parameter.report = null;
  122 + };
  123 +
  124 + $scope.setParameterDataObject = function (item) {
  125 + if(item && item.id) {
  126 + $scope.parameter.report = item;
  127 + }
  128 + };
  129 +
106 130 $scope.findFlow = function(value) {
107 131 var flowVH = {
108 132 nome : value
... ... @@ -131,6 +155,16 @@ citApp.controller(&#39;ReportController&#39;, [&quot;$scope&quot;, &quot;appService&quot;, &quot;ReportRepository
131 155 }
132 156 };
133 157  
  158 + $scope.clearParameterFlow = function() {
  159 + $scope.parameter.flow = null;
  160 + };
  161 +
  162 + $scope.setParameterFlow = function (item) {
  163 + if(item && item.id) {
  164 + $scope.parameter.flow = item;
  165 + }
  166 + };
  167 +
134 168 $scope.showComponents = function(){
135 169 if (!$scope.canShowComponents()) {
136 170 return ;
... ... @@ -191,6 +225,7 @@ citApp.controller(&#39;ReportController&#39;, [&quot;$scope&quot;, &quot;appService&quot;, &quot;ReportRepository
191 225 // Limpa formulário para novo cadastro
192 226 $scope.resetForm = function() {
193 227 $scope.limparReport();
  228 + $scope.clearParameter();
194 229 $scope.edit = true;
195 230 $timeout(function(){
196 231 $scope.reportForm.$submitted = false;
... ... @@ -224,9 +259,57 @@ citApp.controller(&#39;ReportController&#39;, [&quot;$scope&quot;, &quot;appService&quot;, &quot;ReportRepository
224 259 });
225 260 };
226 261  
  262 + $scope.isValidProperties = function(formVersion) {
  263 + var mensagens = '';
  264 + var msg = '';
  265 +
  266 + var result = true;
  267 +
  268 + angular.forEach(formVersion.rows, function(row){
  269 + angular.forEach(row.components, function(component){
  270 + angular.forEach(component.widget.properties, function(widgetProperty){
  271 + if (widgetProperty.property.required && (!component[widgetProperty.property.name] || component[widgetProperty.property.name] == '')) {
  272 + msg = $translate.instant('ESI.PROPRIEDADE_FORM_NAO_PREENCHIDA');
  273 + msg = msg.replace("#property#", $translate.instant(widgetProperty.property.name));
  274 + msg = msg.replace("#component#", $translate.instant(component.widget.description));
  275 + mensagens += msg + '<br><br>';
  276 +
  277 + result = false;
  278 + }
  279 + });
  280 + });
  281 + });
  282 +
  283 + if (!result) {
  284 + var template = '<div class="widget-header"><div class="widget-toolbar"><a href="javascript:;" ng-click="closeModal();"><i class="fa fa-times"></i></a></div></div>'+
  285 + '<br><div class="alert alert-danger">'+
  286 + ' <strong>'+$translate.instant('ESI.ATUALIZACAO_NAO_PERMITIDA')+'!<br>'+
  287 + ' </strong>'+mensagens+
  288 + '</div>';
  289 +
  290 + $scope.$modalInstance = $modal.open({
  291 + template: template,
  292 + size: 'lg',
  293 + scope: $scope
  294 + });
  295 + }
  296 + return result;
  297 + };
  298 +
  299 + $scope.setValues = function(formVersion) {
  300 + angular.forEach(formVersion.rows, function(row){
  301 + angular.forEach(row.components, function(component){
  302 + angular.forEach(component.widget.properties, function(widgetProperty){
  303 + FormContainerHelper.setValue(component, widgetProperty);
  304 + delete component[widgetProperty.property.name];
  305 + });
  306 + });
  307 + });
  308 + };
  309 +
227 310 $scope.saveOrUpdate = function(oldVersion){
228 311 $scope.reportForm.$submitted = true;
229   -
  312 +
230 313 //verifica se o formulario esta valido para salvar
231 314 if($scope.reportForm.$valid){
232 315  
... ... @@ -235,33 +318,60 @@ citApp.controller(&#39;ReportController&#39;, [&quot;$scope&quot;, &quot;appService&quot;, &quot;ReportRepository
235 318 return;
236 319 }
237 320  
238   - if (oldVersion == undefined) {
239   - oldVersion = $scope.report.id > 0;
240   - }
241   -
242   - $scope.setLoadingSalva(true);
243   -
244   - $scope.uploader.url = '/cit-esi-web/rest/esi/resource/report/upload?';
245   - $scope.uploader.url += 'name=' + $scope.report.resource.name;
246   - $scope.uploader.url += '&description=' + $scope.report.resource.description;
247   - $scope.uploader.url += '&path=' + $scope.report.path;
248   -
249   - if (oldVersion) {
250   - $scope.uploader.url += '&replace=true';
251   - }
252   -
253   - if ($scope.report.id) {
254   - $scope.uploader.url += '&id=' + $scope.report.id;
255   - }
256   -
257   - $scope.uploader.queue[0].url = $scope.uploader.url;
258   - $scope.uploader.uploadAll();
  321 + if ($scope.isValidProperties($scope.report.formVersion)) {
  322 + $scope.removeComponentWorkspace();
  323 +
  324 + if (oldVersion == undefined) {
  325 + oldVersion = $scope.report.id > 0;
  326 + }
  327 +
  328 + $scope.setValues($scope.report.formVersion);
  329 +
  330 + $scope.setLoadingSalva(true);
  331 + $scope.report.className = className;
  332 +
  333 + var menu = undefined;
  334 + if ($scope.report.formVersion.menu && $scope.report.formVersion.menu.id) {
  335 + menu = {id: $scope.report.formVersion.menu.id};
  336 + }
  337 + $scope.report.formVersion.menu = menu;
  338 +
  339 + if (oldVersion) {
  340 + ReportRepository.replace($scope.report).then(function(result) {
  341 + $scope.report = result.originalElement;
  342 + $scope.uploadFile();
  343 + });
  344 + }else{
  345 + FormBuilderRepository.save($scope.report).then(function(result) {
  346 + $scope.report = result.originalElement;
  347 + $scope.uploadFile();
  348 + });
  349 + }
  350 + }
259 351 }else{
260 352 //Mensagem de erro de campos obrigatorios não preenchidos
261 353 $scope.showAlert('error', $translate.instant('VALIDACAO.ALERTA_OBRIGATORIOS'), " ", false);
262 354 }
263 355 };
264 356  
  357 + $scope.uploadFile = function() {
  358 + $scope.uploader.url = '/cit-esi-web/rest/esi/resource/report/upload?';
  359 + $scope.uploader.url += 'name=' + $scope.report.resource.name;
  360 + $scope.uploader.url += '&description=' + $scope.report.resource.description;
  361 + $scope.uploader.url += '&path=' + $scope.report.path;
  362 +
  363 + if (oldVersion) {
  364 + $scope.uploader.url += '&replace=true';
  365 + }
  366 +
  367 + if ($scope.report.id) {
  368 + $scope.uploader.url += '&id=' + $scope.report.id;
  369 + }
  370 +
  371 + $scope.uploader.queue[0].url = $scope.uploader.url;
  372 + $scope.uploader.uploadAll();
  373 + };
  374 +
265 375 // Limpa o formulario preenchido
266 376 $scope.limparReport = function(){
267 377 $scope.report = {resource: {type: "REPORT"}, className: className, majorVersion: 1, minorVersion: 0
... ... @@ -400,4 +510,64 @@ citApp.controller(&#39;ReportController&#39;, [&quot;$scope&quot;, &quot;appService&quot;, &quot;ReportRepository
400 510 scope: this
401 511 });
402 512 };
  513 +
  514 + $scope.getParameterType = function(parameter) {
  515 + return DomainRepository.getEnumDescription(parameter['type'], $scope.parameterTypeList);
  516 + };
  517 +
  518 + $scope.checkParameter = function(index, parameter) {
  519 + parameter.$index = index;
  520 + $scope.parameterChecked = parameter;
  521 + };
  522 +
  523 + $scope.clearParameter = function(){
  524 + $scope.parameter = {};
  525 + $scope.parameterChecked = undefined;
  526 + };
  527 +
  528 + $scope.newParameter = function(){
  529 + $scope.indexParameter = -1;
  530 + $scope.clearParameter();
  531 + $scope.openParameter();
  532 + };
  533 +
  534 + $scope.editParameter = function(){
  535 + $scope.parameter = $scope.parameterChecked;
  536 + $scope.indexParameter = $scope.parameterChecked.$index;
  537 + $scope.openParameter();
  538 + };
  539 +
  540 + $scope.removeParameter = function(){
  541 + if(!$scope.parameterChecked) {
  542 + $scope.showAlert('warning', $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_SER_REMOVIDO'));
  543 + return;
  544 + } else {
  545 + $scope.$openModalConfirm({
  546 + message: $translate.instant('MSG.CONFIRMA_EXCLUSAO'),
  547 + callback: function () {
  548 + $scope.$modalConfirmInstance.dismiss('cancel');
  549 + $scope.report.parameters.splice($scope.parameterChecked.$index, 1);
  550 + }
  551 + });
  552 + }
  553 + };
  554 +
  555 + $scope.openParameter = function(){
  556 + $scope.$openModal('/cit-esi-web/html/report/dialogReportParameter.html', 'lg');
  557 + };
  558 +
  559 + $scope.saveParameter = function(formReportParameter) {
  560 + formReportParameter.$submitted = true;
  561 +
  562 + if(formReportParameter.$valid){
  563 + if ($scope.indexParameter >= 0) {
  564 + $scope.report.parameters[$scope.indexParameter] = $scope.parameter;
  565 + }else{
  566 + $scope.report.parameters.push($scope.parameter);
  567 + }
  568 + $scope.$modalInstance.dismiss('cancel');
  569 + }else{
  570 + $scope.showAlert('error', $translate.instant('VALIDACAO.ALERTA_OBRIGATORIOS'));
  571 + }
  572 + };
403 573 }]);
... ...
cit-esi-web/src/main/webapp/html/report/dialogReportParameter.html 0 → 100644
... ... @@ -0,0 +1,91 @@
  1 +<ng-form name="formReportParameter" autocomplete="off">
  2 + <div class="modal-header">
  3 + <button class="btn btn-clear" type="button" ng-click="saveParameter(formReportParameter)">
  4 + <i class="fa fa-save green"></i> <translate>LABEL.SALVAR</translate>
  5 + </button>
  6 +
  7 + <button title="{{$translate.instant('LABEL.CANCELAR')}}" alt="{{$translate.instant('LABEL.CANCELAR')}}"
  8 + ng-click="$dismiss('cancel');" class="btn btn-clear">
  9 + <i class="fa fa-times red"></i>
  10 + <translate>LABEL.CANCELAR</translate>
  11 + </button>
  12 + </div>
  13 +
  14 + <div class="modal-body">
  15 + <fieldset>
  16 + <p>
  17 + <small>( <span class="red">*</span> ) <translate>LABEL.CAMPOS_OBRIGATORIOS</translate>
  18 + </small>
  19 + </p>
  20 +
  21 + <fieldset>
  22 + <legend><translate>ESI.PARAMETRO</translate></legend>
  23 +
  24 + <div class='row'>
  25 + <div class="col-sm-7">
  26 + <label-input-identifier ng-label="LABEL.NOME" ng-type="text" ng-id="parameter.name" ng-obrigatorio="true"
  27 + ng-disabled="!edit" ng-model="parameter.name" ng-custom-maxlength="100" form="formReportParameter"/>
  28 + </div>
  29 +
  30 + <div class="col-sm-5">
  31 + <label-select ng-id="parameter.type" ng-label="LABEL.TIPO" ng-model="parameter.type" ng-obrigatorio='true' form="formReportParameter"
  32 + ng-list="parameterTypeList | domainFilter" ng-custom-options="item.originalElement.chave as item.descricao for item">
  33 + </label-select>
  34 + </div>
  35 + </div><!-- .row -->
  36 +
  37 + <div class='row'>
  38 + <div class='col-sm-6' ng-if="parameter.type == 'DATAOBJECT'">
  39 + <auto-complete
  40 + ng-label="ESI.DATAOBJECT"
  41 + ng-find="findDataObject(value)"
  42 + ng-acao-borracha="clearParameterDataObject()"
  43 + ng-item="item.description"
  44 + ng-id="parameter.dataObject"
  45 + ng-model="parameter.dataObject"
  46 + ng-set-result="setParameterDataObject(item)"
  47 + form="reportForm"
  48 + ng-obrigatorio="true">
  49 + </auto-complete>
  50 + </div>
  51 +
  52 + <div class='col-sm-6' ng-if="parameter.type == 'FLOW'">
  53 + <auto-complete
  54 + ng-find="findFlow(value)"
  55 + ng-acao-borracha="clearParameterFlow()"
  56 + ng-item="item.description"
  57 + ng-id="parameter.flow"
  58 + ng-label="ESI.FLUXO"
  59 + ng-model="parameter.flow"
  60 + ng-set-result="setParameterFlow(item)"
  61 + form="reportForm"
  62 + ng-obrigatorio="true">
  63 + </auto-complete>
  64 + </div>
  65 +
  66 + </div>
  67 +
  68 + <div class="row">
  69 + <div class="col-md-6" ng-if="parameter.type == 'DATAOBJECT' && parameter.dataObject">
  70 + <label-select ng-id="parameter.customSQL" ng-label="ESI.SQL" ng-model="parameter.customSQL" ng-obrigatorio='false' form="reportForm"
  71 + ng-list="parameter.dataObject.sqls" ng-custom-options="sql.id as sql.description for sql" >
  72 + </label-select>
  73 + </div>
  74 + <div class="col-md-6" ng-if="parameter.type == 'FLOW' && parameter.flow">
  75 + <label-input-identifier ng-id="parameter.outputAttributeName" ng-label="ESI.VARIAVEL_SAIDA_FLUXO" ng-model="parameter.outputAttributeName"
  76 + form="reportForm" ng-obrigatorio="true" ng-disabled="!edit" ng-obrigatorio="true" />
  77 + </div><!-- .col -->
  78 + </div>
  79 +
  80 + <div class='row' ng-if="parameter.type == 'SCRIPT'">
  81 + <div class='col-md-12'>
  82 + <label-ui-ace ng-theme="eclipse" ng-mode="javascript" ng-model="parameter.scriptCode.script" ng-obrigatorio="true"/>
  83 + </div>
  84 + </div>
  85 + </fieldset>
  86 +
  87 +
  88 + </fieldset>
  89 + </div>
  90 +
  91 +</ng-form>
... ...
cit-esi-web/src/main/webapp/html/report/reportEdit.html
... ... @@ -133,11 +133,11 @@
133 133 <auto-complete
134 134 ng-label="ESI.CONEXAO_BANCO"
135 135 ng-find="findDataSource(value)"
136   - ng-acao-borracha="clearDataSourceAutoComplete()"
  136 + ng-acao-borracha="clearParameterDataSource()"
137 137 ng-item="item.description"
138   - ng-id="report.dataSource.connection"
139   - ng-model="report.dataSource.connection"
140   - ng-set-result="setDataSource(item)"
  138 + ng-id="parameter.connection"
  139 + ng-model="parameter.connection"
  140 + ng-set-result="setParameterDataSource(item)"
141 141 form="reportForm"
142 142 ng-obrigatorio="true">
143 143 </auto-complete>
... ... @@ -170,14 +170,7 @@
170 170 ng-obrigatorio="true">
171 171 </auto-complete>
172 172 </div>
173   -
174   - <div class='col-md-6' ng-if="report.dataSource.type == 'EXPRESSION'">
175   - <label-select ng-id="report.dataSource.expression.expressionType" ng-model="report.dataSource.expression.expressionType" ng-label="LABEL.TIPO"
176   - ng-obrigatorio='false' ng-disabled="disabled" form="reportForm" ng-list="expressionTypeList | domainFilter"
177   - ng-custom-options="item.originalElement.chave as item.descricao for item">
178   - </label-select>
179   - </div>
180   -
  173 +
181 174 </div>
182 175  
183 176 <div class="row">
... ... @@ -192,18 +185,9 @@
192 185 </div><!-- .col -->
193 186 </div>
194 187  
195   - <div class='row' ng-if="report.dataSource.type == 'EXPRESSION' && report.dataSource.expression.expressionType == 'CONSTANT'">
196   - <div class='col-md-12'>
197   - <div class='form-group'>
198   - <label class='control-label'><translate>LABEL.VALOR</translate><span class='red'>*</span></label>
199   - <div ui-ace="{ useWrapMode: true, theme:'eclipse', mode: 'javascript' }" ng-model="report.dataSource.expression.constantValue"></div>
200   - </div>
201   - </div>
202   - </div>
203   -
204   - <div class='row' ng-if="report.dataSource.expression.expressionType == 'SCRIPT'">
  188 + <div class='row' ng-if="report.dataSource.type == 'SCRIPT'">
205 189 <div class='col-md-12'>
206   - <label-ui-ace ng-theme="eclipse" ng-mode="javascript" ng-model="report.dataSource.expression.scriptCode.script" ng-obrigatorio="true"/>
  190 + <label-ui-ace ng-theme="eclipse" ng-mode="javascript" ng-model="report.dataSource.scriptCode.script" ng-obrigatorio="true"/>
207 191 </div>
208 192 </div>
209 193  
... ... @@ -212,11 +196,58 @@
212 196 <tab active="tabs[2].active" ng-click="setTabAtual(2)" select="setTabAtual(2)">
213 197 <tab-heading><i class="blue ace-icon fa fa-list"></i>&nbsp;<translate>ESI.PARAMETROS</translate></tab-heading>
214 198 <div class="row">
  199 + <div class="col-md-12">
  200 + <div class='row'>
  201 + <div class='col-sm-12'>
  202 + <div class="panel panel-default">
  203 + <div class="panel-heading clearfix">
  204 + <button class="btn btn-clear" ng-click="newParameter()" type="button" >
  205 + <i class="fa fa-plus-circle yellow-dark"></i>
  206 + <translate>LABEL.ADICIONAR</translate>
  207 + </button>
  208 +
  209 + <button class="btn btn-clear" ng-click="editParameter()" ng-disabled="!parameterChecked" type="button" >
  210 + <i class="fa fa-pencil blue"></i>
  211 + <translate>LABEL.EDITAR</translate>
  212 + </button>
  213 +
  214 + <button class="btn btn-clear" ng-click="removeParameter()" ng-disabled="!parameterChecked" type="button" >
  215 + <i class="fa fa-close red"></i>
  216 + <translate>LABEL.REMOVER</translate>
  217 + </button>
  218 + </div><!-- .panel-heading -->
  219 +
  220 + <table class="table table-striped table-bordered table-hover">
  221 + <thead>
  222 + <tr>
  223 + <th width="5%" class="text-center"></th>
  224 + <th width="70%"><translate>LABEL.NOME</translate></th>
  225 + <th width="20%"><translate>LABEL.TIPO</translate></th>
  226 + </tr>
  227 + </thead>
  228 + <tbody>
  229 + <tr ng-repeat="parameter in report.parameters" >
  230 + <td class="text-center vertical-middle">
  231 + <input type="radio" name="parameterChecked" ng-value="parameter" ng-disabled="!edit"
  232 + ng-model="parameterChecked" ng-click="checkParameter($index, parameter)" />
  233 + </td>
  234 + <td class="vertical-middle">{{parameter.name}}</td>
  235 + <td class="vertical-middle">{{getParameterType(parameter)}}</td>
  236 + </tr>
  237 + <tr ng-hide="report.parameters.length > 0">
  238 + <td colspan="3"><translate>LABEL.TABELA_VAZIA</translate></td>
  239 + </tr>
  240 + </tbody>
  241 + </table>
  242 + </div><!-- .panel -->
  243 + </div><!-- .col -->
  244 + </div><!-- .row -->
  245 + </div>
215 246 </div>
216 247 </tab>
217 248  
218 249 <tab active="tabs[3].active" ng-click="setTabAtual(3);setFormAttributes();" select="setTabAtual(3);setFormAttributes()">
219   - <tab-heading><i class="blue ace-icon fa fa-file-code-o"></i>&nbsp;<translate>ESI.CONSTRUCAO_FORM</translate></tab-heading>
  250 + <tab-heading><i class="blue ace-icon fa fa-file-code-o"></i>&nbsp;<translate>ESI.FORMULARIO_TAB</translate></tab-heading>
220 251 <div class="row">
221 252 <div class="col-md-4">
222 253 <label-input ng-type="text" ng-id="report.formVersion.resource.name" ng-label="ESI.NOME_FORM" ng-obrigatorio="false"
... ...