Wiki source code of Reports

Version 4.1 by Maurice Gasco on 2015/10/23 19:12

Show last authors
1 == Introduction ==
2
3 The (% style="font-family: sans-serif; font-size: 14px; font-style: normal; line-height: 19.6000003814697px; text-align: start;" %)REQUEA(%%) platform integrates the JasperReports reporting engine.
4
5 This engine allows you to create reports as lists, graphics or detail sheets. These reports can be generated as PDF, stored in the database or sent by email.
6
7 These (% style="font-family: sans-serif; font-size: 14px; font-style: normal; line-height: 19.6000003814697px; text-align: start; background-color: rgb(245, 245, 245);" %)JasperReports (% style="font-size: 14px; background-color: rgb(245, 245, 245);" %)reports are defined as .jrxml file. They are typically created with iReport reports design tool.
8
9 NOTE: iReport documentation is available as a book we recommend [[reading>>http://jasperreports.sourceforge.net/JasperReports-Ultimate-Guide-3.pdf]]:
10
11
12 '' 'Requea provides no support, or assistance with the design of reports iReport / JasperReports' ''.
13
14 Please see the iReport documentation, purchase books published by JasperSoft, or buy service or training iReport / JasperSoft if you need it.
15
16 iReport is an open source tool developed by JasperSoft offers a number of services around its tool. Requea does not provide services around iReport paying nor free.
17
18
19 == Installation ==
20
21
22 NOTE: Versions of iReport / JaspertReports
23 iReport is a tool that evolves pretty quickly. Requea actually provides integration with iReport version 4.0.1.
24
25 Integration is done as a netbeans plugin offering the following features :
26
27 - Dynapage connexion to use HQL queries (DynapageQL) on top of Dynapage model.
28
29 - HTTP / HTTPS connexion allowing the use of a remote serveur.
30
31 To install the Dyanapage plugin:
32
33 * Download Dynapage pglugin here: [[Dynapage IReport plugin>>https://download.requea.com/ireport/com-requea-dynapage-ireport.nbm||rel="__blank"]]
34 * Download iReport 4.0.1 from JasperReports website.
35 * in the Tools / Plugins menu, in the"Downloaded" tab, click on "Add Plugins..." button, select the .nbm file
36 * Then select the plugin and click "Install".
37
38 (((
39 (% class="Apple-style-span" style="line-height: 19px;" %)[[image:VoilaCapture25.png]]
40 )))
41
42
43
44 [[image:VoilaCapture26.png]]
45
46
47
48 == HQL vs SQL ==
49
50 You can choose between 2 query langages for your reports
51
52
53 ==== SQL ====
54
55 '''Pros''':
56
57 * more powerful, more flexible
58
59 '''Cons''':
60
61 * no portability between database engines (Oracle / mySQL / MSSQL)
62 * SQL expressions more complicated
63 * Dynapage Option labels not managed
64 * You need to look into the database to discover table and columns names
65
66 ==== HQL (Hibernate Query Language) ====
67
68 Pros :
69
70 * Works with any database engine
71 * Simpler expressions (specially for joins)
72
73 Cons :
74
75 * Need of the knowledge: documentation available on : [[Documentation Hibernate Query Language on JBoss website>>http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html]]
76 * Data model must include all the relations between objects, you cannot build joins "on the fly". You can only use relations defined by Reference/Component properties
77
78 ==== Conclusion ====
79
80 * Use SQL if it is a single project and you are a SQL expert
81 * Use HQL if you build a product that can be used in various environment
82
83 == Building a connection ==
84
85 Click on the Datasource button in the iReport toolbar
86
87 [[image:jsr-tool.jpg]]
88
89 Click "New" to create your datasource: JDBC for a SQL connection, or "Dynapage Instance" for a HQL based connection
90
91 [[image:jsr-datasource.jpg]]
92
93 [[image:jsr-sourceinst.jpg]]
94
95
96 == Dynapage Query ==
97
98
99 When you are in the report editor(Hit "New" menu to create one), you can enter the query that will populate the report
100
101 [[image:jsr-queryl.jpg]]
102
103 === Query language selection ===
104
105 For Requea Dynapage based HQL, select"Dynapage QL", not "Hibernate Query Language (HQL)"
106
107
108 === Query ===
109
110 Here is a simple query example On the right, a tree view shows the available properties. Note: you need sometimes to modify the query (add / remove a character) for the list to be refreshed
111
112 [[image:jsr-query.jpg||alt="png"]]
113
114 ==== Field selection ====
115
116 [[image:jsr-queryfields.jpg]]
117
118 ==== References / components / extensions ====
119
120 Double click on a cardinality 1 reference and you can pickup properties from the referenced object.
121
122 [[image:jsr-field.jpg]]
123
124 ==== List of values ====
125
126 For property defined with a "List of values", the returned value by default is the value stored in the database. You can "double click" on the field to access on the "title" field. You will then get the corresponding title instead of the value stored in the database.
127
128 [[image:jsr-opttitle.jpg]]
129
130 ==== Using fields ====
131
132 Once you have selected the fields and added them with the "Add selected fields" button, you can use them in your report.
133
134 [[image:jsr-fields.jpg]]
135
136
137 == Subreports ==
138
139 In Jasperreports, sub lists and graphics must be managed as subreports .
140
141 Please read the (% style="font-family: sans-serif; font-size: 14px; font-style: normal; line-height: 19.6000003814697px; text-align: start; background-color: rgb(245, 245, 245);" %)iReport (% style="font-size: 14px; background-color: rgb(245, 245, 245);" %)documentation (JasperSoft) for further help.
142
143 Important things to know are:
144
145 * You need to use the "SUBREPORT_DIR" parameter to manage the subreport directory in order to be ready for the deployment on the Requea server
146 * The connection
147
148 Here are the steps to create a subreport.
149
150 [[image:jsr-subreport1.jpg]]
151
152 [[image:jsr-subreport2.jpg]]
153
154 [[image:jsr-subreport3.jpg]]
155
156 [[image:jsr-subreport4.jpg]]
157
158
159
160 ==== SUBREPORT_DIR ====
161
162 This parameter is mandatory for the reporting engine to find the subreports when running in the Requea platform.
163
164 We advise you to always define this parameter
165
166 Put your local directory where you put your reports in order to test the report in iReport. The value will be automatically overridden when the report will be processed with the Requea platform:
167
168 [[image:jsr-subreportdir.jpg]]
169
170 NOTE: SUBREPORT_DIR is also used for static images ("Image Expression" property):
171
172 [[image:jsr-subreportdir2.jpg]]
173
174 == Deployment on the target Requea plateform ==
175
176 Go to the "Design" tab and click on the "Reports and graphs" menu using the "RequeaDev" login
177
178
179 [[image:jsr-deploy1.jpg]]
180
181 [[image:jsr-deploy2.jpg]]
182
183
184 Fill the mandatory fields:
185
186 * The bundle in which the report will be saved
187 * The format (PDF by default)
188 * Upload in "File" the jrxml file of the main report
189 * Upload in "Support files" subreports jrxml files and static images files
190 * Parameters. Fill the parameters according to your report definition (SUBREPORT_DIR parameter does not need to be defined here). in order to have dynamic values for parameters use the ${xxx} syntax.
191
192 [[image:jsr-deploy3.jpg]]
193
194 == Génération du rapport ==
195
196 Les rapports peuvent être générés dans une action (sur click puis download du résultat par l'utilisateur), ou dans une opératio, ce qui permet de mettre le résultat en attachement d'un objet et donc de le stocker ou de l'envoyer via un workflow par exemple.
197
198
199
200 === Dans une action ===
201
202 Dans une action, le rapport peut être généré en utilisant une étape de type "Print".
203
204
205 Par exemple, essayons d'imprimer un rapport qui contient 2 paramètres de type date à saisir par l'utilisateur.
206
207 Dans cet exemple, nous avons un rapport jrxml qui utilise les 2 paramètres de type java.util.Date: parameter1 et parameter2
208
209
210 [[image:jsr-deploy4.jpg]]
211
212
213 ==== définition du rapport ====
214
215 Dans Design / Rapports et graphiques / Rapports Jasper, on crée un nouveau rapport:
216
217 [[image:jsr-deploy5.jpg]]
218
219
220 A noter les 2 paramètres qui sont définis : parameter1 et parameter2 et les expressions pour les valeurs (plus d'explications dans la suite)
221
222 ==== définition de l'entité qui va permettre la saisie des paramètres ====
223
224 Les 2 paramètres doivent être saisis par l'utilisateur. Pour cela on crée une entitée non persistée.
225
226 [[image:jsr-deploy6.jpg]]
227
228 On lui ajoute 2 propriétés de type date: Param1 et Param2. Dans cet exemple, l'entité a été crée dans le bundle customisations, dont le préfixe est "cust". Le nom complet des propriétés est donc custParam1 et custParam2. D'ou le nom et la syntaxe des expressions des 2 paramètres. A adapter en fonction de vos entités.
229
230 [[image:jsr-deploy6.jpg]]
231
232
233 Puis on crée une action testPrint:
234
235 [[image:jsr-deploy8.jpg]]
236
237
238 La première étape construit un objet custTestReportParams en mémoire et le stocke dans la variable "params"
239
240 La seconde étape permet la saisie des 2 parametres par l'utilisateur de l'objet stocké dans "params"
241 [[image:jsr-deploy9.jpg]]
242
243
244 La 3ème étape déclache la géneration du rapport. Sa définition est la suivante:
245
246 [[image:jsr-deploy10.jpg]]
247
248 A noter le champs Entrée qui permet de préciser l'objet utilisé pour évaluer les expressions de valeur de paramètre (ici "params").
249 C'est cet objet qui servira de base au calcul des ${custParam1} défini dans l'objet "JasperReport" et dont les valeurs seront passées à JasperReports comme paramètres du rapport.
250
251
252
253 Le résultat est alors le suivant:\\
254
255 [[image:jsr-deploy11.jpg]]
256
257 [[image:jsr-deploy12.jpg]]
258
259 === Dans une opération ===
260
261 Dans une opération, la génération du rapport se fait par du script:
262
263 // retrieve the report
264 var report = sysReport.Get("402881ff1cbdc5aa011cbde9dfc915ac");
265 // retrieve the PDF result
266 var result = report.PrintReport(data);
267 // set the report as an attachement
268 data.custFile = result.sysData;//
269
270 Dans cet exemple, le rapport est attaché dans la propriété custFile de l'objet
271
272
273 ==== Valorisation des paramètres dans l'appel d'opération ====
274
275 Les paramètres peuvent être valorisés de 2 manières:
276
277 * soit en passant un objet en contexte. Les définitions de paramètres seront utilisées et les expressions ${xxxx} seront valorisées par rapport à cet objet.
278
279 // retrieve the PDF result
280 var result = report.PrintReport(data); // the params are calculated based on 'data'
281
282
283 * soit en passant un tableau de paramètres en utilisant un objet avec une notation JSON
284 // retrieve the PDF result
285 var params = {
286 param1:"test",
287 param2:"test2"
288 }
289 var result = JasperReports.Print(report, null, report.rqFormat, params); // the params are in params'
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 9.11.5 - Documentation