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

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

References #2056: Improve API for project-specific annotations

The AnnotationBatcher should now have support for setting a specific project to work with. A single batcher may only work with one project (or with default values) during it's lifetime. It is not possible to switch strategy between items or annotation types.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 98.2 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 7298 2017-02-21 08:49:31Z 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_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
2404    <sql>
2405      SELECT mbr
2406      FROM FileSetMemberData mbr
2407      WHERE mbr.dataFileType.externalId = :externalId
2408      AND mbr.fileSet = :fileSet
2409    </sql>
2410    <description>
2411      A Hibernate query that loads a member in a given file set
2412      if we know the external ID of the data file type.
2413    </description>
2414  </query>
2415
2416 
2417  <query id="UPDATE_JOB_STATUS" type="HQL">
2418    <sql>
2419      UPDATE JobData job
2420      SET
2421        job.percentComplete = :percent,
2422        job.statusMessage = :statusMessage
2423      WHERE job.id = :id
2424    </sql>
2425    <description>
2426      A HQL query that updates the progress information on a specific job.
2427    </description>
2428  </query>
2429 
2430  <query id="APPEND_JOB_STATUS" type="HQL">
2431    <sql>
2432      UPDATE JobData job
2433      SET
2434        job.statusMessage = job.statusMessage || :statusMessage
2435      WHERE job.id = :id
2436    </sql>
2437    <description>
2438      A HQL query that appends a string to the status message on a specific job.
2439    </description>
2440  </query>
2441
2442  <query id="LOAD_RAWBIOASSAY_JOBS_IN_EXPERIMENT" type="HQL">
2443    <sql>
2444      SELECT DISTINCT rba.job.id
2445      FROM RawBioAssayData rba
2446      WHERE rba.job.experiment = :experiment
2447    </sql>
2448    <description>
2449      A HQL query that loads the ID:s of all jobs that are part
2450      of a given experiment and also has been assigned to at
2451      least one raw bioassay.
2452    </description>
2453  </query>
2454 
2455  <query id="LOAD_ARRAYDESIGN_JOBS_IN_EXPERIMENT" type="HQL">
2456    <sql>
2457      SELECT ad.job.id
2458      FROM ArrayDesignData ad
2459      WHERE ad.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 array design.
2465    </description>
2466  </query>
2467
2468  <query id="UNLINK_JOBS_FROM_EXPERIMENT" type="HQL">
2469    <sql>
2470      UPDATE JobData job
2471      SET job.experiment = null
2472      WHERE job.id IN (:list)
2473    </sql>
2474    <description>
2475      A HQL query that set the experiment property to null for
2476      a given set of jobs.
2477    </description>
2478  </query>
2479 
2480  <query id="GET_UNIT_WITH_NAME_FOR_QUANTITY" type="HQL">
2481    <sql>
2482      SELECT unt
2483      FROM UnitData unt
2484      WHERE unt.quantity = :quantity
2485      AND unt.name = :name
2486    </sql>
2487    <description>
2488      A HQL query that finds the unit for a quantity
2489      with a given name.
2490    </description>
2491  </query>
2492
2493  <query id="GET_UNITS_FOR_QUANTITY" type="HQL">
2494    <sql>
2495      SELECT {1}
2496      FROM UnitData unt
2497      WHERE unt.quantity = :quantity
2498    </sql>
2499    <description>
2500      A Hibernate query that gets units
2501      for a given quantity.
2502    </description>
2503  </query>
2504
2505  <query id="GET_ANNOTATIONTYPES_FOR_QUANTITY" type="HQL">
2506    <sql>
2507      SELECT {1}
2508      FROM AnnotationTypeData at
2509      WHERE at.quantity = :quantity
2510    </sql>
2511    <description>
2512      A Hibernate query that gets annotation types
2513      that are using a given quantity.
2514    </description>
2515  </query>
2516 
2517  <query id="GET_ANNOTATIONTYPES_FOR_UNIT" type="HQL">
2518    <sql>
2519      SELECT {1}
2520      FROM AnnotationTypeData at
2521      WHERE at.defaultUnit = :unit
2522    </sql>
2523    <description>
2524      A Hibernate query that gets annotation types
2525      that are using a given unit as default unit.
2526    </description>
2527  </query>
2528 
2529  <query id="GET_ANNOTATIONS_FOR_UNIT" type="HQL">
2530    <sql>
2531      SELECT {1}
2532      FROM AnnotationData a
2533      WHERE a.unit = :unit
2534    </sql>
2535    <description>
2536      A Hibernate query that gets annotations
2537      that are using a given unit.
2538    </description>
2539  </query>
2540 
2541  <query id="GET_UNIT_WITH_SYMBOL_FOR_QUANTITY" type="HQL">
2542    <sql>
2543      SELECT unt
2544      FROM UnitData unt
2545      JOIN unt.symbols smb
2546      WHERE unt.quantity = :quantity
2547      AND smb.symbol = :symbol
2548    </sql>
2549    <description>
2550      A HQL query that finds the unit for a quantity
2551      with a given symbol.
2552    </description>
2553  </query>
2554 
2555  <query id="GET_UNIT_WITH_SYMBOL_FOR_UNIT" type="HQL">
2556    <sql>
2557      SELECT smb.unit
2558      FROM UnitSymbolData smb
2559      JOIN smb.quantity qnt
2560      JOIN qnt.units unt
2561      WHERE unt = :unit
2562      AND smb.symbol = :symbol
2563    </sql>
2564    <description>
2565      A HQL query that finds the unit with a given symbol
2566      that has the same quantity as another unit.
2567    </description>
2568  </query>
2569 
2570  <query id="SET_UNIT_TO_NULL_ON_PROPERTY_FILTERS" type="SQL">
2571    <sql>
2572      UPDATE [PropertyFilters]
2573      SET [unit_id] = null
2574      WHERE [unit_id] = :unit
2575    </sql>
2576    <description>
2577      A SQL query that sets the unit to null for all properties
2578      with a given unit (about to be deleted).
2579    </description>
2580  </query>
2581 
2582  <query id="RECALCULATE_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="SQL">
2583    <sql>
2584      UPDATE [{1}]
2585      SET [value] = [value] * :factor + :offset
2586      WHERE [id] IN
2587      (
2588        SELECT [value_id]
2589        FROM [Annotations]
2590        WHERE [annotationtype_id] = :annotationType
2591      )
2592    </sql>
2593    <description>
2594      A SQL query that recalculates the annotation values for
2595      a given annotation type.
2596    </description>
2597  </query>
2598 
2599  <query id="SET_UNIT_ON_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="HQL">
2600    <sql>
2601      UPDATE AnnotationData a
2602      SET a.unit = :unit
2603      WHERE a.annotationType = :annotationType
2604    </sql>
2605    <description>
2606      A HQL query that changes the unit for all annotations with a given
2607      annotation type.
2608    </description>
2609  </query>
2610 
2611  <query id="RECALCULATE_ANNOTATIONS_FOR_UNIT" type="SQL">
2612    <sql>
2613      UPDATE [{1}] SET [value] = [value] * :factor + :offset
2614      WHERE [id] IN
2615      (
2616        SELECT [a].[value_id]
2617        FROM [Annotations] [a]
2618        JOIN [AnnotationTypes] [at] ON [at].[id] = [a].[annotationtype_id]
2619        WHERE [at].[value_type] = :valueType
2620        AND
2621        (
2622          (:case = 1 AND [a].[unit_id] = :unit AND [at].[default_unit_id] &lt;&gt; :unit)
2623          OR
2624          (:case = 2 AND [a].[unit_id] &lt;&gt; :unit AND [at].[default_unit_id] = :unit)
2625        )
2626      )
2627    </sql>
2628    <description>
2629      A SQL query that recalculates the annotation values for
2630      when reference factor and/or offset changes. The query must handle
2631      two cases where either the annotation type's default unit
2632      or the annotation's unit matched. More info in doc for the
2633      Unit.changeReferenceFactorAndOffset() method.
2634    </description>
2635  </query>
2636
2637  <query id="UPDATE_ITEMLIST_SIZE" type="SQL">
2638    <sql>
2639      UPDATE [ItemLists]
2640      SET [size] = [size] + :delta
2641      WHERE [member_type] = :memberType
2642      AND [id] = ANY(
2643        SELECT [list_id]
2644        FROM [ItemListMembers]
2645        WHERE [item_id] = :itemId
2646      )
2647    </sql>
2648    <description>
2649      An update query that changes the size for all item lists
2650      where a given item is a member. Mainly used to decrease
2651      the size when an item is deleted.
2652    </description>
2653  </query>
2654 
2655  <query id="DELETE_ITEMLIST_MEMBER" type="SQL">
2656    <sql>
2657      DELETE FROM [ItemListMembers]
2658      WHERE [item_id] = :itemId
2659      AND [list_id] = ANY(
2660        SELECT [id]
2661        FROM [ItemLists]
2662        WHERE [member_type] = :memberType
2663      )
2664    </sql>
2665    <description>
2666      An update query that delete the list member entries
2667      for all lists where the given item is a member.
2668    </description>
2669  </query>
2670 
2671  <query id="GET_BIOMATERIAL_ON_PLATE" type="HQL">
2672    <sql>
2673      SELECT {1}
2674      FROM MeasuredBioMaterialData mbm
2675      JOIN mbm.bioWell bw
2676      WHERE bw.bioPlate = :bioPlate
2677    </sql>
2678    <description>
2679      A HQL query that gets MeasuredBioMaterial:s
2680      located on a given bioplate.
2681    </description>
2682  </query>
2683  <query id="FIND_USED_TYPES_IN_ANYTOANY" type="SQL">
2684    <sql>
2685      SELECT [a].[from_type] FROM [AnyToAny] [a]
2686      UNION
2687      SELECT [a].[to_type] FROM [AnyToAny] [a]
2688    </sql>
2689    <description>
2690      An SQL query that selects all used item types in any-to-any
2691      links. It must select both the the 'from' and 'to' item type.
2692    </description>
2693  </query>
2694  <query id="SELECT_STRAY_ANYTOANY" type="SQL">
2695    <sql>
2696      SELECT [a].[id]
2697      FROM [AnyToAny] [a]
2698      LEFT JOIN [{1}] [t]
2699        ON ([t].[id] = [a].[from_id] AND [a].[from_type] = :type)
2700        OR ([t].[id] = [a].[to_id] AND [a].[to_type] = :type)
2701      WHERE [t].[id] IS NULL
2702      AND ([a].[from_type] = :type OR [a].[to_type] = :type)
2703    </sql>
2704    <description>
2705      An SQL query that selects the ID of all any-to-any links were
2706      either the 'from' or 'to' item is missing. A single query
2707      is used to delete all items of a specific type (both
2708      'from' and 'to).
2709    </description>
2710  </query>
2711  <query id="DELETE_STRAY_ANYTOANY" type="HQL">
2712    <sql>
2713      DELETE FROM AnyToAnyData
2714      WHERE id IN (:ids)
2715    </sql>
2716    <description>
2717      A HQL query that deletes all any-to-any links with the
2718      id's given in the list.
2719    </description>
2720  </query>
2721  <query id="FIND_USED_TYPES_IN_CHANGEHISTORY" type="HQL">
2722    <sql>
2723      SELECT DISTINCT ch.itemType FROM ChangeHistoryDetailData ch
2724    </sql>
2725    <description>
2726      An HQL query that selects all used item types in the change
2727      history table.
2728    </description>
2729  </query>
2730  <query id="DELETE_STRAY_CHANGEHISTORY" type="HQL">
2731    <sql>
2732      DELETE FROM ChangeHistoryDetailData
2733      WHERE id IN (:ids)
2734    </sql>
2735    <description>
2736      A HQL query that deletes all change history entries with the
2737      id's given in the list.
2738    </description>
2739  </query>
2740  <query id="SELECT_STRAY_CHANGEHISTORY" type="SQL">
2741    <sql>
2742      SELECT [ch].[id]
2743      FROM [ChangeHistoryDetails] [ch]
2744      LEFT JOIN [{1}] [t]
2745        ON ([t].[id] = [ch].[item_id] AND [ch].[item_type] = :type)
2746      WHERE [t].[id] IS NULL
2747      AND [ch].[item_type] = :type
2748    </sql>
2749    <description>
2750      An SQL query that selects the ID of all change history entries
2751      that references a missing item of a specified type.
2752    </description>
2753  </query>
2754  <query id="DBLOG_GET_ANNOTATIONTYPE_INFO" type="HQL">
2755    <sql>
2756      SELECT at.name, at.valueType, at.disableLogOfValues
2757      FROM AnnotationTypeData at
2758      WHERE at.id = :annotationTypeId
2759    </sql>
2760    <description>
2761      An HQL query that loads the 'name', 'valueType' and 'disableLogOfValues' flag
2762      for an annotation type given the ID.
2763    </description>
2764  </query>
2765  <query id="DBLOG_GET_ANNOTATION_ITEMTYPE" type="HQL">
2766    <sql>
2767      SELECT a.itemType
2768      FROM AnnotationSetData a
2769      WHERE a.id = :annotationSetId
2770    </sql>
2771    <description>
2772      An HQL query that loads the item type value an annotation
2773      set with a given ID belongs to.
2774    </description>
2775  </query>
2776  <query id="DBLOG_GET_ITEMID_WITH_ANNOTATION" type="HQL">
2777    <sql>
2778      SELECT i.id
2779      FROM {1} i
2780      WHERE i.annotationSet = :annotationSetId
2781    </sql>
2782    <description>
2783      An HQL query that loads the ID of the item that
2784      is associated with a given annotation set.
2785    </description>
2786  </query>
2787  <query id="DBLOG_GET_NAME_FOR_ITEM" type="HQL">
2788    <sql>
2789      SELECT i.name
2790      FROM {1} i
2791      WHERE i.id = :id
2792    </sql>
2793    <description>
2794      An HQL query that loads the name of a an item.
2795    </description>
2796  </query>
2797  <query id="DBLOG_GET_FILESET_ITEMTYPE" type="HQL">
2798    <sql>
2799      SELECT fs.itemType
2800      FROM FileSetData fs
2801      WHERE fs.id = :fileSetId
2802    </sql>
2803    <description>
2804      An HQL query that loads the item type value a file set
2805      set with a given ID belongs to.
2806    </description>
2807  </query>
2808  <query id="DBLOG_GET_ITEMID_WITH_FILESET" type="HQL">
2809    <sql>
2810      SELECT i.id
2811      FROM {1} i
2812      WHERE i.fileSet = :fileSetId
2813    </sql>
2814    <description>
2815      An HQL query that loads the ID of the item that
2816      is associated with a given file set.
2817    </description>
2818  </query>
2819  <query id="DBLOG_INSERT_INTO_CHANGEHISTORYDETAILS" type="SQL">
2820    <sql>
2821      INSERT INTO [ChangeHistoryDetails]
2822        ([id], [version], [history_id], [change_type], [item_id], [item_type], [change_info], [old_value], [new_value])
2823      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, ?, ?)
2824    </sql>
2825    <description>
2826      SQL query for inserting rows into the ChangeHistoryDetails table.
2827      The primary key (id) must be auto-generated.
2828      Parameters: history_id, change_type, item_id, item_type, change_info, old_value, new_value
2829    </description>
2830  </query>
2831  <query id="GET_GROUPS_WITH_NONHIDDENMEMBERS" type="HQL">
2832    <sql>
2833      SELECT grp.id
2834      FROM GroupData grp
2835      WHERE grp.hiddenMembers = false
2836      AND grp.id IN (:groups)
2837    </sql>
2838    <description>
2839      A HQL query that selects the ID of the groups among a given set of
2840      groups that has 'hiddenMembers=false'
2841    </description>
2842  </query>
2843  <query id="GET_BIOPLATES_FOR_BIOPLATETYPE" type="HQL">
2844    <sql>
2845      SELECT {1}
2846      FROM BioPlateData bpl
2847      WHERE bpl.bioPlateType = :bioPlateType
2848    </sql>
2849    <description>
2850      A HQL query that gets the bioplates using a given type.
2851    </description>
2852  </query>
2853 
2854  <query id="GET_BIOPLATETYPE_WITH_NAME" type="HQL">
2855    <sql>
2856      SELECT bpt
2857      FROM BioPlateTypeData bpt
2858      WHERE bpt.name = :name
2859    </sql>
2860    <description>
2861      A HQL query that gets the bioplate type with a given name.
2862    </description>
2863  </query>
2864  <query id="GET_PROJECTS_FOR_PERMISSION_TEMPLATE" type="HQL">
2865    <sql>
2866      SELECT {1}
2867      FROM ProjectData prj
2868      WHERE prj.permissionTemplate = :permissionTemplate
2869    </sql>
2870    <description>
2871      A HQL query that gets the projects that are using a given permission
2872      template.
2873    </description>
2874  </query>
2875
2876  <query id="SET_GROUP_TO_NULL_ON_DISK_USAGE" type="HQL">
2877    <sql>
2878      UPDATE DiskUsageData du
2879        SET du.group = null
2880        WHERE du.group = :group
2881    </sql>
2882    <description>
2883      An HQL update-query that sets group to null on all
2884      diskusage that are associated with a given group.
2885    </description>
2886  </query>
2887
2888  <query id="CLEAR_ORIGINAL_BIOMATERIAL_ON_BIOWELLS" type="HQL">
2889    <sql>
2890      UPDATE BioWellData bw
2891      SET bw.originalBioMaterial = null
2892      WHERE bw.originalBioMaterial = :bioMaterial
2893    </sql>
2894    <description>
2895      An HQL update-query that for a given biomaterial clears the
2896      link on all biowells were it is set as the original biomaterial.
2897    </description>
2898  </query>
2899
2900  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATEEVENT" type="HQL">
2901    <sql>
2902      UPDATE BioMaterialEventData bme
2903      SET bme.bioPlateEventParticipant = null
2904      WHERE bme.bioPlateEventParticipant =ANY (
2905        SELECT bep FROM BioPlateEventParticipantData bep
2906        WHERE bep.event = :event
2907      )
2908    </sql>
2909    <description>
2910      An HQL update-query that clears the references to a given
2911      bioplate event on all biomaterial events that links to it
2912      (via the bioplate event participant table).
2913    </description>
2914  </query>
2915
2916  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATE" type="HQL">
2917    <sql>
2918      UPDATE BioMaterialEventData bme
2919      SET bme.bioPlateEventParticipant = null
2920      WHERE bme.bioPlateEventParticipant =ANY (
2921        SELECT bep FROM BioPlateEventParticipantData bep
2922        WHERE bep.bioPlate = :bioPlate
2923      )
2924    </sql>
2925    <description>
2926      An HQL update-query that clears the references to all bioplate
2927      event participants on biomaterial events for a given bioplate.
2928    </description>
2929  </query>
2930
2931  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_PARTICIPANT" type="HQL">
2932    <sql>
2933      UPDATE BioMaterialEventData bme
2934      SET bme.bioPlateEventParticipant = null
2935      WHERE bme.bioPlateEventParticipant = :participant
2936    </sql>
2937    <description>
2938      An HQL update-query that clears the references to a given bioplate
2939      event participant on all related biomaterial events.
2940    </description>
2941  </query>
2942
2943  <query id="GET_BIOPLATEEVENTS_FOR_BIOPLATEEVENTTYPE" type="HQL">
2944    <sql>
2945      SELECT {1}
2946      FROM BioPlateEventData bpe
2947      WHERE bpe.eventType = :eventType
2948    </sql>
2949    <description>
2950      An HQL update-query that gets the bioplate events that are
2951      of a given bioplate event type.
2952    </description>
2953  </query>
2954 
2955  <query id="GET_JAR_PATH_FROM_TABLE" type="SQL">
2956    <sql>
2957      SELECT [id], [jar_path] FROM [{1}] [t]
2958      where [t].[jar_file] IS NULL AND NOT [t].[jar_path] IS NULL
2959    </sql>
2960    <description>
2961      An SQL query that selects the ID and JAR_PATH column from a given table
2962      where the existing JAR_PATH has a value and the existing JAR_FILE is
2963      null.
2964    </description>
2965  </query>
2966
2967  <query id="SET_JAR_FILE_IN_TABLE" type="SQL">
2968    <sql>
2969      UPDATE [{1}] SET [jar_file] = :file WHERE id = :id
2970    </sql>
2971    <description>
2972      An SQL query that updates the JAR_FILE with the given value.
2973    </description>
2974  </query>
2975 
2976  <query id="DROP_COLUMN" type="SQL">
2977    <sql>
2978      ALTER TABLE [{1}] DROP COLUMN [{2}]
2979    </sql>
2980    <description>
2981      An SQL query that drops a column (2) from a table (1).
2982    </description>
2983  </query>
2984 
2985  <query id="DROP_NOT_NULL_CONSTRAINT" type="SQL">
2986    <sql>
2987      ALTER TABLE [{1}] ALTER COLUMN [{2}] DROP NOT NULL
2988    </sql>
2989    <description>
2990      An SQL query that drops a NOT NULL contraint from column (2) in a table (1).
2991    </description>
2992  </query>
2993
2994  <query id="DROP_TABLE" type="SQL">
2995    <sql>
2996      DROP TABLE [{1}]
2997    </sql>
2998    <description>
2999      An SQL query that drops a table (1).
3000    </description>
3001  </query>
3002
3003  <query id="CONVERT_LABELEDEXTRACTS_TO_EXTRACTS" type="SQL">
3004    <sql>
3005      UPDATE [BioMaterials]
3006      SET [discriminator] = 3
3007      WHERE [discriminator] = 4
3008    </sql>
3009    <description>
3010      An SQL query that convert labeled extract to extract.
3011    </description>
3012  </query>
3013
3014  <query id="GET_HYBRIDIZATIONS" type="SQL">
3015    <sql>
3016      SELECT
3017        [id], [version],
3018        [arrayslide_id], [num_arrays],
3019        [annotationset_id], [name],
3020        [description], [removed],
3021        [itemkey_id], [projectkey_id],
3022        [owner]
3023      FROM
3024        [Hybridizations]
3025    </sql>
3026    <description>
3027      An SQL query that load all BASE 2.17 hybridizations.
3028    </description>
3029  </query>
3030
3031  <query id="UPDATE_BIOASSAYID_FROM_HYBID" type="SQL">
3032    <sql>
3033      UPDATE [BioMaterialEvents]
3034      SET [physicalbioassay_id] = :bioAssayId
3035      WHERE [hybridization_id] = :hybId
3036    </sql>
3037    <description>
3038      An SQL query that sets the physicalbioassay_id
3039      for a given hybridization_id
3040    </description>
3041  </query>
3042
3043  <query id="GET_SCANS" type="SQL">
3044    <sql>
3045      SELECT
3046        [id], [version],
3047        [entry_date], [hybridization_id],
3048        [hardware_id], [protocol_id],
3049        [annotationset_id], [name],
3050        [description], [removed],
3051        [itemkey_id], [projectkey_id],
3052        [owner]
3053      FROM
3054        [Scans]
3055    </sql>
3056    <description>
3057      An SQL query that load all BASE 2.17 scans.
3058    </description>
3059  </query>
3060
3061  <query id="GET_IMAGES" type="SQL">
3062    <sql>
3063      SELECT
3064        [id], [version],
3065        [file_id]
3066      FROM
3067        [Images]
3068      WHERE [scan_id] = :scanId
3069    </sql>
3070    <description>
3071      An SQL query that load BASE 2.17 image files for a given scan.
3072    </description>
3073  </query>
3074
3075  <query id="GET_PROTOCOLTYPES" type="SQL">
3076    <sql>
3077      SELECT
3078        [id], [version],
3079        [entry_date], [name],
3080        [description], [removed],
3081        [system_id]
3082      FROM
3083        [ProtocolTypes]
3084    </sql>
3085    <description>
3086      An SQL query that load all BASE 2.17 protocol types.
3087    </description>
3088  </query>
3089
3090  <query id="GET_HARDWARETYPES" type="SQL">
3091    <sql>
3092      SELECT
3093        [id], [version],
3094        [entry_date], [name],
3095        [description], [removed],
3096        [system_id]
3097      FROM
3098        [HardwareTypes]
3099    </sql>
3100    <description>
3101      An SQL query that load all BASE 2.17 hardware types.
3102    </description>
3103  </query>
3104 
3105  <query id="GET_SOFTWARETYPES" type="SQL">
3106    <sql>
3107      SELECT
3108        [id], [version],
3109        [entry_date], [name],
3110        [description], [system_id]
3111      FROM
3112        [SoftwareTypes]
3113    </sql>
3114    <description>
3115      An SQL query that load all BASE 2.17 software types.
3116    </description>
3117  </query>
3118
3119  <query id="GET_FILETYPES" type="SQL">
3120    <sql>
3121      SELECT
3122        [id], [version],
3123        [entry_date], [name],
3124        [description], [system_id]
3125      FROM
3126        [FileTypes]
3127    </sql>
3128    <description>
3129      An SQL query that load all BASE 2.17 file types.
3130    </description>
3131  </query>
3132
3133  <query id="GET_RAWBIOASSAYS" type="SQL">
3134    <sql>
3135      SELECT
3136        [id], [scan_id],
3137        [array_num]
3138      FROM [RawBioAssays]
3139      WHERE NOT [scan_id] IS NULL
3140    </sql>
3141    <description>
3142      An SQL query that load scan and array num for all raw bioassays
3143      that has a scan parent.
3144    </description>
3145  </query>
3146
3147  <query id="FIND_EXTRACT_FOR_RAWBIOASSAY_POSITION" type="SQL">
3148    <sql>
3149      SELECT bm2.[biomaterial_id]
3150      FROM [DerivedBioAssays] dba
3151      INNER JOIN [ParentPhysicalBioAssays] pba ON pba.[derivedbioassay_id] = dba.[id]
3152      INNER JOIN [BioMaterialEvents] bme ON bme.[physicalbioassay_id] = pba.[physicalbioassay_id]
3153      INNER JOIN [BioMaterialEventSources2] bm2 ON bm2.[event_id]=bme.[id]
3154      WHERE bm2.[position] = :position AND dba.[id] = :derivedBioAssayId
3155    </sql>
3156    <description>
3157      An SQL query that tries to find the extract id given a
3158      derived bioassay and the bioassay position.
3159    </description>
3160  </query>
3161 
3162  <query id="UPDATE_RAWBIOASSAY" type="SQL">
3163    <sql>
3164      UPDATE [RawBioAssays]
3165      SET [bioassay_id] = :parentBioAssayId,
3166      [extract_id] = :extractId
3167      WHERE [id] = :rawBioAssayId
3168    </sql>
3169    <description>
3170      An SQL query that update the parent bioassay and extract
3171      for a given raw bioassay.
3172    </description>
3173  </query>
3174
3175
3176  <query id="COPY_BIOMATERIALEVENTSOURCES" type="SQL">
3177    <sql>
3178      INSERT INTO [BioMaterialEventSources2]
3179      (
3180        [id], [version],
3181        [biomaterial_id], [event_id],
3182        [used_quantity], [position]
3183      )
3184      SELECT
3185        {1}, 0,
3186        [biomaterial_id], [event_id],
3187        [used_quantity], [dummy]
3188      FROM [BioMaterialEventSources]
3189    </sql>
3190    <description>
3191      An SQL query that load copy BASE 2.17 biomaterial
3192      event sources to the new table.
3193    </description>
3194  </query>
3195
3196  <query id="COPY_SAMPLE_BIOSOURCE_PARENT_LINK" type="SQL">
3197    <sql>
3198      INSERT INTO [BioMaterialEventSources2]
3199      (
3200        [id], [version],
3201        [biomaterial_id], [event_id],
3202        [used_quantity], [position]
3203      )
3204      SELECT
3205        {1}, 0,
3206        bm.[parent_id], evt.[id],
3207        null, 1
3208      FROM [BioMaterials] bm
3209      INNER JOIN [BioMaterialEvents] evt ON bm.[id]=evt.[biomaterial_id] AND evt.[event_type]=1
3210      WHERE bm.[discriminator] = 2 AND NOT bm.[parent_id] IS NULL
3211    </sql>
3212    <description>
3213      An SQL query that copy Sample--BioSource parent
3214      links to the BioMaterialEventSources2 table.
3215    </description>
3216  </query>
3217
3218  <query id="NULLIFY_ALL_BIOMATERIAL_PARENTS" type="SQL">
3219    <sql>
3220      UPDATE [BioMaterials]
3221      SET [parent_type] = NULL, [parent_id] = NULL
3222    </sql>
3223    <description>
3224      An SQL query that nullify all biomaterial parent
3225      information.
3226    </description>
3227  </query>
3228
3229  <query id="GET_BIOMATERIAL_PARENT_INFO" type="SQL">
3230    <sql>
3231      SELECT bm.[id], bm.[discriminator], evt.[biomaterial_id]
3232      FROM [BioMaterialEventSources2] bm2
3233      INNER JOIN [BioMaterialEvents] evt ON bm2.[event_id]=evt.[id] AND evt.[event_type]=1
3234      INNER JOIN [BioMaterials] bm ON bm2.[biomaterial_id]=bm.[id]
3235      ORDER BY evt.[biomaterial_id]
3236    </sql>
3237    <description>
3238      An SQL query that get parent biomaterial information. We need
3239      parent_id, parent_type and child_id ordered by child_id
3240    </description>
3241  </query>
3242
3243
3244  <query id="SET_BIOMATERIAL_PARENT" type="SQL">
3245    <sql>
3246      UPDATE [BioMaterials]
3247      SET [parent_type] = :parentType, [parent_id] = :parentId
3248      WHERE [id] = :childId
3249    </sql>
3250    <description>
3251      An SQL query that set the biomaterial parent info for a single
3252      biomaterial.
3253    </description>
3254  </query>
3255
3256  <query id="SET_LABELEDEXTRACT_SUBTYPE" type="SQL">
3257    <sql>
3258      UPDATE [BioMaterials]
3259      SET [subtype_id]=:subtype
3260      WHERE [label_id] IS NOT NULL
3261    </sql>
3262    <description>
3263      An SQL query that sets the subtype of labeled extracts
3264    </description>
3265  </query>
3266
3267  <query id="SET_SUBTYPE_ON_ALL" type="SQL">
3268    <sql>
3269      UPDATE [{1}]
3270      SET [subtype_id]=:subtype
3271    </sql>
3272    <description>
3273      An SQL query that sets the subtype
3274      of all items in a table
3275    </description>
3276  </query>
3277
3278  <query id="UPDATE_ANNOTATIONSET_ITEM" type="SQL">
3279    <sql>
3280      UPDATE [AnnotationSets]
3281      SET [item_id] = :newId, [item_type] = {1}
3282      WHERE [id] = :id
3283    </sql>
3284    <description>
3285      An SQL query that update the item_type and item_id
3286      on annotation set.
3287    </description>
3288  </query>
3289
3290  <query id="UPDATE_ANYTOANY_FROMITEM" type="SQL">
3291    <sql>
3292      UPDATE [AnyToAny]
3293      SET [from_id] = :newId, [from_type] = {2}
3294      WHERE [from_id] = :oldId AND [from_type] = {1}
3295    </sql>
3296    <description>
3297      An SQL query that update the from_type and from_id
3298      on any-to-any.
3299    </description>
3300  </query>
3301 
3302  <query id="UPDATE_ANYTOANY_TOITEM" type="SQL">
3303    <sql>
3304      UPDATE [AnyToAny]
3305      SET [to_id] = :newId, [to_type] = {2}
3306      WHERE [to_id] = :oldId AND [to_type] = {1}
3307    </sql>
3308    <description>
3309      An SQL query that update the to_type and to_id
3310      on any-to-any.
3311    </description>
3312  </query>
3313 
3314  <query id="UPDATE_CHANGEHISTORYDETAILS_ITEM" type="SQL">
3315    <sql>
3316      UPDATE [ChangeHistoryDetails]
3317      SET [item_id] = :newId, [item_type] = {2}
3318      WHERE [item_id] = :oldId AND [item_type] = {1}
3319    </sql>
3320    <description>
3321      An SQL query that update the item_type and item_id
3322      on change history details.
3323    </description>
3324  </query>
3325 
3326  <query id="UPDATE_ITEMVALUES_ITEM" type="SQL">
3327    <sql>
3328      UPDATE [ItemValues]
3329      SET [data_class_id] = :newId, [data_class] = :newClass
3330      WHERE [data_class_id] = :oldId AND [data_class] = :oldClass
3331    </sql>
3332    <description>
3333      An SQL query that update the data_class_id and data_class
3334      on item values.
3335    </description>
3336  </query>
3337
3338  <query id="UPDATE_ITEMVALUES_CLASS" type="SQL">
3339    <sql>
3340      UPDATE [ItemValues]
3341      SET [data_class] = :newClass
3342      WHERE [data_class] = :oldClass
3343    </sql>
3344    <description>
3345      An SQL query that update the data_class
3346      on item values.
3347    </description>
3348  </query>
3349
3350  <query id="UPDATE_ITEMTYPE" type="SQL">
3351    <sql>
3352      UPDATE [{1}]
3353      SET [{2}] = {4}
3354      WHERE [{2}] = {3}
3355    </sql>
3356    <description>
3357      An SQL query that update the item-type column on
3358      a generic table.
3359    </description>
3360  </query>
3361
3362  <query id="UPDATE_SUBTYPEID_FROM_OLDTYPEID" type="SQL">
3363    <sql>
3364      UPDATE [{1}]
3365      SET [{2}] = :subtypeId
3366      WHERE [{3}] = :oldTypeId
3367    </sql>
3368    <description>
3369      An SQL query that update the subtype_id column on
3370      a generic table.
3371    </description>
3372  </query>
3373
3374
3375  <query id="DELETE_PLUGINGUICONTEXTS_FOR_ITEMTYPE" type="SQL">
3376    <sql>
3377      DELETE FROM [PluginDefinitionGuiContexts]
3378      WHERE [item_type] = :itemType
3379    </sql>
3380    <description>
3381      An SQL query that delete plug-in gui contexts for
3382      a given item type.
3383    </description>
3384  </query>
3385
3386  <query id="DELETE_PLUGINKEYS_FOR_ITEMTYPE" type="SQL">
3387    <sql>
3388      DELETE FROM [PluginKeys]
3389      WHERE [key_id] IN (
3390        SELECT k.[id]
3391        FROM [Keys] k
3392        WHERE k.[item_type] = :itemType
3393      )
3394    </sql>
3395    <description>
3396      An SQL query that delete plug-in keys referencing keys
3397      for a given item type.
3398    </description>
3399  </query>
3400
3401
3402  <query id="GET_SUBTYPABLE_ITEMS_FOR_SUBTYPE_OF_CLASS" type="HQL">
3403    <sql>
3404      SELECT {1}
3405      FROM {2} sub
3406      WHERE sub.itemSubtype = :subtype
3407    </sql>
3408    <description>
3409      Get all items that are subtyped with a subtype for a given class.
3410    </description>
3411  </query>
3412 
3413  <query id="GET_ITEMLISTS_FOR_SUBTYPE" type="HQL">
3414    <sql>
3415      SELECT {1}
3416      FROM ItemListData il
3417      WHERE il.itemSubtype = :subtype
3418    </sql>
3419    <description>
3420      A Hibernate query that gets ITEMLISTS for a given item subtype.
3421    </description>
3422  </query>
3423 
3424  <query id="GET_MIMETYPES_FOR_FILETYPE" type="HQL">
3425    <sql>
3426      SELECT {1}
3427      FROM MimeTypeData mt
3428      WHERE mt.fileType = :subtype
3429    </sql>
3430    <description>
3431      A Hibernate query that gets MIME types for a given item subtype.
3432    </description>
3433  </query>
3434 
3435  <query id="GET_DATAFILETYPES_FOR_FILETYPE" type="HQL">
3436    <sql>
3437      SELECT {1}
3438      FROM DataFileTypeData dft
3439      WHERE dft.genericType = :subtype
3440    </sql>
3441    <description>
3442      A Hibernate query that gets Data file types for a given item subtype.
3443    </description>
3444  </query>
3445 
3446  <query id="UPDATE_FILESETMEMBER_FILETYPE" type="HQL">
3447    <sql>
3448      UPDATE FileSetMemberData mbr
3449      SET mbr.dataFileType = :newType
3450      WHERE mbr.dataFileType = :oldType
3451    </sql>
3452    <description>
3453      A Hibernate query that update the data file type of all
3454      file set members with a given old data file type.
3455    </description>
3456  </query>
3457 
3458  <query id="DISABLE_ALL_PLUGINS" type="HQL">
3459    <sql>
3460      UPDATE PluginDefinitionData pl
3461      SET pl.disabled = true
3462    </sql>
3463    <description>
3464      A Hibernate query that disable all plug-ins.
3465    </description>
3466  </query>
3467 
3468  <query id="GET_PROJECT_DEFAULT_ANYTOANY" type="HQL">
3469    <sql>
3470      SELECT a FROM AnyToAnyData a
3471      WHERE a.fromType = 24 AND a.name LIKE 'default_%'
3472    </sql>
3473    <description>
3474      A Hibernate query that load all any-to-any links containing
3475      project default items.
3476    </description>
3477  </query>
3478 
3479  <query id="GET_MD5_PASSWORDS" type="SQL">
3480    <sql>
3481      SELECT [id], [md5password] FROM [Passwords]
3482    </sql>
3483    <description>
3484      An SQL query that load all md5 passwords.
3485    </description>
3486  </query>
3487
3488  <query id="SET_ENCRYPTED_PASSWORD" type="SQL">
3489    <sql>
3490      UPDATE [Passwords]
3491      SET [crypted_password] = :cryptedPassword
3492      WHERE [id] = :id
3493    </sql>
3494    <description>
3495      An SQL query that set the encrypted password for a given entry.
3496    </description>
3497  </query>
3498 
3499  <query id="GET_VIRTUALDBS_FOR_REPORTERCLONETEMPLATE" type="HQL">
3500    <sql>
3501      SELECT {1}
3502      FROM VirtualDbData vdb
3503      WHERE vdb.reporterCloneTemplate = :reporterCloneTemplate
3504    </sql>
3505    <description>
3506      A Hibernate query that get virtual databases
3507      that are using a given reporter clone template.
3508    </description>
3509  </query>
3510
3511  <query id="GET_ALL_ANNOTATIONTYPE_IDS_FOR_USER" type="SQL">
3512    <sql>
3513      SELECT [at].[id]
3514      FROM [AnnotationTypes] [at]
3515      WHERE [at].[owner] = :owner
3516      OR [at].[itemkey_id] IN (:itemKeys)
3517      OR [at].[projectkey_id] IN (:projectKeys)
3518    </sql>
3519    <description>
3520      An SQL query that load the ID of all the annotation types
3521      that the current user has access to. We need to set owner,
3522      item keys and project keys as parameters.
3523    </description>
3524  </query>
3525
3526  <query id="COPY_PARENT_PHYSICAL_BIOASSAYS" type="SQL">
3527    <sql>
3528      INSERT INTO [ParentPhysicalBioAssays] ([physicalbioassay_id], [derivedbioassay_id])
3529      SELECT [bioassay_id], [id] FROM [DerivedBioAssays]
3530    </sql>
3531    <description>
3532      An SQL query that copy the parent physical bioassays
3533      to the new (in BASE 3.2) ParentPhysicalBioAssays table
3534    </description>
3535  </query>
3536
3537
3538  <query id="COPY_PARENT_DERIVED_BIOASSAYS" type="SQL">
3539    <sql>
3540      INSERT INTO [ParentDerivedBioAssays] ([parentbioassay_id], [derivedbioassay_id])
3541      SELECT [parent_id], [id] FROM [DerivedBioAssays] WHERE NOT [parent_id] IS NULL
3542    </sql>
3543    <description>
3544      An SQL query that copy the parent derived bioassays
3545      to the new (in BASE 3.2) ParentDerivedBioAssays table
3546    </description>
3547  </query>
3548
3549  <query id="SET_ISROOT_ON_DERIVED_BIOASSAYS" type="SQL">
3550    <sql>
3551      UPDATE [DerivedBioAssays] SET [is_root] = ([parent_id] IS NULL)
3552    </sql>
3553    <description>
3554      An SQL query that set the is_root property on DerivedBioAssays table.
3555    </description>
3556  </query>
3557 
3558  <query id="GET_ITEMSUBTYPE_WITH_NAME_AND_ITEMTYPE" type="HQL">
3559    <sql>
3560      SELECT st FROM ItemSubtypeData st
3561      WHERE st.name = :name AND st.itemType = :itemType
3562    </sql>
3563    <description>
3564      A Hibernate query that load an item subtype given the name
3565      and main item type.
3566    </description>
3567  </query>
3568 
3569  <query id="SET_DISABLE_LOG_FOR_ANNOTATION_TYPES" type="HQL">
3570    <sql>
3571      UPDATE AnnotationTypeData at
3572      SET at.disableLogOfValues = false
3573      WHERE at.disableLogOfValues IS NULL
3574    </sql>
3575    <description>
3576      An HQL query that set the disableLogOfValues=false for all annotation types
3577      with a null value.
3578    </description>
3579  </query>
3580
3581  <query id="AB_LOAD_ANNOTATION_INFO" type="SQL">
3582    <sql>
3583      SELECT [annotationtype_id], [id], [version], [unit_id], [value_id], [last_update], [project_id], [override_id]
3584      FROM [Annotations]
3585      WHERE [annotationset_id] = :annotationSet AND [source] = 0 AND ([project_id] = :defaultProject OR [project_id] = :activeProject)
3586    </sql>
3587    <description>
3588      SQL query for loading current (primary) annotations for
3589      a given item.
3590      Used by the AnnotationBatcher as a SQL query via Hibernate.
3591    </description>
3592  </query>
3593
3594  <query id="AB_LOAD_ANNOTATION_VALUES" type="SQL">
3595    <sql>
3596      SELECT [id], [value]
3597      FROM [{1}]
3598      WHERE [id] IN (:listOfIds)
3599    </sql>
3600    <description>
3601      SQL query for loading current annotation values
3602      for a given list of annotation value IDs.
3603      Used by the AnnotationBatcher as a SQL query via Hibernate.
3604    </description>
3605  </query>
3606
3607  <query id="AB_INSERT_INTO_PARAMETERVALUES" type="SQL">
3608    <sql>
3609      INSERT INTO [ParameterValues] ([id], [discriminator], [version])
3610      VALUES (nextval('hibernate_sequence'), ?, 0)
3611    </sql>
3612    <description>
3613      SQL query for inserting rows into the ParameterValues table.
3614      The primary key (id) must be auto-generated.
3615      Parameters: discriminator
3616    </description>
3617  </query>
3618
3619  <query id="AB_INSERT_INTO_ANNOTATIONS" type="SQL">
3620    <sql>
3621      INSERT INTO [Annotations] ([id], [version], [annotationset_id], [annotationtype_id], [unit_id], [value_id], [last_update], [source], [project_id], [override_id])
3622      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, 0, ?, ?)
3623    </sql>
3624    <description>
3625      SQL query for inserting rows into the Annotations table.
3626      The primary key (id) must be auto-generated.
3627      Parameters: annotationset_id, annotationtype_id, unit_id, value_id, last_updated, project_id, override_id
3628    </description>
3629  </query>
3630
3631  <query id="AB_UPDATE_ANNOTATIONS" type="SQL">
3632    <sql>
3633      UPDATE [Annotations]
3634      SET [version] = ?, [unit_id] = ?, [last_update] = ?
3635      WHERE [id] = ? AND [version] = ?
3636    </sql>
3637    <description>
3638      SQL query for updating rows into the Annotations table.
3639      Parameters: version (new), unit_id, last_updated, id, version (old)
3640    </description>
3641  </query>
3642
3643  <query id="AB_INSERT_INTO_ANNOTATIONSETS" type="SQL">
3644    <sql>
3645      INSERT INTO [AnnotationSets] ([id], [version], [item_type], [item_id])
3646      VALUES (nextval('hibernate_sequence'), 0, {1}, ?)
3647    </sql>
3648    <description>
3649      SQL query for inserting rows into the AnnotationSets table.
3650      The primary key (id) must be auto-generated.
3651      Parameters: item_id
3652    </description>
3653  </query>
3654 
3655  <query id="AB_UPDATE_ITEMTABLE" type="SQL">
3656    <sql>
3657      UPDATE [{1}]
3658      SET [annotationset_id] = ?
3659      WHERE [id] = ?
3660    </sql>
3661    <description>
3662      SQL query for updating the annotationset_id column in any
3663      table it exists in.
3664      Parameters: annotationset_id, item_id
3665    </description>
3666  </query>
3667
3668  <query id="AB_NULLIFY_CLONED_ANNOTATIONS" type="SQL">
3669    <sql>
3670      UPDATE [Annotations]
3671      SET [inherited_id] = null
3672      WHERE [inherited_id] = ? and [source] = 2
3673    </sql>
3674    <description>
3675      SQL query for setting the 'inherited_id' column to null
3676      for cloned annotations that reference the annotation that
3677      is about to be deleted.
3678      Parameters: inherited_id
3679    </description>
3680  </query>
3681
3682  <query id="AB_DELETE_INHERITED_ANNOTATIONS" type="SQL">
3683    <sql>
3684      DELETE FROM [Annotations]
3685      WHERE [inherited_id] = ? and [source] = 1
3686    </sql>
3687    <description>
3688      SQL query for deleting inherited annotations that reference
3689      the annotation that is about to be deleted.
3690      Parameters: inherited_id
3691    </description>
3692  </query>
3693
3694  <query id="AB_DELETE_FROM_ANNOTATIONS" type="SQL">
3695    <sql>
3696      DELETE FROM [Annotations]
3697      WHERE [id] = ?
3698    </sql>
3699    <description>
3700      SQL query for deleting an annotation with a given id.
3701      Used by the AnnotationBatcher as a PreparedStatement.
3702      Parameters: id
3703    </description>
3704  </query>
3705
3706  <query id="AB_DELETE_FROM_PARAMETERVALUES" type="SQL">
3707    <sql>
3708      DELETE FROM [ParameterValues] WHERE [id] = ?
3709    </sql>
3710    <description>
3711      SQL query for deleting a parameter value with a given id.
3712      Used by the AnnotationBatcher as a PreparedStatement.
3713    </description>
3714  </query>
3715
3716  <query id="AB_DELETE_FROM_VALUES" type="SQL">
3717    <sql>
3718      DELETE FROM [{1}] WHERE [id] = ?
3719    </sql>
3720    <description>
3721      SQL query for deleting all actual annotation values with a given id.
3722      The {1} parameter is the table the value are stored in, eg. StringValues,
3723      IntegerValues, FloatValues, etc.
3724      Used by the AnnotationBatcher as a PreparedStatement.
3725    </description>
3726  </query>
3727 
3728  <query id="AB_INSERT_INTO_VALUES" type="SQL">
3729    <sql>
3730      INSERT INTO [{1}] ([id], [value]) VALUES (?, ?)
3731    </sql>
3732    <description>
3733      SQL query for inserting annotation values in their respective
3734      table (eg. StringValues, IntegerValues, FloatValues, etc.).
3735      Used by the AnnotationBatcher as a PreparedStatement.
3736    </description>
3737  </query>
3738 
3739  <query id="AB_UPDATE_OVERRIDE_ID" type="SQL">
3740    <sql>
3741      UPDATE [Annotations]
3742      SET [override_id] = ?
3743      WHERE [annotationset_id] = ?
3744      AND [annotationtype_id] = ?
3745      AND [source] = 0
3746      AND [project_id] &lt;&gt; 0
3747    </sql>
3748    <description>
3749      Updates the "override_id" column on project-specific annotations
3750      to point to a newly created default annotation of the same
3751      annotation type (PRIMARY annotations only).
3752      Used by the AnnotationBatcher as a PreparedStatement.
3753      Parameters: override_id, annotationset_id, annotationtype_id
3754    </description>
3755  </query>
3756 
3757 
3758  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF" type="SQL">
3759    <sql>
3760      UPDATE [Annotations]
3761      SET [override_id] = :annotationId
3762      WHERE [annotationset_id] = :annotationSetId
3763      AND [annotationtype_id] = :annotationTypeId
3764      AND [source] = 0
3765      AND [project_id] &lt;&gt; 0
3766    </sql>
3767    <description>
3768      Updates the "override_id" column on project-specific annotations
3769      to point to a newly created default annotation of the same
3770      annotation type (PRIMARY annotations only).
3771    </description>
3772  </query>
3773 
3774  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION" type="SQL">
3775    <sql>
3776      UPDATE [Annotations]
3777      SET [override_id] = COALESCE(
3778        (SELECT [id] FROM [Annotations]
3779        WHERE [annotationset_id] = :annotationSetId
3780        AND [annotationtype_id] = :annotationTypeId
3781        AND [source] = 0 AND [project_id] = 0)
3782        , 0)
3783      WHERE id = :annotationId
3784    </sql>
3785    <description>
3786      Updates the "override_id" column on a newly created project-specific
3787      (PRIMARY) annotation to point to the existing default annotation id
3788      or 0 if no default annotation exists.
3789    </description>
3790  </query>
3791 
3792  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF_INHERITED" type="HQL">
3793    <sql>
3794      UPDATE [Annotations]
3795      SET [override_id] = :annotationId
3796      WHERE [annotationset_id] = :annotationSetId
3797      AND [inherited_id] IN (
3798        SELECT [id] FROM [Annotations]
3799        WHERE [annotationset_id] = :parentSetId
3800        AND [override_id] = :parentId
3801      )
3802    </sql>
3803    <description>
3804      Updates the "override_id" column on project-specific annotations
3805      to point to a newly created default annotation (INHERITED and
3806      CLONED annotations). The subquery will find project-specific annotation
3807      on the parent annotation set that is overriding the inherited annotation.
3808    </description>
3809  </query>
3810 
3811  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION_INHERITED" type="SQL">
3812    <sql>
3813      UPDATE [Annotations]
3814      SET [override_id] = COALESCE(
3815        (SELECT [id] FROM [Annotations]
3816        WHERE [annotationset_id] = :annotationSetId
3817        AND [inherited_id] = :parentOverrideId
3818        AND [source] &lt;&gt; 0
3819        AND [project_id] = 0)
3820        , 0)
3821      WHERE id = :annotationId
3822    </sql>
3823    <description>
3824      Updates the "override_id" column on a newly created project-specific
3825      (CLONED or INHERITED) annotation to point to the existing default
3826      annotation id or 0 if no default annotation exists.
3827    </description>
3828  </query>
3829 
3830  <query id="PS_RESET_OVERRIDE_ON_PROJECT_ANNOTATIONS" type="HQL">
3831    <sql>
3832      UPDATE [Annotations] 
3833      SET [override_id] = 0
3834      WHERE [override_id] IN (:deletedAnnotations)
3835      OR [inherited_id] IN (
3836        SELECT [id] FROM [Annotations]
3837        WHERE [override_id] IN (:deletedPrimaryAnnotations)
3838      )
3839    </sql>
3840    <description>
3841      Reset the "override_id" column on project-specific annotations
3842      that points to a default annotation that has been removed.
3843    </description>
3844  </query>
3845   
3846  <query id="PS_LOAD_ANNOTATIONS_IN_NON_EXISTING_PROJECTS" type="SQL">
3847    <sql>
3848      SELECT a.[id], a.[annotationset_id], a.[value_id], a.[project_id], at.[value_type]
3849      FROM [Annotations] a
3850      INNER JOIN [AnnotationTypes] at ON at.[id] = a.[annotationtype_id]
3851      WHERE a.[project_id] &lt;&gt; 0 AND a.[project_id] NOT IN (SELECT [id] FROM [Projects])
3852    </sql>
3853    <description>
3854      SQL query for loading information about annotations
3855      that are project-specific annotations for a given
3856      list of projects.
3857      Used by the ProjectSpecificAnnotationsManager when
3858      a project has been deleted.
3859    </description>
3860  </query>
3861 
3862  <query id="PS_DELETE_FROM_PARAMETERVALUES" type="SQL">
3863    <sql>
3864      DELETE FROM [ParameterValues] WHERE [id] IN (:deletedValues)
3865    </sql>
3866    <description>
3867      SQL query for deleting mutliple parameter values with a given id's.
3868      Used by the ProjectSpecificAnnotationsManager.
3869    </description>
3870  </query>
3871
3872  <query id="PS_DELETE_FROM_VALUES" type="SQL">
3873    <sql>
3874      DELETE FROM [{1}] WHERE [id] IN (:deletedValues)
3875    </sql>
3876    <description>
3877      SQL query for deleting all actual annotation values with given id's.
3878      The {1} parameter is the table the value are stored in, eg. StringValues,
3879      IntegerValues, FloatValues, etc.
3880      Used by the ProjectSpecificAnnotationsManager.
3881    </description>
3882  </query>
3883 
3884  <query id="PS_DELETE_FROM_ANNOTATIONS_IN_PROJECTS" type="SQL">
3885    <sql>
3886      DELETE FROM [Annotations] WHERE [project_id] IN (:deletedProjects)
3887    </sql>
3888    <description>
3889      SQL query for deleting all annotation entries referenceing
3890      given list of projects.
3891      Used by the ProjectSpecificAnnotationsManager.
3892    </description>
3893  </query>
3894 
3895  <query id="PS_FIND_PROJECT_SPECIFIC_ANNOTATION" type="HQL">
3896    <sql>
3897      SELECT ad FROM AnnotationData ad
3898      WHERE ad.projectId = :activeProject
3899      AND ad.overrideId = :defaultAnnotation
3900      AND ad.annotationSet = :annotationSet
3901    </sql>
3902    <description>
3903      HQL query for locating a project-specific annotation
3904      overriding a specified default annotation.
3905      Used by the ProjectSpecificAnnotationsManager.
3906    </description>
3907  </query>
3908 
3909  <query id="COUNT_PROJECT_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
3910    <sql>
3911      SELECT count(*)
3912      FROM AnnotationData ad
3913      WHERE ad.annotationType = :annotationType
3914      AND ad.projectId &lt;&gt; 0
3915    </sql>
3916    <description>
3917      HQL query that counts the number of project-specific annotations
3918      for an annotation type.
3919    </description>
3920  </query>
3921
3922</predefined-queries>
Note: See TracBrowser for help on using the repository browser.