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

Last change on this file since 5039 was 5039, checked in by Nicklas Nordborg, 14 years ago

References #108: Logging the change history of an item

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