source: trunk/src/core/common-queries.xml @ 7997

Last change on this file since 7997 was 7997, checked in by Nicklas Nordborg, 2 years ago

Updated documentation about MySQL support is ending.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 98.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 7997 2021-08-09 13:32:20Z 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      GROUP BY plg.mainType
1859    </sql>
1860    <description>
1861      A Hibernate query that counts the number of plugins available for a
1862      given GUI context grouped by the main type of the plugins taking
1863      the requirement of configurations and user permissions into account.
1864    </description>
1865  </query>
1866 
1867  <query id="GET_FORMULA_WITH_NAME_AND_CHANNELS" type="HQL">
1868    <sql>
1869      SELECT fml
1870      FROM FormulaData fml
1871      WHERE fml.name = :name
1872      AND fml.channels = :channels
1873    </sql>
1874    <description>
1875      A Hibernate query that loads a formula with a given name and number
1876      of channels.
1877    </description>
1878  </query>
1879
1880  <query id="GET_FORMULA_WITH_NAME_AND_TYPE" type="HQL">
1881    <sql>
1882      SELECT fml
1883      FROM FormulaData fml
1884      WHERE fml.name = :name
1885      AND fml.rawDataType = :rawDataType
1886    </sql>
1887    <description>
1888      A Hibernate query that loads a formula with a given name and raw data type.
1889    </description>
1890  </query>
1891 
1892  <query id="GET_HELP_FOR_EXTERNAL_ID" type="HQL">
1893    <sql>
1894      SELECT hlp
1895      FROM HelpData hlp
1896      WHERE hlp.externalId = :externalId AND hlp.client = :client
1897    </sql>
1898    <description>
1899      A Hibernate query that loads a help text.
1900    </description>
1901  </query>
1902 
1903  <query id="GET_SCHEMA_VERSION_FOR_APP" type="HQL">
1904    <sql>
1905      SELECT sv
1906      FROM SchemaVersionData sv
1907      WHERE sv.appId = :appId
1908    </sql>
1909    <description>
1910      A Hibernate query that loads the schema version for a
1911      given application (there should only be one record since appId is unique).
1912    </description>
1913  </query>
1914 
1915  <query id="SET_SCHEMA_VERSION_FOR_APP" type="HQL">
1916    <sql>
1917      UPDATE SchemaVersionData sv
1918      SET sv.schemaVersion = :schemaVersion,
1919      sv.build = :build
1920      WHERE sv.appId = :appId
1921    </sql>
1922    <description>
1923      A Hibernate query that updates the schema version and build number.
1924    </description>
1925  </query>
1926 
1927  <query id="GET_PRIMARY_ANNOTATION" type="HQL">
1928    <sql>
1929      SELECT ad
1930      FROM AnnotationData ad
1931      WHERE ad.annotationType = :annotationType
1932      AND ad.annotationSet = :annotationSet
1933      AND ad.source = 0
1934    </sql>
1935    <description>
1936      A Hibernate query that loads the primary annotation of a specific
1937      annotation type for a given annotation set.
1938    </description>
1939  </query>
1940 
1941  <query id="LOAD_ANNOTATIONSET_INHERITING_ANNOTATIONTYPE" type="SQL">
1942    <sql>
1943      SELECT [a].[annotationset_id] FROM [Annotations] [a]
1944      WHERE [a].[annotationtype_id] = :annotationType
1945      AND [a].[source] != 0
1946    </sql>
1947    <description>
1948      An SQL query that load the ID of all annotation sets that
1949      are inheriting a given annotation type.
1950    </description>
1951  </query>
1952 
1953  <query id="DELETE_INHERITED_ANNOTATIONS" type="SQL">
1954    <sql>
1955      DELETE FROM [Annotations]
1956      WHERE [annotationtype_id] = :annotationType
1957      AND [source] != 0
1958    </sql>
1959    <description>
1960      An SQL query that delete all inherited annotations of the specified
1961      annotation type.
1962    </description>
1963  </query>
1964 
1965  <query id="NULLIFY_LINK_FROM_CLONES" type="HQL">
1966    <sql>
1967      UPDATE AnnotationData ad
1968      SET ad.inheritedFrom = null
1969      WHERE ad.inheritedFrom = :targetId
1970      AND ad.source = 2
1971    </sql>
1972    <description>
1973      A HQL query that nullify the link from all cloned annotations
1974      to a specified target annotation.
1975    </description>
1976  </query>
1977 
1978  <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL">
1979    <sql>
1980      UPDATE ExperimentData xpm
1981      SET xpm.bytes = xpm.bytes + :addedBytes
1982      WHERE xpm.id = :experiment
1983    </sql>
1984    <description>
1985      A Hibernate query that updates the number of bytes used by an experiment.
1986    </description>
1987  </query>
1988
1989  <query id="UPDATE_BYTES_FOR_DATACUBE" type="HQL">
1990    <sql>
1991      UPDATE DataCubeData dcd
1992      SET dcd.bytes = dcd.bytes + :addedBytes
1993      WHERE dcd.id = :dataCube
1994    </sql>
1995    <description>
1996      A Hibernate query that updates the number of bytes used by a data cube.
1997    </description>
1998  </query>
1999 
2000  <query id="GET_REMOVED_ITEMS" type="HQL">
2001    <sql>
2002      SELECT trash
2003      FROM net.sf.basedb.core.data.RemovableData trash
2004      WHERE NOT trash.removedBy IS NULL
2005    </sql>
2006    <description>
2007      A Hibernate query that loads all items flagged for deletion.
2008    </description>
2009  </query>
2010 
2011  <query id="UPDATE_REMAINING_QUANTITY" type="HQL">
2012    <sql>
2013      UPDATE MeasuredBioMaterialData mbm
2014      SET mbm.remainingQuantity = mbm.remainingQuantity - :used
2015      WHERE mbm = :bioMaterial
2016    </sql>
2017    <description>
2018      A Hibernate query that adds/removes the remaining quantity on a
2019      measuered biomaterial.
2020    </description>
2021  </query>
2022 
2023  <query id="GET_REMAINING_QUANTITY" type="HQL">
2024    <sql>
2025      SELECT mbm.remainingQuantity
2026      FROM MeasuredBioMaterialData mbm
2027      WHERE mbm = :bioMaterial
2028    </sql>
2029    <description>
2030      A Hibernate query that load the remaining quantity for a
2031      measuered biomaterial.
2032    </description>
2033  </query>
2034
2035  <query id="GET_ANYTOANY_FOR_NAME" type="HQL">
2036    <sql>
2037      SELECT ata
2038      FROM AnyToAnyData ata
2039      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2040    </sql>
2041    <description>
2042      A Hibernate query that loads the any-to-any link with the specified name
2043      for an item.
2044    </description>
2045  </query>
2046
2047  <query id="DELETE_ANYTOANY_FROM" type="HQL">
2048    <sql>
2049      DELETE FROM AnyToAnyData ata
2050      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2051    </sql>
2052    <description>
2053      A Hibernate query that deletes a names any-to-any link leading out from
2054      an item.
2055    </description>
2056  </query>
2057
2058
2059  <query id="DELETE_ALL_ANYTOANY_FROM" type="HQL">
2060    <sql>
2061      DELETE FROM AnyToAnyData ata
2062      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2063    </sql>
2064    <description>
2065      A Hibernate query that deletes all any-to-any links leading out from
2066      an item.
2067    </description>
2068  </query>
2069 
2070  <query id="DELETE_ALL_ANYTOANY_TO" type="HQL">
2071    <sql>
2072      DELETE FROM AnyToAnyData ata
2073      WHERE ata.toId = :toId AND ata.toType = :toType
2074    </sql>
2075    <description>
2076      A Hibernate query that deletes all any-to-any links leading in to an item.
2077    </description>
2078  </query>
2079
2080  <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
2081    <sql>
2082      DELETE FROM AnyToAnyData ata
2083      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = false
2084    </sql>
2085    <description>
2086      A Hibernate query that deletes all any-to-any links leading in to
2087      an item that doesn't count as using the item.
2088    </description>
2089  </query>
2090
2091  <query id="COUNT_USED_ANYTOANY_TO" type="HQL">
2092    <sql>
2093      SELECT count(*)
2094      FROM AnyToAnyData ata
2095      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = true
2096    </sql>
2097    <description>
2098      A Hibernate query that counts the number of any-to-any links
2099      to a given item that counts as using the item.
2100    </description>
2101  </query>
2102
2103  <query id="FIND_USING_ANYTOANY" type="HQL">
2104    <sql>
2105      SELECT ana.fromId, ana.fromType
2106      FROM AnyToAnyData ana
2107      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
2108    </sql>
2109    <description>
2110      A Hibernate query that finds the any-to-any links
2111      to a given item that counts as using the item.
2112    </description>
2113  </query>
2114
2115 
2116  <query id="UPDATE_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2117    <sql>
2118      UPDATE VirtualDbData vdb
2119      SET vdb.cubes = vdb.cubes + 1
2120      WHERE vdb.id = :virtualDb
2121    </sql>
2122    <description>
2123      A Hibernate query that updates the number of data cubes
2124      for the specified virtual database.
2125    </description>
2126  </query>
2127
2128  <query id="GET_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2129    <sql>
2130      SELECT vdb.cubes
2131      FROM VirtualDbData vdb
2132      WHERE vdb.id = :virtualDb
2133    </sql>
2134    <description>
2135      A Hibernate query that gets the current number of data cubes
2136      for the specified virtual database.
2137    </description>
2138  </query>
2139 
2140  <query id="UPDATE_FILTERNO_FOR_DATACUBE" type="HQL">
2141    <sql>
2142      UPDATE DataCubeData dcb
2143      SET dcb.numFilters = dcb.numFilters + 1
2144      WHERE dcb.id = :dataCube
2145    </sql>
2146    <description>
2147      A Hibernate query that updates the number of filters
2148      for the specified data cube.
2149    </description>
2150  </query>
2151
2152  <query id="GET_FILTERNO_FOR_DATACUBE" type="HQL">
2153    <sql>
2154      SELECT dcb.numFilters
2155      FROM DataCubeData dcb
2156      WHERE dcb.id = :dataCube
2157    </sql>
2158    <description>
2159      A Hibernate query that gets the current number of filters
2160      for the specified data cube.
2161    </description>
2162  </query>
2163
2164  <query id="UPDATE_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2165    <sql>
2166      UPDATE DataCubeData dcb
2167      SET dcb.numExtraValues = dcb.numExtraValues + 1
2168      WHERE dcb.id = :dataCube
2169    </sql>
2170    <description>
2171      A Hibernate query that updates the number of extra values
2172      for the specified data cube.
2173    </description>
2174  </query>
2175
2176  <query id="GET_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2177    <sql>
2178      SELECT dcb.numExtraValues
2179      FROM DataCubeData dcb
2180      WHERE dcb.id = :dataCube
2181    </sql>
2182    <description>
2183      A Hibernate query that gets the current number of extra values
2184      for the specified data cube.
2185    </description>
2186  </query>
2187
2188  <query id="UPDATE_LAYERNO_FOR_DATACUBE" type="HQL">
2189    <sql>
2190      UPDATE DataCubeData dcb
2191      SET dcb.numLayers = dcb.numLayers + 1
2192      WHERE dcb.id = :dataCube
2193    </sql>
2194    <description>
2195      A Hibernate query that updates the number of layers
2196      for the specified data cube.
2197    </description>
2198  </query>
2199
2200  <query id="GET_LAYERNO_FOR_DATACUBE" type="HQL">
2201    <sql>
2202      SELECT dcb.numLayers
2203      FROM DataCubeData dcb
2204      WHERE dcb.id = :dataCube
2205    </sql>
2206    <description>
2207      A Hibernate query that gets the current number of layers
2208      for the specified data cube.
2209    </description>
2210  </query>
2211
2212  <query id="UPDATE_COLUMNNO_FOR_DATACUBE" type="HQL">
2213    <sql>
2214      UPDATE DataCubeData dcb
2215      SET dcb.numColumns = dcb.numColumns + 1
2216      WHERE dcb.id = :dataCube
2217    </sql>
2218    <description>
2219      A Hibernate query that updates the number of columns
2220      for the specified data cube.
2221    </description>
2222  </query>
2223
2224  <query id="GET_COLUMNNO_FOR_DATACUBE" type="HQL">
2225    <sql>
2226      SELECT dcb.numColumns
2227      FROM DataCubeData dcb
2228      WHERE dcb.id = :dataCube
2229    </sql>
2230    <description>
2231      A Hibernate query that gets the current number of columns
2232      for the specified data cube.
2233    </description>
2234  </query>
2235
2236  <query id="GET_JOBAGENT_FOR_EXTERNALID" type="HQL">
2237    <sql>
2238      SELECT jag
2239      FROM JobAgentData jag
2240      WHERE jag.externalId = :externalId
2241    </sql>
2242    <description>
2243      A Hibernate query that loads the job agent with the specified external ID.
2244    </description>
2245  </query>
2246
2247  <query id="GET_KEYS_FOR_PLUGIN" type="HQL">
2248    <sql>
2249      SELECT pdk
2250      FROM PluginKeys pdk
2251      WHERE pdk.pluginDefinitionId = :pluginId
2252      ORDER BY pdk.keyId
2253    </sql>
2254    <description>
2255      A Hibernate query that loads all PluginDefinitionKeys for a specified plugin ID.
2256    </description>
2257  </query>
2258 
2259  <query id="LOAD_DEFAULT_GROUPS" type="HQL">
2260    <sql>
2261      SELECT grp
2262      FROM GroupData grp
2263      WHERE grp.default = true
2264    </sql>
2265    <description>
2266      A HQL query that loads all groups which are marked as default
2267      groups.
2268    </description>
2269  </query>
2270 
2271  <query id="LOAD_DEFAULT_ROLES" type="HQL">
2272    <sql>
2273      SELECT rle
2274      FROM RoleData rle
2275      WHERE rle.default = true
2276    </sql>
2277    <description>
2278      A HQL query that loads all roles which are marked as default
2279      roles.
2280    </description>
2281  </query>
2282 
2283  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
2284    <sql>
2285      SELECT {1}
2286      FROM RawBioAssayData rba
2287      WHERE rba.platform = :platform
2288    </sql>
2289    <description>
2290      A Hibernate query that gets raw bioassays
2291      with a given platform.
2292    </description>
2293  </query>
2294
2295  <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL">
2296    <sql>
2297      SELECT {1}
2298      FROM ArrayDesignData ad
2299      WHERE ad.platform = :platform
2300    </sql>
2301    <description>
2302      A Hibernate query that gets array designs
2303      with a given platform.
2304    </description>
2305  </query>
2306 
2307  <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL">
2308    <sql>
2309      SELECT {1}
2310      FROM RawBioAssayData rba
2311      WHERE rba.variant = :variant
2312    </sql>
2313    <description>
2314      A Hibernate query that gets raw bioassays
2315      with a given platform variant.
2316    </description>
2317  </query>
2318
2319  <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL">
2320    <sql>
2321      SELECT {1}
2322      FROM ArrayDesignData ad
2323      WHERE ad.variant = :variant
2324    </sql>
2325    <description>
2326      A Hibernate query that gets array designs
2327      with a given platform variant.
2328    </description>
2329  </query>
2330 
2331  <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL">
2332    <sql>
2333      SELECT plf
2334      FROM PlatformData plf
2335      WHERE plf.externalId = :externalId
2336    </sql>
2337    <description>
2338      A Hibernate query that loads a platform by external ID.
2339    </description>
2340  </query>
2341 
2342  <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL">
2343    <sql>
2344      SELECT plv
2345      FROM PlatformVariantData plv
2346      WHERE plv.externalId = :externalId
2347    </sql>
2348    <description>
2349      A Hibernate query that loads a platform variant by external ID.
2350    </description>
2351  </query>
2352 
2353  <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL">
2354    <sql>
2355      SELECT dft
2356      FROM DataFileTypeData dft
2357      WHERE dft.externalId = :externalId
2358    </sql>
2359    <description>
2360      A Hibernate query that loads a data file type by external ID.
2361    </description>
2362  </query>
2363
2364  <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL">
2365    <sql>
2366      SELECT {1}
2367      FROM FileSetMemberData mbr
2368      WHERE mbr.dataFileType = :dataFileType
2369    </sql>
2370    <description>
2371      A Hibernate query that gets file set members of a specific
2372      data file type.
2373    </description>
2374  </query>
2375
2376  <query id="GET_PLATFORMFILETYPE_FOR_DATAFILETYPE" type="HQL">
2377    <sql>
2378      SELECT {1}
2379      FROM PlatformFileTypeData pft
2380      WHERE pft.dataFileType = :dataFileType
2381    </sql>
2382    <description>
2383      A Hibernate query that gets platform file types of a specific
2384      data file type.
2385    </description>
2386  </query>
2387 
2388  <query id="GET_ITEMSUBTYPES_FOR_DATAFILETYPE" type="HQL">
2389    <sql>
2390      SELECT {1}
2391      FROM ItemSubtypeFileTypeData sft
2392      WHERE sft.dataFileType = :dataFileType
2393    </sql>
2394    <description>
2395      A Hibernate query that gets item subtype file types for a specific
2396      data file type.
2397    </description>
2398  </query>
2399 
2400 
2401  <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
2402    <sql>
2403      SELECT mbr
2404      FROM FileSetMemberData mbr
2405      WHERE mbr.dataFileType.externalId = :externalId
2406      AND mbr.fileSet = :fileSet
2407    </sql>
2408    <description>
2409      A Hibernate query that loads a member in a given file set
2410      if we know the external ID of the data file type.
2411    </description>
2412  </query>
2413
2414 
2415  <query id="UPDATE_JOB_STATUS" type="HQL">
2416    <sql>
2417      UPDATE JobData job
2418      SET
2419        job.percentComplete = :percent,
2420        job.statusMessage = :statusMessage
2421      WHERE job.id = :id
2422    </sql>
2423    <description>
2424      A HQL query that updates the progress information on a specific job.
2425    </description>
2426  </query>
2427 
2428  <query id="APPEND_JOB_STATUS" type="HQL">
2429    <sql>
2430      UPDATE JobData job
2431      SET
2432        job.statusMessage = job.statusMessage || :statusMessage
2433      WHERE job.id = :id
2434    </sql>
2435    <description>
2436      A HQL query that appends a string to the status message on a specific job.
2437    </description>
2438  </query>
2439
2440  <query id="LOAD_RAWBIOASSAY_JOBS_IN_EXPERIMENT" type="HQL">
2441    <sql>
2442      SELECT DISTINCT rba.job.id
2443      FROM RawBioAssayData rba
2444      WHERE rba.job.experiment = :experiment
2445    </sql>
2446    <description>
2447      A HQL query that loads the ID:s of all jobs that are part
2448      of a given experiment and also has been assigned to at
2449      least one raw bioassay.
2450    </description>
2451  </query>
2452 
2453  <query id="LOAD_ARRAYDESIGN_JOBS_IN_EXPERIMENT" type="HQL">
2454    <sql>
2455      SELECT ad.job.id
2456      FROM ArrayDesignData ad
2457      WHERE ad.job.experiment = :experiment
2458    </sql>
2459    <description>
2460      A HQL query that loads the ID:s of all jobs that are part
2461      of a given experiment and also has been assigned to at
2462      least one array design.
2463    </description>
2464  </query>
2465
2466  <query id="UNLINK_JOBS_FROM_EXPERIMENT" type="HQL">
2467    <sql>
2468      UPDATE JobData job
2469      SET job.experiment = null
2470      WHERE job.id IN (:list)
2471    </sql>
2472    <description>
2473      A HQL query that set the experiment property to null for
2474      a given set of jobs.
2475    </description>
2476  </query>
2477 
2478  <query id="GET_UNIT_WITH_NAME_FOR_QUANTITY" type="HQL">
2479    <sql>
2480      SELECT unt
2481      FROM UnitData unt
2482      WHERE unt.quantity = :quantity
2483      AND unt.name = :name
2484    </sql>
2485    <description>
2486      A HQL query that finds the unit for a quantity
2487      with a given name.
2488    </description>
2489  </query>
2490
2491  <query id="GET_UNITS_FOR_QUANTITY" type="HQL">
2492    <sql>
2493      SELECT {1}
2494      FROM UnitData unt
2495      WHERE unt.quantity = :quantity
2496    </sql>
2497    <description>
2498      A Hibernate query that gets units
2499      for a given quantity.
2500    </description>
2501  </query>
2502
2503  <query id="GET_ANNOTATIONTYPES_FOR_QUANTITY" type="HQL">
2504    <sql>
2505      SELECT {1}
2506      FROM AnnotationTypeData at
2507      WHERE at.quantity = :quantity
2508    </sql>
2509    <description>
2510      A Hibernate query that gets annotation types
2511      that are using a given quantity.
2512    </description>
2513  </query>
2514 
2515  <query id="GET_ANNOTATIONTYPES_FOR_UNIT" type="HQL">
2516    <sql>
2517      SELECT {1}
2518      FROM AnnotationTypeData at
2519      WHERE at.defaultUnit = :unit
2520    </sql>
2521    <description>
2522      A Hibernate query that gets annotation types
2523      that are using a given unit as default unit.
2524    </description>
2525  </query>
2526 
2527  <query id="GET_ANNOTATIONS_FOR_UNIT" type="HQL">
2528    <sql>
2529      SELECT {1}
2530      FROM AnnotationData a
2531      WHERE a.unit = :unit
2532    </sql>
2533    <description>
2534      A Hibernate query that gets annotations
2535      that are using a given unit.
2536    </description>
2537  </query>
2538 
2539  <query id="GET_UNIT_WITH_SYMBOL_FOR_QUANTITY" type="HQL">
2540    <sql>
2541      SELECT unt
2542      FROM UnitData unt
2543      JOIN unt.symbols smb
2544      WHERE unt.quantity = :quantity
2545      AND smb.symbol = :symbol
2546    </sql>
2547    <description>
2548      A HQL query that finds the unit for a quantity
2549      with a given symbol.
2550    </description>
2551  </query>
2552 
2553  <query id="GET_UNIT_WITH_SYMBOL_FOR_UNIT" type="HQL">
2554    <sql>
2555      SELECT smb.unit
2556      FROM UnitSymbolData smb
2557      JOIN smb.quantity qnt
2558      JOIN qnt.units unt
2559      WHERE unt = :unit
2560      AND smb.symbol = :symbol
2561    </sql>
2562    <description>
2563      A HQL query that finds the unit with a given symbol
2564      that has the same quantity as another unit.
2565    </description>
2566  </query>
2567 
2568  <query id="SET_UNIT_TO_NULL_ON_PROPERTY_FILTERS" type="SQL">
2569    <sql>
2570      UPDATE [PropertyFilters]
2571      SET [unit_id] = null
2572      WHERE [unit_id] = :unit
2573    </sql>
2574    <description>
2575      A SQL query that sets the unit to null for all properties
2576      with a given unit (about to be deleted).
2577    </description>
2578  </query>
2579 
2580  <query id="RECALCULATE_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="SQL">
2581    <sql>
2582      UPDATE [{1}]
2583      SET [value] = [value] * :factor + :offset
2584      WHERE [id] IN
2585      (
2586        SELECT [value_id]
2587        FROM [Annotations]
2588        WHERE [annotationtype_id] = :annotationType
2589      )
2590    </sql>
2591    <description>
2592      A SQL query that recalculates the annotation values for
2593      a given annotation type.
2594    </description>
2595  </query>
2596 
2597  <query id="SET_UNIT_ON_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="HQL">
2598    <sql>
2599      UPDATE AnnotationData a
2600      SET a.unit = :unit
2601      WHERE a.annotationType = :annotationType
2602    </sql>
2603    <description>
2604      A HQL query that changes the unit for all annotations with a given
2605      annotation type.
2606    </description>
2607  </query>
2608 
2609  <query id="RECALCULATE_ANNOTATIONS_FOR_UNIT" type="SQL">
2610    <sql>
2611      UPDATE [{1}] SET [value] = [value] * :factor + :offset
2612      WHERE [id] IN
2613      (
2614        SELECT [a].[value_id]
2615        FROM [Annotations] [a]
2616        JOIN [AnnotationTypes] [at] ON [at].[id] = [a].[annotationtype_id]
2617        WHERE [at].[value_type] = :valueType
2618        AND
2619        (
2620          (:case = 1 AND [a].[unit_id] = :unit AND [at].[default_unit_id] &lt;&gt; :unit)
2621          OR
2622          (:case = 2 AND [a].[unit_id] &lt;&gt; :unit AND [at].[default_unit_id] = :unit)
2623        )
2624      )
2625    </sql>
2626    <description>
2627      A SQL query that recalculates the annotation values for
2628      when reference factor and/or offset changes. The query must handle
2629      two cases where either the annotation type's default unit
2630      or the annotation's unit matched. More info in doc for the
2631      Unit.changeReferenceFactorAndOffset() method.
2632    </description>
2633  </query>
2634
2635  <query id="UPDATE_ITEMLIST_SIZE" type="SQL">
2636    <sql>
2637      UPDATE [ItemLists]
2638      SET [size] = [size] + :delta
2639      WHERE [member_type] = :memberType
2640      AND [id] = ANY(
2641        SELECT [list_id]
2642        FROM [ItemListMembers]
2643        WHERE [item_id] = :itemId
2644      )
2645    </sql>
2646    <description>
2647      An update query that changes the size for all item lists
2648      where a given item is a member. Mainly used to decrease
2649      the size when an item is deleted.
2650    </description>
2651  </query>
2652 
2653  <query id="DELETE_ITEMLIST_MEMBER" type="SQL">
2654    <sql>
2655      DELETE FROM [ItemListMembers]
2656      WHERE [item_id] = :itemId
2657      AND [list_id] = ANY(
2658        SELECT [id]
2659        FROM [ItemLists]
2660        WHERE [member_type] = :memberType
2661      )
2662    </sql>
2663    <description>
2664      An update query that delete the list member entries
2665      for all lists where the given item is a member.
2666    </description>
2667  </query>
2668 
2669  <query id="GET_BIOMATERIAL_ON_PLATE" type="HQL">
2670    <sql>
2671      SELECT {1}
2672      FROM MeasuredBioMaterialData mbm
2673      JOIN mbm.bioWell bw
2674      WHERE bw.bioPlate = :bioPlate
2675    </sql>
2676    <description>
2677      A HQL query that gets MeasuredBioMaterial:s
2678      located on a given bioplate.
2679    </description>
2680  </query>
2681  <query id="FIND_USED_TYPES_IN_ANYTOANY" type="SQL">
2682    <sql>
2683      SELECT [a].[from_type] FROM [AnyToAny] [a]
2684      UNION
2685      SELECT [a].[to_type] FROM [AnyToAny] [a]
2686    </sql>
2687    <description>
2688      An SQL query that selects all used item types in any-to-any
2689      links. It must select both the the 'from' and 'to' item type.
2690    </description>
2691  </query>
2692  <query id="SELECT_STRAY_ANYTOANY" type="SQL">
2693    <sql>
2694      SELECT [a].[id]
2695      FROM [AnyToAny] [a]
2696      LEFT JOIN [{1}] [t]
2697        ON ([t].[id] = [a].[from_id] AND [a].[from_type] = :type)
2698        OR ([t].[id] = [a].[to_id] AND [a].[to_type] = :type)
2699      WHERE [t].[id] IS NULL
2700      AND ([a].[from_type] = :type OR [a].[to_type] = :type)
2701    </sql>
2702    <description>
2703      An SQL query that selects the ID of all any-to-any links were
2704      either the 'from' or 'to' item is missing. A single query
2705      is used to delete all items of a specific type (both
2706      'from' and 'to).
2707    </description>
2708  </query>
2709  <query id="DELETE_STRAY_ANYTOANY" type="HQL">
2710    <sql>
2711      DELETE FROM AnyToAnyData
2712      WHERE id IN (:ids)
2713    </sql>
2714    <description>
2715      A HQL query that deletes all any-to-any links with the
2716      id's given in the list.
2717    </description>
2718  </query>
2719  <query id="FIND_USED_TYPES_IN_CHANGEHISTORY" type="HQL">
2720    <sql>
2721      SELECT DISTINCT ch.itemType FROM ChangeHistoryDetailData ch
2722    </sql>
2723    <description>
2724      An HQL query that selects all used item types in the change
2725      history table.
2726    </description>
2727  </query>
2728  <query id="DELETE_STRAY_CHANGEHISTORY" type="HQL">
2729    <sql>
2730      DELETE FROM ChangeHistoryDetailData
2731      WHERE id IN (:ids)
2732    </sql>
2733    <description>
2734      A HQL query that deletes all change history entries with the
2735      id's given in the list.
2736    </description>
2737  </query>
2738  <query id="SELECT_STRAY_CHANGEHISTORY" type="SQL">
2739    <sql>
2740      SELECT [ch].[id]
2741      FROM [ChangeHistoryDetails] [ch]
2742      LEFT JOIN [{1}] [t]
2743        ON ([t].[id] = [ch].[item_id] AND [ch].[item_type] = :type)
2744      WHERE [t].[id] IS NULL
2745      AND [ch].[item_type] = :type
2746    </sql>
2747    <description>
2748      An SQL query that selects the ID of all change history entries
2749      that references a missing item of a specified type.
2750    </description>
2751  </query>
2752  <query id="DBLOG_GET_ANNOTATIONTYPE_INFO" type="HQL">
2753    <sql>
2754      SELECT at.name, at.valueType, at.disableLogOfValues
2755      FROM AnnotationTypeData at
2756      WHERE at.id = :annotationTypeId
2757    </sql>
2758    <description>
2759      An HQL query that loads the 'name', 'valueType' and 'disableLogOfValues' flag
2760      for an annotation type given the ID.
2761    </description>
2762  </query>
2763  <query id="DBLOG_GET_ANNOTATION_ITEMTYPE" type="HQL">
2764    <sql>
2765      SELECT a.itemType
2766      FROM AnnotationSetData a
2767      WHERE a.id = :annotationSetId
2768    </sql>
2769    <description>
2770      An HQL query that loads the item type value an annotation
2771      set with a given ID belongs to.
2772    </description>
2773  </query>
2774  <query id="DBLOG_GET_ITEMID_WITH_ANNOTATION" type="HQL">
2775    <sql>
2776      SELECT i.id
2777      FROM {1} i
2778      WHERE i.annotationSet = :annotationSetId
2779    </sql>
2780    <description>
2781      An HQL query that loads the ID of the item that
2782      is associated with a given annotation set.
2783    </description>
2784  </query>
2785  <query id="DBLOG_GET_NAME_FOR_ITEM" type="HQL">
2786    <sql>
2787      SELECT i.name
2788      FROM {1} i
2789      WHERE i.id = :id
2790    </sql>
2791    <description>
2792      An HQL query that loads the name of a an item.
2793    </description>
2794  </query>
2795  <query id="DBLOG_GET_FILESET_ITEMTYPE" type="HQL">
2796    <sql>
2797      SELECT fs.itemType
2798      FROM FileSetData fs
2799      WHERE fs.id = :fileSetId
2800    </sql>
2801    <description>
2802      An HQL query that loads the item type value a file set
2803      set with a given ID belongs to.
2804    </description>
2805  </query>
2806  <query id="DBLOG_GET_ITEMID_WITH_FILESET" type="HQL">
2807    <sql>
2808      SELECT i.id
2809      FROM {1} i
2810      WHERE i.fileSet = :fileSetId
2811    </sql>
2812    <description>
2813      An HQL query that loads the ID of the item that
2814      is associated with a given file set.
2815    </description>
2816  </query>
2817  <query id="DBLOG_INSERT_INTO_CHANGEHISTORYDETAILS" type="SQL">
2818    <sql>
2819      INSERT INTO [ChangeHistoryDetails]
2820        ([id], [version], [history_id], [change_type], [item_id], [item_type], [change_info], [old_value], [new_value])
2821      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, ?, ?)
2822    </sql>
2823    <description>
2824      SQL query for inserting rows into the ChangeHistoryDetails table.
2825      The primary key (id) must be auto-generated.
2826      Parameters: history_id, change_type, item_id, item_type, change_info, old_value, new_value
2827    </description>
2828  </query>
2829  <query id="GET_GROUPS_WITH_NONHIDDENMEMBERS" type="HQL">
2830    <sql>
2831      SELECT grp.id
2832      FROM GroupData grp
2833      WHERE grp.hiddenMembers = false
2834      AND grp.id IN (:groups)
2835    </sql>
2836    <description>
2837      A HQL query that selects the ID of the groups among a given set of
2838      groups that has 'hiddenMembers=false'
2839    </description>
2840  </query>
2841  <query id="GET_BIOPLATES_FOR_BIOPLATETYPE" type="HQL">
2842    <sql>
2843      SELECT {1}
2844      FROM BioPlateData bpl
2845      WHERE bpl.bioPlateType = :bioPlateType
2846    </sql>
2847    <description>
2848      A HQL query that gets the bioplates using a given type.
2849    </description>
2850  </query>
2851 
2852  <query id="GET_BIOPLATETYPE_WITH_NAME" type="HQL">
2853    <sql>
2854      SELECT bpt
2855      FROM BioPlateTypeData bpt
2856      WHERE bpt.name = :name
2857    </sql>
2858    <description>
2859      A HQL query that gets the bioplate type with a given name.
2860    </description>
2861  </query>
2862  <query id="GET_PROJECTS_FOR_PERMISSION_TEMPLATE" type="HQL">
2863    <sql>
2864      SELECT {1}
2865      FROM ProjectData prj
2866      WHERE prj.permissionTemplate = :permissionTemplate
2867    </sql>
2868    <description>
2869      A HQL query that gets the projects that are using a given permission
2870      template.
2871    </description>
2872  </query>
2873
2874  <query id="SET_GROUP_TO_NULL_ON_DISK_USAGE" type="HQL">
2875    <sql>
2876      UPDATE DiskUsageData du
2877        SET du.group = null
2878        WHERE du.group = :group
2879    </sql>
2880    <description>
2881      An HQL update-query that sets group to null on all
2882      diskusage that are associated with a given group.
2883    </description>
2884  </query>
2885
2886  <query id="CLEAR_ORIGINAL_BIOMATERIAL_ON_BIOWELLS" type="HQL">
2887    <sql>
2888      UPDATE BioWellData bw
2889      SET bw.originalBioMaterial = null
2890      WHERE bw.originalBioMaterial = :bioMaterial
2891    </sql>
2892    <description>
2893      An HQL update-query that for a given biomaterial clears the
2894      link on all biowells were it is set as the original biomaterial.
2895    </description>
2896  </query>
2897
2898  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATEEVENT" type="HQL">
2899    <sql>
2900      UPDATE BioMaterialEventData bme
2901      SET bme.bioPlateEventParticipant = null
2902      WHERE bme.bioPlateEventParticipant =ANY (
2903        SELECT bep FROM BioPlateEventParticipantData bep
2904        WHERE bep.event = :event
2905      )
2906    </sql>
2907    <description>
2908      An HQL update-query that clears the references to a given
2909      bioplate event on all biomaterial events that links to it
2910      (via the bioplate event participant table).
2911    </description>
2912  </query>
2913
2914  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATE" type="HQL">
2915    <sql>
2916      UPDATE BioMaterialEventData bme
2917      SET bme.bioPlateEventParticipant = null
2918      WHERE bme.bioPlateEventParticipant =ANY (
2919        SELECT bep FROM BioPlateEventParticipantData bep
2920        WHERE bep.bioPlate = :bioPlate
2921      )
2922    </sql>
2923    <description>
2924      An HQL update-query that clears the references to all bioplate
2925      event participants on biomaterial events for a given bioplate.
2926    </description>
2927  </query>
2928
2929  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_PARTICIPANT" type="HQL">
2930    <sql>
2931      UPDATE BioMaterialEventData bme
2932      SET bme.bioPlateEventParticipant = null
2933      WHERE bme.bioPlateEventParticipant = :participant
2934    </sql>
2935    <description>
2936      An HQL update-query that clears the references to a given bioplate
2937      event participant on all related biomaterial events.
2938    </description>
2939  </query>
2940
2941  <query id="GET_BIOPLATEEVENTS_FOR_BIOPLATEEVENTTYPE" type="HQL">
2942    <sql>
2943      SELECT {1}
2944      FROM BioPlateEventData bpe
2945      WHERE bpe.eventType = :eventType
2946    </sql>
2947    <description>
2948      An HQL update-query that gets the bioplate events that are
2949      of a given bioplate event type.
2950    </description>
2951  </query>
2952 
2953  <query id="GET_JAR_PATH_FROM_TABLE" type="SQL">
2954    <sql>
2955      SELECT [id], [jar_path] FROM [{1}] [t]
2956      where [t].[jar_file] IS NULL AND NOT [t].[jar_path] IS NULL
2957    </sql>
2958    <description>
2959      An SQL query that selects the ID and JAR_PATH column from a given table
2960      where the existing JAR_PATH has a value and the existing JAR_FILE is
2961      null.
2962    </description>
2963  </query>
2964
2965  <query id="SET_JAR_FILE_IN_TABLE" type="SQL">
2966    <sql>
2967      UPDATE [{1}] SET [jar_file] = :file WHERE id = :id
2968    </sql>
2969    <description>
2970      An SQL query that updates the JAR_FILE with the given value.
2971    </description>
2972  </query>
2973 
2974  <query id="DROP_COLUMN" type="SQL">
2975    <sql>
2976      ALTER TABLE [{1}] DROP COLUMN [{2}]
2977    </sql>
2978    <description>
2979      An SQL query that drops a column (2) from a table (1).
2980    </description>
2981  </query>
2982 
2983  <query id="DROP_NOT_NULL_CONSTRAINT" type="SQL">
2984    <sql>
2985      ALTER TABLE [{1}] ALTER COLUMN [{2}] DROP NOT NULL
2986    </sql>
2987    <description>
2988      An SQL query that drops a NOT NULL contraint from column (2) in a table (1).
2989    </description>
2990  </query>
2991
2992  <query id="DROP_TABLE" type="SQL">
2993    <sql>
2994      DROP TABLE [{1}]
2995    </sql>
2996    <description>
2997      An SQL query that drops a table (1).
2998    </description>
2999  </query>
3000
3001  <query id="CONVERT_LABELEDEXTRACTS_TO_EXTRACTS" type="SQL">
3002    <sql>
3003      UPDATE [BioMaterials]
3004      SET [discriminator] = 3
3005      WHERE [discriminator] = 4
3006    </sql>
3007    <description>
3008      An SQL query that convert labeled extract to extract.
3009    </description>
3010  </query>
3011
3012  <query id="GET_HYBRIDIZATIONS" type="SQL">
3013    <sql>
3014      SELECT
3015        [id], [version],
3016        [arrayslide_id], [num_arrays],
3017        [annotationset_id], [name],
3018        [description], [removed],
3019        [itemkey_id], [projectkey_id],
3020        [owner]
3021      FROM
3022        [Hybridizations]
3023    </sql>
3024    <description>
3025      An SQL query that load all BASE 2.17 hybridizations.
3026    </description>
3027  </query>
3028
3029  <query id="UPDATE_BIOASSAYID_FROM_HYBID" type="SQL">
3030    <sql>
3031      UPDATE [BioMaterialEvents]
3032      SET [physicalbioassay_id] = :bioAssayId
3033      WHERE [hybridization_id] = :hybId
3034    </sql>
3035    <description>
3036      An SQL query that sets the physicalbioassay_id
3037      for a given hybridization_id
3038    </description>
3039  </query>
3040
3041  <query id="GET_SCANS" type="SQL">
3042    <sql>
3043      SELECT
3044        [id], [version],
3045        [entry_date], [hybridization_id],
3046        [hardware_id], [protocol_id],
3047        [annotationset_id], [name],
3048        [description], [removed],
3049        [itemkey_id], [projectkey_id],
3050        [owner]
3051      FROM
3052        [Scans]
3053    </sql>
3054    <description>
3055      An SQL query that load all BASE 2.17 scans.
3056    </description>
3057  </query>
3058
3059  <query id="GET_IMAGES" type="SQL">
3060    <sql>
3061      SELECT
3062        [id], [version],
3063        [file_id]
3064      FROM
3065        [Images]
3066      WHERE [scan_id] = :scanId
3067    </sql>
3068    <description>
3069      An SQL query that load BASE 2.17 image files for a given scan.
3070    </description>
3071  </query>
3072
3073  <query id="GET_PROTOCOLTYPES" type="SQL">
3074    <sql>
3075      SELECT
3076        [id], [version],
3077        [entry_date], [name],
3078        [description], [removed],
3079        [system_id]
3080      FROM
3081        [ProtocolTypes]
3082    </sql>
3083    <description>
3084      An SQL query that load all BASE 2.17 protocol types.
3085    </description>
3086  </query>
3087
3088  <query id="GET_HARDWARETYPES" type="SQL">
3089    <sql>
3090      SELECT
3091        [id], [version],
3092        [entry_date], [name],
3093        [description], [removed],
3094        [system_id]
3095      FROM
3096        [HardwareTypes]
3097    </sql>
3098    <description>
3099      An SQL query that load all BASE 2.17 hardware types.
3100    </description>
3101  </query>
3102 
3103  <query id="GET_SOFTWARETYPES" type="SQL">
3104    <sql>
3105      SELECT
3106        [id], [version],
3107        [entry_date], [name],
3108        [description], [system_id]
3109      FROM
3110        [SoftwareTypes]
3111    </sql>
3112    <description>
3113      An SQL query that load all BASE 2.17 software types.
3114    </description>
3115  </query>
3116
3117  <query id="GET_FILETYPES" type="SQL">
3118    <sql>
3119      SELECT
3120        [id], [version],
3121        [entry_date], [name],
3122        [description], [system_id]
3123      FROM
3124        [FileTypes]
3125    </sql>
3126    <description>
3127      An SQL query that load all BASE 2.17 file types.
3128    </description>
3129  </query>
3130
3131  <query id="GET_RAWBIOASSAYS" type="SQL">
3132    <sql>
3133      SELECT
3134        [id], [scan_id],
3135        [array_num]
3136      FROM [RawBioAssays]
3137      WHERE NOT [scan_id] IS NULL
3138    </sql>
3139    <description>
3140      An SQL query that load scan and array num for all raw bioassays
3141      that has a scan parent.
3142    </description>
3143  </query>
3144
3145  <query id="FIND_EXTRACT_FOR_RAWBIOASSAY_POSITION" type="SQL">
3146    <sql>
3147      SELECT bm2.[biomaterial_id]
3148      FROM [DerivedBioAssays] dba
3149      INNER JOIN [ParentPhysicalBioAssays] pba ON pba.[derivedbioassay_id] = dba.[id]
3150      INNER JOIN [BioMaterialEvents] bme ON bme.[physicalbioassay_id] = pba.[physicalbioassay_id]
3151      INNER JOIN [BioMaterialEventSources2] bm2 ON bm2.[event_id]=bme.[id]
3152      WHERE bm2.[position] = :position AND dba.[id] = :derivedBioAssayId
3153    </sql>
3154    <description>
3155      An SQL query that tries to find the extract id given a
3156      derived bioassay and the bioassay position.
3157    </description>
3158  </query>
3159 
3160  <query id="UPDATE_RAWBIOASSAY" type="SQL">
3161    <sql>
3162      UPDATE [RawBioAssays]
3163      SET [bioassay_id] = :parentBioAssayId,
3164      [extract_id] = :extractId
3165      WHERE [id] = :rawBioAssayId
3166    </sql>
3167    <description>
3168      An SQL query that update the parent bioassay and extract
3169      for a given raw bioassay.
3170    </description>
3171  </query>
3172
3173
3174  <query id="COPY_BIOMATERIALEVENTSOURCES" type="SQL">
3175    <sql>
3176      INSERT INTO [BioMaterialEventSources2]
3177      (
3178        [id], [version],
3179        [biomaterial_id], [event_id],
3180        [used_quantity], [position]
3181      )
3182      SELECT
3183        {1}, 0,
3184        [biomaterial_id], [event_id],
3185        [used_quantity], [dummy]
3186      FROM [BioMaterialEventSources]
3187    </sql>
3188    <description>
3189      An SQL query that load copy BASE 2.17 biomaterial
3190      event sources to the new table.
3191    </description>
3192  </query>
3193
3194  <query id="COPY_SAMPLE_BIOSOURCE_PARENT_LINK" type="SQL">
3195    <sql>
3196      INSERT INTO [BioMaterialEventSources2]
3197      (
3198        [id], [version],
3199        [biomaterial_id], [event_id],
3200        [used_quantity], [position]
3201      )
3202      SELECT
3203        {1}, 0,
3204        bm.[parent_id], evt.[id],
3205        null, 1
3206      FROM [BioMaterials] bm
3207      INNER JOIN [BioMaterialEvents] evt ON bm.[id]=evt.[biomaterial_id] AND evt.[event_type]=1
3208      WHERE bm.[discriminator] = 2 AND NOT bm.[parent_id] IS NULL
3209    </sql>
3210    <description>
3211      An SQL query that copy Sample--BioSource parent
3212      links to the BioMaterialEventSources2 table.
3213    </description>
3214  </query>
3215
3216  <query id="NULLIFY_ALL_BIOMATERIAL_PARENTS" type="SQL">
3217    <sql>
3218      UPDATE [BioMaterials]
3219      SET [parent_type] = NULL, [parent_id] = NULL
3220    </sql>
3221    <description>
3222      An SQL query that nullify all biomaterial parent
3223      information.
3224    </description>
3225  </query>
3226
3227  <query id="GET_BIOMATERIAL_PARENT_INFO" type="SQL">
3228    <sql>
3229      SELECT bm.[id], bm.[discriminator], evt.[biomaterial_id]
3230      FROM [BioMaterialEventSources2] bm2
3231      INNER JOIN [BioMaterialEvents] evt ON bm2.[event_id]=evt.[id] AND evt.[event_type]=1
3232      INNER JOIN [BioMaterials] bm ON bm2.[biomaterial_id]=bm.[id]
3233      ORDER BY evt.[biomaterial_id]
3234    </sql>
3235    <description>
3236      An SQL query that get parent biomaterial information. We need
3237      parent_id, parent_type and child_id ordered by child_id
3238    </description>
3239  </query>
3240
3241
3242  <query id="SET_BIOMATERIAL_PARENT" type="SQL">
3243    <sql>
3244      UPDATE [BioMaterials]
3245      SET [parent_type] = :parentType, [parent_id] = :parentId
3246      WHERE [id] = :childId
3247    </sql>
3248    <description>
3249      An SQL query that set the biomaterial parent info for a single
3250      biomaterial.
3251    </description>
3252  </query>
3253
3254  <query id="SET_LABELEDEXTRACT_SUBTYPE" type="SQL">
3255    <sql>
3256      UPDATE [BioMaterials]
3257      SET [subtype_id]=:subtype
3258      WHERE [label_id] IS NOT NULL
3259    </sql>
3260    <description>
3261      An SQL query that sets the subtype of labeled extracts
3262    </description>
3263  </query>
3264
3265  <query id="SET_SUBTYPE_ON_ALL" type="SQL">
3266    <sql>
3267      UPDATE [{1}]
3268      SET [subtype_id]=:subtype
3269    </sql>
3270    <description>
3271      An SQL query that sets the subtype
3272      of all items in a table
3273    </description>
3274  </query>
3275
3276  <query id="UPDATE_ANNOTATIONSET_ITEM" type="SQL">
3277    <sql>
3278      UPDATE [AnnotationSets]
3279      SET [item_id] = :newId, [item_type] = {1}
3280      WHERE [id] = :id
3281    </sql>
3282    <description>
3283      An SQL query that update the item_type and item_id
3284      on annotation set.
3285    </description>
3286  </query>
3287
3288  <query id="UPDATE_ANYTOANY_FROMITEM" type="SQL">
3289    <sql>
3290      UPDATE [AnyToAny]
3291      SET [from_id] = :newId, [from_type] = {2}
3292      WHERE [from_id] = :oldId AND [from_type] = {1}
3293    </sql>
3294    <description>
3295      An SQL query that update the from_type and from_id
3296      on any-to-any.
3297    </description>
3298  </query>
3299 
3300  <query id="UPDATE_ANYTOANY_TOITEM" type="SQL">
3301    <sql>
3302      UPDATE [AnyToAny]
3303      SET [to_id] = :newId, [to_type] = {2}
3304      WHERE [to_id] = :oldId AND [to_type] = {1}
3305    </sql>
3306    <description>
3307      An SQL query that update the to_type and to_id
3308      on any-to-any.
3309    </description>
3310  </query>
3311 
3312  <query id="UPDATE_CHANGEHISTORYDETAILS_ITEM" type="SQL">
3313    <sql>
3314      UPDATE [ChangeHistoryDetails]
3315      SET [item_id] = :newId, [item_type] = {2}
3316      WHERE [item_id] = :oldId AND [item_type] = {1}
3317    </sql>
3318    <description>
3319      An SQL query that update the item_type and item_id
3320      on change history details.
3321    </description>
3322  </query>
3323 
3324  <query id="UPDATE_ITEMVALUES_ITEM" type="SQL">
3325    <sql>
3326      UPDATE [ItemValues]
3327      SET [data_class_id] = :newId, [data_class] = :newClass
3328      WHERE [data_class_id] = :oldId AND [data_class] = :oldClass
3329    </sql>
3330    <description>
3331      An SQL query that update the data_class_id and data_class
3332      on item values.
3333    </description>
3334  </query>
3335
3336  <query id="UPDATE_ITEMVALUES_CLASS" type="SQL">
3337    <sql>
3338      UPDATE [ItemValues]
3339      SET [data_class] = :newClass
3340      WHERE [data_class] = :oldClass
3341    </sql>
3342    <description>
3343      An SQL query that update the data_class
3344      on item values.
3345    </description>
3346  </query>
3347
3348  <query id="UPDATE_ITEMTYPE" type="SQL">
3349    <sql>
3350      UPDATE [{1}]
3351      SET [{2}] = {4}
3352      WHERE [{2}] = {3}
3353    </sql>
3354    <description>
3355      An SQL query that update the item-type column on
3356      a generic table.
3357    </description>
3358  </query>
3359
3360  <query id="UPDATE_SUBTYPEID_FROM_OLDTYPEID" type="SQL">
3361    <sql>
3362      UPDATE [{1}]
3363      SET [{2}] = :subtypeId
3364      WHERE [{3}] = :oldTypeId
3365    </sql>
3366    <description>
3367      An SQL query that update the subtype_id column on
3368      a generic table.
3369    </description>
3370  </query>
3371
3372
3373  <query id="DELETE_PLUGINGUICONTEXTS_FOR_ITEMTYPE" type="SQL">
3374    <sql>
3375      DELETE FROM [PluginDefinitionGuiContexts]
3376      WHERE [item_type] = :itemType
3377    </sql>
3378    <description>
3379      An SQL query that delete plug-in gui contexts for
3380      a given item type.
3381    </description>
3382  </query>
3383
3384  <query id="DELETE_PLUGINKEYS_FOR_ITEMTYPE" type="SQL">
3385    <sql>
3386      DELETE FROM [PluginKeys]
3387      WHERE [key_id] IN (
3388        SELECT k.[id]
3389        FROM [Keys] k
3390        WHERE k.[item_type] = :itemType
3391      )
3392    </sql>
3393    <description>
3394      An SQL query that delete plug-in keys referencing keys
3395      for a given item type.
3396    </description>
3397  </query>
3398
3399
3400  <query id="GET_SUBTYPABLE_ITEMS_FOR_SUBTYPE_OF_CLASS" type="HQL">
3401    <sql>
3402      SELECT {1}
3403      FROM {2} sub
3404      WHERE sub.itemSubtype = :subtype
3405    </sql>
3406    <description>
3407      Get all items that are subtyped with a subtype for a given class.
3408    </description>
3409  </query>
3410 
3411  <query id="GET_ITEMLISTS_FOR_SUBTYPE" type="HQL">
3412    <sql>
3413      SELECT {1}
3414      FROM ItemListData il
3415      WHERE il.itemSubtype = :subtype
3416    </sql>
3417    <description>
3418      A Hibernate query that gets ITEMLISTS for a given item subtype.
3419    </description>
3420  </query>
3421 
3422  <query id="GET_MIMETYPES_FOR_FILETYPE" type="HQL">
3423    <sql>
3424      SELECT {1}
3425      FROM MimeTypeData mt
3426      WHERE mt.fileType = :subtype
3427    </sql>
3428    <description>
3429      A Hibernate query that gets MIME types for a given item subtype.
3430    </description>
3431  </query>
3432 
3433  <query id="GET_DATAFILETYPES_FOR_FILETYPE" type="HQL">
3434    <sql>
3435      SELECT {1}
3436      FROM DataFileTypeData dft
3437      WHERE dft.genericType = :subtype
3438    </sql>
3439    <description>
3440      A Hibernate query that gets Data file types for a given item subtype.
3441    </description>
3442  </query>
3443 
3444  <query id="UPDATE_FILESETMEMBER_FILETYPE" type="HQL">
3445    <sql>
3446      UPDATE FileSetMemberData mbr
3447      SET mbr.dataFileType = :newType
3448      WHERE mbr.dataFileType = :oldType
3449    </sql>
3450    <description>
3451      A Hibernate query that update the data file type of all
3452      file set members with a given old data file type.
3453    </description>
3454  </query>
3455 
3456  <query id="DISABLE_ALL_PLUGINS" type="HQL">
3457    <sql>
3458      UPDATE PluginDefinitionData pl
3459      SET pl.disabled = true
3460    </sql>
3461    <description>
3462      A Hibernate query that disable all plug-ins.
3463    </description>
3464  </query>
3465 
3466  <query id="GET_PROJECT_DEFAULT_ANYTOANY" type="HQL">
3467    <sql>
3468      SELECT a FROM AnyToAnyData a
3469      WHERE a.fromType = 24 AND a.name LIKE 'default_%'
3470    </sql>
3471    <description>
3472      A Hibernate query that load all any-to-any links containing
3473      project default items.
3474    </description>
3475  </query>
3476 
3477  <query id="GET_MD5_PASSWORDS" type="SQL">
3478    <sql>
3479      SELECT [id], [md5password] FROM [Passwords]
3480    </sql>
3481    <description>
3482      An SQL query that load all md5 passwords.
3483    </description>
3484  </query>
3485
3486  <query id="SET_ENCRYPTED_PASSWORD" type="SQL">
3487    <sql>
3488      UPDATE [Passwords]
3489      SET [crypted_password] = :cryptedPassword
3490      WHERE [id] = :id
3491    </sql>
3492    <description>
3493      An SQL query that set the encrypted password for a given entry.
3494    </description>
3495  </query>
3496 
3497  <query id="GET_VIRTUALDBS_FOR_REPORTERCLONETEMPLATE" type="HQL">
3498    <sql>
3499      SELECT {1}
3500      FROM VirtualDbData vdb
3501      WHERE vdb.reporterCloneTemplate = :reporterCloneTemplate
3502    </sql>
3503    <description>
3504      A Hibernate query that get virtual databases
3505      that are using a given reporter clone template.
3506    </description>
3507  </query>
3508
3509  <query id="GET_ALL_ANNOTATIONTYPE_IDS_FOR_USER" type="SQL">
3510    <sql>
3511      SELECT [at].[id]
3512      FROM [AnnotationTypes] [at]
3513      WHERE [at].[owner] = :owner
3514      OR [at].[itemkey_id] IN (:itemKeys)
3515      OR [at].[projectkey_id] IN (:projectKeys)
3516    </sql>
3517    <description>
3518      An SQL query that load the ID of all the annotation types
3519      that the current user has access to. We need to set owner,
3520      item keys and project keys as parameters.
3521    </description>
3522  </query>
3523
3524  <query id="COPY_PARENT_PHYSICAL_BIOASSAYS" type="SQL">
3525    <sql>
3526      INSERT INTO [ParentPhysicalBioAssays] ([physicalbioassay_id], [derivedbioassay_id])
3527      SELECT [bioassay_id], [id] FROM [DerivedBioAssays]
3528    </sql>
3529    <description>
3530      An SQL query that copy the parent physical bioassays
3531      to the new (in BASE 3.2) ParentPhysicalBioAssays table
3532    </description>
3533  </query>
3534
3535
3536  <query id="COPY_PARENT_DERIVED_BIOASSAYS" type="SQL">
3537    <sql>
3538      INSERT INTO [ParentDerivedBioAssays] ([parentbioassay_id], [derivedbioassay_id])
3539      SELECT [parent_id], [id] FROM [DerivedBioAssays] WHERE NOT [parent_id] IS NULL
3540    </sql>
3541    <description>
3542      An SQL query that copy the parent derived bioassays
3543      to the new (in BASE 3.2) ParentDerivedBioAssays table
3544    </description>
3545  </query>
3546
3547  <query id="SET_ISROOT_ON_DERIVED_BIOASSAYS" type="SQL">
3548    <sql>
3549      UPDATE [DerivedBioAssays] SET [is_root] = ([parent_id] IS NULL)
3550    </sql>
3551    <description>
3552      An SQL query that set the is_root property on DerivedBioAssays table.
3553    </description>
3554  </query>
3555 
3556  <query id="GET_ITEMSUBTYPE_WITH_NAME_AND_ITEMTYPE" type="HQL">
3557    <sql>
3558      SELECT st FROM ItemSubtypeData st
3559      WHERE st.name = :name AND st.itemType = :itemType
3560    </sql>
3561    <description>
3562      A Hibernate query that load an item subtype given the name
3563      and main item type.
3564    </description>
3565  </query>
3566 
3567  <query id="SET_DISABLE_LOG_FOR_ANNOTATION_TYPES" type="HQL">
3568    <sql>
3569      UPDATE AnnotationTypeData at
3570      SET at.disableLogOfValues = false
3571      WHERE at.disableLogOfValues IS NULL
3572    </sql>
3573    <description>
3574      An HQL query that set the disableLogOfValues=false for all annotation types
3575      with a null value.
3576    </description>
3577  </query>
3578
3579  <query id="AB_LOAD_ANNOTATION_INFO" type="SQL">
3580    <sql>
3581      SELECT [annotationtype_id], [id], [version], [unit_id], [value_id], [last_update], [project_id], [override_id]
3582      FROM [Annotations]
3583      WHERE [annotationset_id] = :annotationSet AND [source] = 0 AND ([project_id] = :defaultProject OR [project_id] = :activeProject)
3584    </sql>
3585    <description>
3586      SQL query for loading current (primary) annotations for
3587      a given item.
3588      Used by the AnnotationBatcher as a SQL query via Hibernate.
3589    </description>
3590  </query>
3591
3592  <query id="AB_LOAD_ANNOTATION_VALUES" type="SQL">
3593    <sql>
3594      SELECT [id], [value]
3595      FROM [{1}]
3596      WHERE [id] IN (:listOfIds)
3597    </sql>
3598    <description>
3599      SQL query for loading current annotation values
3600      for a given list of annotation value IDs.
3601      Used by the AnnotationBatcher as a SQL query via Hibernate.
3602    </description>
3603  </query>
3604
3605  <query id="AB_INSERT_INTO_PARAMETERVALUES" type="SQL">
3606    <sql>
3607      INSERT INTO [ParameterValues] ([id], [discriminator], [version])
3608      VALUES (nextval('hibernate_sequence'), ?, 0)
3609    </sql>
3610    <description>
3611      SQL query for inserting rows into the ParameterValues table.
3612      The primary key (id) must be auto-generated.
3613      Parameters: discriminator
3614    </description>
3615  </query>
3616
3617  <query id="AB_INSERT_INTO_ANNOTATIONS" type="SQL">
3618    <sql>
3619      INSERT INTO [Annotations] ([id], [version], [annotationset_id], [annotationtype_id], [unit_id], [value_id], [last_update], [source], [project_id], [override_id])
3620      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, 0, ?, ?)
3621    </sql>
3622    <description>
3623      SQL query for inserting rows into the Annotations table.
3624      The primary key (id) must be auto-generated.
3625      Parameters: annotationset_id, annotationtype_id, unit_id, value_id, last_updated, project_id, override_id
3626    </description>
3627  </query>
3628
3629  <query id="AB_UPDATE_ANNOTATIONS" type="SQL">
3630    <sql>
3631      UPDATE [Annotations]
3632      SET [version] = ?, [unit_id] = ?, [last_update] = ?
3633      WHERE [id] = ? AND [version] = ?
3634    </sql>
3635    <description>
3636      SQL query for updating rows into the Annotations table.
3637      Parameters: version (new), unit_id, last_updated, id, version (old)
3638    </description>
3639  </query>
3640
3641  <query id="AB_INSERT_INTO_ANNOTATIONSETS" type="SQL">
3642    <sql>
3643      INSERT INTO [AnnotationSets] ([id], [version], [item_type], [item_id])
3644      VALUES (nextval('hibernate_sequence'), 0, {1}, ?)
3645    </sql>
3646    <description>
3647      SQL query for inserting rows into the AnnotationSets table.
3648      The primary key (id) must be auto-generated.
3649      Parameters: item_id
3650    </description>
3651  </query>
3652 
3653  <query id="AB_UPDATE_ITEMTABLE" type="SQL">
3654    <sql>
3655      UPDATE [{1}]
3656      SET [annotationset_id] = ?
3657      WHERE [id] = ?
3658    </sql>
3659    <description>
3660      SQL query for updating the annotationset_id column in any
3661      table it exists in.
3662      Parameters: annotationset_id, item_id
3663    </description>
3664  </query>
3665
3666  <query id="AB_NULLIFY_CLONED_ANNOTATIONS" type="SQL">
3667    <sql>
3668      UPDATE [Annotations]
3669      SET [inherited_id] = null
3670      WHERE [inherited_id] = ? and [source] = 2
3671    </sql>
3672    <description>
3673      SQL query for setting the 'inherited_id' column to null
3674      for cloned annotations that reference the annotation that
3675      is about to be deleted.
3676      Parameters: inherited_id
3677    </description>
3678  </query>
3679
3680  <query id="AB_DELETE_INHERITED_ANNOTATIONS" type="SQL">
3681    <sql>
3682      DELETE FROM [Annotations]
3683      WHERE [inherited_id] = ? and [source] = 1
3684    </sql>
3685    <description>
3686      SQL query for deleting inherited annotations that reference
3687      the annotation that is about to be deleted.
3688      Parameters: inherited_id
3689    </description>
3690  </query>
3691
3692  <query id="AB_DELETE_FROM_ANNOTATIONS" type="SQL">
3693    <sql>
3694      DELETE FROM [Annotations]
3695      WHERE [id] = ?
3696    </sql>
3697    <description>
3698      SQL query for deleting an annotation with a given id.
3699      Used by the AnnotationBatcher as a PreparedStatement.
3700      Parameters: id
3701    </description>
3702  </query>
3703
3704  <query id="AB_DELETE_FROM_PARAMETERVALUES" type="SQL">
3705    <sql>
3706      DELETE FROM [ParameterValues] WHERE [id] = ?
3707    </sql>
3708    <description>
3709      SQL query for deleting a parameter value with a given id.
3710      Used by the AnnotationBatcher as a PreparedStatement.
3711    </description>
3712  </query>
3713
3714  <query id="AB_DELETE_FROM_VALUES" type="SQL">
3715    <sql>
3716      DELETE FROM [{1}] WHERE [id] = ?
3717    </sql>
3718    <description>
3719      SQL query for deleting all actual annotation values with a given id.
3720      The {1} parameter is the table the value are stored in, eg. StringValues,
3721      IntegerValues, FloatValues, etc.
3722      Used by the AnnotationBatcher as a PreparedStatement.
3723    </description>
3724  </query>
3725 
3726  <query id="AB_INSERT_INTO_VALUES" type="SQL">
3727    <sql>
3728      INSERT INTO [{1}] ([id], [value]) VALUES (?, ?)
3729    </sql>
3730    <description>
3731      SQL query for inserting annotation values in their respective
3732      table (eg. StringValues, IntegerValues, FloatValues, etc.).
3733      Used by the AnnotationBatcher as a PreparedStatement.
3734    </description>
3735  </query>
3736 
3737  <query id="AB_UPDATE_OVERRIDE_ID" type="SQL">
3738    <sql>
3739      UPDATE [Annotations]
3740      SET [override_id] = ?
3741      WHERE [annotationset_id] = ?
3742      AND [annotationtype_id] = ?
3743      AND [source] = 0
3744      AND [project_id] &lt;&gt; 0
3745    </sql>
3746    <description>
3747      Updates the "override_id" column on project-specific annotations
3748      to point to a newly created default annotation of the same
3749      annotation type (PRIMARY annotations only).
3750      Used by the AnnotationBatcher as a PreparedStatement.
3751      Parameters: override_id, annotationset_id, annotationtype_id
3752    </description>
3753  </query>
3754 
3755 
3756  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF" type="SQL">
3757    <sql>
3758      UPDATE [Annotations]
3759      SET [override_id] = :annotationId
3760      WHERE [annotationset_id] = :annotationSetId
3761      AND [annotationtype_id] = :annotationTypeId
3762      AND [source] = 0
3763      AND [project_id] &lt;&gt; 0
3764    </sql>
3765    <description>
3766      Updates the "override_id" column on project-specific annotations
3767      to point to a newly created default annotation of the same
3768      annotation type (PRIMARY annotations only).
3769    </description>
3770  </query>
3771 
3772  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION" type="SQL">
3773    <sql>
3774      UPDATE [Annotations]
3775      SET [override_id] = COALESCE(
3776        (SELECT [id] FROM [Annotations]
3777        WHERE [annotationset_id] = :annotationSetId
3778        AND [annotationtype_id] = :annotationTypeId
3779        AND [source] = 0 AND [project_id] = 0)
3780        , 0)
3781      WHERE id = :annotationId
3782    </sql>
3783    <description>
3784      Updates the "override_id" column on a newly created project-specific
3785      (PRIMARY) annotation to point to the existing default annotation id
3786      or 0 if no default annotation exists.
3787    </description>
3788  </query>
3789 
3790  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF_INHERITED" type="HQL">
3791    <sql>
3792      UPDATE [Annotations]
3793      SET [override_id] = :annotationId
3794      WHERE [annotationset_id] = :annotationSetId
3795      AND [inherited_id] IN (
3796        SELECT [id] FROM [Annotations]
3797        WHERE [annotationset_id] = :parentSetId
3798        AND [override_id] = :parentId
3799      )
3800    </sql>
3801    <description>
3802      Updates the "override_id" column on project-specific annotations
3803      to point to a newly created default annotation (INHERITED and
3804      CLONED annotations). The subquery will find project-specific annotation
3805      on the parent annotation set that is overriding the inherited annotation.
3806    </description>
3807  </query>
3808 
3809  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION_INHERITED" type="SQL">
3810    <sql>
3811      UPDATE [Annotations]
3812      SET [override_id] = COALESCE(
3813        (SELECT [id] FROM [Annotations]
3814        WHERE [annotationset_id] = :annotationSetId
3815        AND [inherited_id] = :parentOverrideId
3816        AND [source] &lt;&gt; 0
3817        AND [project_id] = 0)
3818        , 0)
3819      WHERE id = :annotationId
3820    </sql>
3821    <description>
3822      Updates the "override_id" column on a newly created project-specific
3823      (CLONED or INHERITED) annotation to point to the existing default
3824      annotation id or 0 if no default annotation exists.
3825    </description>
3826  </query>
3827 
3828  <query id="PS_RESET_OVERRIDE_ON_PROJECT_ANNOTATIONS" type="HQL">
3829    <sql>
3830      UPDATE [Annotations] 
3831      SET [override_id] = 0
3832      WHERE [override_id] IN (:deletedAnnotations)
3833      OR [inherited_id] IN (
3834        SELECT [id] FROM [Annotations]
3835        WHERE [override_id] IN (:deletedPrimaryAnnotations)
3836      )
3837    </sql>
3838    <description>
3839      Reset the "override_id" column on project-specific annotations
3840      that points to a default annotation that has been removed.
3841    </description>
3842  </query>
3843   
3844  <query id="PS_LOAD_ANNOTATIONS_IN_NON_EXISTING_PROJECTS" type="SQL">
3845    <sql>
3846      SELECT a.[id], a.[annotationset_id], a.[value_id], a.[project_id], at.[value_type]
3847      FROM [Annotations] a
3848      INNER JOIN [AnnotationTypes] at ON at.[id] = a.[annotationtype_id]
3849      WHERE a.[project_id] &lt;&gt; 0 AND a.[project_id] NOT IN (SELECT [id] FROM [Projects])
3850    </sql>
3851    <description>
3852      SQL query for loading information about annotations
3853      that are project-specific annotations for a given
3854      list of projects.
3855      Used by the ProjectSpecificAnnotationsManager when
3856      a project has been deleted.
3857    </description>
3858  </query>
3859 
3860  <query id="PS_DELETE_FROM_PARAMETERVALUES" type="SQL">
3861    <sql>
3862      DELETE FROM [ParameterValues] WHERE [id] IN (:deletedValues)
3863    </sql>
3864    <description>
3865      SQL query for deleting mutliple parameter values with a given id's.
3866      Used by the ProjectSpecificAnnotationsManager.
3867    </description>
3868  </query>
3869
3870  <query id="PS_DELETE_FROM_VALUES" type="SQL">
3871    <sql>
3872      DELETE FROM [{1}] WHERE [id] IN (:deletedValues)
3873    </sql>
3874    <description>
3875      SQL query for deleting all actual annotation values with given id's.
3876      The {1} parameter is the table the value are stored in, eg. StringValues,
3877      IntegerValues, FloatValues, etc.
3878      Used by the ProjectSpecificAnnotationsManager.
3879    </description>
3880  </query>
3881 
3882  <query id="PS_DELETE_FROM_ANNOTATIONS_IN_PROJECTS" type="SQL">
3883    <sql>
3884      DELETE FROM [Annotations] WHERE [project_id] IN (:deletedProjects)
3885    </sql>
3886    <description>
3887      SQL query for deleting all annotation entries referenceing
3888      given list of projects.
3889      Used by the ProjectSpecificAnnotationsManager.
3890    </description>
3891  </query>
3892 
3893  <query id="PS_FIND_PROJECT_SPECIFIC_ANNOTATION" type="HQL">
3894    <sql>
3895      SELECT ad FROM AnnotationData ad
3896      WHERE ad.projectId = :activeProject
3897      AND ad.overrideId = :defaultAnnotation
3898      AND ad.annotationSet = :annotationSet
3899    </sql>
3900    <description>
3901      HQL query for locating a project-specific annotation
3902      overriding a specified default annotation.
3903      Used by the ProjectSpecificAnnotationsManager.
3904    </description>
3905  </query>
3906 
3907  <query id="COUNT_PROJECT_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
3908    <sql>
3909      SELECT count(*)
3910      FROM AnnotationData ad
3911      WHERE ad.annotationType = :annotationType
3912      AND ad.projectId &lt;&gt; 0
3913    </sql>
3914    <description>
3915      HQL query that counts the number of project-specific annotations
3916      for an annotation type.
3917    </description>
3918  </query>
3919 
3920  <query id="GET_USER_DEVICE" type="HQL">
3921    <sql>
3922      SELECT dev
3923      FROM UserDeviceData dev
3924      WHERE dev.user = :userId
3925      AND dev.client = :clientId
3926      AND dev.token = :token
3927    </sql>
3928    <description>
3929      HQL query that selects a device for a given user and client
3930      with a given device token.
3931    </description>
3932  </query>
3933
3934</predefined-queries>
Note: See TracBrowser for help on using the repository browser.