source: branches/3.19-stable/src/core/common-queries.xml @ 8099

Last change on this file since 8099 was 8099, checked in by Nicklas Nordborg, 9 months ago

References #2290: Allow plug-in configurations to be disabled

Added a filter to get rid of disabled plug-in configurations when starting a new job.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 98.5 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 8099 2022-12-20 13:16:51Z nicklas $
5
6  Copyright (C) 2005 Samuel Andersson, Johan Enell, Nicklas Nordborg
7  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
8  Copyright (C) 2007 Johan Enell, Nicklas Nordborg, Martin Svensson
9
10  This file is part of BASE - BioArray Software Environment.
11  Available at http://base.thep.lu.se/
12
13  BASE is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License
15  as published by the Free Software Foundation; either version 3
16  of the License, or (at your option) any later version.
17
18  BASE is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  GNU General Public License for more details.
22
23  You should have received a copy of the GNU General Public License
24  along with BASE. If not, see <http://www.gnu.org/licenses/>.
25-->
26<!--
27  This XML file contains HQL and SQL queries that are common
28  to all databases. If one of them happens to fail on your
29  particular database, do not modify this file. Instead, you
30  should add an entry into the file that is specific for your
31  particular database that overrides the query in this file.
32  For example, for PostgreSQL modify the postgresql-queries.xml.
33-->
34<predefined-queries>
35
36  <query id="LOAD_SYSTEM_ITEMS" type="HQL">
37    <sql>
38      SELECT item.id, item.systemId
39      FROM net.sf.basedb.core.data.SystemData item
40      WHERE NOT item.systemId IS NULL
41    </sql>
42    <description>
43      Load the ID and systemID, in that order, of all SystemData
44      items.
45    </description>
46  </query>
47
48  <query id="LOAD_ROLE_KEY_IDS" type="HQL">
49    <sql>
50      SELECT rk.id, rk.itemType
51      FROM RoleKeyData rk
52    </sql>
53    <description>
54      Load the ID and itemType, in that order, of all RoleKeyData
55      items.
56    </description>
57  </query>
58
59  <query id="GET_USER_FOR_LOGIN" type="HQL">
60    <sql>
61      SELECT usr
62      FROM UserData usr
63      WHERE usr.login = :login
64    </sql>
65    <description>
66      Load a user when you know the login.
67    </description>
68  </query>
69 
70  <query id="GET_USER_FOR_EXTERNAL_ID" type="HQL">
71    <sql>
72      SELECT usr
73      FROM UserData usr
74      WHERE usr.externalId = :externalId
75    </sql>
76    <description>
77      Load a user when you know the external id.
78    </description>
79  </query>
80
81  <query id="GET_CLIENT_FOR_EXTERNAL_ID" type="HQL">
82    <sql>
83      SELECT cli
84      FROM ClientData cli
85      WHERE cli.externalId = :externalId
86    </sql>
87    <description>
88      Load a client when you know the external ID.
89    </description>
90  </query>
91 
92  <query id="GET_ROLE_IDS_FOR_USER" type="HQL">
93    <sql>
94      SELECT ur.roleId
95      FROM UserRoles ur
96      WHERE ur.userId = :userId
97    </sql>
98    <description>
99      Load the ID of all roles where the given user is a member.
100    </description>
101  </query>
102
103  <query id="GET_GROUP_IDS_FOR_USER" type="HQL">
104    <sql>
105      SELECT ug.groupId
106      FROM UserGroups ug
107      WHERE ug.userId = :userId
108    </sql>
109    <description>
110      Load the ID of all groups where the given user is a direct member.
111    </description>
112  </query>
113 
114  <query id="GET_QUOTA_GROUP_ID_FOR_USER" type="HQL">
115    <sql>
116      SELECT usr.quotaGroup.id
117      FROM UserData usr
118      WHERE usr.id = :userId
119    </sql>
120    <description>
121      Load the ID of a user's quota group.
122    </description>
123  </query>
124
125  <query id="GET_PARENTGROUPS_IDS_FOR_GROUPS" type="HQL">
126    <sql>
127      SELECT DISTINCT gg.parentId
128      FROM GroupGroups gg
129      WHERE gg.childId IN (:groups)
130      AND gg.parentId NOT IN (:groups)
131    </sql>
132    <description>
133      Load the ID of all groups that are parents to at least one of
134      the given groups, excluding the given groups.
135    </description>
136  </query>
137 
138  <query id="GET_CHILDGROUPS_IDS_FOR_GROUPS" type="HQL">
139    <sql>
140      SELECT DISTINCT gg.childId
141      FROM GroupGroups gg
142      WHERE gg.parentId IN (:groups)
143      AND gg.childId NOT IN (:groups)
144    </sql>
145    <description>
146      Load the ID of all groups that are children to at least one of
147      the given groups, excluding the given groups.
148    </description>
149  </query>
150
151  <query id="GET_PROJECT_IDS_FOR_OWNER" type="HQL">
152    <sql>
153      SELECT p.id
154      FROM ProjectData p
155      WHERE p.owner = :userId
156    </sql>
157    <description>
158      Load the ID of all projects where the given user is the owner.
159    </description>
160  </query>
161
162  <query id="GET_PROJECTINFO_FOR_USER" type="HQL">
163    <sql>
164      SELECT up
165      FROM UserProjects up
166      WHERE up.userId = :userId
167    </sql>
168    <description>
169      Load the UserProjects of all projects where the given user is a member.
170    </description>
171  </query>
172
173  <query id="GET_PROJECTINFO_FOR_GROUPS" type="HQL">
174    <sql>
175      SELECT DISTINCT gp
176      FROM GroupProjects gp
177      WHERE gp.groupId IN (:groups)
178    </sql>
179    <description>
180      Load the GroupProjects of all projects where at least one of the given groups
181      is a member.
182    </description>
183  </query>
184
185  <query id="GET_USER_IDS_FOR_GROUPS" type="HQL">
186    <sql>
187      SELECT ug.userId
188      FROM UserGroups ug
189      WHERE ug.groupId IN (:groups)
190    </sql>
191    <description>
192      Load the ID of all users which is a member of at least one of the given groups.
193    </description>
194  </query>
195
196  <query id="GET_USER_IDS_FOR_QUOTAGROUPS" type="HQL">
197    <sql>
198      SELECT usr.id
199      FROM UserData usr
200      WHERE usr.quotaGroup.id IN (:groups)
201    </sql>
202    <description>
203      Load the ID of all users which has a quota group from one of the given groups.
204    </description>
205  </query>
206
207  <query id="GET_USER_IDS_FOR_PROJECT" type="HQL">
208    <sql>
209      SELECT up.userId
210      FROM UserProjects up
211      WHERE up.projectId = :projectId
212    </sql>
213    <description>
214      Load the ID of all users which are direct member of the given project
215    </description>
216  </query>
217
218  <query id="GET_GROUP_IDS_FOR_PROJECT" type="HQL">
219    <sql>
220      SELECT gp.groupId
221      FROM GroupProjects gp
222      WHERE gp.projectId = :projectId
223    </sql>
224    <description>
225      Load the ID of all groups which are direct member of the given project
226    </description>
227  </query>
228
229  <query id="GET_USERKEYS_FOR_USER" type="HQL">
230    <sql>
231      SELECT uk
232      FROM UserKeys uk
233      WHERE uk.userId = :userId
234    </sql>
235    <description>
236      Load the UserKeys for the given user.
237    </description>
238  </query>
239
240  <query id="GET_GROUPKEYS_FOR_GROUPS" type="HQL">
241    <sql>
242      SELECT gk
243      FROM GroupKeys gk
244      WHERE gk.groupId IN (:groups)
245    </sql>
246    <description>
247      Load the GroupKeys for the given groups.
248    </description>
249  </query>
250
251  <query id="GET_ROLEKEYS_FOR_USER" type="HQL">
252    <sql>
253      SELECT rk
254      FROM RoleKeys rk, UserRoles ur
255      WHERE rk.roleId = ur.roleId AND ur.userId = :userId
256      ORDER BY rk.keyId
257    </sql>
258    <description>
259      Load the RoleKeys for the roles where the given user is a member.
260    </description>
261  </query>
262
263  <query id="GET_PROJECTKEYS_FOR_PROJECT" type="HQL">
264    <sql>
265      SELECT pk
266      FROM ProjectKeys pk
267      WHERE pk.projectId = :projectId
268      ORDER BY pk.keyId
269    </sql>
270    <description>
271      Load the ProjectKeys for the given project. Sort by
272      keyId for fast lookup in array (Keyring class).
273    </description>
274  </query>
275 
276  <query id="GET_PROJECTKEYIDS_FOR_PROJECT" type="HQL">
277    <sql>
278      SELECT pk.keyId
279      FROM ProjectKeys pk
280      WHERE pk.projectId = :projectId
281    </sql>
282    <description>
283      Load the ID of ProjectKeys for the given project.
284    </description>
285  </query>
286
287  <query id="GET_PROJECTKEY_IDS_FOR_COUNT" type="HQL">
288    <sql>
289      SELECT pk.keyId FROM ProjectKeys pk
290      GROUP BY pk.keyId
291      HAVING count(pk.projectId) = :numPermissions
292    </sql>
293    <description>
294      Load the ID of all project keys which have permissions for the
295      specified number of projects.
296    </description>
297  </query>
298
299  <query id="FIND_USED_PROJECTKEY_IDS" type="HQL">
300    <sql>
301      SELECT DISTINCT sd.projectKey.id
302      FROM net.sf.basedb.core.data.ShareableData sd
303      WHERE NOT sd.projectKey IS NULL
304    </sql>
305    <description>
306      Load the ID of all project keys which are used by at least one
307      shareable item.
308    </description>
309  </query>
310 
311  <query id="SELECT_UNUSED_PROJECTKEYS" type="HQL">
312    <sql>
313      SELECT pk FROM ProjectKeyData pk
314      WHERE pk.id NOT IN (:used)
315    </sql>
316    <description>
317      Load all unused project keys given a list of the ID:s of all used
318      keys.
319    </description>
320  </query>
321
322  <query id="GET_ITEMKEY_IDS_FOR_USERCOUNT" type="HQL">
323    <sql>
324      SELECT ik.id FROM ItemKeyData ik
325      LEFT JOIN ik.users u
326      GROUP BY ik.id
327      HAVING COUNT(u.index) = :numPermissions
328    </sql>
329    <description>
330      Load the ID of all item keys which have permissions for the
331      specified number of users.
332    </description>
333  </query>
334
335  <query id="GET_ITEMKEY_IDS_FOR_GROUPCOUNT" type="HQL">
336    <sql>
337      SELECT ik.id FROM ItemKeyData ik
338      LEFT JOIN ik.groups g
339      WHERE ik.id IN (:candidates)
340      GROUP BY ik.id
341      HAVING count(g.index) = :numPermissions
342    </sql>
343    <description>
344      Load the ID of all item keys which have permissions for the
345      specified number of groups and are among the list of candidates.
346    </description>
347  </query>
348 
349  <query id="FIND_USED_ITEMKEY_IDS" type="HQL">
350    <sql>
351      SELECT DISTINCT sd.itemKey.id
352      FROM net.sf.basedb.core.data.ShareableData sd
353      WHERE NOT sd.itemKey IS NULL
354    </sql>
355    <description>
356      Load the ID of all item keys which are used by at least one
357      shareable item.
358    </description>
359  </query>
360 
361  <query id="SELECT_UNUSED_ITEMKEYS" type="HQL">
362    <sql>
363      SELECT ik FROM ItemKeyData ik
364      WHERE ik.id NOT IN (:used)
365    </sql>
366    <description>
367      Load all unused item keys given a list of the ID:s of all used
368      keys.
369    </description>
370  </query>
371
372  <query id="GET_USERS_FOR_QUOTAGROUP" type="HQL">
373    <sql>
374      SELECT {1}
375      FROM UserData usr
376      WHERE usr.quotaGroup = :theGroup
377    </sql>
378    <description>
379      Get users having the specified group as
380      their quota group.
381    </description>
382  </query>
383 
384  <query id="GET_USERS_FOR_QUOTA" type="HQL">
385    <sql>
386      SELECT {1}
387      FROM UserData u
388      WHERE u.quota = :quota
389    </sql>
390    <description>
391      A Hibernate query that gets users
392      that has been assigned a given quota.
393    </description>
394  </query>
395 
396  <query id="GET_GROUPS_FOR_QUOTA" type="HQL">
397    <sql>
398      SELECT {1}
399      FROM GroupData g
400      WHERE g.quota = :quota
401    </sql>
402    <description>
403      A Hibernate query that gets groups
404      that has been assigned a given quota.
405    </description>
406  </query>
407
408  <query id="GET_SHAREABLE_ITEMS_FOR_ITEMKEY" type="HQL">
409    <sql>
410      SELECT s
411      FROM net.sf.basedb.core.data.ShareableData s
412      WHERE s.itemKey = :itemKey
413    </sql>
414    <description>
415      Get all items beeing shared to the specified item key.
416    </description>
417  </query>
418
419  <query id="GET_SHAREABLE_ITEMS_FOR_PROJECTKEY" type="HQL">
420    <sql>
421      SELECT s
422      FROM net.sf.basedb.core.data.ShareableData s
423      WHERE s.projectKey = :projectKey
424    </sql>
425    <description>
426      Get all items beeing shared to the specified project key.
427    </description>
428  </query>
429 
430  <query id="GET_OWNABLE_ITEMS_FOR_USER" type="HQL">
431    <sql>
432      SELECT o
433      FROM net.sf.basedb.core.data.OwnableData o
434      WHERE o.owner = :user
435    </sql>
436    <description>
437      Get all items that are owned by the specified user.
438    </description>
439  </query>
440 
441  <query id="LOAD_USER_CLIENT_SETTINGS" type="HQL">
442    <sql>
443      SELECT s
444      FROM UserClientSettingData s
445      WHERE s.user = :user AND s.client = :client
446    </sql>
447    <description>
448      Load all settings for the specified user and client application.
449    </description>
450  </query>
451 
452  <query id="LOAD_USER_DEFAULT_SETTINGS" type="HQL">
453    <sql>
454      SELECT s
455      FROM UserDefaultSettingData s
456      WHERE s.user = :user
457    </sql>
458    <description>
459      Load all default settings for the specified user.
460    </description>
461  </query>
462
463  <query id="LOAD_CLIENT_DEFAULT_SETTINGS" type="HQL">
464    <sql>
465      SELECT s
466      FROM ClientDefaultSettingData s
467      WHERE s.client = :client
468    </sql>
469    <description>
470      Load all default settings for the specified client application.
471    </description>
472  </query>
473 
474  <query id="GET_MIME_TYPE_FROM_EXTENSION" type="HQL">
475    <sql>
476      SELECT s
477      FROM net.sf.basedb.core.data.MimeTypeData s
478      WHERE LOWER(s.extension) = LOWER(:extension)
479    </sql>
480    <description>
481      A Hibernate query that returns a MimeType given an extension.
482    </description>
483  </query>
484 
485  <query id="GET_TOTAL_DISKUSAGE_FOR_USER" type="HQL">
486    <sql>
487      SELECT sum(du.bytes)
488      FROM DiskUsageData du
489      WHERE du.user = :user
490      AND du.location = :location
491    </sql>
492    <description>
493      A Hibernate query that returns the total used quota
494      for the specified user at the specified location.
495    </description>
496  </query>
497 
498  <query id="GET_SPECIFIC_DISKUSAGE_FOR_USER" type="HQL">
499    <sql>
500      SELECT sum(du.bytes)
501      FROM DiskUsageData du
502      WHERE du.user = :user
503      AND du.location = :location
504      AND du.quotaType = :quotaType
505    </sql>
506    <description>
507      A Hibernate query that returns the used quota for the
508      specific quota type for the specified user at the
509      specified location.
510    </description>
511  </query>
512
513  <query id="GET_TOTAL_DISKUSAGE_FOR_GROUP" type="HQL">
514    <sql>
515      SELECT sum(du.bytes)
516      FROM DiskUsageData du
517      WHERE du.group = :group
518      AND du.location = :location
519    </sql>
520    <description>
521      A Hibernate query that returns the total used quota
522      for the specified group at the specified location.
523    </description>
524  </query>
525
526  <query id="GET_SPECIFIC_DISKUSAGE_FOR_GROUP" type="HQL">
527    <sql>
528      SELECT sum(du.bytes)
529      FROM DiskUsageData du
530      WHERE du.group = :group
531      AND du.location = :location
532      AND du.quotaType = :quotaType
533    </sql>
534    <description>
535      A Hibernate query that returns the used quota for the
536      specific quota type for the specified group at the
537      specified location.
538    </description>
539  </query>
540
541  <query id="GET_TOTAL_DISKUSAGE_SUMMARY" type="HQL">
542    <sql>
543      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
544      FROM DiskUsageData du
545      GROUP BY du.location, du.quotaType.systemId
546    </sql>
547    <description>
548      A Hibernate query that returns the total disk usage grouped
549      by location and quota type system id.
550    </description>
551  </query>
552
553  <query id="GET_DISKUSAGE_SUMMARY_FOR_USER" type="HQL">
554    <sql>
555      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
556      FROM DiskUsageData du
557      WHERE du.user = :user
558      GROUP BY du.location, du.quotaType.systemId
559    </sql>
560    <description>
561      A Hibernate query that returns the disk usage for a user grouped
562      by location and quota type system id.
563    </description>
564  </query>
565
566  <query id="GET_DISKUSAGE_SUMMARY_FOR_GROUP" type="HQL">
567    <sql>
568      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
569      FROM DiskUsageData du
570      WHERE du.group = :group
571      GROUP BY du.location, du.quotaType.systemId
572    </sql>
573    <description>
574      A Hibernate query that returns the disk usage for a group grouped
575      by location and quota type system id.
576    </description>
577  </query>
578 
579  <query id="GET_FILES_IN_DIRECTORY" type="HQL">
580    <sql>
581      SELECT {1}
582      FROM FileData f
583      WHERE f.directory = :directory
584    </sql>
585    <description>
586      A Hibernate query that gets the files
587      in a given directory.
588    </description>
589  </query>
590
591  <query id="GET_FILES_FOR_FILESERVER" type="HQL">
592    <sql>
593      SELECT {1}
594      FROM FileData f
595      WHERE f.fileServer = :fileServer
596    </sql>
597    <description>
598      A Hibernate query that gets the files
599      with a given file server.
600    </description>
601  </query>
602
603
604  <query id="GET_SUBDIRECTORIES_IN_DIRECTORY" type="HQL">
605    <sql>
606      SELECT {1}
607      FROM DirectoryData d
608      WHERE d.parent = :directory
609    </sql>
610    <description>
611      A Hibernate query that gets the subdirectories
612      in a given directory.
613    </description>
614  </query>
615 
616  <query id="GET_HOME_DIRECTORIES" type="HQL">
617    <sql>
618      SELECT {1}
619      FROM UserData usr
620      WHERE usr.homeDirectory = :directory
621    </sql>
622    <description>
623      A Hibernate query that gets the users having
624      the specified directory as home directory.
625    </description>
626  </query>
627 
628  <query id="GET_EXPERIMENT_DIRECTORIES" type="HQL">
629    <sql>
630      SELECT {1}
631      FROM ExperimentData xpr
632      WHERE xpr.directory = :directory
633    </sql>
634    <description>
635      A Hibernate query that gets the experiments having
636      the specified directory as the plugin directory.
637    </description>
638  </query>
639
640  <query id="GET_SUBDIRECTORIES" type="HQL">
641    <sql>
642      SELECT dir
643      FROM DirectoryData dir
644      WHERE dir.parent = :parent
645    </sql>
646    <description>
647      A Hibernate query that returns all subdirectories in a directory.
648    </description>
649  </query>
650 
651  <query id="GET_SUBDIRECTORY_WITH_NAME" type="HQL">
652    <sql>
653      SELECT dir
654      FROM DirectoryData dir
655      WHERE dir.name = :name
656      AND dir.parent = :parent
657    </sql>
658    <description>
659      A Hibernate query that returns the a subdirectory with the
660      specified name in a given directory.
661    </description>
662  </query>
663 
664  <query id="GET_QUOTA_TYPE_WITH_NAME" type="HQL">
665    <sql>
666      SELECT qt
667      FROM QuotaTypeData qt
668      WHERE qt.name = :name
669    </sql>
670    <description>
671      A Hibernate query that returns the quota type with the specified
672      name.
673    </description>
674  </query>
675 
676  <query id="GET_QUOTA_WITH_NAME" type="HQL">
677    <sql>
678      SELECT q
679      FROM QuotaData q
680      WHERE q.name = :name
681    </sql>
682    <description>
683      A Hibernate query that returns the quota with the specified
684      name.
685    </description>
686  </query>
687 
688  <query id="GET_GROUP_WITH_NAME" type="HQL">
689    <sql>
690      SELECT grp
691      FROM GroupData grp
692      WHERE grp.name = :name
693    </sql>
694    <description>
695      A Hibernate query that returns the group with the specified
696      name.
697    </description>
698  </query>
699 
700  <query id="GET_ROLE_WITH_NAME" type="HQL">
701    <sql>
702      SELECT rle
703      FROM RoleData rle
704      WHERE rle.name = :name
705    </sql>
706    <description>
707      A Hibernate query that returns the role with the specified
708      name.
709    </description>
710  </query>
711 
712  <query id="GET_SOFTWARE_WITH_NAME" type="HQL">
713    <sql>
714      SELECT sw
715      FROM SoftwareData sw
716      WHERE sw.name = :name
717    </sql>
718    <description>
719      A Hibernate query that returns the software with the specified
720      name.
721    </description>
722  </query>
723 
724  <query id="GET_HARDWARE_WITH_NAME" type="HQL">
725    <sql>
726      SELECT hw
727      FROM HardwareData hw
728      WHERE hw.name = :name
729    </sql>
730    <description>
731      A Hibernate query that returns the hardware with the specified
732      name.
733    </description>
734  </query>
735 
736  <query id="GET_PLATE_GEOMETRY_WITH_SIZE" type="HQL">
737    <sql>
738      SELECT pg
739      FROM PlateGeometryData pg
740      WHERE pg.rows = :rows AND pg.columns = :columns
741    </sql>
742    <description>
743      A Hibernate query that returns the plate geometry with the specified
744      size (rows and columns).
745    </description>
746  </query>
747
748  <query id="GET_PLATE_MAPPING_WITH_PROPERTIES" type="HQL">
749    <sql>
750      SELECT pm
751      FROM PlateMappingData pm
752      WHERE pm.sourceCount = :sourceCount AND pm.sourceGeometry = :sourceGeometry
753      AND pm.destinationCount = :destinationCount AND pm.destinationGeometry = :destinationGeometry
754    </sql>
755    <description>
756      A Hibernate query that returns the plate mapping with the specified
757      source and destination properties.
758    </description>
759  </query>
760 
761  <query id="GET_TAG_WITH_NAME" type="HQL">
762    <sql>
763      SELECT tag
764      FROM TagData tag
765      WHERE tag.name = :name
766    </sql>
767    <description>
768      A Hibernate query that returns the tag with the specified
769      name.
770    </description>
771  </query>
772 
773  <query id="GET_ANNOTATION_TYPE_WITH_NAME" type="HQL">
774    <sql>
775      SELECT at
776      FROM AnnotationTypeData at
777      WHERE at.name = :name
778    </sql>
779    <description>
780      A Hibernate query that returns the annotation type with the specified
781      name.
782    </description>
783  </query>
784 
785  <query id="GET_NEWS_WITH_NAME" type="HQL">
786    <sql>
787      SELECT nws
788      FROM NewsData nws
789      WHERE nws.name = :name
790    </sql>
791    <description>
792      A Hibernate query that returns the news with the specified
793      name.
794    </description>
795  </query>
796
797  <query id="GET_FILE_IN_DIRECTORY" type="HQL">
798    <sql>
799      SELECT f
800      FROM FileData f
801      WHERE f.directory = :directory
802      AND f.name = :name
803    </sql>
804    <description>
805      A Hibernate query that returns the file with the specified
806      name in a given directory.
807    </description>
808  </query>
809
810  <query id="GET_PLATEEVENTTYPES_FOR_PROTOCOLTYPE" type="HQL">
811    <sql>
812      SELECT {1}
813      FROM PlateEventTypeData pet
814      WHERE pet.protocolType = :subtype
815    </sql>
816    <description>
817      Get the plate events types that uses a protocol type.
818    </description>
819  </query>
820 
821  <query id="GET_BIOMATERIALEVENTS_FOR_PROTOCOL" type="HQL">
822    <sql>
823      SELECT {1}
824      FROM BioMaterialEventData bme
825      WHERE bme.protocol = :protocol
826    </sql>
827    <description>
828      A Hibernate query that gets biomaterial
829      events using a protocol.
830    </description>
831  </query>
832
833  <query id="GET_PLATEEVENTS_FOR_PROTOCOL" type="HQL">
834    <sql>
835      SELECT {1}
836      FROM PlateEventData pe
837      WHERE pe.protocol = :protocol
838    </sql>
839    <description>
840      A Hibernate query thatgets plate events
841      using a protocol.
842    </description>
843  </query>
844
845  <query id="GET_ARRAYBATCHES_FOR_PROTOCOL" type="HQL">
846    <sql>
847      SELECT {1}
848      FROM ArrayBatchData ab
849      WHERE ab.protocol = :protocol
850    </sql>
851    <description>
852      A Hibernate query that gets array batches
853      using a protocol.
854    </description>
855  </query>
856
857  <query id="GET_DERIVEDBIOASSAY_FOR_PROTOCOL" type="HQL">
858    <sql>
859      SELECT {1}
860      FROM DerivedBioAssayData dba
861      WHERE dba.protocol = :protocol
862    </sql>
863    <description>
864      A Hibernate query that gets derived bioassays
865      using a protocol.
866    </description>
867  </query>
868
869  <query id="GET_RAWBIOASSAYS_FOR_PROTOCOL" type="HQL">
870    <sql>
871      SELECT {1}
872      FROM RawBioAssayData rba
873      WHERE rba.protocol = :protocol
874    </sql>
875    <description>
876      A Hibernate query that gets raw bioassays
877      using a protocol.
878    </description>
879  </query>
880
881  <query id="GET_BIOMATERIALEVENTS_FOR_KIT" type="HQL">
882    <sql>
883      SELECT {1}
884      FROM BioMaterialEventData bme
885      WHERE bme.kit = :kit
886    </sql>
887    <description>
888      A Hibernate query that gets biomaterial
889      events using a kit.
890    </description>
891  </query>
892
893  <query id="GET_BIOPLATEEVENTS_FOR_KIT" type="HQL">
894    <sql>
895      SELECT {1}
896      FROM BioPlateEventData bpe
897      WHERE bpe.kit = :kit
898    </sql>
899    <description>
900      A Hibernate query that gets bioplate events
901      events using a kit.
902    </description>
903  </query>
904 
905  <query id="GET_DERIVEDBIOASSAYS_FOR_KIT" type="HQL">
906    <sql>
907      SELECT {1}
908      FROM DerivedBioAssayData dba
909      WHERE dba.kit = :kit
910    </sql>
911    <description>
912      A Hibernate query that gets derived bioassays using a kit.
913    </description>
914  </query>
915
916  <query id="FIND_USED_FILES" type="HQL">
917    <sql>
918      SELECT fad
919      FROM net.sf.basedb.core.data.FileAttachableData fad
920      WHERE fad.file = :file
921    </sql>
922    <description>
923      Load the files that is used by any FileAttachableData.
924    </description>
925  </query>
926
927  <query id="GET_FILESETMEMBERS_FOR_FILE" type="HQL">
928    <sql>
929      SELECT {1}
930      FROM FileSetMemberData fsm
931      WHERE fsm.file = :file
932    </sql>
933    <description>
934      A Hibernate query that gets file set membership
935      for a given file
936    </description>
937  </query>
938 
939  <query id="GET_DERIVEDBIOASSAYS_FOR_HARDWARE" type="HQL">
940    <sql>
941        SELECT {1}
942        FROM DerivedBioAssayData dba
943        WHERE dba.hardware = :hardware
944    </sql>
945    <description>
946      A Hibernate query that gets derived bioassays which
947      uses a given hardware.
948    </description>
949  </query>
950 
951  <query id="GET_ARRAYBATCHES_FOR_PRINTROBOT" type="HQL">
952    <sql>
953      SELECT {1}
954      FROM ArrayBatchData ab
955      WHERE ab.printRobot = :printrobot
956    </sql>
957    <description>
958      A Hibernate query that gets array batches which
959      uses a given print robot (hardware).
960    </description>
961  </query>
962 
963  <query id="GET_BIOMATERIALEVENTS_FOR_HARDWARE" type="HQL">
964    <sql>
965      SELECT {1}
966      FROM BioMaterialEventData bme
967      WHERE bme.hardware = :hardware
968    </sql>
969    <description>
970      A Hibernate query that gets biomaterial events which
971      uses a given hardware.
972    </description>
973  </query>
974 
975  <query id="GET_PLATEEVENTS_FOR_HARDWARE" type="HQL">
976    <sql>
977      SELECT {1}
978      FROM PlateEventData ple
979      WHERE ple.hardware = :hardware
980    </sql>
981    <description>
982      A Hibernate query that gets plates events which
983      uses a given hardware.
984    </description>
985  </query>
986
987  <query id="GET_REPORTERS_FOR_REPORTERTYPE" type="HQL">
988    <sql>
989      SELECT {1}
990      FROM ReporterData rpt
991      WHERE rpt.reporterType = :reporterType
992    </sql>
993    <description>
994      A Hibernate query that gets reporter items
995      of the given reporter type.
996    </description>
997  </query>
998
999  <query id="GET_REPORTER_FOR_EXTERNAL_ID" type="HQL">
1000    <sql>
1001      SELECT rpt
1002      FROM ReporterData rpt
1003      WHERE rpt.externalId = :externalId
1004    </sql>
1005    <description>
1006      A Hibernate query that finds the reporter with a given external id.
1007    </description>
1008  </query>
1009
1010  <query id="GET_RAWBIOASSAYS_FOR_SOFTWARE" type="HQL">
1011    <sql>
1012      SELECT {1}
1013      FROM RawBioAssayData rba
1014      WHERE rba.software = :software
1015    </sql>
1016    <description>
1017      A Hibernate query that gets the raw bioassays
1018      produced from a given software.
1019    </description>
1020  </query>
1021
1022  <query id="GET_DERIVEDBIOASSAYS_FOR_SOFTWARE" type="HQL">
1023    <sql>
1024      SELECT {1}
1025      FROM DerivedBioAssayData dba
1026      WHERE dba.software = :software
1027    </sql>
1028    <description>
1029      A Hibernate query that gets the derived bioassay
1030      using a given software.
1031    </description>
1032  </query>
1033
1034
1035  <query id="GET_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
1036    <sql>
1037      SELECT {1}
1038      FROM AnnotationData a
1039      WHERE a.annotationType = :annotationType
1040    </sql>
1041    <description>
1042      A Hibernate query that gets annotations
1043      of the given annotation type.
1044    </description>
1045  </query>
1046 
1047  <query id="GET_EXPERIMENTS_FOR_ANNOTATIONTYPE" type="HQL">
1048    <sql>
1049      SELECT {1}
1050      FROM ExperimentData exp
1051      JOIN exp.experimentalFactors ef
1052      WHERE ef = :annotationType
1053    </sql>
1054    <description>
1055      A Hibernate query that gets experiments
1056      where the given annotation type is used as an experimental factor.
1057    </description>
1058  </query>
1059 
1060  <query id="GET_PROTOCOLS_FOR_ANNOTATIONTYPE" type="HQL">
1061    <sql>
1062      SELECT {1}
1063      FROM ProtocolData prt
1064      JOIN prt.parameters pp
1065      WHERE pp = :annotationType
1066    </sql>
1067    <description>
1068      A Hibernate query that gets protocols
1069      where the given annotation type is used as a protocol parameter.
1070    </description>
1071  </query>
1072
1073  <query id="GET_SAMPLES_FOR_BIOSOURCE" type="HQL">
1074    <sql>
1075      SELECT {1}
1076      FROM SampleData s
1077      WHERE s.parent = :biosource
1078    </sql>
1079    <description>
1080      A Hibernate query that gets samples
1081      created from a given biosource.
1082    </description>
1083  </query>
1084
1085  <query id="GET_EXTRACTS_FOR_SAMPLE" type="HQL">
1086    <sql>
1087      SELECT {1}
1088      FROM ExtractData e
1089      WHERE e.parent = :sample
1090    </sql>
1091    <description>
1092      A Hibernate query that gets extracts
1093      created from a given sample.
1094    </description>
1095  </query>
1096 
1097  <query id="GET_EXTRACTS_FOR_TAG" type="HQL">
1098    <sql>
1099      SELECT {1}
1100      FROM ExtractData ext
1101      WHERE ext.tag = :tag
1102    </sql>
1103    <description>
1104      A Hibernate query that gets extracts with a given tag.
1105    </description>
1106  </query>
1107
1108  <query id="GET_SOURCEEVENTS_FOR_BIOMATERIAL" type="HQL">
1109    <sql>
1110      SELECT {1}
1111      FROM BioMaterialEventData bme
1112      JOIN bme.sources src
1113      WHERE src.bioMaterial = :bioMaterial
1114    </sql>
1115    <description>
1116      A Hibernate query that gets the events where a given
1117      biomaterial has been part of as a source biomaterial, ie. the number
1118      of pooled biomaterials that have been created from it.
1119    </description>
1120  </query>
1121
1122  <query id="GET_DERIVEDBIOASSAYS_FOR_EXTRACT" type="HQL">
1123    <sql>
1124      SELECT {1}
1125      FROM DerivedBioAssayData dba
1126      WHERE dba.extract = :extract
1127    </sql>
1128    <description>
1129      A Hibernate query that gets the derived bioassays
1130      that are referencing a given extract.
1131    </description>
1132  </query>
1133
1134  <query id="GET_RAWBIOASSAYS_FOR_EXTRACT" type="HQL">
1135    <sql>
1136      SELECT {1}
1137      FROM RawBioAssayData rba
1138      WHERE rba.parentExtract = :extract
1139    </sql>
1140    <description>
1141      A Hibernate query that gets the raw bioassays
1142      that are referencing a given extract.
1143    </description>
1144  </query>
1145
1146  <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL">
1147    <sql>
1148      SELECT count(*)
1149      FROM MessageData msg
1150      WHERE msg.to = :user AND msg.read = false AND msg.removedBy IS NULL
1151    </sql>
1152    <description>
1153      A Hibernate query that counts the number of
1154      unread messages for a given user
1155    </description>
1156  </query>
1157 
1158  <query id="GET_PLATETYPES_FOR_PLATEGEOMETRY" type="HQL">
1159    <sql>
1160      SELECT {1}
1161      FROM PlateTypeData pt
1162      WHERE pt.plateGeometry = :plateGeometry
1163    </sql>
1164    <description>
1165      A Hibernate query that gets the
1166      plate types using a given plate geometry
1167    </description>
1168  </query>
1169 
1170  <query id="GET_PLATEMAPPINGS_FOR_PLATEGEOMETRY" type="HQL">
1171    <sql>
1172      SELECT {1}
1173      FROM PlateMappingData pm
1174      WHERE pm.sourceGeometry = :plateGeometry
1175      OR pm.destinationGeometry = :plateGeometry
1176    </sql>
1177    <description>
1178      A Hibernate query that gets the
1179      plate mappings using a given plate geometry as source or destination
1180    </description>
1181  </query>
1182
1183  <query id="GET_BIOPLATES_FOR_PLATEGEOMETRY" type="HQL">
1184    <sql>
1185      SELECT {1}
1186      FROM BioPlateData bp
1187      WHERE bp.plateGeometry = :plateGeometry
1188    </sql>
1189    <description>
1190      A Hibernate query that gets the
1191      bioplates using of given plate geometry
1192    </description>
1193  </query>
1194
1195  <query id="GET_PLATES_FOR_PLATETYPE" type="HQL">
1196    <sql>
1197      SELECT {1}
1198      FROM PlateData p
1199      WHERE p.plateType = :plateType
1200    </sql>
1201    <description>
1202      A Hibernate query that gets
1203      plates of a specific plate type.
1204    </description>
1205  </query>
1206
1207  <query id="GET_PLATEEVENTS_FOR_PLATEEVENTTYPE" type="HQL">
1208    <sql>
1209      SELECT {1}
1210      FROM PlateEventData pe
1211      WHERE pe.plateEventType = :plateEventType
1212    </sql>
1213    <description>
1214      A Hibernate query that gets
1215      plate events of the given plate event type.
1216    </description>
1217  </query>
1218
1219  <query id="GET_CHILDPLATES_FOR_PLATE" type="HQL">
1220    <sql>
1221      SELECT {1}
1222      FROM PlateData p
1223      JOIN p.parents pp
1224      WHERE pp = :plate
1225    </sql>
1226    <description>
1227      A Hibernate query that gets the
1228      child plates for a given plate.
1229    </description>
1230  </query>
1231
1232  <query id="GET_ARRAYDESIGNS_FOR_PLATE" type="HQL">
1233    <sql>
1234      SELECT {1}
1235      FROM ArrayDesignData ad
1236      JOIN ad.plates p
1237      WHERE p = :plate
1238    </sql>
1239    <description>
1240      A Hibernate query that gets the
1241      array designs that has used a given plate.
1242    </description>
1243  </query>
1244
1245  <query id="GET_PLATES_FOR_PLATEMAPPING" type="HQL">
1246    <sql>
1247      SELECT {1}
1248      FROM PlateData p
1249      WHERE p.plateMapping = :plateMapping
1250    </sql>
1251    <description>
1252      A Hibernate query that gets the
1253      plates that has been created from a given plate mapping.
1254    </description>
1255  </query>
1256 
1257  <query id="GET_FEATURES_FOR_WELL" type="HQL">
1258    <sql>
1259      SELECT {1}
1260      FROM FeatureData f
1261      WHERE f.well = :well
1262    </sql>
1263    <description>
1264      A Hibernate query that gets the
1265      features using a given well.
1266    </description>
1267  </query>
1268
1269  <query id="COUNT_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1270    <sql>
1271      SELECT count(*)
1272      FROM FeatureData f
1273      WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
1274    </sql>
1275    <description>
1276      A Hibernate query that counts the number of
1277      features on a given array design
1278    </description>
1279  </query>
1280
1281
1282  <query id="GET_CHILDWELLS_FOR_WELL" type="HQL">
1283    <sql>
1284      SELECT {1}
1285      FROM Well w
1286      WHERE w.parent = :well
1287    </sql>
1288    <description>
1289      A Hibernate query that gets the
1290      child wells of a given well.
1291    </description>
1292  </query>
1293
1294  <query id="GET_PLUGINCONFIGURATIONS_FOR_PLUGINDEFINITION" type="HQL">
1295    <sql>
1296      SELECT {1}
1297      FROM PluginConfigurationData pc
1298      WHERE pc.pluginDefinition = :pluginDefinition
1299    </sql>
1300    <description>
1301      A Hibernate query that gets plugin configurations
1302      using a plugin definition.
1303    </description>
1304  </query>
1305 
1306  <query id="GET_JOBS_FOR_PLUGINCONFIGURATION" type="HQL">
1307    <sql>
1308      SELECT {1}
1309      FROM JobData j
1310      WHERE j.pluginConfiguration = :pluginConfiguration
1311    </sql>
1312    <description>
1313      A Hibernate query that gets the jobs
1314      using a specific plugin configuration.
1315    </description>
1316  </query>
1317 
1318  <query id="GET_JOBS_FOR_PLUGINDEFINITION" type="HQL">
1319    <sql>
1320      SELECT {1}
1321      FROM JobData j
1322      WHERE j.pluginDefinition = :pluginDefinition
1323    </sql>
1324    <description>
1325      A Hibernate query that gets the jobs
1326      using a specific plugin definition.
1327    </description>
1328  </query>
1329
1330  <query id="FIND_JOBS_IN_QUEUE" type="HQL">
1331    <sql>
1332      SELECT job
1333      FROM JobData job
1334      WHERE job.status = :status
1335      AND job.type = :type
1336      AND job.removedBy IS NULL
1337      ORDER BY job.priority ASC, job.scheduled ASC
1338    </sql>
1339    <description>
1340      A Hibernate query that loads plugin jobs in the job queue waiting to be
1341      executed sorted by priority and waiting time. The query should return all
1342      jobs, ignoring all settings specifying that the internal job queue should
1343      not be used.
1344    </description>
1345  </query>
1346 
1347  <query id="FIND_INTERNAL_JOBS_IN_QUEUE" type="HQL">
1348    <sql>
1349      SELECT job
1350      FROM JobData job
1351      WHERE job.status = :status
1352      AND job.type = :type
1353      AND job.removedBy IS NULL
1354      AND job.pluginDefinition.useInternalJobQueue = true
1355      AND job.jobAgentId IS NULL
1356      ORDER BY job.priority ASC, job.scheduled ASC
1357    </sql>
1358    <description>
1359      A Hibernate query that loads plugin jobs in the job queue waiting to be
1360      executed sorted by priority and waiting time. It should only return
1361      jobs where the plug-in setting useInternalJobQueue=true and no
1362      specific job agent has been selected for the job.
1363    </description>
1364  </query>
1365 
1366  <query id="FIND_EXTERNAL_JOBS_FOR_STATUS_UPDATE" type="HQL">
1367    <sql>
1368      SELECT job
1369      FROM JobData job
1370      WHERE job.type = :type
1371      AND job.removedBy IS NULL
1372      AND NOT job.signalTransporter IS NULL
1373    </sql>
1374    <description>
1375      A Hibernate query that loads external jobs in the job queue that
1376      has a non-null signal transporter so that it may be possible to
1377      send a signal request for status update to them,
1378    </description>
1379  </query>
1380 
1381  <query id="GET_ARRAYSLIDES_FOR_BATCH" type="HQL">
1382    <sql>
1383      SELECT {1}
1384      FROM ArraySlideData a
1385      WHERE a.arrayBatch = :arrayBatch
1386    </sql>
1387    <description>
1388      A Hibernate query that gets the array slides
1389      in an array batch.
1390    </description>
1391  </query>
1392
1393  <query id="GET_ARRAYSLIDES_WITH_BARCODE" type="HQL">
1394    <sql>
1395      SELECT {1}
1396      FROM ArraySlideData ars
1397      WHERE ars.barcode = :barcode
1398    </sql>
1399    <description>
1400      A Hibernate query that gets the array slides
1401      with a given barcode.
1402    </description>
1403  </query>
1404
1405
1406  <query id="GET_ARRAYBATCHES_FOR_ARRAYDESIGN" type="HQL">
1407    <sql>
1408      SELECT {1}
1409      FROM ArrayBatchData a
1410      WHERE a.arrayDesign = :arrayDesign
1411    </sql>
1412    <description>
1413      A Hibernate query that gets array batches
1414      that uses a specific array design.
1415    </description>
1416  </query>
1417
1418  <query id="GET_RAWBIOASSAYS_FOR_ARRAYDESIGN" type="HQL">
1419    <sql>
1420      SELECT {1}
1421      FROM RawBioAssayData rba
1422      WHERE rba.arrayDesign = :arrayDesign
1423    </sql>
1424    <description>
1425      A Hibernate query that gets raw bioassays
1426      that uses a specific array design.
1427    </description>
1428  </query>
1429
1430  <query id="GET_ROOT_DERIVEDBIOASSAYS_FOR_PHYSICALBIOASSAY" type="HQL">
1431    <sql>
1432      SELECT {1}
1433      FROM DerivedBioAssayData dba
1434      INNER JOIN dba.physicalBioAssays pba
1435      WHERE pba = :bioAssay
1436      AND dba.root = true
1437    </sql>
1438    <description>
1439      A Hibernate query that gets root derived bioassays
1440      created from a specific physical bioassay.
1441    </description>
1442  </query>
1443
1444  <query id="GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL">
1445    <sql>
1446      SELECT {1}
1447      FROM DerivedBioAssayData dba
1448      INNER JOIN dba.parents p
1449      WHERE p = :bioAssay
1450    </sql>
1451    <description>
1452      A Hibernate query that gets child derived bioassays
1453      created from a specific derived bioassay.
1454    </description>
1455  </query>
1456
1457
1458  <query id="GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL">
1459    <sql>
1460      SELECT {1}
1461      FROM RawBioAssayData rba
1462      WHERE rba.parentBioAssay = :bioAssay
1463    </sql>
1464    <description>
1465      A Hibernate query that gets raw bioassays
1466      created from a specific derived bioassay.
1467    </description>
1468  </query>
1469
1470  <query id="PRELOAD_FEATURES" type="HQL">
1471    <sql>
1472      SELECT f
1473      FROM FeatureData f
1474      JOIN FETCH f.arrayDesignBlock b
1475      LEFT JOIN FETCH f.reporter
1476      WHERE b.arrayDesign = :arrayDesign
1477    </sql>
1478    <description>
1479      A Hibernate query that loads features, blocks and reporters
1480      for a single array design.
1481    </description>
1482  </query>
1483 
1484  <query id="DELETE_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1485    <sql>
1486      DELETE FROM Features f, ArrayDesignBlocks adb
1487      WHERE adb.id = f.arraydesignblock_id AND adb.arraydesign_id = ?
1488    </sql>
1489    <description>
1490      A Hibernate query that deletes all features for an array design.
1491    </description>
1492  </query>
1493
1494  <query id="GET_PLUGINTYPE_FOR_INTERFACENAME" type="HQL">
1495    <sql>
1496      SELECT plt
1497      FROM PluginTypeData plt
1498      WHERE plt.interfaceName = :interfaceName
1499    </sql>
1500    <description>
1501      Load a plugin type when you know the interface name.
1502    </description>
1503  </query>
1504
1505  <query id="GET_PLUGINDEFINITION_FOR_CLASSNAME" type="HQL">
1506    <sql>
1507      SELECT pd
1508      FROM PluginDefinitionData pd
1509      WHERE pd.className = :className
1510    </sql>
1511    <description>
1512      Load a plugin definition when you know the class name.
1513    </description>
1514  </query>
1515
1516  <query id="GET_PLUGINCONFIGURATION_FOR_PLUGIN_WITH_NAME" type="HQL">
1517    <sql>
1518      SELECT pc
1519      FROM PluginConfigurationData pc
1520      WHERE pc.pluginDefinition.className = :className
1521      AND pc.name = :name
1522    </sql>
1523    <description>
1524      Load a plugin configuration for a given plug-in and with a given name
1525    </description>
1526  </query>
1527
1528
1529  <query id="GET_EXPERIMENTS_FOR_RAWBIOASSAY" type="HQL">
1530    <sql>
1531      SELECT {1}
1532      FROM ExperimentData xp
1533      JOIN xp.rawBioAssays rba
1534      WHERE rba = :rawBioAssay
1535    </sql>
1536    <description>
1537      A Hibernate query that gets the experiments
1538      using a specific raw bioassay.
1539    </description>
1540  </query>
1541 
1542  <query id="GET_TRANSFORMATIONS_FOR_RAWBIOASSAY" type="HQL">
1543    <sql>
1544      SELECT {1}
1545      FROM TransformationData trf
1546      JOIN trf.rawSources rba
1547      WHERE rba = :rawBioAssay
1548    </sql>
1549    <description>
1550      A Hibernate query that gets the transformations
1551      using a specifiec raw bioassay.
1552    </description>
1553  </query>
1554 
1555  <query id="GET_TRANSFORMATIONS_FOR_JOB" type="HQL">
1556    <sql>
1557      SELECT {1}
1558      FROM TransformationData trf
1559      WHERE trf.job = :job
1560    </sql>
1561    <description>
1562      A Hibernate query that gets transformations
1563      linked to a job.
1564    </description>
1565  </query>
1566 
1567  <query id="GET_RAWBIOASSAYS_FOR_JOB" type="HQL">
1568    <sql>
1569      SELECT {1}
1570      FROM RawBioAssayData rba
1571      WHERE rba.job = :job
1572    </sql>
1573    <description>
1574      A Hibernate query that gets raw bioassays
1575      linked to a job.
1576    </description>
1577  </query>
1578 
1579  <query id="GET_ARRAYDESIGNS_FOR_JOB" type="HQL">
1580    <sql>
1581      SELECT {1}
1582      FROM ArrayDesignData ad
1583      WHERE ad.job = :job
1584    </sql>
1585    <description>
1586      A Hibernate query that gets array designs
1587      linked to a job.
1588    </description>
1589  </query>
1590 
1591  <query id="GET_DERIVEDBIOASSAYS_FOR_JOB" type="HQL">
1592    <sql>
1593      SELECT {1}
1594      FROM DerivedBioAssayData dba
1595      WHERE dba.job = :job
1596    </sql>
1597    <description>
1598      A Hibernate query that gets derived bioassays
1599      linked to a job.
1600    </description>
1601  </query>
1602
1603  <query id="FIND_CHILD_BIOASSAYSETS" type="HQL">
1604    <sql>
1605      SELECT bas
1606      FROM BioAssaySetData bas
1607      WHERE bas.transformation.source = :parent
1608    </sql>
1609    <description>
1610      A Hibernate query that returns all bioassaysets that are
1611      children to a specified parent bioassayset.
1612    </description>
1613  </query>
1614 
1615  <query id="FIND_DATACUBES_FOR_BIOASSAYSETS" type="HQL">
1616    <sql>
1617      SELECT DISTINCT cbe
1618      FROM BioAssaySetData bas
1619      JOIN bas.dataCubeLayer.dataCube cbe
1620      WHERE bas IN (:basList)
1621    </sql>
1622    <description>
1623      A Hibernate query that returns all data cubes that are
1624      used by the specified list of bioassaysets
1625    </description>
1626  </query>
1627 
1628  <query id="FIND_DATACUBES_USED_BY_OTHERS" type="HQL">
1629    <sql>
1630      SELECT DISTINCT cbe
1631      FROM BioAssaySetData bas
1632      JOIN bas.dataCubeLayer.dataCube cbe
1633      WHERE bas NOT IN (:basList)
1634      AND cbe IN (:possibleCubes)
1635    </sql>
1636    <description>
1637      A Hibernate query that, given a list of data cubes and bioassaysets,
1638      returns all of those data cubes that are also used by other bioassaysets.
1639    </description>
1640  </query>
1641
1642  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS" type="HQL">
1643    <sql>
1644      SELECT lay
1645      FROM BioAssaySetData bas
1646      JOIN bas.dataCubeLayer lay
1647      WHERE bas IN (:basList)
1648    </sql>
1649    <description>
1650      A Hibernate query that returns all data cube layers that are
1651      used by the specified list of bioassaysets
1652    </description>
1653  </query>
1654 
1655  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1656    <sql>
1657      SELECT lay
1658      FROM BioAssaySetData bas
1659      JOIN bas.dataCubeLayer lay
1660      WHERE bas IN (:basList)
1661      AND lay.dataCube NOT IN (:deletedCubes)
1662    </sql>
1663    <description>
1664      A Hibernate query that returns all data cube layers that are
1665      used by the specified list of bioassaysets but not are part of the
1666      list of already deleted data cubes.
1667    </description>
1668  </query>
1669
1670  <query id="FIND_DATACUBELAYERS_USED_BY_OTHERS" type="HQL">
1671    <sql>
1672      SELECT lay
1673      FROM BioAssaySetData bas
1674      JOIN bas.dataCubeLayer lay
1675      WHERE bas NOT IN (:basList)
1676      AND lay IN (:possibleLayers)
1677    </sql>
1678    <description>
1679      A Hibernate query that, given a list of data cube layers and bioassaysets,
1680      returns all of those data cube layers that are also used by other bioassaysets.
1681    </description>
1682  </query>
1683
1684  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS" type="HQL">
1685    <sql>
1686      SELECT flt
1687      FROM BioAssaySetData bas
1688      JOIN bas.dataCubeFilter flt
1689      WHERE bas IN (:basList)
1690    </sql>
1691    <description>
1692      A Hibernate query that returns all data cube filters that are
1693      used by the specified list of bioassaysets
1694    </description>
1695  </query>
1696 
1697  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1698    <sql>
1699      SELECT flt
1700      FROM BioAssaySetData bas
1701      JOIN bas.dataCubeFilter flt
1702      WHERE bas IN (:basList)
1703      AND flt.dataCube NOT IN (:deletedCubes)
1704    </sql>
1705    <description>
1706      A Hibernate query that returns all data cube filters that are
1707      used by the specified list of bioassaysets but not are part of the
1708      list of already deleted data cubes.
1709    </description>
1710  </query>
1711
1712  <query id="FIND_DATACUBEFILTERS_USED_BY_OTHERS" type="HQL">
1713    <sql>
1714      SELECT flt
1715      FROM BioAssaySetData bas
1716      JOIN bas.dataCubeFilter flt
1717      WHERE bas NOT IN (:basList)
1718      AND flt IN (:possibleFilters)
1719    </sql>
1720    <description>
1721      A Hibernate query that, given a list of data cube filters and bioassaysets,
1722      returns all of those data cube filters that are also used by other bioassaysets.
1723    </description>
1724  </query>
1725
1726  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS" type="HQL">
1727    <sql>
1728      SELECT dcev
1729      FROM BioAssaySetData bas
1730      JOIN bas.extraValues ev
1731      JOIN ev.dataCubeExtraValue dcev
1732      WHERE bas IN (:basList)
1733    </sql>
1734    <description>
1735      A Hibernate query that returns all data cube extra values that are
1736      used by the specified list of bioassaysets
1737    </description>
1738  </query>
1739 
1740  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1741    <sql>
1742      SELECT dcev
1743      FROM BioAssaySetData bas
1744      JOIN bas.extraValues ev
1745      JOIN ev.dataCubeExtraValue dcev
1746      WHERE bas IN (:basList)
1747      AND dcev.dataCube NOT IN (:deletedCubes)
1748    </sql>
1749    <description>
1750      A Hibernate query that returns all data cube extra values that are
1751      used by the specified list of bioassaysets but not are part of the
1752      list of already deleted data cubes.
1753    </description>
1754  </query>
1755
1756  <query id="FIND_DATACUBEEXTRAVALUES_USED_BY_OTHERS" type="HQL">
1757    <sql>
1758      SELECT dcev
1759      FROM BioAssaySetData bas
1760      JOIN bas.extraValues ev
1761      JOIN ev.dataCubeExtraValue dcev
1762      WHERE bas NOT IN (:basList)
1763      AND dcev IN (:possibleExtraValues)
1764    </sql>
1765    <description>
1766      A Hibernate query that, given a list of data cube extra values and bioassaysets,
1767      returns all of those data cube extra values that are also used by other bioassaysets.
1768    </description>
1769  </query>
1770
1771  <query id="GET_EXTRAVALUETYPE_FOR_EXTERNAL_ID" type="HQL">
1772    <sql>
1773      SELECT evt
1774      FROM ExtraValueTypeData evt
1775      WHERE evt.externalId = :externalId
1776    </sql>
1777    <description>
1778      Load an extra value type when you know the external id.
1779    </description>
1780  </query>
1781
1782  <query id="GET_EXTRAVALUES_FOR_EXTRAVALUETYPE" type="HQL">
1783    <sql>
1784      SELECT {1}
1785      FROM ExtraValueData ev
1786      WHERE ev.extraValueType = :extraValueType
1787    </sql>
1788    <description>
1789      A Hibernate query that gets extra values
1790      of a specific type.
1791    </description>
1792  </query>
1793 
1794  <query id="LOAD_CONTEXT_NAMES" type="HQL">
1795    <sql>
1796      SELECT ctx.id, ctx.name
1797      FROM ContextData ctx
1798      WHERE ctx.client = :client AND
1799      (ctx.user = :user OR ctx.public = true)
1800      AND ctx.itemType = :itemType
1801      AND ctx.subContext = :subContext
1802      ORDER BY ctx.name
1803    </sql>
1804    <description>
1805      A Hibernate query that selects the id and name of all contexts for
1806      a user and item type. The names should be sorted in ascending order.
1807    </description>
1808  </query>
1809 
1810  <query id="LOAD_CONTEXT_BY_NAME" type="HQL">
1811    <sql>
1812      SELECT ctx
1813      FROM ContextData ctx
1814      WHERE ctx.user = :user
1815      AND ctx.client = :client
1816      AND ctx.itemType = :itemType
1817      AND ctx.subContext  = :subContext
1818      AND ctx.name = :name
1819    </sql>
1820    <description>
1821      A Hibernate query that load a context given the user, client,
1822      item type, subcontext and name of the context.
1823    </description>
1824  </query>
1825 
1826  <query id="LOAD_USER_CONTEXTS" type="HQL">
1827    <sql>
1828      SELECT ctx
1829      FROM ContextData ctx
1830      WHERE ctx.user.id = :user
1831      AND ctx.client.id = :client
1832      AND ctx.name = :name
1833    </sql>
1834    <description>
1835      A Hibernate query that loads all saved context information
1836      with a given name for a specific user/client.
1837    </description>
1838  </query>
1839
1840  <query id="COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT" type="HQL">
1841    <sql>
1842      SELECT plg.mainType, count(DISTINCT plg.id)
1843      FROM PluginDefinitionData plg
1844      JOIN plg.guiContexts gcx
1845      LEFT JOIN plg.configurations cfg
1846      WITH true = :hasConfigPermission OR cfg.owner.id = :owner
1847        OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
1848      WHERE
1849        (true = :hasPluginPermission OR plg.owner.id = :owner
1850        OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
1851      AND gcx.itemType = :itemType AND gcx.contextType = :contextType
1852      AND (
1853        (plg.requiresConfiguration = false)
1854        OR
1855        (plg.requiresConfiguration = true AND cfg.parameterVersion > 0)
1856      )
1857      AND plg.disabled = false
1858      AND (cfg.id IS NULL OR cfg.disabled = false)
1859      GROUP BY plg.mainType
1860    </sql>
1861    <description>
1862      A Hibernate query that counts the number of plugins available for a
1863      given GUI context grouped by the main type of the plugins taking
1864      the requirement of configurations and user permissions into account.
1865    </description>
1866  </query>
1867 
1868  <query id="GET_FORMULA_WITH_NAME_AND_CHANNELS" type="HQL">
1869    <sql>
1870      SELECT fml
1871      FROM FormulaData fml
1872      WHERE fml.name = :name
1873      AND fml.channels = :channels
1874    </sql>
1875    <description>
1876      A Hibernate query that loads a formula with a given name and number
1877      of channels.
1878    </description>
1879  </query>
1880
1881  <query id="GET_FORMULA_WITH_NAME_AND_TYPE" type="HQL">
1882    <sql>
1883      SELECT fml
1884      FROM FormulaData fml
1885      WHERE fml.name = :name
1886      AND fml.rawDataType = :rawDataType
1887    </sql>
1888    <description>
1889      A Hibernate query that loads a formula with a given name and raw data type.
1890    </description>
1891  </query>
1892 
1893  <query id="GET_HELP_FOR_EXTERNAL_ID" type="HQL">
1894    <sql>
1895      SELECT hlp
1896      FROM HelpData hlp
1897      WHERE hlp.externalId = :externalId AND hlp.client = :client
1898    </sql>
1899    <description>
1900      A Hibernate query that loads a help text.
1901    </description>
1902  </query>
1903 
1904  <query id="GET_SCHEMA_VERSION_FOR_APP" type="HQL">
1905    <sql>
1906      SELECT sv
1907      FROM SchemaVersionData sv
1908      WHERE sv.appId = :appId
1909    </sql>
1910    <description>
1911      A Hibernate query that loads the schema version for a
1912      given application (there should only be one record since appId is unique).
1913    </description>
1914  </query>
1915 
1916  <query id="SET_SCHEMA_VERSION_FOR_APP" type="HQL">
1917    <sql>
1918      UPDATE SchemaVersionData sv
1919      SET sv.schemaVersion = :schemaVersion,
1920      sv.build = :build
1921      WHERE sv.appId = :appId
1922    </sql>
1923    <description>
1924      A Hibernate query that updates the schema version and build number.
1925    </description>
1926  </query>
1927 
1928  <query id="GET_PRIMARY_ANNOTATION" type="HQL">
1929    <sql>
1930      SELECT ad
1931      FROM AnnotationData ad
1932      WHERE ad.annotationType = :annotationType
1933      AND ad.annotationSet = :annotationSet
1934      AND ad.source = 0
1935    </sql>
1936    <description>
1937      A Hibernate query that loads the primary annotation of a specific
1938      annotation type for a given annotation set.
1939    </description>
1940  </query>
1941 
1942  <query id="LOAD_ANNOTATIONSET_INHERITING_ANNOTATIONTYPE" type="SQL">
1943    <sql>
1944      SELECT [a].[annotationset_id] FROM [Annotations] [a]
1945      WHERE [a].[annotationtype_id] = :annotationType
1946      AND [a].[source] != 0
1947    </sql>
1948    <description>
1949      An SQL query that load the ID of all annotation sets that
1950      are inheriting a given annotation type.
1951    </description>
1952  </query>
1953 
1954  <query id="DELETE_INHERITED_ANNOTATIONS" type="SQL">
1955    <sql>
1956      DELETE FROM [Annotations]
1957      WHERE [annotationtype_id] = :annotationType
1958      AND [source] != 0
1959    </sql>
1960    <description>
1961      An SQL query that delete all inherited annotations of the specified
1962      annotation type.
1963    </description>
1964  </query>
1965 
1966  <query id="NULLIFY_LINK_FROM_CLONES" type="HQL">
1967    <sql>
1968      UPDATE AnnotationData ad
1969      SET ad.inheritedFrom = null
1970      WHERE ad.inheritedFrom = :targetId
1971      AND ad.source = 2
1972    </sql>
1973    <description>
1974      A HQL query that nullify the link from all cloned annotations
1975      to a specified target annotation.
1976    </description>
1977  </query>
1978 
1979  <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL">
1980    <sql>
1981      UPDATE ExperimentData xpm
1982      SET xpm.bytes = xpm.bytes + :addedBytes
1983      WHERE xpm.id = :experiment
1984    </sql>
1985    <description>
1986      A Hibernate query that updates the number of bytes used by an experiment.
1987    </description>
1988  </query>
1989
1990  <query id="UPDATE_BYTES_FOR_DATACUBE" type="HQL">
1991    <sql>
1992      UPDATE DataCubeData dcd
1993      SET dcd.bytes = dcd.bytes + :addedBytes
1994      WHERE dcd.id = :dataCube
1995    </sql>
1996    <description>
1997      A Hibernate query that updates the number of bytes used by a data cube.
1998    </description>
1999  </query>
2000 
2001  <query id="GET_REMOVED_ITEMS" type="HQL">
2002    <sql>
2003      SELECT trash
2004      FROM net.sf.basedb.core.data.RemovableData trash
2005      WHERE NOT trash.removedBy IS NULL
2006    </sql>
2007    <description>
2008      A Hibernate query that loads all items flagged for deletion.
2009    </description>
2010  </query>
2011 
2012  <query id="UPDATE_REMAINING_QUANTITY" type="HQL">
2013    <sql>
2014      UPDATE MeasuredBioMaterialData mbm
2015      SET mbm.remainingQuantity = mbm.remainingQuantity - :used
2016      WHERE mbm = :bioMaterial
2017    </sql>
2018    <description>
2019      A Hibernate query that adds/removes the remaining quantity on a
2020      measuered biomaterial.
2021    </description>
2022  </query>
2023 
2024  <query id="GET_REMAINING_QUANTITY" type="HQL">
2025    <sql>
2026      SELECT mbm.remainingQuantity
2027      FROM MeasuredBioMaterialData mbm
2028      WHERE mbm = :bioMaterial
2029    </sql>
2030    <description>
2031      A Hibernate query that load the remaining quantity for a
2032      measuered biomaterial.
2033    </description>
2034  </query>
2035
2036  <query id="GET_ANYTOANY_FOR_NAME" type="HQL">
2037    <sql>
2038      SELECT ata
2039      FROM AnyToAnyData ata
2040      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2041    </sql>
2042    <description>
2043      A Hibernate query that loads the any-to-any link with the specified name
2044      for an item.
2045    </description>
2046  </query>
2047
2048  <query id="DELETE_ANYTOANY_FROM" type="HQL">
2049    <sql>
2050      DELETE FROM AnyToAnyData ata
2051      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2052    </sql>
2053    <description>
2054      A Hibernate query that deletes a names any-to-any link leading out from
2055      an item.
2056    </description>
2057  </query>
2058
2059
2060  <query id="DELETE_ALL_ANYTOANY_FROM" type="HQL">
2061    <sql>
2062      DELETE FROM AnyToAnyData ata
2063      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2064    </sql>
2065    <description>
2066      A Hibernate query that deletes all any-to-any links leading out from
2067      an item.
2068    </description>
2069  </query>
2070 
2071  <query id="DELETE_ALL_ANYTOANY_TO" type="HQL">
2072    <sql>
2073      DELETE FROM AnyToAnyData ata
2074      WHERE ata.toId = :toId AND ata.toType = :toType
2075    </sql>
2076    <description>
2077      A Hibernate query that deletes all any-to-any links leading in to an item.
2078    </description>
2079  </query>
2080
2081  <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
2082    <sql>
2083      DELETE FROM AnyToAnyData ata
2084      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = false
2085    </sql>
2086    <description>
2087      A Hibernate query that deletes all any-to-any links leading in to
2088      an item that doesn't count as using the item.
2089    </description>
2090  </query>
2091
2092  <query id="COUNT_USED_ANYTOANY_TO" type="HQL">
2093    <sql>
2094      SELECT count(*)
2095      FROM AnyToAnyData ata
2096      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = true
2097    </sql>
2098    <description>
2099      A Hibernate query that counts the number of any-to-any links
2100      to a given item that counts as using the item.
2101    </description>
2102  </query>
2103
2104  <query id="FIND_USING_ANYTOANY" type="HQL">
2105    <sql>
2106      SELECT ana.fromId, ana.fromType
2107      FROM AnyToAnyData ana
2108      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
2109    </sql>
2110    <description>
2111      A Hibernate query that finds the any-to-any links
2112      to a given item that counts as using the item.
2113    </description>
2114  </query>
2115
2116 
2117  <query id="UPDATE_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2118    <sql>
2119      UPDATE VirtualDbData vdb
2120      SET vdb.cubes = vdb.cubes + 1
2121      WHERE vdb.id = :virtualDb
2122    </sql>
2123    <description>
2124      A Hibernate query that updates the number of data cubes
2125      for the specified virtual database.
2126    </description>
2127  </query>
2128
2129  <query id="GET_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2130    <sql>
2131      SELECT vdb.cubes
2132      FROM VirtualDbData vdb
2133      WHERE vdb.id = :virtualDb
2134    </sql>
2135    <description>
2136      A Hibernate query that gets the current number of data cubes
2137      for the specified virtual database.
2138    </description>
2139  </query>
2140 
2141  <query id="UPDATE_FILTERNO_FOR_DATACUBE" type="HQL">
2142    <sql>
2143      UPDATE DataCubeData dcb
2144      SET dcb.numFilters = dcb.numFilters + 1
2145      WHERE dcb.id = :dataCube
2146    </sql>
2147    <description>
2148      A Hibernate query that updates the number of filters
2149      for the specified data cube.
2150    </description>
2151  </query>
2152
2153  <query id="GET_FILTERNO_FOR_DATACUBE" type="HQL">
2154    <sql>
2155      SELECT dcb.numFilters
2156      FROM DataCubeData dcb
2157      WHERE dcb.id = :dataCube
2158    </sql>
2159    <description>
2160      A Hibernate query that gets the current number of filters
2161      for the specified data cube.
2162    </description>
2163  </query>
2164
2165  <query id="UPDATE_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2166    <sql>
2167      UPDATE DataCubeData dcb
2168      SET dcb.numExtraValues = dcb.numExtraValues + 1
2169      WHERE dcb.id = :dataCube
2170    </sql>
2171    <description>
2172      A Hibernate query that updates the number of extra values
2173      for the specified data cube.
2174    </description>
2175  </query>
2176
2177  <query id="GET_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2178    <sql>
2179      SELECT dcb.numExtraValues
2180      FROM DataCubeData dcb
2181      WHERE dcb.id = :dataCube
2182    </sql>
2183    <description>
2184      A Hibernate query that gets the current number of extra values
2185      for the specified data cube.
2186    </description>
2187  </query>
2188
2189  <query id="UPDATE_LAYERNO_FOR_DATACUBE" type="HQL">
2190    <sql>
2191      UPDATE DataCubeData dcb
2192      SET dcb.numLayers = dcb.numLayers + 1
2193      WHERE dcb.id = :dataCube
2194    </sql>
2195    <description>
2196      A Hibernate query that updates the number of layers
2197      for the specified data cube.
2198    </description>
2199  </query>
2200
2201  <query id="GET_LAYERNO_FOR_DATACUBE" type="HQL">
2202    <sql>
2203      SELECT dcb.numLayers
2204      FROM DataCubeData dcb
2205      WHERE dcb.id = :dataCube
2206    </sql>
2207    <description>
2208      A Hibernate query that gets the current number of layers
2209      for the specified data cube.
2210    </description>
2211  </query>
2212
2213  <query id="UPDATE_COLUMNNO_FOR_DATACUBE" type="HQL">
2214    <sql>
2215      UPDATE DataCubeData dcb
2216      SET dcb.numColumns = dcb.numColumns + 1
2217      WHERE dcb.id = :dataCube
2218    </sql>
2219    <description>
2220      A Hibernate query that updates the number of columns
2221      for the specified data cube.
2222    </description>
2223  </query>
2224
2225  <query id="GET_COLUMNNO_FOR_DATACUBE" type="HQL">
2226    <sql>
2227      SELECT dcb.numColumns
2228      FROM DataCubeData dcb
2229      WHERE dcb.id = :dataCube
2230    </sql>
2231    <description>
2232      A Hibernate query that gets the current number of columns
2233      for the specified data cube.
2234    </description>
2235  </query>
2236
2237  <query id="GET_JOBAGENT_FOR_EXTERNALID" type="HQL">
2238    <sql>
2239      SELECT jag
2240      FROM JobAgentData jag
2241      WHERE jag.externalId = :externalId
2242    </sql>
2243    <description>
2244      A Hibernate query that loads the job agent with the specified external ID.
2245    </description>
2246  </query>
2247
2248  <query id="GET_KEYS_FOR_PLUGIN" type="HQL">
2249    <sql>
2250      SELECT pdk
2251      FROM PluginKeys pdk
2252      WHERE pdk.pluginDefinitionId = :pluginId
2253      ORDER BY pdk.keyId
2254    </sql>
2255    <description>
2256      A Hibernate query that loads all PluginDefinitionKeys for a specified plugin ID.
2257    </description>
2258  </query>
2259 
2260  <query id="LOAD_DEFAULT_GROUPS" type="HQL">
2261    <sql>
2262      SELECT grp
2263      FROM GroupData grp
2264      WHERE grp.default = true
2265    </sql>
2266    <description>
2267      A HQL query that loads all groups which are marked as default
2268      groups.
2269    </description>
2270  </query>
2271 
2272  <query id="LOAD_DEFAULT_ROLES" type="HQL">
2273    <sql>
2274      SELECT rle
2275      FROM RoleData rle
2276      WHERE rle.default = true
2277    </sql>
2278    <description>
2279      A HQL query that loads all roles which are marked as default
2280      roles.
2281    </description>
2282  </query>
2283 
2284  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
2285    <sql>
2286      SELECT {1}
2287      FROM RawBioAssayData rba
2288      WHERE rba.platform = :platform
2289    </sql>
2290    <description>
2291      A Hibernate query that gets raw bioassays
2292      with a given platform.
2293    </description>
2294  </query>
2295
2296  <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL">
2297    <sql>
2298      SELECT {1}
2299      FROM ArrayDesignData ad
2300      WHERE ad.platform = :platform
2301    </sql>
2302    <description>
2303      A Hibernate query that gets array designs
2304      with a given platform.
2305    </description>
2306  </query>
2307 
2308  <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL">
2309    <sql>
2310      SELECT {1}
2311      FROM RawBioAssayData rba
2312      WHERE rba.variant = :variant
2313    </sql>
2314    <description>
2315      A Hibernate query that gets raw bioassays
2316      with a given platform variant.
2317    </description>
2318  </query>
2319
2320  <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL">
2321    <sql>
2322      SELECT {1}
2323      FROM ArrayDesignData ad
2324      WHERE ad.variant = :variant
2325    </sql>
2326    <description>
2327      A Hibernate query that gets array designs
2328      with a given platform variant.
2329    </description>
2330  </query>
2331 
2332  <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL">
2333    <sql>
2334      SELECT plf
2335      FROM PlatformData plf
2336      WHERE plf.externalId = :externalId
2337    </sql>
2338    <description>
2339      A Hibernate query that loads a platform by external ID.
2340    </description>
2341  </query>
2342 
2343  <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL">
2344    <sql>
2345      SELECT plv
2346      FROM PlatformVariantData plv
2347      WHERE plv.externalId = :externalId
2348    </sql>
2349    <description>
2350      A Hibernate query that loads a platform variant by external ID.
2351    </description>
2352  </query>
2353 
2354  <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL">
2355    <sql>
2356      SELECT dft
2357      FROM DataFileTypeData dft
2358      WHERE dft.externalId = :externalId
2359    </sql>
2360    <description>
2361      A Hibernate query that loads a data file type by external ID.
2362    </description>
2363  </query>
2364
2365  <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL">
2366    <sql>
2367      SELECT {1}
2368      FROM FileSetMemberData mbr
2369      WHERE mbr.dataFileType = :dataFileType
2370    </sql>
2371    <description>
2372      A Hibernate query that gets file set members of a specific
2373      data file type.
2374    </description>
2375  </query>
2376
2377  <query id="GET_PLATFORMFILETYPE_FOR_DATAFILETYPE" type="HQL">
2378    <sql>
2379      SELECT {1}
2380      FROM PlatformFileTypeData pft
2381      WHERE pft.dataFileType = :dataFileType
2382    </sql>
2383    <description>
2384      A Hibernate query that gets platform file types of a specific
2385      data file type.
2386    </description>
2387  </query>
2388 
2389  <query id="GET_ITEMSUBTYPES_FOR_DATAFILETYPE" type="HQL">
2390    <sql>
2391      SELECT {1}
2392      FROM ItemSubtypeFileTypeData sft
2393      WHERE sft.dataFileType = :dataFileType
2394    </sql>
2395    <description>
2396      A Hibernate query that gets item subtype file types for a specific
2397      data file type.
2398    </description>
2399  </query>
2400 
2401 
2402  <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
2403    <sql>
2404      SELECT mbr
2405      FROM FileSetMemberData mbr
2406      WHERE mbr.dataFileType.externalId = :externalId
2407      AND mbr.fileSet = :fileSet
2408    </sql>
2409    <description>
2410      A Hibernate query that loads a member in a given file set
2411      if we know the external ID of the data file type.
2412    </description>
2413  </query>
2414
2415 
2416  <query id="UPDATE_JOB_STATUS" type="HQL">
2417    <sql>
2418      UPDATE JobData job
2419      SET
2420        job.percentComplete = :percent,
2421        job.statusMessage = :statusMessage
2422      WHERE job.id = :id
2423    </sql>
2424    <description>
2425      A HQL query that updates the progress information on a specific job.
2426    </description>
2427  </query>
2428 
2429  <query id="APPEND_JOB_STATUS" type="HQL">
2430    <sql>
2431      UPDATE JobData job
2432      SET
2433        job.statusMessage = job.statusMessage || :statusMessage
2434      WHERE job.id = :id
2435    </sql>
2436    <description>
2437      A HQL query that appends a string to the status message on a specific job.
2438    </description>
2439  </query>
2440
2441  <query id="LOAD_RAWBIOASSAY_JOBS_IN_EXPERIMENT" type="HQL">
2442    <sql>
2443      SELECT DISTINCT rba.job.id
2444      FROM RawBioAssayData rba
2445      WHERE rba.job.experiment = :experiment
2446    </sql>
2447    <description>
2448      A HQL query that loads the ID:s of all jobs that are part
2449      of a given experiment and also has been assigned to at
2450      least one raw bioassay.
2451    </description>
2452  </query>
2453 
2454  <query id="LOAD_ARRAYDESIGN_JOBS_IN_EXPERIMENT" type="HQL">
2455    <sql>
2456      SELECT ad.job.id
2457      FROM ArrayDesignData ad
2458      WHERE ad.job.experiment = :experiment
2459    </sql>
2460    <description>
2461      A HQL query that loads the ID:s of all jobs that are part
2462      of a given experiment and also has been assigned to at
2463      least one array design.
2464    </description>
2465  </query>
2466
2467  <query id="UNLINK_JOBS_FROM_EXPERIMENT" type="HQL">
2468    <sql>
2469      UPDATE JobData job
2470      SET job.experiment = null
2471      WHERE job.id IN (:list)
2472    </sql>
2473    <description>
2474      A HQL query that set the experiment property to null for
2475      a given set of jobs.
2476    </description>
2477  </query>
2478 
2479  <query id="GET_UNIT_WITH_NAME_FOR_QUANTITY" type="HQL">
2480    <sql>
2481      SELECT unt
2482      FROM UnitData unt
2483      WHERE unt.quantity = :quantity
2484      AND unt.name = :name
2485    </sql>
2486    <description>
2487      A HQL query that finds the unit for a quantity
2488      with a given name.
2489    </description>
2490  </query>
2491
2492  <query id="GET_UNITS_FOR_QUANTITY" type="HQL">
2493    <sql>
2494      SELECT {1}
2495      FROM UnitData unt
2496      WHERE unt.quantity = :quantity
2497    </sql>
2498    <description>
2499      A Hibernate query that gets units
2500      for a given quantity.
2501    </description>
2502  </query>
2503
2504  <query id="GET_ANNOTATIONTYPES_FOR_QUANTITY" type="HQL">
2505    <sql>
2506      SELECT {1}
2507      FROM AnnotationTypeData at
2508      WHERE at.quantity = :quantity
2509    </sql>
2510    <description>
2511      A Hibernate query that gets annotation types
2512      that are using a given quantity.
2513    </description>
2514  </query>
2515 
2516  <query id="GET_ANNOTATIONTYPES_FOR_UNIT" type="HQL">
2517    <sql>
2518      SELECT {1}
2519      FROM AnnotationTypeData at
2520      WHERE at.defaultUnit = :unit
2521    </sql>
2522    <description>
2523      A Hibernate query that gets annotation types
2524      that are using a given unit as default unit.
2525    </description>
2526  </query>
2527 
2528  <query id="GET_ANNOTATIONS_FOR_UNIT" type="HQL">
2529    <sql>
2530      SELECT {1}
2531      FROM AnnotationData a
2532      WHERE a.unit = :unit
2533    </sql>
2534    <description>
2535      A Hibernate query that gets annotations
2536      that are using a given unit.
2537    </description>
2538  </query>
2539 
2540  <query id="GET_UNIT_WITH_SYMBOL_FOR_QUANTITY" type="HQL">
2541    <sql>
2542      SELECT unt
2543      FROM UnitData unt
2544      JOIN unt.symbols smb
2545      WHERE unt.quantity = :quantity
2546      AND smb.symbol = :symbol
2547    </sql>
2548    <description>
2549      A HQL query that finds the unit for a quantity
2550      with a given symbol.
2551    </description>
2552  </query>
2553 
2554  <query id="GET_UNIT_WITH_SYMBOL_FOR_UNIT" type="HQL">
2555    <sql>
2556      SELECT smb.unit
2557      FROM UnitSymbolData smb
2558      JOIN smb.quantity qnt
2559      JOIN qnt.units unt
2560      WHERE unt = :unit
2561      AND smb.symbol = :symbol
2562    </sql>
2563    <description>
2564      A HQL query that finds the unit with a given symbol
2565      that has the same quantity as another unit.
2566    </description>
2567  </query>
2568 
2569  <query id="SET_UNIT_TO_NULL_ON_PROPERTY_FILTERS" type="SQL">
2570    <sql>
2571      UPDATE [PropertyFilters]
2572      SET [unit_id] = null
2573      WHERE [unit_id] = :unit
2574    </sql>
2575    <description>
2576      A SQL query that sets the unit to null for all properties
2577      with a given unit (about to be deleted).
2578    </description>
2579  </query>
2580 
2581  <query id="RECALCULATE_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="SQL">
2582    <sql>
2583      UPDATE [{1}]
2584      SET [value] = [value] * :factor + :offset
2585      WHERE [id] IN
2586      (
2587        SELECT [value_id]
2588        FROM [Annotations]
2589        WHERE [annotationtype_id] = :annotationType
2590      )
2591    </sql>
2592    <description>
2593      A SQL query that recalculates the annotation values for
2594      a given annotation type.
2595    </description>
2596  </query>
2597 
2598  <query id="SET_UNIT_ON_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="HQL">
2599    <sql>
2600      UPDATE AnnotationData a
2601      SET a.unit = :unit
2602      WHERE a.annotationType = :annotationType
2603    </sql>
2604    <description>
2605      A HQL query that changes the unit for all annotations with a given
2606      annotation type.
2607    </description>
2608  </query>
2609 
2610  <query id="RECALCULATE_ANNOTATIONS_FOR_UNIT" type="SQL">
2611    <sql>
2612      UPDATE [{1}] SET [value] = [value] * :factor + :offset
2613      WHERE [id] IN
2614      (
2615        SELECT [a].[value_id]
2616        FROM [Annotations] [a]
2617        JOIN [AnnotationTypes] [at] ON [at].[id] = [a].[annotationtype_id]
2618        WHERE [at].[value_type] = :valueType
2619        AND
2620        (
2621          (:case = 1 AND [a].[unit_id] = :unit AND [at].[default_unit_id] &lt;&gt; :unit)
2622          OR
2623          (:case = 2 AND [a].[unit_id] &lt;&gt; :unit AND [at].[default_unit_id] = :unit)
2624        )
2625      )
2626    </sql>
2627    <description>
2628      A SQL query that recalculates the annotation values for
2629      when reference factor and/or offset changes. The query must handle
2630      two cases where either the annotation type's default unit
2631      or the annotation's unit matched. More info in doc for the
2632      Unit.changeReferenceFactorAndOffset() method.
2633    </description>
2634  </query>
2635
2636  <query id="UPDATE_ITEMLIST_SIZE" type="SQL">
2637    <sql>
2638      UPDATE [ItemLists]
2639      SET [size] = [size] + :delta
2640      WHERE [member_type] = :memberType
2641      AND [id] = ANY(
2642        SELECT [list_id]
2643        FROM [ItemListMembers]
2644        WHERE [item_id] = :itemId
2645      )
2646    </sql>
2647    <description>
2648      An update query that changes the size for all item lists
2649      where a given item is a member. Mainly used to decrease
2650      the size when an item is deleted.
2651    </description>
2652  </query>
2653 
2654  <query id="DELETE_ITEMLIST_MEMBER" type="SQL">
2655    <sql>
2656      DELETE FROM [ItemListMembers]
2657      WHERE [item_id] = :itemId
2658      AND [list_id] = ANY(
2659        SELECT [id]
2660        FROM [ItemLists]
2661        WHERE [member_type] = :memberType
2662      )
2663    </sql>
2664    <description>
2665      An update query that delete the list member entries
2666      for all lists where the given item is a member.
2667    </description>
2668  </query>
2669 
2670  <query id="GET_BIOMATERIAL_ON_PLATE" type="HQL">
2671    <sql>
2672      SELECT {1}
2673      FROM MeasuredBioMaterialData mbm
2674      JOIN mbm.bioWell bw
2675      WHERE bw.bioPlate = :bioPlate
2676    </sql>
2677    <description>
2678      A HQL query that gets MeasuredBioMaterial:s
2679      located on a given bioplate.
2680    </description>
2681  </query>
2682  <query id="FIND_USED_TYPES_IN_ANYTOANY" type="SQL">
2683    <sql>
2684      SELECT [a].[from_type] FROM [AnyToAny] [a]
2685      UNION
2686      SELECT [a].[to_type] FROM [AnyToAny] [a]
2687    </sql>
2688    <description>
2689      An SQL query that selects all used item types in any-to-any
2690      links. It must select both the the 'from' and 'to' item type.
2691    </description>
2692  </query>
2693  <query id="SELECT_STRAY_ANYTOANY" type="SQL">
2694    <sql>
2695      SELECT [a].[id]
2696      FROM [AnyToAny] [a]
2697      LEFT JOIN [{1}] [t]
2698        ON ([t].[id] = [a].[from_id] AND [a].[from_type] = :type)
2699        OR ([t].[id] = [a].[to_id] AND [a].[to_type] = :type)
2700      WHERE [t].[id] IS NULL
2701      AND ([a].[from_type] = :type OR [a].[to_type] = :type)
2702    </sql>
2703    <description>
2704      An SQL query that selects the ID of all any-to-any links were
2705      either the 'from' or 'to' item is missing. A single query
2706      is used to delete all items of a specific type (both
2707      'from' and 'to).
2708    </description>
2709  </query>
2710  <query id="DELETE_STRAY_ANYTOANY" type="HQL">
2711    <sql>
2712      DELETE FROM AnyToAnyData
2713      WHERE id IN (:ids)
2714    </sql>
2715    <description>
2716      A HQL query that deletes all any-to-any links with the
2717      id's given in the list.
2718    </description>
2719  </query>
2720  <query id="FIND_USED_TYPES_IN_CHANGEHISTORY" type="HQL">
2721    <sql>
2722      SELECT DISTINCT ch.itemType FROM ChangeHistoryDetailData ch
2723    </sql>
2724    <description>
2725      An HQL query that selects all used item types in the change
2726      history table.
2727    </description>
2728  </query>
2729  <query id="DELETE_STRAY_CHANGEHISTORY" type="HQL">
2730    <sql>
2731      DELETE FROM ChangeHistoryDetailData
2732      WHERE id IN (:ids)
2733    </sql>
2734    <description>
2735      A HQL query that deletes all change history entries with the
2736      id's given in the list.
2737    </description>
2738  </query>
2739  <query id="SELECT_STRAY_CHANGEHISTORY" type="SQL">
2740    <sql>
2741      SELECT [ch].[id]
2742      FROM [ChangeHistoryDetails] [ch]
2743      LEFT JOIN [{1}] [t]
2744        ON ([t].[id] = [ch].[item_id] AND [ch].[item_type] = :type)
2745      WHERE [t].[id] IS NULL
2746      AND [ch].[item_type] = :type
2747    </sql>
2748    <description>
2749      An SQL query that selects the ID of all change history entries
2750      that references a missing item of a specified type.
2751    </description>
2752  </query>
2753  <query id="DBLOG_GET_ANNOTATIONTYPE_INFO" type="HQL">
2754    <sql>
2755      SELECT at.name, at.valueType, at.disableLogOfValues, at.projectAnnotations
2756      FROM AnnotationTypeData at
2757      WHERE at.id = :annotationTypeId
2758    </sql>
2759    <description>
2760      An HQL query that loads the 'name', 'valueType', 'disableLogOfValues' and
2761      the 'projectAnnotations' flag for an annotation type given the ID.
2762    </description>
2763  </query>
2764  <query id="DBLOG_GET_ANNOTATION_ITEMTYPE" type="HQL">
2765    <sql>
2766      SELECT a.itemType
2767      FROM AnnotationSetData a
2768      WHERE a.id = :annotationSetId
2769    </sql>
2770    <description>
2771      An HQL query that loads the item type value an annotation
2772      set with a given ID belongs to.
2773    </description>
2774  </query>
2775  <query id="DBLOG_GET_ITEMID_WITH_ANNOTATION" type="HQL">
2776    <sql>
2777      SELECT i.id
2778      FROM {1} i
2779      WHERE i.annotationSet = :annotationSetId
2780    </sql>
2781    <description>
2782      An HQL query that loads the ID of the item that
2783      is associated with a given annotation set.
2784    </description>
2785  </query>
2786  <query id="DBLOG_GET_NAME_FOR_ITEM" type="HQL">
2787    <sql>
2788      SELECT i.name
2789      FROM {1} i
2790      WHERE i.id = :id
2791    </sql>
2792    <description>
2793      An HQL query that loads the name of a an item.
2794    </description>
2795  </query>
2796  <query id="DBLOG_GET_FILESET_ITEMTYPE" type="HQL">
2797    <sql>
2798      SELECT fs.itemType
2799      FROM FileSetData fs
2800      WHERE fs.id = :fileSetId
2801    </sql>
2802    <description>
2803      An HQL query that loads the item type value a file set
2804      set with a given ID belongs to.
2805    </description>
2806  </query>
2807  <query id="DBLOG_GET_ITEMID_WITH_FILESET" type="HQL">
2808    <sql>
2809      SELECT i.id
2810      FROM {1} i
2811      WHERE i.fileSet = :fileSetId
2812    </sql>
2813    <description>
2814      An HQL query that loads the ID of the item that
2815      is associated with a given file set.
2816    </description>
2817  </query>
2818  <query id="DBLOG_INSERT_INTO_CHANGEHISTORYDETAILS" type="SQL">
2819    <sql>
2820      INSERT INTO [ChangeHistoryDetails]
2821        ([id], [version], [history_id], [change_type], [item_id], [item_type], [change_info], [old_value], [new_value])
2822      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, ?, ?)
2823    </sql>
2824    <description>
2825      SQL query for inserting rows into the ChangeHistoryDetails table.
2826      The primary key (id) must be auto-generated.
2827      Parameters: history_id, change_type, item_id, item_type, change_info, old_value, new_value
2828    </description>
2829  </query>
2830  <query id="GET_GROUPS_WITH_NONHIDDENMEMBERS" type="HQL">
2831    <sql>
2832      SELECT grp.id
2833      FROM GroupData grp
2834      WHERE grp.hiddenMembers = false
2835      AND grp.id IN (:groups)
2836    </sql>
2837    <description>
2838      A HQL query that selects the ID of the groups among a given set of
2839      groups that has 'hiddenMembers=false'
2840    </description>
2841  </query>
2842  <query id="GET_BIOPLATES_FOR_BIOPLATETYPE" type="HQL">
2843    <sql>
2844      SELECT {1}
2845      FROM BioPlateData bpl
2846      WHERE bpl.bioPlateType = :bioPlateType
2847    </sql>
2848    <description>
2849      A HQL query that gets the bioplates using a given type.
2850    </description>
2851  </query>
2852 
2853  <query id="GET_BIOPLATETYPE_WITH_NAME" type="HQL">
2854    <sql>
2855      SELECT bpt
2856      FROM BioPlateTypeData bpt
2857      WHERE bpt.name = :name
2858    </sql>
2859    <description>
2860      A HQL query that gets the bioplate type with a given name.
2861    </description>
2862  </query>
2863  <query id="GET_PROJECTS_FOR_PERMISSION_TEMPLATE" type="HQL">
2864    <sql>
2865      SELECT {1}
2866      FROM ProjectData prj
2867      WHERE prj.permissionTemplate = :permissionTemplate
2868    </sql>
2869    <description>
2870      A HQL query that gets the projects that are using a given permission
2871      template.
2872    </description>
2873  </query>
2874
2875  <query id="SET_GROUP_TO_NULL_ON_DISK_USAGE" type="HQL">
2876    <sql>
2877      UPDATE DiskUsageData du
2878        SET du.group = null
2879        WHERE du.group = :group
2880    </sql>
2881    <description>
2882      An HQL update-query that sets group to null on all
2883      diskusage that are associated with a given group.
2884    </description>
2885  </query>
2886
2887  <query id="CLEAR_ORIGINAL_BIOMATERIAL_ON_BIOWELLS" type="HQL">
2888    <sql>
2889      UPDATE BioWellData bw
2890      SET bw.originalBioMaterial = null
2891      WHERE bw.originalBioMaterial = :bioMaterial
2892    </sql>
2893    <description>
2894      An HQL update-query that for a given biomaterial clears the
2895      link on all biowells were it is set as the original biomaterial.
2896    </description>
2897  </query>
2898
2899  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATEEVENT" type="HQL">
2900    <sql>
2901      UPDATE BioMaterialEventData bme
2902      SET bme.bioPlateEventParticipant = null
2903      WHERE bme.bioPlateEventParticipant =ANY (
2904        SELECT bep FROM BioPlateEventParticipantData bep
2905        WHERE bep.event = :event
2906      )
2907    </sql>
2908    <description>
2909      An HQL update-query that clears the references to a given
2910      bioplate event on all biomaterial events that links to it
2911      (via the bioplate event participant table).
2912    </description>
2913  </query>
2914
2915  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATE" type="HQL">
2916    <sql>
2917      UPDATE BioMaterialEventData bme
2918      SET bme.bioPlateEventParticipant = null
2919      WHERE bme.bioPlateEventParticipant =ANY (
2920        SELECT bep FROM BioPlateEventParticipantData bep
2921        WHERE bep.bioPlate = :bioPlate
2922      )
2923    </sql>
2924    <description>
2925      An HQL update-query that clears the references to all bioplate
2926      event participants on biomaterial events for a given bioplate.
2927    </description>
2928  </query>
2929
2930  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_PARTICIPANT" type="HQL">
2931    <sql>
2932      UPDATE BioMaterialEventData bme
2933      SET bme.bioPlateEventParticipant = null
2934      WHERE bme.bioPlateEventParticipant = :participant
2935    </sql>
2936    <description>
2937      An HQL update-query that clears the references to a given bioplate
2938      event participant on all related biomaterial events.
2939    </description>
2940  </query>
2941
2942  <query id="GET_BIOPLATEEVENTS_FOR_BIOPLATEEVENTTYPE" type="HQL">
2943    <sql>
2944      SELECT {1}
2945      FROM BioPlateEventData bpe
2946      WHERE bpe.eventType = :eventType
2947    </sql>
2948    <description>
2949      An HQL update-query that gets the bioplate events that are
2950      of a given bioplate event type.
2951    </description>
2952  </query>
2953 
2954  <query id="GET_JAR_PATH_FROM_TABLE" type="SQL">
2955    <sql>
2956      SELECT [id], [jar_path] FROM [{1}] [t]
2957      where [t].[jar_file] IS NULL AND NOT [t].[jar_path] IS NULL
2958    </sql>
2959    <description>
2960      An SQL query that selects the ID and JAR_PATH column from a given table
2961      where the existing JAR_PATH has a value and the existing JAR_FILE is
2962      null.
2963    </description>
2964  </query>
2965
2966  <query id="SET_JAR_FILE_IN_TABLE" type="SQL">
2967    <sql>
2968      UPDATE [{1}] SET [jar_file] = :file WHERE id = :id
2969    </sql>
2970    <description>
2971      An SQL query that updates the JAR_FILE with the given value.
2972    </description>
2973  </query>
2974 
2975  <query id="DROP_COLUMN" type="SQL">
2976    <sql>
2977      ALTER TABLE [{1}] DROP COLUMN [{2}]
2978    </sql>
2979    <description>
2980      An SQL query that drops a column (2) from a table (1).
2981    </description>
2982  </query>
2983 
2984  <query id="DROP_NOT_NULL_CONSTRAINT" type="SQL">
2985    <sql>
2986      ALTER TABLE [{1}] ALTER COLUMN [{2}] DROP NOT NULL
2987    </sql>
2988    <description>
2989      An SQL query that drops a NOT NULL contraint from column (2) in a table (1).
2990    </description>
2991  </query>
2992
2993  <query id="DROP_TABLE" type="SQL">
2994    <sql>
2995      DROP TABLE [{1}]
2996    </sql>
2997    <description>
2998      An SQL query that drops a table (1).
2999    </description>
3000  </query>
3001
3002  <query id="CONVERT_LABELEDEXTRACTS_TO_EXTRACTS" type="SQL">
3003    <sql>
3004      UPDATE [BioMaterials]
3005      SET [discriminator] = 3
3006      WHERE [discriminator] = 4
3007    </sql>
3008    <description>
3009      An SQL query that convert labeled extract to extract.
3010    </description>
3011  </query>
3012
3013  <query id="GET_HYBRIDIZATIONS" type="SQL">
3014    <sql>
3015      SELECT
3016        [id], [version],
3017        [arrayslide_id], [num_arrays],
3018        [annotationset_id], [name],
3019        [description], [removed],
3020        [itemkey_id], [projectkey_id],
3021        [owner]
3022      FROM
3023        [Hybridizations]
3024    </sql>
3025    <description>
3026      An SQL query that load all BASE 2.17 hybridizations.
3027    </description>
3028  </query>
3029
3030  <query id="UPDATE_BIOASSAYID_FROM_HYBID" type="SQL">
3031    <sql>
3032      UPDATE [BioMaterialEvents]
3033      SET [physicalbioassay_id] = :bioAssayId
3034      WHERE [hybridization_id] = :hybId
3035    </sql>
3036    <description>
3037      An SQL query that sets the physicalbioassay_id
3038      for a given hybridization_id
3039    </description>
3040  </query>
3041
3042  <query id="GET_SCANS" type="SQL">
3043    <sql>
3044      SELECT
3045        [id], [version],
3046        [entry_date], [hybridization_id],
3047        [hardware_id], [protocol_id],
3048        [annotationset_id], [name],
3049        [description], [removed],
3050        [itemkey_id], [projectkey_id],
3051        [owner]
3052      FROM
3053        [Scans]
3054    </sql>
3055    <description>
3056      An SQL query that load all BASE 2.17 scans.
3057    </description>
3058  </query>
3059
3060  <query id="GET_IMAGES" type="SQL">
3061    <sql>
3062      SELECT
3063        [id], [version],
3064        [file_id]
3065      FROM
3066        [Images]
3067      WHERE [scan_id] = :scanId
3068    </sql>
3069    <description>
3070      An SQL query that load BASE 2.17 image files for a given scan.
3071    </description>
3072  </query>
3073
3074  <query id="GET_PROTOCOLTYPES" type="SQL">
3075    <sql>
3076      SELECT
3077        [id], [version],
3078        [entry_date], [name],
3079        [description], [removed],
3080        [system_id]
3081      FROM
3082        [ProtocolTypes]
3083    </sql>
3084    <description>
3085      An SQL query that load all BASE 2.17 protocol types.
3086    </description>
3087  </query>
3088
3089  <query id="GET_HARDWARETYPES" type="SQL">
3090    <sql>
3091      SELECT
3092        [id], [version],
3093        [entry_date], [name],
3094        [description], [removed],
3095        [system_id]
3096      FROM
3097        [HardwareTypes]
3098    </sql>
3099    <description>
3100      An SQL query that load all BASE 2.17 hardware types.
3101    </description>
3102  </query>
3103 
3104  <query id="GET_SOFTWARETYPES" type="SQL">
3105    <sql>
3106      SELECT
3107        [id], [version],
3108        [entry_date], [name],
3109        [description], [system_id]
3110      FROM
3111        [SoftwareTypes]
3112    </sql>
3113    <description>
3114      An SQL query that load all BASE 2.17 software types.
3115    </description>
3116  </query>
3117
3118  <query id="GET_FILETYPES" type="SQL">
3119    <sql>
3120      SELECT
3121        [id], [version],
3122        [entry_date], [name],
3123        [description], [system_id]
3124      FROM
3125        [FileTypes]
3126    </sql>
3127    <description>
3128      An SQL query that load all BASE 2.17 file types.
3129    </description>
3130  </query>
3131
3132  <query id="GET_RAWBIOASSAYS" type="SQL">
3133    <sql>
3134      SELECT
3135        [id], [scan_id],
3136        [array_num]
3137      FROM [RawBioAssays]
3138      WHERE NOT [scan_id] IS NULL
3139    </sql>
3140    <description>
3141      An SQL query that load scan and array num for all raw bioassays
3142      that has a scan parent.
3143    </description>
3144  </query>
3145
3146  <query id="FIND_EXTRACT_FOR_RAWBIOASSAY_POSITION" type="SQL">
3147    <sql>
3148      SELECT bm2.[biomaterial_id]
3149      FROM [DerivedBioAssays] dba
3150      INNER JOIN [ParentPhysicalBioAssays] pba ON pba.[derivedbioassay_id] = dba.[id]
3151      INNER JOIN [BioMaterialEvents] bme ON bme.[physicalbioassay_id] = pba.[physicalbioassay_id]
3152      INNER JOIN [BioMaterialEventSources2] bm2 ON bm2.[event_id]=bme.[id]
3153      WHERE bm2.[position] = :position AND dba.[id] = :derivedBioAssayId
3154    </sql>
3155    <description>
3156      An SQL query that tries to find the extract id given a
3157      derived bioassay and the bioassay position.
3158    </description>
3159  </query>
3160 
3161  <query id="UPDATE_RAWBIOASSAY" type="SQL">
3162    <sql>
3163      UPDATE [RawBioAssays]
3164      SET [bioassay_id] = :parentBioAssayId,
3165      [extract_id] = :extractId
3166      WHERE [id] = :rawBioAssayId
3167    </sql>
3168    <description>
3169      An SQL query that update the parent bioassay and extract
3170      for a given raw bioassay.
3171    </description>
3172  </query>
3173
3174
3175  <query id="COPY_BIOMATERIALEVENTSOURCES" type="SQL">
3176    <sql>
3177      INSERT INTO [BioMaterialEventSources2]
3178      (
3179        [id], [version],
3180        [biomaterial_id], [event_id],
3181        [used_quantity], [position]
3182      )
3183      SELECT
3184        {1}, 0,
3185        [biomaterial_id], [event_id],
3186        [used_quantity], [dummy]
3187      FROM [BioMaterialEventSources]
3188    </sql>
3189    <description>
3190      An SQL query that load copy BASE 2.17 biomaterial
3191      event sources to the new table.
3192    </description>
3193  </query>
3194
3195  <query id="COPY_SAMPLE_BIOSOURCE_PARENT_LINK" type="SQL">
3196    <sql>
3197      INSERT INTO [BioMaterialEventSources2]
3198      (
3199        [id], [version],
3200        [biomaterial_id], [event_id],
3201        [used_quantity], [position]
3202      )
3203      SELECT
3204        {1}, 0,
3205        bm.[parent_id], evt.[id],
3206        null, 1
3207      FROM [BioMaterials] bm
3208      INNER JOIN [BioMaterialEvents] evt ON bm.[id]=evt.[biomaterial_id] AND evt.[event_type]=1
3209      WHERE bm.[discriminator] = 2 AND NOT bm.[parent_id] IS NULL
3210    </sql>
3211    <description>
3212      An SQL query that copy Sample--BioSource parent
3213      links to the BioMaterialEventSources2 table.
3214    </description>
3215  </query>
3216
3217  <query id="NULLIFY_ALL_BIOMATERIAL_PARENTS" type="SQL">
3218    <sql>
3219      UPDATE [BioMaterials]
3220      SET [parent_type] = NULL, [parent_id] = NULL
3221    </sql>
3222    <description>
3223      An SQL query that nullify all biomaterial parent
3224      information.
3225    </description>
3226  </query>
3227
3228  <query id="GET_BIOMATERIAL_PARENT_INFO" type="SQL">
3229    <sql>
3230      SELECT bm.[id], bm.[discriminator], evt.[biomaterial_id]
3231      FROM [BioMaterialEventSources2] bm2
3232      INNER JOIN [BioMaterialEvents] evt ON bm2.[event_id]=evt.[id] AND evt.[event_type]=1
3233      INNER JOIN [BioMaterials] bm ON bm2.[biomaterial_id]=bm.[id]
3234      ORDER BY evt.[biomaterial_id]
3235    </sql>
3236    <description>
3237      An SQL query that get parent biomaterial information. We need
3238      parent_id, parent_type and child_id ordered by child_id
3239    </description>
3240  </query>
3241
3242
3243  <query id="SET_BIOMATERIAL_PARENT" type="SQL">
3244    <sql>
3245      UPDATE [BioMaterials]
3246      SET [parent_type] = :parentType, [parent_id] = :parentId
3247      WHERE [id] = :childId
3248    </sql>
3249    <description>
3250      An SQL query that set the biomaterial parent info for a single
3251      biomaterial.
3252    </description>
3253  </query>
3254
3255  <query id="SET_LABELEDEXTRACT_SUBTYPE" type="SQL">
3256    <sql>
3257      UPDATE [BioMaterials]
3258      SET [subtype_id]=:subtype
3259      WHERE [label_id] IS NOT NULL
3260    </sql>
3261    <description>
3262      An SQL query that sets the subtype of labeled extracts
3263    </description>
3264  </query>
3265
3266  <query id="SET_SUBTYPE_ON_ALL" type="SQL">
3267    <sql>
3268      UPDATE [{1}]
3269      SET [subtype_id]=:subtype
3270    </sql>
3271    <description>
3272      An SQL query that sets the subtype
3273      of all items in a table
3274    </description>
3275  </query>
3276
3277  <query id="UPDATE_ANNOTATIONSET_ITEM" type="SQL">
3278    <sql>
3279      UPDATE [AnnotationSets]
3280      SET [item_id] = :newId, [item_type] = {1}
3281      WHERE [id] = :id
3282    </sql>
3283    <description>
3284      An SQL query that update the item_type and item_id
3285      on annotation set.
3286    </description>
3287  </query>
3288
3289  <query id="UPDATE_ANYTOANY_FROMITEM" type="SQL">
3290    <sql>
3291      UPDATE [AnyToAny]
3292      SET [from_id] = :newId, [from_type] = {2}
3293      WHERE [from_id] = :oldId AND [from_type] = {1}
3294    </sql>
3295    <description>
3296      An SQL query that update the from_type and from_id
3297      on any-to-any.
3298    </description>
3299  </query>
3300 
3301  <query id="UPDATE_ANYTOANY_TOITEM" type="SQL">
3302    <sql>
3303      UPDATE [AnyToAny]
3304      SET [to_id] = :newId, [to_type] = {2}
3305      WHERE [to_id] = :oldId AND [to_type] = {1}
3306    </sql>
3307    <description>
3308      An SQL query that update the to_type and to_id
3309      on any-to-any.
3310    </description>
3311  </query>
3312 
3313  <query id="UPDATE_CHANGEHISTORYDETAILS_ITEM" type="SQL">
3314    <sql>
3315      UPDATE [ChangeHistoryDetails]
3316      SET [item_id] = :newId, [item_type] = {2}
3317      WHERE [item_id] = :oldId AND [item_type] = {1}
3318    </sql>
3319    <description>
3320      An SQL query that update the item_type and item_id
3321      on change history details.
3322    </description>
3323  </query>
3324 
3325  <query id="UPDATE_ITEMVALUES_ITEM" type="SQL">
3326    <sql>
3327      UPDATE [ItemValues]
3328      SET [data_class_id] = :newId, [data_class] = :newClass
3329      WHERE [data_class_id] = :oldId AND [data_class] = :oldClass
3330    </sql>
3331    <description>
3332      An SQL query that update the data_class_id and data_class
3333      on item values.
3334    </description>
3335  </query>
3336
3337  <query id="UPDATE_ITEMVALUES_CLASS" type="SQL">
3338    <sql>
3339      UPDATE [ItemValues]
3340      SET [data_class] = :newClass
3341      WHERE [data_class] = :oldClass
3342    </sql>
3343    <description>
3344      An SQL query that update the data_class
3345      on item values.
3346    </description>
3347  </query>
3348
3349  <query id="UPDATE_ITEMTYPE" type="SQL">
3350    <sql>
3351      UPDATE [{1}]
3352      SET [{2}] = {4}
3353      WHERE [{2}] = {3}
3354    </sql>
3355    <description>
3356      An SQL query that update the item-type column on
3357      a generic table.
3358    </description>
3359  </query>
3360
3361  <query id="UPDATE_SUBTYPEID_FROM_OLDTYPEID" type="SQL">
3362    <sql>
3363      UPDATE [{1}]
3364      SET [{2}] = :subtypeId
3365      WHERE [{3}] = :oldTypeId
3366    </sql>
3367    <description>
3368      An SQL query that update the subtype_id column on
3369      a generic table.
3370    </description>
3371  </query>
3372
3373
3374  <query id="DELETE_PLUGINGUICONTEXTS_FOR_ITEMTYPE" type="SQL">
3375    <sql>
3376      DELETE FROM [PluginDefinitionGuiContexts]
3377      WHERE [item_type] = :itemType
3378    </sql>
3379    <description>
3380      An SQL query that delete plug-in gui contexts for
3381      a given item type.
3382    </description>
3383  </query>
3384
3385  <query id="DELETE_PLUGINKEYS_FOR_ITEMTYPE" type="SQL">
3386    <sql>
3387      DELETE FROM [PluginKeys]
3388      WHERE [key_id] IN (
3389        SELECT k.[id]
3390        FROM [Keys] k
3391        WHERE k.[item_type] = :itemType
3392      )
3393    </sql>
3394    <description>
3395      An SQL query that delete plug-in keys referencing keys
3396      for a given item type.
3397    </description>
3398  </query>
3399
3400
3401  <query id="GET_SUBTYPABLE_ITEMS_FOR_SUBTYPE_OF_CLASS" type="HQL">
3402    <sql>
3403      SELECT {1}
3404      FROM {2} sub
3405      WHERE sub.itemSubtype = :subtype
3406    </sql>
3407    <description>
3408      Get all items that are subtyped with a subtype for a given class.
3409    </description>
3410  </query>
3411 
3412  <query id="GET_ITEMLISTS_FOR_SUBTYPE" type="HQL">
3413    <sql>
3414      SELECT {1}
3415      FROM ItemListData il
3416      WHERE il.itemSubtype = :subtype
3417    </sql>
3418    <description>
3419      A Hibernate query that gets ITEMLISTS for a given item subtype.
3420    </description>
3421  </query>
3422 
3423  <query id="GET_MIMETYPES_FOR_FILETYPE" type="HQL">
3424    <sql>
3425      SELECT {1}
3426      FROM MimeTypeData mt
3427      WHERE mt.fileType = :subtype
3428    </sql>
3429    <description>
3430      A Hibernate query that gets MIME types for a given item subtype.
3431    </description>
3432  </query>
3433 
3434  <query id="GET_DATAFILETYPES_FOR_FILETYPE" type="HQL">
3435    <sql>
3436      SELECT {1}
3437      FROM DataFileTypeData dft
3438      WHERE dft.genericType = :subtype
3439    </sql>
3440    <description>
3441      A Hibernate query that gets Data file types for a given item subtype.
3442    </description>
3443  </query>
3444 
3445  <query id="UPDATE_FILESETMEMBER_FILETYPE" type="HQL">
3446    <sql>
3447      UPDATE FileSetMemberData mbr
3448      SET mbr.dataFileType = :newType
3449      WHERE mbr.dataFileType = :oldType
3450    </sql>
3451    <description>
3452      A Hibernate query that update the data file type of all
3453      file set members with a given old data file type.
3454    </description>
3455  </query>
3456 
3457  <query id="DISABLE_ALL_PLUGINS" type="HQL">
3458    <sql>
3459      UPDATE PluginDefinitionData pl
3460      SET pl.disabled = true
3461    </sql>
3462    <description>
3463      A Hibernate query that disable all plug-ins.
3464    </description>
3465  </query>
3466 
3467  <query id="GET_PROJECT_DEFAULT_ANYTOANY" type="HQL">
3468    <sql>
3469      SELECT a FROM AnyToAnyData a
3470      WHERE a.fromType = 24 AND a.name LIKE 'default_%'
3471    </sql>
3472    <description>
3473      A Hibernate query that load all any-to-any links containing
3474      project default items.
3475    </description>
3476  </query>
3477 
3478  <query id="GET_MD5_PASSWORDS" type="SQL">
3479    <sql>
3480      SELECT [id], [md5password] FROM [Passwords]
3481    </sql>
3482    <description>
3483      An SQL query that load all md5 passwords.
3484    </description>
3485  </query>
3486
3487  <query id="SET_ENCRYPTED_PASSWORD" type="SQL">
3488    <sql>
3489      UPDATE [Passwords]
3490      SET [crypted_password] = :cryptedPassword
3491      WHERE [id] = :id
3492    </sql>
3493    <description>
3494      An SQL query that set the encrypted password for a given entry.
3495    </description>
3496  </query>
3497 
3498  <query id="GET_VIRTUALDBS_FOR_REPORTERCLONETEMPLATE" type="HQL">
3499    <sql>
3500      SELECT {1}
3501      FROM VirtualDbData vdb
3502      WHERE vdb.reporterCloneTemplate = :reporterCloneTemplate
3503    </sql>
3504    <description>
3505      A Hibernate query that get virtual databases
3506      that are using a given reporter clone template.
3507    </description>
3508  </query>
3509
3510  <query id="GET_ALL_ANNOTATIONTYPE_IDS_FOR_USER" type="SQL">
3511    <sql>
3512      SELECT [at].[id]
3513      FROM [AnnotationTypes] [at]
3514      WHERE [at].[owner] = :owner
3515      OR [at].[itemkey_id] IN (:itemKeys)
3516      OR [at].[projectkey_id] IN (:projectKeys)
3517    </sql>
3518    <description>
3519      An SQL query that load the ID of all the annotation types
3520      that the current user has access to. We need to set owner,
3521      item keys and project keys as parameters.
3522    </description>
3523  </query>
3524
3525  <query id="COPY_PARENT_PHYSICAL_BIOASSAYS" type="SQL">
3526    <sql>
3527      INSERT INTO [ParentPhysicalBioAssays] ([physicalbioassay_id], [derivedbioassay_id])
3528      SELECT [bioassay_id], [id] FROM [DerivedBioAssays]
3529    </sql>
3530    <description>
3531      An SQL query that copy the parent physical bioassays
3532      to the new (in BASE 3.2) ParentPhysicalBioAssays table
3533    </description>
3534  </query>
3535
3536
3537  <query id="COPY_PARENT_DERIVED_BIOASSAYS" type="SQL">
3538    <sql>
3539      INSERT INTO [ParentDerivedBioAssays] ([parentbioassay_id], [derivedbioassay_id])
3540      SELECT [parent_id], [id] FROM [DerivedBioAssays] WHERE NOT [parent_id] IS NULL
3541    </sql>
3542    <description>
3543      An SQL query that copy the parent derived bioassays
3544      to the new (in BASE 3.2) ParentDerivedBioAssays table
3545    </description>
3546  </query>
3547
3548  <query id="SET_ISROOT_ON_DERIVED_BIOASSAYS" type="SQL">
3549    <sql>
3550      UPDATE [DerivedBioAssays] SET [is_root] = ([parent_id] IS NULL)
3551    </sql>
3552    <description>
3553      An SQL query that set the is_root property on DerivedBioAssays table.
3554    </description>
3555  </query>
3556 
3557  <query id="GET_ITEMSUBTYPE_WITH_NAME_AND_ITEMTYPE" type="HQL">
3558    <sql>
3559      SELECT st FROM ItemSubtypeData st
3560      WHERE st.name = :name AND st.itemType = :itemType
3561    </sql>
3562    <description>
3563      A Hibernate query that load an item subtype given the name
3564      and main item type.
3565    </description>
3566  </query>
3567 
3568  <query id="SET_DISABLE_LOG_FOR_ANNOTATION_TYPES" type="HQL">
3569    <sql>
3570      UPDATE AnnotationTypeData at
3571      SET at.disableLogOfValues = false
3572      WHERE at.disableLogOfValues IS NULL
3573    </sql>
3574    <description>
3575      An HQL query that set the disableLogOfValues=false for all annotation types
3576      with a null value.
3577    </description>
3578  </query>
3579
3580  <query id="AB_LOAD_ANNOTATION_INFO" type="SQL">
3581    <sql>
3582      SELECT [annotationtype_id], [id], [version], [unit_id], [value_id], [last_update], [project_id], [override_id]
3583      FROM [Annotations]
3584      WHERE [annotationset_id] = :annotationSet AND [source] = 0 AND ([project_id] = :defaultProject OR [project_id] = :activeProject)
3585    </sql>
3586    <description>
3587      SQL query for loading current (primary) annotations for
3588      a given item.
3589      Used by the AnnotationBatcher as a SQL query via Hibernate.
3590    </description>
3591  </query>
3592
3593  <query id="AB_LOAD_ANNOTATION_VALUES" type="SQL">
3594    <sql>
3595      SELECT [id], [value]
3596      FROM [{1}]
3597      WHERE [id] IN (:listOfIds)
3598    </sql>
3599    <description>
3600      SQL query for loading current annotation values
3601      for a given list of annotation value IDs.
3602      Used by the AnnotationBatcher as a SQL query via Hibernate.
3603    </description>
3604  </query>
3605
3606  <query id="AB_INSERT_INTO_PARAMETERVALUES" type="SQL">
3607    <sql>
3608      INSERT INTO [ParameterValues] ([id], [discriminator], [version])
3609      VALUES (nextval('hibernate_sequence'), ?, 0)
3610    </sql>
3611    <description>
3612      SQL query for inserting rows into the ParameterValues table.
3613      The primary key (id) must be auto-generated.
3614      Parameters: discriminator
3615    </description>
3616  </query>
3617
3618  <query id="AB_INSERT_INTO_ANNOTATIONS" type="SQL">
3619    <sql>
3620      INSERT INTO [Annotations] ([id], [version], [annotationset_id], [annotationtype_id], [unit_id], [value_id], [last_update], [source], [project_id], [override_id])
3621      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, 0, ?, ?)
3622    </sql>
3623    <description>
3624      SQL query for inserting rows into the Annotations table.
3625      The primary key (id) must be auto-generated.
3626      Parameters: annotationset_id, annotationtype_id, unit_id, value_id, last_updated, project_id, override_id
3627    </description>
3628  </query>
3629
3630  <query id="AB_UPDATE_ANNOTATIONS" type="SQL">
3631    <sql>
3632      UPDATE [Annotations]
3633      SET [version] = ?, [unit_id] = ?, [last_update] = ?
3634      WHERE [id] = ? AND [version] = ?
3635    </sql>
3636    <description>
3637      SQL query for updating rows into the Annotations table.
3638      Parameters: version (new), unit_id, last_updated, id, version (old)
3639    </description>
3640  </query>
3641
3642  <query id="AB_INSERT_INTO_ANNOTATIONSETS" type="SQL">
3643    <sql>
3644      INSERT INTO [AnnotationSets] ([id], [version], [item_type], [item_id])
3645      VALUES (nextval('hibernate_sequence'), 0, {1}, ?)
3646    </sql>
3647    <description>
3648      SQL query for inserting rows into the AnnotationSets table.
3649      The primary key (id) must be auto-generated.
3650      Parameters: item_id
3651    </description>
3652  </query>
3653 
3654  <query id="AB_UPDATE_ITEMTABLE" type="SQL">
3655    <sql>
3656      UPDATE [{1}]
3657      SET [annotationset_id] = ?
3658      WHERE [id] = ?
3659    </sql>
3660    <description>
3661      SQL query for updating the annotationset_id column in any
3662      table it exists in.
3663      Parameters: annotationset_id, item_id
3664    </description>
3665  </query>
3666
3667  <query id="AB_NULLIFY_CLONED_ANNOTATIONS" type="SQL">
3668    <sql>
3669      UPDATE [Annotations]
3670      SET [inherited_id] = null
3671      WHERE [inherited_id] = ? and [source] = 2
3672    </sql>
3673    <description>
3674      SQL query for setting the 'inherited_id' column to null
3675      for cloned annotations that reference the annotation that
3676      is about to be deleted.
3677      Parameters: inherited_id
3678    </description>
3679  </query>
3680
3681  <query id="AB_DELETE_INHERITED_ANNOTATIONS" type="SQL">
3682    <sql>
3683      DELETE FROM [Annotations]
3684      WHERE [inherited_id] = ? and [source] = 1
3685    </sql>
3686    <description>
3687      SQL query for deleting inherited annotations that reference
3688      the annotation that is about to be deleted.
3689      Parameters: inherited_id
3690    </description>
3691  </query>
3692
3693  <query id="AB_DELETE_FROM_ANNOTATIONS" type="SQL">
3694    <sql>
3695      DELETE FROM [Annotations]
3696      WHERE [id] = ?
3697    </sql>
3698    <description>
3699      SQL query for deleting an annotation with a given id.
3700      Used by the AnnotationBatcher as a PreparedStatement.
3701      Parameters: id
3702    </description>
3703  </query>
3704
3705  <query id="AB_DELETE_FROM_PARAMETERVALUES" type="SQL">
3706    <sql>
3707      DELETE FROM [ParameterValues] WHERE [id] = ?
3708    </sql>
3709    <description>
3710      SQL query for deleting a parameter value with a given id.
3711      Used by the AnnotationBatcher as a PreparedStatement.
3712    </description>
3713  </query>
3714
3715  <query id="AB_DELETE_FROM_VALUES" type="SQL">
3716    <sql>
3717      DELETE FROM [{1}] WHERE [id] = ?
3718    </sql>
3719    <description>
3720      SQL query for deleting all actual annotation values with a given id.
3721      The {1} parameter is the table the value are stored in, eg. StringValues,
3722      IntegerValues, FloatValues, etc.
3723      Used by the AnnotationBatcher as a PreparedStatement.
3724    </description>
3725  </query>
3726 
3727  <query id="AB_INSERT_INTO_VALUES" type="SQL">
3728    <sql>
3729      INSERT INTO [{1}] ([id], [value]) VALUES (?, ?)
3730    </sql>
3731    <description>
3732      SQL query for inserting annotation values in their respective
3733      table (eg. StringValues, IntegerValues, FloatValues, etc.).
3734      Used by the AnnotationBatcher as a PreparedStatement.
3735    </description>
3736  </query>
3737 
3738  <query id="AB_UPDATE_OVERRIDE_ID" type="SQL">
3739    <sql>
3740      UPDATE [Annotations]
3741      SET [override_id] = ?
3742      WHERE [annotationset_id] = ?
3743      AND [annotationtype_id] = ?
3744      AND [source] = 0
3745      AND [project_id] &lt;&gt; 0
3746    </sql>
3747    <description>
3748      Updates the "override_id" column on project-specific annotations
3749      to point to a newly created default annotation of the same
3750      annotation type (PRIMARY annotations only).
3751      Used by the AnnotationBatcher as a PreparedStatement.
3752      Parameters: override_id, annotationset_id, annotationtype_id
3753    </description>
3754  </query>
3755 
3756 
3757  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF" type="SQL">
3758    <sql>
3759      UPDATE [Annotations]
3760      SET [override_id] = :annotationId
3761      WHERE [annotationset_id] = :annotationSetId
3762      AND [annotationtype_id] = :annotationTypeId
3763      AND [source] = 0
3764      AND [project_id] &lt;&gt; 0
3765    </sql>
3766    <description>
3767      Updates the "override_id" column on project-specific annotations
3768      to point to a newly created default annotation of the same
3769      annotation type (PRIMARY annotations only).
3770    </description>
3771  </query>
3772 
3773  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION" type="SQL">
3774    <sql>
3775      UPDATE [Annotations]
3776      SET [override_id] = COALESCE(
3777        (SELECT [id] FROM [Annotations]
3778        WHERE [annotationset_id] = :annotationSetId
3779        AND [annotationtype_id] = :annotationTypeId
3780        AND [source] = 0 AND [project_id] = 0)
3781        , 0)
3782      WHERE id = :annotationId
3783    </sql>
3784    <description>
3785      Updates the "override_id" column on a newly created project-specific
3786      (PRIMARY) annotation to point to the existing default annotation id
3787      or 0 if no default annotation exists.
3788    </description>
3789  </query>
3790 
3791  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF_INHERITED" type="HQL">
3792    <sql>
3793      UPDATE [Annotations]
3794      SET [override_id] = :annotationId
3795      WHERE [annotationset_id] = :annotationSetId
3796      AND [inherited_id] IN (
3797        SELECT [id] FROM [Annotations]
3798        WHERE [annotationset_id] = :parentSetId
3799        AND [override_id] = :parentId
3800      )
3801    </sql>
3802    <description>
3803      Updates the "override_id" column on project-specific annotations
3804      to point to a newly created default annotation (INHERITED and
3805      CLONED annotations). The subquery will find project-specific annotation
3806      on the parent annotation set that is overriding the inherited annotation.
3807    </description>
3808  </query>
3809 
3810  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION_INHERITED" type="SQL">
3811    <sql>
3812      UPDATE [Annotations]
3813      SET [override_id] = COALESCE(
3814        (SELECT [id] FROM [Annotations]
3815        WHERE [annotationset_id] = :annotationSetId
3816        AND [inherited_id] = :parentOverrideId
3817        AND [source] &lt;&gt; 0
3818        AND [project_id] = 0)
3819        , 0)
3820      WHERE id = :annotationId
3821    </sql>
3822    <description>
3823      Updates the "override_id" column on a newly created project-specific
3824      (CLONED or INHERITED) annotation to point to the existing default
3825      annotation id or 0 if no default annotation exists.
3826    </description>
3827  </query>
3828 
3829  <query id="PS_RESET_OVERRIDE_ON_PROJECT_ANNOTATIONS" type="HQL">
3830    <sql>
3831      UPDATE [Annotations] 
3832      SET [override_id] = 0
3833      WHERE [override_id] IN (:deletedAnnotations)
3834      OR [inherited_id] IN (
3835        SELECT [id] FROM [Annotations]
3836        WHERE [override_id] IN (:deletedPrimaryAnnotations)
3837      )
3838    </sql>
3839    <description>
3840      Reset the "override_id" column on project-specific annotations
3841      that points to a default annotation that has been removed.
3842    </description>
3843  </query>
3844   
3845  <query id="PS_LOAD_ANNOTATIONS_IN_NON_EXISTING_PROJECTS" type="SQL">
3846    <sql>
3847      SELECT a.[id], a.[annotationset_id], a.[value_id], a.[project_id], at.[value_type]
3848      FROM [Annotations] a
3849      INNER JOIN [AnnotationTypes] at ON at.[id] = a.[annotationtype_id]
3850      WHERE a.[project_id] &lt;&gt; 0 AND a.[project_id] NOT IN (SELECT [id] FROM [Projects])
3851    </sql>
3852    <description>
3853      SQL query for loading information about annotations
3854      that are project-specific annotations for a given
3855      list of projects.
3856      Used by the ProjectSpecificAnnotationsManager when
3857      a project has been deleted.
3858    </description>
3859  </query>
3860 
3861  <query id="PS_DELETE_FROM_PARAMETERVALUES" type="SQL">
3862    <sql>
3863      DELETE FROM [ParameterValues] WHERE [id] IN (:deletedValues)
3864    </sql>
3865    <description>
3866      SQL query for deleting mutliple parameter values with a given id's.
3867      Used by the ProjectSpecificAnnotationsManager.
3868    </description>
3869  </query>
3870
3871  <query id="PS_DELETE_FROM_VALUES" type="SQL">
3872    <sql>
3873      DELETE FROM [{1}] WHERE [id] IN (:deletedValues)
3874    </sql>
3875    <description>
3876      SQL query for deleting all actual annotation values with given id's.
3877      The {1} parameter is the table the value are stored in, eg. StringValues,
3878      IntegerValues, FloatValues, etc.
3879      Used by the ProjectSpecificAnnotationsManager.
3880    </description>
3881  </query>
3882 
3883  <query id="PS_DELETE_FROM_ANNOTATIONS_IN_PROJECTS" type="SQL">
3884    <sql>
3885      DELETE FROM [Annotations] WHERE [project_id] IN (:deletedProjects)
3886    </sql>
3887    <description>
3888      SQL query for deleting all annotation entries referenceing
3889      given list of projects.
3890      Used by the ProjectSpecificAnnotationsManager.
3891    </description>
3892  </query>
3893 
3894  <query id="PS_FIND_PROJECT_SPECIFIC_ANNOTATION" type="HQL">
3895    <sql>
3896      SELECT ad FROM AnnotationData ad
3897      WHERE ad.projectId = :activeProject
3898      AND ad.overrideId = :defaultAnnotation
3899      AND ad.annotationSet = :annotationSet
3900    </sql>
3901    <description>
3902      HQL query for locating a project-specific annotation
3903      overriding a specified default annotation.
3904      Used by the ProjectSpecificAnnotationsManager.
3905    </description>
3906  </query>
3907 
3908  <query id="COUNT_PROJECT_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
3909    <sql>
3910      SELECT count(*)
3911      FROM AnnotationData ad
3912      WHERE ad.annotationType = :annotationType
3913      AND ad.projectId &lt;&gt; 0
3914    </sql>
3915    <description>
3916      HQL query that counts the number of project-specific annotations
3917      for an annotation type.
3918    </description>
3919  </query>
3920 
3921  <query id="GET_USER_DEVICE" type="HQL">
3922    <sql>
3923      SELECT dev
3924      FROM UserDeviceData dev
3925      WHERE dev.user = :userId
3926      AND dev.client = :clientId
3927      AND dev.token = :token
3928    </sql>
3929    <description>
3930      HQL query that selects a device for a given user and client
3931      with a given device token.
3932    </description>
3933  </query>
3934
3935</predefined-queries>
Note: See TracBrowser for help on using the repository browser.