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

Last change on this file since 6937 was 6937, checked in by Nicklas Nordborg, 7 years ago

References #1941: Store experimental factor values as part experiments

Removing the annotation on a parent item will nullify the link from cloned annotations instead of removing the clones.

Other changes are related to fixing various NullPointerExceptions and other problems resulting from having "inherited" annotations without a parent item.

But more work is needed on this since the cloned annotations now end up in a state that is almost impossible to manage via the gui. The "batch inherit annotations" can be used to remove or update cloned annotation.

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