reefdb-queries.hbm.xml 83.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

<!--
  TODO EIS: modifications à faire deans le nommage d'attribute UML
   - refTaxonId -> referenceTaxon
   - progCds -> programs
   - unitId -> unit
11

12
13
14
15
 -->

  <query name="allCampaigns">
    <![CDATA[
16
      SELECT campaignId, campaignNm, campaignStartDt, campaignEndDt, campaignSismerLk, campaignCm, quser.quserId, recorderDepartment.depId
17
18
19
      FROM CampaignImpl
    ]]>
  </query>
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

  <query name="campaignsByIds">
    <![CDATA[
      SELECT campaignId, campaignNm, campaignStartDt, campaignEndDt, campaignSismerLk, campaignCm, quser.quserId, recorderDepartment.depId
      FROM CampaignImpl
      WHERE campaignId IN (:campaignIds)
    ]]>
    <query-param name="campaignIds" type="java.lang.String"/>
  </query>

  <query name="campaignsByCriteria">
    <![CDATA[
      SELECT campaignId, campaignNm, campaignStartDt, campaignEndDt, campaignSismerLk, campaignCm, quser.quserId, recorderDepartment.depId
      FROM CampaignImpl
      WHERE (:name is null OR upper(campaignNm) like upper(concat('%', :name, '%')))
    ]]>
    <query-param name="name" type="java.lang.String"/>
  </query>

  <query name="campaignsByName">
    <![CDATA[
      SELECT campaignId, campaignNm, campaignStartDt, campaignEndDt, campaignSismerLk, campaignCm, quser.quserId, recorderDepartment.depId
      FROM CampaignImpl
      WHERE upper(campaignNm) = upper(:name)
    ]]>
    <query-param name="name" type="java.lang.String"/>
  </query>

48
49
  <query name="allPrograms">
    <![CDATA[
50
      SELECT p.progCd, p.progNm, p.progDc, p.isDepartmentHermetic, status.statusCd
51
52
53
54
55
56
57
      FROM ProgramImpl p
      ORDER BY p.progNm
    ]]>
  </query>
  
  <query name="programByCode">
    <![CDATA[
58
      SELECT p.progCd, p.progNm, p.progDc, p.isDepartmentHermetic, p.status.statusCd
59
60
61
62
63
64
65
66
      FROM ProgramImpl p
      WHERE p.progCd = :programCode      
    ]]>
    <query-param name="programCode" type="java.lang.String"/>
  </query>
  
  <query name="programsByCodes">
    <![CDATA[
67
      SELECT p.progCd, p.progNm, p.progDc, p.isDepartmentHermetic, p.status.statusCd
68
69
70
71
72
73
74
75
      FROM ProgramImpl p
      WHERE p.progCd IN (:programCodes)
    ]]>
    <query-param name="programCodes" type="java.lang.String"/>
  </query>
  
  <query name="programsByCampaignId">
    <![CDATA[
76
      SELECT p.progCd, p.progNm, p.progDc, p.isDepartmentHermetic, p.status.statusCd
77
78
79
80
81
82
83
      FROM CampaignImpl c
      JOIN c.programs p
      WHERE c.campaignId = :campaignId
    ]]>
    <query-param name="campaignId" type="java.lang.Integer"/>
  </query>
  
84
85
  <query name="programsByCodeAndName">
    <![CDATA[
86
      SELECT p.progCd, p.progNm, p.progDc, p.isDepartmentHermetic, p.status.statusCd
87
88
89
90
91
92
93
94
95
96
      FROM ProgramImpl p
      WHERE (:code is null OR p.progCd = :code)
      AND (:name is null OR p.progNm = :name)
      AND p.status.statusCd IN (:statusCodes)
    ]]>
    <query-param name="code" type="java.lang.String"/>
    <query-param name="name" type="java.lang.String"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
PECQUOT's avatar
   
PECQUOT committed
97
98
  <query name="programsByLocationAndDate">
    <![CDATA[
99
      SELECT p.progCd, p.progNm, p.progDc, p.isDepartmentHermetic, p.status.statusCd
PECQUOT's avatar
   
PECQUOT committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
      FROM ProgramImpl p
      INNER JOIN p.strategies s
      INNER JOIN s.appliedStrategies aps
      INNER JOIN aps.appliedPeriods app
      WHERE aps.monitoringLocation.monLocId = :locationId
      AND app.id.appliedPeriodStartDt <= :date
      AND app.appliedPeriodEndDt >= :date
      AND p.status.statusCd IN (:statusCodes)
    ]]>
    <query-param name="locationId" type="java.lang.Integer"/>
    <query-param name="date" type="java.util.Date"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>

PECQUOT's avatar
   
PECQUOT committed
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  <query name="programPrivilegesForUsersByProgramCode">
    <![CDATA[
      SELECT up.id.programPrivilege.progPrivId, up.id.quser.quserId
      FROM ProgramImpl p
      LEFT JOIN p.progQuserProgPrivs up
      WHERE p.progCd = :programCode
    ]]>
    <query-param name="programCode" type="java.lang.String"/>
  </query>

  <query name="programPrivilegesForDepartmentsByProgramCode">
    <![CDATA[
      SELECT dp.id.programPrivilege.progPrivId, dp.id.department.depId
      FROM ProgramImpl p
      LEFT JOIN p.progDepProgPrivs dp
      WHERE p.progCd = :programCode
    ]]>
    <query-param name="programCode" type="java.lang.String"/>
  </query>

134
135
136
137
138
139
140
141
142
  <query name="stratIdsByProgCd">
    <![CDATA[
      SELECT stratId
      FROM StrategyImpl
      WHERE program.progCd = :programCode
    ]]>
    <query-param name="programCode" type="java.lang.String"/>
  </query>

PECQUOT's avatar
   
PECQUOT committed
143

144
  <query name="allUsers">
PECQUOT's avatar
PECQUOT committed
145
    <![CDATA[
146
      SELECT quserId,
PECQUOT's avatar
   
PECQUOT committed
147
            quserCd,
148
149
150
151
152
            quserLastNm,
            quserFirstNm,
            department.depId,
            quserIntranetLg,
            quserExtranetLg,
PECQUOT's avatar
   
PECQUOT committed
153
            quserCryptPassword,
154
155
156
157
158
159
160
            quserEMail,
            quserPhone,
            quserAddress,
            quserOrgan,
            quserAdminCenter,
            quserSite,
            status.statusCd
PECQUOT's avatar
PECQUOT committed
161
      FROM QuserImpl
162
      WHERE status.statusCd IN (:statusCodes)
PECQUOT's avatar
PECQUOT committed
163
164
165
166
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
167
  <query name="userById">
PECQUOT's avatar
PECQUOT committed
168
    <![CDATA[
169
      SELECT quserId,
PECQUOT's avatar
   
PECQUOT committed
170
            quserCd,
171
172
173
174
175
            quserLastNm,
            quserFirstNm,
            department.depId,
            quserIntranetLg,
            quserExtranetLg,
PECQUOT's avatar
   
PECQUOT committed
176
            quserCryptPassword,
177
178
179
180
181
182
183
            quserEMail,
            quserPhone,
            quserAddress,
            quserOrgan,
            quserAdminCenter,
            quserSite,
            status.statusCd
PECQUOT's avatar
PECQUOT committed
184
      FROM QuserImpl
185
      WHERE quserId = :quserId
PECQUOT's avatar
PECQUOT committed
186
    ]]>
187
    <query-param name="quserId" type="java.lang.Integer"/>
PECQUOT's avatar
PECQUOT committed
188
189
  </query>

PECQUOT's avatar
PECQUOT committed
190
191
192
  <query name="usersByIds">
    <![CDATA[
      SELECT quserId,
PECQUOT's avatar
   
PECQUOT committed
193
            quserCd,
PECQUOT's avatar
PECQUOT committed
194
195
196
197
198
            quserLastNm,
            quserFirstNm,
            department.depId,
            quserIntranetLg,
            quserExtranetLg,
PECQUOT's avatar
   
PECQUOT committed
199
            quserCryptPassword,
PECQUOT's avatar
PECQUOT committed
200
201
202
203
204
205
206
207
208
209
210
211
212
            quserEMail,
            quserPhone,
            quserAddress,
            quserOrgan,
            quserAdminCenter,
            quserSite,
            status.statusCd
      FROM QuserImpl
      WHERE quserId IN (:quserIds)
    ]]>
    <query-param name="quserIds" type="java.lang.String"/>
  </query>

213
  <query name="usersByLogin">
214
215
    <!-- Make sure to get local user first, to avoid identity substitution
        (because a local user could have the same login as a national user) -->
PECQUOT's avatar
PECQUOT committed
216
    <![CDATA[
217
      SELECT quserId,
PECQUOT's avatar
   
PECQUOT committed
218
            quserCd,
219
220
221
222
223
            quserLastNm,
            quserFirstNm,
            department.depId,
            quserIntranetLg,
            quserExtranetLg,
PECQUOT's avatar
   
PECQUOT committed
224
            quserCryptPassword,
225
226
227
228
229
230
231
            quserEMail,
            quserPhone,
            quserAddress,
            quserOrgan,
            quserAdminCenter,
            quserSite,
            status.statusCd
PECQUOT's avatar
PECQUOT committed
232
      FROM QuserImpl
233
234
235
236
      WHERE
        status.statusCd IN (:statusCodes)
        AND (quserIntranetLg = :login OR quserExtranetLg = :login)
      ORDER BY quserId ASC
PECQUOT's avatar
PECQUOT committed
237
238
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
239
    <query-param name="login" type="java.lang.String"/>
PECQUOT's avatar
PECQUOT committed
240
241
  </query>

242
243
  <query name="usersByCriteria">
    <![CDATA[
244
      SELECT u.quserId,
PECQUOT's avatar
   
PECQUOT committed
245
            u.quserCd,
246
247
248
249
250
            u.quserLastNm,
            u.quserFirstNm,
            u.department.depId,
            u.quserIntranetLg,
            u.quserExtranetLg,
PECQUOT's avatar
   
PECQUOT committed
251
            u.quserCryptPassword,
252
253
254
255
256
257
258
259
260
261
            u.quserEMail,
            u.quserPhone,
            u.quserAddress,
            u.quserOrgan,
            u.quserAdminCenter,
            u.quserSite,
            u.status.statusCd
      FROM QuserImpl u
      LEFT JOIN u.privileges p
      WHERE u.status.statusCd IN (:statusCodes)
PECQUOT's avatar
   
PECQUOT committed
262
263
264
265
      AND (:lastName is null OR lower(u.quserLastNm) like lower(concat('%', :lastName, '%')))
      AND (:firstName is null OR lower(u.quserFirstNm) like lower(concat('%', :firstName, '%')))
      AND (:strictLastName is null OR lower(u.quserLastNm) = lower(:strictLastName))
      AND (:strictFirstName is null OR lower(u.quserFirstNm) = lower(:strictFirstName))
266
267
      AND (:departmentId is null OR u.department.depId = :departmentId)
      AND (:privilegeCd is null OR p.privilegeCd = :privilegeCd)
PECQUOT's avatar
   
PECQUOT committed
268
      AND (:login is null OR lower(u.quserIntranetLg) = lower(:login) OR lower(u.quserExtranetLg) = lower(:login))
269
270
      GROUP BY u.quserId
      ORDER BY u.quserLastNm
271
272
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
PECQUOT's avatar
   
PECQUOT committed
273
274
275
276
    <query-param name="lastName" type="java.lang.String"/>
    <query-param name="firstName" type="java.lang.String"/>
    <query-param name="strictLastName" type="java.lang.String"/>
    <query-param name="strictFirstName" type="java.lang.String"/>
277
    <query-param name="departmentId" type="java.lang.Integer"/>
278
    <query-param name="privilegeCd" type="java.lang.String"/>
PECQUOT's avatar
   
PECQUOT committed
279
    <query-param name="login" type="java.lang.String"/>
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
  </query>

  <query name="allPrivileges">
    <![CDATA[
      SELECT p.privilegeCd,
            p.privilegeNm,
            p.privilegeDc
      FROM PrivilegeImpl p
    ]]>
  </query>

  <query name="privilegesByUserId">
    <![CDATA[
      SELECT p.privilegeCd,
            p.privilegeNm,
            p.privilegeDc
      FROM QuserImpl u
      INNER JOIN u.privileges p
      WHERE u.quserId = :userId
    ]]>
    <query-param name="userId" type="java.lang.Integer"/>
301
302
  </query>

303
304
  <query name="allDepartments">
    <![CDATA[
305
306
307
308
      SELECT d.depId, d.depCd, d.depNm, d.depDc, d.depEMail, d.depAddress, d.depPhone, p.depId, d.status.statusCd
      FROM DepartmentImpl d
      LEFT JOIN d.parentDepartment p
      WHERE d.status.statusCd IN (:statusCodes)
309
    ]]>
PECQUOT's avatar
   
PECQUOT committed
310
    <query-param name="statusCodes" type="java.lang.String"/>
311
  </query>
PECQUOT's avatar
PECQUOT committed
312

313
314
  <query name="departmentById">
    <![CDATA[
315
316
317
318
      SELECT d.depId, d.depCd, d.depNm, d.depDc, d.depEMail, d.depAddress, d.depPhone, p.depId, d.status.statusCd
      FROM DepartmentImpl d
      LEFT JOIN d.parentDepartment p
      WHERE d.depId = :departementId
319
320
321
    ]]>
    <query-param name="departementId" type="java.lang.Integer"/>
  </query>
PECQUOT's avatar
   
PECQUOT committed
322
323
324
325
326
327
328
329
330
331

  <query name="departmentIdsByParentDepartmentId">
    <![CDATA[
      SELECT depId
      FROM DepartmentImpl
      WHERE parentDepartment.depId = :parentDepartementId
    ]]>
    <query-param name="parentDepartementId" type="java.lang.Integer"/>
  </query>

332
333
  <query name="departmentsByIds">
    <![CDATA[
334
335
336
337
      SELECT d.depId, d.depCd, d.depNm, d.depDc, d.depEMail, d.depAddress, d.depPhone, p.depId, d.status.statusCd
      FROM DepartmentImpl d
      LEFT JOIN d.parentDepartment p
      WHERE d.depId IN (:departementIds)
338
339
340
341
    ]]>
    <query-param name="departementIds" type="java.lang.String"/>
  </query>
  
342
343
  <query name="departmentsByCodeAndName">
    <![CDATA[
344
345
346
      SELECT d.depId, d.depCd, d.depNm, d.depDc, d.depEMail, d.depAddress, d.depPhone, p.depId, d.status.statusCd
      FROM DepartmentImpl d
      LEFT JOIN d.parentDepartment p
PECQUOT's avatar
   
PECQUOT committed
347
      WHERE (:departmentCode is null OR lower(d.depCd) like lower(concat('%', :departmentCode, '%')))
348
      AND (:departmentName is null OR lower(d.depNm) like lower(concat('%', :departmentName, '%')))
PECQUOT's avatar
   
PECQUOT committed
349
350
      AND (:strictDepartmentCode is null OR lower(d.depCd) = lower(:strictDepartmentCode))
      AND (:strictDepartmentName is null OR lower(d.depNm) = lower(:strictDepartmentName))
351
352
      AND (:parentId is null OR p.depId = :parentId)
      AND d.status.statusCd IN (:statusCodes)
353
354
355
    ]]>
    <query-param name="departementCode" type="java.lang.String"/>
    <query-param name="departementName" type="java.lang.String"/>
PECQUOT's avatar
   
PECQUOT committed
356
357
    <query-param name="strictDepartementCode" type="java.lang.String"/>
    <query-param name="strictDepartementName" type="java.lang.String"/>
358
    <query-param name="parentId" type="java.lang.Integer"/>
359
360
361
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
362
363
364
365
366
367
  <query name="allSamplingEquipments">
    <![CDATA[
      SELECT s.samplingEquipmentId, s.samplingEquipmentNm, s.samplingEquipmentDc, s.samplingEquipmentSize, s.status.statusCd,
        u.unitId, u.unitNm, u.unitSymbol, u.status.statusCd
      FROM SamplingEquipmentImpl s
      LEFT JOIN s.unitId u
368
      WHERE s.status.statusCd IN (:statusCodes)
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="samplingEquipmentById">
    <![CDATA[
      SELECT s.samplingEquipmentId, s.samplingEquipmentNm, s.samplingEquipmentDc, s.samplingEquipmentSize, s.status.statusCd,
        u.unitId, u.unitNm, u.unitSymbol, u.status.statusCd
      FROM SamplingEquipmentImpl s
      LEFT JOIN s.unitId u
      WHERE s.samplingEquipmentId = :samplingEquipmentId
    ]]>
    <query-param name="samplingEquipmentId" type="java.lang.Integer"/>
  </query>

PECQUOT's avatar
   
PECQUOT committed
384
  <query name="samplingEquipmentsByIds">
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
    <![CDATA[
      SELECT s.samplingEquipmentId, s.samplingEquipmentNm, s.samplingEquipmentDc, s.samplingEquipmentSize, s.status.statusCd,
        u.unitId, u.unitNm, u.unitSymbol, u.status.statusCd
      FROM SamplingEquipmentImpl s
      LEFT JOIN s.unitId u
      WHERE s.samplingEquipmentId IN (:samplingEquipmentIds)
    ]]>
    <query-param name="samplingEquipmentIds" type="java.lang.String"/>
  </query> 
      
  <query name="samplingEquipmentsByCriteria">
    <![CDATA[
      SELECT s.samplingEquipmentId, s.samplingEquipmentNm, s.samplingEquipmentDc, s.samplingEquipmentSize, s.status.statusCd,
        u.unitId, u.unitNm, u.unitSymbol, u.status.statusCd
      FROM SamplingEquipmentImpl s
      LEFT JOIN s.unitId u
      WHERE (:samplingEquipmentId is null OR s.samplingEquipmentId = :samplingEquipmentId)
      AND (:unitId is null OR u.unitId = :unitId)
403
      AND s.status.statusCd IN (:statusCodes)
404
405
406
407
408
409
    ]]>
    <query-param name="samplingEquipmentId" type="java.lang.Integer"/>
    <query-param name="unitId" type="java.lang.Integer"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
410
411
412
413
414
415
  <query name="samplingEquipmentsByName">
    <![CDATA[
      SELECT s.samplingEquipmentId, s.samplingEquipmentNm, s.samplingEquipmentDc, s.samplingEquipmentSize, s.status.statusCd,
        u.unitId, u.unitNm, u.unitSymbol, u.status.statusCd
      FROM SamplingEquipmentImpl s
      LEFT JOIN s.unitId u
PECQUOT's avatar
   
PECQUOT committed
416
      WHERE (:samplingEquipmentName is null OR upper(s.samplingEquipmentNm) = upper(:samplingEquipmentName))
417
418
419
420
421
422
      AND s.status.statusCd IN (:statusCodes)
    ]]>
    <query-param name="samplingEquipmentName" type="java.lang.String"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
423
424
425
426
  <query name="allAnalysisInstruments">
    <![CDATA[
      SELECT a.analInstId, a.analInstNm, a.analInstDc, a.status.statusCd
      FROM AnalysisInstrumentImpl a
427
      WHERE a.status.statusCd IN (:statusCodes)
428
429
430
431
432
433
434
435
436
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="analysisInstrumentsByCriteria">
    <![CDATA[
      SELECT a.analInstId, a.analInstNm, a.analInstDc, a.status.statusCd
      FROM AnalysisInstrumentImpl a
      WHERE (:analysisInstrumentId is null OR a.analInstId = :analysisInstrumentId)
437
      AND a.status.statusCd IN (:statusCodes)
438
439
440
441
442
    ]]>
    <query-param name="analysisInstrumentId" type="java.lang.Integer"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
443
444
445
446
  <query name="analysisInstrumentsByName">
    <![CDATA[
      SELECT a.analInstId, a.analInstNm, a.analInstDc, a.status.statusCd
      FROM AnalysisInstrumentImpl a
PECQUOT's avatar
   
PECQUOT committed
447
      WHERE (:analysisInstrumentName is null OR upper(a.analInstNm) = upper(:analysisInstrumentName))
448
449
450
451
452
453
      AND a.status.statusCd IN (:statusCodes)
    ]]>
    <query-param name="analysisInstrumentName" type="java.lang.String"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
  <query name="analysisInstrumentById">
    <![CDATA[
      SELECT analInstId, analInstNm, analInstDc, status.statusCd
      FROM AnalysisInstrumentImpl ai
      WHERE ai.analInstId = :analysisInstrumentId
    ]]>
    <query-param name="analysisInstrumentId" type="java.lang.Integer"/>
  </query>
  
  <query name="analysisInstrumentsByIds">
    <![CDATA[
      SELECT analInstId, analInstNm, analInstDc, status.statusCd
      FROM AnalysisInstrumentImpl ai
      WHERE ai.analInstId IN (:analysisInstrumentIds)
    ]]>
    <query-param name="analysisInstrumentIds" type="java.lang.String"/>
  </query> 
  
  <query name="allQualityFlags">
    <![CDATA[
      SELECT q.qualFlagCd, q.qualFlagNm, q.qualFlagDc, q.status.statusCd
      FROM QualityFlagImpl q
476
      WHERE q.status.statusCd IN (:statusCodes)
477
478
479
480
481
482
483
484
485
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="qualityFlagsByCriteria">
    <![CDATA[
      SELECT q.qualFlagCd, q.qualFlagNm, q.qualFlagDc, q.status.statusCd
      FROM QualityFlagImpl q
      WHERE (:qualityFlagCode is null OR q.qualFlagCd = :qualityFlagCode)
486
      AND q.status.statusCd IN (:statusCodes)
487
488
489
490
491
492
493
494
495
496
497
498
499
500
    ]]>
    <query-param name="qualityFlagCode" type="java.lang.String"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="qualityFlagByCode">
    <![CDATA[
      SELECT q.qualFlagCd, q.qualFlagNm, q.qualFlagDc, q.status.statusCd
      FROM QualityFlagImpl q
      WHERE q.qualFlagCd = :qualityFlagCode
    ]]>
    <query-param name="qualityFlagCode" type="java.lang.String"/>
  </query>
  
PECQUOT's avatar
   
PECQUOT committed
501
  <query name="monitoringLocationsByProgramCode">
502
    <![CDATA[
PECQUOT's avatar
   
PECQUOT committed
503
      SELECT DISTINCT ml.monLocId, ml.monLocNm, ml.monLocBathym, ml.monLocCm, ml.monLocLb, ml.monLocUtFormat, ml.monLocDaylightSavingTime,
504
        h.harbourCd, h.harbourNm, ml.status.statusCd, ml.positionningSystem.posSystemId
505
506
      FROM
        ProgramImpl p
PECQUOT's avatar
   
PECQUOT committed
507
508
        INNER JOIN p.monLocProgs mlprog
        INNER JOIN mlprog.monitoringLocation ml
PECQUOT's avatar
   
PECQUOT committed
509
        LEFT JOIN ml.harbour h
510
511
512
513
514
515
      WHERE
       (:programCode is null OR p.progCd = :programCode)
    ]]>
    <query-param name="programCode" type="java.lang.String"/>
  </query>

PECQUOT's avatar
   
PECQUOT committed
516
  <query name="monitoringLocationsByCampaignIdAndProgramCode">
517
    <![CDATA[
PECQUOT's avatar
   
PECQUOT committed
518
      SELECT ml.monLocId, ml.monLocNm, ml.monLocBathym, ml.monLocCm, ml.monLocLb, ml.monLocUtFormat, ml.monLocDaylightSavingTime,
519
        h.harbourCd, h.harbourNm, ml.status.statusCd, ml.positionningSystem.posSystemId
520
521
522
      FROM
        CampaignImpl c
        INNER JOIN c.programs p
PECQUOT's avatar
   
PECQUOT committed
523
524
        INNER JOIN p.monLocProgs mlprog
        INNER JOIN mlprog.monitoringLocation ml
PECQUOT's avatar
   
PECQUOT committed
525
        LEFT JOIN ml.harbour h
526
527
528
529
530
531
532
533
534
535
      WHERE
        c.campaignId = :campaignId
        AND  (:programCode is null OR p.progCd = :programCode)
    ]]>
    <query-param name="campaignId" type="java.lang.Integer"/>
    <query-param name="programCode" type="java.lang.String"/>
  </query>
  
  <query name="allMonitoringLocations">
    <![CDATA[
PECQUOT's avatar
   
PECQUOT committed
536
      SELECT ml.monLocId, ml.monLocNm, ml.monLocBathym, ml.monLocCm, ml.monLocLb, ml.monLocUtFormat, ml.monLocDaylightSavingTime,
537
        h.harbourCd, h.harbourNm, ml.status.statusCd, ml.positionningSystem.posSystemId
538
      FROM MonitoringLocationImpl ml
PECQUOT's avatar
   
PECQUOT committed
539
      LEFT JOIN ml.harbour h
540
      WHERE ml.status.statusCd IN (:statusCodes)
541
542
543
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
PECQUOT's avatar
   
PECQUOT committed
544
545
546
547

  <query name="monitoringLocationsByIds">
    <![CDATA[
      SELECT ml.monLocId, ml.monLocNm, ml.monLocBathym, ml.monLocCm, ml.monLocLb, ml.monLocUtFormat, ml.monLocDaylightSavingTime,
548
        h.harbourCd, h.harbourNm, ml.status.statusCd, ml.positionningSystem.posSystemId
PECQUOT's avatar
   
PECQUOT committed
549
      FROM MonitoringLocationImpl ml
PECQUOT's avatar
   
PECQUOT committed
550
      LEFT JOIN ml.harbour h
PECQUOT's avatar
   
PECQUOT committed
551
552
553
554
555
      WHERE ml.monLocId IN (:locationIds)
    ]]>
    <query-param name="locationIds" type="java.lang.String"/>
  </query>

556
557
558
  <query name="monitoringLocationById">
    <![CDATA[
      SELECT ml.monLocId, ml.monLocNm, ml.monLocBathym, ml.monLocCm, ml.monLocLb, ml.monLocUtFormat, ml.monLocDaylightSavingTime,
559
        h.harbourCd, h.harbourNm, ml.status.statusCd, ml.positionningSystem.posSystemId
560
      FROM MonitoringLocationImpl ml
PECQUOT's avatar
   
PECQUOT committed
561
      LEFT JOIN ml.harbour h
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
      WHERE ml.monLocId = :monitoringLocationId
    ]]>
    <query-param name="monitoringLocationId" type="java.lang.Integer"/>
  </query>

  <query name="allMonitoringLocationPoints">
    <![CDATA[
      SELECT monLocId, monLocPosition
      FROM MonLocPointImpl
    ]]>
  </query>

  <query name="allMonitoringLocationLines">
    <![CDATA[
      SELECT monLocId, monLocPosition
      FROM MonLocLineImpl
    ]]>
  </query>

  <query name="allMonitoringLocationAreas">
    <![CDATA[
      SELECT monLocId, monLocPosition
      FROM MonLocAreaImpl
    ]]>
  </query>

  <query name="positionByLocationId">
    <![CDATA[
      SELECT COALESCE(mla.monLocPosition, mll.monLocPosition, mlp.monLocPosition)
      FROM MonitoringLocationImpl ml
PECQUOT's avatar
   
PECQUOT committed
592
593
594
      LEFT JOIN ml.monLocPoints mlp
      LEFT JOIN ml.monLocLines mll
      LEFT JOIN ml.monLocAreas mla
595
596
597
598
599
      WHERE ml.monLocId = :monitoringLocationId
    ]]>
    <query-param name="monitoringLocationId" type="java.lang.Integer"/>
  </query>

PECQUOT's avatar
   
PECQUOT committed
600
601
602
603
604
605
606
607
608
  <query name="allHarbours">
    <![CDATA[
      SELECT harbourCd, harbourNm
      FROM HarbourImpl
      WHERE status.statusCd IN (:statusCodes)
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>

609
610
611
612
  <query name="allOrderItemTypes">
    <![CDATA[
      SELECT o.orderItemTypeCd, o.orderItemTypeNm
      FROM OrderItemTypeImpl o
PECQUOT's avatar
   
PECQUOT committed
613
      WHERE o.status.statusCd IN (:statusCodes)
614
    ]]>
PECQUOT's avatar
   
PECQUOT committed
615
    <query-param name="statusCodes" type="java.lang.String"/>
616
  </query>
PECQUOT's avatar
   
PECQUOT committed
617

618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
  <query name="allOrderItemsByTypeCode">
    <![CDATA[
      SELECT o.orderItemId, o.orderItemNm
      FROM OrderItemImpl o
      WHERE o.orderItemTypeCd = :typeCode
      ORDER BY o.orderItemNumber
    ]]>
    <query-param name="typeCode" type="java.lang.String"/>
  </query>
  
  <query name="allPositioningSystems">
    <![CDATA[
      SELECT posSystemId, posSystemNm, posSystemCoordPrecision
      FROM PositionningSystemImpl
    ]]>
  </query>
  
  <query name="positioningSystemById">
    <![CDATA[
      SELECT posSystemId, posSystemNm, posSystemCoordPrecision
      FROM PositionningSystemImpl
      WHERE posSystemId = :posSystemId
    ]]>
    <query-param name="posSystemId" type="java.lang.Integer"/>
  </query>
  
  <query name="allTaxonGroup">
    <![CDATA[
646
647
648
649
650
651
      SELECT tg.taxonGroupId,
              tg.taxonGroupLb,
              tg.taxonGroupNm,
              tg.taxonGroupCm,
              tg.taxonGroupExclus,
              tg.taxonGroupUpdate,
652
              tg.taxonGroupType.taxonGroupTypeNm,
653
654
655
656
              p.taxonGroupId,
              p.taxonGroupLb,
              p.taxonGroupNm,
              tg.status.statusCd
657
      FROM TaxonGroupImpl tg
658
      LEFT JOIN tg.parentTaxonGroup p
659
      WHERE tg.status.statusCd IN (:statusCodes)
660
      AND tg.taxonGroupType.taxonGroupTypeCd = :taxonGroupTypeCode
661
662
      ORDER BY
        tg.taxonGroupNm
663
    ]]>
664
    <query-param name="statusCodes" type="java.lang.String"/>
665
    <query-param name="taxonGroupTypeCode" type="java.lang.String"/>
666
667
668
669
  </query>
  
  <query name="taxonGroupById">
    <![CDATA[
670
671
672
673
674
675
      SELECT tg.taxonGroupId,
              tg.taxonGroupLb,
              tg.taxonGroupNm,
              tg.taxonGroupCm,
              tg.taxonGroupExclus,
              tg.taxonGroupUpdate,
676
              tg.taxonGroupType.taxonGroupTypeNm,
677
678
679
680
              p.taxonGroupId,
              p.taxonGroupLb,
              p.taxonGroupNm,
              tg.status.statusCd
681
      FROM TaxonGroupImpl tg
682
      LEFT JOIN tg.parentTaxonGroup p
683
      WHERE tg.taxonGroupId = :taxonGroupId
684
685
686
687
688
689
      ORDER BY
        tg.taxonGroupNm
    ]]>
    <query-param name="taxonGroupId" type="java.lang.Integer"/>
  </query>
  
690
  <query name="taxonGroupsByCriteria">
691
    <![CDATA[
692
693
694
695
696
697
      SELECT tg.taxonGroupId,
              tg.taxonGroupLb,
              tg.taxonGroupNm,
              tg.taxonGroupCm,
              tg.taxonGroupExclus,
              tg.taxonGroupUpdate,
698
              tg.taxonGroupType.taxonGroupTypeNm,
699
700
701
702
              p.taxonGroupId,
              p.taxonGroupLb,
              p.taxonGroupNm,
              tg.status.statusCd
703
      FROM TaxonGroupImpl tg
704
      LEFT JOIN tg.parentTaxonGroup p
705
706
707
708
      WHERE (:parentTaxonGroupId is null
            OR p.taxonGroupId = :parentTaxonGroupId)
      AND (:label is null OR lower(tg.taxonGroupLb) like lower(concat('%', :label, '%')))
      AND (:name is null OR lower(tg.taxonGroupNm) like lower(concat('%', :name, '%')))
PECQUOT's avatar
   
PECQUOT committed
709
      AND (:strictName is null OR lower(tg.taxonGroupNm) = lower(:strictName))
710
      AND tg.status.statusCd IN (:statusCodes)
711
      AND tg.taxonGroupType.taxonGroupTypeCd = :taxonGroupTypeCode
712
713
714
      ORDER BY
        tg.taxonGroupNm
    ]]>
715
716
    <query-param name="parentTaxonGroupId" type="java.lang.Integer"/>
    <query-param name="label" type="java.lang.String"/>
717
    <query-param name="name" type="java.lang.String"/>
PECQUOT's avatar
   
PECQUOT committed
718
    <query-param name="strictName" type="java.lang.String"/>
719
    <query-param name="statusCodes" type="java.lang.String"/>
720
    <query-param name="taxonGroupTypeCode" type="java.lang.String"/>
721
722
  </query>
  
723
724
725
726
  <query name="allTaxonName">
    <![CDATA[
      SELECT
        tn.taxonNameId,
727
728
729
730
731
732
733
734
735
736
737
738
739
740
        tn.taxonNameCompleteNm,
        tn.taxonNameCm,
        tn.taxonNameIsRefer,
        tn.taxonNameIsVirtual,
        tn.taxonNameObsol,
        tn.taxonNameTempor,
        tn.referenceTaxon.id,
        p.taxonNameId,
        l.taxLevelCd,
        l.taxLevelLb,
        l.taxLevelNm,
        l.taxLevelNb,
        c.citId,
        c.citNm
741
742
      FROM
        TaxonNameImpl tn
743
744
        LEFT JOIN tn.taxonomicLevel l
        LEFT JOIN tn.parentTaxonName p
745
        LEFT JOIN tn.citId c
746
      ORDER BY
747
        tn.taxonNameCompleteNm
748
749
    ]]>
  </query>
PECQUOT's avatar
   
PECQUOT committed
750

PECQUOT's avatar
   
PECQUOT committed
751
752
753
754
755
756
757
  <query name="taxonNameIdsWithTaxonGroupId">
    <![CDATA[
      SELECT
        tghr.taxonGroup.taxonGroupId,
        tn.taxonNameId
      FROM
        TaxonNameImpl tn
758
        LEFT JOIN tn.taxonGroupHistoricalRecords tghr
PECQUOT's avatar
   
PECQUOT committed
759
      WHERE (tghr.taxonGroupHistStartDt is null
760
        OR tghr.taxonGroupHistStartDt <= :referenceDate)
PECQUOT's avatar
   
PECQUOT committed
761
      AND (tghr.taxonGroupHistRecordEndDt is null
762
        OR tghr.taxonGroupHistRecordEndDt >= :referenceDate)
763
      AND tghr.taxonGroup.taxonGroupType.taxonGroupTypeCd = :taxonGroupTypeCode
PECQUOT's avatar
   
PECQUOT committed
764
    ]]>
765
    <query-param name="referenceDate" type="java.util.Date"/>
766
    <query-param name="taxonGroupTypeCode" type="java.lang.String"/>
PECQUOT's avatar
   
PECQUOT committed
767
768
  </query>

769
770
  <query name="taxonNameById">
    <![CDATA[
771
      SELECT
772
        tn.taxonNameId,
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
        tn.taxonNameCompleteNm,
        tn.taxonNameCm,
        tn.taxonNameIsRefer,
        tn.taxonNameIsVirtual,
        tn.taxonNameObsol,
        tn.taxonNameTempor,
        tn.referenceTaxon.id,
        p.id,
        l.taxLevelCd,
        l.taxLevelLb,
        l.taxLevelNm,
        l.taxLevelNb,
        c.citId,
        c.citNm
      FROM
        TaxonNameImpl tn
789
790
        INNER JOIN tn.taxonomicLevel l
        LEFT JOIN tn.parentTaxonName p
791
        LEFT JOIN tn.citId c
792
793
      WHERE tn.taxonNameId = :taxonNameId
      ORDER BY
794
        tn.taxonNameCompleteNm
795
796
797
    ]]>
    <query-param name="taxonNameId" type="java.lang.Integer"/>
  </query>
PECQUOT's avatar
   
PECQUOT committed
798

799
800
  <query name="taxonNameByReferenceId">
    <![CDATA[
801
      SELECT
802
        tn.taxonNameId,
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
        tn.taxonNameCompleteNm,
        tn.taxonNameCm,
        tn.taxonNameIsRefer,
        tn.taxonNameIsVirtual,
        tn.taxonNameObsol,
        tn.taxonNameTempor,
        tn.referenceTaxon.id,
        p.id,
        l.taxLevelCd,
        l.taxLevelLb,
        l.taxLevelNm,
        l.taxLevelNb,
        c.citId,
        c.citNm
      FROM
        TaxonNameImpl tn
819
820
        INNER JOIN tn.taxonomicLevel l
        LEFT JOIN tn.parentTaxonName p
821
        LEFT JOIN tn.citId c
822
823
      WHERE tn.referenceTaxon.id = :taxonReferenceId
      AND tn.taxonNameIsRefer = '1'
824
      AND tn.taxonNameObsol = '0'
825
826
      ORDER BY
        tn.taxonNameCompleteNm
827
828
829
830
    ]]>
    <query-param name="taxonReferenceId" type="java.lang.Integer"/>
  </query>
  
831
  <query name="taxonNamesByCriteria">
832
    <![CDATA[
833
      SELECT
834
        tn.taxonNameId,
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
        tn.taxonNameCompleteNm,
        tn.taxonNameCm,
        tn.taxonNameIsRefer,
        tn.taxonNameIsVirtual,
        tn.taxonNameObsol,
        tn.taxonNameTempor,
        tn.referenceTaxon.id,
        p.id,
        l.taxLevelCd,
        l.taxLevelLb,
        l.taxLevelNm,
        l.taxLevelNb,
        c.citId,
        c.citNm
      FROM
        TaxonNameImpl tn
851
852
        INNER JOIN tn.taxonomicLevel l
        LEFT JOIN tn.parentTaxonName p
853
854
        LEFT JOIN tn.citId c
      WHERE (:name is null OR lower(tn.taxonNameCompleteNm) like lower(concat('%', :name, '%')))
PECQUOT's avatar
   
PECQUOT committed
855
      AND (:strictName is null OR lower(tn.taxonNameCompleteNm) = lower(:strictName))
856
      AND (:levelCd is null OR l.taxLevelCd = :levelCd)
857
      ORDER BY
858
        tn.taxonNameCompleteNm
859
860
    ]]>
    <query-param name="name" type="java.lang.String"/>
PECQUOT's avatar
   
PECQUOT committed
861
    <query-param name="strictName" type="java.lang.String"/>
862
    <query-param name="levelCd" type="java.lang.String"/>
863
864
  </query>
  
PECQUOT's avatar
   
PECQUOT committed
865
866
  <query name="alternateTaxonCode">
    <![CDATA[
PECQUOT's avatar
   
PECQUOT committed
867
      SELECT at.taxonName.taxonNameId, at.alternTaxonCd
PECQUOT's avatar
   
PECQUOT committed
868
869
870
871
872
873
      FROM AlternativeTaxonImpl at
      WHERE at.alternativeTaxonOrigin.alternTaxonOriginCd = :originCode
    ]]>
    <query-param name="originCode" type="java.lang.String"/>
  </query>
  
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
   <query name="compositeTaxonNamesByTaxonNameId">
    <![CDATA[
      SELECT
        tn.taxonNameId,
        tn.taxonNameCompleteNm,
        tn.taxonNameCm,
        tn.taxonNameIsRefer,
        tn.taxonNameIsVirtual,
        tn.taxonNameObsol,
        tn.taxonNameTempor,
        tn.referenceTaxon.id,
        p.id,
        l.taxLevelCd,
        l.taxLevelLb,
        l.taxLevelNm,
        l.taxLevelNb,
        c.citId,
        c.citNm
      FROM
        TaxonNameImpl ref
        INNER JOIN ref.referenceTaxon.virtualComponents vc
        INNER JOIN vc.virtualComponentPk.taxonName tn
896
897
        INNER JOIN tn.taxonomicLevel l
        LEFT JOIN tn.parentTaxonName p
898
899
900
901
902
903
904
905
906
        LEFT JOIN tn.citId c
      WHERE ref.taxonNameId = :taxonNameId
      AND ref.taxonNameIsVirtual = '1'
      ORDER BY
        tn.taxonNameCompleteNm
    ]]>
    <query-param name="taxonNameId" type="java.lang.Integer"/>
  </query>
  
907
908
909
910
911
912
913
914
915
916
917
918
919
  <query name="allTaxonomicLevels">
    <![CDATA[
      SELECT taxLevelCd, taxLevelLb, taxLevelNm, taxLevelNb
      FROM TaxonomicLevelImpl
    ]]>
  </query>
  
  <query name="allCitations">
    <![CDATA[
      SELECT citId, citNm
      FROM CitationImpl
    ]]>
  </query>
920
  
PECQUOT's avatar
   
PECQUOT committed
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
  <query name="allPhotoTypes">
    <![CDATA[
      SELECT photoTypeCd, photoTypeNm, photoTypeDc, status.statusCd
      FROM PhotoTypeImpl
      WHERE status.statusCd IN (:statusCodes)
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>

  <query name="photoTypeByCode">
    <![CDATA[
      SELECT photoTypeCd, photoTypeNm, photoTypeDc, status.statusCd
      FROM PhotoTypeImpl
      WHERE photoTypeCd = :photoTypeCode
    ]]>
    <query-param name="photoTypeCode" type="java.lang.String"/>
  </query>

939
940
941
942
  <query name="allParameterGroups">
    <![CDATA[
      SELECT parGroupId, parGroupNm, parGroupDc, status.statusCd, parentParGroupId.parGroupId
      FROM ParameterGroupImpl
943
      WHERE status.statusCd IN (:statusCodes)
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="parameterGroupById">
    <![CDATA[
      SELECT parGroupId, parGroupNm, parGroupDc, status.statusCd, parentParGroupId.parGroupId
      FROM ParameterGroupImpl
      WHERE parGroupId = :parameterGroupId
    ]]>
    <query-param name="parameterGroupId" type="java.lang.Integer"/>
  </query>
  
  <query name="allParameters">
    <![CDATA[
      SELECT parCd, parNm, parDc, parIsQualitative, parIsCalculated, parIsTaxonomic, status.statusCd, parGroupId.parGroupId
      FROM ParameterImpl
961
      WHERE status.statusCd IN (:statusCodes)
962
963
964
965
966
967
968
969
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="parameterByCode">
    <![CDATA[
      SELECT parCd, parNm, parDc, parIsQualitative, parIsCalculated, parIsTaxonomic, status.statusCd, parGroupId.parGroupId
      FROM ParameterImpl
PECQUOT's avatar
   
PECQUOT committed
970
      WHERE upper(parCd) = upper(:parameterCode)
971
972
973
974
    ]]>
    <query-param name="parameterCode" type="java.lang.String"/>
  </query>
  
975
976
977
978
  <query name="parametersByCriteria">
    <![CDATA[
      SELECT parCd, parNm, parDc, parIsQualitative, parIsCalculated, parIsTaxonomic, status.statusCd, parGroupId.parGroupId
      FROM ParameterImpl
PECQUOT's avatar
   
PECQUOT committed
979
      WHERE (:parameterCode is null OR upper(parCd) = upper(:parameterCode))
980
981
982
983
984
985
986
987
      AND (:parameterGroupId is null OR parGroupId.parGroupId = :parameterGroupId)
      AND status.statusCd IN (:statusCodes)
    ]]>
    <query-param name="parameterCode" type="java.lang.String"/>
    <query-param name="parameterGroupId" type="java.lang.Integer"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
988
989
990
991
  <query name="allQualitativeValuesByParameterCode">
    <![CDATA[
      SELECT qualValueId, qualValueNm, qualValueDc, status.statusCd
      FROM QualitativeValueImpl
992
      WHERE status.statusCd IN (:statusCodes) AND parameter.parCd = :parameterCode
993
994
995
996
997
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
    <query-param name="parameterCode" type="java.lang.String"/>
  </query>
  
Lionel Touseau's avatar
Lionel Touseau committed
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
  <query name="allQualitativeValuesByPmfmId">
    <![CDATA[
      SELECT qv.qualValueId, qv.qualValueNm, qv.qualValueDc, qv.status.statusCd
      FROM PmfmQualValueImpl pqv
        INNER JOIN pqv.pmfmQualValuePk.qualitativeValue qv
        INNER JOIN pqv.pmfmQualValuePk.pmfm pmfm
      WHERE qv.status.statusCd IN (:statusCodes) AND pmfm.pmfmId = :pmfmId
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
    <query-param name="pmfmId" type="java.lang.Integer"/>
  </query>
  
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
  <query name="qualitativeValueById">
    <![CDATA[
      SELECT qualValueId, qualValueNm, qualValueDc, status.statusCd
      FROM QualitativeValueImpl
      WHERE qualValueId = :qualitativeValueId
    ]]>
    <query-param name="qualitativeValueId" type="java.lang.Integer"/>
  </query>
  
  <query name="allMatrices">
    <![CDATA[
      SELECT matrixId, matrixNm, matrixDc, status.statusCd
      FROM MatrixImpl
1023
      WHERE status.statusCd IN (:statusCodes)
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="matrixById">
    <![CDATA[
      SELECT matrixId, matrixNm, matrixDc, status.statusCd
      FROM MatrixImpl
      WHERE matrixId = :matrixId
    ]]>
    <query-param name="matrixId" type="java.lang.Integer"/>
  </query>
  
PECQUOT's avatar
   
PECQUOT committed
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
  <query name="matrixByCriteria">
    <![CDATA[
      SELECT matrixId, matrixNm, matrixDc, status.statusCd
      FROM MatrixImpl
      WHERE status.statusCd IN (:statusCodes)
      AND (:matrixId IS NULL OR matrixId = :matrixId)
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
    <query-param name="matrixId" type="java.lang.Integer"/>
  </query>

1048
1049
1050
1051
1052
  <query name="allFractions">
    <![CDATA[
      SELECT f.fractionId, f.fractionNm, f.fractionDc, f.status.statusCd, m.matrixId
      FROM FractionImpl f
      LEFT JOIN f.matrixes m
1053
      WHERE f.status.statusCd IN (:statusCodes)
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
      ORDER BY f.fractionId
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="fractionById">
    <![CDATA[
      SELECT f.fractionId, f.fractionNm, f.fractionDc, f.status.statusCd, m.matrixId
      FROM FractionImpl f
      LEFT JOIN f.matrixes m
      WHERE f.fractionId = :fractionId
    ]]>
    <query-param name="fractionId" type="java.lang.Integer"/>
  </query>
  
PECQUOT's avatar
   
PECQUOT committed
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
  <query name="fractionByCriteria">
    <![CDATA[
      SELECT f.fractionId, f.fractionNm, f.fractionDc, f.status.statusCd, m.matrixId
      FROM FractionImpl f
      LEFT JOIN f.matrixes m
      WHERE f.status.statusCd IN (:statusCodes)
      AND (:fractionId IS NULL OR f.fractionId = :fractionId)
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
    <query-param name="fractionId" type="java.lang.Integer"/>
  </query>

1081
1082
  <query name="fractionsByMatrixId">
    <![CDATA[
PECQUOT's avatar
   
PECQUOT committed
1083
      SELECT distinct f.fractionId, f.fractionNm, f.fractionDc, f.status.statusCd, m.matrixId
1084
1085
1086
1087
1088
1089
1090
      FROM FractionImpl f
      LEFT JOIN f.matrixes m
      WHERE m.matrixId = :matrixId
    ]]>
    <query-param name="matrixId" type="java.lang.Integer"/>
  </query>
  
1091
1092
1093
1094
  <query name="allMethods">
    <![CDATA[
      SELECT methodId, methodNm, methodDc, methodRef, methodRk, methodCondition, methodPrepar, methodConserv, status.statusCd
      FROM MethodImpl
1095
      WHERE status.statusCd IN (:statusCodes)
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="methodById">
    <![CDATA[
      SELECT methodId, methodNm, methodDc, methodRef, methodRk, methodCondition, methodPrepar, methodConserv, status.statusCd
      FROM MethodImpl
      WHERE methodId = :methodId
    ]]>
    <query-param name="methodId" type="java.lang.Integer"/>
  </query>
PECQUOT's avatar
   
PECQUOT committed
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119

  <query name="methodsByCriteria">
    <![CDATA[
      SELECT methodId, methodNm, methodDc, methodRef, methodRk, methodCondition, methodPrepar, methodConserv, status.statusCd
      FROM MethodImpl
      WHERE status.statusCd IN (:statusCodes)
      AND (:methodId IS NULL OR methodId = :methodId)
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
    <query-param name="methodId" type="java.lang.Integer"/>
  </query>

1120
1121
1122
1123
  <query name="allUnits">
    <![CDATA[
      SELECT u.unitId, u.unitNm, u.unitSymbol, u.status.statusCd
      FROM UnitImpl u
1124
      WHERE u.status.statusCd IN (:statusCodes)
1125
1126
1127
1128
1129
1130
1131
1132
1133
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="unitsByCriteria">
    <![CDATA[
      SELECT u.unitId, u.unitNm, u.unitSymbol, u.status.statusCd
      FROM UnitImpl u
      WHERE (:unitId is null OR u.unitId = :unitId)
1134
      AND u.status.statusCd IN (:statusCodes)
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
    ]]>
    <query-param name="unitId" type="java.lang.Integer"/>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>
  
  <query name="unitById">
    <![CDATA[
      SELECT u.unitId, u.unitNm, u.unitSymbol, u.status.statusCd
      FROM UnitImpl u
      WHERE u.unitId = :unitId
    ]]>
    <query-param name="unitId" type="java.lang.Integer"/>
  </query>
  
  <query name="allPmfms">
    <![CDATA[
1151
      SELECT
LAVENIER's avatar
LAVENIER committed
1152
          pmfmId,
PECQUOT's avatar
   
PECQUOT committed
1153
1154
	      status.statusCd,
	      parameter.parCd,
LAVENIER's avatar
LAVENIER committed
1155
          matrix.matrixId,
PECQUOT's avatar
   
PECQUOT committed
1156
1157
1158
	      fraction.fractionId,
	      method.methodId,
	      unit.unitId
1159
      FROM
PECQUOT's avatar
   
PECQUOT committed
1160
        PmfmImpl
1161
      WHERE
PECQUOT's avatar
   
PECQUOT committed
1162
        status.statusCd IN (:statusCodes)
1163
1164
1165
1166
1167
    ]]>
    <query-param name="statusCodes" type="java.lang.String"/>
  </query>

  <query name="pmfmsByCriteria">
1168
1169
    <![CDATA[
      SELECT pmfmId, 
PECQUOT's avatar
   
PECQUOT committed
1170
            status.statusCd,
1171
1172
1173
1174
1175
1176
            parameter.parCd, 
            matrix.matrixId, 
            fraction.fractionId, 
            method.methodId, 
            unit.unitId 
      FROM PmfmImpl
Lionel Touseau's avatar
Lionel Touseau committed
1177
1178
      WHERE status.statusCd IN (:statusCodes)
      AND (:parameterCode is null OR parameter.parCd = :parameterCode)
1179
1180
1181
1182
      AND (:pmfmName is null OR lower(parameter.parNm) like lower(concat('%', :pmfmName, '%')))
      AND (:matrixId is null OR matrix.matrixId = :matrixId)
      AND (:fractionId is null OR fraction.fractionId = :fractionId)
      AND (:methodId is null OR method.methodId = :methodId)
1183
      AND (:unitId is null OR unit.unitId = :unitId)
1184
1185
1186
1187
1188
    ]]>
    <query-param name="parameterCode" type="java.lang.String"/>
    <query-param name="matrixId" type="java.lang.Integer"/>
    <query-param name="fractionId" type="java.lang.Integer"/>
    <query-param name="methodId" type="java.lang.Integer"/>
1189
    <query-param name="unitId" type="java.lang.Integer"/>
1190
    <query-param name="pmfmName" type="java.lang.String"/>
Lionel Touseau's avatar
Lionel Touseau committed
1191
    <query-param name="statusCodes" type="java.lang.String"/>
1192
1193
  </query>
  
1194
1195
1196
  <query name="pmfmById">
    <![CDATA[
      SELECT pmfmId, 
PECQUOT's avatar
   
PECQUOT committed
1197
1198
1199
1200
1201
1202
	      status.statusCd,
	      parameter.parCd,
	      matrix.matrixId,
	      fraction.fractionId,
	      method.methodId,
	      unit.unitId
1203
1204
1205
1206
1207
1208
1209
1210
1211
      FROM PmfmImpl p
      WHERE pmfmId = :pmfmId
    ]]>
    <query-param name="pmfmId" type="java.lang.Integer"/>
  </query>
  
  <query name="pmfmByIds">
    <![CDATA[
      SELECT pmfmId, 
PECQUOT's avatar
   
PECQUOT committed
1212
1213
1214
1215
1216
1217
        status.statusCd,
        parameter.parCd,
        matrix.matrixId,
        fraction.fractionId,
        method.methodId,
        unit.unitId
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
      FROM PmfmImpl p
      WHERE pmfmId IN (:pmfmIds)
    ]]>
    <query-param name="pmfmIds" type="java.lang.String"/>
  </query>
  
  <query name="allDepthLevels">
    <![CDATA[
      SELECT depthLevelId, depthLevelNm, depthLevelDc
      FROM DepthLevelImpl
      WHERE status.statusCd = :statusCode
    ]]>
    <query-param name="statusCode" type="java.lang.String"/>
  </query>
  
  <query name="depthLevelById">
    <![CDATA[
      SELECT depthLevelId, depthLevelNm, depthLevelDc
      FROM DepthLevelImpl
      WHERE status.statusCd = :statusCode 
      AND depthLevelId = :depthLevelId
    ]]>
    <query-param name="statusCode" type="java.lang.String"/>
    <query-param name="depthLevelId" type="java.lang.Integer"/>
  </query>
  
  <query name="allRuleList">
    <![CDATA[
1246
      SELECT ruleListCd, ruleListIsActive, ruleListFirstMonth, ruleListLastMonth, ruleListDc, status.statusCd
1247
1248
1249
1250
      FROM RuleListImpl
    ]]>
  </query>
  
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
  <query name="allRuleListWithProgramCode">
    <![CDATA[
      SELECT rl.ruleListCd, rl.ruleListIsActive, rl.ruleListFirstMonth, rl.ruleListLastMonth, rl.ruleListDc, rl.status.statusCd
      FROM RuleListImpl rl
      INNER JOIN rl.programs p
      WHERE p.progCd = :programCode
    ]]>
    <query-param name="programCode" type="java.lang.String"/>
  </query>

1261
1262
  <query name="ruleListByCode">
    <![CDATA[
1263
      SELECT ruleListCd, ruleListIsActive, ruleListFirstMonth, ruleListLastMonth, ruleListDc, status.statusCd
1264
      FROM RuleListImpl
PECQUOT's avatar
   
PECQUOT committed
1265
      WHERE upper(ruleListCd) = upper(:ruleListCode)
1266
1267
1268
    ]]>
    <query-param name="ruleListCode" type="java.lang.String"/>
  </query>
PECQUOT's avatar
PECQUOT committed
1269

1270
  <query name="programCodesByRuleListCode">
1271
    <![CDATA[
1272
      SELECT p.progCd
1273
1274
1275
1276
1277
1278
1279
      FROM RuleListImpl rl
      INNER JOIN rl.programs p
      WHERE rl.ruleListCd = :ruleListCode
    ]]>
    <query-param name="ruleListCode" type="java.lang.String"/>
  </query>
  
1280
  <query name="departmentIdsByRuleListCode">
1281
    <![CDATA[
1282
      SELECT d.depId
1283
1284
1285
1286
1287
1288
1289
      FROM RuleListImpl rl
      INNER JOIN rl.controledDepartments d
      WHERE rl.ruleListCd = :ruleListCode
    ]]>
    <query-param name="ruleListCode" type="java.lang.String"/>
  </query>
  
1290
  <query name="rulesForControlOnlyByRuleListCode">
1291
    <![CDATA[
PECQUOT's avatar
PECQUOT committed
1292
      SELECT r.ruleCd, r.ruleControledAttribut, r.ruleDc, r.ruleIsActive, r.ruleIsBlocking, r.ruleErrorMsg, r.function,
1293
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp 
PECQUOT's avatar
PECQUOT committed
1294
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdMinMax AND rp.functionParameter.functionParId = :functionParameterIdMin) AS minValue,
1295
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp 
PECQUOT's avatar
PECQUOT committed
1296
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdMinMax AND rp.functionParameter.functionParId = :functionParameterIdMax) AS maxValue,
PECQUOT's avatar
   
PECQUOT committed
1297
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp
PECQUOT's avatar
PECQUOT committed
1298
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdDateMinMax AND rp.functionParameter.functionParId = :functionParameterIdDateMin) AS minValue,
PECQUOT's avatar
   
PECQUOT committed
1299
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp
PECQUOT's avatar
PECQUOT committed
1300
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdDateMinMax AND rp.functionParameter.functionParId = :functionParameterIdDateMax) AS maxValue,
PECQUOT's avatar
   
PECQUOT committed
1301
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp
PECQUOT's avatar
PECQUOT committed
1302
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdIn AND rp.functionParameter.functionParId = :functionParameterIdIn) AS inValue
1303
1304
      FROM RuleListImpl rl
      INNER JOIN rl.rules r
1305
      LEFT JOIN r.rulePreconditions rp
1306
      LEFT JOIN r.ruleGroups rg
1307
      WHERE rl.ruleListCd = :ruleListCode
PECQUOT's avatar
   
PECQUOT committed
1308
      AND (:ruleIsActive is null OR r.ruleIsActive = :ruleIsActive)
1309
1310
1311
1312
1313
      AND rp.rulePrecondId IS NULL
      AND r.ruleCd NOT IN (
      	SELECT rp.usedRule.ruleCd
      	FROM RulePreconditionImpl rp
      	)
1314
      AND rg.ruleGroupId IS NULL
1315
1316
1317
1318
1319
    ]]>
    <query-param name="ruleListCode" type="java.lang.String"/>
    <query-param name="functionIdMinMax" type="java.lang.Integer"/>
    <query-param name="functionParameterIdMin" type="java.lang.Integer"/>
    <query-param name="functionParameterIdMax" type="java.lang.Integer"/>
PECQUOT's avatar
   
PECQUOT committed
1320
1321
1322
    <query-param name="functionIdDateMinMax" type="java.lang.Integer"/>
    <query-param name="functionParameterIdDateMin" type="java.lang.Integer"/>
    <query-param name="functionParameterIdDateMax" type="java.lang.Integer"/>
1323
1324
    <query-param name="functionIdIn" type="java.lang.Integer"/>
    <query-param name="functionParameterIdIn" type="java.lang.Integer"/>
PECQUOT's avatar
   
PECQUOT committed
1325
    <query-param name="ruleIsActive" type="java.lang.String"/>
1326
  </query>
1327

1328
  <query name="ruleByCode">
1329
    <![CDATA[
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
      SELECT r.ruleCd, r.ruleControledAttribut, r.ruleDc, r.ruleIsActive, r.ruleIsBlocking, r.ruleErrorMsg, r.function,
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdMinMax AND rp.functionParameter.functionParId = :functionParameterIdMin) AS minValue,
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdMinMax AND rp.functionParameter.functionParId = :functionParameterIdMax) AS maxValue,
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdDateMinMax AND rp.functionParameter.functionParId = :functionParameterIdDateMin) AS minValue,
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdDateMinMax AND rp.functionParameter.functionParId = :functionParameterIdDateMax) AS maxValue,
      (SELECT rp.ruleParValue FROM RuleParameterImpl rp
        WHERE rp.rule.ruleCd = r.ruleCd AND r.function.functionId = :functionIdIn AND rp.functionParameter.functionParId = :functionParameterIdIn) AS inValue
      FROM RuleImpl r
      WHERE r.ruleCd = :ruleCode
    ]]>
    <query-param name="ruleCode" type="java.lang.String"/>
    <query-param name="functionIdMinMax" type="java.lang.Integer"/>
    <query-param name="functionParameterIdMin" type="java.lang.Integer"/>
    <query-param name="functionParameterIdMax" type="java.lang.Integer"/>
    <query-param name="functionIdDateMinMax" type="java.lang.Integer"/>
    <query-param name="functionParameterIdDateMin" type="java.lang.Integer"/>
    <query-param name="functionParameterIdDateMax" type="java.lang.Integer"/>
    <query-param name="functionIdIn" type="java.lang.Integer"/>
    <query-param name="functionParameterIdIn" type="java.lang.Integer"/>
  </query>

  <query name="ruleExists">
    <![CDATA[
      FROM RuleImpl r
      WHERE upper(r.ruleCd) = upper(:ruleCode)
    ]]>
    <query-param name="ruleCode" type="java.lang.String"/>
  </query>

  <query name="rulePreconditionsByRuleListCode">
    <![CDATA[
      SELECT rp.rulePrecondId, rp.rulePrecondLb, rp.rulePrecondIsActive, rp.rulePrecondIsBidir, r.ruleCd, rp.usedRule.ruleCd
1366
1367
      FROM RuleListImpl rl
      INNER JOIN rl.rules r
1368
      inner join r.rulePreconditions rp
1369
      WHERE rl.ruleListCd = :ruleListCode
1370
      AND (:rulePreconditionIsActive is null OR rp.rulePrecondIsActive = :rulePreconditionIsActive)
1371
1372
    ]]>
    <query-param name="ruleListCode" type="java.lang.String"/>
1373
    <query-param name="rulePreconditionIsActive" type="java.lang.String"/>
1374
  </query>
1375

1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
  <query name="ruleGroupsByRuleListCode">
    <![CDATA[
      SELECT rg.ruleGroupId, rg.ruleGroupLb, rg.ruleGroupIsActive, rg.ruleGroupIsOr, r.ruleCd
      FROM RuleListImpl rl
      INNER JOIN rl.rules r
      inner join r.ruleGroups rg
      WHERE rl.ruleListCd = :ruleListCode
      AND (:ruleGroupIsActive is null OR rg.ruleGroupIsActive = :ruleGroupIsActive)
    ]]>
    <query-param name="ruleListCode" type="java.lang.String"/>
    <query-param name="ruleGroupIsActive" type="java.lang.String"/>
  </query>

1389
  <query name="activeRuleListCodesByCriteria">
PECQUOT's avatar
PECQUOT committed
1390
    <![CDATA[
PECQUOT's avatar
   
PECQUOT committed
1391
      SELECT DISTINCT rl.ruleListCd
PECQUOT's avatar
PECQUOT committed
1392
1393
1394
      FROM RuleListImpl rl
      LEFT JOIN rl.programs p
      LEFT JOIN rl.controledDepartments cd
PECQUOT's avatar
   
PECQUOT committed
1395
      WHERE rl.ruleListIsActive = '1'
1396
          AND p.progCd = :programCode
PECQUOT's avatar
PECQUOT committed
1397
          AND (cd.depId is null OR cd.depId = :departmentId)
PECQUOT's avatar
   
PECQUOT committed
1398
1399
          AND (rl.ruleListFirstMonth is null OR rl.ruleListFirstMonth <= :date)
          AND (rl.ruleListLastMonth is null OR rl.ruleListLastMonth >= :date)
PECQUOT's avatar
PECQUOT committed
1400
1401
1402
    ]]>
    <query-param name="programCode" type="java.lang.String"/>
    <query-param name="departmentId" type="java.lang.Integer"/>
PECQUOT's avatar
   
PECQUOT committed
1403
    <query-param name="date" type="java.util.Date"/>
PECQUOT's avatar
PECQUOT committed
1404
  </query>
1405
1406

  <query name="activeRuleListCodesByProgramCodes">
1407
    <![CDATA[