Commit 7f080a63262e9d31de670fb8866ac9bbfda2b678

Authored by Carlos Alberto
1 parent 3cd770af
Exists in master

Implementação dos recursos de relatório

cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/JasperReportManagerImpl.java
... ... @@ -5,6 +5,7 @@ import java.io.FileOutputStream;
5 5 import java.sql.Connection;
6 6 import java.util.HashMap;
7 7 import java.util.List;
  8 +import java.util.Map;
8 9  
9 10 import net.sf.jasperreports.engine.JRDataSource;
10 11 import net.sf.jasperreports.engine.JRException;
... ... @@ -52,12 +53,15 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper
52 53 throw new EsiExecutionException(e1);
53 54 }
54 55  
  56 + Map<String, Object> params = this.buildParams(report, inputMap);
  57 + params.put("SUBREPORT_DIR", servletContext.getRealPath(path)+"/");
  58 +
55 59 switch (report.getDataSource().getType()) {
56 60 case CONNECTION:
57 61 Connection connection = dataSourceService.connect(report.getDataSource().getConnection());
58 62  
59 63 try {
60   - print = JasperFillManager.fillReport(pathReportJasper, this.buildParams(report, inputMap), connection);
  64 + print = JasperFillManager.fillReport(pathReportJasper, params, connection);
61 65 } catch (JRException e) {
62 66 e.printStackTrace();
63 67 try {
... ... @@ -71,7 +75,7 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper
71 75  
72 76 default:
73 77 try {
74   - print = JasperFillManager.fillReport(pathReportJasper, this.buildParams(report, inputMap), this.buildDataSource(report, inputMap));
  78 + print = JasperFillManager.fillReport(pathReportJasper, params, this.buildDataSource(report, inputMap));
75 79 } catch (JRException e) {
76 80 throw new EsiExecutionException(e);
77 81 }
... ...
cit-esi-web/src/main/resources/reports/empregado.jrxml
... ... @@ -4,8 +4,11 @@
4 4 <property name="ireport.x" value="0"/>
5 5 <property name="ireport.y" value="0"/>
6 6 <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
7   - <defaultValueExpression><![CDATA["D:\\cit\\cit-grp-esi\\cit-esi-web\\src\\main\\resources\\reports\\"]]></defaultValueExpression>
  7 + <defaultValueExpression><![CDATA[]]></defaultValueExpression>
8 8 </parameter>
  9 + <queryString language="JSON">
  10 + <![CDATA[]]>
  11 + </queryString>
9 12 <field name="id" class="java.lang.Integer">
10 13 <fieldDescription><![CDATA[id]]></fieldDescription>
11 14 </field>
... ... @@ -55,8 +58,8 @@
55 58 <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
56 59 </textField>
57 60 <subreport>
58   - <reportElement x="438" y="0" width="106" height="20" uuid="904cdc0b-98c8-40ac-af91-baaed29629f0"/>
59   - <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
  61 + <reportElement x="434" y="0" width="110" height="22" uuid="10ec63c0-9a3b-4c31-bb52-8e3a6296b10b"/>
  62 + <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{telefones})]]></dataSourceExpression>
60 63 <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "empregado_telefone.jasper"]]></subreportExpression>
61 64 </subreport>
62 65 </band>
... ...
cit-esi-web/src/main/resources/reports/empregado_telefone.jrxml
... ... @@ -10,9 +10,9 @@
10 10 <band splitType="Stretch"/>
11 11 </background>
12 12 <detail>
13   - <band height="42" splitType="Stretch">
  13 + <band height="23" splitType="Stretch">
14 14 <textField>
15   - <reportElement x="11" y="12" width="100" height="20" uuid="42865c6c-27a5-48de-9549-8c87e20aa594"/>
  15 + <reportElement x="0" y="0" width="100" height="20" uuid="2b62387e-af3c-4c0c-81b8-e211519c1d4a"/>
16 16 <textFieldExpression><![CDATA[$F{numero}]]></textFieldExpression>
17 17 </textField>
18 18 </band>
... ...