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

Last change on this file since 5730 was 5730, checked in by Nicklas Nordborg, 12 years ago

References #1591: Upgrade script for BASE 2.17 --> 3.0

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