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

Last change on this file since 7312 was 7312, checked in by Nicklas Nordborg, 6 years ago

Fixes #2065: Exception when trying to delete a data file type that is referenced from item subtype

The item subtype should now be displayed in the trashcan under the "Items using" section.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 98.5 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 7312 2017-03-21 08:44:03Z 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 MySQL modify the mysql-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_SPOTIMAGES_FOR_FILE" type="HQL">
928    <sql>
929      SELECT {1}
930      FROM SpotImagesData spi
931      WHERE spi.redImageFile = :file
932      OR spi.greenImageFile = :file
933      OR spi.blueImageFile = :file
934      OR spi.spotImagesFile = :file
935    </sql>
936    <description>
937      A Hibernate query that gets spot images where a given
938      file is used as one of the color components or holds the generated spot images.
939    </description>
940  </query>
941 
942  <query id="GET_FILESETMEMBERS_FOR_FILE" type="HQL">
943    <sql>
944      SELECT {1}
945      FROM FileSetMemberData fsm
946      WHERE fsm.file = :file
947    </sql>
948    <description>
949      A Hibernate query that gets file set membership
950      for a given file
951    </description>
952  </query>
953 
954  <query id="GET_DERIVEDBIOASSAYS_FOR_HARDWARE" type="HQL">
955    <sql>
956        SELECT {1}
957        FROM DerivedBioAssayData dba
958        WHERE dba.hardware = :hardware
959    </sql>
960    <description>
961      A Hibernate query that gets derived bioassays which
962      uses a given hardware.
963    </description>
964  </query>
965 
966  <query id="GET_ARRAYBATCHES_FOR_PRINTROBOT" type="HQL">
967    <sql>
968      SELECT {1}
969      FROM ArrayBatchData ab
970      WHERE ab.printRobot = :printrobot
971    </sql>
972    <description>
973      A Hibernate query that gets array batches which
974      uses a given print robot (hardware).
975    </description>
976  </query>
977 
978  <query id="GET_BIOMATERIALEVENTS_FOR_HARDWARE" type="HQL">
979    <sql>
980      SELECT {1}
981      FROM BioMaterialEventData bme
982      WHERE bme.hardware = :hardware
983    </sql>
984    <description>
985      A Hibernate query that gets biomaterial events which
986      uses a given hardware.
987    </description>
988  </query>
989 
990  <query id="GET_PLATEEVENTS_FOR_HARDWARE" type="HQL">
991    <sql>
992      SELECT {1}
993      FROM PlateEventData ple
994      WHERE ple.hardware = :hardware
995    </sql>
996    <description>
997      A Hibernate query that gets plates events which
998      uses a given hardware.
999    </description>
1000  </query>
1001
1002  <query id="GET_REPORTERS_FOR_REPORTERTYPE" type="HQL">
1003    <sql>
1004      SELECT {1}
1005      FROM ReporterData rpt
1006      WHERE rpt.reporterType = :reporterType
1007    </sql>
1008    <description>
1009      A Hibernate query that gets reporter items
1010      of the given reporter type.
1011    </description>
1012  </query>
1013
1014  <query id="GET_REPORTER_FOR_EXTERNAL_ID" type="HQL">
1015    <sql>
1016      SELECT rpt
1017      FROM ReporterData rpt
1018      WHERE rpt.externalId = :externalId
1019    </sql>
1020    <description>
1021      A Hibernate query that finds the reporter with a given external id.
1022    </description>
1023  </query>
1024
1025  <query id="GET_RAWBIOASSAYS_FOR_SOFTWARE" type="HQL">
1026    <sql>
1027      SELECT {1}
1028      FROM RawBioAssayData rba
1029      WHERE rba.software = :software
1030    </sql>
1031    <description>
1032      A Hibernate query that gets the raw bioassays
1033      produced from a given software.
1034    </description>
1035  </query>
1036
1037  <query id="GET_DERIVEDBIOASSAYS_FOR_SOFTWARE" type="HQL">
1038    <sql>
1039      SELECT {1}
1040      FROM DerivedBioAssayData dba
1041      WHERE dba.software = :software
1042    </sql>
1043    <description>
1044      A Hibernate query that gets the derived bioassay
1045      using a given software.
1046    </description>
1047  </query>
1048
1049
1050  <query id="GET_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
1051    <sql>
1052      SELECT {1}
1053      FROM AnnotationData a
1054      WHERE a.annotationType = :annotationType
1055    </sql>
1056    <description>
1057      A Hibernate query that gets annotations
1058      of the given annotation type.
1059    </description>
1060  </query>
1061 
1062  <query id="GET_EXPERIMENTS_FOR_ANNOTATIONTYPE" type="HQL">
1063    <sql>
1064      SELECT {1}
1065      FROM ExperimentData exp
1066      JOIN exp.experimentalFactors ef
1067      WHERE ef = :annotationType
1068    </sql>
1069    <description>
1070      A Hibernate query that gets experiments
1071      where the given annotation type is used as an experimental factor.
1072    </description>
1073  </query>
1074 
1075  <query id="GET_PROTOCOLS_FOR_ANNOTATIONTYPE" type="HQL">
1076    <sql>
1077      SELECT {1}
1078      FROM ProtocolData prt
1079      JOIN prt.parameters pp
1080      WHERE pp = :annotationType
1081    </sql>
1082    <description>
1083      A Hibernate query that gets protocols
1084      where the given annotation type is used as a protocol parameter.
1085    </description>
1086  </query>
1087
1088  <query id="GET_SAMPLES_FOR_BIOSOURCE" type="HQL">
1089    <sql>
1090      SELECT {1}
1091      FROM SampleData s
1092      WHERE s.parent = :biosource
1093    </sql>
1094    <description>
1095      A Hibernate query that gets samples
1096      created from a given biosource.
1097    </description>
1098  </query>
1099
1100  <query id="GET_EXTRACTS_FOR_SAMPLE" type="HQL">
1101    <sql>
1102      SELECT {1}
1103      FROM ExtractData e
1104      WHERE e.parent = :sample
1105    </sql>
1106    <description>
1107      A Hibernate query that gets extracts
1108      created from a given sample.
1109    </description>
1110  </query>
1111 
1112  <query id="GET_EXTRACTS_FOR_TAG" type="HQL">
1113    <sql>
1114      SELECT {1}
1115      FROM ExtractData ext
1116      WHERE ext.tag = :tag
1117    </sql>
1118    <description>
1119      A Hibernate query that gets extracts with a given tag.
1120    </description>
1121  </query>
1122
1123  <query id="GET_SOURCEEVENTS_FOR_BIOMATERIAL" type="HQL">
1124    <sql>
1125      SELECT {1}
1126      FROM BioMaterialEventData bme
1127      JOIN bme.sources src
1128      WHERE src.bioMaterial = :bioMaterial
1129    </sql>
1130    <description>
1131      A Hibernate query that gets the events where a given
1132      biomaterial has been part of as a source biomaterial, ie. the number
1133      of pooled biomaterials that have been created from it.
1134    </description>
1135  </query>
1136
1137  <query id="GET_DERIVEDBIOASSAYS_FOR_EXTRACT" type="HQL">
1138    <sql>
1139      SELECT {1}
1140      FROM DerivedBioAssayData dba
1141      WHERE dba.extract = :extract
1142    </sql>
1143    <description>
1144      A Hibernate query that gets the derived bioassays
1145      that are referencing a given extract.
1146    </description>
1147  </query>
1148
1149  <query id="GET_RAWBIOASSAYS_FOR_EXTRACT" type="HQL">
1150    <sql>
1151      SELECT {1}
1152      FROM RawBioAssayData rba
1153      WHERE rba.parentExtract = :extract
1154    </sql>
1155    <description>
1156      A Hibernate query that gets the raw bioassays
1157      that are referencing a given extract.
1158    </description>
1159  </query>
1160
1161  <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL">
1162    <sql>
1163      SELECT count(*)
1164      FROM MessageData msg
1165      WHERE msg.to = :user AND msg.read = false AND msg.removedBy IS NULL
1166    </sql>
1167    <description>
1168      A Hibernate query that counts the number of
1169      unread messages for a given user
1170    </description>
1171  </query>
1172 
1173  <query id="GET_PLATETYPES_FOR_PLATEGEOMETRY" type="HQL">
1174    <sql>
1175      SELECT {1}
1176      FROM PlateTypeData pt
1177      WHERE pt.plateGeometry = :plateGeometry
1178    </sql>
1179    <description>
1180      A Hibernate query that gets the
1181      plate types using a given plate geometry
1182    </description>
1183  </query>
1184 
1185  <query id="GET_PLATEMAPPINGS_FOR_PLATEGEOMETRY" type="HQL">
1186    <sql>
1187      SELECT {1}
1188      FROM PlateMappingData pm
1189      WHERE pm.sourceGeometry = :plateGeometry
1190      OR pm.destinationGeometry = :plateGeometry
1191    </sql>
1192    <description>
1193      A Hibernate query that gets the
1194      plate mappings using a given plate geometry as source or destination
1195    </description>
1196  </query>
1197
1198  <query id="GET_BIOPLATES_FOR_PLATEGEOMETRY" type="HQL">
1199    <sql>
1200      SELECT {1}
1201      FROM BioPlateData bp
1202      WHERE bp.plateGeometry = :plateGeometry
1203    </sql>
1204    <description>
1205      A Hibernate query that gets the
1206      bioplates using of given plate geometry
1207    </description>
1208  </query>
1209
1210  <query id="GET_PLATES_FOR_PLATETYPE" type="HQL">
1211    <sql>
1212      SELECT {1}
1213      FROM PlateData p
1214      WHERE p.plateType = :plateType
1215    </sql>
1216    <description>
1217      A Hibernate query that gets
1218      plates of a specific plate type.
1219    </description>
1220  </query>
1221
1222  <query id="GET_PLATEEVENTS_FOR_PLATEEVENTTYPE" type="HQL">
1223    <sql>
1224      SELECT {1}
1225      FROM PlateEventData pe
1226      WHERE pe.plateEventType = :plateEventType
1227    </sql>
1228    <description>
1229      A Hibernate query that gets
1230      plate events of the given plate event type.
1231    </description>
1232  </query>
1233
1234  <query id="GET_CHILDPLATES_FOR_PLATE" type="HQL">
1235    <sql>
1236      SELECT {1}
1237      FROM PlateData p
1238      JOIN p.parents pp
1239      WHERE pp = :plate
1240    </sql>
1241    <description>
1242      A Hibernate query that gets the
1243      child plates for a given plate.
1244    </description>
1245  </query>
1246
1247  <query id="GET_ARRAYDESIGNS_FOR_PLATE" type="HQL">
1248    <sql>
1249      SELECT {1}
1250      FROM ArrayDesignData ad
1251      JOIN ad.plates p
1252      WHERE p = :plate
1253    </sql>
1254    <description>
1255      A Hibernate query that gets the
1256      array designs that has used a given plate.
1257    </description>
1258  </query>
1259
1260  <query id="GET_PLATES_FOR_PLATEMAPPING" type="HQL">
1261    <sql>
1262      SELECT {1}
1263      FROM PlateData p
1264      WHERE p.plateMapping = :plateMapping
1265    </sql>
1266    <description>
1267      A Hibernate query that gets the
1268      plates that has been created from a given plate mapping.
1269    </description>
1270  </query>
1271 
1272  <query id="GET_FEATURES_FOR_WELL" type="HQL">
1273    <sql>
1274      SELECT {1}
1275      FROM FeatureData f
1276      WHERE f.well = :well
1277    </sql>
1278    <description>
1279      A Hibernate query that gets the
1280      features using a given well.
1281    </description>
1282  </query>
1283
1284  <query id="COUNT_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1285    <sql>
1286      SELECT count(*)
1287      FROM FeatureData f
1288      WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
1289    </sql>
1290    <description>
1291      A Hibernate query that counts the number of
1292      features on a given array design
1293    </description>
1294  </query>
1295
1296
1297  <query id="GET_CHILDWELLS_FOR_WELL" type="HQL">
1298    <sql>
1299      SELECT {1}
1300      FROM Well w
1301      WHERE w.parent = :well
1302    </sql>
1303    <description>
1304      A Hibernate query that gets the
1305      child wells of a given well.
1306    </description>
1307  </query>
1308
1309  <query id="GET_PLUGINCONFIGURATIONS_FOR_PLUGINDEFINITION" type="HQL">
1310    <sql>
1311      SELECT {1}
1312      FROM PluginConfigurationData pc
1313      WHERE pc.pluginDefinition = :pluginDefinition
1314    </sql>
1315    <description>
1316      A Hibernate query that gets plugin configurations
1317      using a plugin definition.
1318    </description>
1319  </query>
1320 
1321  <query id="GET_JOBS_FOR_PLUGINCONFIGURATION" type="HQL">
1322    <sql>
1323      SELECT {1}
1324      FROM JobData j
1325      WHERE j.pluginConfiguration = :pluginConfiguration
1326    </sql>
1327    <description>
1328      A Hibernate query that gets the jobs
1329      using a specific plugin configuration.
1330    </description>
1331  </query>
1332 
1333  <query id="GET_JOBS_FOR_PLUGINDEFINITION" type="HQL">
1334    <sql>
1335      SELECT {1}
1336      FROM JobData j
1337      WHERE j.pluginDefinition = :pluginDefinition
1338    </sql>
1339    <description>
1340      A Hibernate query that gets the jobs
1341      using a specific plugin definition.
1342    </description>
1343  </query>
1344
1345  <query id="FIND_JOBS_IN_QUEUE" type="HQL">
1346    <sql>
1347      SELECT job
1348      FROM JobData job
1349      WHERE job.status = :status
1350      AND job.type = :type
1351      AND job.removedBy IS NULL
1352      ORDER BY job.priority ASC, job.scheduled ASC
1353    </sql>
1354    <description>
1355      A Hibernate query that loads plugin jobs in the job queue waiting to be
1356      executed sorted by priority and waiting time. The query should return all
1357      jobs, ignoring all settings specifying that the internal job queue should
1358      not be used.
1359    </description>
1360  </query>
1361 
1362  <query id="FIND_INTERNAL_JOBS_IN_QUEUE" type="HQL">
1363    <sql>
1364      SELECT job
1365      FROM JobData job
1366      WHERE job.status = :status
1367      AND job.type = :type
1368      AND job.removedBy IS NULL
1369      AND job.pluginDefinition.useInternalJobQueue = true
1370      AND job.jobAgentId IS NULL
1371      ORDER BY job.priority ASC, job.scheduled ASC
1372    </sql>
1373    <description>
1374      A Hibernate query that loads plugin jobs in the job queue waiting to be
1375      executed sorted by priority and waiting time. It should only return
1376      jobs where the plug-in setting useInternalJobQueue=true and no
1377      specific job agent has been selected for the job.
1378    </description>
1379  </query>
1380 
1381  <query id="FIND_EXTERNAL_JOBS_FOR_STATUS_UPDATE" type="HQL">
1382    <sql>
1383      SELECT job
1384      FROM JobData job
1385      WHERE job.type = :type
1386      AND job.removedBy IS NULL
1387      AND NOT job.signalTransporter IS NULL
1388    </sql>
1389    <description>
1390      A Hibernate query that loads external jobs in the job queue that
1391      has a non-null signal transporter so that it may be possible to
1392      send a signal request for status update to them,
1393    </description>
1394  </query>
1395 
1396  <query id="GET_ARRAYSLIDES_FOR_BATCH" type="HQL">
1397    <sql>
1398      SELECT {1}
1399      FROM ArraySlideData a
1400      WHERE a.arrayBatch = :arrayBatch
1401    </sql>
1402    <description>
1403      A Hibernate query that gets the array slides
1404      in an array batch.
1405    </description>
1406  </query>
1407
1408  <query id="GET_ARRAYSLIDES_WITH_BARCODE" type="HQL">
1409    <sql>
1410      SELECT {1}
1411      FROM ArraySlideData ars
1412      WHERE ars.barcode = :barcode
1413    </sql>
1414    <description>
1415      A Hibernate query that gets the array slides
1416      with a given barcode.
1417    </description>
1418  </query>
1419
1420
1421  <query id="GET_ARRAYBATCHES_FOR_ARRAYDESIGN" type="HQL">
1422    <sql>
1423      SELECT {1}
1424      FROM ArrayBatchData a
1425      WHERE a.arrayDesign = :arrayDesign
1426    </sql>
1427    <description>
1428      A Hibernate query that gets array batches
1429      that uses a specific array design.
1430    </description>
1431  </query>
1432
1433  <query id="GET_RAWBIOASSAYS_FOR_ARRAYDESIGN" type="HQL">
1434    <sql>
1435      SELECT {1}
1436      FROM RawBioAssayData rba
1437      WHERE rba.arrayDesign = :arrayDesign
1438    </sql>
1439    <description>
1440      A Hibernate query that gets raw bioassays
1441      that uses a specific array design.
1442    </description>
1443  </query>
1444
1445  <query id="GET_ROOT_DERIVEDBIOASSAYS_FOR_PHYSICALBIOASSAY" type="HQL">
1446    <sql>
1447      SELECT {1}
1448      FROM DerivedBioAssayData dba
1449      INNER JOIN dba.physicalBioAssays pba
1450      WHERE pba = :bioAssay
1451      AND dba.root = true
1452    </sql>
1453    <description>
1454      A Hibernate query that gets root derived bioassays
1455      created from a specific physical bioassay.
1456    </description>
1457  </query>
1458
1459  <query id="GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL">
1460    <sql>
1461      SELECT {1}
1462      FROM DerivedBioAssayData dba
1463      INNER JOIN dba.parents p
1464      WHERE p = :bioAssay
1465    </sql>
1466    <description>
1467      A Hibernate query that gets child derived bioassays
1468      created from a specific derived bioassay.
1469    </description>
1470  </query>
1471
1472
1473  <query id="GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL">
1474    <sql>
1475      SELECT {1}
1476      FROM RawBioAssayData rba
1477      WHERE rba.parentBioAssay = :bioAssay
1478    </sql>
1479    <description>
1480      A Hibernate query that gets raw bioassays
1481      created from a specific derived bioassay.
1482    </description>
1483  </query>
1484
1485  <query id="PRELOAD_FEATURES" type="HQL">
1486    <sql>
1487      SELECT f
1488      FROM FeatureData f
1489      JOIN FETCH f.arrayDesignBlock b
1490      LEFT JOIN FETCH f.reporter
1491      WHERE b.arrayDesign = :arrayDesign
1492    </sql>
1493    <description>
1494      A Hibernate query that loads features, blocks and reporters
1495      for a single array design.
1496    </description>
1497  </query>
1498 
1499  <query id="DELETE_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1500    <sql>
1501      DELETE FROM Features f, ArrayDesignBlocks adb
1502      WHERE adb.id = f.arraydesignblock_id AND adb.arraydesign_id = ?
1503    </sql>
1504    <description>
1505      A Hibernate query that deletes all features for an array design.
1506    </description>
1507  </query>
1508
1509  <query id="GET_PLUGINTYPE_FOR_INTERFACENAME" type="HQL">
1510    <sql>
1511      SELECT plt
1512      FROM PluginTypeData plt
1513      WHERE plt.interfaceName = :interfaceName
1514    </sql>
1515    <description>
1516      Load a plugin type when you know the interface name.
1517    </description>
1518  </query>
1519
1520  <query id="GET_PLUGINDEFINITION_FOR_CLASSNAME" type="HQL">
1521    <sql>
1522      SELECT pd
1523      FROM PluginDefinitionData pd
1524      WHERE pd.className = :className
1525    </sql>
1526    <description>
1527      Load a plugin definition when you know the class name.
1528    </description>
1529  </query>
1530
1531  <query id="GET_PLUGINCONFIGURATION_FOR_PLUGIN_WITH_NAME" type="HQL">
1532    <sql>
1533      SELECT pc
1534      FROM PluginConfigurationData pc
1535      WHERE pc.pluginDefinition.className = :className
1536      AND pc.name = :name
1537    </sql>
1538    <description>
1539      Load a plugin configuration for a given plug-in and with a given name
1540    </description>
1541  </query>
1542
1543
1544  <query id="GET_EXPERIMENTS_FOR_RAWBIOASSAY" type="HQL">
1545    <sql>
1546      SELECT {1}
1547      FROM ExperimentData xp
1548      JOIN xp.rawBioAssays rba
1549      WHERE rba = :rawBioAssay
1550    </sql>
1551    <description>
1552      A Hibernate query that gets the experiments
1553      using a specific raw bioassay.
1554    </description>
1555  </query>
1556 
1557  <query id="GET_TRANSFORMATIONS_FOR_RAWBIOASSAY" type="HQL">
1558    <sql>
1559      SELECT {1}
1560      FROM TransformationData trf
1561      JOIN trf.rawSources rba
1562      WHERE rba = :rawBioAssay
1563    </sql>
1564    <description>
1565      A Hibernate query that gets the transformations
1566      using a specifiec raw bioassay.
1567    </description>
1568  </query>
1569 
1570  <query id="GET_TRANSFORMATIONS_FOR_JOB" type="HQL">
1571    <sql>
1572      SELECT {1}
1573      FROM TransformationData trf
1574      WHERE trf.job = :job
1575    </sql>
1576    <description>
1577      A Hibernate query that gets transformations
1578      linked to a job.
1579    </description>
1580  </query>
1581 
1582  <query id="GET_RAWBIOASSAYS_FOR_JOB" type="HQL">
1583    <sql>
1584      SELECT {1}
1585      FROM RawBioAssayData rba
1586      WHERE rba.job = :job
1587    </sql>
1588    <description>
1589      A Hibernate query that gets raw bioassays
1590      linked to a job.
1591    </description>
1592  </query>
1593 
1594  <query id="GET_ARRAYDESIGNS_FOR_JOB" type="HQL">
1595    <sql>
1596      SELECT {1}
1597      FROM ArrayDesignData ad
1598      WHERE ad.job = :job
1599    </sql>
1600    <description>
1601      A Hibernate query that gets array designs
1602      linked to a job.
1603    </description>
1604  </query>
1605 
1606  <query id="GET_DERIVEDBIOASSAYS_FOR_JOB" type="HQL">
1607    <sql>
1608      SELECT {1}
1609      FROM DerivedBioAssayData dba
1610      WHERE dba.job = :job
1611    </sql>
1612    <description>
1613      A Hibernate query that gets derived bioassays
1614      linked to a job.
1615    </description>
1616  </query>
1617
1618  <query id="FIND_CHILD_BIOASSAYSETS" type="HQL">
1619    <sql>
1620      SELECT bas
1621      FROM BioAssaySetData bas
1622      WHERE bas.transformation.source = :parent
1623    </sql>
1624    <description>
1625      A Hibernate query that returns all bioassaysets that are
1626      children to a specified parent bioassayset.
1627    </description>
1628  </query>
1629 
1630  <query id="FIND_DATACUBES_FOR_BIOASSAYSETS" type="HQL">
1631    <sql>
1632      SELECT DISTINCT cbe
1633      FROM BioAssaySetData bas
1634      JOIN bas.dataCubeLayer.dataCube cbe
1635      WHERE bas IN (:basList)
1636    </sql>
1637    <description>
1638      A Hibernate query that returns all data cubes that are
1639      used by the specified list of bioassaysets
1640    </description>
1641  </query>
1642 
1643  <query id="FIND_DATACUBES_USED_BY_OTHERS" type="HQL">
1644    <sql>
1645      SELECT DISTINCT cbe
1646      FROM BioAssaySetData bas
1647      JOIN bas.dataCubeLayer.dataCube cbe
1648      WHERE bas NOT IN (:basList)
1649      AND cbe IN (:possibleCubes)
1650    </sql>
1651    <description>
1652      A Hibernate query that, given a list of data cubes and bioassaysets,
1653      returns all of those data cubes that are also used by other bioassaysets.
1654    </description>
1655  </query>
1656
1657  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS" type="HQL">
1658    <sql>
1659      SELECT lay
1660      FROM BioAssaySetData bas
1661      JOIN bas.dataCubeLayer lay
1662      WHERE bas IN (:basList)
1663    </sql>
1664    <description>
1665      A Hibernate query that returns all data cube layers that are
1666      used by the specified list of bioassaysets
1667    </description>
1668  </query>
1669 
1670  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1671    <sql>
1672      SELECT lay
1673      FROM BioAssaySetData bas
1674      JOIN bas.dataCubeLayer lay
1675      WHERE bas IN (:basList)
1676      AND lay.dataCube NOT IN (:deletedCubes)
1677    </sql>
1678    <description>
1679      A Hibernate query that returns all data cube layers that are
1680      used by the specified list of bioassaysets but not are part of the
1681      list of already deleted data cubes.
1682    </description>
1683  </query>
1684
1685  <query id="FIND_DATACUBELAYERS_USED_BY_OTHERS" type="HQL">
1686    <sql>
1687      SELECT lay
1688      FROM BioAssaySetData bas
1689      JOIN bas.dataCubeLayer lay
1690      WHERE bas NOT IN (:basList)
1691      AND lay IN (:possibleLayers)
1692    </sql>
1693    <description>
1694      A Hibernate query that, given a list of data cube layers and bioassaysets,
1695      returns all of those data cube layers that are also used by other bioassaysets.
1696    </description>
1697  </query>
1698
1699  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS" type="HQL">
1700    <sql>
1701      SELECT flt
1702      FROM BioAssaySetData bas
1703      JOIN bas.dataCubeFilter flt
1704      WHERE bas IN (:basList)
1705    </sql>
1706    <description>
1707      A Hibernate query that returns all data cube filters that are
1708      used by the specified list of bioassaysets
1709    </description>
1710  </query>
1711 
1712  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1713    <sql>
1714      SELECT flt
1715      FROM BioAssaySetData bas
1716      JOIN bas.dataCubeFilter flt
1717      WHERE bas IN (:basList)
1718      AND flt.dataCube NOT IN (:deletedCubes)
1719    </sql>
1720    <description>
1721      A Hibernate query that returns all data cube filters that are
1722      used by the specified list of bioassaysets but not are part of the
1723      list of already deleted data cubes.
1724    </description>
1725  </query>
1726
1727  <query id="FIND_DATACUBEFILTERS_USED_BY_OTHERS" type="HQL">
1728    <sql>
1729      SELECT flt
1730      FROM BioAssaySetData bas
1731      JOIN bas.dataCubeFilter flt
1732      WHERE bas NOT IN (:basList)
1733      AND flt IN (:possibleFilters)
1734    </sql>
1735    <description>
1736      A Hibernate query that, given a list of data cube filters and bioassaysets,
1737      returns all of those data cube filters that are also used by other bioassaysets.
1738    </description>
1739  </query>
1740
1741  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS" type="HQL">
1742    <sql>
1743      SELECT dcev
1744      FROM BioAssaySetData bas
1745      JOIN bas.extraValues ev
1746      JOIN ev.dataCubeExtraValue dcev
1747      WHERE bas IN (:basList)
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
1752    </description>
1753  </query>
1754 
1755  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1756    <sql>
1757      SELECT dcev
1758      FROM BioAssaySetData bas
1759      JOIN bas.extraValues ev
1760      JOIN ev.dataCubeExtraValue dcev
1761      WHERE bas IN (:basList)
1762      AND dcev.dataCube NOT IN (:deletedCubes)
1763    </sql>
1764    <description>
1765      A Hibernate query that returns all data cube extra values that are
1766      used by the specified list of bioassaysets but not are part of the
1767      list of already deleted data cubes.
1768    </description>
1769  </query>
1770
1771  <query id="FIND_DATACUBEEXTRAVALUES_USED_BY_OTHERS" type="HQL">
1772    <sql>
1773      SELECT dcev
1774      FROM BioAssaySetData bas
1775      JOIN bas.extraValues ev
1776      JOIN ev.dataCubeExtraValue dcev
1777      WHERE bas NOT IN (:basList)
1778      AND dcev IN (:possibleExtraValues)
1779    </sql>
1780    <description>
1781      A Hibernate query that, given a list of data cube extra values and bioassaysets,
1782      returns all of those data cube extra values that are also used by other bioassaysets.
1783    </description>
1784  </query>
1785
1786  <query id="GET_EXTRAVALUETYPE_FOR_EXTERNAL_ID" type="HQL">
1787    <sql>
1788      SELECT evt
1789      FROM ExtraValueTypeData evt
1790      WHERE evt.externalId = :externalId
1791    </sql>
1792    <description>
1793      Load an extra value type when you know the external id.
1794    </description>
1795  </query>
1796
1797  <query id="GET_EXTRAVALUES_FOR_EXTRAVALUETYPE" type="HQL">
1798    <sql>
1799      SELECT {1}
1800      FROM ExtraValueData ev
1801      WHERE ev.extraValueType = :extraValueType
1802    </sql>
1803    <description>
1804      A Hibernate query that gets extra values
1805      of a specific type.
1806    </description>
1807  </query>
1808 
1809  <query id="LOAD_CONTEXT_NAMES" type="HQL">
1810    <sql>
1811      SELECT ctx.id, ctx.name
1812      FROM ContextData ctx
1813      WHERE ctx.client = :client AND
1814      (ctx.user = :user OR ctx.public = true)
1815      AND ctx.itemType = :itemType
1816      AND ctx.subContext = :subContext
1817      ORDER BY ctx.name
1818    </sql>
1819    <description>
1820      A Hibernate query that selects the id and name of all contexts for
1821      a user and item type. The names should be sorted in ascending order.
1822    </description>
1823  </query>
1824 
1825  <query id="LOAD_CONTEXT_BY_NAME" type="HQL">
1826    <sql>
1827      SELECT ctx
1828      FROM ContextData ctx
1829      WHERE ctx.user = :user
1830      AND ctx.client = :client
1831      AND ctx.itemType = :itemType
1832      AND ctx.subContext  = :subContext
1833      AND ctx.name = :name
1834    </sql>
1835    <description>
1836      A Hibernate query that load a context given the user, client,
1837      item type, subcontext and name of the context.
1838    </description>
1839  </query>
1840 
1841  <query id="LOAD_USER_CONTEXTS" type="HQL">
1842    <sql>
1843      SELECT ctx
1844      FROM ContextData ctx
1845      WHERE ctx.user.id = :user
1846      AND ctx.client.id = :client
1847      AND ctx.name = :name
1848    </sql>
1849    <description>
1850      A Hibernate query that loads all saved context information
1851      with a given name for a specific user/client.
1852    </description>
1853  </query>
1854
1855  <query id="COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT" type="HQL">
1856    <sql>
1857      SELECT plg.mainType, count(DISTINCT plg.id)
1858      FROM PluginDefinitionData plg
1859      JOIN plg.guiContexts gcx
1860      LEFT JOIN plg.configurations cfg
1861      WITH true = :hasConfigPermission OR cfg.owner.id = :owner
1862        OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
1863      WHERE
1864        (true = :hasPluginPermission OR plg.owner.id = :owner
1865        OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
1866      AND gcx.itemType = :itemType AND gcx.contextType = :contextType
1867      AND (
1868        (plg.requiresConfiguration = false)
1869        OR
1870        (plg.requiresConfiguration = true AND cfg.parameterVersion > 0)
1871      )
1872      AND plg.disabled = false
1873      GROUP BY plg.mainType
1874    </sql>
1875    <description>
1876      A Hibernate query that counts the number of plugins available for a
1877      given GUI context grouped by the main type of the plugins taking
1878      the requirement of configurations and user permissions into account.
1879    </description>
1880  </query>
1881 
1882  <query id="GET_FORMULA_WITH_NAME_AND_CHANNELS" type="HQL">
1883    <sql>
1884      SELECT fml
1885      FROM FormulaData fml
1886      WHERE fml.name = :name
1887      AND fml.channels = :channels
1888    </sql>
1889    <description>
1890      A Hibernate query that loads a formula with a given name and number
1891      of channels.
1892    </description>
1893  </query>
1894
1895  <query id="GET_FORMULA_WITH_NAME_AND_TYPE" type="HQL">
1896    <sql>
1897      SELECT fml
1898      FROM FormulaData fml
1899      WHERE fml.name = :name
1900      AND fml.rawDataType = :rawDataType
1901    </sql>
1902    <description>
1903      A Hibernate query that loads a formula with a given name and raw data type.
1904    </description>
1905  </query>
1906 
1907  <query id="GET_HELP_FOR_EXTERNAL_ID" type="HQL">
1908    <sql>
1909      SELECT hlp
1910      FROM HelpData hlp
1911      WHERE hlp.externalId = :externalId AND hlp.client = :client
1912    </sql>
1913    <description>
1914      A Hibernate query that loads a help text.
1915    </description>
1916  </query>
1917 
1918  <query id="GET_SCHEMA_VERSION_FOR_APP" type="HQL">
1919    <sql>
1920      SELECT sv
1921      FROM SchemaVersionData sv
1922      WHERE sv.appId = :appId
1923    </sql>
1924    <description>
1925      A Hibernate query that loads the schema version for a
1926      given application (there should only be one record since appId is unique).
1927    </description>
1928  </query>
1929 
1930  <query id="SET_SCHEMA_VERSION_FOR_APP" type="HQL">
1931    <sql>
1932      UPDATE SchemaVersionData sv
1933      SET sv.schemaVersion = :schemaVersion,
1934      sv.build = :build
1935      WHERE sv.appId = :appId
1936    </sql>
1937    <description>
1938      A Hibernate query that updates the schema version and build number.
1939    </description>
1940  </query>
1941 
1942  <query id="GET_PRIMARY_ANNOTATION" type="HQL">
1943    <sql>
1944      SELECT ad
1945      FROM AnnotationData ad
1946      WHERE ad.annotationType = :annotationType
1947      AND ad.annotationSet = :annotationSet
1948      AND ad.source = 0
1949    </sql>
1950    <description>
1951      A Hibernate query that loads the primary annotation of a specific
1952      annotation type for a given annotation set.
1953    </description>
1954  </query>
1955 
1956  <query id="LOAD_ANNOTATIONSET_INHERITING_ANNOTATIONTYPE" type="SQL">
1957    <sql>
1958      SELECT [a].[annotationset_id] FROM [Annotations] [a]
1959      WHERE [a].[annotationtype_id] = :annotationType
1960      AND [a].[source] != 0
1961    </sql>
1962    <description>
1963      An SQL query that load the ID of all annotation sets that
1964      are inheriting a given annotation type.
1965    </description>
1966  </query>
1967 
1968  <query id="DELETE_INHERITED_ANNOTATIONS" type="SQL">
1969    <sql>
1970      DELETE FROM [Annotations]
1971      WHERE [annotationtype_id] = :annotationType
1972      AND [source] != 0
1973    </sql>
1974    <description>
1975      An SQL query that delete all inherited annotations of the specified
1976      annotation type.
1977    </description>
1978  </query>
1979 
1980  <query id="NULLIFY_LINK_FROM_CLONES" type="HQL">
1981    <sql>
1982      UPDATE AnnotationData ad
1983      SET ad.inheritedFrom = null
1984      WHERE ad.inheritedFrom = :targetId
1985      AND ad.source = 2
1986    </sql>
1987    <description>
1988      A HQL query that nullify the link from all cloned annotations
1989      to a specified target annotation.
1990    </description>
1991  </query>
1992 
1993  <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL">
1994    <sql>
1995      UPDATE ExperimentData xpm
1996      SET xpm.bytes = xpm.bytes + :addedBytes
1997      WHERE xpm.id = :experiment
1998    </sql>
1999    <description>
2000      A Hibernate query that updates the number of bytes used by an experiment.
2001    </description>
2002  </query>
2003
2004  <query id="UPDATE_BYTES_FOR_DATACUBE" type="HQL">
2005    <sql>
2006      UPDATE DataCubeData dcd
2007      SET dcd.bytes = dcd.bytes + :addedBytes
2008      WHERE dcd.id = :dataCube
2009    </sql>
2010    <description>
2011      A Hibernate query that updates the number of bytes used by a data cube.
2012    </description>
2013  </query>
2014 
2015  <query id="GET_REMOVED_ITEMS" type="HQL">
2016    <sql>
2017      SELECT trash
2018      FROM net.sf.basedb.core.data.RemovableData trash
2019      WHERE NOT trash.removedBy IS NULL
2020    </sql>
2021    <description>
2022      A Hibernate query that loads all items flagged for deletion.
2023    </description>
2024  </query>
2025 
2026  <query id="UPDATE_REMAINING_QUANTITY" type="HQL">
2027    <sql>
2028      UPDATE MeasuredBioMaterialData mbm
2029      SET mbm.remainingQuantity = mbm.remainingQuantity - :used
2030      WHERE mbm = :bioMaterial
2031    </sql>
2032    <description>
2033      A Hibernate query that adds/removes the remaining quantity on a
2034      measuered biomaterial.
2035    </description>
2036  </query>
2037 
2038  <query id="GET_REMAINING_QUANTITY" type="HQL">
2039    <sql>
2040      SELECT mbm.remainingQuantity
2041      FROM MeasuredBioMaterialData mbm
2042      WHERE mbm = :bioMaterial
2043    </sql>
2044    <description>
2045      A Hibernate query that load the remaining quantity for a
2046      measuered biomaterial.
2047    </description>
2048  </query>
2049
2050  <query id="GET_ANYTOANY_FOR_NAME" type="HQL">
2051    <sql>
2052      SELECT ata
2053      FROM AnyToAnyData ata
2054      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2055    </sql>
2056    <description>
2057      A Hibernate query that loads the any-to-any link with the specified name
2058      for an item.
2059    </description>
2060  </query>
2061
2062  <query id="DELETE_ANYTOANY_FROM" type="HQL">
2063    <sql>
2064      DELETE FROM AnyToAnyData ata
2065      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2066    </sql>
2067    <description>
2068      A Hibernate query that deletes a names any-to-any link leading out from
2069      an item.
2070    </description>
2071  </query>
2072
2073
2074  <query id="DELETE_ALL_ANYTOANY_FROM" type="HQL">
2075    <sql>
2076      DELETE FROM AnyToAnyData ata
2077      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2078    </sql>
2079    <description>
2080      A Hibernate query that deletes all any-to-any links leading out from
2081      an item.
2082    </description>
2083  </query>
2084 
2085  <query id="DELETE_ALL_ANYTOANY_TO" type="HQL">
2086    <sql>
2087      DELETE FROM AnyToAnyData ata
2088      WHERE ata.toId = :toId AND ata.toType = :toType
2089    </sql>
2090    <description>
2091      A Hibernate query that deletes all any-to-any links leading in to an item.
2092    </description>
2093  </query>
2094
2095  <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
2096    <sql>
2097      DELETE FROM AnyToAnyData ata
2098      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = false
2099    </sql>
2100    <description>
2101      A Hibernate query that deletes all any-to-any links leading in to
2102      an item that doesn't count as using the item.
2103    </description>
2104  </query>
2105
2106  <query id="COUNT_USED_ANYTOANY_TO" type="HQL">
2107    <sql>
2108      SELECT count(*)
2109      FROM AnyToAnyData ata
2110      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = true
2111    </sql>
2112    <description>
2113      A Hibernate query that counts the number of any-to-any links
2114      to a given item that counts as using the item.
2115    </description>
2116  </query>
2117
2118  <query id="FIND_USING_ANYTOANY" type="HQL">
2119    <sql>
2120      SELECT ana.fromId, ana.fromType
2121      FROM AnyToAnyData ana
2122      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
2123    </sql>
2124    <description>
2125      A Hibernate query that finds the any-to-any links
2126      to a given item that counts as using the item.
2127    </description>
2128  </query>
2129
2130 
2131  <query id="UPDATE_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2132    <sql>
2133      UPDATE VirtualDbData vdb
2134      SET vdb.cubes = vdb.cubes + 1
2135      WHERE vdb.id = :virtualDb
2136    </sql>
2137    <description>
2138      A Hibernate query that updates the number of data cubes
2139      for the specified virtual database.
2140    </description>
2141  </query>
2142
2143  <query id="GET_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2144    <sql>
2145      SELECT vdb.cubes
2146      FROM VirtualDbData vdb
2147      WHERE vdb.id = :virtualDb
2148    </sql>
2149    <description>
2150      A Hibernate query that gets the current number of data cubes
2151      for the specified virtual database.
2152    </description>
2153  </query>
2154 
2155  <query id="UPDATE_FILTERNO_FOR_DATACUBE" type="HQL">
2156    <sql>
2157      UPDATE DataCubeData dcb
2158      SET dcb.numFilters = dcb.numFilters + 1
2159      WHERE dcb.id = :dataCube
2160    </sql>
2161    <description>
2162      A Hibernate query that updates the number of filters
2163      for the specified data cube.
2164    </description>
2165  </query>
2166
2167  <query id="GET_FILTERNO_FOR_DATACUBE" type="HQL">
2168    <sql>
2169      SELECT dcb.numFilters
2170      FROM DataCubeData dcb
2171      WHERE dcb.id = :dataCube
2172    </sql>
2173    <description>
2174      A Hibernate query that gets the current number of filters
2175      for the specified data cube.
2176    </description>
2177  </query>
2178
2179  <query id="UPDATE_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2180    <sql>
2181      UPDATE DataCubeData dcb
2182      SET dcb.numExtraValues = dcb.numExtraValues + 1
2183      WHERE dcb.id = :dataCube
2184    </sql>
2185    <description>
2186      A Hibernate query that updates the number of extra values
2187      for the specified data cube.
2188    </description>
2189  </query>
2190
2191  <query id="GET_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2192    <sql>
2193      SELECT dcb.numExtraValues
2194      FROM DataCubeData dcb
2195      WHERE dcb.id = :dataCube
2196    </sql>
2197    <description>
2198      A Hibernate query that gets the current number of extra values
2199      for the specified data cube.
2200    </description>
2201  </query>
2202
2203  <query id="UPDATE_LAYERNO_FOR_DATACUBE" type="HQL">
2204    <sql>
2205      UPDATE DataCubeData dcb
2206      SET dcb.numLayers = dcb.numLayers + 1
2207      WHERE dcb.id = :dataCube
2208    </sql>
2209    <description>
2210      A Hibernate query that updates the number of layers
2211      for the specified data cube.
2212    </description>
2213  </query>
2214
2215  <query id="GET_LAYERNO_FOR_DATACUBE" type="HQL">
2216    <sql>
2217      SELECT dcb.numLayers
2218      FROM DataCubeData dcb
2219      WHERE dcb.id = :dataCube
2220    </sql>
2221    <description>
2222      A Hibernate query that gets the current number of layers
2223      for the specified data cube.
2224    </description>
2225  </query>
2226
2227  <query id="UPDATE_COLUMNNO_FOR_DATACUBE" type="HQL">
2228    <sql>
2229      UPDATE DataCubeData dcb
2230      SET dcb.numColumns = dcb.numColumns + 1
2231      WHERE dcb.id = :dataCube
2232    </sql>
2233    <description>
2234      A Hibernate query that updates the number of columns
2235      for the specified data cube.
2236    </description>
2237  </query>
2238
2239  <query id="GET_COLUMNNO_FOR_DATACUBE" type="HQL">
2240    <sql>
2241      SELECT dcb.numColumns
2242      FROM DataCubeData dcb
2243      WHERE dcb.id = :dataCube
2244    </sql>
2245    <description>
2246      A Hibernate query that gets the current number of columns
2247      for the specified data cube.
2248    </description>
2249  </query>
2250
2251  <query id="GET_JOBAGENT_FOR_EXTERNALID" type="HQL">
2252    <sql>
2253      SELECT jag
2254      FROM JobAgentData jag
2255      WHERE jag.externalId = :externalId
2256    </sql>
2257    <description>
2258      A Hibernate query that loads the job agent with the specified external ID.
2259    </description>
2260  </query>
2261
2262  <query id="GET_KEYS_FOR_PLUGIN" type="HQL">
2263    <sql>
2264      SELECT pdk
2265      FROM PluginKeys pdk
2266      WHERE pdk.pluginDefinitionId = :pluginId
2267      ORDER BY pdk.keyId
2268    </sql>
2269    <description>
2270      A Hibernate query that loads all PluginDefinitionKeys for a specified plugin ID.
2271    </description>
2272  </query>
2273 
2274  <query id="LOAD_DEFAULT_GROUPS" type="HQL">
2275    <sql>
2276      SELECT grp
2277      FROM GroupData grp
2278      WHERE grp.default = true
2279    </sql>
2280    <description>
2281      A HQL query that loads all groups which are marked as default
2282      groups.
2283    </description>
2284  </query>
2285 
2286  <query id="LOAD_DEFAULT_ROLES" type="HQL">
2287    <sql>
2288      SELECT rle
2289      FROM RoleData rle
2290      WHERE rle.default = true
2291    </sql>
2292    <description>
2293      A HQL query that loads all roles which are marked as default
2294      roles.
2295    </description>
2296  </query>
2297 
2298  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
2299    <sql>
2300      SELECT {1}
2301      FROM RawBioAssayData rba
2302      WHERE rba.platform = :platform
2303    </sql>
2304    <description>
2305      A Hibernate query that gets raw bioassays
2306      with a given platform.
2307    </description>
2308  </query>
2309
2310  <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL">
2311    <sql>
2312      SELECT {1}
2313      FROM ArrayDesignData ad
2314      WHERE ad.platform = :platform
2315    </sql>
2316    <description>
2317      A Hibernate query that gets array designs
2318      with a given platform.
2319    </description>
2320  </query>
2321 
2322  <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL">
2323    <sql>
2324      SELECT {1}
2325      FROM RawBioAssayData rba
2326      WHERE rba.variant = :variant
2327    </sql>
2328    <description>
2329      A Hibernate query that gets raw bioassays
2330      with a given platform variant.
2331    </description>
2332  </query>
2333
2334  <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL">
2335    <sql>
2336      SELECT {1}
2337      FROM ArrayDesignData ad
2338      WHERE ad.variant = :variant
2339    </sql>
2340    <description>
2341      A Hibernate query that gets array designs
2342      with a given platform variant.
2343    </description>
2344  </query>
2345 
2346  <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL">
2347    <sql>
2348      SELECT plf
2349      FROM PlatformData plf
2350      WHERE plf.externalId = :externalId
2351    </sql>
2352    <description>
2353      A Hibernate query that loads a platform by external ID.
2354    </description>
2355  </query>
2356 
2357  <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL">
2358    <sql>
2359      SELECT plv
2360      FROM PlatformVariantData plv
2361      WHERE plv.externalId = :externalId
2362    </sql>
2363    <description>
2364      A Hibernate query that loads a platform variant by external ID.
2365    </description>
2366  </query>
2367 
2368  <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL">
2369    <sql>
2370      SELECT dft
2371      FROM DataFileTypeData dft
2372      WHERE dft.externalId = :externalId
2373    </sql>
2374    <description>
2375      A Hibernate query that loads a data file type by external ID.
2376    </description>
2377  </query>
2378
2379  <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL">
2380    <sql>
2381      SELECT {1}
2382      FROM FileSetMemberData mbr
2383      WHERE mbr.dataFileType = :dataFileType
2384    </sql>
2385    <description>
2386      A Hibernate query that gets file set members of a specific
2387      data file type.
2388    </description>
2389  </query>
2390
2391  <query id="GET_PLATFORMFILETYPE_FOR_DATAFILETYPE" type="HQL">
2392    <sql>
2393      SELECT {1}
2394      FROM PlatformFileTypeData pft
2395      WHERE pft.dataFileType = :dataFileType
2396    </sql>
2397    <description>
2398      A Hibernate query that gets platform file types of a specific
2399      data file type.
2400    </description>
2401  </query>
2402 
2403  <query id="GET_ITEMSUBTYPES_FOR_DATAFILETYPE" type="HQL">
2404    <sql>
2405      SELECT {1}
2406      FROM ItemSubtypeFileTypeData sft
2407      WHERE sft.dataFileType = :dataFileType
2408    </sql>
2409    <description>
2410      A Hibernate query that gets item subtype file types for a specific
2411      data file type.
2412    </description>
2413  </query>
2414 
2415 
2416  <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
2417    <sql>
2418      SELECT mbr
2419      FROM FileSetMemberData mbr
2420      WHERE mbr.dataFileType.externalId = :externalId
2421      AND mbr.fileSet = :fileSet
2422    </sql>
2423    <description>
2424      A Hibernate query that loads a member in a given file set
2425      if we know the external ID of the data file type.
2426    </description>
2427  </query>
2428
2429 
2430  <query id="UPDATE_JOB_STATUS" type="HQL">
2431    <sql>
2432      UPDATE JobData job
2433      SET
2434        job.percentComplete = :percent,
2435        job.statusMessage = :statusMessage
2436      WHERE job.id = :id
2437    </sql>
2438    <description>
2439      A HQL query that updates the progress information on a specific job.
2440    </description>
2441  </query>
2442 
2443  <query id="APPEND_JOB_STATUS" type="HQL">
2444    <sql>
2445      UPDATE JobData job
2446      SET
2447        job.statusMessage = job.statusMessage || :statusMessage
2448      WHERE job.id = :id
2449    </sql>
2450    <description>
2451      A HQL query that appends a string to the status message on a specific job.
2452    </description>
2453  </query>
2454
2455  <query id="LOAD_RAWBIOASSAY_JOBS_IN_EXPERIMENT" type="HQL">
2456    <sql>
2457      SELECT DISTINCT rba.job.id
2458      FROM RawBioAssayData rba
2459      WHERE rba.job.experiment = :experiment
2460    </sql>
2461    <description>
2462      A HQL query that loads the ID:s of all jobs that are part
2463      of a given experiment and also has been assigned to at
2464      least one raw bioassay.
2465    </description>
2466  </query>
2467 
2468  <query id="LOAD_ARRAYDESIGN_JOBS_IN_EXPERIMENT" type="HQL">
2469    <sql>
2470      SELECT ad.job.id
2471      FROM ArrayDesignData ad
2472      WHERE ad.job.experiment = :experiment
2473    </sql>
2474    <description>
2475      A HQL query that loads the ID:s of all jobs that are part
2476      of a given experiment and also has been assigned to at
2477      least one array design.
2478    </description>
2479  </query>
2480
2481  <query id="UNLINK_JOBS_FROM_EXPERIMENT" type="HQL">
2482    <sql>
2483      UPDATE JobData job
2484      SET job.experiment = null
2485      WHERE job.id IN (:list)
2486    </sql>
2487    <description>
2488      A HQL query that set the experiment property to null for
2489      a given set of jobs.
2490    </description>
2491  </query>
2492 
2493  <query id="GET_UNIT_WITH_NAME_FOR_QUANTITY" type="HQL">
2494    <sql>
2495      SELECT unt
2496      FROM UnitData unt
2497      WHERE unt.quantity = :quantity
2498      AND unt.name = :name
2499    </sql>
2500    <description>
2501      A HQL query that finds the unit for a quantity
2502      with a given name.
2503    </description>
2504  </query>
2505
2506  <query id="GET_UNITS_FOR_QUANTITY" type="HQL">
2507    <sql>
2508      SELECT {1}
2509      FROM UnitData unt
2510      WHERE unt.quantity = :quantity
2511    </sql>
2512    <description>
2513      A Hibernate query that gets units
2514      for a given quantity.
2515    </description>
2516  </query>
2517
2518  <query id="GET_ANNOTATIONTYPES_FOR_QUANTITY" type="HQL">
2519    <sql>
2520      SELECT {1}
2521      FROM AnnotationTypeData at
2522      WHERE at.quantity = :quantity
2523    </sql>
2524    <description>
2525      A Hibernate query that gets annotation types
2526      that are using a given quantity.
2527    </description>
2528  </query>
2529 
2530  <query id="GET_ANNOTATIONTYPES_FOR_UNIT" type="HQL">
2531    <sql>
2532      SELECT {1}
2533      FROM AnnotationTypeData at
2534      WHERE at.defaultUnit = :unit
2535    </sql>
2536    <description>
2537      A Hibernate query that gets annotation types
2538      that are using a given unit as default unit.
2539    </description>
2540  </query>
2541 
2542  <query id="GET_ANNOTATIONS_FOR_UNIT" type="HQL">
2543    <sql>
2544      SELECT {1}
2545      FROM AnnotationData a
2546      WHERE a.unit = :unit
2547    </sql>
2548    <description>
2549      A Hibernate query that gets annotations
2550      that are using a given unit.
2551    </description>
2552  </query>
2553 
2554  <query id="GET_UNIT_WITH_SYMBOL_FOR_QUANTITY" type="HQL">
2555    <sql>
2556      SELECT unt
2557      FROM UnitData unt
2558      JOIN unt.symbols smb
2559      WHERE unt.quantity = :quantity
2560      AND smb.symbol = :symbol
2561    </sql>
2562    <description>
2563      A HQL query that finds the unit for a quantity
2564      with a given symbol.
2565    </description>
2566  </query>
2567 
2568  <query id="GET_UNIT_WITH_SYMBOL_FOR_UNIT" type="HQL">
2569    <sql>
2570      SELECT smb.unit
2571      FROM UnitSymbolData smb
2572      JOIN smb.quantity qnt
2573      JOIN qnt.units unt
2574      WHERE unt = :unit
2575      AND smb.symbol = :symbol
2576    </sql>
2577    <description>
2578      A HQL query that finds the unit with a given symbol
2579      that has the same quantity as another unit.
2580    </description>
2581  </query>
2582 
2583  <query id="SET_UNIT_TO_NULL_ON_PROPERTY_FILTERS" type="SQL">
2584    <sql>
2585      UPDATE [PropertyFilters]
2586      SET [unit_id] = null
2587      WHERE [unit_id] = :unit
2588    </sql>
2589    <description>
2590      A SQL query that sets the unit to null for all properties
2591      with a given unit (about to be deleted).
2592    </description>
2593  </query>
2594 
2595  <query id="RECALCULATE_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="SQL">
2596    <sql>
2597      UPDATE [{1}]
2598      SET [value] = [value] * :factor + :offset
2599      WHERE [id] IN
2600      (
2601        SELECT [value_id]
2602        FROM [Annotations]
2603        WHERE [annotationtype_id] = :annotationType
2604      )
2605    </sql>
2606    <description>
2607      A SQL query that recalculates the annotation values for
2608      a given annotation type.
2609    </description>
2610  </query>
2611 
2612  <query id="SET_UNIT_ON_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="HQL">
2613    <sql>
2614      UPDATE AnnotationData a
2615      SET a.unit = :unit
2616      WHERE a.annotationType = :annotationType
2617    </sql>
2618    <description>
2619      A HQL query that changes the unit for all annotations with a given
2620      annotation type.
2621    </description>
2622  </query>
2623 
2624  <query id="RECALCULATE_ANNOTATIONS_FOR_UNIT" type="SQL">
2625    <sql>
2626      UPDATE [{1}] SET [value] = [value] * :factor + :offset
2627      WHERE [id] IN
2628      (
2629        SELECT [a].[value_id]
2630        FROM [Annotations] [a]
2631        JOIN [AnnotationTypes] [at] ON [at].[id] = [a].[annotationtype_id]
2632        WHERE [at].[value_type] = :valueType
2633        AND
2634        (
2635          (:case = 1 AND [a].[unit_id] = :unit AND [at].[default_unit_id] &lt;&gt; :unit)
2636          OR
2637          (:case = 2 AND [a].[unit_id] &lt;&gt; :unit AND [at].[default_unit_id] = :unit)
2638        )
2639      )
2640    </sql>
2641    <description>
2642      A SQL query that recalculates the annotation values for
2643      when reference factor and/or offset changes. The query must handle
2644      two cases where either the annotation type's default unit
2645      or the annotation's unit matched. More info in doc for the
2646      Unit.changeReferenceFactorAndOffset() method.
2647    </description>
2648  </query>
2649
2650  <query id="UPDATE_ITEMLIST_SIZE" type="SQL">
2651    <sql>
2652      UPDATE [ItemLists]
2653      SET [size] = [size] + :delta
2654      WHERE [member_type] = :memberType
2655      AND [id] = ANY(
2656        SELECT [list_id]
2657        FROM [ItemListMembers]
2658        WHERE [item_id] = :itemId
2659      )
2660    </sql>
2661    <description>
2662      An update query that changes the size for all item lists
2663      where a given item is a member. Mainly used to decrease
2664      the size when an item is deleted.
2665    </description>
2666  </query>
2667 
2668  <query id="DELETE_ITEMLIST_MEMBER" type="SQL">
2669    <sql>
2670      DELETE FROM [ItemListMembers]
2671      WHERE [item_id] = :itemId
2672      AND [list_id] = ANY(
2673        SELECT [id]
2674        FROM [ItemLists]
2675        WHERE [member_type] = :memberType
2676      )
2677    </sql>
2678    <description>
2679      An update query that delete the list member entries
2680      for all lists where the given item is a member.
2681    </description>
2682  </query>
2683 
2684  <query id="GET_BIOMATERIAL_ON_PLATE" type="HQL">
2685    <sql>
2686      SELECT {1}
2687      FROM MeasuredBioMaterialData mbm
2688      JOIN mbm.bioWell bw
2689      WHERE bw.bioPlate = :bioPlate
2690    </sql>
2691    <description>
2692      A HQL query that gets MeasuredBioMaterial:s
2693      located on a given bioplate.
2694    </description>
2695  </query>
2696  <query id="FIND_USED_TYPES_IN_ANYTOANY" type="SQL">
2697    <sql>
2698      SELECT [a].[from_type] FROM [AnyToAny] [a]
2699      UNION
2700      SELECT [a].[to_type] FROM [AnyToAny] [a]
2701    </sql>
2702    <description>
2703      An SQL query that selects all used item types in any-to-any
2704      links. It must select both the the 'from' and 'to' item type.
2705    </description>
2706  </query>
2707  <query id="SELECT_STRAY_ANYTOANY" type="SQL">
2708    <sql>
2709      SELECT [a].[id]
2710      FROM [AnyToAny] [a]
2711      LEFT JOIN [{1}] [t]
2712        ON ([t].[id] = [a].[from_id] AND [a].[from_type] = :type)
2713        OR ([t].[id] = [a].[to_id] AND [a].[to_type] = :type)
2714      WHERE [t].[id] IS NULL
2715      AND ([a].[from_type] = :type OR [a].[to_type] = :type)
2716    </sql>
2717    <description>
2718      An SQL query that selects the ID of all any-to-any links were
2719      either the 'from' or 'to' item is missing. A single query
2720      is used to delete all items of a specific type (both
2721      'from' and 'to).
2722    </description>
2723  </query>
2724  <query id="DELETE_STRAY_ANYTOANY" type="HQL">
2725    <sql>
2726      DELETE FROM AnyToAnyData
2727      WHERE id IN (:ids)
2728    </sql>
2729    <description>
2730      A HQL query that deletes all any-to-any links with the
2731      id's given in the list.
2732    </description>
2733  </query>
2734  <query id="FIND_USED_TYPES_IN_CHANGEHISTORY" type="HQL">
2735    <sql>
2736      SELECT DISTINCT ch.itemType FROM ChangeHistoryDetailData ch
2737    </sql>
2738    <description>
2739      An HQL query that selects all used item types in the change
2740      history table.
2741    </description>
2742  </query>
2743  <query id="DELETE_STRAY_CHANGEHISTORY" type="HQL">
2744    <sql>
2745      DELETE FROM ChangeHistoryDetailData
2746      WHERE id IN (:ids)
2747    </sql>
2748    <description>
2749      A HQL query that deletes all change history entries with the
2750      id's given in the list.
2751    </description>
2752  </query>
2753  <query id="SELECT_STRAY_CHANGEHISTORY" type="SQL">
2754    <sql>
2755      SELECT [ch].[id]
2756      FROM [ChangeHistoryDetails] [ch]
2757      LEFT JOIN [{1}] [t]
2758        ON ([t].[id] = [ch].[item_id] AND [ch].[item_type] = :type)
2759      WHERE [t].[id] IS NULL
2760      AND [ch].[item_type] = :type
2761    </sql>
2762    <description>
2763      An SQL query that selects the ID of all change history entries
2764      that references a missing item of a specified type.
2765    </description>
2766  </query>
2767  <query id="DBLOG_GET_ANNOTATIONTYPE_INFO" type="HQL">
2768    <sql>
2769      SELECT at.name, at.valueType, at.disableLogOfValues
2770      FROM AnnotationTypeData at
2771      WHERE at.id = :annotationTypeId
2772    </sql>
2773    <description>
2774      An HQL query that loads the 'name', 'valueType' and 'disableLogOfValues' flag
2775      for an annotation type given the ID.
2776    </description>
2777  </query>
2778  <query id="DBLOG_GET_ANNOTATION_ITEMTYPE" type="HQL">
2779    <sql>
2780      SELECT a.itemType
2781      FROM AnnotationSetData a
2782      WHERE a.id = :annotationSetId
2783    </sql>
2784    <description>
2785      An HQL query that loads the item type value an annotation
2786      set with a given ID belongs to.
2787    </description>
2788  </query>
2789  <query id="DBLOG_GET_ITEMID_WITH_ANNOTATION" type="HQL">
2790    <sql>
2791      SELECT i.id
2792      FROM {1} i
2793      WHERE i.annotationSet = :annotationSetId
2794    </sql>
2795    <description>
2796      An HQL query that loads the ID of the item that
2797      is associated with a given annotation set.
2798    </description>
2799  </query>
2800  <query id="DBLOG_GET_NAME_FOR_ITEM" type="HQL">
2801    <sql>
2802      SELECT i.name
2803      FROM {1} i
2804      WHERE i.id = :id
2805    </sql>
2806    <description>
2807      An HQL query that loads the name of a an item.
2808    </description>
2809  </query>
2810  <query id="DBLOG_GET_FILESET_ITEMTYPE" type="HQL">
2811    <sql>
2812      SELECT fs.itemType
2813      FROM FileSetData fs
2814      WHERE fs.id = :fileSetId
2815    </sql>
2816    <description>
2817      An HQL query that loads the item type value a file set
2818      set with a given ID belongs to.
2819    </description>
2820  </query>
2821  <query id="DBLOG_GET_ITEMID_WITH_FILESET" type="HQL">
2822    <sql>
2823      SELECT i.id
2824      FROM {1} i
2825      WHERE i.fileSet = :fileSetId
2826    </sql>
2827    <description>
2828      An HQL query that loads the ID of the item that
2829      is associated with a given file set.
2830    </description>
2831  </query>
2832  <query id="DBLOG_INSERT_INTO_CHANGEHISTORYDETAILS" type="SQL">
2833    <sql>
2834      INSERT INTO [ChangeHistoryDetails]
2835        ([id], [version], [history_id], [change_type], [item_id], [item_type], [change_info], [old_value], [new_value])
2836      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, ?, ?)
2837    </sql>
2838    <description>
2839      SQL query for inserting rows into the ChangeHistoryDetails table.
2840      The primary key (id) must be auto-generated.
2841      Parameters: history_id, change_type, item_id, item_type, change_info, old_value, new_value
2842    </description>
2843  </query>
2844  <query id="GET_GROUPS_WITH_NONHIDDENMEMBERS" type="HQL">
2845    <sql>
2846      SELECT grp.id
2847      FROM GroupData grp
2848      WHERE grp.hiddenMembers = false
2849      AND grp.id IN (:groups)
2850    </sql>
2851    <description>
2852      A HQL query that selects the ID of the groups among a given set of
2853      groups that has 'hiddenMembers=false'
2854    </description>
2855  </query>
2856  <query id="GET_BIOPLATES_FOR_BIOPLATETYPE" type="HQL">
2857    <sql>
2858      SELECT {1}
2859      FROM BioPlateData bpl
2860      WHERE bpl.bioPlateType = :bioPlateType
2861    </sql>
2862    <description>
2863      A HQL query that gets the bioplates using a given type.
2864    </description>
2865  </query>
2866 
2867  <query id="GET_BIOPLATETYPE_WITH_NAME" type="HQL">
2868    <sql>
2869      SELECT bpt
2870      FROM BioPlateTypeData bpt
2871      WHERE bpt.name = :name
2872    </sql>
2873    <description>
2874      A HQL query that gets the bioplate type with a given name.
2875    </description>
2876  </query>
2877  <query id="GET_PROJECTS_FOR_PERMISSION_TEMPLATE" type="HQL">
2878    <sql>
2879      SELECT {1}
2880      FROM ProjectData prj
2881      WHERE prj.permissionTemplate = :permissionTemplate
2882    </sql>
2883    <description>
2884      A HQL query that gets the projects that are using a given permission
2885      template.
2886    </description>
2887  </query>
2888
2889  <query id="SET_GROUP_TO_NULL_ON_DISK_USAGE" type="HQL">
2890    <sql>
2891      UPDATE DiskUsageData du
2892        SET du.group = null
2893        WHERE du.group = :group
2894    </sql>
2895    <description>
2896      An HQL update-query that sets group to null on all
2897      diskusage that are associated with a given group.
2898    </description>
2899  </query>
2900
2901  <query id="CLEAR_ORIGINAL_BIOMATERIAL_ON_BIOWELLS" type="HQL">
2902    <sql>
2903      UPDATE BioWellData bw
2904      SET bw.originalBioMaterial = null
2905      WHERE bw.originalBioMaterial = :bioMaterial
2906    </sql>
2907    <description>
2908      An HQL update-query that for a given biomaterial clears the
2909      link on all biowells were it is set as the original biomaterial.
2910    </description>
2911  </query>
2912
2913  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATEEVENT" type="HQL">
2914    <sql>
2915      UPDATE BioMaterialEventData bme
2916      SET bme.bioPlateEventParticipant = null
2917      WHERE bme.bioPlateEventParticipant =ANY (
2918        SELECT bep FROM BioPlateEventParticipantData bep
2919        WHERE bep.event = :event
2920      )
2921    </sql>
2922    <description>
2923      An HQL update-query that clears the references to a given
2924      bioplate event on all biomaterial events that links to it
2925      (via the bioplate event participant table).
2926    </description>
2927  </query>
2928
2929  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATE" type="HQL">
2930    <sql>
2931      UPDATE BioMaterialEventData bme
2932      SET bme.bioPlateEventParticipant = null
2933      WHERE bme.bioPlateEventParticipant =ANY (
2934        SELECT bep FROM BioPlateEventParticipantData bep
2935        WHERE bep.bioPlate = :bioPlate
2936      )
2937    </sql>
2938    <description>
2939      An HQL update-query that clears the references to all bioplate
2940      event participants on biomaterial events for a given bioplate.
2941    </description>
2942  </query>
2943
2944  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_PARTICIPANT" type="HQL">
2945    <sql>
2946      UPDATE BioMaterialEventData bme
2947      SET bme.bioPlateEventParticipant = null
2948      WHERE bme.bioPlateEventParticipant = :participant
2949    </sql>
2950    <description>
2951      An HQL update-query that clears the references to a given bioplate
2952      event participant on all related biomaterial events.
2953    </description>
2954  </query>
2955
2956  <query id="GET_BIOPLATEEVENTS_FOR_BIOPLATEEVENTTYPE" type="HQL">
2957    <sql>
2958      SELECT {1}
2959      FROM BioPlateEventData bpe
2960      WHERE bpe.eventType = :eventType
2961    </sql>
2962    <description>
2963      An HQL update-query that gets the bioplate events that are
2964      of a given bioplate event type.
2965    </description>
2966  </query>
2967 
2968  <query id="GET_JAR_PATH_FROM_TABLE" type="SQL">
2969    <sql>
2970      SELECT [id], [jar_path] FROM [{1}] [t]
2971      where [t].[jar_file] IS NULL AND NOT [t].[jar_path] IS NULL
2972    </sql>
2973    <description>
2974      An SQL query that selects the ID and JAR_PATH column from a given table
2975      where the existing JAR_PATH has a value and the existing JAR_FILE is
2976      null.
2977    </description>
2978  </query>
2979
2980  <query id="SET_JAR_FILE_IN_TABLE" type="SQL">
2981    <sql>
2982      UPDATE [{1}] SET [jar_file] = :file WHERE id = :id
2983    </sql>
2984    <description>
2985      An SQL query that updates the JAR_FILE with the given value.
2986    </description>
2987  </query>
2988 
2989  <query id="DROP_COLUMN" type="SQL">
2990    <sql>
2991      ALTER TABLE [{1}] DROP COLUMN [{2}]
2992    </sql>
2993    <description>
2994      An SQL query that drops a column (2) from a table (1).
2995    </description>
2996  </query>
2997 
2998  <query id="DROP_NOT_NULL_CONSTRAINT" type="SQL">
2999    <sql>
3000      ALTER TABLE [{1}] ALTER COLUMN [{2}] DROP NOT NULL
3001    </sql>
3002    <description>
3003      An SQL query that drops a NOT NULL contraint from column (2) in a table (1).
3004    </description>
3005  </query>
3006
3007  <query id="DROP_TABLE" type="SQL">
3008    <sql>
3009      DROP TABLE [{1}]
3010    </sql>
3011    <description>
3012      An SQL query that drops a table (1).
3013    </description>
3014  </query>
3015
3016  <query id="CONVERT_LABELEDEXTRACTS_TO_EXTRACTS" type="SQL">
3017    <sql>
3018      UPDATE [BioMaterials]
3019      SET [discriminator] = 3
3020      WHERE [discriminator] = 4
3021    </sql>
3022    <description>
3023      An SQL query that convert labeled extract to extract.
3024    </description>
3025  </query>
3026
3027  <query id="GET_HYBRIDIZATIONS" type="SQL">
3028    <sql>
3029      SELECT
3030        [id], [version],
3031        [arrayslide_id], [num_arrays],
3032        [annotationset_id], [name],
3033        [description], [removed],
3034        [itemkey_id], [projectkey_id],
3035        [owner]
3036      FROM
3037        [Hybridizations]
3038    </sql>
3039    <description>
3040      An SQL query that load all BASE 2.17 hybridizations.
3041    </description>
3042  </query>
3043
3044  <query id="UPDATE_BIOASSAYID_FROM_HYBID" type="SQL">
3045    <sql>
3046      UPDATE [BioMaterialEvents]
3047      SET [physicalbioassay_id] = :bioAssayId
3048      WHERE [hybridization_id] = :hybId
3049    </sql>
3050    <description>
3051      An SQL query that sets the physicalbioassay_id
3052      for a given hybridization_id
3053    </description>
3054  </query>
3055
3056  <query id="GET_SCANS" type="SQL">
3057    <sql>
3058      SELECT
3059        [id], [version],
3060        [entry_date], [hybridization_id],
3061        [hardware_id], [protocol_id],
3062        [annotationset_id], [name],
3063        [description], [removed],
3064        [itemkey_id], [projectkey_id],
3065        [owner]
3066      FROM
3067        [Scans]
3068    </sql>
3069    <description>
3070      An SQL query that load all BASE 2.17 scans.
3071    </description>
3072  </query>
3073
3074  <query id="GET_IMAGES" type="SQL">
3075    <sql>
3076      SELECT
3077        [id], [version],
3078        [file_id]
3079      FROM
3080        [Images]
3081      WHERE [scan_id] = :scanId
3082    </sql>
3083    <description>
3084      An SQL query that load BASE 2.17 image files for a given scan.
3085    </description>
3086  </query>
3087
3088  <query id="GET_PROTOCOLTYPES" type="SQL">
3089    <sql>
3090      SELECT
3091        [id], [version],
3092        [entry_date], [name],
3093        [description], [removed],
3094        [system_id]
3095      FROM
3096        [ProtocolTypes]
3097    </sql>
3098    <description>
3099      An SQL query that load all BASE 2.17 protocol types.
3100    </description>
3101  </query>
3102
3103  <query id="GET_HARDWARETYPES" type="SQL">
3104    <sql>
3105      SELECT
3106        [id], [version],
3107        [entry_date], [name],
3108        [description], [removed],
3109        [system_id]
3110      FROM
3111        [HardwareTypes]
3112    </sql>
3113    <description>
3114      An SQL query that load all BASE 2.17 hardware types.
3115    </description>
3116  </query>
3117 
3118  <query id="GET_SOFTWARETYPES" type="SQL">
3119    <sql>
3120      SELECT
3121        [id], [version],
3122        [entry_date], [name],
3123        [description], [system_id]
3124      FROM
3125        [SoftwareTypes]
3126    </sql>
3127    <description>
3128      An SQL query that load all BASE 2.17 software types.
3129    </description>
3130  </query>
3131
3132  <query id="GET_FILETYPES" type="SQL">
3133    <sql>
3134      SELECT
3135        [id], [version],
3136        [entry_date], [name],
3137        [description], [system_id]
3138      FROM
3139        [FileTypes]
3140    </sql>
3141    <description>
3142      An SQL query that load all BASE 2.17 file types.
3143    </description>
3144  </query>
3145
3146  <query id="GET_RAWBIOASSAYS" type="SQL">
3147    <sql>
3148      SELECT
3149        [id], [scan_id],
3150        [array_num]
3151      FROM [RawBioAssays]
3152      WHERE NOT [scan_id] IS NULL
3153    </sql>
3154    <description>
3155      An SQL query that load scan and array num for all raw bioassays
3156      that has a scan parent.
3157    </description>
3158  </query>
3159
3160  <query id="FIND_EXTRACT_FOR_RAWBIOASSAY_POSITION" type="SQL">
3161    <sql>
3162      SELECT bm2.[biomaterial_id]
3163      FROM [DerivedBioAssays] dba
3164      INNER JOIN [ParentPhysicalBioAssays] pba ON pba.[derivedbioassay_id] = dba.[id]
3165      INNER JOIN [BioMaterialEvents] bme ON bme.[physicalbioassay_id] = pba.[physicalbioassay_id]
3166      INNER JOIN [BioMaterialEventSources2] bm2 ON bm2.[event_id]=bme.[id]
3167      WHERE bm2.[position] = :position AND dba.[id] = :derivedBioAssayId
3168    </sql>
3169    <description>
3170      An SQL query that tries to find the extract id given a
3171      derived bioassay and the bioassay position.
3172    </description>
3173  </query>
3174 
3175  <query id="UPDATE_RAWBIOASSAY" type="SQL">
3176    <sql>
3177      UPDATE [RawBioAssays]
3178      SET [bioassay_id] = :parentBioAssayId,
3179      [extract_id] = :extractId
3180      WHERE [id] = :rawBioAssayId
3181    </sql>
3182    <description>
3183      An SQL query that update the parent bioassay and extract
3184      for a given raw bioassay.
3185    </description>
3186  </query>
3187
3188
3189  <query id="COPY_BIOMATERIALEVENTSOURCES" type="SQL">
3190    <sql>
3191      INSERT INTO [BioMaterialEventSources2]
3192      (
3193        [id], [version],
3194        [biomaterial_id], [event_id],
3195        [used_quantity], [position]
3196      )
3197      SELECT
3198        {1}, 0,
3199        [biomaterial_id], [event_id],
3200        [used_quantity], [dummy]
3201      FROM [BioMaterialEventSources]
3202    </sql>
3203    <description>
3204      An SQL query that load copy BASE 2.17 biomaterial
3205      event sources to the new table.
3206    </description>
3207  </query>
3208
3209  <query id="COPY_SAMPLE_BIOSOURCE_PARENT_LINK" type="SQL">
3210    <sql>
3211      INSERT INTO [BioMaterialEventSources2]
3212      (
3213        [id], [version],
3214        [biomaterial_id], [event_id],
3215        [used_quantity], [position]
3216      )
3217      SELECT
3218        {1}, 0,
3219        bm.[parent_id], evt.[id],
3220        null, 1
3221      FROM [BioMaterials] bm
3222      INNER JOIN [BioMaterialEvents] evt ON bm.[id]=evt.[biomaterial_id] AND evt.[event_type]=1
3223      WHERE bm.[discriminator] = 2 AND NOT bm.[parent_id] IS NULL
3224    </sql>
3225    <description>
3226      An SQL query that copy Sample--BioSource parent
3227      links to the BioMaterialEventSources2 table.
3228    </description>
3229  </query>
3230
3231  <query id="NULLIFY_ALL_BIOMATERIAL_PARENTS" type="SQL">
3232    <sql>
3233      UPDATE [BioMaterials]
3234      SET [parent_type] = NULL, [parent_id] = NULL
3235    </sql>
3236    <description>
3237      An SQL query that nullify all biomaterial parent
3238      information.
3239    </description>
3240  </query>
3241
3242  <query id="GET_BIOMATERIAL_PARENT_INFO" type="SQL">
3243    <sql>
3244      SELECT bm.[id], bm.[discriminator], evt.[biomaterial_id]
3245      FROM [BioMaterialEventSources2] bm2
3246      INNER JOIN [BioMaterialEvents] evt ON bm2.[event_id]=evt.[id] AND evt.[event_type]=1
3247      INNER JOIN [BioMaterials] bm ON bm2.[biomaterial_id]=bm.[id]
3248      ORDER BY evt.[biomaterial_id]
3249    </sql>
3250    <description>
3251      An SQL query that get parent biomaterial information. We need
3252      parent_id, parent_type and child_id ordered by child_id
3253    </description>
3254  </query>
3255
3256
3257  <query id="SET_BIOMATERIAL_PARENT" type="SQL">
3258    <sql>
3259      UPDATE [BioMaterials]
3260      SET [parent_type] = :parentType, [parent_id] = :parentId
3261      WHERE [id] = :childId
3262    </sql>
3263    <description>
3264      An SQL query that set the biomaterial parent info for a single
3265      biomaterial.
3266    </description>
3267  </query>
3268
3269  <query id="SET_LABELEDEXTRACT_SUBTYPE" type="SQL">
3270    <sql>
3271      UPDATE [BioMaterials]
3272      SET [subtype_id]=:subtype
3273      WHERE [label_id] IS NOT NULL
3274    </sql>
3275    <description>
3276      An SQL query that sets the subtype of labeled extracts
3277    </description>
3278  </query>
3279
3280  <query id="SET_SUBTYPE_ON_ALL" type="SQL">
3281    <sql>
3282      UPDATE [{1}]
3283      SET [subtype_id]=:subtype
3284    </sql>
3285    <description>
3286      An SQL query that sets the subtype
3287      of all items in a table
3288    </description>
3289  </query>
3290
3291  <query id="UPDATE_ANNOTATIONSET_ITEM" type="SQL">
3292    <sql>
3293      UPDATE [AnnotationSets]
3294      SET [item_id] = :newId, [item_type] = {1}
3295      WHERE [id] = :id
3296    </sql>
3297    <description>
3298      An SQL query that update the item_type and item_id
3299      on annotation set.
3300    </description>
3301  </query>
3302
3303  <query id="UPDATE_ANYTOANY_FROMITEM" type="SQL">
3304    <sql>
3305      UPDATE [AnyToAny]
3306      SET [from_id] = :newId, [from_type] = {2}
3307      WHERE [from_id] = :oldId AND [from_type] = {1}
3308    </sql>
3309    <description>
3310      An SQL query that update the from_type and from_id
3311      on any-to-any.
3312    </description>
3313  </query>
3314 
3315  <query id="UPDATE_ANYTOANY_TOITEM" type="SQL">
3316    <sql>
3317      UPDATE [AnyToAny]
3318      SET [to_id] = :newId, [to_type] = {2}
3319      WHERE [to_id] = :oldId AND [to_type] = {1}
3320    </sql>
3321    <description>
3322      An SQL query that update the to_type and to_id
3323      on any-to-any.
3324    </description>
3325  </query>
3326 
3327  <query id="UPDATE_CHANGEHISTORYDETAILS_ITEM" type="SQL">
3328    <sql>
3329      UPDATE [ChangeHistoryDetails]
3330      SET [item_id] = :newId, [item_type] = {2}
3331      WHERE [item_id] = :oldId AND [item_type] = {1}
3332    </sql>
3333    <description>
3334      An SQL query that update the item_type and item_id
3335      on change history details.
3336    </description>
3337  </query>
3338 
3339  <query id="UPDATE_ITEMVALUES_ITEM" type="SQL">
3340    <sql>
3341      UPDATE [ItemValues]
3342      SET [data_class_id] = :newId, [data_class] = :newClass
3343      WHERE [data_class_id] = :oldId AND [data_class] = :oldClass
3344    </sql>
3345    <description>
3346      An SQL query that update the data_class_id and data_class
3347      on item values.
3348    </description>
3349  </query>
3350
3351  <query id="UPDATE_ITEMVALUES_CLASS" type="SQL">
3352    <sql>
3353      UPDATE [ItemValues]
3354      SET [data_class] = :newClass
3355      WHERE [data_class] = :oldClass
3356    </sql>
3357    <description>
3358      An SQL query that update the data_class
3359      on item values.
3360    </description>
3361  </query>
3362
3363  <query id="UPDATE_ITEMTYPE" type="SQL">
3364    <sql>
3365      UPDATE [{1}]
3366      SET [{2}] = {4}
3367      WHERE [{2}] = {3}
3368    </sql>
3369    <description>
3370      An SQL query that update the item-type column on
3371      a generic table.
3372    </description>
3373  </query>
3374
3375  <query id="UPDATE_SUBTYPEID_FROM_OLDTYPEID" type="SQL">
3376    <sql>
3377      UPDATE [{1}]
3378      SET [{2}] = :subtypeId
3379      WHERE [{3}] = :oldTypeId
3380    </sql>
3381    <description>
3382      An SQL query that update the subtype_id column on
3383      a generic table.
3384    </description>
3385  </query>
3386
3387
3388  <query id="DELETE_PLUGINGUICONTEXTS_FOR_ITEMTYPE" type="SQL">
3389    <sql>
3390      DELETE FROM [PluginDefinitionGuiContexts]
3391      WHERE [item_type] = :itemType
3392    </sql>
3393    <description>
3394      An SQL query that delete plug-in gui contexts for
3395      a given item type.
3396    </description>
3397  </query>
3398
3399  <query id="DELETE_PLUGINKEYS_FOR_ITEMTYPE" type="SQL">
3400    <sql>
3401      DELETE FROM [PluginKeys]
3402      WHERE [key_id] IN (
3403        SELECT k.[id]
3404        FROM [Keys] k
3405        WHERE k.[item_type] = :itemType
3406      )
3407    </sql>
3408    <description>
3409      An SQL query that delete plug-in keys referencing keys
3410      for a given item type.
3411    </description>
3412  </query>
3413
3414
3415  <query id="GET_SUBTYPABLE_ITEMS_FOR_SUBTYPE_OF_CLASS" type="HQL">
3416    <sql>
3417      SELECT {1}
3418      FROM {2} sub
3419      WHERE sub.itemSubtype = :subtype
3420    </sql>
3421    <description>
3422      Get all items that are subtyped with a subtype for a given class.
3423    </description>
3424  </query>
3425 
3426  <query id="GET_ITEMLISTS_FOR_SUBTYPE" type="HQL">
3427    <sql>
3428      SELECT {1}
3429      FROM ItemListData il
3430      WHERE il.itemSubtype = :subtype
3431    </sql>
3432    <description>
3433      A Hibernate query that gets ITEMLISTS for a given item subtype.
3434    </description>
3435  </query>
3436 
3437  <query id="GET_MIMETYPES_FOR_FILETYPE" type="HQL">
3438    <sql>
3439      SELECT {1}
3440      FROM MimeTypeData mt
3441      WHERE mt.fileType = :subtype
3442    </sql>
3443    <description>
3444      A Hibernate query that gets MIME types for a given item subtype.
3445    </description>
3446  </query>
3447 
3448  <query id="GET_DATAFILETYPES_FOR_FILETYPE" type="HQL">
3449    <sql>
3450      SELECT {1}
3451      FROM DataFileTypeData dft
3452      WHERE dft.genericType = :subtype
3453    </sql>
3454    <description>
3455      A Hibernate query that gets Data file types for a given item subtype.
3456    </description>
3457  </query>
3458 
3459  <query id="UPDATE_FILESETMEMBER_FILETYPE" type="HQL">
3460    <sql>
3461      UPDATE FileSetMemberData mbr
3462      SET mbr.dataFileType = :newType
3463      WHERE mbr.dataFileType = :oldType
3464    </sql>
3465    <description>
3466      A Hibernate query that update the data file type of all
3467      file set members with a given old data file type.
3468    </description>
3469  </query>
3470 
3471  <query id="DISABLE_ALL_PLUGINS" type="HQL">
3472    <sql>
3473      UPDATE PluginDefinitionData pl
3474      SET pl.disabled = true
3475    </sql>
3476    <description>
3477      A Hibernate query that disable all plug-ins.
3478    </description>
3479  </query>
3480 
3481  <query id="GET_PROJECT_DEFAULT_ANYTOANY" type="HQL">
3482    <sql>
3483      SELECT a FROM AnyToAnyData a
3484      WHERE a.fromType = 24 AND a.name LIKE 'default_%'
3485    </sql>
3486    <description>
3487      A Hibernate query that load all any-to-any links containing
3488      project default items.
3489    </description>
3490  </query>
3491 
3492  <query id="GET_MD5_PASSWORDS" type="SQL">
3493    <sql>
3494      SELECT [id], [md5password] FROM [Passwords]
3495    </sql>
3496    <description>
3497      An SQL query that load all md5 passwords.
3498    </description>
3499  </query>
3500
3501  <query id="SET_ENCRYPTED_PASSWORD" type="SQL">
3502    <sql>
3503      UPDATE [Passwords]
3504      SET [crypted_password] = :cryptedPassword
3505      WHERE [id] = :id
3506    </sql>
3507    <description>
3508      An SQL query that set the encrypted password for a given entry.
3509    </description>
3510  </query>
3511 
3512  <query id="GET_VIRTUALDBS_FOR_REPORTERCLONETEMPLATE" type="HQL">
3513    <sql>
3514      SELECT {1}
3515      FROM VirtualDbData vdb
3516      WHERE vdb.reporterCloneTemplate = :reporterCloneTemplate
3517    </sql>
3518    <description>
3519      A Hibernate query that get virtual databases
3520      that are using a given reporter clone template.
3521    </description>
3522  </query>
3523
3524  <query id="GET_ALL_ANNOTATIONTYPE_IDS_FOR_USER" type="SQL">
3525    <sql>
3526      SELECT [at].[id]
3527      FROM [AnnotationTypes] [at]
3528      WHERE [at].[owner] = :owner
3529      OR [at].[itemkey_id] IN (:itemKeys)
3530      OR [at].[projectkey_id] IN (:projectKeys)
3531    </sql>
3532    <description>
3533      An SQL query that load the ID of all the annotation types
3534      that the current user has access to. We need to set owner,
3535      item keys and project keys as parameters.
3536    </description>
3537  </query>
3538
3539  <query id="COPY_PARENT_PHYSICAL_BIOASSAYS" type="SQL">
3540    <sql>
3541      INSERT INTO [ParentPhysicalBioAssays] ([physicalbioassay_id], [derivedbioassay_id])
3542      SELECT [bioassay_id], [id] FROM [DerivedBioAssays]
3543    </sql>
3544    <description>
3545      An SQL query that copy the parent physical bioassays
3546      to the new (in BASE 3.2) ParentPhysicalBioAssays table
3547    </description>
3548  </query>
3549
3550
3551  <query id="COPY_PARENT_DERIVED_BIOASSAYS" type="SQL">
3552    <sql>
3553      INSERT INTO [ParentDerivedBioAssays] ([parentbioassay_id], [derivedbioassay_id])
3554      SELECT [parent_id], [id] FROM [DerivedBioAssays] WHERE NOT [parent_id] IS NULL
3555    </sql>
3556    <description>
3557      An SQL query that copy the parent derived bioassays
3558      to the new (in BASE 3.2) ParentDerivedBioAssays table
3559    </description>
3560  </query>
3561
3562  <query id="SET_ISROOT_ON_DERIVED_BIOASSAYS" type="SQL">
3563    <sql>
3564      UPDATE [DerivedBioAssays] SET [is_root] = ([parent_id] IS NULL)
3565    </sql>
3566    <description>
3567      An SQL query that set the is_root property on DerivedBioAssays table.
3568    </description>
3569  </query>
3570 
3571  <query id="GET_ITEMSUBTYPE_WITH_NAME_AND_ITEMTYPE" type="HQL">
3572    <sql>
3573      SELECT st FROM ItemSubtypeData st
3574      WHERE st.name = :name AND st.itemType = :itemType
3575    </sql>
3576    <description>
3577      A Hibernate query that load an item subtype given the name
3578      and main item type.
3579    </description>
3580  </query>
3581 
3582  <query id="SET_DISABLE_LOG_FOR_ANNOTATION_TYPES" type="HQL">
3583    <sql>
3584      UPDATE AnnotationTypeData at
3585      SET at.disableLogOfValues = false
3586      WHERE at.disableLogOfValues IS NULL
3587    </sql>
3588    <description>
3589      An HQL query that set the disableLogOfValues=false for all annotation types
3590      with a null value.
3591    </description>
3592  </query>
3593
3594  <query id="AB_LOAD_ANNOTATION_INFO" type="SQL">
3595    <sql>
3596      SELECT [annotationtype_id], [id], [version], [unit_id], [value_id], [last_update], [project_id], [override_id]
3597      FROM [Annotations]
3598      WHERE [annotationset_id] = :annotationSet AND [source] = 0 AND ([project_id] = :defaultProject OR [project_id] = :activeProject)
3599    </sql>
3600    <description>
3601      SQL query for loading current (primary) annotations for
3602      a given item.
3603      Used by the AnnotationBatcher as a SQL query via Hibernate.
3604    </description>
3605  </query>
3606
3607  <query id="AB_LOAD_ANNOTATION_VALUES" type="SQL">
3608    <sql>
3609      SELECT [id], [value]
3610      FROM [{1}]
3611      WHERE [id] IN (:listOfIds)
3612    </sql>
3613    <description>
3614      SQL query for loading current annotation values
3615      for a given list of annotation value IDs.
3616      Used by the AnnotationBatcher as a SQL query via Hibernate.
3617    </description>
3618  </query>
3619
3620  <query id="AB_INSERT_INTO_PARAMETERVALUES" type="SQL">
3621    <sql>
3622      INSERT INTO [ParameterValues] ([id], [discriminator], [version])
3623      VALUES (nextval('hibernate_sequence'), ?, 0)
3624    </sql>
3625    <description>
3626      SQL query for inserting rows into the ParameterValues table.
3627      The primary key (id) must be auto-generated.
3628      Parameters: discriminator
3629    </description>
3630  </query>
3631
3632  <query id="AB_INSERT_INTO_ANNOTATIONS" type="SQL">
3633    <sql>
3634      INSERT INTO [Annotations] ([id], [version], [annotationset_id], [annotationtype_id], [unit_id], [value_id], [last_update], [source], [project_id], [override_id])
3635      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, 0, ?, ?)
3636    </sql>
3637    <description>
3638      SQL query for inserting rows into the Annotations table.
3639      The primary key (id) must be auto-generated.
3640      Parameters: annotationset_id, annotationtype_id, unit_id, value_id, last_updated, project_id, override_id
3641    </description>
3642  </query>
3643
3644  <query id="AB_UPDATE_ANNOTATIONS" type="SQL">
3645    <sql>
3646      UPDATE [Annotations]
3647      SET [version] = ?, [unit_id] = ?, [last_update] = ?
3648      WHERE [id] = ? AND [version] = ?
3649    </sql>
3650    <description>
3651      SQL query for updating rows into the Annotations table.
3652      Parameters: version (new), unit_id, last_updated, id, version (old)
3653    </description>
3654  </query>
3655
3656  <query id="AB_INSERT_INTO_ANNOTATIONSETS" type="SQL">
3657    <sql>
3658      INSERT INTO [AnnotationSets] ([id], [version], [item_type], [item_id])
3659      VALUES (nextval('hibernate_sequence'), 0, {1}, ?)
3660    </sql>
3661    <description>
3662      SQL query for inserting rows into the AnnotationSets table.
3663      The primary key (id) must be auto-generated.
3664      Parameters: item_id
3665    </description>
3666  </query>
3667 
3668  <query id="AB_UPDATE_ITEMTABLE" type="SQL">
3669    <sql>
3670      UPDATE [{1}]
3671      SET [annotationset_id] = ?
3672      WHERE [id] = ?
3673    </sql>
3674    <description>
3675      SQL query for updating the annotationset_id column in any
3676      table it exists in.
3677      Parameters: annotationset_id, item_id
3678    </description>
3679  </query>
3680
3681  <query id="AB_NULLIFY_CLONED_ANNOTATIONS" type="SQL">
3682    <sql>
3683      UPDATE [Annotations]
3684      SET [inherited_id] = null
3685      WHERE [inherited_id] = ? and [source] = 2
3686    </sql>
3687    <description>
3688      SQL query for setting the 'inherited_id' column to null
3689      for cloned annotations that reference the annotation that
3690      is about to be deleted.
3691      Parameters: inherited_id
3692    </description>
3693  </query>
3694
3695  <query id="AB_DELETE_INHERITED_ANNOTATIONS" type="SQL">
3696    <sql>
3697      DELETE FROM [Annotations]
3698      WHERE [inherited_id] = ? and [source] = 1
3699    </sql>
3700    <description>
3701      SQL query for deleting inherited annotations that reference
3702      the annotation that is about to be deleted.
3703      Parameters: inherited_id
3704    </description>
3705  </query>
3706
3707  <query id="AB_DELETE_FROM_ANNOTATIONS" type="SQL">
3708    <sql>
3709      DELETE FROM [Annotations]
3710      WHERE [id] = ?
3711    </sql>
3712    <description>
3713      SQL query for deleting an annotation with a given id.
3714      Used by the AnnotationBatcher as a PreparedStatement.
3715      Parameters: id
3716    </description>
3717  </query>
3718
3719  <query id="AB_DELETE_FROM_PARAMETERVALUES" type="SQL">
3720    <sql>
3721      DELETE FROM [ParameterValues] WHERE [id] = ?
3722    </sql>
3723    <description>
3724      SQL query for deleting a parameter value with a given id.
3725      Used by the AnnotationBatcher as a PreparedStatement.
3726    </description>
3727  </query>
3728
3729  <query id="AB_DELETE_FROM_VALUES" type="SQL">
3730    <sql>
3731      DELETE FROM [{1}] WHERE [id] = ?
3732    </sql>
3733    <description>
3734      SQL query for deleting all actual annotation values with a given id.
3735      The {1} parameter is the table the value are stored in, eg. StringValues,
3736      IntegerValues, FloatValues, etc.
3737      Used by the AnnotationBatcher as a PreparedStatement.
3738    </description>
3739  </query>
3740 
3741  <query id="AB_INSERT_INTO_VALUES" type="SQL">
3742    <sql>
3743      INSERT INTO [{1}] ([id], [value]) VALUES (?, ?)
3744    </sql>
3745    <description>
3746      SQL query for inserting annotation values in their respective
3747      table (eg. StringValues, IntegerValues, FloatValues, etc.).
3748      Used by the AnnotationBatcher as a PreparedStatement.
3749    </description>
3750  </query>
3751 
3752  <query id="AB_UPDATE_OVERRIDE_ID" type="SQL">
3753    <sql>
3754      UPDATE [Annotations]
3755      SET [override_id] = ?
3756      WHERE [annotationset_id] = ?
3757      AND [annotationtype_id] = ?
3758      AND [source] = 0
3759      AND [project_id] &lt;&gt; 0
3760    </sql>
3761    <description>
3762      Updates the "override_id" column on project-specific annotations
3763      to point to a newly created default annotation of the same
3764      annotation type (PRIMARY annotations only).
3765      Used by the AnnotationBatcher as a PreparedStatement.
3766      Parameters: override_id, annotationset_id, annotationtype_id
3767    </description>
3768  </query>
3769 
3770 
3771  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF" type="SQL">
3772    <sql>
3773      UPDATE [Annotations]
3774      SET [override_id] = :annotationId
3775      WHERE [annotationset_id] = :annotationSetId
3776      AND [annotationtype_id] = :annotationTypeId
3777      AND [source] = 0
3778      AND [project_id] &lt;&gt; 0
3779    </sql>
3780    <description>
3781      Updates the "override_id" column on project-specific annotations
3782      to point to a newly created default annotation of the same
3783      annotation type (PRIMARY annotations only).
3784    </description>
3785  </query>
3786 
3787  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION" type="SQL">
3788    <sql>
3789      UPDATE [Annotations]
3790      SET [override_id] = COALESCE(
3791        (SELECT [id] FROM [Annotations]
3792        WHERE [annotationset_id] = :annotationSetId
3793        AND [annotationtype_id] = :annotationTypeId
3794        AND [source] = 0 AND [project_id] = 0)
3795        , 0)
3796      WHERE id = :annotationId
3797    </sql>
3798    <description>
3799      Updates the "override_id" column on a newly created project-specific
3800      (PRIMARY) annotation to point to the existing default annotation id
3801      or 0 if no default annotation exists.
3802    </description>
3803  </query>
3804 
3805  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF_INHERITED" type="HQL">
3806    <sql>
3807      UPDATE [Annotations]
3808      SET [override_id] = :annotationId
3809      WHERE [annotationset_id] = :annotationSetId
3810      AND [inherited_id] IN (
3811        SELECT [id] FROM [Annotations]
3812        WHERE [annotationset_id] = :parentSetId
3813        AND [override_id] = :parentId
3814      )
3815    </sql>
3816    <description>
3817      Updates the "override_id" column on project-specific annotations
3818      to point to a newly created default annotation (INHERITED and
3819      CLONED annotations). The subquery will find project-specific annotation
3820      on the parent annotation set that is overriding the inherited annotation.
3821    </description>
3822  </query>
3823 
3824  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION_INHERITED" type="SQL">
3825    <sql>
3826      UPDATE [Annotations]
3827      SET [override_id] = COALESCE(
3828        (SELECT [id] FROM [Annotations]
3829        WHERE [annotationset_id] = :annotationSetId
3830        AND [inherited_id] = :parentOverrideId
3831        AND [source] &lt;&gt; 0
3832        AND [project_id] = 0)
3833        , 0)
3834      WHERE id = :annotationId
3835    </sql>
3836    <description>
3837      Updates the "override_id" column on a newly created project-specific
3838      (CLONED or INHERITED) annotation to point to the existing default
3839      annotation id or 0 if no default annotation exists.
3840    </description>
3841  </query>
3842 
3843  <query id="PS_RESET_OVERRIDE_ON_PROJECT_ANNOTATIONS" type="HQL">
3844    <sql>
3845      UPDATE [Annotations] 
3846      SET [override_id] = 0
3847      WHERE [override_id] IN (:deletedAnnotations)
3848      OR [inherited_id] IN (
3849        SELECT [id] FROM [Annotations]
3850        WHERE [override_id] IN (:deletedPrimaryAnnotations)
3851      )
3852    </sql>
3853    <description>
3854      Reset the "override_id" column on project-specific annotations
3855      that points to a default annotation that has been removed.
3856    </description>
3857  </query>
3858   
3859  <query id="PS_LOAD_ANNOTATIONS_IN_NON_EXISTING_PROJECTS" type="SQL">
3860    <sql>
3861      SELECT a.[id], a.[annotationset_id], a.[value_id], a.[project_id], at.[value_type]
3862      FROM [Annotations] a
3863      INNER JOIN [AnnotationTypes] at ON at.[id] = a.[annotationtype_id]
3864      WHERE a.[project_id] &lt;&gt; 0 AND a.[project_id] NOT IN (SELECT [id] FROM [Projects])
3865    </sql>
3866    <description>
3867      SQL query for loading information about annotations
3868      that are project-specific annotations for a given
3869      list of projects.
3870      Used by the ProjectSpecificAnnotationsManager when
3871      a project has been deleted.
3872    </description>
3873  </query>
3874 
3875  <query id="PS_DELETE_FROM_PARAMETERVALUES" type="SQL">
3876    <sql>
3877      DELETE FROM [ParameterValues] WHERE [id] IN (:deletedValues)
3878    </sql>
3879    <description>
3880      SQL query for deleting mutliple parameter values with a given id's.
3881      Used by the ProjectSpecificAnnotationsManager.
3882    </description>
3883  </query>
3884
3885  <query id="PS_DELETE_FROM_VALUES" type="SQL">
3886    <sql>
3887      DELETE FROM [{1}] WHERE [id] IN (:deletedValues)
3888    </sql>
3889    <description>
3890      SQL query for deleting all actual annotation values with given id's.
3891      The {1} parameter is the table the value are stored in, eg. StringValues,
3892      IntegerValues, FloatValues, etc.
3893      Used by the ProjectSpecificAnnotationsManager.
3894    </description>
3895  </query>
3896 
3897  <query id="PS_DELETE_FROM_ANNOTATIONS_IN_PROJECTS" type="SQL">
3898    <sql>
3899      DELETE FROM [Annotations] WHERE [project_id] IN (:deletedProjects)
3900    </sql>
3901    <description>
3902      SQL query for deleting all annotation entries referenceing
3903      given list of projects.
3904      Used by the ProjectSpecificAnnotationsManager.
3905    </description>
3906  </query>
3907 
3908  <query id="PS_FIND_PROJECT_SPECIFIC_ANNOTATION" type="HQL">
3909    <sql>
3910      SELECT ad FROM AnnotationData ad
3911      WHERE ad.projectId = :activeProject
3912      AND ad.overrideId = :defaultAnnotation
3913      AND ad.annotationSet = :annotationSet
3914    </sql>
3915    <description>
3916      HQL query for locating a project-specific annotation
3917      overriding a specified default annotation.
3918      Used by the ProjectSpecificAnnotationsManager.
3919    </description>
3920  </query>
3921 
3922  <query id="COUNT_PROJECT_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
3923    <sql>
3924      SELECT count(*)
3925      FROM AnnotationData ad
3926      WHERE ad.annotationType = :annotationType
3927      AND ad.projectId &lt;&gt; 0
3928    </sql>
3929    <description>
3930      HQL query that counts the number of project-specific annotations
3931      for an annotation type.
3932    </description>
3933  </query>
3934
3935</predefined-queries>
Note: See TracBrowser for help on using the repository browser.