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

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

References #1910: Disable annotation inheritance for annotation types

Added AnnotationType.getDisableInheritance() which is a flag that if set will disable the inheritance. Schema version is updated and all existing annotation types are set to FALSE.

A permission check when calling AnnotationSet.inheritAnnotation has been implemented and setting the flag with AnnotationType.setDisableInheritance() will trigger a removal of existing inherited annotations.

This should complete the core part of the functionality but we also need some supporting functionality (mainly in the gui).

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