source: branches/filedb/src/core/common-queries.xml @ 3814

Last change on this file since 3814 was 3814, checked in by Nicklas Nordborg, 16 years ago

References #721: Store data in files instead of in the database

  • Experiments are now aware of file-only raw data types
  • Fixed test programs
  • A few remaining Affymetrix issues


  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 70.6 KB
Line 
1<?xml version="1.0" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 3814 2007-10-10 12:57: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="FIND_JOBS_IN_QUEUE" type="HQL">
1393    <sql>
1394      SELECT job
1395      FROM JobData job
1396      WHERE job.status = :status
1397      AND job.type = :type
1398      ORDER BY job.priority ASC, job.created ASC
1399    </sql>
1400    <description>
1401      A Hibernate query that loads plugin jobs in the job queue waiting to be
1402      executed sorted by priority and waiting type.
1403    </description>
1404  </query>
1405 
1406  <query id="GET_ARRAYSLIDES_FOR_BATCH" type="HQL">
1407    <sql>
1408      SELECT {1}
1409      FROM ArraySlideData a
1410      WHERE a.arrayBatch = :arrayBatch
1411    </sql>
1412    <description>
1413      A Hibernate query that gets the array slides
1414      in an array batch.
1415    </description>
1416  </query>
1417
1418  <query id="GET_ARRAYBATCHES_FOR_ARRAYDESIGN" type="HQL">
1419    <sql>
1420      SELECT {1}
1421      FROM ArrayBatchData a
1422      WHERE a.arrayDesign = :arrayDesign
1423    </sql>
1424    <description>
1425      A Hibernate query that gets array batches
1426      that uses a specific array design.
1427    </description>
1428  </query>
1429
1430  <query id="GET_RAWBIOASSAYS_FOR_ARRAYDESIGN" type="HQL">
1431    <sql>
1432      SELECT {1}
1433      FROM RawBioAssayData rba
1434      WHERE rba.arrayDesign = :arrayDesign
1435    </sql>
1436    <description>
1437      A Hibernate query that gets raw bioassays
1438      that uses a specific array design.
1439    </description>
1440  </query>
1441
1442  <query id="GET_SCANS_FOR_HYBRIDIZATION" type="HQL">
1443    <sql>
1444      SELECT {1}
1445      FROM ScanData scn
1446      WHERE scn.hybridization = :hybridization
1447    </sql>
1448    <description>
1449      A Hibernate query that gets scans
1450      that uses a specific hybridization.
1451    </description>
1452  </query>
1453
1454  <query id="GET_RAWBIOASSAYS_FOR_SCAN" type="HQL">
1455    <sql>
1456      SELECT {1}
1457      FROM RawBioAssayData rba
1458      WHERE rba.scan = :scan
1459    </sql>
1460    <description>
1461      A Hibernate query that gets raw bioassays
1462      created from a specific scan.
1463    </description>
1464  </query>
1465
1466  <query id="GET_IMAGES_FOR_SCAN" type="HQL">
1467    <sql>
1468      SELECT {1}
1469      FROM ImageData img
1470      WHERE img.scan = :scan
1471    </sql>
1472    <description>
1473      A Hibernate query that gets images
1474      created from a specific scan.
1475    </description>
1476  </query>
1477
1478  <query id="GET_FEATURE_BY_ALL_COORDINATES" type="HQL">
1479    <sql>
1480      SELECT f
1481      FROM FeatureData f
1482      WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign
1483      AND f.row = :row
1484      AND f.column = :column
1485      AND
1486      (
1487        (f.arrayDesignBlock.blockNumber = :block AND :block &lt;&gt; 0)
1488        OR
1489        (:block = 0 AND f.arrayDesignBlock.metaGridX = :metaGridX
1490        AND f.arrayDesignBlock.metaGridY = :metaGridY)
1491      )
1492    </sql>
1493    <description>
1494      A Hibernate query that finds a feature on a given array design
1495      with specified block and coordinates.
1496    </description>
1497  </query>
1498 
1499  <query id="PRELOAD_FEATURES" type="HQL">
1500    <sql>
1501      SELECT f
1502      FROM FeatureData f
1503      JOIN FETCH f.arrayDesignBlock b
1504      LEFT JOIN FETCH f.reporter
1505      WHERE b.arrayDesign = :arrayDesign
1506    </sql>
1507    <description>
1508      A Hibernate query that loads features, blocks and reporters
1509      for a single array design.
1510    </description>
1511  </query>
1512 
1513  <query id="DELETE_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1514    <sql>
1515      DELETE FROM Features f, ArrayDesignBlocks adb
1516      WHERE adb.id = f.arraydesignblock_id AND adb.arraydesign_id = ?
1517    </sql>
1518    <description>
1519      A Hibernate query that deletes all features for an array design.
1520    </description>
1521  </query>
1522
1523  <query id="GET_PLUGINTYPE_FOR_INTERFACENAME" type="HQL">
1524    <sql>
1525      SELECT plt
1526      FROM PluginTypeData plt
1527      WHERE plt.interfaceName = :interfaceName
1528    </sql>
1529    <description>
1530      Load a plugin type when you know the interface name.
1531    </description>
1532  </query>
1533
1534  <query id="GET_PLUGINDEFINITION_FOR_CLASSNAME" type="HQL">
1535    <sql>
1536      SELECT pd
1537      FROM PluginDefinitionData pd
1538      WHERE pd.className = :className
1539    </sql>
1540    <description>
1541      Load a plugin definition when you know the class name.
1542    </description>
1543  </query>
1544
1545  <query id="GET_PLUGINCONFIGURATION_FOR_PLUGIN_WITH_NAME" type="HQL">
1546    <sql>
1547      SELECT pc
1548      FROM PluginConfigurationData pc
1549      WHERE pc.pluginDefinition.className = :className
1550      AND pc.name = :name
1551    </sql>
1552    <description>
1553      Load a plugin configuration for a given plug-in and with a given name
1554    </description>
1555  </query>
1556
1557
1558  <query id="GET_EXPERIMENTS_FOR_RAWBIOASSAY" type="HQL">
1559    <sql>
1560      SELECT {1}
1561      FROM ExperimentData xp
1562      JOIN xp.rawBioAssays rba
1563      WHERE rba = :rawBioAssay
1564    </sql>
1565    <description>
1566      A Hibernate query that gets the experiments
1567      using a specific raw bioassay.
1568    </description>
1569  </query>
1570 
1571  <query id="GET_TRANSFORMATIONS_FOR_RAWBIOASSAY" type="HQL">
1572    <sql>
1573      SELECT {1}
1574      FROM TransformationData trf
1575      JOIN trf.rawSources rba
1576      WHERE rba = :rawBioAssay
1577    </sql>
1578    <description>
1579      A Hibernate query that gets the transformations
1580      using a specifiec raw bioassay.
1581    </description>
1582  </query>
1583 
1584  <query id="GET_TRANSFORMATIONS_FOR_JOB" type="HQL">
1585    <sql>
1586      SELECT {1}
1587      FROM TransformationData trf
1588      WHERE trf.job = :job
1589    </sql>
1590    <description>
1591      A Hibernate query that gets transformations
1592      linked to a job.
1593    </description>
1594  </query>
1595
1596  <query id="FIND_CHILD_BIOASSAYSETS" type="HQL">
1597    <sql>
1598      SELECT bas
1599      FROM BioAssaySetData bas
1600      WHERE bas.transformation.source = :parent
1601    </sql>
1602    <description>
1603      A Hibernate query that returns all bioassaysets that are
1604      children to a specified parent bioassayset.
1605    </description>
1606  </query>
1607 
1608  <query id="FIND_DATACUBES_FOR_BIOASSAYSETS" type="HQL">
1609    <sql>
1610      SELECT DISTINCT cbe
1611      FROM BioAssaySetData bas
1612      JOIN bas.dataCubeLayer.dataCube cbe
1613      WHERE bas IN (:basList)
1614    </sql>
1615    <description>
1616      A Hibernate query that returns all data cubes that are
1617      used by the specified list of bioassaysets
1618    </description>
1619  </query>
1620 
1621  <query id="FIND_DATACUBES_USED_BY_OTHERS" type="HQL">
1622    <sql>
1623      SELECT DISTINCT cbe
1624      FROM BioAssaySetData bas
1625      JOIN bas.dataCubeLayer.dataCube cbe
1626      WHERE bas NOT IN (:basList)
1627      AND cbe IN (:possibleCubes)
1628    </sql>
1629    <description>
1630      A Hibernate query that, given a list of data cubes and bioassaysets,
1631      returns all of those data cubes that are also used by other bioassaysets.
1632    </description>
1633  </query>
1634
1635  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS" type="HQL">
1636    <sql>
1637      SELECT lay
1638      FROM BioAssaySetData bas
1639      JOIN bas.dataCubeLayer lay
1640      WHERE bas IN (:basList)
1641    </sql>
1642    <description>
1643      A Hibernate query that returns all data cube layers that are
1644      used by the specified list of bioassaysets
1645    </description>
1646  </query>
1647 
1648  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1649    <sql>
1650      SELECT lay
1651      FROM BioAssaySetData bas
1652      JOIN bas.dataCubeLayer lay
1653      WHERE bas IN (:basList)
1654      AND lay.dataCube NOT IN (:deletedCubes)
1655    </sql>
1656    <description>
1657      A Hibernate query that returns all data cube layers that are
1658      used by the specified list of bioassaysets but not are part of the
1659      list of already deleted data cubes.
1660    </description>
1661  </query>
1662
1663  <query id="FIND_DATACUBELAYERS_USED_BY_OTHERS" type="HQL">
1664    <sql>
1665      SELECT lay
1666      FROM BioAssaySetData bas
1667      JOIN bas.dataCubeLayer lay
1668      WHERE bas NOT IN (:basList)
1669      AND lay IN (:possibleLayers)
1670    </sql>
1671    <description>
1672      A Hibernate query that, given a list of data cube layers and bioassaysets,
1673      returns all of those data cube layers that are also used by other bioassaysets.
1674    </description>
1675  </query>
1676
1677  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS" type="HQL">
1678    <sql>
1679      SELECT flt
1680      FROM BioAssaySetData bas
1681      JOIN bas.dataCubeFilter flt
1682      WHERE bas IN (:basList)
1683    </sql>
1684    <description>
1685      A Hibernate query that returns all data cube filters that are
1686      used by the specified list of bioassaysets
1687    </description>
1688  </query>
1689 
1690  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1691    <sql>
1692      SELECT flt
1693      FROM BioAssaySetData bas
1694      JOIN bas.dataCubeFilter flt
1695      WHERE bas IN (:basList)
1696      AND flt.dataCube NOT IN (:deletedCubes)
1697    </sql>
1698    <description>
1699      A Hibernate query that returns all data cube filters that are
1700      used by the specified list of bioassaysets but not are part of the
1701      list of already deleted data cubes.
1702    </description>
1703  </query>
1704
1705  <query id="FIND_DATACUBEFILTERS_USED_BY_OTHERS" type="HQL">
1706    <sql>
1707      SELECT flt
1708      FROM BioAssaySetData bas
1709      JOIN bas.dataCubeFilter flt
1710      WHERE bas NOT IN (:basList)
1711      AND flt IN (:possibleFilters)
1712    </sql>
1713    <description>
1714      A Hibernate query that, given a list of data cube filters and bioassaysets,
1715      returns all of those data cube filters that are also used by other bioassaysets.
1716    </description>
1717  </query>
1718
1719  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS" type="HQL">
1720    <sql>
1721      SELECT dcev
1722      FROM BioAssaySetData bas
1723      JOIN bas.extraValues ev
1724      JOIN ev.dataCubeExtraValue dcev
1725      WHERE bas IN (:basList)
1726    </sql>
1727    <description>
1728      A Hibernate query that returns all data cube extra values that are
1729      used by the specified list of bioassaysets
1730    </description>
1731  </query>
1732 
1733  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1734    <sql>
1735      SELECT dcev
1736      FROM BioAssaySetData bas
1737      JOIN bas.extraValues ev
1738      JOIN ev.dataCubeExtraValue dcev
1739      WHERE bas IN (:basList)
1740      AND dcev.dataCube NOT IN (:deletedCubes)
1741    </sql>
1742    <description>
1743      A Hibernate query that returns all data cube extra values that are
1744      used by the specified list of bioassaysets but not are part of the
1745      list of already deleted data cubes.
1746    </description>
1747  </query>
1748
1749  <query id="FIND_DATACUBEEXTRAVALUES_USED_BY_OTHERS" type="HQL">
1750    <sql>
1751      SELECT dcev
1752      FROM BioAssaySetData bas
1753      JOIN bas.extraValues ev
1754      JOIN ev.dataCubeExtraValue dcev
1755      WHERE bas NOT IN (:basList)
1756      AND dcev IN (:possibleExtraValues)
1757    </sql>
1758    <description>
1759      A Hibernate query that, given a list of data cube extra values and bioassaysets,
1760      returns all of those data cube extra values that are also used by other bioassaysets.
1761    </description>
1762  </query>
1763
1764  <query id="GET_EXTRAVALUETYPE_FOR_EXTERNAL_ID" type="HQL">
1765    <sql>
1766      SELECT evt
1767      FROM ExtraValueTypeData evt
1768      WHERE evt.externalId = :externalId
1769    </sql>
1770    <description>
1771      Load an extra value type when you know the external id.
1772    </description>
1773  </query>
1774
1775  <query id="GET_EXTRAVALUES_FOR_EXTRAVALUETYPE" type="HQL">
1776    <sql>
1777      SELECT {1}
1778      FROM ExtraValueData ev
1779      WHERE ev.extraValueType = :extraValueType
1780    </sql>
1781    <description>
1782      A Hibernate query that gets extra values
1783      of a specific type.
1784    </description>
1785  </query>
1786 
1787  <query id="LOAD_CONTEXT_NAMES" type="HQL">
1788    <sql>
1789      SELECT ctx.id, ctx.name
1790      FROM ContextData ctx
1791      WHERE ctx.client = :client AND
1792      (ctx.user = :user OR ctx.public = true)
1793      AND ctx.itemType = :itemType
1794      AND ctx.subContext = :subContext
1795      ORDER BY ctx.name
1796    </sql>
1797    <description>
1798      A Hibernate query that selects the id and name of all contexts for
1799      a user and item type. The names should be sorted in ascending order.
1800    </description>
1801  </query>
1802 
1803  <query id="LOAD_CONTEXT_BY_NAME" type="HQL">
1804    <sql>
1805      SELECT ctx
1806      FROM ContextData ctx
1807      WHERE ctx.user = :user
1808      AND ctx.client = :client
1809      AND ctx.itemType = :itemType
1810      AND ctx.subContext  = :subContext
1811      AND ctx.name = :name
1812    </sql>
1813    <description>
1814      A Hibernate query that load a context given the user, client,
1815      item type, subcontext and name of the context.
1816    </description>
1817  </query>
1818 
1819  <query id="COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT" type="HQL">
1820    <sql>
1821      SELECT plg.mainType, count(DISTINCT plg.id)
1822      FROM PluginDefinitionData plg
1823      JOIN plg.guiContexts gcx
1824      LEFT JOIN plg.configurations cfg
1825      WITH true = :hasConfigPermission OR cfg.owner.id = :owner
1826        OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
1827      WHERE
1828        (true = :hasPluginPermission OR plg.owner.id = :owner
1829        OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
1830      AND gcx.itemType = :itemType AND gcx.contextType = :contextType
1831      AND (
1832        (plg.requiresConfiguration = false)
1833        OR
1834        (plg.requiresConfiguration = true AND NOT cfg.id IS NULL)
1835      )
1836      GROUP BY plg.mainType
1837    </sql>
1838    <description>
1839      A Hibernate query that counts the number of plugins available for a
1840      given GUI context grouped by the main type of the plugins taking
1841      the requirement of configurations and user permissions into account.
1842    </description>
1843  </query>
1844 
1845  <query id="GET_FORMULA_WITH_NAME_AND_CHANNELS" type="HQL">
1846    <sql>
1847      SELECT fml
1848      FROM FormulaData fml
1849      WHERE fml.name = :name
1850      AND fml.channels = :channels
1851    </sql>
1852    <description>
1853      A Hibernate query that loads a formula with a given name and number
1854      of channels.
1855    </description>
1856  </query>
1857
1858  <query id="GET_FORMULA_WITH_NAME_AND_TYPE" type="HQL">
1859    <sql>
1860      SELECT fml
1861      FROM FormulaData fml
1862      WHERE fml.name = :name
1863      AND fml.rawDataType = :rawDataType
1864    </sql>
1865    <description>
1866      A Hibernate query that loads a formula with a given name and raw data type.
1867    </description>
1868  </query>
1869 
1870  <query id="GET_HELP_FOR_EXTERNAL_ID" type="HQL">
1871    <sql>
1872      SELECT hlp
1873      FROM HelpData hlp
1874      WHERE hlp.externalId = :externalId AND hlp.client = :client
1875    </sql>
1876    <description>
1877      A Hibernate query that loads a help text.
1878    </description>
1879  </query>
1880 
1881  <query id="GET_SCHEMA_VERSION" type="HQL">
1882    <sql>
1883      SELECT sv
1884      FROM SchemaVersionData sv
1885    </sql>
1886    <description>
1887      A Hibernate query that loads the schema version (there should only be one record).
1888    </description>
1889  </query>
1890 
1891  <query id="SET_SCHEMA_VERSION" type="HQL">
1892    <sql>
1893      UPDATE SchemaVersionData sv
1894      SET sv.schemaVersion = :schemaVersion,
1895      sv.build = :build
1896    </sql>
1897    <description>
1898      A Hibernate query that updates the schema version and build number.
1899    </description>
1900  </query>
1901 
1902  <query id="SET_PROJECT_ID_FOR_JOBS" type="HQL">
1903    <sql>
1904      UPDATE JobData job
1905      SET job.activeProjectId = 0
1906      WHERE job.activeProjectId IS NULL
1907    </sql>
1908    <description>
1909      A Hibernate query that sets the active project ID for all
1910      jobs to 0 if they have a null value.
1911    </description>
1912  </query>
1913
1914  <query id="GET_PRIMARY_ANNOTATION" type="HQL">
1915    <sql>
1916      SELECT ad
1917      FROM AnnotationData ad
1918      WHERE ad.annotationType = :annotationType
1919      AND ad.annotationSet = :annotationSet
1920    </sql>
1921    <description>
1922      A Hibernate query that loads the primary annotation of a specific
1923      annotation type for a given annotation set.
1924    </description>
1925  </query>
1926 
1927  <query id="GET_DIRECTLY_INHERITED_ANNOTATION" type="HQL">
1928    <sql>
1929      SELECT ad
1930      FROM AnnotationData ad
1931      JOIN ad.inheritingSets ans
1932      WHERE ad.annotationType = :annotationType
1933      AND ans = :annotationSet
1934    </sql>
1935    <description>
1936      A Hibernate query that loads an directly inherited annotation of a specific
1937      annotation type for a given annotation set. A directly inhertited annotation
1938      is an annotation that is linked to the specified annotation set.
1939    </description>
1940  </query>
1941
1942  <query id="GET_INDIRECTLY_INHERITED_ANNOTATION" type="HQL">
1943    <sql>
1944      SELECT ad
1945      FROM AnnotationData ad
1946      JOIN ad.annotationSet.inheritingSets ians
1947      WHERE ad.annotationType = :annotationType
1948      AND ians = :annotationSet
1949    </sql>
1950    <description>
1951      A Hibernate query that loads an indirectly inherited annotation of a specific
1952      annotation type for a given annotation set. An indirectly inherited annotation
1953      is an annotation which belongs to an annotation set which is inherited by
1954      the given annotation set.
1955    </description>
1956  </query>
1957 
1958  <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL">
1959    <sql>
1960      UPDATE ExperimentData xpm
1961      SET xpm.bytes = xpm.bytes + :addedBytes
1962      WHERE xpm.id = :experiment
1963    </sql>
1964    <description>
1965      A Hibernate query that updates the number of bytes used by an experiment.
1966    </description>
1967  </query>
1968
1969  <query id="UPDATE_BYTES_FOR_DATACUBE" type="HQL">
1970    <sql>
1971      UPDATE DataCubeData dcd
1972      SET dcd.bytes = dcd.bytes + :addedBytes
1973      WHERE dcd.id = :dataCube
1974    </sql>
1975    <description>
1976      A Hibernate query that updates the number of bytes used by a data cube.
1977    </description>
1978  </query>
1979 
1980  <query id="GET_REMOVED_ITEMS" type="HQL">
1981    <sql>
1982      SELECT trash
1983      FROM net.sf.basedb.core.data.RemovableData trash
1984      WHERE trash.removed = true
1985    </sql>
1986    <description>
1987      A Hibernate query that loads all items flagged for deletion.
1988    </description>
1989  </query>
1990 
1991  <query id="UPDATE_REMAINING_QUANTITY" type="HQL">
1992    <sql>
1993      UPDATE MeasuredBioMaterialData mbm
1994      SET mbm.remainingQuantity = mbm.remainingQuantity - :used
1995      WHERE mbm = :bioMaterial
1996    </sql>
1997    <description>
1998      A Hibernate query that adds/removes the remaining quantity on a
1999      measuered biomaterial.
2000    </description>
2001  </query>
2002
2003  <query id="SET_REMAINING_QUANTITY" type="HQL">
2004    <sql>
2005      UPDATE MeasuredBioMaterialData mbm
2006      SET mbm.remainingQuantity = :remain
2007      WHERE mbm = :bioMaterial
2008    </sql>
2009    <description>
2010      A Hibernate query that sets the remaining quantity on a
2011      measuered biomaterial.
2012    </description>
2013  </query>
2014
2015
2016  <query id="GET_ANYTOANY_FOR_NAME" type="HQL">
2017    <sql>
2018      SELECT ata
2019      FROM AnyToAnyData ata
2020      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2021    </sql>
2022    <description>
2023      A Hibernate query that loads the any-to-any link with the specified name
2024      for an item.
2025    </description>
2026  </query>
2027
2028  <query id="DELETE_ANYTOANY_FROM" type="HQL">
2029    <sql>
2030      DELETE FROM AnyToAnyData ata
2031      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2032    </sql>
2033    <description>
2034      A Hibernate query that deletes a names any-to-any link leading out from
2035      an item.
2036    </description>
2037  </query>
2038
2039
2040  <query id="DELETE_ALL_ANYTOANY_FROM" type="HQL">
2041    <sql>
2042      DELETE FROM AnyToAnyData ata
2043      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2044    </sql>
2045    <description>
2046      A Hibernate query that deletes all any-to-any links leading out from
2047      an item.
2048    </description>
2049  </query>
2050
2051  <query id="DELETE_ALL_ANYTOANY_TO" type="HQL">
2052    <sql>
2053      DELETE FROM AnyToAnyData ata
2054      WHERE ata.toId = :toId AND ata.toType = :toType
2055    </sql>
2056    <description>
2057      A Hibernate query that deletes all any-to-any links leading in to
2058      an item.
2059    </description>
2060  </query>
2061 
2062  <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
2063    <sql>
2064      DELETE FROM AnyToAnyData ata
2065      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = false
2066    </sql>
2067    <description>
2068      A Hibernate query that deletes all any-to-any links leading in to
2069      an item that doesn't count as using the item.
2070    </description>
2071  </query>
2072
2073  <query id="COUNT_ANYTOANY_FROM" type="HQL">
2074    <sql>
2075      SELECT count(*)
2076      FROM AnyToAnyData ata
2077      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2078    </sql>
2079    <description>
2080      A Hibernate query that counts the number of any-to-any links
2081      from a given item.
2082    </description>
2083  </query>
2084
2085  <query id="COUNT_ANYTOANY_TO" type="HQL">
2086    <sql>
2087      SELECT count(*)
2088      FROM AnyToAnyData ana
2089      WHERE ana.toId = :toId AND ana.toType = :toType
2090    </sql>
2091    <description>
2092      A Hibernate query that counts the number of any-to-any links
2093      to a given item.
2094    </description>
2095  </query>
2096
2097  <query id="COUNT_USED_ANYTOANY_TO" type="HQL">
2098    <sql>
2099      SELECT count(*)
2100      FROM AnyToAnyData ata
2101      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = true
2102    </sql>
2103    <description>
2104      A Hibernate query that counts the number of any-to-any links
2105      to a given item that counts as using the item.
2106    </description>
2107  </query>
2108
2109  <query id="FIND_USING_ANYTOANY" type="HQL">
2110    <sql>
2111      SELECT ana.fromId, ana.fromType
2112      FROM AnyToAnyData ana
2113      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
2114    </sql>
2115    <description>
2116      A Hibernate query that finds the any-to-any links
2117      to a given item that counts as using the item.
2118    </description>
2119  </query>
2120
2121 
2122  <query id="UPDATE_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2123    <sql>
2124      UPDATE VirtualDbData vdb
2125      SET vdb.cubes = vdb.cubes + 1
2126      WHERE vdb.id = :virtualDb
2127    </sql>
2128    <description>
2129      A Hibernate query that updates the number of data cubes
2130      for the specified virtual database.
2131    </description>
2132  </query>
2133
2134  <query id="GET_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2135    <sql>
2136      SELECT vdb.cubes
2137      FROM VirtualDbData vdb
2138      WHERE vdb.id = :virtualDb
2139    </sql>
2140    <description>
2141      A Hibernate query that gets the current number of data cubes
2142      for the specified virtual database.
2143    </description>
2144  </query>
2145 
2146  <query id="UPDATE_FILTERNO_FOR_DATACUBE" type="HQL">
2147    <sql>
2148      UPDATE DataCubeData dcb
2149      SET dcb.numFilters = dcb.numFilters + 1
2150      WHERE dcb.id = :dataCube
2151    </sql>
2152    <description>
2153      A Hibernate query that updates the number of filters
2154      for the specified data cube.
2155    </description>
2156  </query>
2157
2158  <query id="GET_FILTERNO_FOR_DATACUBE" type="HQL">
2159    <sql>
2160      SELECT dcb.numFilters
2161      FROM DataCubeData dcb
2162      WHERE dcb.id = :dataCube
2163    </sql>
2164    <description>
2165      A Hibernate query that gets the current number of filters
2166      for the specified data cube.
2167    </description>
2168  </query>
2169
2170  <query id="UPDATE_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2171    <sql>
2172      UPDATE DataCubeData dcb
2173      SET dcb.numExtraValues = dcb.numExtraValues + 1
2174      WHERE dcb.id = :dataCube
2175    </sql>
2176    <description>
2177      A Hibernate query that updates the number of extra values
2178      for the specified data cube.
2179    </description>
2180  </query>
2181
2182  <query id="GET_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2183    <sql>
2184      SELECT dcb.numExtraValues
2185      FROM DataCubeData dcb
2186      WHERE dcb.id = :dataCube
2187    </sql>
2188    <description>
2189      A Hibernate query that gets the current number of extra values
2190      for the specified data cube.
2191    </description>
2192  </query>
2193
2194  <query id="UPDATE_LAYERNO_FOR_DATACUBE" type="HQL">
2195    <sql>
2196      UPDATE DataCubeData dcb
2197      SET dcb.numLayers = dcb.numLayers + 1
2198      WHERE dcb.id = :dataCube
2199    </sql>
2200    <description>
2201      A Hibernate query that updates the number of layers
2202      for the specified data cube.
2203    </description>
2204  </query>
2205
2206  <query id="GET_LAYERNO_FOR_DATACUBE" type="HQL">
2207    <sql>
2208      SELECT dcb.numLayers
2209      FROM DataCubeData dcb
2210      WHERE dcb.id = :dataCube
2211    </sql>
2212    <description>
2213      A Hibernate query that gets the current number of layers
2214      for the specified data cube.
2215    </description>
2216  </query>
2217
2218  <query id="UPDATE_COLUMNNO_FOR_DATACUBE" type="HQL">
2219    <sql>
2220      UPDATE DataCubeData dcb
2221      SET dcb.numColumns = dcb.numColumns + 1
2222      WHERE dcb.id = :dataCube
2223    </sql>
2224    <description>
2225      A Hibernate query that updates the number of columns
2226      for the specified data cube.
2227    </description>
2228  </query>
2229
2230  <query id="GET_COLUMNNO_FOR_DATACUBE" type="HQL">
2231    <sql>
2232      SELECT dcb.numColumns
2233      FROM DataCubeData dcb
2234      WHERE dcb.id = :dataCube
2235    </sql>
2236    <description>
2237      A Hibernate query that gets the current number of columns
2238      for the specified data cube.
2239    </description>
2240  </query>
2241
2242  <query id="SET_HAS_DATA_FOR_RAWBIOASSAYS" type="HQL">
2243    <sql>
2244      UPDATE RawBioAssayData rba
2245      SET rba.hasData = CASE
2246        WHEN rba.spots > 0 THEN true
2247        ELSE false
2248        END
2249      WHERE rba.hasData IS NULL
2250    </sql>
2251    <description>
2252      A Hibernate query that sets the hasData property for a
2253      raw bioassay depending on if it has spots or not.
2254    </description>
2255  </query>
2256 
2257  <query id="SET_REMOVED_FOR_HARDWARETYPES" type="HQL">
2258    <sql>
2259      UPDATE HardwareTypeData hwd
2260      SET hwd.removed = false
2261      WHERE hwd.removed IS NULL
2262    </sql>
2263    <description>
2264      A Hibernate query that sets the removed property to false for a
2265      HardwareTypeData if it has NULL value.
2266    </description>
2267  </query>
2268
2269  <query id="SET_CONFIG_FOR_PLUGINS" type="HQL">
2270    <sql>
2271      UPDATE PluginDefinitionData pd
2272      SET pd.supportsConfigurations = true, pd.requiresConfiguration = false
2273      WHERE pd.supportsConfigurations IS NULL OR pd.requiresConfiguration IS NULL
2274    </sql>
2275    <description>
2276      A Hibernate query that sets the supportsConfigurations and requiresConfiguration
2277      properties of PluginDefinitionData items if any of them is null.
2278    </description>
2279  </query>
2280
2281  <query id="GET_INCORRECT_PLATEMAPPINGS" type="HQL">
2282    <sql>
2283      SELECT pm
2284      FROM PlateMappingData pm
2285      WHERE pm.sourceCount = 4 AND pm.destinationCount = 1
2286      AND
2287      (
2288        (pm.sourceGeometry.rows = 8 AND pm.sourceGeometry.columns = 12)
2289        OR
2290        (pm.sourceGeometry.rows = 16 AND pm.sourceGeometry.columns = 24)
2291      )
2292    </sql>
2293    <description>
2294      A Hibernate query that finds incorrect plate mappings.
2295    </description>
2296  </query>
2297 
2298  <query id="GET_PLATES_WITH_MAPPING" type="HQL">
2299    <sql>
2300      SELECT p
2301      FROM PlateData p
2302      WHERE p.plateMapping = :plateMapping
2303    </sql>
2304    <description>
2305      A Hibernate query that loads all plates with a specific plate mapping.
2306    </description>
2307  </query>
2308 
2309  <query id="GET_JOBAGENT_FOR_EXTERNALID" type="HQL">
2310    <sql>
2311      SELECT jag
2312      FROM JobAgentData jag
2313      WHERE jag.externalId = :externalId
2314    </sql>
2315    <description>
2316      A Hibernate query that loads the job agent with the specified external ID.
2317    </description>
2318  </query>
2319
2320  <query id="SET_TRUSTED_FOR_PLUGINDEFINITIONS" type="HQL">
2321    <sql>
2322      UPDATE PluginDefinitionData pd
2323      SET pd.trusted = true
2324      WHERE pd.trusted IS NULL
2325    </sql>
2326    <description>
2327      A Hibernate query that sets the trusted flag for all plugins with a null value
2328      to TRUE.
2329    </description>
2330  </query>
2331 
2332  <query id="SET_USE_PERMISSION_FOR_PLUGINDEFINITIONS" type="HQL">
2333    <sql>
2334      UPDATE PluginDefinitionData pd
2335      SET pd.usePermissions = false
2336      WHERE pd.usePermissions IS NULL
2337    </sql>
2338    <description>
2339      A Hibernate query that sets the use permission flag to false
2340      for all plugins with a null value.
2341    </description>
2342  </query>
2343 
2344  <query id="GET_KEYS_FOR_PLUGIN" type="HQL">
2345    <sql>
2346      SELECT pdk
2347      FROM PluginKeys pdk
2348      WHERE pdk.pluginDefinitionId = :pluginId
2349      ORDER BY pdk.keyId
2350    </sql>
2351    <description>
2352      A Hibernate query that loads all PluginDefinitionKeys for a specified plugin ID.
2353    </description>
2354  </query>
2355 
2356  <query id="SET_SENDMESSAGE_FOR_JOBS" type="HQL">
2357    <sql>
2358      UPDATE JobData job
2359      SET job.sendMessage = true
2360      WHERE job.sendMessage IS NULL
2361    </sql>
2362    <description>
2363      A Hibernate query that sets the send message flag for all jobs with a null value.
2364    </description>
2365  </query>
2366
2367  <query id="SET_PARAMETER_VERSION_FOR_PLUGINCONFIGURATIONS" type="HQL">
2368    <sql>
2369      UPDATE PluginConfigurationData pc
2370      SET pc.parameterVersion = 1
2371      WHERE pc.parameterVersion IS NULL
2372    </sql>
2373    <description>
2374      A Hibernate query that sets the parameter version to 1 for all
2375      configurations with a null value.
2376    </description>
2377  </query>
2378
2379  <query id="SET_PARAMETER_VERSION_FOR_JOBS" type="HQL">
2380    <sql>
2381      UPDATE JobData job
2382      SET job.parameterVersion = 1
2383      WHERE job.parameterVersion IS NULL
2384    </sql>
2385    <description>
2386      A Hibernate query that sets the parameter version to 1 for all
2387      jobs with a null value.
2388    </description>
2389  </query>
2390
2391  <query id="COPY_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
2392    <sql>
2393      INSERT INTO "VersionedPluginConfigurationValues"
2394      ("pluginconfiguration_id", "name", "parameter_version", "value_id")
2395      SELECT "pluginconfiguration_id", "name", 1, "value_id"
2396      FROM "PluginConfigurationValues"
2397    </sql>
2398    <description>
2399      An SQL query that creates versioned parameters from unversioned.
2400    </description>
2401  </query>
2402 
2403  <query id="DELETE_UNVERSIONED_PLUGINCONFIGURATION_PARAMETERS" type="SQL">
2404    <sql>
2405      DELETE FROM "PluginConfigurationValues"
2406    </sql>
2407    <description>
2408      An SQL query that deletes unversioned plugin configuration parameters.
2409    </description>
2410  </query>
2411
2412  <query id="SET_COLORING_FOR_FORMULAS" type="HQL">
2413    <sql>
2414        UPDATE FormulaData frm
2415        SET
2416          frm.coloring.usingColors = false,
2417          frm.coloring.logarithmic = false
2418        WHERE frm.coloring.usingColors IS NULL
2419    </sql>
2420    <description>
2421      A HQL query that sets the usingColors and logarithmic to false
2422      for all formulas with null values.
2423    </description>
2424  </query>
2425 
2426  <query id="SET_COLORING_FOR_EXTRAVALUETYPES" type="HQL">
2427    <sql>
2428      UPDATE ExtraValueTypeData evt
2429      SET
2430        evt.coloring.usingColors = false,
2431        evt.coloring.logarithmic = false
2432        WHERE evt.coloring.usingColors IS NULL
2433    </sql>
2434    <description>
2435      A HQL query that sets the usingColors and logarithmic to false
2436      for all extra value types with null values.
2437    </description>
2438  </query>
2439 
2440  <query id="SET_IMMEDIATE_EXECUTION_FOR_PLUGINS" type="HQL">
2441    <sql>
2442      UPDATE PluginDefinitionData plg
2443      SET plg.allowImmediateExecution = false
2444      WHERE plg.allowImmediateExecution IS NULL
2445    </sql>
2446    <description>
2447      A HQL query that sets the allowImmediateExecution to false
2448      for all plugins which has a null value.
2449    </description>
2450  </query>
2451 
2452  <query id="SET_PROTOCOL_PARAMETER_FOR_ANNOTATION_TYPES" type="HQL">
2453    <sql>
2454      UPDATE AnnotationTypeData at
2455      SET at.protocolParameter = false
2456      WHERE at.protocolParameter IS NULL
2457    </sql>
2458    <description>
2459      A HQL query that sets the protocolParameter flag to false
2460      for all annotation types with a null value.
2461    </description>
2462  </query>
2463
2464  <query id="CHANGE_FILE_DISCRIMINATOR" type="SQL">
2465    <sql>
2466      UPDATE "ParameterValues"
2467      SET "discriminator" = 10
2468      WHERE "discriminator" = 9
2469    </sql>
2470    <description>
2471      An SQL query that changes the discriminator for file
2472      parameters
2473    </description>
2474  </query>
2475
2476  <query id="COPY_FILE_PARAMETERS" type="SQL">
2477    <sql>
2478      INSERT INTO "ItemValues" ("id", "data_class", "data_class_id")
2479      SELECT "id", 'net.sf.basedb.core.data.FileData', "value"
2480      FROM "FileValues"
2481    </sql>
2482    <description>
2483      An SQL query that copies file parameter values into
2484      the item parameter values table.
2485    </description>
2486  </query>
2487
2488  <query id="DELETE_FILE_PARAMETERS" type="SQL">
2489    <sql>
2490      DELETE FROM "FileValues"
2491    </sql>
2492    <description>
2493      An SQL query that deletes old file parameter values (after they have been copied).
2494    </description>
2495  </query>
2496
2497  <query id="SET_ITEMTYPE_ON_DISKUSAGE" type="HQL">
2498    <sql>
2499      UPDATE DiskUsageData du
2500      SET du.itemType = :itemType
2501      WHERE du.id IN (:itemList)
2502      AND du.itemType IS NULL
2503    </sql>
2504    <description>
2505      A HQL query that sets the item type for disk usage items.
2506    </description>
2507  </query>
2508
2509  <query id="LOAD_DISKUSAGEID_FOR_FILES" type="HQL">
2510    <sql>
2511      SELECT f.diskUsage.id
2512      FROM FileData f
2513    </sql>
2514    <description>
2515      A HQL query that loads the disk usage ID for all files.
2516    </description>
2517  </query>
2518 
2519  <query id="LOAD_DISKUSAGEID_FOR_EXPERIMENTS" type="HQL">
2520    <sql>
2521      SELECT xp.diskUsage.id
2522      FROM ExperimentData xp
2523    </sql>
2524    <description>
2525      A HQL query that loads the disk usage ID for all experiments.
2526    </description>
2527  </query>
2528 
2529  <query id="LOAD_DISKUSAGEID_FOR_RAWBIOASSAYS" type="HQL">
2530    <sql>
2531      SELECT rba.diskUsage.id
2532      FROM RawBioAssayData rba
2533    </sql>
2534    <description>
2535      A HQL query that loads the disk usage ID for all raw bioassays.
2536    </description>
2537  </query>
2538
2539  <query id="SET_MAX_MAPPING_ON_DATACUBES" type="HQL">
2540    <sql>
2541      UPDATE DataCubeData dcd
2542      SET dcd.maxRawMappingsForSpot = -1
2543      WHERE dcd.maxRawMappingsForSpot IS NULL
2544    </sql>
2545    <description>
2546      A HQL query that sets the maxRawMappingsForSpot on all data cubes with a
2547      null value to -1. This is required so we can load them by Hibernate.
2548    </description>
2549  </query>
2550
2551  <query id="SET_MAX_MAPPING_ON_DATACUBE" type="HQL">
2552    <sql>
2553      UPDATE DataCubeData dcd
2554      SET dcd.maxRawMappingsForSpot = :mapCount
2555      WHERE dcd.id = :dataCube
2556    </sql>
2557    <description>
2558      A HQL query that sets the maxRawMappingsForSpot on a data cube.
2559    </description>
2560  </query>
2561
2562  <query id="GET_USED_QUANTITY_EVENTS" type="HQL">
2563    <sql>
2564      SELECT evt.bioMaterial, evt.usedQuantity
2565      FROM BioMaterialEventData evt
2566    </sql>
2567    <description>
2568      A HQL query that loads the biomaterial and the used quantity
2569      for all BioMaterialEvent:s.
2570    </description>
2571  </query>
2572 
2573  <query id="GET_USED_QUANTITY_SOURCES" type="HQL">
2574    <sql>
2575      SELECT index(src), src.usedQuantity
2576      FROM BioMaterialEventData evt
2577      JOIN evt.sources src
2578    </sql>
2579    <description>
2580      A HQL query that loads the used quantity
2581      for all sources to BioMaterialEvent:s.
2582    </description>
2583  </query>
2584
2585  <query id="SET_WRITE_PROTECTED_ON_FILES" type="HQL">
2586    <sql>
2587      UPDATE FileData f
2588      SET f.writeProtected = false
2589      WHERE f.writeProtected IS NULL
2590    </sql>
2591    <description>
2592      A HQL query that sets the writeProtected on all files with a
2593      null value to false.
2594    </description>
2595  </query>
2596 
2597  <query id="SET_REMOVE_JOB_ON_JOBS" type="HQL">
2598    <sql>
2599      UPDATE JobData j
2600      SET j.removeJobWhenFinished = false
2601      WHERE j.removeJobWhenFinished IS NULL
2602    </sql>
2603    <description>
2604      A HQL query that sets the deleteJobWhenFinished to false
2605      on all jobs with a null value.
2606    </description>
2607  </query> 
2608 
2609  <query id="GET_INTERNAL_FILES_WITH_NO_LAST_UPDATE" type="HQL">
2610    <sql>
2611      SELECT f
2612      FROM FileData f
2613      WHERE f.lastUpdate IS NULL AND NOT f.internalName IS NULL
2614    </sql>
2615    <description>
2616      A HQL query that sets the writeProtected on all files with a
2617      null value to false.
2618    </description>
2619  </query>
2620 
2621  <query id="LOAD_DEFAULT_GROUPS" type="HQL">
2622    <sql>
2623      SELECT grp
2624      FROM GroupData grp
2625      WHERE grp.default = true
2626    </sql>
2627    <description>
2628      A HQL query that loads all groups which are marked as default
2629      groups.
2630    </description>
2631  </query>
2632 
2633  <query id="LOAD_DEFAULT_ROLES" type="HQL">
2634    <sql>
2635      SELECT rle
2636      FROM RoleData rle
2637      WHERE rle.default = true
2638    </sql>
2639    <description>
2640      A HQL query that loads all roles which are marked as default
2641      roles.
2642    </description>
2643  </query>
2644 
2645  <query id="SET_DEFAULT_ON_GROUPS" type="HQL">
2646    <sql>
2647      UPDATE GroupData grp
2648      SET grp.default = false
2649      WHERE grp.default IS NULL
2650    </sql>
2651    <description>
2652      A HQL query that sets the isDefault flag to false for all
2653      groups with a null value.
2654    </description>
2655  </query>
2656 
2657  <query id="SET_DEFAULT_ON_ROLES" type="HQL">
2658    <sql>
2659      UPDATE RoleData rle
2660      SET rle.default = false
2661      WHERE rle.default IS NULL
2662    </sql>
2663    <description>
2664      A HQL query that sets the isDefault flag to false for all
2665      roles with a null value.
2666    </description>
2667  </query>
2668 
2669  <query id="SET_ITEM_ID_ON_CONTEXTS" type="HQL">
2670    <sql>
2671      UPDATE ContextData ctx
2672      SET ctx.itemId = 0
2673      WHERE ctx.itemId IS NULL
2674    </sql>
2675    <description>
2676      A HQL query that sets the itemId to 0 for all
2677      contexts with a null value.
2678    </description>
2679  </query>
2680 
2681  <query id="SET_AVERAGE_METHOD_ON_FORMULAS" type="HQL">
2682    <sql>
2683      UPDATE FormulaData f
2684      SET f.averageMethod = 2
2685      WHERE f.averageMethod IS NULL
2686    </sql>
2687    <description>
2688      A HQL query that sets the averageMethod to arithmetic mean for all
2689      formulas with a null value.
2690    </description>
2691  </query>
2692 
2693  <query id="SET_AVERAGE_METHOD_ON_EXTRAVALUETYPES" type="HQL">
2694    <sql>
2695      UPDATE ExtraValueTypeData evt
2696      SET evt.averageMethod = 2
2697      WHERE evt.averageMethod IS NULL
2698    </sql>
2699    <description>
2700      A HQL query that sets the averageMethod to arithmetic mean for all
2701      extra value types with a null value.
2702    </description>
2703  </query>
2704 
2705  <query id="UPDATE_PROPERTY_FILTER" type="SQL">
2706    <sql>
2707      UPDATE [PropertyFilters]
2708      SET [property] = :newProperty
2709      WHERE [property] = :oldProperty
2710    </sql>
2711    <description>
2712      An SQL query that changes the property for all PropertyFilters
2713      with a given value.
2714    </description>
2715  </query>
2716 
2717  <query id="SET_AUTOCOMPRESS_ON_MIMETYPES" type="HQL">
2718    <sql>
2719      UPDATE MimeTypeData mt
2720      SET mt.autoCompress = false
2721      WHERE mt.autoCompress IS NULL
2722    </sql>
2723    <description>
2724      A HQL query that sets the autoCompress property to false for all
2725      MIME types with a null value.
2726    </description>
2727  </query>
2728 
2729  <query id="SET_AUTOCOMPRESS_ON_DIRECTORIES" type="HQL">
2730    <sql>
2731      UPDATE DirectoryData dir
2732      SET dir.autoCompress = false
2733      WHERE dir.autoCompress IS NULL
2734    </sql>
2735    <description>
2736      A HQL query that sets the autoCompress property to false for all
2737      directories with a null value.
2738    </description>
2739  </query>
2740
2741  <query id="SET_COMPRESSED_ON_FILES" type="HQL">
2742    <sql>
2743      UPDATE FileData f
2744      SET
2745        f.compressed = false,
2746        f.compressedSize = f.size
2747      WHERE f.compressed IS NULL
2748    </sql>
2749    <description>
2750      A HQL query that sets the compressed property to false and the
2751      compressedSize to size for all files with a null value.
2752    </description>
2753  </query>
2754 
2755  <query id="SET_NUMFEATURES_ON_ARRAYDESIGNS" type="HQL">
2756    <sql>
2757      UPDATE ArrayDesignData ad
2758      SET ad.numFeatures = 0
2759      WHERE ad.numFeatures IS NULL
2760    </sql>
2761    <description>
2762      A HQL query that sets the number of features to 0
2763      on all array designs with a null value.
2764    </description>
2765  </query>
2766
2767  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
2768    <sql>
2769      SELECT {1}
2770      FROM RawBioAssayData rba
2771      WHERE rba.platform = :platform
2772    </sql>
2773    <description>
2774      A Hibernate query that gets raw bioassays
2775      with a given platform.
2776    </description>
2777  </query>
2778
2779  <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL">
2780    <sql>
2781      SELECT {1}
2782      FROM ArrayDesignData ad
2783      WHERE ad.platform = :platform
2784    </sql>
2785    <description>
2786      A Hibernate query that gets array designs
2787      with a given platform.
2788    </description>
2789  </query>
2790 
2791  <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL">
2792    <sql>
2793      SELECT {1}
2794      FROM RawBioAssayData rba
2795      WHERE rba.variant = :variant
2796    </sql>
2797    <description>
2798      A Hibernate query that gets raw bioassays
2799      with a given platform variant.
2800    </description>
2801  </query>
2802
2803  <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL">
2804    <sql>
2805      SELECT {1}
2806      FROM ArrayDesignData ad
2807      WHERE ad.variant = :variant
2808    </sql>
2809    <description>
2810      A Hibernate query that gets array designs
2811      with a given platform variant.
2812    </description>
2813  </query>
2814 
2815  <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL">
2816    <sql>
2817      SELECT plf
2818      FROM PlatformData plf
2819      WHERE plf.externalId = :externalId
2820    </sql>
2821    <description>
2822      A Hibernate query that loads a platform by external ID.
2823    </description>
2824  </query>
2825 
2826  <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL">
2827    <sql>
2828      SELECT plv
2829      FROM PlatformVariantData plv
2830      WHERE plv.externalId = :externalId
2831    </sql>
2832    <description>
2833      A Hibernate query that loads a platform variant by external ID.
2834    </description>
2835  </query>
2836 
2837  <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL">
2838    <sql>
2839      SELECT dft
2840      FROM DataFileTypeData dft
2841      WHERE dft.externalId = :externalId
2842    </sql>
2843    <description>
2844      A Hibernate query that loads a data file type by external ID.
2845    </description>
2846  </query>
2847
2848  <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL">
2849    <sql>
2850      SELECT {1}
2851      FROM FileSetMemberData mbr
2852      WHERE mbr.dataFileType = :dataFileType
2853    </sql>
2854    <description>
2855      A Hibernate query that gets file set members of a specific
2856      data file type.
2857    </description>
2858  </query>
2859 
2860  <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
2861    <sql>
2862      SELECT mbr
2863      FROM FileSetMemberData mbr
2864      WHERE mbr.dataFileType.externalId = :externalId
2865      AND mbr.fileSet = :fileSet
2866    </sql>
2867    <description>
2868      A Hibernate query that loads a member in a given file set
2869      if we know the external ID of the data file type.
2870    </description>
2871  </query>
2872
2873 
2874  <query id="DELETE_PROPERTY_FILTER" type="SQL">
2875    <sql>
2876      DELETE FROM [PropertyFilters]
2877      WHERE [property] = :property
2878    </sql>
2879    <description>
2880      An SQL query that delete all PropertyFilters
2881      which filter on a given property.
2882    </description>
2883  </query>
2884 
2885  <query id="GET_PLUGINS_WITH_KEYS" type="HQL">
2886    <sql>
2887      SELECT DISTINCT pk.pluginDefinitionId
2888      FROM PluginKeys pk WHERE pk.keyId IN (:keys)
2889    </sql>
2890    <description>
2891      A HQL query that has been granted a specific permission. Used by
2892      update scripts when new item types are added to make sure existing
2893      plug-ins can continue to work.
2894    </description>
2895  </query>
2896
2897  <query id="CHANGE_EXPERIMENT_RAWDATATYPE" type="HQL">
2898    <sql>
2899      UPDATE ExperimentData
2900      SET rawDataType = :newRawDataType
2901      WHERE rawDataType = :oldRawDataType
2902    </sql>
2903    <description>
2904      A HQL query that changes all raw data type for experiments from
2905      an old value to a new value.
2906    </description>
2907  </query>
2908
2909
2910</predefined-queries>
Note: See TracBrowser for help on using the repository browser.