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

Last change on this file since 3086 was 3086, checked in by Nicklas Nordborg, 17 years ago

Fixes #466: Remaining Quantity not display in extracts

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 62.0 KB
Line 
1<?xml version="1.0" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 3086 2007-01-29 13:45:24Z nicklas $
5
6  Copyright (C) Authors contributing to this file.
7
8  This file is part of BASE - BioArray Software Environment.
9  Available at http://base.thep.lu.se/
10
11  BASE is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License
13  as published by the Free Software Foundation; either version 2
14  of the License, or (at your option) any later version.
15
16  BASE is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  GNU General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330,
24  Boston, MA  02111-1307, USA.
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_USERKEYS_FOR_USER" type="HQL">
208    <sql>
209      SELECT uk
210      FROM UserKeys uk
211      WHERE uk.userId = :userId
212    </sql>
213    <description>
214      Load the UserKeys for the given user.
215    </description>
216  </query>
217
218  <query id="GET_GROUPKEYS_FOR_GROUPS" type="HQL">
219    <sql>
220      SELECT gk
221      FROM GroupKeys gk
222      WHERE gk.groupId IN (:groups)
223    </sql>
224    <description>
225      Load the GroupKeys for the given groups.
226    </description>
227  </query>
228
229  <query id="GET_ROLEKEYS_FOR_USER" type="HQL">
230    <sql>
231      SELECT rk
232      FROM RoleKeys rk, UserRoles ur
233      WHERE rk.roleId = ur.roleId AND ur.userId = :userId
234      ORDER BY rk.keyId
235    </sql>
236    <description>
237      Load the RoleKeys for the roles where the given user is a member.
238    </description>
239  </query>
240
241  <query id="GET_PROJECTKEYS_FOR_PROJECT" type="HQL">
242    <sql>
243      SELECT pk
244      FROM ProjectKeys pk
245      WHERE pk.projectId = :projectId
246      ORDER BY pk.keyId
247    </sql>
248    <description>
249      Load the ProjectKeys for the given project. Sort by
250      keyId for fast lookup in array (Keyring class).
251    </description>
252  </query>
253 
254  <query id="GET_PROJECTKEYIDS_FOR_PROJECT" type="HQL">
255    <sql>
256      SELECT pk.keyId
257      FROM ProjectKeys pk
258      WHERE pk.projectId = :projectId
259    </sql>
260    <description>
261      Load the ID of ProjectKeys for the given project.
262    </description>
263  </query>
264
265  <query id="GET_PERMISSION_FOR_USER_IN_PROJECT" type="HQL">
266    <sql>
267      SELECT up.permission
268      FROM UserProjects up
269      WHERE up.userId = :userId
270      AND up.projectId = :projectId
271    </sql>
272    <description>
273      Load the permission for the given user in the given project.
274    </description>
275  </query>
276
277  <query id="GET_PERMISSIONS_FOR_GROUPS_IN_PROJECT" type="HQL">
278    <sql>
279      SELECT gp.permission
280      FROM GroupProjects gp
281      WHERE gp.groupId IN (:groups)
282      AND gp.projectId = :projectId
283    </sql>
284    <description>
285      Load the permissions for the given groups in the given project.
286    </description>
287  </query>
288
289  <query id="GET_PROJECTKEY_IDS_FOR_COUNT" type="HQL">
290    <sql>
291      SELECT pk.keyId FROM ProjectKeys pk
292      GROUP BY pk.keyId
293      HAVING count(pk.projectId) = :numPermissions
294    </sql>
295    <description>
296      Load the ID of all project keys which have permissions for the
297      specified number of projects.
298    </description>
299  </query>
300
301  <query id="FIND_USED_PROJECTKEY_IDS" type="HQL">
302    <sql>
303      SELECT DISTINCT sd.projectKey.id
304      FROM net.sf.basedb.core.data.ShareableData sd
305      WHERE NOT sd.projectKey IS NULL
306    </sql>
307    <description>
308      Load the ID of all project keys which are used by at least one
309      shareable item.
310    </description>
311  </query>
312 
313  <query id="SELECT_UNUSED_PROJECTKEYS" type="HQL">
314    <sql>
315      SELECT pk FROM ProjectKeyData pk
316      WHERE pk.id NOT IN (:used)
317    </sql>
318    <description>
319      Load all unused project keys given a list of the ID:s of all used
320      keys.
321    </description>
322  </query>
323
324  <query id="GET_ITEMKEY_IDS_FOR_USERCOUNT" type="HQL">
325    <sql>
326      SELECT ik.id FROM ItemKeyData ik
327      LEFT JOIN ik.users u
328      GROUP BY ik.id
329      HAVING COUNT(u.index) = :numPermissions
330    </sql>
331    <description>
332      Load the ID of all item keys which have permissions for the
333      specified number of users.
334    </description>
335  </query>
336
337  <query id="GET_ITEMKEY_IDS_FOR_GROUPCOUNT" type="HQL">
338    <sql>
339      SELECT ik.id FROM ItemKeyData ik
340      LEFT JOIN ik.groups g
341      WHERE ik.id IN (:candidates)
342      GROUP BY ik.id
343      HAVING count(g.index) = :numPermissions
344    </sql>
345    <description>
346      Load the ID of all item keys which have permissions for the
347      specified number of groups and are among the list of candidates.
348    </description>
349  </query>
350 
351  <query id="FIND_USED_ITEMKEY_IDS" type="HQL">
352    <sql>
353      SELECT DISTINCT sd.itemKey.id
354      FROM net.sf.basedb.core.data.ShareableData sd
355      WHERE NOT sd.itemKey IS NULL
356    </sql>
357    <description>
358      Load the ID of all item keys which are used by at least one
359      shareable item.
360    </description>
361  </query>
362 
363  <query id="SELECT_UNUSED_ITEMKEYS" type="HQL">
364    <sql>
365      SELECT ik FROM ItemKeyData ik
366      WHERE ik.id NOT IN (:used)
367    </sql>
368    <description>
369      Load all unused item keys given a list of the ID:s of all used
370      keys.
371    </description>
372  </query>
373
374  <query id="GET_USERS_FOR_QUOTAGROUP" type="HQL">
375    <sql>
376      SELECT {1}
377      FROM UserData usr
378      WHERE usr.quotaGroup = :theGroup
379    </sql>
380    <description>
381      Get users having the specified group as
382      their quota group.
383    </description>
384  </query>
385 
386  <query id="GET_USERS_FOR_QUOTA" type="HQL">
387    <sql>
388      SELECT {1}
389      FROM UserData u
390      WHERE u.quota = :quota
391    </sql>
392    <description>
393      A Hibernate query that gets users
394      that has been assigned a given quota.
395    </description>
396  </query>
397 
398  <query id="GET_GROUPS_FOR_QUOTA" type="HQL">
399    <sql>
400      SELECT {1}
401      FROM GroupData g
402      WHERE g.quota = :quota
403    </sql>
404    <description>
405      A Hibernate query that gets groups
406      that has been assigned a given quota.
407    </description>
408  </query>
409
410  <query id="GET_SHAREABLE_ITEMS_FOR_ITEMKEY" type="HQL">
411    <sql>
412      SELECT s
413      FROM net.sf.basedb.core.data.ShareableData s
414      WHERE s.itemKey = :itemKey
415    </sql>
416    <description>
417      Get all items beeing shared to the specified item key.
418    </description>
419  </query>
420
421  <query id="GET_SHAREABLE_ITEMS_FOR_PROJECTKEY" type="HQL">
422    <sql>
423      SELECT s
424      FROM net.sf.basedb.core.data.ShareableData s
425      WHERE s.projectKey = :projectKey
426    </sql>
427    <description>
428      Get all items beeing shared to the specified project key.
429    </description>
430  </query>
431 
432  <query id="GET_SHARED_ITEMS" type="HQL">
433    <sql>
434      SELECT s
435      FROM net.sf.basedb.core.data.ShareableData s
436    </sql>
437    <description>
438      Get all shared items.
439    </description>
440  </query>
441
442  <query id="GET_OWNABLE_ITEMS_FOR_USER" type="HQL">
443    <sql>
444      SELECT o
445      FROM net.sf.basedb.core.data.OwnableData o
446      WHERE o.owner = :user
447    </sql>
448    <description>
449      Get all items that are owned by the specified user.
450    </description>
451  </query>
452 
453  <query id="GET_DISKCONSUMABLE_ITEMS_FOR_USER" type="HQL">
454    <sql>
455      SELECT o
456      FROM net.sf.basedb.core.data.DiskConsumableData o
457      WHERE o.owner = :user
458    </sql>
459    <description>
460      Get all diskconsumable items that are owned by the specified user.
461    </description>
462  </query>
463
464 
465  <query id="LOAD_USER_CLIENT_SETTINGS" type="HQL">
466    <sql>
467      SELECT s
468      FROM UserClientSettingData s
469      WHERE s.user = :user AND s.client = :client
470    </sql>
471    <description>
472      Load all settings for the specified user and client application.
473    </description>
474  </query>
475 
476  <query id="LOAD_USER_DEFAULT_SETTINGS" type="HQL">
477    <sql>
478      SELECT s
479      FROM UserDefaultSettingData s
480      WHERE s.user = :user
481    </sql>
482    <description>
483      Load all default settings for the specified user.
484    </description>
485  </query>
486
487  <query id="LOAD_CLIENT_DEFAULT_SETTINGS" type="HQL">
488    <sql>
489      SELECT s
490      FROM ClientDefaultSettingData s
491      WHERE s.client = :client
492    </sql>
493    <description>
494      Load all default settings for the specified client application.
495    </description>
496  </query>
497 
498  <query id="GET_MIME_TYPE_FROM_EXTENSION" type="HQL">
499    <sql>
500      SELECT s
501      FROM net.sf.basedb.core.data.MimeTypeData s
502      WHERE s.extension = :extension
503    </sql>
504    <description>
505      A Hibernate query that returns a MimeType given an extension.
506    </description>
507  </query>
508 
509  <query id="GET_TOTAL_DISKUSAGE_FOR_USER" type="HQL">
510    <sql>
511      SELECT sum(du.bytes)
512      FROM DiskUsageData du
513      WHERE du.user = :user
514      AND du.location = :location
515    </sql>
516    <description>
517      A Hibernate query that returns the total used quota
518      for the specified user at the specified location.
519    </description>
520  </query>
521 
522  <query id="GET_SPECIFIC_DISKUSAGE_FOR_USER" type="HQL">
523    <sql>
524      SELECT sum(du.bytes)
525      FROM DiskUsageData du
526      WHERE du.user = :user
527      AND du.location = :location
528      AND du.quotaType = :quotaType
529    </sql>
530    <description>
531      A Hibernate query that returns the used quota for the
532      specific quota type for the specified user at the
533      specified location.
534    </description>
535  </query>
536
537  <query id="GET_TOTAL_DISKUSAGE_FOR_GROUP" type="HQL">
538    <sql>
539      SELECT sum(du.bytes)
540      FROM DiskUsageData du
541      WHERE du.group = :group
542      AND du.location = :location
543    </sql>
544    <description>
545      A Hibernate query that returns the total used quota
546      for the specified group at the specified location.
547    </description>
548  </query>
549
550  <query id="GET_SPECIFIC_DISKUSAGE_FOR_GROUP" type="HQL">
551    <sql>
552      SELECT sum(du.bytes)
553      FROM DiskUsageData du
554      WHERE du.group = :group
555      AND du.location = :location
556      AND du.quotaType = :quotaType
557    </sql>
558    <description>
559      A Hibernate query that returns the used quota for the
560      specific quota type for the specified group at the
561      specified location.
562    </description>
563  </query>
564
565  <query id="GET_TOTAL_DISKUSAGE_SUMMARY" type="HQL">
566    <sql>
567      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
568      FROM DiskUsageData du
569      GROUP BY du.location, du.quotaType.systemId
570    </sql>
571    <description>
572      A Hibernate query that returns the total disk usage grouped
573      by location and quota type system id.
574    </description>
575  </query>
576
577  <query id="GET_DISKUSAGE_SUMMARY_FOR_USER" type="HQL">
578    <sql>
579      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
580      FROM DiskUsageData du
581      WHERE du.user = :user
582      GROUP BY du.location, du.quotaType.systemId
583    </sql>
584    <description>
585      A Hibernate query that returns the disk usage for a user grouped
586      by location and quota type system id.
587    </description>
588  </query>
589
590  <query id="GET_DISKUSAGE_SUMMARY_FOR_GROUP" type="HQL">
591    <sql>
592      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
593      FROM DiskUsageData du
594      WHERE du.group = :group
595      GROUP BY du.location, du.quotaType.systemId
596    </sql>
597    <description>
598      A Hibernate query that returns the disk usage for a group grouped
599      by location and quota type system id.
600    </description>
601  </query>
602 
603  <query id="GET_FILES_IN_DIRECTORY" type="HQL">
604    <sql>
605      SELECT {1}
606      FROM FileData f
607      WHERE f.directory = :directory
608    </sql>
609    <description>
610      A Hibernate query that gets the files
611      in a given directory.
612    </description>
613  </query>
614 
615  <query id="GET_FILES_FOR_FILETYPE" type="HQL">
616    <sql>
617      SELECT {1}
618      FROM FileData f
619      WHERE f.fileType = :filetype
620    </sql>
621    <description>
622      A Hibernate query that gets the files
623      with a given filetype.
624    </description>
625  </query>
626
627  <query id="GET_SUBDIRECTORIES_IN_DIRECTORY" type="HQL">
628    <sql>
629      SELECT {1}
630      FROM DirectoryData d
631      WHERE d.parent = :directory
632    </sql>
633    <description>
634      A Hibernate query that gets the subdirectories
635      in a given directory.
636    </description>
637  </query>
638 
639  <query id="GET_HOME_DIRECTORIES" type="HQL">
640    <sql>
641      SELECT {1}
642      FROM UserData usr
643      WHERE usr.homeDirectory = :directory
644    </sql>
645    <description>
646      A Hibernate query that gets the users having
647      the specified directory as home directory.
648    </description>
649  </query>
650 
651  <query id="GET_EXPERIMENT_DIRECTORIES" type="HQL">
652    <sql>
653      SELECT {1}
654      FROM ExperimentData xpr
655      WHERE xpr.directory = :directory
656    </sql>
657    <description>
658      A Hibernate query that gets the experiments having
659      the specified directory as the plugin directory.
660    </description>
661  </query>
662
663  <query id="GET_SUBDIRECTORIES" type="HQL">
664    <sql>
665      SELECT dir
666      FROM DirectoryData dir
667      WHERE dir.parent = :parent
668    </sql>
669    <description>
670      A Hibernate query that returns all subdirectories in a directory.
671    </description>
672  </query>
673 
674  <query id="GET_SUBDIRECTORY_WITH_NAME" type="HQL">
675    <sql>
676      SELECT dir
677      FROM DirectoryData dir
678      WHERE dir.name = :name
679      AND dir.parent = :parent
680    </sql>
681    <description>
682      A Hibernate query that returns the a subdirectory with the
683      specified name in a given directory.
684    </description>
685  </query>
686
687  <query id="GET_FILE_TYPE_WITH_NAME" type="HQL">
688    <sql>
689      SELECT ft
690      FROM FileTypeData ft
691      WHERE ft.name = :name
692    </sql>
693    <description>
694      A Hibernate query that returns the file type with the specified
695      name.
696    </description>
697  </query>
698 
699  <query id="GET_QUOTA_TYPE_WITH_NAME" type="HQL">
700    <sql>
701      SELECT qt
702      FROM QuotaTypeData qt
703      WHERE qt.name = :name
704    </sql>
705    <description>
706      A Hibernate query that returns the quota type with the specified
707      name.
708    </description>
709  </query>
710 
711  <query id="GET_QUOTA_WITH_NAME" type="HQL">
712    <sql>
713      SELECT q
714      FROM QuotaData q
715      WHERE q.name = :name
716    </sql>
717    <description>
718      A Hibernate query that returns the quota with the specified
719      name.
720    </description>
721  </query>
722 
723  <query id="GET_GROUP_WITH_NAME" type="HQL">
724    <sql>
725      SELECT grp
726      FROM GroupData grp
727      WHERE grp.name = :name
728    </sql>
729    <description>
730      A Hibernate query that returns the group with the specified
731      name.
732    </description>
733  </query>
734 
735  <query id="GET_ROLE_WITH_NAME" type="HQL">
736    <sql>
737      SELECT rle
738      FROM RoleData rle
739      WHERE rle.name = :name
740    </sql>
741    <description>
742      A Hibernate query that returns the role with the specified
743      name.
744    </description>
745  </query>
746 
747  <query id="GET_PROTOCOL_TYPE_WITH_NAME" type="HQL">
748    <sql>
749      SELECT pt
750      FROM ProtocolTypeData pt
751      WHERE pt.name = :name
752    </sql>
753    <description>
754      A Hibernate query that returns the protocol type with the specified
755      name.
756    </description>
757  </query>
758 
759  <query id="GET_SOFTWARE_TYPE_WITH_NAME" type="HQL">
760    <sql>
761      SELECT st
762      FROM SoftwareTypeData st
763      WHERE st.name = :name
764    </sql>
765    <description>
766      A Hibernate query that returns the software type with the specified
767      name.
768    </description>
769  </query>
770 
771  <query id="GET_SOFTWARE_WITH_NAME" type="HQL">
772    <sql>
773      SELECT sw
774      FROM SoftwareData sw
775      WHERE sw.name = :name
776    </sql>
777    <description>
778      A Hibernate query that returns the software with the specified
779      name.
780    </description>
781  </query>
782 
783  <query id="GET_HARDWARE_TYPE_WITH_NAME" type="HQL">
784    <sql>
785      SELECT ht
786      FROM HardwareTypeData ht
787      WHERE ht.name = :name
788    </sql>
789    <description>
790      A Hibernate query that returns the hardware type with the specified
791      name.
792    </description>
793  </query>
794 
795  <query id="GET_HARDWARE_WITH_NAME" type="HQL">
796    <sql>
797      SELECT hw
798      FROM HardwareData hw
799      WHERE hw.name = :name
800    </sql>
801    <description>
802      A Hibernate query that returns the hardware with the specified
803      name.
804    </description>
805  </query>
806 
807  <query id="GET_PLATE_GEOMETRY_WITH_NAME" type="HQL">
808    <sql>
809      SELECT pg
810      FROM PlateGeometryData pg
811      WHERE pg.name = :name
812    </sql>
813    <description>
814      A Hibernate query that returns the plate geometry with the specified
815      name.
816    </description>
817  </query>
818
819  <query id="GET_PLATE_MAPPING_WITH_NAME" type="HQL">
820    <sql>
821      SELECT pm
822      FROM PlateMappingData pm
823      WHERE pm.name = :name
824    </sql>
825    <description>
826      A Hibernate query that returns the plate mapping with the specified
827      name.
828    </description>
829  </query>
830 
831  <query id="GET_LABEL_WITH_NAME" type="HQL">
832    <sql>
833      SELECT lbl
834      FROM LabelData lbl
835      WHERE lbl.name = :name
836    </sql>
837    <description>
838      A Hibernate query that returns the label with the specified
839      name.
840    </description>
841  </query>
842 
843  <query id="GET_ANNOTATION_TYPE_WITH_NAME" type="HQL">
844    <sql>
845      SELECT at
846      FROM AnnotationTypeData at
847      WHERE at.name = :name
848    </sql>
849    <description>
850      A Hibernate query that returns the annotation type with the specified
851      name.
852    </description>
853  </query>
854 
855  <query id="GET_NEWS_WITH_NAME" type="HQL">
856    <sql>
857      SELECT nws
858      FROM NewsData nws
859      WHERE nws.name = :name
860    </sql>
861    <description>
862      A Hibernate query that returns the news with the specified
863      name.
864    </description>
865  </query>
866
867  <query id="GET_FILE_IN_DIRECTORY" type="HQL">
868    <sql>
869      SELECT f
870      FROM FileData f
871      WHERE f.directory = :directory
872      AND f.name = :name
873    </sql>
874    <description>
875      A Hibernate query that returns the file with the specified
876      name in a given directory.
877    </description>
878  </query>
879
880  <query id="GET_PROTOCOLS_FOR_PROTOCOLTYPE" type="HQL">
881    <sql>
882      SELECT {1}
883      FROM ProtocolData p
884      WHERE p.protocolType = :protocolType
885    </sql>
886    <description>
887      Get the protocols the uses a protocol type.
888    </description>
889  </query>
890
891  <query id="GET_PLATEEVENTTYPES_FOR_PROTOCOLTYPE" type="HQL">
892    <sql>
893      SELECT {1}
894      FROM PlateEventTypeData pet
895      WHERE pet.protocolType = :protocolType
896    </sql>
897    <description>
898      Get the plate events types that uses a protocol type.
899    </description>
900  </query>
901 
902  <query id="GET_BIOMATERIALEVENTS_FOR_PROTOCOL" type="HQL">
903    <sql>
904      SELECT {1}
905      FROM BioMaterialEventData bme
906      WHERE bme.protocol = :protocol
907    </sql>
908    <description>
909      A Hibernate query that gets biomaterial
910      events using a protocol.
911    </description>
912  </query>
913
914  <query id="GET_PLATEEVENTS_FOR_PROTOCOL" type="HQL">
915    <sql>
916      SELECT {1}
917      FROM PlateEventData pe
918      WHERE pe.protocol = :protocol
919    </sql>
920    <description>
921      A Hibernate query thatgets plate events
922      using a protocol.
923    </description>
924  </query>
925
926  <query id="GET_ARRAYBATCHES_FOR_PROTOCOL" type="HQL">
927    <sql>
928      SELECT {1}
929      FROM ArrayBatchData ab
930      WHERE ab.protocol = :protocol
931    </sql>
932    <description>
933      A Hibernate query that gets array batches
934      using a protocol.
935    </description>
936  </query>
937
938  <query id="GET_SCANS_FOR_PROTOCOL" type="HQL">
939    <sql>
940      SELECT {1}
941      FROM ScanData sc
942      WHERE sc.protocol = :protocol
943    </sql>
944    <description>
945      A Hibernate query that gets scans
946      using a protocol.
947    </description>
948  </query>
949
950  <query id="GET_RAWBIOASSAYS_FOR_PROTOCOL" type="HQL">
951    <sql>
952      SELECT {1}
953      FROM RawBioAssayData rba
954      WHERE rba.protocol = :protocol
955    </sql>
956    <description>
957      A Hibernate query that gets raw bioassays
958      using a protocol.
959    </description>
960  </query>
961
962  <query id="FIND_USED_FILES" type="HQL">
963    <sql>
964      SELECT fad
965      FROM net.sf.basedb.core.data.FileAttachableData fad
966      WHERE fad.file = :file
967    </sql>
968    <description>
969      Load the files that is used by any FileAttachableData.
970    </description>
971  </query>
972
973  <query id="GET_SPOTIMAGES_FOR_FILE" type="HQL">
974    <sql>
975      SELECT {1}
976      FROM SpotImagesData spi
977      WHERE spi.redImageFile = :file
978      OR spi.greenImageFile = :file
979      OR spi.blueImageFile = :file
980      OR spi.spotImagesFile = :file
981    </sql>
982    <description>
983      A Hibernate query that gets spot images where a given
984      file is used as one of the color components or holds the generated spot images.
985    </description>
986  </query>
987 
988  <query id="GET_HARDWARE_FOR_TYPE" type="HQL">
989    <sql>
990      SELECT {1}
991      FROM HardwareData hw
992      WHERE hw.hardwareType = :hardwaretype
993    </sql>
994    <description>
995      A Hibernate query that gets hardware items
996      of the given hardware type.
997    </description>
998  </query>
999
1000  <query id="GET_SCANS_FOR_SCANNER" type="HQL">
1001    <sql>
1002      SELECT {1}
1003      FROM ScanData scn
1004      WHERE scn.scanner = :scanner
1005    </sql>
1006    <description>
1007      A Hibernate query that gets scans which
1008      uses a given scanner (hardware).
1009    </description>
1010  </query>
1011 
1012  <query id="GET_ARRAYBATCHES_FOR_PRINTROBOT" type="HQL">
1013    <sql>
1014      SELECT {1}
1015      FROM ArrayBatchData ab
1016      WHERE ab.printRobot = :printrobot
1017    </sql>
1018    <description>
1019      A Hibernate query that gets array batches which
1020      uses a given print robot (hardware).
1021    </description>
1022  </query>
1023 
1024  <query id="GET_BIOMATERIALEVENTS_FOR_HARDWARE" type="HQL">
1025    <sql>
1026      SELECT {1}
1027      FROM BioMaterialEventData bme
1028      WHERE bme.hardware = :hardware
1029    </sql>
1030    <description>
1031      A Hibernate query that gets biomaterial events which
1032      uses a given hardware.
1033    </description>
1034  </query>
1035 
1036  <query id="GET_PLATEEVENTS_FOR_HARDWARE" type="HQL">
1037    <sql>
1038      SELECT {1}
1039      FROM PlateEventData ple
1040      WHERE ple.hardware = :hardware
1041    </sql>
1042    <description>
1043      A Hibernate query that gets plates events which
1044      uses a given hardware.
1045    </description>
1046  </query>
1047
1048  <query id="GET_REPORTERS_FOR_REPORTERTYPE" type="HQL">
1049    <sql>
1050      SELECT {1}
1051      FROM ReporterData rpt
1052      WHERE rpt.reporterType = :reporterType
1053    </sql>
1054    <description>
1055      A Hibernate query that gets reporter items
1056      of the given reporter type.
1057    </description>
1058  </query>
1059
1060  <query id="GET_REPORTER_FOR_EXTERNAL_ID" type="HQL">
1061    <sql>
1062      SELECT rpt
1063      FROM ReporterData rpt
1064      WHERE rpt.externalId = :externalId
1065    </sql>
1066    <description>
1067      A Hibernate query that finds the reporter with a given external id.
1068    </description>
1069  </query>
1070 
1071  <query id="GET_SOFTWARE_FOR_SOFTWARETYPE" type="HQL">
1072    <sql>
1073      SELECT {1}
1074      FROM SoftwareData sw
1075      WHERE sw.softwareType = :softwaretype
1076    </sql>
1077    <description>
1078      A Hibernate query that gets software items
1079      of the given software type.
1080    </description>
1081  </query>
1082
1083  <query id="GET_RAWBIOASSAYS_FOR_SOFTWARE" type="HQL">
1084    <sql>
1085      SELECT {1}
1086      FROM RawBioAssayData rba
1087      WHERE rba.software = :software
1088    </sql>
1089    <description>
1090      A Hibernate query that gets the raw bioassays
1091      produced from a given software.
1092    </description>
1093  </query>
1094
1095  <query id="GET_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
1096    <sql>
1097      SELECT {1}
1098      FROM AnnotationData a
1099      WHERE a.annotationType = :annotationType
1100    </sql>
1101    <description>
1102      A Hibernate query that gets annotations
1103      of the given annotation type.
1104    </description>
1105  </query>
1106 
1107  <query id="GET_EXPERIMENTS_FOR_ANNOTATIONTYPE" type="HQL">
1108    <sql>
1109      SELECT {1}
1110      FROM ExperimentData exp
1111      JOIN exp.experimentalFactors ef
1112      WHERE ef = :annotationType
1113    </sql>
1114    <description>
1115      A Hibernate query that gets experiments
1116      where the given annotation type is used as an experimental factor.
1117    </description>
1118  </query>
1119 
1120  <query id="GET_PROTOCOLS_FOR_ANNOTATIONTYPE" type="HQL">
1121    <sql>
1122      SELECT {1}
1123      FROM ProtocolData prt
1124      JOIN prt.parameters pp
1125      WHERE pp = :annotationType
1126    </sql>
1127    <description>
1128      A Hibernate query that gets protocols
1129      where the given annotation type is used as a protocol parameter.
1130    </description>
1131  </query>
1132
1133  <query id="GET_SAMPLES_FOR_BIOSOURCE" type="HQL">
1134    <sql>
1135      SELECT {1}
1136      FROM SampleData s
1137      WHERE s.parent = :biosource
1138    </sql>
1139    <description>
1140      A Hibernate query that gets samples
1141      created from a given biosource.
1142    </description>
1143  </query>
1144
1145  <query id="GET_EXTRACTS_FOR_SAMPLE" type="HQL">
1146    <sql>
1147      SELECT {1}
1148      FROM ExtractData e
1149      WHERE e.parent = :sample
1150    </sql>
1151    <description>
1152      A Hibernate query that gets extracts
1153      created from a given sample.
1154    </description>
1155  </query>
1156 
1157  <query id="GET_LABELED_EXTRACTS_FOR_EXTRACT" type="HQL">
1158    <sql>
1159      SELECT {1}
1160      FROM LabeledExtractData le
1161      WHERE le.parent = :extract
1162    </sql>
1163    <description>
1164      A Hibernate query that gets labeled extracts
1165      created from a given extract.
1166    </description>
1167  </query>
1168
1169  <query id="GET_LABELED_EXTRACTS_FOR_LABEL" type="HQL">
1170    <sql>
1171      SELECT {1}
1172      FROM LabeledExtractData le
1173      WHERE le.label = :label
1174    </sql>
1175    <description>
1176      A Hibernate query that gets labeled extracts
1177      with a given label.
1178    </description>
1179  </query>
1180
1181  <query id="GET_SOURCEEVENTS_FOR_BIOMATERIAL" type="HQL">
1182    <sql>
1183      SELECT {1}
1184      FROM BioMaterialEventData bme
1185      JOIN bme.sources src
1186      WHERE index(src) = :bioMaterial
1187    </sql>
1188    <description>
1189      A Hibernate query that gets the events where a given
1190      biomaterial has been part of as a source biomaterial, ie. the number
1191      of pooled biomaterials that have been created from it.
1192    </description>
1193  </query>
1194
1195  <query id="GET_CREATION_EVENT_FOR_BIOMATERIAL" type="HQL">
1196    <sql>
1197      SELECT evt
1198      FROM BioMaterialEventData evt
1199      WHERE evt.bioMaterial = :bioMaterial
1200      AND evt.eventType = 1
1201    </sql>
1202    <description>
1203      A Hibernate query that returns the creation event for
1204      a biomaterial.
1205    </description>
1206  </query>
1207 
1208  <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL">
1209    <sql>
1210      SELECT count(*)
1211      FROM MessageData msg
1212      WHERE msg.to = :user AND msg.read = false AND msg.removed = false
1213    </sql>
1214    <description>
1215      A Hibernate query that counts the number of
1216      unread messages for a given user
1217    </description>
1218  </query>
1219 
1220  <query id="GET_PLATETYPES_FOR_PLATEGEOMETRY" type="HQL">
1221    <sql>
1222      SELECT {1}
1223      FROM PlateTypeData pt
1224      WHERE pt.plateGeometry = :plateGeometry
1225    </sql>
1226    <description>
1227      A Hibernate query that gets the
1228      plate types using a given plate geometry
1229    </description>
1230  </query>
1231 
1232  <query id="GET_PLATEMAPPINGS_FOR_PLATEGEOMETRY" type="HQL">
1233    <sql>
1234      SELECT {1}
1235      FROM PlateMappingData pm
1236      WHERE pm.sourceGeometry = :plateGeometry
1237      OR pm.destinationGeometry = :plateGeometry
1238    </sql>
1239    <description>
1240      A Hibernate query that gets the
1241      plate mappings using a given plate geometry as source or destination
1242    </description>
1243  </query>
1244
1245  <query id="GET_PLATES_FOR_PLATETYPE" type="HQL">
1246    <sql>
1247      SELECT {1}
1248      FROM PlateData p
1249      WHERE p.plateType = :plateType
1250    </sql>
1251    <description>
1252      A Hibernate query that gets
1253      plates of a specific plate type.
1254    </description>
1255  </query>
1256
1257  <query id="GET_PLATEEVENTS_FOR_PLATEEVENTTYPE" type="HQL">
1258    <sql>
1259      SELECT {1}
1260      FROM PlateEventData pe
1261      WHERE pe.plateEventType = :plateEventType
1262    </sql>
1263    <description>
1264      A Hibernate query that gets
1265      plate events of the given plate event type.
1266    </description>
1267  </query>
1268
1269  <query id="GET_CHILDPLATES_FOR_PLATE" type="HQL">
1270    <sql>
1271      SELECT {1}
1272      FROM PlateData p
1273      JOIN p.parents pp
1274      WHERE pp = :plate
1275    </sql>
1276    <description>
1277      A Hibernate query that gets the
1278      child plates for a given plate.
1279    </description>
1280  </query>
1281
1282  <query id="GET_ARRAYDESIGNS_FOR_PLATE" type="HQL">
1283    <sql>
1284      SELECT {1}
1285      FROM ArrayDesignData ad
1286      JOIN ad.plates p
1287      WHERE p = :plate
1288    </sql>
1289    <description>
1290      A Hibernate query that gets the
1291      array designs that has used a given plate.
1292    </description>
1293  </query>
1294
1295  <query id="GET_PLATES_FOR_PLATEMAPPING" type="HQL">
1296    <sql>
1297      SELECT {1}
1298      FROM PlateData p
1299      WHERE p.plateMapping = :plateMapping
1300    </sql>
1301    <description>
1302      A Hibernate query that gets the
1303      plates that has been created from a given plate mapping.
1304    </description>
1305  </query>
1306 
1307  <query id="GET_FEATURES_FOR_WELL" type="HQL">
1308    <sql>
1309      SELECT {1}
1310      FROM FeatureData f
1311      WHERE f.well = :well
1312    </sql>
1313    <description>
1314      A Hibernate query that gets the
1315      features using a given well.
1316    </description>
1317  </query>
1318
1319  <query id="COUNT_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1320    <sql>
1321      SELECT count(*)
1322      FROM FeatureData f
1323      WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
1324    </sql>
1325    <description>
1326      A Hibernate query that counts the number of
1327      features on a given array design
1328    </description>
1329  </query>
1330
1331
1332  <query id="GET_CHILDWELLS_FOR_WELL" type="HQL">
1333    <sql>
1334      SELECT {1}
1335      FROM Well w
1336      WHERE w.parent = :well
1337    </sql>
1338    <description>
1339      A Hibernate query that gets the
1340      child wells of a given well.
1341    </description>
1342  </query>
1343
1344  <query id="GET_PLUGINCONFIGURATIONS_FOR_PLUGINDEFINITION" type="HQL">
1345    <sql>
1346      SELECT {1}
1347      FROM PluginConfigurationData pc
1348      WHERE pc.pluginDefinition = :pluginDefinition
1349    </sql>
1350    <description>
1351      A Hibernate query that gets plugin configurations
1352      using a plugin definition.
1353    </description>
1354  </query>
1355 
1356  <query id="GET_JOBS_FOR_PLUGINCONFIGURATION" type="HQL">
1357    <sql>
1358      SELECT {1}
1359      FROM JobData j
1360      WHERE j.pluginConfiguration = :pluginConfiguration
1361    </sql>
1362    <description>
1363      A Hibernate query that gets the jobs
1364      using a specific plugin configuration.
1365    </description>
1366  </query>
1367
1368  <query id="FIND_JOBS_IN_QUEUE" type="HQL">
1369    <sql>
1370      SELECT job
1371      FROM JobData job
1372      WHERE job.status = :status
1373      AND job.type = :type
1374      ORDER BY job.priority ASC, job.created ASC
1375    </sql>
1376    <description>
1377      A Hibernate query that loads plugin jobs in the job queue waiting to be
1378      executed sorted by priority and waiting type.
1379    </description>
1380  </query>
1381 
1382  <query id="GET_ARRAYSLIDES_FOR_BATCH" type="HQL">
1383    <sql>
1384      SELECT {1}
1385      FROM ArraySlideData a
1386      WHERE a.arrayBatch = :arrayBatch
1387    </sql>
1388    <description>
1389      A Hibernate query that gets the array slides
1390      in an array batch.
1391    </description>
1392  </query>
1393
1394  <query id="GET_ARRAYBATCHES_FOR_ARRAYDESIGN" type="HQL">
1395    <sql>
1396      SELECT {1}
1397      FROM ArrayBatchData a
1398      WHERE a.arrayDesign = :arrayDesign
1399    </sql>
1400    <description>
1401      A Hibernate query that gets array batches
1402      that uses a specific array design.
1403    </description>
1404  </query>
1405
1406  <query id="GET_RAWBIOASSAYS_FOR_ARRAYDESIGN" type="HQL">
1407    <sql>
1408      SELECT {1}
1409      FROM RawBioAssayData rba
1410      WHERE rba.arrayDesign = :arrayDesign
1411    </sql>
1412    <description>
1413      A Hibernate query that gets raw bioassays
1414      that uses a specific array design.
1415    </description>
1416  </query>
1417
1418  <query id="GET_SCANS_FOR_HYBRIDIZATION" type="HQL">
1419    <sql>
1420      SELECT {1}
1421      FROM ScanData scn
1422      WHERE scn.hybridization = :hybridization
1423    </sql>
1424    <description>
1425      A Hibernate query that gets scans
1426      that uses a specific hybridization.
1427    </description>
1428  </query>
1429
1430  <query id="GET_RAWBIOASSAYS_FOR_SCAN" type="HQL">
1431    <sql>
1432      SELECT {1}
1433      FROM RawBioAssayData rba
1434      WHERE rba.scan = :scan
1435    </sql>
1436    <description>
1437      A Hibernate query that gets raw bioassays
1438      created from a specific scan.
1439    </description>
1440  </query>
1441
1442  <query id="GET_IMAGES_FOR_SCAN" type="HQL">
1443    <sql>
1444      SELECT {1}
1445      FROM ImageData img
1446      WHERE img.scan = :scan
1447    </sql>
1448    <description>
1449      A Hibernate query that gets images
1450      created from a specific scan.
1451    </description>
1452  </query>
1453
1454  <query id="GET_FEATURE_BY_ALL_COORDINATES" type="HQL">
1455    <sql>
1456      SELECT f
1457      FROM FeatureData f
1458      WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
1459      AND f.row = :row
1460      AND f.column = :column
1461      AND
1462      (
1463        (f.arrayDesignBlock.blockNumber = :block AND :block &lt;&gt; 0)
1464        OR
1465        (:block = 0 AND f.arrayDesignBlock.metaGridX = :metaGridX
1466        AND f.arrayDesignBlock.metaGridY = :metaGridY)
1467      )
1468    </sql>
1469    <description>
1470      A Hibernate query that finds a feature on a given array design
1471      with specified block and coordinates.
1472    </description>
1473  </query>
1474 
1475  <query id="PRELOAD_FEATURES" type="HQL">
1476    <sql>
1477      SELECT f
1478      FROM FeatureData f
1479      JOIN FETCH f.arrayDesignBlock b
1480      LEFT JOIN FETCH f.reporter
1481      WHERE b.arrayDesign = :arrayDesign
1482    </sql>
1483    <description>
1484      A Hibernate query that loads features, blocks and reporters
1485      for a single array design.
1486    </description>
1487  </query>
1488 
1489  <query id="DELETE_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1490    <sql>
1491      DELETE FROM Features f, ArrayDesignBlocks adb
1492      WHERE adb.id = f.arraydesignblock_id AND adb.arraydesign_id = ?
1493    </sql>
1494    <description>
1495      A Hibernate query that deletes all features for an array design.
1496    </description>
1497  </query>
1498
1499  <query id="GET_PLUGINTYPE_FOR_INTERFACENAME" type="HQL">
1500    <sql>
1501      SELECT plt
1502      FROM PluginTypeData plt
1503      WHERE plt.interfaceName = :interfaceName
1504    </sql>
1505    <description>
1506      Load a plugin type when you know the interface name.
1507    </description>
1508  </query>
1509
1510  <query id="GET_PLUGINDEFINITION_FOR_CLASSNAME" type="HQL">
1511    <sql>
1512      SELECT pd
1513      FROM PluginDefinitionData pd
1514      WHERE pd.className = :className
1515    </sql>
1516    <description>
1517      Load a plugin definition when you know the class name.
1518    </description>
1519  </query>
1520
1521  <query id="GET_EXPERIMENTS_FOR_RAWBIOASSAY" type="HQL">
1522    <sql>
1523      SELECT {1}
1524      FROM ExperimentData xp
1525      JOIN xp.rawBioAssays rba
1526      WHERE rba = :rawBioAssay
1527    </sql>
1528    <description>
1529      A Hibernate query that gets the experiments
1530      using a specific raw bioassay.
1531    </description>
1532  </query>
1533 
1534  <query id="GET_TRANSFORMATIONS_FOR_RAWBIOASSAY" type="HQL">
1535    <sql>
1536      SELECT {1}
1537      FROM TransformationData trf
1538      JOIN trf.rawSources rba
1539      WHERE rba = :rawBioAssay
1540    </sql>
1541    <description>
1542      A Hibernate query that gets the transformations
1543      using a specifiec raw bioassay.
1544    </description>
1545  </query>
1546 
1547  <query id="GET_TRANSFORMATIONS_FOR_JOB" type="HQL">
1548    <sql>
1549      SELECT {1}
1550      FROM TransformationData trf
1551      WHERE trf.job = :job
1552    </sql>
1553    <description>
1554      A Hibernate query that gets transformations
1555      linked to a job.
1556    </description>
1557  </query>
1558
1559  <query id="FIND_CHILD_BIOASSAYSETS" type="HQL">
1560    <sql>
1561      SELECT bas
1562      FROM BioAssaySetData bas
1563      WHERE bas.transformation.source = :parent
1564    </sql>
1565    <description>
1566      A Hibernate query that returns all bioassaysets that are
1567      children to a specified parent bioassayset.
1568    </description>
1569  </query>
1570 
1571  <query id="FIND_DATACUBES_FOR_BIOASSAYSETS" type="HQL">
1572    <sql>
1573      SELECT DISTINCT cbe
1574      FROM BioAssaySetData bas
1575      JOIN bas.dataCubeLayer.dataCube cbe
1576      WHERE bas IN (:basList)
1577    </sql>
1578    <description>
1579      A Hibernate query that returns all data cubes that are
1580      used by the specified list of bioassaysets
1581    </description>
1582  </query>
1583 
1584  <query id="FIND_DATACUBES_USED_BY_OTHERS" type="HQL">
1585    <sql>
1586      SELECT DISTINCT cbe
1587      FROM BioAssaySetData bas
1588      JOIN bas.dataCubeLayer.dataCube cbe
1589      WHERE bas NOT IN (:basList)
1590      AND cbe IN (:possibleCubes)
1591    </sql>
1592    <description>
1593      A Hibernate query that, given a list of data cubes and bioassaysets,
1594      returns all of those data cubes that are also used by other bioassaysets.
1595    </description>
1596  </query>
1597
1598  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS" type="HQL">
1599    <sql>
1600      SELECT lay
1601      FROM BioAssaySetData bas
1602      JOIN bas.dataCubeLayer lay
1603      WHERE bas IN (:basList)
1604    </sql>
1605    <description>
1606      A Hibernate query that returns all data cube layers that are
1607      used by the specified list of bioassaysets
1608    </description>
1609  </query>
1610 
1611  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1612    <sql>
1613      SELECT lay
1614      FROM BioAssaySetData bas
1615      JOIN bas.dataCubeLayer lay
1616      WHERE bas IN (:basList)
1617      AND lay.dataCube NOT IN (:deletedCubes)
1618    </sql>
1619    <description>
1620      A Hibernate query that returns all data cube layers that are
1621      used by the specified list of bioassaysets but not are part of the
1622      list of already deleted data cubes.
1623    </description>
1624  </query>
1625
1626  <query id="FIND_DATACUBELAYERS_USED_BY_OTHERS" type="HQL">
1627    <sql>
1628      SELECT lay
1629      FROM BioAssaySetData bas
1630      JOIN bas.dataCubeLayer lay
1631      WHERE bas NOT IN (:basList)
1632      AND lay IN (:possibleLayers)
1633    </sql>
1634    <description>
1635      A Hibernate query that, given a list of data cube layers and bioassaysets,
1636      returns all of those data cube layers that are also used by other bioassaysets.
1637    </description>
1638  </query>
1639
1640  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS" type="HQL">
1641    <sql>
1642      SELECT flt
1643      FROM BioAssaySetData bas
1644      JOIN bas.dataCubeFilter flt
1645      WHERE bas IN (:basList)
1646    </sql>
1647    <description>
1648      A Hibernate query that returns all data cube filters that are
1649      used by the specified list of bioassaysets
1650    </description>
1651  </query>
1652 
1653  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1654    <sql>
1655      SELECT flt
1656      FROM BioAssaySetData bas
1657      JOIN bas.dataCubeFilter flt
1658      WHERE bas IN (:basList)
1659      AND flt.dataCube NOT IN (:deletedCubes)
1660    </sql>
1661    <description>
1662      A Hibernate query that returns all data cube filters that are
1663      used by the specified list of bioassaysets but not are part of the
1664      list of already deleted data cubes.
1665    </description>
1666  </query>
1667
1668  <query id="FIND_DATACUBEFILTERS_USED_BY_OTHERS" type="HQL">
1669    <sql>
1670      SELECT flt
1671      FROM BioAssaySetData bas
1672      JOIN bas.dataCubeFilter flt
1673      WHERE bas NOT IN (:basList)
1674      AND flt IN (:possibleFilters)
1675    </sql>
1676    <description>
1677      A Hibernate query that, given a list of data cube filters and bioassaysets,
1678      returns all of those data cube filters that are also used by other bioassaysets.
1679    </description>
1680  </query>
1681
1682  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS" type="HQL">
1683    <sql>
1684      SELECT dcev
1685      FROM BioAssaySetData bas
1686      JOIN bas.extraValues ev
1687      JOIN ev.dataCubeExtraValue dcev
1688      WHERE bas IN (:basList)
1689    </sql>
1690    <description>
1691      A Hibernate query that returns all data cube extra values that are
1692      used by the specified list of bioassaysets
1693    </description>
1694  </query>
1695 
1696  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1697    <sql>
1698      SELECT dcev
1699      FROM BioAssaySetData bas
1700      JOIN bas.extraValues ev
1701      JOIN ev.dataCubeExtraValue dcev
1702      WHERE bas IN (:basList)
1703      AND dcev.dataCube NOT IN (:deletedCubes)
1704    </sql>
1705    <description>
1706      A Hibernate query that returns all data cube extra values that are
1707      used by the specified list of bioassaysets but not are part of the
1708      list of already deleted data cubes.
1709    </description>
1710  </query>
1711
1712  <query id="FIND_DATACUBEEXTRAVALUES_USED_BY_OTHERS" type="HQL">
1713    <sql>
1714      SELECT dcev
1715      FROM BioAssaySetData bas
1716      JOIN bas.extraValues ev
1717      JOIN ev.dataCubeExtraValue dcev
1718      WHERE bas NOT IN (:basList)
1719      AND dcev IN (:possibleExtraValues)
1720    </sql>
1721    <description>
1722      A Hibernate query that, given a list of data cube extra values and bioassaysets,
1723      returns all of those data cube extra values that are also used by other bioassaysets.
1724    </description>
1725  </query>
1726
1727  <query id="GET_EXTRAVALUETYPE_FOR_EXTERNAL_ID" type="HQL">
1728    <sql>
1729      SELECT evt
1730      FROM ExtraValueTypeData evt
1731      WHERE evt.externalId = :externalId
1732    </sql>
1733    <description>
1734      Load an extra value type when you know the external id.
1735    </description>
1736  </query>
1737
1738  <query id="GET_EXTRAVALUES_FOR_EXTRAVALUETYPE" type="HQL">
1739    <sql>
1740      SELECT {1}
1741      FROM ExtraValueData ev
1742      WHERE ev.extraValueType = :extraValueType
1743    </sql>
1744    <description>
1745      A Hibernate query that gets extra values
1746      of a specific type.
1747    </description>
1748  </query>
1749 
1750  <query id="LOAD_CONTEXT_NAMES" type="HQL">
1751    <sql>
1752      SELECT ctx.id, ctx.name
1753      FROM ContextData ctx
1754      WHERE ctx.client = :client AND
1755      (ctx.user = :user OR ctx.public = true)
1756      AND ctx.itemType = :itemType
1757      AND ctx.subContext = :subContext
1758      ORDER BY ctx.name
1759    </sql>
1760    <description>
1761      A Hibernate query that selects the id and name of all contexts for
1762      a user and item type. The names should be sorted in ascending order.
1763    </description>
1764  </query>
1765 
1766  <query id="LOAD_CONTEXT_BY_NAME" type="HQL">
1767    <sql>
1768      SELECT ctx
1769      FROM ContextData ctx
1770      WHERE ctx.user = :user
1771      AND ctx.client = :client
1772      AND ctx.itemType = :itemType
1773      AND ctx.subContext  = :subContext
1774      AND ctx.name = :name
1775    </sql>
1776    <description>
1777      A Hibernate query that load a context given the user, client,
1778      item type, subcontext and name of the context.
1779    </description>
1780  </query>
1781 
1782  <query id="COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT" type="HQL">
1783    <sql>
1784      SELECT plg.mainType, count(DISTINCT plg.id)
1785      FROM PluginDefinitionData plg
1786      JOIN plg.guiContexts gcx
1787      LEFT JOIN plg.configurations cfg
1788      WITH true = :hasConfigPermission OR cfg.owner.id = :owner
1789        OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
1790      WHERE
1791        (true = :hasPluginPermission OR plg.owner.id = :owner
1792        OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
1793      AND gcx.itemType = :itemType AND gcx.contextType = :contextType
1794      AND (
1795        (plg.requiresConfiguration = false)
1796        OR
1797        (plg.requiresConfiguration = true AND NOT cfg.id IS NULL)
1798      )
1799      GROUP BY plg.mainType
1800    </sql>
1801    <description>
1802      A Hibernate query that counts the number of plugins available for a
1803      given GUI context grouped by the main type of the plugins taking
1804      the requirement of configurations and user permissions into account.
1805    </description>
1806  </query>
1807 
1808  <query id="GET_FORMULA_WITH_NAME_AND_CHANNELS" type="HQL">
1809    <sql>
1810      SELECT fml
1811      FROM FormulaData fml
1812      WHERE fml.name = :name
1813      AND fml.channels = :channels
1814    </sql>
1815    <description>
1816      A Hibernate query that loads a formula with a given name and number
1817      of channels.
1818    </description>
1819  </query>
1820
1821  <query id="GET_FORMULA_WITH_NAME_AND_TYPE" type="HQL">
1822    <sql>
1823      SELECT fml
1824      FROM FormulaData fml
1825      WHERE fml.name = :name
1826      AND fml.rawDataType = :rawDataType
1827    </sql>
1828    <description>
1829      A Hibernate query that loads a formula with a given name and raw data type.
1830    </description>
1831  </query>
1832 
1833  <query id="GET_HELP_FOR_EXTERNAL_ID" type="HQL">
1834    <sql>
1835      SELECT hlp
1836      FROM HelpData hlp
1837      WHERE hlp.externalId = :externalId AND hlp.client = :client
1838    </sql>
1839    <description>
1840      A Hibernate query that loads a help text.
1841    </description>
1842  </query>
1843 
1844  <query id="GET_SCHEMA_VERSION" type="HQL">
1845    <sql>
1846      SELECT sv
1847      FROM SchemaVersionData sv
1848    </sql>
1849    <description>
1850      A Hibernate query that loads the schema version (there should only be one record).
1851    </description>
1852  </query>
1853 
1854  <query id="SET_SCHEMA_VERSION" type="HQL">
1855    <sql>
1856      UPDATE SchemaVersionData sv
1857      SET sv.schemaVersion = :schemaVersion,
1858      sv.build = :build
1859    </sql>
1860    <description>
1861      A Hibernate query that updates the schema version and build number.
1862    </description>
1863  </query>
1864 
1865  <query id="SET_PROJECT_ID_FOR_JOBS" type="HQL">
1866    <sql>
1867      UPDATE JobData job
1868      SET job.activeProjectId = 0
1869      WHERE job.activeProjectId IS NULL
1870    </sql>
1871    <description>
1872      A Hibernate query that sets the active project ID for all
1873      jobs to 0 if they have a null value.
1874    </description>
1875  </query>
1876
1877  <query id="GET_PRIMARY_ANNOTATION" type="HQL">
1878    <sql>
1879      SELECT ad
1880      FROM AnnotationData ad
1881      WHERE ad.annotationType = :annotationType
1882      AND ad.annotationSet = :annotationSet
1883    </sql>
1884    <description>
1885      A Hibernate query that loads the primary annotation of a specific
1886      annotation type for a given annotation set.
1887    </description>
1888  </query>
1889 
1890  <query id="GET_DIRECTLY_INHERITED_ANNOTATION" type="HQL">
1891    <sql>
1892      SELECT ad
1893      FROM AnnotationData ad
1894      JOIN ad.inheritingSets ans
1895      WHERE ad.annotationType = :annotationType
1896      AND ans = :annotationSet
1897    </sql>
1898    <description>
1899      A Hibernate query that loads an directly inherited annotation of a specific
1900      annotation type for a given annotation set. A directly inhertited annotation
1901      is an annotation that is linked to the specified annotation set.
1902    </description>
1903  </query>
1904
1905  <query id="GET_INDIRECTLY_INHERITED_ANNOTATION" type="HQL">
1906    <sql>
1907      SELECT ad
1908      FROM AnnotationData ad
1909      JOIN ad.annotationSet.inheritingSets ians
1910      WHERE ad.annotationType = :annotationType
1911      AND ians = :annotationSet
1912    </sql>
1913    <description>
1914      A Hibernate query that loads an indirectly inherited annotation of a specific
1915      annotation type for a given annotation set. An indirectly inherited annotation
1916      is an annotation which belongs to an annotation set which is inherited by
1917      the given annotation set.
1918    </description>
1919  </query>
1920 
1921  <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL">
1922    <sql>
1923      UPDATE ExperimentData xpm
1924      SET xpm.bytes = xpm.bytes + :addedBytes
1925      WHERE xpm.id = :experiment
1926    </sql>
1927    <description>
1928      A Hibernate query that updates the number of bytes used by an experiment.
1929    </description>
1930  </query>
1931
1932  <query id="UPDATE_BYTES_FOR_DATACUBE" type="HQL">
1933    <sql>
1934      UPDATE DataCubeData dcd
1935      SET dcd.bytes = dcd.bytes + :addedBytes
1936      WHERE dcd.id = :dataCube
1937    </sql>
1938    <description>
1939      A Hibernate query that updates the number of bytes used by a data cube.
1940    </description>
1941  </query>
1942 
1943  <query id="GET_REMOVED_ITEMS" type="HQL">
1944    <sql>
1945      SELECT trash
1946      FROM net.sf.basedb.core.data.RemovableData trash
1947      WHERE trash.removed = true
1948    </sql>
1949    <description>
1950      A Hibernate query that loads all items flagged for deletion.
1951    </description>
1952  </query>
1953 
1954  <query id="UPDATE_REMAINING_QUANTITY" type="HQL">
1955    <sql>
1956      UPDATE MeasuredBioMaterialData mbm
1957      SET mbm.remainingQuantity = mbm.remainingQuantity - :used
1958      WHERE mbm = :bioMaterial
1959    </sql>
1960    <description>
1961      A Hibernate query that adds/removes the remaining quantity on a
1962      measuered biomaterial.
1963    </description>
1964  </query>
1965
1966  <query id="SET_REMAINING_QUANTITY" type="HQL">
1967    <sql>
1968      UPDATE MeasuredBioMaterialData mbm
1969      SET mbm.remainingQuantity = :remain
1970      WHERE mbm = :bioMaterial
1971    </sql>
1972    <description>
1973      A Hibernate query that sets the remaining quantity on a
1974      measuered biomaterial.
1975    </description>
1976  </query>
1977
1978
1979  <query id="GET_ANYTOANY_FOR_NAME" type="HQL">
1980    <sql>
1981      SELECT ata
1982      FROM AnyToAnyData ata
1983      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
1984    </sql>
1985    <description>
1986      A Hibernate query that loads the any-to-any link with the specified name
1987      for an item.
1988    </description>
1989  </query>
1990
1991  <query id="DELETE_ANYTOANY_FROM" type="HQL">
1992    <sql>
1993      DELETE FROM AnyToAnyData ata
1994      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
1995    </sql>
1996    <description>
1997      A Hibernate query that deletes a names any-to-any link leading out from
1998      an item.
1999    </description>
2000  </query>
2001
2002
2003  <query id="DELETE_ALL_ANYTOANY_FROM" type="HQL">
2004    <sql>
2005      DELETE FROM AnyToAnyData ata
2006      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2007    </sql>
2008    <description>
2009      A Hibernate query that deletes all any-to-any links leading out from
2010      an item.
2011    </description>
2012  </query>
2013
2014  <query id="DELETE_ALL_ANYTOANY_TO" type="HQL">
2015    <sql>
2016      DELETE FROM AnyToAnyData ata
2017      WHERE ata.toId = :toId AND ata.toType = :toType
2018    </sql>
2019    <description>
2020      A Hibernate query that deletes all any-to-any links leading in to
2021      an item.
2022    </description>
2023  </query>
2024 
2025  <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
2026    <sql>
2027      DELETE FROM AnyToAnyData ata
2028      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = false
2029    </sql>
2030    <description>
2031      A Hibernate query that deletes all any-to-any links leading in to
2032      an item that doesn't count as using the item.
2033    </description>
2034  </query>
2035
2036  <query id="COUNT_ANYTOANY_FROM" type="HQL">
2037    <sql>
2038      SELECT count(*)
2039      FROM AnyToAnyData ata
2040      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2041    </sql>
2042    <description>
2043      A Hibernate query that counts the number of any-to-any links
2044      from a given item.
2045    </description>
2046  </query>
2047
2048  <query id="COUNT_ANYTOANY_TO" type="HQL">
2049    <sql>
2050      SELECT count(*)
2051      FROM AnyToAnyData ana
2052      WHERE ana.toId = :toId AND ana.toType = :toType
2053    </sql>
2054    <description>
2055      A Hibernate query that counts the number of any-to-any links
2056      to a given item.
2057    </description>
2058  </query>
2059
2060  <query id="COUNT_USED_ANYTOANY_TO" type="HQL">
2061    <sql>
2062      SELECT count(*)
2063      FROM AnyToAnyData ata
2064      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = true
2065    </sql>
2066    <description>
2067      A Hibernate query that counts the number of any-to-any links
2068      to a given item that counts as using the item.
2069    </description>
2070  </query>
2071
2072  <query id="FIND_USING_ANYTOANY" type="HQL">
2073    <sql>
2074      SELECT ana.fromId, ana.fromType
2075      FROM AnyToAnyData ana
2076      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
2077    </sql>
2078    <description>
2079      A Hibernate query that finds the any-to-any links
2080      to a given item that counts as using the item.
2081    </description>
2082  </query>
2083
2084 
2085  <query id="UPDATE_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2086    <sql>
2087      UPDATE VirtualDbData vdb
2088      SET vdb.cubes = vdb.cubes + 1
2089      WHERE vdb.id = :virtualDb
2090    </sql>
2091    <description>
2092      A Hibernate query that updates the number of data cubes
2093      for the specified virtual database.
2094    </description>
2095  </query>
2096
2097  <query id="GET_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2098    <sql>
2099      SELECT vdb.cubes
2100      FROM VirtualDbData vdb
2101      WHERE vdb.id = :virtualDb
2102    </sql>
2103    <description>
2104      A Hibernate query that gets the current number of data cubes
2105      for the specified virtual database.
2106    </description>
2107  </query>
2108 
2109  <query id="UPDATE_FILTERNO_FOR_DATACUBE" type="HQL">
2110    <sql>
2111      UPDATE DataCubeData dcb
2112      SET dcb.numFilters = dcb.numFilters + 1
2113      WHERE dcb.id = :dataCube
2114    </sql>
2115    <description>
2116      A Hibernate query that updates the number of filters
2117      for the specified data cube.
2118    </description>
2119  </query>
2120
2121  <query id="GET_FILTERNO_FOR_DATACUBE" type="HQL">
2122    <sql>
2123      SELECT dcb.numFilters
2124      FROM DataCubeData dcb
2125      WHERE dcb.id = :dataCube
2126    </sql>
2127    <description>
2128      A Hibernate query that gets the current number of filters
2129      for the specified data cube.
2130    </description>
2131  </query>
2132
2133  <query id="UPDATE_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2134    <sql>
2135      UPDATE DataCubeData dcb
2136      SET dcb.numExtraValues = dcb.numExtraValues + 1
2137      WHERE dcb.id = :dataCube
2138    </sql>
2139    <description>
2140      A Hibernate query that updates the number of extra values
2141      for the specified data cube.
2142    </description>
2143  </query>
2144
2145  <query id="GET_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2146    <sql>
2147      SELECT dcb.numExtraValues
2148      FROM DataCubeData dcb
2149      WHERE dcb.id = :dataCube
2150    </sql>
2151    <description>
2152      A Hibernate query that gets the current number of extra values
2153      for the specified data cube.
2154    </description>
2155  </query>
2156
2157  <query id="UPDATE_LAYERNO_FOR_DATACUBE" type="HQL">
2158    <sql>
2159      UPDATE DataCubeData dcb
2160      SET dcb.numLayers = dcb.numLayers + 1
2161      WHERE dcb.id = :dataCube
2162    </sql>
2163    <description>
2164      A Hibernate query that updates the number of layers
2165      for the specified data cube.
2166    </description>
2167  </query>
2168
2169  <query id="GET_LAYERNO_FOR_DATACUBE" type="HQL">
2170    <sql>
2171      SELECT dcb.numLayers
2172      FROM DataCubeData dcb
2173      WHERE dcb.id = :dataCube
2174    </sql>
2175    <description>
2176      A Hibernate query that gets the current number of layers
2177      for the specified data cube.
2178    </description>
2179  </query>
2180
2181  <query id="UPDATE_COLUMNNO_FOR_DATACUBE" type="HQL">
2182    <sql>
2183      UPDATE DataCubeData dcb
2184      SET dcb.numColumns = dcb.numColumns + 1
2185      WHERE dcb.id = :dataCube
2186    </sql>
2187    <description>
2188      A Hibernate query that updates the number of columns
2189      for the specified data cube.
2190    </description>
2191  </query>
2192
2193  <query id="GET_COLUMNNO_FOR_DATACUBE" type="HQL">
2194    <sql>
2195      SELECT dcb.numColumns
2196      FROM DataCubeData dcb
2197      WHERE dcb.id = :dataCube
2198    </sql>
2199    <description>
2200      A Hibernate query that gets the current number of columns
2201      for the specified data cube.
2202    </description>
2203  </query>
2204
2205  <query id="SET_HAS_DATA_FOR_RAWBIOASSAYS" type="HQL">
2206    <sql>
2207      UPDATE RawBioAssayData rba
2208      SET rba.hasData = CASE
2209        WHEN rba.spots > 0 THEN true
2210        ELSE false
2211        END
2212      WHERE rba.hasData IS NULL
2213    </sql>
2214    <description>
2215      A Hibernate query that sets the hasData property for a
2216      raw bioassay depending on if it has spots or not.
2217    </description>
2218  </query>
2219 
2220  <query id="SET_REMOVED_FOR_HARDWARETYPES" type="HQL">
2221    <sql>
2222      UPDATE HardwareTypeData hwd
2223      SET hwd.removed = false
2224      WHERE hwd.removed IS NULL
2225    </sql>
2226    <description>
2227      A Hibernate query that sets the removed property to false for a
2228      HardwareTypeData if it has NULL value.
2229    </description>
2230  </query>
2231
2232  <query id="SET_CONFIG_FOR_PLUGINS" type="HQL">
2233    <sql>
2234      UPDATE PluginDefinitionData pd
2235      SET pd.supportsConfigurations = true, pd.requiresConfiguration = false
2236      WHERE pd.supportsConfigurations IS NULL OR pd.requiresConfiguration IS NULL
2237    </sql>
2238    <description>
2239      A Hibernate query that sets the supportsConfigurations and requiresConfiguration
2240      properties of PluginDefinitionData items if any of them is null.
2241    </description>
2242  </query>
2243
2244  <query id="GET_INCORRECT_PLATEMAPPINGS" type="HQL">
2245    <sql>
2246      SELECT pm
2247      FROM PlateMappingData pm
2248      WHERE pm.sourceCount = 4 AND pm.destinationCount = 1
2249      AND
2250      (
2251        (pm.sourceGeometry.rows = 8 AND pm.sourceGeometry.columns = 12)
2252        OR
2253        (pm.sourceGeometry.rows = 16 AND pm.sourceGeometry.columns = 24)
2254      )
2255    </sql>
2256    <description>
2257      A Hibernate query that finds incorrect plate mappings.
2258    </description>
2259  </query>
2260 
2261  <query id="GET_PLATES_WITH_MAPPING" type="HQL">
2262    <sql>
2263      SELECT p
2264      FROM PlateData p
2265      WHERE p.plateMapping = :plateMapping
2266    </sql>
2267    <description>
2268      A Hibernate query that loads all plates with a specific plate mapping.
2269    </description>
2270  </query>
2271 
2272  <query id="GET_JOBAGENT_FOR_EXTERNALID" type="HQL">
2273    <sql>
2274      SELECT jag
2275      FROM JobAgentData jag
2276      WHERE jag.externalId = :externalId
2277    </sql>
2278    <description>
2279      A Hibernate query that loads the job agent with the specified external ID.
2280    </description>
2281  </query>
2282
2283  <query id="SET_TRUSTED_FOR_PLUGINDEFINITIONS" type="HQL">
2284    <sql>
2285      UPDATE PluginDefinitionData pd
2286      SET pd.trusted = true
2287      WHERE pd.trusted IS NULL
2288    </sql>
2289    <description>
2290      A Hibernate query that sets the trusted flag for all plugins with a null value
2291      to TRUE.
2292    </description>
2293  </query>
2294 
2295  <query id="SET_USE_PERMISSION_FOR_PLUGINDEFINITIONS" type="HQL">
2296    <sql>
2297      UPDATE PluginDefinitionData pd
2298      SET pd.usePermissions = false
2299      WHERE pd.usePermissions IS NULL
2300    </sql>
2301    <description>
2302      A Hibernate query that sets the use permission flag to false
2303      for all plugins with a null value.
2304    </description>
2305  </query>
2306 
2307  <query id="GET_KEYS_FOR_PLUGIN" type="HQL">
2308    <sql>
2309      SELECT pdk
2310      FROM PluginKeys pdk
2311      WHERE pdk.pluginDefinitionId = :pluginId
2312      ORDER BY pdk.keyId
2313    </sql>
2314    <description>
2315      A Hibernate query that loads all PluginDefinitionKeys for a specified plugin ID.
2316    </description>
2317  </query>
2318 
2319  <query id="SET_SENDMESSAGE_FOR_JOBS" type="HQL">
2320    <sql>
2321      UPDATE JobData job
2322      SET job.sendMessage = true
2323      WHERE job.sendMessage IS NULL
2324    </sql>
2325    <description>
2326      A Hibernate query that sets the send message flag for all jobs with a null value.
2327    </description>
2328  </query>
2329
2330  <query id="SET_PARAMETER_VERSION_FOR_PLUGINCONFIGURATIONS" type="HQL">
2331    <sql>
2332      UPDATE PluginConfigurationData pc
2333      SET pc.parameterVersion = 1
2334      WHERE pc.parameterVersion IS NULL
2335    </sql>
2336    <description>
2337      A Hibernate query that sets the parameter version to 1 for all
2338      configurations with a null value.
2339    </description>
2340  </query>
2341
2342  <query id="SET_PARAMETER_VERSION_FOR_JOBS" type="HQL">
2343    <sql>
2344      UPDATE JobData job
2345      SET job.parameterVersion = 1
2346      WHERE job.parameterVersion IS NULL
2347    </sql>
2348    <description>
2349      A Hibernate query that sets the parameter version to 1 for all
2350      jobs with a null value.
2351    </description>
2352  </query>
2353
2354  <query id="COPY_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
2355    <sql>
2356      INSERT INTO "VersionedPluginConfigurationValues"
2357      ("pluginconfiguration_id", "name", "parameter_version", "value_id")
2358      SELECT "pluginconfiguration_id", "name", 1, "value_id"
2359      FROM "PluginConfigurationValues"
2360    </sql>
2361    <description>
2362      An SQL query that creates versioned parameters from unversioned.
2363    </description>
2364  </query>
2365 
2366  <query id="DELETE_UNVERSIONED_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
2367    <sql>
2368      DELETE FROM "PluginConfigurationValues"
2369    </sql>
2370    <description>
2371      An SQL query that deletes unversioned plugin configuration parameters.
2372    </description>
2373  </query>
2374
2375  <query id="SET_COLORING_FOR_FORMULAS" type="HQL">
2376    <sql>
2377        UPDATE FormulaData frm
2378        SET
2379          frm.coloring.usingColors = false,
2380          frm.coloring.logarithmic = false
2381        WHERE frm.coloring.usingColors IS NULL
2382    </sql>
2383    <description>
2384      A HQL query that sets the usingColors and logarithmic to false
2385      for all formulas with null values.
2386    </description>
2387  </query>
2388 
2389  <query id="SET_COLORING_FOR_EXTRAVALUETYPES" type="HQL">
2390    <sql>
2391      UPDATE ExtraValueTypeData evt
2392      SET
2393        evt.coloring.usingColors = false,
2394        evt.coloring.logarithmic = false
2395        WHERE evt.coloring.usingColors IS NULL
2396    </sql>
2397    <description>
2398      A HQL query that sets the usingColors and logarithmic to false
2399      for all extra value types with null values.
2400    </description>
2401  </query>
2402 
2403  <query id="SET_IMMEDIATE_EXECUTION_FOR_PLUGINS" type="HQL">
2404    <sql>
2405      UPDATE PluginDefinitionData plg
2406      SET plg.allowImmediateExecution = false
2407      WHERE plg.allowImmediateExecution IS NULL
2408    </sql>
2409    <description>
2410      A HQL query that sets the allowImmediateExecution to false
2411      for all plugins which has a null value.
2412    </description>
2413  </query>
2414 
2415  <query id="SET_PROTOCOL_PARAMETER_FOR_ANNOTATION_TYPES" type="HQL">
2416    <sql>
2417      UPDATE AnnotationTypeData at
2418      SET at.protocolParameter = false
2419      WHERE at.protocolParameter IS NULL
2420    </sql>
2421    <description>
2422      A HQL query that sets the protocolParameter flag to false
2423      for all annotation types with a null value.
2424    </description>
2425  </query>
2426
2427  <query id="CHANGE_FILE_DISCRIMINATOR" type="SQL">
2428    <sql>
2429      UPDATE "ParameterValues"
2430      SET "discriminator" = 10
2431      WHERE "discriminator" = 9
2432    </sql>
2433    <description>
2434      An SQL query that changes the discriminator for file
2435      parameters
2436    </description>
2437  </query>
2438
2439  <query id="COPY_FILE_PARAMETERS" type="SQL">
2440    <sql>
2441      INSERT INTO "ItemValues" ("id", "data_class", "data_class_id")
2442      SELECT "id", 'net.sf.basedb.core.data.FileData', "value"
2443      FROM "FileValues"
2444    </sql>
2445    <description>
2446      An SQL query that copies file parameter values into
2447      the item parameter values table.
2448    </description>
2449  </query>
2450
2451  <query id="DELETE_FILE_PARAMETERS" type="SQL">
2452    <sql>
2453      DELETE FROM "FileValues"
2454    </sql>
2455    <description>
2456      An SQL query that deletes old file parameter values (after they have been copied).
2457    </description>
2458  </query>
2459
2460  <query id="SET_ITEMTYPE_ON_DISKUSAGE" type="HQL">
2461    <sql>
2462      UPDATE DiskUsageData du
2463      SET du.itemType = :itemType
2464      WHERE du.id IN (:itemList)
2465      AND du.itemType IS NULL
2466    </sql>
2467    <description>
2468      A HQL query that sets the item type for disk usage items.
2469    </description>
2470  </query>
2471
2472  <query id="LOAD_DISKUSAGEID_FOR_FILES" type="HQL">
2473    <sql>
2474      SELECT f.diskUsage.id
2475      FROM FileData f
2476    </sql>
2477    <description>
2478      A HQL query that loads the disk usage ID for all files.
2479    </description>
2480  </query>
2481 
2482  <query id="LOAD_DISKUSAGEID_FOR_EXPERIMENTS" type="HQL">
2483    <sql>
2484      SELECT xp.diskUsage.id
2485      FROM ExperimentData xp
2486    </sql>
2487    <description>
2488      A HQL query that loads the disk usage ID for all experiments.
2489    </description>
2490  </query>
2491 
2492  <query id="LOAD_DISKUSAGEID_FOR_RAWBIOASSAYS" type="HQL">
2493    <sql>
2494      SELECT rba.diskUsage.id
2495      FROM RawBioAssayData rba
2496    </sql>
2497    <description>
2498      A HQL query that loads the disk usage ID for all raw bioassays.
2499    </description>
2500  </query>
2501
2502  <query id="SET_MAX_MAPPING_ON_DATACUBES" type="HQL">
2503    <sql>
2504      UPDATE DataCubeData dcd
2505      SET dcd.maxRawMappingsForSpot = -1
2506      WHERE dcd.maxRawMappingsForSpot IS NULL
2507    </sql>
2508    <description>
2509      A HQL query that sets the maxRawMappingsForSpot on all data cubes with a
2510      null value to -1. This is required so we can load them by Hibernate.
2511    </description>
2512  </query>
2513
2514  <query id="SET_MAX_MAPPING_ON_DATACUBE" type="HQL">
2515    <sql>
2516      UPDATE DataCubeData dcd
2517      SET dcd.maxRawMappingsForSpot = :mapCount
2518      WHERE dcd.id = :dataCube
2519    </sql>
2520    <description>
2521      A HQL query that sets the maxRawMappingsForSpot on a data cube.
2522    </description>
2523  </query>
2524
2525  <query id="GET_SUM_USED_QUANTITY_EVENTS" type="HQL">
2526    <sql>
2527      SELECT evt.bioMaterial, SUM(evt.usedQuantity)
2528      FROM BioMaterialEventData evt
2529      GROUP BY evt.bioMaterial
2530    </sql>
2531    <description>
2532      A HQL query that loads the sum of the used quantity
2533      grouped by the biomaterial for all BioMaterialEvent:s.
2534    </description>
2535  </query>
2536 
2537  <query id="GET_SUM_USED_QUANTITY_SOURCES" type="HQL">
2538    <sql>
2539      SELECT index(src), SUM(src.usedQuantity)
2540      FROM BioMaterialEventData evt
2541      JOIN evt.sources src
2542      GROUP BY index(src)
2543    </sql>
2544    <description>
2545      A HQL query that loads the sum of the used quantity
2546      grouped by the biomaterial for all sources to
2547      BioMaterialEvent:s.
2548    </description>
2549  </query>
2550
2551</predefined-queries>
Note: See TracBrowser for help on using the repository browser.