Wiki source code of Reports

Version 2.5 by Maurice Gasco on 2015/10/23 18:46

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
171 A noter: le subreport_dir doit aussi être utilisé pour les images fixes (Propriété "Image Expression"):
172
173 [[image:jsr-subreportdir2.jpg]]
174
175 == Déploiement sur plateforme cible ==
176
177 Le déploiement sur la plateforme Requea se fait par la création d'une entité "JasperReports".
178
179 Dans le menu "Design / Rapports et graphiques" lorsque vous êtes connecté comme "RequeaDev"
180
181
182 [[image:jsr-deploy1.jpg]]
183
184 [[image:jsr-deploy2.jpg]]
185
186
187 Les champs importants sont:
188
189 * Le bundle est le bundle dans lequel le rapport sera placé.
190 * Le format (par défaut, PDF)
191 * Le fichier est le fichier jrxml du rapport principal
192 * les sous rapports et logos doivent être uploadés
193 * les paramètres. A noter la possibilité de mettre des valeurs de type ${xxx} qui seront évaluées lors de la génération du rapport.
194
195 [[image:jsr-deploy3.jpg]]
196
197 == Génération du rapport ==
198
199 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.
200
201
202
203 === Dans une action ===
204
205 Dans une action, le rapport peut être généré en utilisant une étape de type "Print".
206
207
208 Par exemple, essayons d'imprimer un rapport qui contient 2 paramètres de type date à saisir par l'utilisateur.
209
210 Dans cet exemple, nous avons un rapport jrxml qui utilise les 2 paramètres de type java.util.Date: parameter1 et parameter2
211
212
213 [[image:jsr-deploy4.jpg]]
214
215
216 ==== définition du rapport ====
217
218 Dans Design / Rapports et graphiques / Rapports Jasper, on crée un nouveau rapport:
219
220 [[image:jsr-deploy5.jpg]]
221
222
223 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)
224
225 ==== définition de l'entité qui va permettre la saisie des paramètres ====
226
227 Les 2 paramètres doivent être saisis par l'utilisateur. Pour cela on crée une entitée non persistée.
228
229 [[image:jsr-deploy6.jpg]]
230
231 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.
232
233 [[image:jsr-deploy6.jpg]]
234
235
236 Puis on crée une action testPrint:
237
238 [[image:jsr-deploy8.jpg]]
239
240
241 La première étape construit un objet custTestReportParams en mémoire et le stocke dans la variable "params"
242
243 La seconde étape permet la saisie des 2 parametres par l'utilisateur de l'objet stocké dans "params"
244 [[image:jsr-deploy9.jpg]]
245
246
247 La 3ème étape déclache la géneration du rapport. Sa définition est la suivante:
248
249 [[image:jsr-deploy10.jpg]]
250
251 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").
252 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.
253
254
255
256 Le résultat est alors le suivant:\\
257
258 [[image:jsr-deploy11.jpg]]
259
260 [[image:jsr-deploy12.jpg]]
261
262 === Dans une opération ===
263
264 Dans une opération, la génération du rapport se fait par du script:
265
266 // retrieve the report
267 var report = sysReport.Get("402881ff1cbdc5aa011cbde9dfc915ac");
268 // retrieve the PDF result
269 var result = report.PrintReport(data);
270 // set the report as an attachement
271 data.custFile = result.sysData;//
272
273 Dans cet exemple, le rapport est attaché dans la propriété custFile de l'objet
274
275
276 ==== Valorisation des paramètres dans l'appel d'opération ====
277
278 Les paramètres peuvent être valorisés de 2 manières:
279
280 * 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.
281
282 // retrieve the PDF result
283 var result = report.PrintReport(data); // the params are calculated based on 'data'
284
285
286 * soit en passant un tableau de paramètres en utilisant un objet avec une notation JSON
287 // retrieve the PDF result
288 var params = {
289 param1:"test",
290 param2:"test2"
291 }
292 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