Hide last authors
Pierre Dubois 1.1 1 == Introduction ==
2
Maurice Gasco 2.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.
Pierre Dubois 1.1 4
Maurice Gasco 2.2 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.
Pierre Dubois 1.1 6
Maurice Gasco 2.2 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.
Pierre Dubois 1.1 8
Maurice Gasco 2.2 9 NOTE: iReport documentation is available as a book we recommend [[reading>>http://jasperreports.sourceforge.net/JasperReports-Ultimate-Guide-3.pdf]]:
Pierre Dubois 1.1 10
11
Maurice Gasco 2.2 12 '' 'Requea provides no support, or assistance with the design of reports iReport / JasperReports' ''.
Pierre Dubois 1.1 13
Maurice Gasco 2.2 14 Please see the iReport documentation, purchase books published by JasperSoft, or buy service or training iReport / JasperSoft if you need it.
Pierre Dubois 1.1 15
Maurice Gasco 2.2 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.
Pierre Dubois 1.1 17
Maurice Gasco 2.2 18
Pierre Dubois 1.1 19 == Installation ==
20
21
Maurice Gasco 2.2 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.
Pierre Dubois 1.1 24
Maurice Gasco 2.2 25 Integration is done as a netbeans plugin offering the following features :
Pierre Dubois 1.1 26
Maurice Gasco 2.2 27 - Dynapage connexion to use HQL queries (DynapageQL) on top of Dynapage model.
Pierre Dubois 1.1 28
Maurice Gasco 2.2 29 - HTTP / HTTPS connexion allowing the use of a remote serveur.
Pierre Dubois 1.1 30
Maurice Gasco 2.2 31 To install the Dyanapage plugin:
Pierre Dubois 1.1 32
Maurice Gasco 2.2 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".
Pierre Dubois 1.1 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
Maurice Gasco 2.3 50 You can choose between 2 query langages for your reports
Pierre Dubois 1.1 51
52
53 ==== SQL ====
54
Maurice Gasco 2.3 55 '''Pros''':
Pierre Dubois 1.1 56
Maurice Gasco 2.3 57 * more powerful, more flexible
Pierre Dubois 1.1 58
Maurice Gasco 2.3 59 '''Cons''':
Pierre Dubois 1.1 60
Maurice Gasco 2.3 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
Pierre Dubois 1.1 65
66 ==== HQL (Hibernate Query Language) ====
67
Maurice Gasco 2.3 68 Pros :
Pierre Dubois 1.1 69
Maurice Gasco 2.3 70 * Works with any database engine
71 * Simpler expressions (specially for joins)
Pierre Dubois 1.1 72
Maurice Gasco 2.3 73 Cons :
Pierre Dubois 1.1 74
Maurice Gasco 2.3 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
Pierre Dubois 1.1 77
78 ==== Conclusion ====
79
Maurice Gasco 2.3 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
Pierre Dubois 1.1 82
Maurice Gasco 2.4 83 == Building a connection ==
Pierre Dubois 1.1 84
Maurice Gasco 2.4 85 Click on the Datasource button in the iReport toolbar
Pierre Dubois 1.1 86
87 [[image:jsr-tool.jpg]]
88
Maurice Gasco 2.4 89 Click "New" to create your datasource: JDBC for a SQL connection, or "Dynapage Instance" for a HQL based connection
Pierre Dubois 1.1 90
91 [[image:jsr-datasource.jpg]]
92
93 [[image:jsr-sourceinst.jpg]]
94
95
Maurice Gasco 2.4 96 == Dynapage Query ==
Pierre Dubois 1.1 97
98
Maurice Gasco 2.4 99 When you are in the report editor(Hit "New" menu to create one), you can enter the query that will populate the report
Pierre Dubois 1.1 100
101 [[image:jsr-queryl.jpg]]
102
Maurice Gasco 2.4 103 === Query language selection ===
Pierre Dubois 1.1 104
Maurice Gasco 2.4 105 For Requea Dynapage based HQL, select"Dynapage QL", not "Hibernate Query Language (HQL)"
Pierre Dubois 1.1 106
107
108 === Query ===
109
Maurice Gasco 2.4 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
Pierre Dubois 1.1 111
112 [[image:jsr-query.jpg||alt="png"]]
113
Maurice Gasco 2.5 114 ==== Field selection ====
Pierre Dubois 1.1 115
116 [[image:jsr-queryfields.jpg]]
117
Maurice Gasco 2.5 118 ==== References / components / extensions ====
Pierre Dubois 1.1 119
Maurice Gasco 2.5 120 Double click on a cardinality 1 reference and you can pickup properties from the referenced object.
Pierre Dubois 1.1 121
122 [[image:jsr-field.jpg]]
123
Maurice Gasco 2.5 124 ==== List of values ====
Pierre Dubois 1.1 125
Maurice Gasco 2.5 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.
Pierre Dubois 1.1 127
128 [[image:jsr-opttitle.jpg]]
129
Maurice Gasco 2.5 130 ==== Using fields ====
Pierre Dubois 1.1 131
Maurice Gasco 2.5 132 Once you have selected the fields and added them with the "Add selected fields" button, you can use them in your report.
Pierre Dubois 1.1 133
134 [[image:jsr-fields.jpg]]
135
136
Maurice Gasco 2.5 137 == Subreports ==
Pierre Dubois 1.1 138
Maurice Gasco 2.5 139 In Jasperreports, sub lists and graphics must be managed as subreports .
Pierre Dubois 1.1 140
Maurice Gasco 2.5 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.
Pierre Dubois 1.1 142
Maurice Gasco 2.5 143 Important things to know are:
Pierre Dubois 1.1 144
Maurice Gasco 2.5 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
Pierre Dubois 1.1 147
Maurice Gasco 2.5 148 Here are the steps to create a subreport.
Pierre Dubois 1.1 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
Maurice Gasco 2.5 162 This parameter is mandatory for the reporting engine to find the subreports when running in the Requea platform.
Pierre Dubois 1.1 163
Maurice Gasco 2.5 164 We advise you to always define this parameter
Pierre Dubois 1.1 165
Maurice Gasco 2.5 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:
Pierre Dubois 1.1 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