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

Last change on this file since 3999 was 3999, checked in by Nicklas Nordborg, 15 years ago

Fixes #842: PluginDefinition?.isUsed() throws exception

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 73.2 KB
Line 
1<?xml version="1.0" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 3999 2007-11-26 11:36:07Z nicklas $
5
6  Copyright (C) 2005 Samuel Andersson, Johan Enell, Nicklas Nordborg
7  Copyright (C) 2006 Jari Hakkinen, 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 2
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 this program; if not, write to the Free Software
25  Foundation, Inc., 59 Temple Place - Suite 330,
26  Boston, MA  02111-1307, USA.
27-->
28<!--
29  This XML file contains HQL and SQL queries that are common
30  to all databases. If one of them happens to fail on your
31  particular database, do not modify this file. Instead, you
32  should add an entry into the file that is specific for your
33  particular database that overrides the query in this file.
34  For example, for MySQL modify the mysql-queries.xml.
35-->
36<predefined-queries>
37
38  <query id="LOAD_SYSTEM_ITEMS" type="HQL">
39    <sql>
40      SELECT item.id, item.systemId
41      FROM net.sf.basedb.core.data.SystemData item
42      WHERE NOT item.systemId IS NULL
43    </sql>
44    <description>
45      Load the ID and systemID, in that order, of all SystemData
46      items.
47    </description>
48  </query>
49
50  <query id="LOAD_ROLE_KEY_IDS" type="HQL">
51    <sql>
52      SELECT rk.id, rk.itemType
53      FROM RoleKeyData rk
54    </sql>
55    <description>
56      Load the ID and itemType, in that order, of all RoleKeyData
57      items.
58    </description>
59  </query>
60
61  <query id="GET_USER_FOR_LOGIN" type="HQL">
62    <sql>
63      SELECT usr
64      FROM UserData usr
65      WHERE usr.login = :login
66    </sql>
67    <description>
68      Load a user when you know the login.
69    </description>
70  </query>
71 
72  <query id="GET_USER_FOR_EXTERNAL_ID" type="HQL">
73    <sql>
74      SELECT usr
75      FROM UserData usr
76      WHERE usr.externalId = :externalId
77    </sql>
78    <description>
79      Load a user when you know the external id.
80    </description>
81  </query>
82
83  <query id="GET_CLIENT_FOR_EXTERNAL_ID" type="HQL">
84    <sql>
85      SELECT cli
86      FROM ClientData cli
87      WHERE cli.externalId = :externalId
88    </sql>
89    <description>
90      Load a client when you know the external ID.
91    </description>
92  </query>
93 
94  <query id="GET_ROLE_IDS_FOR_USER" type="HQL">
95    <sql>
96      SELECT ur.roleId
97      FROM UserRoles ur
98      WHERE ur.userId = :userId
99    </sql>
100    <description>
101      Load the ID of all roles where the given user is a member.
102    </description>
103  </query>
104
105  <query id="GET_GROUP_IDS_FOR_USER" type="HQL">
106    <sql>
107      SELECT ug.groupId
108      FROM UserGroups ug
109      WHERE ug.userId = :userId
110    </sql>
111    <description>
112      Load the ID of all groups where the given user is a direct member.
113    </description>
114  </query>
115 
116  <query id="GET_QUOTA_GROUP_ID_FOR_USER" type="HQL">
117    <sql>
118      SELECT usr.quotaGroup.id
119      FROM UserData usr
120      WHERE usr.id = :userId
121    </sql>
122    <description>
123      Load the ID of a user's quota group.
124    </description>
125  </query>
126
127  <query id="GET_PARENTGROUPS_IDS_FOR_GROUPS" type="HQL">
128    <sql>
129      SELECT DISTINCT gg.parentId
130      FROM GroupGroups gg
131      WHERE gg.childId IN (:groups)
132      AND gg.parentId NOT IN (:groups)
133    </sql>
134    <description>
135      Load the ID of all groups that are parents to at least one of
136      the given groups, excluding the given groups.
137    </description>
138  </query>
139 
140  <query id="GET_CHILDGROUPS_IDS_FOR_GROUPS" type="HQL">
141    <sql>
142      SELECT DISTINCT gg.childId
143      FROM GroupGroups gg
144      WHERE gg.parentId IN (:groups)
145      AND gg.childId NOT IN (:groups)
146    </sql>
147    <description>
148      Load the ID of all groups that are children to at least one of
149      the given groups, excluding the given groups.
150    </description>
151  </query>
152
153  <query id="GET_PROJECT_IDS_FOR_OWNER" type="HQL">
154    <sql>
155      SELECT p.id
156      FROM ProjectData p
157      WHERE p.owner = :userId
158    </sql>
159    <description>
160      Load the ID of all projects where the given user is the owner.
161    </description>
162  </query>
163
164  <query id="GET_PROJECTINFO_FOR_USER" type="HQL">
165    <sql>
166      SELECT up
167      FROM UserProjects up
168      WHERE up.userId = :userId
169    </sql>
170    <description>
171      Load the UserProjects of all projects where the given user is a member.
172    </description>
173  </query>
174
175  <query id="GET_PROJECTINFO_FOR_GROUPS" type="HQL">
176    <sql>
177      SELECT DISTINCT gp
178      FROM GroupProjects gp
179      WHERE gp.groupId IN (:groups)
180    </sql>
181    <description>
182      Load the GroupProjects of all projects where at least one of the given groups
183      is a member.
184    </description>
185  </query>
186
187  <query id="GET_USER_IDS_FOR_GROUPS" type="HQL">
188    <sql>
189      SELECT ug.userId
190      FROM UserGroups ug
191      WHERE ug.groupId IN (:groups)
192    </sql>
193    <description>
194      Load the ID of all users which is a member of at least one of the given groups.
195    </description>
196  </query>
197
198  <query id="GET_USER_IDS_FOR_QUOTAGROUPS" type="HQL">
199    <sql>
200      SELECT usr.id
201      FROM UserData usr
202      WHERE usr.quotaGroup.id IN (:groups)
203    </sql>
204    <description>
205      Load the ID of all users which has a quota group from one of the given groups.
206    </description>
207  </query>
208
209  <query id="GET_USER_IDS_FOR_PROJECT" type="HQL">
210    <sql>
211      SELECT up.userId
212      FROM UserProjects up
213      WHERE up.projectId = :projectId
214    </sql>
215    <description>
216      Load the ID of all users which are direct member of the given project
217    </description>
218  </query>
219
220  <query id="GET_GROUP_IDS_FOR_PROJECT" type="HQL">
221    <sql>
222      SELECT gp.groupId
223      FROM GroupProjects gp
224      WHERE gp.projectId = :projectId
225    </sql>
226    <description>
227      Load the ID of all groups which are direct member of the given project
228    </description>
229  </query>
230
231  <query id="GET_USERKEYS_FOR_USER" type="HQL">
232    <sql>
233      SELECT uk
234      FROM UserKeys uk
235      WHERE uk.userId = :userId
236    </sql>
237    <description>
238      Load the UserKeys for the given user.
239    </description>
240  </query>
241
242  <query id="GET_GROUPKEYS_FOR_GROUPS" type="HQL">
243    <sql>
244      SELECT gk
245      FROM GroupKeys gk
246      WHERE gk.groupId IN (:groups)
247    </sql>
248    <description>
249      Load the GroupKeys for the given groups.
250    </description>
251  </query>
252
253  <query id="GET_ROLEKEYS_FOR_USER" type="HQL">
254    <sql>
255      SELECT rk
256      FROM RoleKeys rk, UserRoles ur
257      WHERE rk.roleId = ur.roleId AND ur.userId = :userId
258      ORDER BY rk.keyId
259    </sql>
260    <description>
261      Load the RoleKeys for the roles where the given user is a member.
262    </description>
263  </query>
264
265  <query id="GET_PROJECTKEYS_FOR_PROJECT" type="HQL">
266    <sql>
267      SELECT pk
268      FROM ProjectKeys pk
269      WHERE pk.projectId = :projectId
270      ORDER BY pk.keyId
271    </sql>
272    <description>
273      Load the ProjectKeys for the given project. Sort by
274      keyId for fast lookup in array (Keyring class).
275    </description>
276  </query>
277 
278  <query id="GET_PROJECTKEYIDS_FOR_PROJECT" type="HQL">
279    <sql>
280      SELECT pk.keyId
281      FROM ProjectKeys pk
282      WHERE pk.projectId = :projectId
283    </sql>
284    <description>
285      Load the ID of ProjectKeys for the given project.
286    </description>
287  </query>
288
289  <query id="GET_PERMISSION_FOR_USER_IN_PROJECT" type="HQL">
290    <sql>
291      SELECT up.permission
292      FROM UserProjects up
293      WHERE up.userId = :userId
294      AND up.projectId = :projectId
295    </sql>
296    <description>
297      Load the permission for the given user in the given project.
298    </description>
299  </query>
300
301  <query id="GET_PERMISSIONS_FOR_GROUPS_IN_PROJECT" type="HQL">
302    <sql>
303      SELECT gp.permission
304      FROM GroupProjects gp
305      WHERE gp.groupId IN (:groups)
306      AND gp.projectId = :projectId
307    </sql>
308    <description>
309      Load the permissions for the given groups in the given project.
310    </description>
311  </query>
312
313  <query id="GET_PROJECTKEY_IDS_FOR_COUNT" type="HQL">
314    <sql>
315      SELECT pk.keyId FROM ProjectKeys pk
316      GROUP BY pk.keyId
317      HAVING count(pk.projectId) = :numPermissions
318    </sql>
319    <description>
320      Load the ID of all project keys which have permissions for the
321      specified number of projects.
322    </description>
323  </query>
324
325  <query id="FIND_USED_PROJECTKEY_IDS" type="HQL">
326    <sql>
327      SELECT DISTINCT sd.projectKey.id
328      FROM net.sf.basedb.core.data.ShareableData sd
329      WHERE NOT sd.projectKey IS NULL
330    </sql>
331    <description>
332      Load the ID of all project keys which are used by at least one
333      shareable item.
334    </description>
335  </query>
336 
337  <query id="SELECT_UNUSED_PROJECTKEYS" type="HQL">
338    <sql>
339      SELECT pk FROM ProjectKeyData pk
340      WHERE pk.id NOT IN (:used)
341    </sql>
342    <description>
343      Load all unused project keys given a list of the ID:s of all used
344      keys.
345    </description>
346  </query>
347
348  <query id="GET_ITEMKEY_IDS_FOR_USERCOUNT" type="HQL">
349    <sql>
350      SELECT ik.id FROM ItemKeyData ik
351      LEFT JOIN ik.users u
352      GROUP BY ik.id
353      HAVING COUNT(u.index) = :numPermissions
354    </sql>
355    <description>
356      Load the ID of all item keys which have permissions for the
357      specified number of users.
358    </description>
359  </query>
360
361  <query id="GET_ITEMKEY_IDS_FOR_GROUPCOUNT" type="HQL">
362    <sql>
363      SELECT ik.id FROM ItemKeyData ik
364      LEFT JOIN ik.groups g
365      WHERE ik.id IN (:candidates)
366      GROUP BY ik.id
367      HAVING count(g.index) = :numPermissions
368    </sql>
369    <description>
370      Load the ID of all item keys which have permissions for the
371      specified number of groups and are among the list of candidates.
372    </description>
373  </query>
374 
375  <query id="FIND_USED_ITEMKEY_IDS" type="HQL">
376    <sql>
377      SELECT DISTINCT sd.itemKey.id
378      FROM net.sf.basedb.core.data.ShareableData sd
379      WHERE NOT sd.itemKey IS NULL
380    </sql>
381    <description>
382      Load the ID of all item keys which are used by at least one
383      shareable item.
384    </description>
385  </query>
386 
387  <query id="SELECT_UNUSED_ITEMKEYS" type="HQL">
388    <sql>
389      SELECT ik FROM ItemKeyData ik
390      WHERE ik.id NOT IN (:used)
391    </sql>
392    <description>
393      Load all unused item keys given a list of the ID:s of all used
394      keys.
395    </description>
396  </query>
397
398  <query id="GET_USERS_FOR_QUOTAGROUP" type="HQL">
399    <sql>
400      SELECT {1}
401      FROM UserData usr
402      WHERE usr.quotaGroup = :theGroup
403    </sql>
404    <description>
405      Get users having the specified group as
406      their quota group.
407    </description>
408  </query>
409 
410  <query id="GET_USERS_FOR_QUOTA" type="HQL">
411    <sql>
412      SELECT {1}
413      FROM UserData u
414      WHERE u.quota = :quota
415    </sql>
416    <description>
417      A Hibernate query that gets users
418      that has been assigned a given quota.
419    </description>
420  </query>
421 
422  <query id="GET_GROUPS_FOR_QUOTA" type="HQL">
423    <sql>
424      SELECT {1}
425      FROM GroupData g
426      WHERE g.quota = :quota
427    </sql>
428    <description>
429      A Hibernate query that gets groups
430      that has been assigned a given quota.
431    </description>
432  </query>
433
434  <query id="GET_SHAREABLE_ITEMS_FOR_ITEMKEY" type="HQL">
435    <sql>
436      SELECT s
437      FROM net.sf.basedb.core.data.ShareableData s
438      WHERE s.itemKey = :itemKey
439    </sql>
440    <description>
441      Get all items beeing shared to the specified item key.
442    </description>
443  </query>
444
445  <query id="GET_SHAREABLE_ITEMS_FOR_PROJECTKEY" type="HQL">
446    <sql>
447      SELECT s
448      FROM net.sf.basedb.core.data.ShareableData s
449      WHERE s.projectKey = :projectKey
450    </sql>
451    <description>
452      Get all items beeing shared to the specified project key.
453    </description>
454  </query>
455 
456  <query id="GET_SHARED_ITEMS" type="HQL">
457    <sql>
458      SELECT s
459      FROM net.sf.basedb.core.data.ShareableData s
460    </sql>
461    <description>
462      Get all shared items.
463    </description>
464  </query>
465
466  <query id="GET_OWNABLE_ITEMS_FOR_USER" type="HQL">
467    <sql>
468      SELECT o
469      FROM net.sf.basedb.core.data.OwnableData o
470      WHERE o.owner = :user
471    </sql>
472    <description>
473      Get all items that are owned by the specified user.
474    </description>
475  </query>
476 
477  <query id="GET_DISKCONSUMABLE_ITEMS_FOR_USER" type="HQL">
478    <sql>
479      SELECT o
480      FROM net.sf.basedb.core.data.DiskConsumableData o
481      WHERE o.owner = :user
482    </sql>
483    <description>
484      Get all diskconsumable items that are owned by the specified user.
485    </description>
486  </query>
487
488 
489  <query id="LOAD_USER_CLIENT_SETTINGS" type="HQL">
490    <sql>
491      SELECT s
492      FROM UserClientSettingData s
493      WHERE s.user = :user AND s.client = :client
494    </sql>
495    <description>
496      Load all settings for the specified user and client application.
497    </description>
498  </query>
499 
500  <query id="LOAD_USER_DEFAULT_SETTINGS" type="HQL">
501    <sql>
502      SELECT s
503      FROM UserDefaultSettingData s
504      WHERE s.user = :user
505    </sql>
506    <description>
507      Load all default settings for the specified user.
508    </description>
509  </query>
510
511  <query id="LOAD_CLIENT_DEFAULT_SETTINGS" type="HQL">
512    <sql>
513      SELECT s
514      FROM ClientDefaultSettingData s
515      WHERE s.client = :client
516    </sql>
517    <description>
518      Load all default settings for the specified client application.
519    </description>
520  </query>
521 
522  <query id="GET_MIME_TYPE_FROM_EXTENSION" type="HQL">
523    <sql>
524      SELECT s
525      FROM net.sf.basedb.core.data.MimeTypeData s
526      WHERE s.extension = :extension
527    </sql>
528    <description>
529      A Hibernate query that returns a MimeType given an extension.
530    </description>
531  </query>
532 
533  <query id="GET_TOTAL_DISKUSAGE_FOR_USER" type="HQL">
534    <sql>
535      SELECT sum(du.bytes)
536      FROM DiskUsageData du
537      WHERE du.user = :user
538      AND du.location = :location
539    </sql>
540    <description>
541      A Hibernate query that returns the total used quota
542      for the specified user at the specified location.
543    </description>
544  </query>
545 
546  <query id="GET_SPECIFIC_DISKUSAGE_FOR_USER" type="HQL">
547    <sql>
548      SELECT sum(du.bytes)
549      FROM DiskUsageData du
550      WHERE du.user = :user
551      AND du.location = :location
552      AND du.quotaType = :quotaType
553    </sql>
554    <description>
555      A Hibernate query that returns the used quota for the
556      specific quota type for the specified user at the
557      specified location.
558    </description>
559  </query>
560
561  <query id="GET_TOTAL_DISKUSAGE_FOR_GROUP" type="HQL">
562    <sql>
563      SELECT sum(du.bytes)
564      FROM DiskUsageData du
565      WHERE du.group = :group
566      AND du.location = :location
567    </sql>
568    <description>
569      A Hibernate query that returns the total used quota
570      for the specified group at the specified location.
571    </description>
572  </query>
573
574  <query id="GET_SPECIFIC_DISKUSAGE_FOR_GROUP" type="HQL">
575    <sql>
576      SELECT sum(du.bytes)
577      FROM DiskUsageData du
578      WHERE du.group = :group
579      AND du.location = :location
580      AND du.quotaType = :quotaType
581    </sql>
582    <description>
583      A Hibernate query that returns the used quota for the
584      specific quota type for the specified group at the
585      specified location.
586    </description>
587  </query>
588
589  <query id="GET_TOTAL_DISKUSAGE_SUMMARY" type="HQL">
590    <sql>
591      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
592      FROM DiskUsageData du
593      GROUP BY du.location, du.quotaType.systemId
594    </sql>
595    <description>
596      A Hibernate query that returns the total disk usage grouped
597      by location and quota type system id.
598    </description>
599  </query>
600
601  <query id="GET_DISKUSAGE_SUMMARY_FOR_USER" type="HQL">
602    <sql>
603      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
604      FROM DiskUsageData du
605      WHERE du.user = :user
606      GROUP BY du.location, du.quotaType.systemId
607    </sql>
608    <description>
609      A Hibernate query that returns the disk usage for a user grouped
610      by location and quota type system id.
611    </description>
612  </query>
613
614  <query id="GET_DISKUSAGE_SUMMARY_FOR_GROUP" type="HQL">
615    <sql>
616      SELECT SUM(du.bytes), du.location, du.quotaType.systemId
617      FROM DiskUsageData du
618      WHERE du.group = :group
619      GROUP BY du.location, du.quotaType.systemId
620    </sql>
621    <description>
622      A Hibernate query that returns the disk usage for a group grouped
623      by location and quota type system id.
624    </description>
625  </query>
626 
627  <query id="GET_FILES_IN_DIRECTORY" type="HQL">
628    <sql>
629      SELECT {1}
630      FROM FileData f
631      WHERE f.directory = :directory
632    </sql>
633    <description>
634      A Hibernate query that gets the files
635      in a given directory.
636    </description>
637  </query>
638 
639  <query id="GET_FILES_FOR_FILETYPE" type="HQL">
640    <sql>
641      SELECT {1}
642      FROM FileData f
643      WHERE f.fileType = :filetype
644    </sql>
645    <description>
646      A Hibernate query that gets the files
647      with a given filetype.
648    </description>
649  </query>
650
651  <query id="GET_SUBDIRECTORIES_IN_DIRECTORY" type="HQL">
652    <sql>
653      SELECT {1}
654      FROM DirectoryData d
655      WHERE d.parent = :directory
656    </sql>
657    <description>
658      A Hibernate query that gets the subdirectories
659      in a given directory.
660    </description>
661  </query>
662 
663  <query id="GET_HOME_DIRECTORIES" type="HQL">
664    <sql>
665      SELECT {1}
666      FROM UserData usr
667      WHERE usr.homeDirectory = :directory
668    </sql>
669    <description>
670      A Hibernate query that gets the users having
671      the specified directory as home directory.
672    </description>
673  </query>
674 
675  <query id="GET_EXPERIMENT_DIRECTORIES" type="HQL">
676    <sql>
677      SELECT {1}
678      FROM ExperimentData xpr
679      WHERE xpr.directory = :directory
680    </sql>
681    <description>
682      A Hibernate query that gets the experiments having
683      the specified directory as the plugin directory.
684    </description>
685  </query>
686
687  <query id="GET_SUBDIRECTORIES" type="HQL">
688    <sql>
689      SELECT dir
690      FROM DirectoryData dir
691      WHERE dir.parent = :parent
692    </sql>
693    <description>
694      A Hibernate query that returns all subdirectories in a directory.
695    </description>
696  </query>
697 
698  <query id="GET_SUBDIRECTORY_WITH_NAME" type="HQL">
699    <sql>
700      SELECT dir
701      FROM DirectoryData dir
702      WHERE dir.name = :name
703      AND dir.parent = :parent
704    </sql>
705    <description>
706      A Hibernate query that returns the a subdirectory with the
707      specified name in a given directory.
708    </description>
709  </query>
710
711  <query id="GET_FILE_TYPE_WITH_NAME" type="HQL">
712    <sql>
713      SELECT ft
714      FROM FileTypeData ft
715      WHERE ft.name = :name
716    </sql>
717    <description>
718      A Hibernate query that returns the file type with the specified
719      name.
720    </description>
721  </query>
722 
723  <query id="GET_QUOTA_TYPE_WITH_NAME" type="HQL">
724    <sql>
725      SELECT qt
726      FROM QuotaTypeData qt
727      WHERE qt.name = :name
728    </sql>
729    <description>
730      A Hibernate query that returns the quota type with the specified
731      name.
732    </description>
733  </query>
734 
735  <query id="GET_QUOTA_WITH_NAME" type="HQL">
736    <sql>
737      SELECT q
738      FROM QuotaData q
739      WHERE q.name = :name
740    </sql>
741    <description>
742      A Hibernate query that returns the quota with the specified
743      name.
744    </description>
745  </query>
746 
747  <query id="GET_GROUP_WITH_NAME" type="HQL">
748    <sql>
749      SELECT grp
750      FROM GroupData grp
751      WHERE grp.name = :name
752    </sql>
753    <description>
754      A Hibernate query that returns the group with the specified
755      name.
756    </description>
757  </query>
758 
759  <query id="GET_ROLE_WITH_NAME" type="HQL">
760    <sql>
761      SELECT rle
762      FROM RoleData rle
763      WHERE rle.name = :name
764    </sql>
765    <description>
766      A Hibernate query that returns the role with the specified
767      name.
768    </description>
769  </query>
770 
771  <query id="GET_PROTOCOL_TYPE_WITH_NAME" type="HQL">
772    <sql>
773      SELECT pt
774      FROM ProtocolTypeData pt
775      WHERE pt.name = :name
776    </sql>
777    <description>
778      A Hibernate query that returns the protocol type with the specified
779      name.
780    </description>
781  </query>
782 
783  <query id="GET_SOFTWARE_TYPE_WITH_NAME" type="HQL">
784    <sql>
785      SELECT st
786      FROM SoftwareTypeData st
787      WHERE st.name = :name
788    </sql>
789    <description>
790      A Hibernate query that returns the software type with the specified
791      name.
792    </description>
793  </query>
794 
795  <query id="GET_SOFTWARE_WITH_NAME" type="HQL">
796    <sql>
797      SELECT sw
798      FROM SoftwareData sw
799      WHERE sw.name = :name
800    </sql>
801    <description>
802      A Hibernate query that returns the software with the specified
803      name.
804    </description>
805  </query>
806 
807  <query id="GET_HARDWARE_TYPE_WITH_NAME" type="HQL">
808    <sql>
809      SELECT ht
810      FROM HardwareTypeData ht
811      WHERE ht.name = :name
812    </sql>
813    <description>
814      A Hibernate query that returns the hardware type with the specified
815      name.
816    </description>
817  </query>
818 
819  <query id="GET_HARDWARE_WITH_NAME" type="HQL">
820    <sql>
821      SELECT hw
822      FROM HardwareData hw
823      WHERE hw.name = :name
824    </sql>
825    <description>
826      A Hibernate query that returns the hardware with the specified
827      name.
828    </description>
829  </query>
830 
831  <query id="GET_PLATE_GEOMETRY_WITH_NAME" type="HQL">
832    <sql>
833      SELECT pg
834      FROM PlateGeometryData pg
835      WHERE pg.name = :name
836    </sql>
837    <description>
838      A Hibernate query that returns the plate geometry with the specified
839      name.
840    </description>
841  </query>
842
843  <query id="GET_PLATE_MAPPING_WITH_NAME" type="HQL">
844    <sql>
845      SELECT pm
846      FROM PlateMappingData pm
847      WHERE pm.name = :name
848    </sql>
849    <description>
850      A Hibernate query that returns the plate mapping with the specified
851      name.
852    </description>
853  </query>
854 
855  <query id="GET_LABEL_WITH_NAME" type="HQL">
856    <sql>
857      SELECT lbl
858      FROM LabelData lbl
859      WHERE lbl.name = :name
860    </sql>
861    <description>
862      A Hibernate query that returns the label with the specified
863      name.
864    </description>
865  </query>
866 
867  <query id="GET_ANNOTATION_TYPE_WITH_NAME" type="HQL">
868    <sql>
869      SELECT at
870      FROM AnnotationTypeData at
871      WHERE at.name = :name
872    </sql>
873    <description>
874      A Hibernate query that returns the annotation type with the specified
875      name.
876    </description>
877  </query>
878 
879  <query id="GET_NEWS_WITH_NAME" type="HQL">
880    <sql>
881      SELECT nws
882      FROM NewsData nws
883      WHERE nws.name = :name
884    </sql>
885    <description>
886      A Hibernate query that returns the news with the specified
887      name.
888    </description>
889  </query>
890
891  <query id="GET_FILE_IN_DIRECTORY" type="HQL">
892    <sql>
893      SELECT f
894      FROM FileData f
895      WHERE f.directory = :directory
896      AND f.name = :name
897    </sql>
898    <description>
899      A Hibernate query that returns the file with the specified
900      name in a given directory.
901    </description>
902  </query>
903
904  <query id="GET_PROTOCOLS_FOR_PROTOCOLTYPE" type="HQL">
905    <sql>
906      SELECT {1}
907      FROM ProtocolData p
908      WHERE p.protocolType = :protocolType
909    </sql>
910    <description>
911      Get the protocols the uses a protocol type.
912    </description>
913  </query>
914
915  <query id="GET_PLATEEVENTTYPES_FOR_PROTOCOLTYPE" type="HQL">
916    <sql>
917      SELECT {1}
918      FROM PlateEventTypeData pet
919      WHERE pet.protocolType = :protocolType
920    </sql>
921    <description>
922      Get the plate events types that uses a protocol type.
923    </description>
924  </query>
925 
926  <query id="GET_BIOMATERIALEVENTS_FOR_PROTOCOL" type="HQL">
927    <sql>
928      SELECT {1}
929      FROM BioMaterialEventData bme
930      WHERE bme.protocol = :protocol
931    </sql>
932    <description>
933      A Hibernate query that gets biomaterial
934      events using a protocol.
935    </description>
936  </query>
937
938  <query id="GET_PLATEEVENTS_FOR_PROTOCOL" type="HQL">
939    <sql>
940      SELECT {1}
941      FROM PlateEventData pe
942      WHERE pe.protocol = :protocol
943    </sql>
944    <description>
945      A Hibernate query thatgets plate events
946      using a protocol.
947    </description>
948  </query>
949
950  <query id="GET_ARRAYBATCHES_FOR_PROTOCOL" type="HQL">
951    <sql>
952      SELECT {1}
953      FROM ArrayBatchData ab
954      WHERE ab.protocol = :protocol
955    </sql>
956    <description>
957      A Hibernate query that gets array batches
958      using a protocol.
959    </description>
960  </query>
961
962  <query id="GET_SCANS_FOR_PROTOCOL" type="HQL">
963    <sql>
964      SELECT {1}
965      FROM ScanData sc
966      WHERE sc.protocol = :protocol
967    </sql>
968    <description>
969      A Hibernate query that gets scans
970      using a protocol.
971    </description>
972  </query>
973
974  <query id="GET_RAWBIOASSAYS_FOR_PROTOCOL" type="HQL">
975    <sql>
976      SELECT {1}
977      FROM RawBioAssayData rba
978      WHERE rba.protocol = :protocol
979    </sql>
980    <description>
981      A Hibernate query that gets raw bioassays
982      using a protocol.
983    </description>
984  </query>
985
986  <query id="FIND_USED_FILES" type="HQL">
987    <sql>
988      SELECT fad
989      FROM net.sf.basedb.core.data.FileAttachableData fad
990      WHERE fad.file = :file
991    </sql>
992    <description>
993      Load the files that is used by any FileAttachableData.
994    </description>
995  </query>
996
997  <query id="GET_SPOTIMAGES_FOR_FILE" type="HQL">
998    <sql>
999      SELECT {1}
1000      FROM SpotImagesData spi
1001      WHERE spi.redImageFile = :file
1002      OR spi.greenImageFile = :file
1003      OR spi.blueImageFile = :file
1004      OR spi.spotImagesFile = :file
1005    </sql>
1006    <description>
1007      A Hibernate query that gets spot images where a given
1008      file is used as one of the color components or holds the generated spot images.
1009    </description>
1010  </query>
1011 
1012  <query id="GET_HARDWARE_FOR_TYPE" type="HQL">
1013    <sql>
1014      SELECT {1}
1015      FROM HardwareData hw
1016      WHERE hw.hardwareType = :hardwaretype
1017    </sql>
1018    <description>
1019      A Hibernate query that gets hardware items
1020      of the given hardware type.
1021    </description>
1022  </query>
1023
1024  <query id="GET_SCANS_FOR_SCANNER" type="HQL">
1025    <sql>
1026      SELECT {1}
1027      FROM ScanData scn
1028      WHERE scn.scanner = :scanner
1029    </sql>
1030    <description>
1031      A Hibernate query that gets scans which
1032      uses a given scanner (hardware).
1033    </description>
1034  </query>
1035 
1036  <query id="GET_ARRAYBATCHES_FOR_PRINTROBOT" type="HQL">
1037    <sql>
1038      SELECT {1}
1039      FROM ArrayBatchData ab
1040      WHERE ab.printRobot = :printrobot
1041    </sql>
1042    <description>
1043      A Hibernate query that gets array batches which
1044      uses a given print robot (hardware).
1045    </description>
1046  </query>
1047 
1048  <query id="GET_BIOMATERIALEVENTS_FOR_HARDWARE" type="HQL">
1049    <sql>
1050      SELECT {1}
1051      FROM BioMaterialEventData bme
1052      WHERE bme.hardware = :hardware
1053    </sql>
1054    <description>
1055      A Hibernate query that gets biomaterial events which
1056      uses a given hardware.
1057    </description>
1058  </query>
1059 
1060  <query id="GET_PLATEEVENTS_FOR_HARDWARE" type="HQL">
1061    <sql>
1062      SELECT {1}
1063      FROM PlateEventData ple
1064      WHERE ple.hardware = :hardware
1065    </sql>
1066    <description>
1067      A Hibernate query that gets plates events which
1068      uses a given hardware.
1069    </description>
1070  </query>
1071
1072  <query id="GET_REPORTERS_FOR_REPORTERTYPE" type="HQL">
1073    <sql>
1074      SELECT {1}
1075      FROM ReporterData rpt
1076      WHERE rpt.reporterType = :reporterType
1077    </sql>
1078    <description>
1079      A Hibernate query that gets reporter items
1080      of the given reporter type.
1081    </description>
1082  </query>
1083
1084  <query id="GET_REPORTER_FOR_EXTERNAL_ID" type="HQL">
1085    <sql>
1086      SELECT rpt
1087      FROM ReporterData rpt
1088      WHERE rpt.externalId = :externalId
1089    </sql>
1090    <description>
1091      A Hibernate query that finds the reporter with a given external id.
1092    </description>
1093  </query>
1094 
1095  <query id="GET_SOFTWARE_FOR_SOFTWARETYPE" type="HQL">
1096    <sql>
1097      SELECT {1}
1098      FROM SoftwareData sw
1099      WHERE sw.softwareType = :softwaretype
1100    </sql>
1101    <description>
1102      A Hibernate query that gets software items
1103      of the given software type.
1104    </description>
1105  </query>
1106
1107  <query id="GET_RAWBIOASSAYS_FOR_SOFTWARE" type="HQL">
1108    <sql>
1109      SELECT {1}
1110      FROM RawBioAssayData rba
1111      WHERE rba.software = :software
1112    </sql>
1113    <description>
1114      A Hibernate query that gets the raw bioassays
1115      produced from a given software.
1116    </description>
1117  </query>
1118
1119  <query id="GET_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
1120    <sql>
1121      SELECT {1}
1122      FROM AnnotationData a
1123      WHERE a.annotationType = :annotationType
1124    </sql>
1125    <description>
1126      A Hibernate query that gets annotations
1127      of the given annotation type.
1128    </description>
1129  </query>
1130 
1131  <query id="GET_EXPERIMENTS_FOR_ANNOTATIONTYPE" type="HQL">
1132    <sql>
1133      SELECT {1}
1134      FROM ExperimentData exp
1135      JOIN exp.experimentalFactors ef
1136      WHERE ef = :annotationType
1137    </sql>
1138    <description>
1139      A Hibernate query that gets experiments
1140      where the given annotation type is used as an experimental factor.
1141    </description>
1142  </query>
1143 
1144  <query id="GET_PROTOCOLS_FOR_ANNOTATIONTYPE" type="HQL">
1145    <sql>
1146      SELECT {1}
1147      FROM ProtocolData prt
1148      JOIN prt.parameters pp
1149      WHERE pp = :annotationType
1150    </sql>
1151    <description>
1152      A Hibernate query that gets protocols
1153      where the given annotation type is used as a protocol parameter.
1154    </description>
1155  </query>
1156
1157  <query id="GET_SAMPLES_FOR_BIOSOURCE" type="HQL">
1158    <sql>
1159      SELECT {1}
1160      FROM SampleData s
1161      WHERE s.parent = :biosource
1162    </sql>
1163    <description>
1164      A Hibernate query that gets samples
1165      created from a given biosource.
1166    </description>
1167  </query>
1168
1169  <query id="GET_EXTRACTS_FOR_SAMPLE" type="HQL">
1170    <sql>
1171      SELECT {1}
1172      FROM ExtractData e
1173      WHERE e.parent = :sample
1174    </sql>
1175    <description>
1176      A Hibernate query that gets extracts
1177      created from a given sample.
1178    </description>
1179  </query>
1180 
1181  <query id="GET_LABELED_EXTRACTS_FOR_EXTRACT" type="HQL">
1182    <sql>
1183      SELECT {1}
1184      FROM LabeledExtractData le
1185      WHERE le.parent = :extract
1186    </sql>
1187    <description>
1188      A Hibernate query that gets labeled extracts
1189      created from a given extract.
1190    </description>
1191  </query>
1192
1193  <query id="GET_LABELED_EXTRACTS_FOR_LABEL" type="HQL">
1194    <sql>
1195      SELECT {1}
1196      FROM LabeledExtractData le
1197      WHERE le.label = :label
1198    </sql>
1199    <description>
1200      A Hibernate query that gets labeled extracts
1201      with a given label.
1202    </description>
1203  </query>
1204
1205  <query id="GET_SOURCEEVENTS_FOR_BIOMATERIAL" type="HQL">
1206    <sql>
1207      SELECT {1}
1208      FROM BioMaterialEventData bme
1209      JOIN bme.sources src
1210      WHERE index(src) = :bioMaterial
1211    </sql>
1212    <description>
1213      A Hibernate query that gets the events where a given
1214      biomaterial has been part of as a source biomaterial, ie. the number
1215      of pooled biomaterials that have been created from it.
1216    </description>
1217  </query>
1218
1219  <query id="GET_CREATION_EVENT_FOR_BIOMATERIAL" type="HQL">
1220    <sql>
1221      SELECT evt
1222      FROM BioMaterialEventData evt
1223      WHERE evt.bioMaterial = :bioMaterial
1224      AND evt.eventType = 1
1225    </sql>
1226    <description>
1227      A Hibernate query that returns the creation event for
1228      a biomaterial.
1229    </description>
1230  </query>
1231 
1232  <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL">
1233    <sql>
1234      SELECT count(*)
1235      FROM MessageData msg
1236      WHERE msg.to = :user AND msg.read = false AND msg.removed = false
1237    </sql>
1238    <description>
1239      A Hibernate query that counts the number of
1240      unread messages for a given user
1241    </description>
1242  </query>
1243 
1244  <query id="GET_PLATETYPES_FOR_PLATEGEOMETRY" type="HQL">
1245    <sql>
1246      SELECT {1}
1247      FROM PlateTypeData pt
1248      WHERE pt.plateGeometry = :plateGeometry
1249    </sql>
1250    <description>
1251      A Hibernate query that gets the
1252      plate types using a given plate geometry
1253    </description>
1254  </query>
1255 
1256  <query id="GET_PLATEMAPPINGS_FOR_PLATEGEOMETRY" type="HQL">
1257    <sql>
1258      SELECT {1}
1259      FROM PlateMappingData pm
1260      WHERE pm.sourceGeometry = :plateGeometry
1261      OR pm.destinationGeometry = :plateGeometry
1262    </sql>
1263    <description>
1264      A Hibernate query that gets the
1265      plate mappings using a given plate geometry as source or destination
1266    </description>
1267  </query>
1268
1269  <query id="GET_PLATES_FOR_PLATETYPE" type="HQL">
1270    <sql>
1271      SELECT {1}
1272      FROM PlateData p
1273      WHERE p.plateType = :plateType
1274    </sql>
1275    <description>
1276      A Hibernate query that gets
1277      plates of a specific plate type.
1278    </description>
1279  </query>
1280
1281  <query id="GET_PLATEEVENTS_FOR_PLATEEVENTTYPE" type="HQL">
1282    <sql>
1283      SELECT {1}
1284      FROM PlateEventData pe
1285      WHERE pe.plateEventType = :plateEventType
1286    </sql>
1287    <description>
1288      A Hibernate query that gets
1289      plate events of the given plate event type.
1290    </description>
1291  </query>
1292
1293  <query id="GET_CHILDPLATES_FOR_PLATE" type="HQL">
1294    <sql>
1295      SELECT {1}
1296      FROM PlateData p
1297      JOIN p.parents pp
1298      WHERE pp = :plate
1299    </sql>
1300    <description>
1301      A Hibernate query that gets the
1302      child plates for a given plate.
1303    </description>
1304  </query>
1305
1306  <query id="GET_ARRAYDESIGNS_FOR_PLATE" type="HQL">
1307    <sql>
1308      SELECT {1}
1309      FROM ArrayDesignData ad
1310      JOIN ad.plates p
1311      WHERE p = :plate
1312    </sql>
1313    <description>
1314      A Hibernate query that gets the
1315      array designs that has used a given plate.
1316    </description>
1317  </query>
1318
1319  <query id="GET_PLATES_FOR_PLATEMAPPING" type="HQL">
1320    <sql>
1321      SELECT {1}
1322      FROM PlateData p
1323      WHERE p.plateMapping = :plateMapping
1324    </sql>
1325    <description>
1326      A Hibernate query that gets the
1327      plates that has been created from a given plate mapping.
1328    </description>
1329  </query>
1330 
1331  <query id="GET_FEATURES_FOR_WELL" type="HQL">
1332    <sql>
1333      SELECT {1}
1334      FROM FeatureData f
1335      WHERE f.well = :well
1336    </sql>
1337    <description>
1338      A Hibernate query that gets the
1339      features using a given well.
1340    </description>
1341  </query>
1342
1343  <query id="COUNT_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1344    <sql>
1345      SELECT count(*)
1346      FROM FeatureData f
1347      WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
1348    </sql>
1349    <description>
1350      A Hibernate query that counts the number of
1351      features on a given array design
1352    </description>
1353  </query>
1354
1355
1356  <query id="GET_CHILDWELLS_FOR_WELL" type="HQL">
1357    <sql>
1358      SELECT {1}
1359      FROM Well w
1360      WHERE w.parent = :well
1361    </sql>
1362    <description>
1363      A Hibernate query that gets the
1364      child wells of a given well.
1365    </description>
1366  </query>
1367
1368  <query id="GET_PLUGINCONFIGURATIONS_FOR_PLUGINDEFINITION" type="HQL">
1369    <sql>
1370      SELECT {1}
1371      FROM PluginConfigurationData pc
1372      WHERE pc.pluginDefinition = :pluginDefinition
1373    </sql>
1374    <description>
1375      A Hibernate query that gets plugin configurations
1376      using a plugin definition.
1377    </description>
1378  </query>
1379 
1380  <query id="GET_JOBS_FOR_PLUGINCONFIGURATION" type="HQL">
1381    <sql>
1382      SELECT {1}
1383      FROM JobData j
1384      WHERE j.pluginConfiguration = :pluginConfiguration
1385    </sql>
1386    <description>
1387      A Hibernate query that gets the jobs
1388      using a specific plugin configuration.
1389    </description>
1390  </query>
1391 
1392  <query id="GET_JOBS_FOR_PLUGINDEFINITION" type="HQL">
1393    <sql>
1394      SELECT {1}
1395      FROM JobData j
1396      WHERE j.pluginDefinition = :pluginDefinition
1397    </sql>
1398    <description>
1399      A Hibernate query that gets the jobs
1400      using a specific plugin definition.
1401    </description>
1402  </query>
1403
1404  <query id="FIND_JOBS_IN_QUEUE" type="HQL">
1405    <sql>
1406      SELECT job
1407      FROM JobData job
1408      WHERE job.status = :status
1409      AND job.type = :type
1410      ORDER BY job.priority ASC, job.created ASC
1411    </sql>
1412    <description>
1413      A Hibernate query that loads plugin jobs in the job queue waiting to be
1414      executed sorted by priority and waiting type.
1415    </description>
1416  </query>
1417 
1418  <query id="FIND_INTERNAL_JOBS_IN_QUEUE" type="HQL">
1419    <sql>
1420      SELECT job
1421      FROM JobData job
1422      WHERE job.status = :status
1423      AND job.type = :type
1424      AND job.pluginDefinition.useInternalJobQueue = true
1425      ORDER BY job.priority ASC, job.created ASC
1426    </sql>
1427    <description>
1428      A Hibernate query that loads plugin jobs in the job queue waiting to be
1429      executed sorted by priority and waiting type. It should only return
1430      jobs where the plug-in setting useInternalJobQueue=true
1431    </description>
1432  </query>
1433 
1434  <query id="GET_ARRAYSLIDES_FOR_BATCH" type="HQL">
1435    <sql>
1436      SELECT {1}
1437      FROM ArraySlideData a
1438      WHERE a.arrayBatch = :arrayBatch
1439    </sql>
1440    <description>
1441      A Hibernate query that gets the array slides
1442      in an array batch.
1443    </description>
1444  </query>
1445
1446  <query id="GET_ARRAYBATCHES_FOR_ARRAYDESIGN" type="HQL">
1447    <sql>
1448      SELECT {1}
1449      FROM ArrayBatchData a
1450      WHERE a.arrayDesign = :arrayDesign
1451    </sql>
1452    <description>
1453      A Hibernate query that gets array batches
1454      that uses a specific array design.
1455    </description>
1456  </query>
1457
1458  <query id="GET_RAWBIOASSAYS_FOR_ARRAYDESIGN" type="HQL">
1459    <sql>
1460      SELECT {1}
1461      FROM RawBioAssayData rba
1462      WHERE rba.arrayDesign = :arrayDesign
1463    </sql>
1464    <description>
1465      A Hibernate query that gets raw bioassays
1466      that uses a specific array design.
1467    </description>
1468  </query>
1469
1470  <query id="GET_SCANS_FOR_HYBRIDIZATION" type="HQL">
1471    <sql>
1472      SELECT {1}
1473      FROM ScanData scn
1474      WHERE scn.hybridization = :hybridization
1475    </sql>
1476    <description>
1477      A Hibernate query that gets scans
1478      that uses a specific hybridization.
1479    </description>
1480  </query>
1481
1482  <query id="GET_RAWBIOASSAYS_FOR_SCAN" type="HQL">
1483    <sql>
1484      SELECT {1}
1485      FROM RawBioAssayData rba
1486      WHERE rba.scan = :scan
1487    </sql>
1488    <description>
1489      A Hibernate query that gets raw bioassays
1490      created from a specific scan.
1491    </description>
1492  </query>
1493
1494  <query id="GET_IMAGES_FOR_SCAN" type="HQL">
1495    <sql>
1496      SELECT {1}
1497      FROM ImageData img
1498      WHERE img.scan = :scan
1499    </sql>
1500    <description>
1501      A Hibernate query that gets images
1502      created from a specific scan.
1503    </description>
1504  </query>
1505
1506  <query id="GET_FEATURE_BY_ALL_COORDINATES" type="HQL">
1507    <sql>
1508      SELECT f
1509      FROM FeatureData f
1510      WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
1511      AND f.row = :row
1512      AND f.column = :column
1513      AND
1514      (
1515        (f.arrayDesignBlock.blockNumber = :block AND :block &lt;&gt; 0)
1516        OR
1517        (:block = 0 AND f.arrayDesignBlock.metaGridX = :metaGridX
1518        AND f.arrayDesignBlock.metaGridY = :metaGridY)
1519      )
1520    </sql>
1521    <description>
1522      A Hibernate query that finds a feature on a given array design
1523      with specified block and coordinates.
1524    </description>
1525  </query>
1526 
1527  <query id="PRELOAD_FEATURES" type="HQL">
1528    <sql>
1529      SELECT f
1530      FROM FeatureData f
1531      JOIN FETCH f.arrayDesignBlock b
1532      LEFT JOIN FETCH f.reporter
1533      WHERE b.arrayDesign = :arrayDesign
1534    </sql>
1535    <description>
1536      A Hibernate query that loads features, blocks and reporters
1537      for a single array design.
1538    </description>
1539  </query>
1540 
1541  <query id="DELETE_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1542    <sql>
1543      DELETE FROM Features f, ArrayDesignBlocks adb
1544      WHERE adb.id = f.arraydesignblock_id AND adb.arraydesign_id = ?
1545    </sql>
1546    <description>
1547      A Hibernate query that deletes all features for an array design.
1548    </description>
1549  </query>
1550
1551  <query id="GET_PLUGINTYPE_FOR_INTERFACENAME" type="HQL">
1552    <sql>
1553      SELECT plt
1554      FROM PluginTypeData plt
1555      WHERE plt.interfaceName = :interfaceName
1556    </sql>
1557    <description>
1558      Load a plugin type when you know the interface name.
1559    </description>
1560  </query>
1561
1562  <query id="GET_PLUGINDEFINITION_FOR_CLASSNAME" type="HQL">
1563    <sql>
1564      SELECT pd
1565      FROM PluginDefinitionData pd
1566      WHERE pd.className = :className
1567    </sql>
1568    <description>
1569      Load a plugin definition when you know the class name.
1570    </description>
1571  </query>
1572
1573  <query id="GET_PLUGINCONFIGURATION_FOR_PLUGIN_WITH_NAME" type="HQL">
1574    <sql>
1575      SELECT pc
1576      FROM PluginConfigurationData pc
1577      WHERE pc.pluginDefinition.className = :className
1578      AND pc.name = :name
1579    </sql>
1580    <description>
1581      Load a plugin configuration for a given plug-in and with a given name
1582    </description>
1583  </query>
1584
1585
1586  <query id="GET_EXPERIMENTS_FOR_RAWBIOASSAY" type="HQL">
1587    <sql>
1588      SELECT {1}
1589      FROM ExperimentData xp
1590      JOIN xp.rawBioAssays rba
1591      WHERE rba = :rawBioAssay
1592    </sql>
1593    <description>
1594      A Hibernate query that gets the experiments
1595      using a specific raw bioassay.
1596    </description>
1597  </query>
1598 
1599  <query id="GET_TRANSFORMATIONS_FOR_RAWBIOASSAY" type="HQL">
1600    <sql>
1601      SELECT {1}
1602      FROM TransformationData trf
1603      JOIN trf.rawSources rba
1604      WHERE rba = :rawBioAssay
1605    </sql>
1606    <description>
1607      A Hibernate query that gets the transformations
1608      using a specifiec raw bioassay.
1609    </description>
1610  </query>
1611 
1612  <query id="GET_TRANSFORMATIONS_FOR_JOB" type="HQL">
1613    <sql>
1614      SELECT {1}
1615      FROM TransformationData trf
1616      WHERE trf.job = :job
1617    </sql>
1618    <description>
1619      A Hibernate query that gets transformations
1620      linked to a job.
1621    </description>
1622  </query>
1623
1624  <query id="FIND_CHILD_BIOASSAYSETS" type="HQL">
1625    <sql>
1626      SELECT bas
1627      FROM BioAssaySetData bas
1628      WHERE bas.transformation.source = :parent
1629    </sql>
1630    <description>
1631      A Hibernate query that returns all bioassaysets that are
1632      children to a specified parent bioassayset.
1633    </description>
1634  </query>
1635 
1636  <query id="FIND_DATACUBES_FOR_BIOASSAYSETS" type="HQL">
1637    <sql>
1638      SELECT DISTINCT cbe
1639      FROM BioAssaySetData bas
1640      JOIN bas.dataCubeLayer.dataCube cbe
1641      WHERE bas IN (:basList)
1642    </sql>
1643    <description>
1644      A Hibernate query that returns all data cubes that are
1645      used by the specified list of bioassaysets
1646    </description>
1647  </query>
1648 
1649  <query id="FIND_DATACUBES_USED_BY_OTHERS" type="HQL">
1650    <sql>
1651      SELECT DISTINCT cbe
1652      FROM BioAssaySetData bas
1653      JOIN bas.dataCubeLayer.dataCube cbe
1654      WHERE bas NOT IN (:basList)
1655      AND cbe IN (:possibleCubes)
1656    </sql>
1657    <description>
1658      A Hibernate query that, given a list of data cubes and bioassaysets,
1659      returns all of those data cubes that are also used by other bioassaysets.
1660    </description>
1661  </query>
1662
1663  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS" type="HQL">
1664    <sql>
1665      SELECT lay
1666      FROM BioAssaySetData bas
1667      JOIN bas.dataCubeLayer lay
1668      WHERE bas IN (:basList)
1669    </sql>
1670    <description>
1671      A Hibernate query that returns all data cube layers that are
1672      used by the specified list of bioassaysets
1673    </description>
1674  </query>
1675 
1676  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1677    <sql>
1678      SELECT lay
1679      FROM BioAssaySetData bas
1680      JOIN bas.dataCubeLayer lay
1681      WHERE bas IN (:basList)
1682      AND lay.dataCube NOT IN (:deletedCubes)
1683    </sql>
1684    <description>
1685      A Hibernate query that returns all data cube layers that are
1686      used by the specified list of bioassaysets but not are part of the
1687      list of already deleted data cubes.
1688    </description>
1689  </query>
1690
1691  <query id="FIND_DATACUBELAYERS_USED_BY_OTHERS" type="HQL">
1692    <sql>
1693      SELECT lay
1694      FROM BioAssaySetData bas
1695      JOIN bas.dataCubeLayer lay
1696      WHERE bas NOT IN (:basList)
1697      AND lay IN (:possibleLayers)
1698    </sql>
1699    <description>
1700      A Hibernate query that, given a list of data cube layers and bioassaysets,
1701      returns all of those data cube layers that are also used by other bioassaysets.
1702    </description>
1703  </query>
1704
1705  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS" type="HQL">
1706    <sql>
1707      SELECT flt
1708      FROM BioAssaySetData bas
1709      JOIN bas.dataCubeFilter flt
1710      WHERE bas IN (:basList)
1711    </sql>
1712    <description>
1713      A Hibernate query that returns all data cube filters that are
1714      used by the specified list of bioassaysets
1715    </description>
1716  </query>
1717 
1718  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1719    <sql>
1720      SELECT flt
1721      FROM BioAssaySetData bas
1722      JOIN bas.dataCubeFilter flt
1723      WHERE bas IN (:basList)
1724      AND flt.dataCube NOT IN (:deletedCubes)
1725    </sql>
1726    <description>
1727      A Hibernate query that returns all data cube filters that are
1728      used by the specified list of bioassaysets but not are part of the
1729      list of already deleted data cubes.
1730    </description>
1731  </query>
1732
1733  <query id="FIND_DATACUBEFILTERS_USED_BY_OTHERS" type="HQL">
1734    <sql>
1735      SELECT flt
1736      FROM BioAssaySetData bas
1737      JOIN bas.dataCubeFilter flt
1738      WHERE bas NOT IN (:basList)
1739      AND flt IN (:possibleFilters)
1740    </sql>
1741    <description>
1742      A Hibernate query that, given a list of data cube filters and bioassaysets,
1743      returns all of those data cube filters that are also used by other bioassaysets.
1744    </description>
1745  </query>
1746
1747  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS" type="HQL">
1748    <sql>
1749      SELECT dcev
1750      FROM BioAssaySetData bas
1751      JOIN bas.extraValues ev
1752      JOIN ev.dataCubeExtraValue dcev
1753      WHERE bas IN (:basList)
1754    </sql>
1755    <description>
1756      A Hibernate query that returns all data cube extra values that are
1757      used by the specified list of bioassaysets
1758    </description>
1759  </query>
1760 
1761  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1762    <sql>
1763      SELECT dcev
1764      FROM BioAssaySetData bas
1765      JOIN bas.extraValues ev
1766      JOIN ev.dataCubeExtraValue dcev
1767      WHERE bas IN (:basList)
1768      AND dcev.dataCube NOT IN (:deletedCubes)
1769    </sql>
1770    <description>
1771      A Hibernate query that returns all data cube extra values that are
1772      used by the specified list of bioassaysets but not are part of the
1773      list of already deleted data cubes.
1774    </description>
1775  </query>
1776
1777  <query id="FIND_DATACUBEEXTRAVALUES_USED_BY_OTHERS" type="HQL">
1778    <sql>
1779      SELECT dcev
1780      FROM BioAssaySetData bas
1781      JOIN bas.extraValues ev
1782      JOIN ev.dataCubeExtraValue dcev
1783      WHERE bas NOT IN (:basList)
1784      AND dcev IN (:possibleExtraValues)
1785    </sql>
1786    <description>
1787      A Hibernate query that, given a list of data cube extra values and bioassaysets,
1788      returns all of those data cube extra values that are also used by other bioassaysets.
1789    </description>
1790  </query>
1791
1792  <query id="GET_EXTRAVALUETYPE_FOR_EXTERNAL_ID" type="HQL">
1793    <sql>
1794      SELECT evt
1795      FROM ExtraValueTypeData evt
1796      WHERE evt.externalId = :externalId
1797    </sql>
1798    <description>
1799      Load an extra value type when you know the external id.
1800    </description>
1801  </query>
1802
1803  <query id="GET_EXTRAVALUES_FOR_EXTRAVALUETYPE" type="HQL">
1804    <sql>
1805      SELECT {1}
1806      FROM ExtraValueData ev
1807      WHERE ev.extraValueType = :extraValueType
1808    </sql>
1809    <description>
1810      A Hibernate query that gets extra values
1811      of a specific type.
1812    </description>
1813  </query>
1814 
1815  <query id="LOAD_CONTEXT_NAMES" type="HQL">
1816    <sql>
1817      SELECT ctx.id, ctx.name
1818      FROM ContextData ctx
1819      WHERE ctx.client = :client AND
1820      (ctx.user = :user OR ctx.public = true)
1821      AND ctx.itemType = :itemType
1822      AND ctx.subContext = :subContext
1823      ORDER BY ctx.name
1824    </sql>
1825    <description>
1826      A Hibernate query that selects the id and name of all contexts for
1827      a user and item type. The names should be sorted in ascending order.
1828    </description>
1829  </query>
1830 
1831  <query id="LOAD_CONTEXT_BY_NAME" type="HQL">
1832    <sql>
1833      SELECT ctx
1834      FROM ContextData ctx
1835      WHERE ctx.user = :user
1836      AND ctx.client = :client
1837      AND ctx.itemType = :itemType
1838      AND ctx.subContext  = :subContext
1839      AND ctx.name = :name
1840    </sql>
1841    <description>
1842      A Hibernate query that load a context given the user, client,
1843      item type, subcontext and name of the context.
1844    </description>
1845  </query>
1846 
1847  <query id="COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT" type="HQL">
1848    <sql>
1849      SELECT plg.mainType, count(DISTINCT plg.id)
1850      FROM PluginDefinitionData plg
1851      JOIN plg.guiContexts gcx
1852      LEFT JOIN plg.configurations cfg
1853      WITH true = :hasConfigPermission OR cfg.owner.id = :owner
1854        OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
1855      WHERE
1856        (true = :hasPluginPermission OR plg.owner.id = :owner
1857        OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
1858      AND gcx.itemType = :itemType AND gcx.contextType = :contextType
1859      AND (
1860        (plg.requiresConfiguration = false)
1861        OR
1862        (plg.requiresConfiguration = true AND NOT cfg.id IS NULL)
1863      )
1864      GROUP BY plg.mainType
1865    </sql>
1866    <description>
1867      A Hibernate query that counts the number of plugins available for a
1868      given GUI context grouped by the main type of the plugins taking
1869      the requirement of configurations and user permissions into account.
1870    </description>
1871  </query>
1872 
1873  <query id="GET_FORMULA_WITH_NAME_AND_CHANNELS" type="HQL">
1874    <sql>
1875      SELECT fml
1876      FROM FormulaData fml
1877      WHERE fml.name = :name
1878      AND fml.channels = :channels
1879    </sql>
1880    <description>
1881      A Hibernate query that loads a formula with a given name and number
1882      of channels.
1883    </description>
1884  </query>
1885
1886  <query id="GET_FORMULA_WITH_NAME_AND_TYPE" type="HQL">
1887    <sql>
1888      SELECT fml
1889      FROM FormulaData fml
1890      WHERE fml.name = :name
1891      AND fml.rawDataType = :rawDataType
1892    </sql>
1893    <description>
1894      A Hibernate query that loads a formula with a given name and raw data type.
1895    </description>
1896  </query>
1897 
1898  <query id="GET_HELP_FOR_EXTERNAL_ID" type="HQL">
1899    <sql>
1900      SELECT hlp
1901      FROM HelpData hlp
1902      WHERE hlp.externalId = :externalId AND hlp.client = :client
1903    </sql>
1904    <description>
1905      A Hibernate query that loads a help text.
1906    </description>
1907  </query>
1908 
1909  <query id="GET_SCHEMA_VERSION" type="HQL">
1910    <sql>
1911      SELECT sv
1912      FROM SchemaVersionData sv
1913    </sql>
1914    <description>
1915      A Hibernate query that loads the schema version (there should only be one record).
1916    </description>
1917  </query>
1918 
1919  <query id="SET_SCHEMA_VERSION" type="HQL">
1920    <sql>
1921      UPDATE SchemaVersionData sv
1922      SET sv.schemaVersion = :schemaVersion,
1923      sv.build = :build
1924    </sql>
1925    <description>
1926      A Hibernate query that updates the schema version and build number.
1927    </description>
1928  </query>
1929 
1930  <query id="SET_PROJECT_ID_FOR_JOBS" type="HQL">
1931    <sql>
1932      UPDATE JobData job
1933      SET job.activeProjectId = 0
1934      WHERE job.activeProjectId IS NULL
1935    </sql>
1936    <description>
1937      A Hibernate query that sets the active project ID for all
1938      jobs to 0 if they have a null value.
1939    </description>
1940  </query>
1941
1942  <query id="GET_PRIMARY_ANNOTATION" type="HQL">
1943    <sql>
1944      SELECT ad
1945      FROM AnnotationData ad
1946      WHERE ad.annotationType = :annotationType
1947      AND ad.annotationSet = :annotationSet
1948    </sql>
1949    <description>
1950      A Hibernate query that loads the primary annotation of a specific
1951      annotation type for a given annotation set.
1952    </description>
1953  </query>
1954 
1955  <query id="GET_DIRECTLY_INHERITED_ANNOTATION" type="HQL">
1956    <sql>
1957      SELECT ad
1958      FROM AnnotationData ad
1959      JOIN ad.inheritingSets ans
1960      WHERE ad.annotationType = :annotationType
1961      AND ans = :annotationSet
1962    </sql>
1963    <description>
1964      A Hibernate query that loads an directly inherited annotation of a specific
1965      annotation type for a given annotation set. A directly inhertited annotation
1966      is an annotation that is linked to the specified annotation set.
1967    </description>
1968  </query>
1969
1970  <query id="GET_INDIRECTLY_INHERITED_ANNOTATION" type="HQL">
1971    <sql>
1972      SELECT ad
1973      FROM AnnotationData ad
1974      JOIN ad.annotationSet.inheritingSets ians
1975      WHERE ad.annotationType = :annotationType
1976      AND ians = :annotationSet
1977    </sql>
1978    <description>
1979      A Hibernate query that loads an indirectly inherited annotation of a specific
1980      annotation type for a given annotation set. An indirectly inherited annotation
1981      is an annotation which belongs to an annotation set which is inherited by
1982      the given annotation set.
1983    </description>
1984  </query>
1985 
1986  <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL">
1987    <sql>
1988      UPDATE ExperimentData xpm
1989      SET xpm.bytes = xpm.bytes + :addedBytes
1990      WHERE xpm.id = :experiment
1991    </sql>
1992    <description>
1993      A Hibernate query that updates the number of bytes used by an experiment.
1994    </description>
1995  </query>
1996
1997  <query id="UPDATE_BYTES_FOR_DATACUBE" type="HQL">
1998    <sql>
1999      UPDATE DataCubeData dcd
2000      SET dcd.bytes = dcd.bytes + :addedBytes
2001      WHERE dcd.id = :dataCube
2002    </sql>
2003    <description>
2004      A Hibernate query that updates the number of bytes used by a data cube.
2005    </description>
2006  </query>
2007 
2008  <query id="GET_REMOVED_ITEMS" type="HQL">
2009    <sql>
2010      SELECT trash
2011      FROM net.sf.basedb.core.data.RemovableData trash
2012      WHERE trash.removed = true
2013    </sql>
2014    <description>
2015      A Hibernate query that loads all items flagged for deletion.
2016    </description>
2017  </query>
2018 
2019  <query id="UPDATE_REMAINING_QUANTITY" type="HQL">
2020    <sql>
2021      UPDATE MeasuredBioMaterialData mbm
2022      SET mbm.remainingQuantity = mbm.remainingQuantity - :used
2023      WHERE mbm = :bioMaterial
2024    </sql>
2025    <description>
2026      A Hibernate query that adds/removes the remaining quantity on a
2027      measuered biomaterial.
2028    </description>
2029  </query>
2030
2031  <query id="SET_REMAINING_QUANTITY" type="HQL">
2032    <sql>
2033      UPDATE MeasuredBioMaterialData mbm
2034      SET mbm.remainingQuantity = :remain
2035      WHERE mbm = :bioMaterial
2036    </sql>
2037    <description>
2038      A Hibernate query that sets the remaining quantity on a
2039      measuered biomaterial.
2040    </description>
2041  </query>
2042
2043
2044  <query id="GET_ANYTOANY_FOR_NAME" type="HQL">
2045    <sql>
2046      SELECT ata
2047      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 loads the any-to-any link with the specified name
2052      for an item.
2053    </description>
2054  </query>
2055
2056  <query id="DELETE_ANYTOANY_FROM" type="HQL">
2057    <sql>
2058      DELETE FROM AnyToAnyData ata
2059      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2060    </sql>
2061    <description>
2062      A Hibernate query that deletes a names any-to-any link leading out from
2063      an item.
2064    </description>
2065  </query>
2066
2067
2068  <query id="DELETE_ALL_ANYTOANY_FROM" type="HQL">
2069    <sql>
2070      DELETE FROM AnyToAnyData ata
2071      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2072    </sql>
2073    <description>
2074      A Hibernate query that deletes all any-to-any links leading out from
2075      an item.
2076    </description>
2077  </query>
2078
2079  <query id="DELETE_ALL_ANYTOANY_TO" type="HQL">
2080    <sql>
2081      DELETE FROM AnyToAnyData ata
2082      WHERE ata.toId = :toId AND ata.toType = :toType
2083    </sql>
2084    <description>
2085      A Hibernate query that deletes all any-to-any links leading in to
2086      an item.
2087    </description>
2088  </query>
2089 
2090  <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
2091    <sql>
2092      DELETE FROM AnyToAnyData ata
2093      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = false
2094    </sql>
2095    <description>
2096      A Hibernate query that deletes all any-to-any links leading in to
2097      an item that doesn't count as using the item.
2098    </description>
2099  </query>
2100
2101  <query id="COUNT_ANYTOANY_FROM" type="HQL">
2102    <sql>
2103      SELECT count(*)
2104      FROM AnyToAnyData ata
2105      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2106    </sql>
2107    <description>
2108      A Hibernate query that counts the number of any-to-any links
2109      from a given item.
2110    </description>
2111  </query>
2112
2113  <query id="COUNT_ANYTOANY_TO" type="HQL">
2114    <sql>
2115      SELECT count(*)
2116      FROM AnyToAnyData ana
2117      WHERE ana.toId = :toId AND ana.toType = :toType
2118    </sql>
2119    <description>
2120      A Hibernate query that counts the number of any-to-any links
2121      to a given item.
2122    </description>
2123  </query>
2124
2125  <query id="COUNT_USED_ANYTOANY_TO" type="HQL">
2126    <sql>
2127      SELECT count(*)
2128      FROM AnyToAnyData ata
2129      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = true
2130    </sql>
2131    <description>
2132      A Hibernate query that counts the number of any-to-any links
2133      to a given item that counts as using the item.
2134    </description>
2135  </query>
2136
2137  <query id="FIND_USING_ANYTOANY" type="HQL">
2138    <sql>
2139      SELECT ana.fromId, ana.fromType
2140      FROM AnyToAnyData ana
2141      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
2142    </sql>
2143    <description>
2144      A Hibernate query that finds the any-to-any links
2145      to a given item that counts as using the item.
2146    </description>
2147  </query>
2148
2149 
2150  <query id="UPDATE_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2151    <sql>
2152      UPDATE VirtualDbData vdb
2153      SET vdb.cubes = vdb.cubes + 1
2154      WHERE vdb.id = :virtualDb
2155    </sql>
2156    <description>
2157      A Hibernate query that updates the number of data cubes
2158      for the specified virtual database.
2159    </description>
2160  </query>
2161
2162  <query id="GET_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2163    <sql>
2164      SELECT vdb.cubes
2165      FROM VirtualDbData vdb
2166      WHERE vdb.id = :virtualDb
2167    </sql>
2168    <description>
2169      A Hibernate query that gets the current number of data cubes
2170      for the specified virtual database.
2171    </description>
2172  </query>
2173 
2174  <query id="UPDATE_FILTERNO_FOR_DATACUBE" type="HQL">
2175    <sql>
2176      UPDATE DataCubeData dcb
2177      SET dcb.numFilters = dcb.numFilters + 1
2178      WHERE dcb.id = :dataCube
2179    </sql>
2180    <description>
2181      A Hibernate query that updates the number of filters
2182      for the specified data cube.
2183    </description>
2184  </query>
2185
2186  <query id="GET_FILTERNO_FOR_DATACUBE" type="HQL">
2187    <sql>
2188      SELECT dcb.numFilters
2189      FROM DataCubeData dcb
2190      WHERE dcb.id = :dataCube
2191    </sql>
2192    <description>
2193      A Hibernate query that gets the current number of filters
2194      for the specified data cube.
2195    </description>
2196  </query>
2197
2198  <query id="UPDATE_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2199    <sql>
2200      UPDATE DataCubeData dcb
2201      SET dcb.numExtraValues = dcb.numExtraValues + 1
2202      WHERE dcb.id = :dataCube
2203    </sql>
2204    <description>
2205      A Hibernate query that updates the number of extra values
2206      for the specified data cube.
2207    </description>
2208  </query>
2209
2210  <query id="GET_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2211    <sql>
2212      SELECT dcb.numExtraValues
2213      FROM DataCubeData dcb
2214      WHERE dcb.id = :dataCube
2215    </sql>
2216    <description>
2217      A Hibernate query that gets the current number of extra values
2218      for the specified data cube.
2219    </description>
2220  </query>
2221
2222  <query id="UPDATE_LAYERNO_FOR_DATACUBE" type="HQL">
2223    <sql>
2224      UPDATE DataCubeData dcb
2225      SET dcb.numLayers = dcb.numLayers + 1
2226      WHERE dcb.id = :dataCube
2227    </sql>
2228    <description>
2229      A Hibernate query that updates the number of layers
2230      for the specified data cube.
2231    </description>
2232  </query>
2233
2234  <query id="GET_LAYERNO_FOR_DATACUBE" type="HQL">
2235    <sql>
2236      SELECT dcb.numLayers
2237      FROM DataCubeData dcb
2238      WHERE dcb.id = :dataCube
2239    </sql>
2240    <description>
2241      A Hibernate query that gets the current number of layers
2242      for the specified data cube.
2243    </description>
2244  </query>
2245
2246  <query id="UPDATE_COLUMNNO_FOR_DATACUBE" type="HQL">
2247    <sql>
2248      UPDATE DataCubeData dcb
2249      SET dcb.numColumns = dcb.numColumns + 1
2250      WHERE dcb.id = :dataCube
2251    </sql>
2252    <description>
2253      A Hibernate query that updates the number of columns
2254      for the specified data cube.
2255    </description>
2256  </query>
2257
2258  <query id="GET_COLUMNNO_FOR_DATACUBE" type="HQL">
2259    <sql>
2260      SELECT dcb.numColumns
2261      FROM DataCubeData dcb
2262      WHERE dcb.id = :dataCube
2263    </sql>
2264    <description>
2265      A Hibernate query that gets the current number of columns
2266      for the specified data cube.
2267    </description>
2268  </query>
2269
2270  <query id="SET_HAS_DATA_FOR_RAWBIOASSAYS" type="HQL">
2271    <sql>
2272      UPDATE RawBioAssayData rba
2273      SET rba.hasData = CASE
2274        WHEN rba.spots > 0 THEN true
2275        ELSE false
2276        END
2277      WHERE rba.hasData IS NULL
2278    </sql>
2279    <description>
2280      A Hibernate query that sets the hasData property for a
2281      raw bioassay depending on if it has spots or not.
2282    </description>
2283  </query>
2284 
2285  <query id="SET_REMOVED_FOR_HARDWARETYPES" type="HQL">
2286    <sql>
2287      UPDATE HardwareTypeData hwd
2288      SET hwd.removed = false
2289      WHERE hwd.removed IS NULL
2290    </sql>
2291    <description>
2292      A Hibernate query that sets the removed property to false for a
2293      HardwareTypeData if it has NULL value.
2294    </description>
2295  </query>
2296
2297  <query id="SET_CONFIG_FOR_PLUGINS" type="HQL">
2298    <sql>
2299      UPDATE PluginDefinitionData pd
2300      SET pd.supportsConfigurations = true, pd.requiresConfiguration = false
2301      WHERE pd.supportsConfigurations IS NULL OR pd.requiresConfiguration IS NULL
2302    </sql>
2303    <description>
2304      A Hibernate query that sets the supportsConfigurations and requiresConfiguration
2305      properties of PluginDefinitionData items if any of them is null.
2306    </description>
2307  </query>
2308
2309  <query id="GET_INCORRECT_PLATEMAPPINGS" type="HQL">
2310    <sql>
2311      SELECT pm
2312      FROM PlateMappingData pm
2313      WHERE pm.sourceCount = 4 AND pm.destinationCount = 1
2314      AND
2315      (
2316        (pm.sourceGeometry.rows = 8 AND pm.sourceGeometry.columns = 12)
2317        OR
2318        (pm.sourceGeometry.rows = 16 AND pm.sourceGeometry.columns = 24)
2319      )
2320    </sql>
2321    <description>
2322      A Hibernate query that finds incorrect plate mappings.
2323    </description>
2324  </query>
2325 
2326  <query id="GET_PLATES_WITH_MAPPING" type="HQL">
2327    <sql>
2328      SELECT p
2329      FROM PlateData p
2330      WHERE p.plateMapping = :plateMapping
2331    </sql>
2332    <description>
2333      A Hibernate query that loads all plates with a specific plate mapping.
2334    </description>
2335  </query>
2336 
2337  <query id="GET_JOBAGENT_FOR_EXTERNALID" type="HQL">
2338    <sql>
2339      SELECT jag
2340      FROM JobAgentData jag
2341      WHERE jag.externalId = :externalId
2342    </sql>
2343    <description>
2344      A Hibernate query that loads the job agent with the specified external ID.
2345    </description>
2346  </query>
2347
2348  <query id="SET_TRUSTED_FOR_PLUGINDEFINITIONS" type="HQL">
2349    <sql>
2350      UPDATE PluginDefinitionData pd
2351      SET pd.trusted = true
2352      WHERE pd.trusted IS NULL
2353    </sql>
2354    <description>
2355      A Hibernate query that sets the trusted flag for all plugins with a null value
2356      to TRUE.
2357    </description>
2358  </query>
2359 
2360  <query id="SET_USE_PERMISSION_FOR_PLUGINDEFINITIONS" type="HQL">
2361    <sql>
2362      UPDATE PluginDefinitionData pd
2363      SET pd.usePermissions = false
2364      WHERE pd.usePermissions IS NULL
2365    </sql>
2366    <description>
2367      A Hibernate query that sets the use permission flag to false
2368      for all plugins with a null value.
2369    </description>
2370  </query>
2371 
2372  <query id="GET_KEYS_FOR_PLUGIN" type="HQL">
2373    <sql>
2374      SELECT pdk
2375      FROM PluginKeys pdk
2376      WHERE pdk.pluginDefinitionId = :pluginId
2377      ORDER BY pdk.keyId
2378    </sql>
2379    <description>
2380      A Hibernate query that loads all PluginDefinitionKeys for a specified plugin ID.
2381    </description>
2382  </query>
2383 
2384  <query id="SET_SENDMESSAGE_FOR_JOBS" type="HQL">
2385    <sql>
2386      UPDATE JobData job
2387      SET job.sendMessage = true
2388      WHERE job.sendMessage IS NULL
2389    </sql>
2390    <description>
2391      A Hibernate query that sets the send message flag for all jobs with a null value.
2392    </description>
2393  </query>
2394
2395  <query id="SET_PARAMETER_VERSION_FOR_PLUGINCONFIGURATIONS" type="HQL">
2396    <sql>
2397      UPDATE PluginConfigurationData pc
2398      SET pc.parameterVersion = 1
2399      WHERE pc.parameterVersion IS NULL
2400    </sql>
2401    <description>
2402      A Hibernate query that sets the parameter version to 1 for all
2403      configurations with a null value.
2404    </description>
2405  </query>
2406
2407  <query id="SET_PARAMETER_VERSION_FOR_JOBS" type="HQL">
2408    <sql>
2409      UPDATE JobData job
2410      SET job.parameterVersion = 1
2411      WHERE job.parameterVersion IS NULL
2412    </sql>
2413    <description>
2414      A Hibernate query that sets the parameter version to 1 for all
2415      jobs with a null value.
2416    </description>
2417  </query>
2418
2419  <query id="COPY_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
2420    <sql>
2421      INSERT INTO "VersionedPluginConfigurationValues"
2422      ("pluginconfiguration_id", "name", "parameter_version", "value_id")
2423      SELECT "pluginconfiguration_id", "name", 1, "value_id"
2424      FROM "PluginConfigurationValues"
2425    </sql>
2426    <description>
2427      An SQL query that creates versioned parameters from unversioned.
2428    </description>
2429  </query>
2430 
2431  <query id="DELETE_UNVERSIONED_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
2432    <sql>
2433      DELETE FROM "PluginConfigurationValues"
2434    </sql>
2435    <description>
2436      An SQL query that deletes unversioned plugin configuration parameters.
2437    </description>
2438  </query>
2439
2440  <query id="SET_COLORING_FOR_FORMULAS" type="HQL">
2441    <sql>
2442        UPDATE FormulaData frm
2443        SET
2444          frm.coloring.usingColors = false,
2445          frm.coloring.logarithmic = false
2446        WHERE frm.coloring.usingColors IS NULL
2447    </sql>
2448    <description>
2449      A HQL query that sets the usingColors and logarithmic to false
2450      for all formulas with null values.
2451    </description>
2452  </query>
2453 
2454  <query id="SET_COLORING_FOR_EXTRAVALUETYPES" type="HQL">
2455    <sql>
2456      UPDATE ExtraValueTypeData evt
2457      SET
2458        evt.coloring.usingColors = false,
2459        evt.coloring.logarithmic = false
2460        WHERE evt.coloring.usingColors IS NULL
2461    </sql>
2462    <description>
2463      A HQL query that sets the usingColors and logarithmic to false
2464      for all extra value types with null values.
2465    </description>
2466  </query>
2467 
2468  <query id="SET_IMMEDIATE_EXECUTION_FOR_PLUGINS" type="HQL">
2469    <sql>
2470      UPDATE PluginDefinitionData plg
2471      SET plg.allowImmediateExecution = false
2472      WHERE plg.allowImmediateExecution IS NULL
2473    </sql>
2474    <description>
2475      A HQL query that sets the allowImmediateExecution to false
2476      for all plugins which has a null value.
2477    </description>
2478  </query>
2479 
2480  <query id="SET_PROTOCOL_PARAMETER_FOR_ANNOTATION_TYPES" type="HQL">
2481    <sql>
2482      UPDATE AnnotationTypeData at
2483      SET at.protocolParameter = false
2484      WHERE at.protocolParameter IS NULL
2485    </sql>
2486    <description>
2487      A HQL query that sets the protocolParameter flag to false
2488      for all annotation types with a null value.
2489    </description>
2490  </query>
2491
2492  <query id="CHANGE_FILE_DISCRIMINATOR" type="SQL">
2493    <sql>
2494      UPDATE "ParameterValues"
2495      SET "discriminator" = 10
2496      WHERE "discriminator" = 9
2497    </sql>
2498    <description>
2499      An SQL query that changes the discriminator for file
2500      parameters
2501    </description>
2502  </query>
2503
2504  <query id="COPY_FILE_PARAMETERS" type="SQL">
2505    <sql>
2506      INSERT INTO "ItemValues" ("id", "data_class", "data_class_id")
2507      SELECT "id", 'net.sf.basedb.core.data.FileData', "value"
2508      FROM "FileValues"
2509    </sql>
2510    <description>
2511      An SQL query that copies file parameter values into
2512      the item parameter values table.
2513    </description>
2514  </query>
2515
2516  <query id="DELETE_FILE_PARAMETERS" type="SQL">
2517    <sql>
2518      DELETE FROM "FileValues"
2519    </sql>
2520    <description>
2521      An SQL query that deletes old file parameter values (after they have been copied).
2522    </description>
2523  </query>
2524
2525  <query id="SET_ITEMTYPE_ON_DISKUSAGE" type="HQL">
2526    <sql>
2527      UPDATE DiskUsageData du
2528      SET du.itemType = :itemType
2529      WHERE du.id IN (:itemList)
2530      AND du.itemType IS NULL
2531    </sql>
2532    <description>
2533      A HQL query that sets the item type for disk usage items.
2534    </description>
2535  </query>
2536
2537  <query id="LOAD_DISKUSAGEID_FOR_FILES" type="HQL">
2538    <sql>
2539      SELECT f.diskUsage.id
2540      FROM FileData f
2541    </sql>
2542    <description>
2543      A HQL query that loads the disk usage ID for all files.
2544    </description>
2545  </query>
2546 
2547  <query id="LOAD_DISKUSAGEID_FOR_EXPERIMENTS" type="HQL">
2548    <sql>
2549      SELECT xp.diskUsage.id
2550      FROM ExperimentData xp
2551    </sql>
2552    <description>
2553      A HQL query that loads the disk usage ID for all experiments.
2554    </description>
2555  </query>
2556 
2557  <query id="LOAD_DISKUSAGEID_FOR_RAWBIOASSAYS" type="HQL">
2558    <sql>
2559      SELECT rba.diskUsage.id
2560      FROM RawBioAssayData rba
2561    </sql>
2562    <description>
2563      A HQL query that loads the disk usage ID for all raw bioassays.
2564    </description>
2565  </query>
2566
2567  <query id="SET_MAX_MAPPING_ON_DATACUBES" type="HQL">
2568    <sql>
2569      UPDATE DataCubeData dcd
2570      SET dcd.maxRawMappingsForSpot = -1
2571      WHERE dcd.maxRawMappingsForSpot IS NULL
2572    </sql>
2573    <description>
2574      A HQL query that sets the maxRawMappingsForSpot on all data cubes with a
2575      null value to -1. This is required so we can load them by Hibernate.
2576    </description>
2577  </query>
2578
2579  <query id="SET_MAX_MAPPING_ON_DATACUBE" type="HQL">
2580    <sql>
2581      UPDATE DataCubeData dcd
2582      SET dcd.maxRawMappingsForSpot = :mapCount
2583      WHERE dcd.id = :dataCube
2584    </sql>
2585    <description>
2586      A HQL query that sets the maxRawMappingsForSpot on a data cube.
2587    </description>
2588  </query>
2589
2590  <query id="GET_USED_QUANTITY_EVENTS" type="HQL">
2591    <sql>
2592      SELECT evt.bioMaterial, evt.usedQuantity
2593      FROM BioMaterialEventData evt
2594    </sql>
2595    <description>
2596      A HQL query that loads the biomaterial and the used quantity
2597      for all BioMaterialEvent:s.
2598    </description>
2599  </query>
2600 
2601  <query id="GET_USED_QUANTITY_SOURCES" type="HQL">
2602    <sql>
2603      SELECT index(src), src.usedQuantity
2604      FROM BioMaterialEventData evt
2605      JOIN evt.sources src
2606    </sql>
2607    <description>
2608      A HQL query that loads the used quantity
2609      for all sources to BioMaterialEvent:s.
2610    </description>
2611  </query>
2612
2613  <query id="SET_WRITE_PROTECTED_ON_FILES" type="HQL">
2614    <sql>
2615      UPDATE FileData f
2616      SET f.writeProtected = false
2617      WHERE f.writeProtected IS NULL
2618    </sql>
2619    <description>
2620      A HQL query that sets the writeProtected on all files with a
2621      null value to false.
2622    </description>
2623  </query>
2624 
2625  <query id="SET_REMOVE_JOB_ON_JOBS" type="HQL">
2626    <sql>
2627      UPDATE JobData j
2628      SET j.removeJobWhenFinished = false
2629      WHERE j.removeJobWhenFinished IS NULL
2630    </sql>
2631    <description>
2632      A HQL query that sets the deleteJobWhenFinished to false
2633      on all jobs with a null value.
2634    </description>
2635  </query> 
2636 
2637  <query id="GET_INTERNAL_FILES_WITH_NO_LAST_UPDATE" type="HQL">
2638    <sql>
2639      SELECT f
2640      FROM FileData f
2641      WHERE f.lastUpdate IS NULL AND NOT f.internalName IS NULL
2642    </sql>
2643    <description>
2644      A HQL query that sets the writeProtected on all files with a
2645      null value to false.
2646    </description>
2647  </query>
2648 
2649  <query id="LOAD_DEFAULT_GROUPS" type="HQL">
2650    <sql>
2651      SELECT grp
2652      FROM GroupData grp
2653      WHERE grp.default = true
2654    </sql>
2655    <description>
2656      A HQL query that loads all groups which are marked as default
2657      groups.
2658    </description>
2659  </query>
2660 
2661  <query id="LOAD_DEFAULT_ROLES" type="HQL">
2662    <sql>
2663      SELECT rle
2664      FROM RoleData rle
2665      WHERE rle.default = true
2666    </sql>
2667    <description>
2668      A HQL query that loads all roles which are marked as default
2669      roles.
2670    </description>
2671  </query>
2672 
2673  <query id="SET_DEFAULT_ON_GROUPS" type="HQL">
2674    <sql>
2675      UPDATE GroupData grp
2676      SET grp.default = false
2677      WHERE grp.default IS NULL
2678    </sql>
2679    <description>
2680      A HQL query that sets the isDefault flag to false for all
2681      groups with a null value.
2682    </description>
2683  </query>
2684 
2685  <query id="SET_DEFAULT_ON_ROLES" type="HQL">
2686    <sql>
2687      UPDATE RoleData rle
2688      SET rle.default = false
2689      WHERE rle.default IS NULL
2690    </sql>
2691    <description>
2692      A HQL query that sets the isDefault flag to false for all
2693      roles with a null value.
2694    </description>
2695  </query>
2696 
2697  <query id="SET_ITEM_ID_ON_CONTEXTS" type="HQL">
2698    <sql>
2699      UPDATE ContextData ctx
2700      SET ctx.itemId = 0
2701      WHERE ctx.itemId IS NULL
2702    </sql>
2703    <description>
2704      A HQL query that sets the itemId to 0 for all
2705      contexts with a null value.
2706    </description>
2707  </query>
2708 
2709  <query id="SET_AVERAGE_METHOD_ON_FORMULAS" type="HQL">
2710    <sql>
2711      UPDATE FormulaData f
2712      SET f.averageMethod = 2
2713      WHERE f.averageMethod IS NULL
2714    </sql>
2715    <description>
2716      A HQL query that sets the averageMethod to arithmetic mean for all
2717      formulas with a null value.
2718    </description>
2719  </query>
2720 
2721  <query id="SET_AVERAGE_METHOD_ON_EXTRAVALUETYPES" type="HQL">
2722    <sql>
2723      UPDATE ExtraValueTypeData evt
2724      SET evt.averageMethod = 2
2725      WHERE evt.averageMethod IS NULL
2726    </sql>
2727    <description>
2728      A HQL query that sets the averageMethod to arithmetic mean for all
2729      extra value types with a null value.
2730    </description>
2731  </query>
2732 
2733  <query id="UPDATE_PROPERTY_FILTER" type="SQL">
2734    <sql>
2735      UPDATE [PropertyFilters]
2736      SET [property] = :newProperty
2737      WHERE [property] = :oldProperty
2738      AND [context_id] NOT IN
2739      (
2740         SELECT [context_id]
2741         FROM [PropertyFilters]
2742         WHERE [property] = :newProperty
2743      )
2744    </sql>
2745    <description>
2746      An SQL query that changes the property for all PropertyFilters
2747      which filters on a given property. It must ignore any filter that 
2748      causes a duplicate key violation if a filter with the new
2749      property already exists for any context.
2750    </description>
2751  </query>
2752 
2753  <query id="UPDATE_PROPERTY_FILTER_VALUE" type="SQL">
2754    <sql>
2755      UPDATE [PropertyFilters]
2756      SET [value] = :newValue
2757      WHERE [property] = :property AND [value] = :oldValue
2758    </sql>
2759    <description>
2760      An SQL query that changes the property for all PropertyFilters
2761      with a given value.
2762    </description>
2763  </query>
2764 
2765  <query id="SET_AUTOCOMPRESS_ON_MIMETYPES" type="HQL">
2766    <sql>
2767      UPDATE MimeTypeData mt
2768      SET mt.autoCompress = false
2769      WHERE mt.autoCompress IS NULL
2770    </sql>
2771    <description>
2772      A HQL query that sets the autoCompress property to false for all
2773      MIME types with a null value.
2774    </description>
2775  </query>
2776 
2777  <query id="SET_AUTOCOMPRESS_ON_DIRECTORIES" type="HQL">
2778    <sql>
2779      UPDATE DirectoryData dir
2780      SET dir.autoCompress = false
2781      WHERE dir.autoCompress IS NULL
2782    </sql>
2783    <description>
2784      A HQL query that sets the autoCompress property to false for all
2785      directories with a null value.
2786    </description>
2787  </query>
2788
2789  <query id="SET_COMPRESSED_ON_FILES" type="HQL">
2790    <sql>
2791      UPDATE FileData f
2792      SET
2793        f.compressed = false,
2794        f.compressedSize = f.size
2795      WHERE f.compressed IS NULL
2796    </sql>
2797    <description>
2798      A HQL query that sets the compressed property to false and the
2799      compressedSize to size for all files with a null value.
2800    </description>
2801  </query>
2802 
2803  <query id="SET_NUMFEATURES_ON_ARRAYDESIGNS" type="HQL">
2804    <sql>
2805      UPDATE ArrayDesignData ad
2806      SET ad.numDbFeatures = 0, ad.numFileFeatures = 0
2807      WHERE ad.numDbFeatures IS NULL OR ad.numFileFeatures IS NULL
2808    </sql>
2809    <description>
2810      A HQL query that sets the number of file and db features to 0
2811      on all array designs with a null value.
2812    </description>
2813  </query>
2814 
2815  <query id="SET_NUMFILESPOTS_ON_RAWBIOASSAY" type="HQL">
2816    <sql>
2817      UPDATE RawBioAssayData rbd
2818      SET rbd.numFileSpots = 0
2819      WHERE rbd.numFileSpots IS NULL
2820    </sql>
2821    <description>
2822      A HQL query that sets the number of file aspots to 0
2823      on all raw bioassays with a null value.
2824    </description>
2825  </query>
2826
2827  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
2828    <sql>
2829      SELECT {1}
2830      FROM RawBioAssayData rba
2831      WHERE rba.platform = :platform
2832    </sql>
2833    <description>
2834      A Hibernate query that gets raw bioassays
2835      with a given platform.
2836    </description>
2837  </query>
2838
2839  <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL">
2840    <sql>
2841      SELECT {1}
2842      FROM ArrayDesignData ad
2843      WHERE ad.platform = :platform
2844    </sql>
2845    <description>
2846      A Hibernate query that gets array designs
2847      with a given platform.
2848    </description>
2849  </query>
2850 
2851  <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL">
2852    <sql>
2853      SELECT {1}
2854      FROM RawBioAssayData rba
2855      WHERE rba.variant = :variant
2856    </sql>
2857    <description>
2858      A Hibernate query that gets raw bioassays
2859      with a given platform variant.
2860    </description>
2861  </query>
2862
2863  <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL">
2864    <sql>
2865      SELECT {1}
2866      FROM ArrayDesignData ad
2867      WHERE ad.variant = :variant
2868    </sql>
2869    <description>
2870      A Hibernate query that gets array designs
2871      with a given platform variant.
2872    </description>
2873  </query>
2874 
2875  <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL">
2876    <sql>
2877      SELECT plf
2878      FROM PlatformData plf
2879      WHERE plf.externalId = :externalId
2880    </sql>
2881    <description>
2882      A Hibernate query that loads a platform by external ID.
2883    </description>
2884  </query>
2885 
2886  <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL">
2887    <sql>
2888      SELECT plv
2889      FROM PlatformVariantData plv
2890      WHERE plv.externalId = :externalId
2891    </sql>
2892    <description>
2893      A Hibernate query that loads a platform variant by external ID.
2894    </description>
2895  </query>
2896 
2897  <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL">
2898    <sql>
2899      SELECT dft
2900      FROM DataFileTypeData dft
2901      WHERE dft.externalId = :externalId
2902    </sql>
2903    <description>
2904      A Hibernate query that loads a data file type by external ID.
2905    </description>
2906  </query>
2907
2908  <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL">
2909    <sql>
2910      SELECT {1}
2911      FROM FileSetMemberData mbr
2912      WHERE mbr.dataFileType = :dataFileType
2913    </sql>
2914    <description>
2915      A Hibernate query that gets file set members of a specific
2916      data file type.
2917    </description>
2918  </query>
2919
2920  <query id="GET_PLATFORMFILETYPE_FOR_DATAFILETYPE" type="HQL">
2921    <sql>
2922      SELECT {1}
2923      FROM PlatformFileTypeData pft
2924      WHERE pft.dataFileType = :dataFileType
2925    </sql>
2926    <description>
2927      A Hibernate query that gets platform file types of a specific
2928      data file type.
2929    </description>
2930  </query>
2931 
2932  <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
2933    <sql>
2934      SELECT mbr
2935      FROM FileSetMemberData mbr
2936      WHERE mbr.dataFileType.externalId = :externalId
2937      AND mbr.fileSet = :fileSet
2938    </sql>
2939    <description>
2940      A Hibernate query that loads a member in a given file set
2941      if we know the external ID of the data file type.
2942    </description>
2943  </query>
2944
2945 
2946  <query id="DELETE_PROPERTY_FILTER" type="SQL">
2947    <sql>
2948      DELETE FROM [PropertyFilters]
2949      WHERE [property] = :property
2950    </sql>
2951    <description>
2952      An SQL query that delete all PropertyFilters
2953      which filter on a given property.
2954    </description>
2955  </query>
2956 
2957  <query id="GET_PLUGINS_WITH_KEYS" type="HQL">
2958    <sql>
2959      SELECT DISTINCT pk.pluginDefinitionId
2960      FROM PluginKeys pk WHERE pk.keyId IN (:keys)
2961    </sql>
2962    <description>
2963      A HQL query that has been granted a specific permission. Used by
2964      update scripts when new item types are added to make sure existing
2965      plug-ins can continue to work.
2966    </description>
2967  </query>
2968
2969  <query id="CHANGE_EXPERIMENT_RAWDATATYPE" type="HQL">
2970    <sql>
2971      UPDATE ExperimentData
2972      SET rawDataType = :newRawDataType
2973      WHERE rawDataType = :oldRawDataType
2974    </sql>
2975    <description>
2976      A HQL query that changes all raw data type for experiments from
2977      an old value to a new value.
2978    </description>
2979  </query>
2980
2981  <query id="GET_PROJECTS_WITH_DEFAULT" type="HQL">
2982    <sql>
2983      SELECT prj
2984      FROM ProjectData prj
2985      WHERE prj.projectDefaults[:name] = :value
2986    </sql>
2987    <description>
2988      A HQL query that loads all projects which has a given default value
2989      for a setting.
2990    </description>
2991  </query>
2992
2993  <query id="SET_USEJOBQUEUE_ON_PLUGINS" type="HQL">
2994    <sql>
2995      UPDATE PluginDefinitionData pld
2996      SET pld.useInternalJobQueue = true
2997      WHERE pld.useInternalJobQueue IS NULL
2998    </sql>
2999    <description>
3000      A HQL query that set the useInternalJobQueue property to true
3001      for all plug-ins.
3002    </description>
3003  </query>
3004
3005</predefined-queries>
Note: See TracBrowser for help on using the repository browser.