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

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

References #1148: Removing items from trashcan when circular references exists

Implemented code for breaking circular references in the following cases:

  • Any-to-any links. This is done by the trashcan code.
  • User->Home directory.
  • Biomaterial->Biomaterial.
  • Derived bioassay->Derived bioassay.


Groups can also have circular references to other groups but that is resolved by cascade delete in Hibernate.

Right now I can't think of any more places that can result in circular references.

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