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

Last change on this file since 6920 was 6920, checked in by Nicklas Nordborg, 7 years ago

References #1941: Store experimental factor values as part experiments

Fixes some more places in the core API that used the old "InheritedAnnotations?" table.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 86.3 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 6920 2015-05-26 11:24:55Z 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="FIND_EXTERNAL_JOBS_FOR_STATUS_UPDATE" type="HQL">
1347    <sql>
1348      SELECT job
1349      FROM JobData job
1350      WHERE job.type = :type
1351      AND job.removed = false
1352      AND NOT job.signalTransporter IS NULL
1353    </sql>
1354    <description>
1355      A Hibernate query that loads external jobs in the job queue that
1356      has a non-null signal transporter so that it may be possible to
1357      send a signal request for status update to them,
1358    </description>
1359  </query>
1360 
1361  <query id="GET_ARRAYSLIDES_FOR_BATCH" type="HQL">
1362    <sql>
1363      SELECT {1}
1364      FROM ArraySlideData a
1365      WHERE a.arrayBatch = :arrayBatch
1366    </sql>
1367    <description>
1368      A Hibernate query that gets the array slides
1369      in an array batch.
1370    </description>
1371  </query>
1372
1373  <query id="GET_ARRAYSLIDES_WITH_BARCODE" type="HQL">
1374    <sql>
1375      SELECT {1}
1376      FROM ArraySlideData ars
1377      WHERE ars.barcode = :barcode
1378    </sql>
1379    <description>
1380      A Hibernate query that gets the array slides
1381      with a given barcode.
1382    </description>
1383  </query>
1384
1385
1386  <query id="GET_ARRAYBATCHES_FOR_ARRAYDESIGN" type="HQL">
1387    <sql>
1388      SELECT {1}
1389      FROM ArrayBatchData a
1390      WHERE a.arrayDesign = :arrayDesign
1391    </sql>
1392    <description>
1393      A Hibernate query that gets array batches
1394      that uses a specific array design.
1395    </description>
1396  </query>
1397
1398  <query id="GET_RAWBIOASSAYS_FOR_ARRAYDESIGN" type="HQL">
1399    <sql>
1400      SELECT {1}
1401      FROM RawBioAssayData rba
1402      WHERE rba.arrayDesign = :arrayDesign
1403    </sql>
1404    <description>
1405      A Hibernate query that gets raw bioassays
1406      that uses a specific array design.
1407    </description>
1408  </query>
1409
1410  <query id="GET_ROOT_DERIVEDBIOASSAYS_FOR_PHYSICALBIOASSAY" type="HQL">
1411    <sql>
1412      SELECT {1}
1413      FROM DerivedBioAssayData dba
1414      INNER JOIN dba.physicalBioAssays pba
1415      WHERE pba = :bioAssay
1416      AND dba.root = true
1417    </sql>
1418    <description>
1419      A Hibernate query that gets root derived bioassays
1420      created from a specific physical bioassay.
1421    </description>
1422  </query>
1423
1424  <query id="GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL">
1425    <sql>
1426      SELECT {1}
1427      FROM DerivedBioAssayData dba
1428      INNER JOIN dba.parents p
1429      WHERE p = :bioAssay
1430    </sql>
1431    <description>
1432      A Hibernate query that gets child derived bioassays
1433      created from a specific derived bioassay.
1434    </description>
1435  </query>
1436
1437
1438  <query id="GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL">
1439    <sql>
1440      SELECT {1}
1441      FROM RawBioAssayData rba
1442      WHERE rba.parentBioAssay = :bioAssay
1443    </sql>
1444    <description>
1445      A Hibernate query that gets raw bioassays
1446      created from a specific derived bioassay.
1447    </description>
1448  </query>
1449
1450  <query id="PRELOAD_FEATURES" type="HQL">
1451    <sql>
1452      SELECT f
1453      FROM FeatureData f
1454      JOIN FETCH f.arrayDesignBlock b
1455      LEFT JOIN FETCH f.reporter
1456      WHERE b.arrayDesign = :arrayDesign
1457    </sql>
1458    <description>
1459      A Hibernate query that loads features, blocks and reporters
1460      for a single array design.
1461    </description>
1462  </query>
1463 
1464  <query id="DELETE_FEATURES_FOR_ARRAYDESIGN" type="HQL">
1465    <sql>
1466      DELETE FROM Features f, ArrayDesignBlocks adb
1467      WHERE adb.id = f.arraydesignblock_id AND adb.arraydesign_id = ?
1468    </sql>
1469    <description>
1470      A Hibernate query that deletes all features for an array design.
1471    </description>
1472  </query>
1473
1474  <query id="GET_PLUGINTYPE_FOR_INTERFACENAME" type="HQL">
1475    <sql>
1476      SELECT plt
1477      FROM PluginTypeData plt
1478      WHERE plt.interfaceName = :interfaceName
1479    </sql>
1480    <description>
1481      Load a plugin type when you know the interface name.
1482    </description>
1483  </query>
1484
1485  <query id="GET_PLUGINDEFINITION_FOR_CLASSNAME" type="HQL">
1486    <sql>
1487      SELECT pd
1488      FROM PluginDefinitionData pd
1489      WHERE pd.className = :className
1490    </sql>
1491    <description>
1492      Load a plugin definition when you know the class name.
1493    </description>
1494  </query>
1495
1496  <query id="GET_PLUGINCONFIGURATION_FOR_PLUGIN_WITH_NAME" type="HQL">
1497    <sql>
1498      SELECT pc
1499      FROM PluginConfigurationData pc
1500      WHERE pc.pluginDefinition.className = :className
1501      AND pc.name = :name
1502    </sql>
1503    <description>
1504      Load a plugin configuration for a given plug-in and with a given name
1505    </description>
1506  </query>
1507
1508
1509  <query id="GET_EXPERIMENTS_FOR_RAWBIOASSAY" type="HQL">
1510    <sql>
1511      SELECT {1}
1512      FROM ExperimentData xp
1513      JOIN xp.rawBioAssays rba
1514      WHERE rba = :rawBioAssay
1515    </sql>
1516    <description>
1517      A Hibernate query that gets the experiments
1518      using a specific raw bioassay.
1519    </description>
1520  </query>
1521 
1522  <query id="GET_TRANSFORMATIONS_FOR_RAWBIOASSAY" type="HQL">
1523    <sql>
1524      SELECT {1}
1525      FROM TransformationData trf
1526      JOIN trf.rawSources rba
1527      WHERE rba = :rawBioAssay
1528    </sql>
1529    <description>
1530      A Hibernate query that gets the transformations
1531      using a specifiec raw bioassay.
1532    </description>
1533  </query>
1534 
1535  <query id="GET_TRANSFORMATIONS_FOR_JOB" type="HQL">
1536    <sql>
1537      SELECT {1}
1538      FROM TransformationData trf
1539      WHERE trf.job = :job
1540    </sql>
1541    <description>
1542      A Hibernate query that gets transformations
1543      linked to a job.
1544    </description>
1545  </query>
1546 
1547  <query id="GET_RAWBIOASSAYS_FOR_JOB" type="HQL">
1548    <sql>
1549      SELECT {1}
1550      FROM RawBioAssayData rba
1551      WHERE rba.job = :job
1552    </sql>
1553    <description>
1554      A Hibernate query that gets raw bioassays
1555      linked to a job.
1556    </description>
1557  </query>
1558 
1559  <query id="GET_ARRAYDESIGNS_FOR_JOB" type="HQL">
1560    <sql>
1561      SELECT {1}
1562      FROM ArrayDesignData ad
1563      WHERE ad.job = :job
1564    </sql>
1565    <description>
1566      A Hibernate query that gets array designs
1567      linked to a job.
1568    </description>
1569  </query>
1570 
1571  <query id="GET_DERIVEDBIOASSAYS_FOR_JOB" type="HQL">
1572    <sql>
1573      SELECT {1}
1574      FROM DerivedBioAssayData dba
1575      WHERE dba.job = :job
1576    </sql>
1577    <description>
1578      A Hibernate query that gets derived bioassays
1579      linked to a job.
1580    </description>
1581  </query>
1582
1583  <query id="FIND_CHILD_BIOASSAYSETS" type="HQL">
1584    <sql>
1585      SELECT bas
1586      FROM BioAssaySetData bas
1587      WHERE bas.transformation.source = :parent
1588    </sql>
1589    <description>
1590      A Hibernate query that returns all bioassaysets that are
1591      children to a specified parent bioassayset.
1592    </description>
1593  </query>
1594 
1595  <query id="FIND_DATACUBES_FOR_BIOASSAYSETS" type="HQL">
1596    <sql>
1597      SELECT DISTINCT cbe
1598      FROM BioAssaySetData bas
1599      JOIN bas.dataCubeLayer.dataCube cbe
1600      WHERE bas IN (:basList)
1601    </sql>
1602    <description>
1603      A Hibernate query that returns all data cubes that are
1604      used by the specified list of bioassaysets
1605    </description>
1606  </query>
1607 
1608  <query id="FIND_DATACUBES_USED_BY_OTHERS" type="HQL">
1609    <sql>
1610      SELECT DISTINCT cbe
1611      FROM BioAssaySetData bas
1612      JOIN bas.dataCubeLayer.dataCube cbe
1613      WHERE bas NOT IN (:basList)
1614      AND cbe IN (:possibleCubes)
1615    </sql>
1616    <description>
1617      A Hibernate query that, given a list of data cubes and bioassaysets,
1618      returns all of those data cubes that are also used by other bioassaysets.
1619    </description>
1620  </query>
1621
1622  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS" type="HQL">
1623    <sql>
1624      SELECT lay
1625      FROM BioAssaySetData bas
1626      JOIN bas.dataCubeLayer lay
1627      WHERE bas IN (:basList)
1628    </sql>
1629    <description>
1630      A Hibernate query that returns all data cube layers that are
1631      used by the specified list of bioassaysets
1632    </description>
1633  </query>
1634 
1635  <query id="FIND_DATACUBELAYERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1636    <sql>
1637      SELECT lay
1638      FROM BioAssaySetData bas
1639      JOIN bas.dataCubeLayer lay
1640      WHERE bas IN (:basList)
1641      AND lay.dataCube NOT IN (:deletedCubes)
1642    </sql>
1643    <description>
1644      A Hibernate query that returns all data cube layers that are
1645      used by the specified list of bioassaysets but not are part of the
1646      list of already deleted data cubes.
1647    </description>
1648  </query>
1649
1650  <query id="FIND_DATACUBELAYERS_USED_BY_OTHERS" type="HQL">
1651    <sql>
1652      SELECT lay
1653      FROM BioAssaySetData bas
1654      JOIN bas.dataCubeLayer lay
1655      WHERE bas NOT IN (:basList)
1656      AND lay IN (:possibleLayers)
1657    </sql>
1658    <description>
1659      A Hibernate query that, given a list of data cube layers and bioassaysets,
1660      returns all of those data cube layers that are also used by other bioassaysets.
1661    </description>
1662  </query>
1663
1664  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS" type="HQL">
1665    <sql>
1666      SELECT flt
1667      FROM BioAssaySetData bas
1668      JOIN bas.dataCubeFilter flt
1669      WHERE bas IN (:basList)
1670    </sql>
1671    <description>
1672      A Hibernate query that returns all data cube filters that are
1673      used by the specified list of bioassaysets
1674    </description>
1675  </query>
1676 
1677  <query id="FIND_DATACUBEFILTERS_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1678    <sql>
1679      SELECT flt
1680      FROM BioAssaySetData bas
1681      JOIN bas.dataCubeFilter flt
1682      WHERE bas IN (:basList)
1683      AND flt.dataCube NOT IN (:deletedCubes)
1684    </sql>
1685    <description>
1686      A Hibernate query that returns all data cube filters that are
1687      used by the specified list of bioassaysets but not are part of the
1688      list of already deleted data cubes.
1689    </description>
1690  </query>
1691
1692  <query id="FIND_DATACUBEFILTERS_USED_BY_OTHERS" type="HQL">
1693    <sql>
1694      SELECT flt
1695      FROM BioAssaySetData bas
1696      JOIN bas.dataCubeFilter flt
1697      WHERE bas NOT IN (:basList)
1698      AND flt IN (:possibleFilters)
1699    </sql>
1700    <description>
1701      A Hibernate query that, given a list of data cube filters and bioassaysets,
1702      returns all of those data cube filters that are also used by other bioassaysets.
1703    </description>
1704  </query>
1705
1706  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS" type="HQL">
1707    <sql>
1708      SELECT dcev
1709      FROM BioAssaySetData bas
1710      JOIN bas.extraValues ev
1711      JOIN ev.dataCubeExtraValue dcev
1712      WHERE bas IN (:basList)
1713    </sql>
1714    <description>
1715      A Hibernate query that returns all data cube extra values that are
1716      used by the specified list of bioassaysets
1717    </description>
1718  </query>
1719 
1720  <query id="FIND_DATACUBEEXTRAVALUES_FOR_BIOASSAYSETS_IGNORE_DELETED_DATACUBES" type="HQL">
1721    <sql>
1722      SELECT dcev
1723      FROM BioAssaySetData bas
1724      JOIN bas.extraValues ev
1725      JOIN ev.dataCubeExtraValue dcev
1726      WHERE bas IN (:basList)
1727      AND dcev.dataCube NOT IN (:deletedCubes)
1728    </sql>
1729    <description>
1730      A Hibernate query that returns all data cube extra values that are
1731      used by the specified list of bioassaysets but not are part of the
1732      list of already deleted data cubes.
1733    </description>
1734  </query>
1735
1736  <query id="FIND_DATACUBEEXTRAVALUES_USED_BY_OTHERS" type="HQL">
1737    <sql>
1738      SELECT dcev
1739      FROM BioAssaySetData bas
1740      JOIN bas.extraValues ev
1741      JOIN ev.dataCubeExtraValue dcev
1742      WHERE bas NOT IN (:basList)
1743      AND dcev IN (:possibleExtraValues)
1744    </sql>
1745    <description>
1746      A Hibernate query that, given a list of data cube extra values and bioassaysets,
1747      returns all of those data cube extra values that are also used by other bioassaysets.
1748    </description>
1749  </query>
1750
1751  <query id="GET_EXTRAVALUETYPE_FOR_EXTERNAL_ID" type="HQL">
1752    <sql>
1753      SELECT evt
1754      FROM ExtraValueTypeData evt
1755      WHERE evt.externalId = :externalId
1756    </sql>
1757    <description>
1758      Load an extra value type when you know the external id.
1759    </description>
1760  </query>
1761
1762  <query id="GET_EXTRAVALUES_FOR_EXTRAVALUETYPE" type="HQL">
1763    <sql>
1764      SELECT {1}
1765      FROM ExtraValueData ev
1766      WHERE ev.extraValueType = :extraValueType
1767    </sql>
1768    <description>
1769      A Hibernate query that gets extra values
1770      of a specific type.
1771    </description>
1772  </query>
1773 
1774  <query id="LOAD_CONTEXT_NAMES" type="HQL">
1775    <sql>
1776      SELECT ctx.id, ctx.name
1777      FROM ContextData ctx
1778      WHERE ctx.client = :client AND
1779      (ctx.user = :user OR ctx.public = true)
1780      AND ctx.itemType = :itemType
1781      AND ctx.subContext = :subContext
1782      ORDER BY ctx.name
1783    </sql>
1784    <description>
1785      A Hibernate query that selects the id and name of all contexts for
1786      a user and item type. The names should be sorted in ascending order.
1787    </description>
1788  </query>
1789 
1790  <query id="LOAD_CONTEXT_BY_NAME" type="HQL">
1791    <sql>
1792      SELECT ctx
1793      FROM ContextData ctx
1794      WHERE ctx.user = :user
1795      AND ctx.client = :client
1796      AND ctx.itemType = :itemType
1797      AND ctx.subContext  = :subContext
1798      AND ctx.name = :name
1799    </sql>
1800    <description>
1801      A Hibernate query that load a context given the user, client,
1802      item type, subcontext and name of the context.
1803    </description>
1804  </query>
1805 
1806  <query id="LOAD_USER_CONTEXTS" type="HQL">
1807    <sql>
1808      SELECT ctx
1809      FROM ContextData ctx
1810      WHERE ctx.user.id = :user
1811      AND ctx.client.id = :client
1812      AND ctx.name = :name
1813    </sql>
1814    <description>
1815      A Hibernate query that loads all saved context information
1816      with a given name for a specific user/client.
1817    </description>
1818  </query>
1819
1820  <query id="COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT" type="HQL">
1821    <sql>
1822      SELECT plg.mainType, count(DISTINCT plg.id)
1823      FROM PluginDefinitionData plg
1824      JOIN plg.guiContexts gcx
1825      LEFT JOIN plg.configurations cfg
1826      WITH true = :hasConfigPermission OR cfg.owner.id = :owner
1827        OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
1828      WHERE
1829        (true = :hasPluginPermission OR plg.owner.id = :owner
1830        OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
1831      AND gcx.itemType = :itemType AND gcx.contextType = :contextType
1832      AND (
1833        (plg.requiresConfiguration = false)
1834        OR
1835        (plg.requiresConfiguration = true AND cfg.parameterVersion > 0)
1836      )
1837      AND plg.disabled = false
1838      GROUP BY plg.mainType
1839    </sql>
1840    <description>
1841      A Hibernate query that counts the number of plugins available for a
1842      given GUI context grouped by the main type of the plugins taking
1843      the requirement of configurations and user permissions into account.
1844    </description>
1845  </query>
1846 
1847  <query id="GET_FORMULA_WITH_NAME_AND_CHANNELS" type="HQL">
1848    <sql>
1849      SELECT fml
1850      FROM FormulaData fml
1851      WHERE fml.name = :name
1852      AND fml.channels = :channels
1853    </sql>
1854    <description>
1855      A Hibernate query that loads a formula with a given name and number
1856      of channels.
1857    </description>
1858  </query>
1859
1860  <query id="GET_FORMULA_WITH_NAME_AND_TYPE" type="HQL">
1861    <sql>
1862      SELECT fml
1863      FROM FormulaData fml
1864      WHERE fml.name = :name
1865      AND fml.rawDataType = :rawDataType
1866    </sql>
1867    <description>
1868      A Hibernate query that loads a formula with a given name and raw data type.
1869    </description>
1870  </query>
1871 
1872  <query id="GET_HELP_FOR_EXTERNAL_ID" type="HQL">
1873    <sql>
1874      SELECT hlp
1875      FROM HelpData hlp
1876      WHERE hlp.externalId = :externalId AND hlp.client = :client
1877    </sql>
1878    <description>
1879      A Hibernate query that loads a help text.
1880    </description>
1881  </query>
1882 
1883  <query id="GET_SCHEMA_VERSION_FOR_APP" type="HQL">
1884    <sql>
1885      SELECT sv
1886      FROM SchemaVersionData sv
1887      WHERE sv.appId = :appId
1888    </sql>
1889    <description>
1890      A Hibernate query that loads the schema version for a
1891      given application (there should only be one record since appId is unique).
1892    </description>
1893  </query>
1894 
1895  <query id="SET_SCHEMA_VERSION_FOR_APP" type="HQL">
1896    <sql>
1897      UPDATE SchemaVersionData sv
1898      SET sv.schemaVersion = :schemaVersion,
1899      sv.build = :build
1900      WHERE sv.appId = :appId
1901    </sql>
1902    <description>
1903      A Hibernate query that updates the schema version and build number.
1904    </description>
1905  </query>
1906 
1907  <query id="GET_PRIMARY_ANNOTATION" type="HQL">
1908    <sql>
1909      SELECT ad
1910      FROM AnnotationData ad
1911      WHERE ad.annotationType = :annotationType
1912      AND ad.annotationSet = :annotationSet
1913      AND ad.source = 0
1914    </sql>
1915    <description>
1916      A Hibernate query that loads the primary annotation of a specific
1917      annotation type for a given annotation set.
1918    </description>
1919  </query>
1920 
1921  <query id="GET_INHERITED_ANNOTATIONS" type="HQL">
1922    <sql>
1923      SELECT ad
1924      FROM AnnotationData ad
1925      JOIN ad.inheritingAnnotations ia
1926      WHERE ad.annotationType = :annotationType
1927      AND ia.annotationSet = :annotationSet
1928    </sql>
1929    <description>
1930      A Hibernate query that loads an inherited annotation of a specific
1931      annotation type for a given annotation set. A directly inhertited annotation
1932      is an annotation that is linked to the specified annotation set.
1933    </description>
1934  </query>
1935
1936  <query id="LOAD_ANNOTATIONSET_INHERITING_ANNOTATIONTYPE" type="SQL">
1937    <sql>
1938      SELECT [a].[annotationset_id] FROM [Annotations] [a]
1939      WHERE [a].[annotationtype_id] = :annotationType
1940      AND [a].[source] != 0
1941    </sql>
1942    <description>
1943      An SQL query that load the ID of all annotation sets that
1944      are inheriting a given annotation type.
1945    </description>
1946  </query>
1947 
1948  <query id="DELETE_INHERITED_ANNOTATIONS" type="SQL">
1949    <sql>
1950      DELETE FROM [Annotations]
1951      WHERE [annotationtype_id] = :annotationType
1952      AND [source] != 0
1953    </sql>
1954    <description>
1955      An SQL query that delete all inherited annotations of the specified
1956      annotation type.
1957    </description>
1958  </query>
1959 
1960  <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL">
1961    <sql>
1962      UPDATE ExperimentData xpm
1963      SET xpm.bytes = xpm.bytes + :addedBytes
1964      WHERE xpm.id = :experiment
1965    </sql>
1966    <description>
1967      A Hibernate query that updates the number of bytes used by an experiment.
1968    </description>
1969  </query>
1970
1971  <query id="UPDATE_BYTES_FOR_DATACUBE" type="HQL">
1972    <sql>
1973      UPDATE DataCubeData dcd
1974      SET dcd.bytes = dcd.bytes + :addedBytes
1975      WHERE dcd.id = :dataCube
1976    </sql>
1977    <description>
1978      A Hibernate query that updates the number of bytes used by a data cube.
1979    </description>
1980  </query>
1981 
1982  <query id="GET_REMOVED_ITEMS" type="HQL">
1983    <sql>
1984      SELECT trash
1985      FROM net.sf.basedb.core.data.RemovableData trash
1986      WHERE trash.removed = true
1987    </sql>
1988    <description>
1989      A Hibernate query that loads all items flagged for deletion.
1990    </description>
1991  </query>
1992 
1993  <query id="UPDATE_REMAINING_QUANTITY" type="HQL">
1994    <sql>
1995      UPDATE MeasuredBioMaterialData mbm
1996      SET mbm.remainingQuantity = mbm.remainingQuantity - :used
1997      WHERE mbm = :bioMaterial
1998    </sql>
1999    <description>
2000      A Hibernate query that adds/removes the remaining quantity on a
2001      measuered biomaterial.
2002    </description>
2003  </query>
2004 
2005  <query id="GET_REMAINING_QUANTITY" type="HQL">
2006    <sql>
2007      SELECT mbm.remainingQuantity
2008      FROM MeasuredBioMaterialData mbm
2009      WHERE mbm = :bioMaterial
2010    </sql>
2011    <description>
2012      A Hibernate query that load the remaining quantity for a
2013      measuered biomaterial.
2014    </description>
2015  </query>
2016
2017  <query id="GET_ANYTOANY_FOR_NAME" type="HQL">
2018    <sql>
2019      SELECT ata
2020      FROM AnyToAnyData ata
2021      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2022    </sql>
2023    <description>
2024      A Hibernate query that loads the any-to-any link with the specified name
2025      for an item.
2026    </description>
2027  </query>
2028
2029  <query id="DELETE_ANYTOANY_FROM" type="HQL">
2030    <sql>
2031      DELETE FROM AnyToAnyData ata
2032      WHERE ata.fromId = :fromId AND ata.fromType = :fromType AND ata.name = :name
2033    </sql>
2034    <description>
2035      A Hibernate query that deletes a names any-to-any link leading out from
2036      an item.
2037    </description>
2038  </query>
2039
2040
2041  <query id="DELETE_ALL_ANYTOANY_FROM" type="HQL">
2042    <sql>
2043      DELETE FROM AnyToAnyData ata
2044      WHERE ata.fromId = :fromId AND ata.fromType = :fromType
2045    </sql>
2046    <description>
2047      A Hibernate query that deletes all any-to-any links leading out from
2048      an item.
2049    </description>
2050  </query>
2051
2052  <query id="DELETE_UNUSED_ANYTOANY_TO" type="HQL">
2053    <sql>
2054      DELETE FROM AnyToAnyData ata
2055      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = false
2056    </sql>
2057    <description>
2058      A Hibernate query that deletes all any-to-any links leading in to
2059      an item that doesn't count as using the item.
2060    </description>
2061  </query>
2062
2063  <query id="COUNT_USED_ANYTOANY_TO" type="HQL">
2064    <sql>
2065      SELECT count(*)
2066      FROM AnyToAnyData ata
2067      WHERE ata.toId = :toId AND ata.toType = :toType AND ata.usingTo = true
2068    </sql>
2069    <description>
2070      A Hibernate query that counts the number of any-to-any links
2071      to a given item that counts as using the item.
2072    </description>
2073  </query>
2074
2075  <query id="FIND_USING_ANYTOANY" type="HQL">
2076    <sql>
2077      SELECT ana.fromId, ana.fromType
2078      FROM AnyToAnyData ana
2079      WHERE ana.toId = :toId AND ana.toType = :toType AND ana.usingTo = true
2080    </sql>
2081    <description>
2082      A Hibernate query that finds the any-to-any links
2083      to a given item that counts as using the item.
2084    </description>
2085  </query>
2086
2087 
2088  <query id="UPDATE_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2089    <sql>
2090      UPDATE VirtualDbData vdb
2091      SET vdb.cubes = vdb.cubes + 1
2092      WHERE vdb.id = :virtualDb
2093    </sql>
2094    <description>
2095      A Hibernate query that updates the number of data cubes
2096      for the specified virtual database.
2097    </description>
2098  </query>
2099
2100  <query id="GET_DATACUBENO_FOR_VIRTUALDB" type="HQL">
2101    <sql>
2102      SELECT vdb.cubes
2103      FROM VirtualDbData vdb
2104      WHERE vdb.id = :virtualDb
2105    </sql>
2106    <description>
2107      A Hibernate query that gets the current number of data cubes
2108      for the specified virtual database.
2109    </description>
2110  </query>
2111 
2112  <query id="UPDATE_FILTERNO_FOR_DATACUBE" type="HQL">
2113    <sql>
2114      UPDATE DataCubeData dcb
2115      SET dcb.numFilters = dcb.numFilters + 1
2116      WHERE dcb.id = :dataCube
2117    </sql>
2118    <description>
2119      A Hibernate query that updates the number of filters
2120      for the specified data cube.
2121    </description>
2122  </query>
2123
2124  <query id="GET_FILTERNO_FOR_DATACUBE" type="HQL">
2125    <sql>
2126      SELECT dcb.numFilters
2127      FROM DataCubeData dcb
2128      WHERE dcb.id = :dataCube
2129    </sql>
2130    <description>
2131      A Hibernate query that gets the current number of filters
2132      for the specified data cube.
2133    </description>
2134  </query>
2135
2136  <query id="UPDATE_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2137    <sql>
2138      UPDATE DataCubeData dcb
2139      SET dcb.numExtraValues = dcb.numExtraValues + 1
2140      WHERE dcb.id = :dataCube
2141    </sql>
2142    <description>
2143      A Hibernate query that updates the number of extra values
2144      for the specified data cube.
2145    </description>
2146  </query>
2147
2148  <query id="GET_EXTRAVALUENO_FOR_DATACUBE" type="HQL">
2149    <sql>
2150      SELECT dcb.numExtraValues
2151      FROM DataCubeData dcb
2152      WHERE dcb.id = :dataCube
2153    </sql>
2154    <description>
2155      A Hibernate query that gets the current number of extra values
2156      for the specified data cube.
2157    </description>
2158  </query>
2159
2160  <query id="UPDATE_LAYERNO_FOR_DATACUBE" type="HQL">
2161    <sql>
2162      UPDATE DataCubeData dcb
2163      SET dcb.numLayers = dcb.numLayers + 1
2164      WHERE dcb.id = :dataCube
2165    </sql>
2166    <description>
2167      A Hibernate query that updates the number of layers
2168      for the specified data cube.
2169    </description>
2170  </query>
2171
2172  <query id="GET_LAYERNO_FOR_DATACUBE" type="HQL">
2173    <sql>
2174      SELECT dcb.numLayers
2175      FROM DataCubeData dcb
2176      WHERE dcb.id = :dataCube
2177    </sql>
2178    <description>
2179      A Hibernate query that gets the current number of layers
2180      for the specified data cube.
2181    </description>
2182  </query>
2183
2184  <query id="UPDATE_COLUMNNO_FOR_DATACUBE" type="HQL">
2185    <sql>
2186      UPDATE DataCubeData dcb
2187      SET dcb.numColumns = dcb.numColumns + 1
2188      WHERE dcb.id = :dataCube
2189    </sql>
2190    <description>
2191      A Hibernate query that updates the number of columns
2192      for the specified data cube.
2193    </description>
2194  </query>
2195
2196  <query id="GET_COLUMNNO_FOR_DATACUBE" type="HQL">
2197    <sql>
2198      SELECT dcb.numColumns
2199      FROM DataCubeData dcb
2200      WHERE dcb.id = :dataCube
2201    </sql>
2202    <description>
2203      A Hibernate query that gets the current number of columns
2204      for the specified data cube.
2205    </description>
2206  </query>
2207
2208  <query id="GET_JOBAGENT_FOR_EXTERNALID" type="HQL">
2209    <sql>
2210      SELECT jag
2211      FROM JobAgentData jag
2212      WHERE jag.externalId = :externalId
2213    </sql>
2214    <description>
2215      A Hibernate query that loads the job agent with the specified external ID.
2216    </description>
2217  </query>
2218
2219  <query id="GET_KEYS_FOR_PLUGIN" type="HQL">
2220    <sql>
2221      SELECT pdk
2222      FROM PluginKeys pdk
2223      WHERE pdk.pluginDefinitionId = :pluginId
2224      ORDER BY pdk.keyId
2225    </sql>
2226    <description>
2227      A Hibernate query that loads all PluginDefinitionKeys for a specified plugin ID.
2228    </description>
2229  </query>
2230 
2231  <query id="LOAD_DEFAULT_GROUPS" type="HQL">
2232    <sql>
2233      SELECT grp
2234      FROM GroupData grp
2235      WHERE grp.default = true
2236    </sql>
2237    <description>
2238      A HQL query that loads all groups which are marked as default
2239      groups.
2240    </description>
2241  </query>
2242 
2243  <query id="LOAD_DEFAULT_ROLES" type="HQL">
2244    <sql>
2245      SELECT rle
2246      FROM RoleData rle
2247      WHERE rle.default = true
2248    </sql>
2249    <description>
2250      A HQL query that loads all roles which are marked as default
2251      roles.
2252    </description>
2253  </query>
2254 
2255  <query id="GET_RAWBIOASSAYS_FOR_PLATFORM" type="HQL">
2256    <sql>
2257      SELECT {1}
2258      FROM RawBioAssayData rba
2259      WHERE rba.platform = :platform
2260    </sql>
2261    <description>
2262      A Hibernate query that gets raw bioassays
2263      with a given platform.
2264    </description>
2265  </query>
2266
2267  <query id="GET_ARRAYDESIGNS_FOR_PLATFORM" type="HQL">
2268    <sql>
2269      SELECT {1}
2270      FROM ArrayDesignData ad
2271      WHERE ad.platform = :platform
2272    </sql>
2273    <description>
2274      A Hibernate query that gets array designs
2275      with a given platform.
2276    </description>
2277  </query>
2278 
2279  <query id="GET_RAWBIOASSAYS_FOR_VARIANT" type="HQL">
2280    <sql>
2281      SELECT {1}
2282      FROM RawBioAssayData rba
2283      WHERE rba.variant = :variant
2284    </sql>
2285    <description>
2286      A Hibernate query that gets raw bioassays
2287      with a given platform variant.
2288    </description>
2289  </query>
2290
2291  <query id="GET_ARRAYDESIGNS_FOR_VARIANT" type="HQL">
2292    <sql>
2293      SELECT {1}
2294      FROM ArrayDesignData ad
2295      WHERE ad.variant = :variant
2296    </sql>
2297    <description>
2298      A Hibernate query that gets array designs
2299      with a given platform variant.
2300    </description>
2301  </query>
2302 
2303  <query id="GET_PLATFORM_FOR_EXTERNAL_ID" type="HQL">
2304    <sql>
2305      SELECT plf
2306      FROM PlatformData plf
2307      WHERE plf.externalId = :externalId
2308    </sql>
2309    <description>
2310      A Hibernate query that loads a platform by external ID.
2311    </description>
2312  </query>
2313 
2314  <query id="GET_PLATFORMVARIANT_FOR_EXTERNAL_ID" type="HQL">
2315    <sql>
2316      SELECT plv
2317      FROM PlatformVariantData plv
2318      WHERE plv.externalId = :externalId
2319    </sql>
2320    <description>
2321      A Hibernate query that loads a platform variant by external ID.
2322    </description>
2323  </query>
2324 
2325  <query id="GET_DATAFILETYPE_FOR_EXTERNAL_ID" type="HQL">
2326    <sql>
2327      SELECT dft
2328      FROM DataFileTypeData dft
2329      WHERE dft.externalId = :externalId
2330    </sql>
2331    <description>
2332      A Hibernate query that loads a data file type by external ID.
2333    </description>
2334  </query>
2335
2336  <query id="GET_FILESETMEMBERS_FOR_DATAFILETYPE" type="HQL">
2337    <sql>
2338      SELECT {1}
2339      FROM FileSetMemberData mbr
2340      WHERE mbr.dataFileType = :dataFileType
2341    </sql>
2342    <description>
2343      A Hibernate query that gets file set members of a specific
2344      data file type.
2345    </description>
2346  </query>
2347
2348  <query id="GET_PLATFORMFILETYPE_FOR_DATAFILETYPE" type="HQL">
2349    <sql>
2350      SELECT {1}
2351      FROM PlatformFileTypeData pft
2352      WHERE pft.dataFileType = :dataFileType
2353    </sql>
2354    <description>
2355      A Hibernate query that gets platform file types of a specific
2356      data file type.
2357    </description>
2358  </query>
2359 
2360  <query id="GET_FILESETMEMBER_FOR_DATAFILETYPE" type="HQL">
2361    <sql>
2362      SELECT mbr
2363      FROM FileSetMemberData mbr
2364      WHERE mbr.dataFileType.externalId = :externalId
2365      AND mbr.fileSet = :fileSet
2366    </sql>
2367    <description>
2368      A Hibernate query that loads a member in a given file set
2369      if we know the external ID of the data file type.
2370    </description>
2371  </query>
2372
2373 
2374  <query id="UPDATE_JOB_STATUS" type="HQL">
2375    <sql>
2376      UPDATE JobData job
2377      SET
2378        job.percentComplete = :percent,
2379        job.statusMessage = :statusMessage
2380      WHERE job.id = :id
2381    </sql>
2382    <description>
2383      A HQL query that updates the progress information on a specific job.
2384    </description>
2385  </query>
2386 
2387  <query id="APPEND_JOB_STATUS" type="HQL">
2388    <sql>
2389      UPDATE JobData job
2390      SET
2391        job.statusMessage = job.statusMessage || :statusMessage
2392      WHERE job.id = :id
2393    </sql>
2394    <description>
2395      A HQL query that appends a string to the status message on a specific job.
2396    </description>
2397  </query>
2398
2399  <query id="LOAD_RAWBIOASSAY_JOBS_IN_EXPERIMENT" type="HQL">
2400    <sql>
2401      SELECT DISTINCT rba.job.id
2402      FROM RawBioAssayData rba
2403      WHERE rba.job.experiment = :experiment
2404    </sql>
2405    <description>
2406      A HQL query that loads the ID:s of all jobs that are part
2407      of a given experiment and also has been assigned to at
2408      least one raw bioassay.
2409    </description>
2410  </query>
2411 
2412  <query id="LOAD_ARRAYDESIGN_JOBS_IN_EXPERIMENT" type="HQL">
2413    <sql>
2414      SELECT ad.job.id
2415      FROM ArrayDesignData ad
2416      WHERE ad.job.experiment = :experiment
2417    </sql>
2418    <description>
2419      A HQL query that loads the ID:s of all jobs that are part
2420      of a given experiment and also has been assigned to at
2421      least one array design.
2422    </description>
2423  </query>
2424
2425  <query id="UNLINK_JOBS_FROM_EXPERIMENT" type="HQL">
2426    <sql>
2427      UPDATE JobData job
2428      SET job.experiment = null
2429      WHERE job.id IN (:list)
2430    </sql>
2431    <description>
2432      A HQL query that set the experiment property to null for
2433      a given set of jobs.
2434    </description>
2435  </query>
2436 
2437  <query id="GET_UNIT_WITH_NAME_FOR_QUANTITY" type="HQL">
2438    <sql>
2439      SELECT unt
2440      FROM UnitData unt
2441      WHERE unt.quantity = :quantity
2442      AND unt.name = :name
2443    </sql>
2444    <description>
2445      A HQL query that finds the unit for a quantity
2446      with a given name.
2447    </description>
2448  </query>
2449
2450  <query id="GET_UNITS_FOR_QUANTITY" type="HQL">
2451    <sql>
2452      SELECT {1}
2453      FROM UnitData unt
2454      WHERE unt.quantity = :quantity
2455    </sql>
2456    <description>
2457      A Hibernate query that gets units
2458      for a given quantity.
2459    </description>
2460  </query>
2461
2462  <query id="GET_ANNOTATIONTYPES_FOR_QUANTITY" type="HQL">
2463    <sql>
2464      SELECT {1}
2465      FROM AnnotationTypeData at
2466      WHERE at.quantity = :quantity
2467    </sql>
2468    <description>
2469      A Hibernate query that gets annotation types
2470      that are using a given quantity.
2471    </description>
2472  </query>
2473 
2474  <query id="GET_ANNOTATIONTYPES_FOR_UNIT" type="HQL">
2475    <sql>
2476      SELECT {1}
2477      FROM AnnotationTypeData at
2478      WHERE at.defaultUnit = :unit
2479    </sql>
2480    <description>
2481      A Hibernate query that gets annotation types
2482      that are using a given unit as default unit.
2483    </description>
2484  </query>
2485 
2486  <query id="GET_ANNOTATIONS_FOR_UNIT" type="HQL">
2487    <sql>
2488      SELECT {1}
2489      FROM AnnotationData a
2490      WHERE a.unit = :unit
2491    </sql>
2492    <description>
2493      A Hibernate query that gets annotations
2494      that are using a given unit.
2495    </description>
2496  </query>
2497 
2498  <query id="GET_UNIT_WITH_SYMBOL_FOR_QUANTITY" type="HQL">
2499    <sql>
2500      SELECT unt
2501      FROM UnitData unt
2502      JOIN unt.symbols smb
2503      WHERE unt.quantity = :quantity
2504      AND smb.symbol = :symbol
2505    </sql>
2506    <description>
2507      A HQL query that finds the unit for a quantity
2508      with a given symbol.
2509    </description>
2510  </query>
2511 
2512  <query id="GET_UNIT_WITH_SYMBOL_FOR_UNIT" type="HQL">
2513    <sql>
2514      SELECT smb.unit
2515      FROM UnitSymbolData smb
2516      JOIN smb.quantity qnt
2517      JOIN qnt.units unt
2518      WHERE unt = :unit
2519      AND smb.symbol = :symbol
2520    </sql>
2521    <description>
2522      A HQL query that finds the unit with a given symbol
2523      that has the same quantity as another unit.
2524    </description>
2525  </query>
2526 
2527  <query id="SET_UNIT_TO_NULL_ON_PROPERTY_FILTERS" type="SQL">
2528    <sql>
2529      UPDATE [PropertyFilters]
2530      SET [unit_id] = null
2531      WHERE [unit_id] = :unit
2532    </sql>
2533    <description>
2534      A SQL query that sets the unit to null for all properties
2535      with a given unit (about to be deleted).
2536    </description>
2537  </query>
2538 
2539  <query id="RECALCULATE_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="SQL">
2540    <sql>
2541      UPDATE [{1}]
2542      SET [value] = [value] * :factor + :offset
2543      WHERE [id] IN
2544      (
2545        SELECT [value_id]
2546        FROM [Annotations]
2547        WHERE [annotationtype_id] = :annotationType
2548      )
2549    </sql>
2550    <description>
2551      A SQL query that recalculates the annotation values for
2552      a given annotation type.
2553    </description>
2554  </query>
2555 
2556  <query id="SET_UNIT_ON_ANNOTATIONS_WITH_ANNOTATIONTYPE" type="HQL">
2557    <sql>
2558      UPDATE AnnotationData a
2559      SET a.unit = :unit
2560      WHERE a.annotationType = :annotationType
2561    </sql>
2562    <description>
2563      A HQL query that changes the unit for all annotations with a given
2564      annotation type.
2565    </description>
2566  </query>
2567 
2568  <query id="RECALCULATE_ANNOTATIONS_FOR_UNIT" type="SQL">
2569    <sql>
2570      UPDATE [{1}] SET [value] = [value] * :factor + :offset
2571      WHERE [id] IN
2572      (
2573        SELECT [a].[value_id]
2574        FROM [Annotations] [a]
2575        JOIN [AnnotationTypes] [at] ON [at].[id] = [a].[annotationtype_id]
2576        WHERE [at].[value_type] = :valueType
2577        AND
2578        (
2579          (:case = 1 AND [a].[unit_id] = :unit AND [at].[default_unit_id] &lt;&gt; :unit)
2580          OR
2581          (:case = 2 AND [a].[unit_id] &lt;&gt; :unit AND [at].[default_unit_id] = :unit)
2582        )
2583      )
2584    </sql>
2585    <description>
2586      A SQL query that recalculates the annotation values for
2587      when reference factor and/or offset changes. The query must handle
2588      two cases where either the annotation type's default unit
2589      or the annotation's unit matched. More info in doc for the
2590      Unit.changeReferenceFactorAndOffset() method.
2591    </description>
2592  </query>
2593
2594  <query id="UPDATE_ITEMLIST_SIZE" type="SQL">
2595    <sql>
2596      UPDATE [ItemLists]
2597      SET [size] = [size] + :delta
2598      WHERE [member_type] = :memberType
2599      AND [id] = ANY(
2600        SELECT [list_id]
2601        FROM [ItemListMembers]
2602        WHERE [item_id] = :itemId
2603      )
2604    </sql>
2605    <description>
2606      An update query that changes the size for all item lists
2607      where a given item is a member. Mainly used to decrease
2608      the size when an item is deleted.
2609    </description>
2610  </query>
2611 
2612  <query id="DELETE_ITEMLIST_MEMBER" type="SQL">
2613    <sql>
2614      DELETE FROM [ItemListMembers]
2615      WHERE [item_id] = :itemId
2616      AND [list_id] = ANY(
2617        SELECT [id]
2618        FROM [ItemLists]
2619        WHERE [member_type] = :memberType
2620      )
2621    </sql>
2622    <description>
2623      An update query that delete the list member entries
2624      for all lists where the given item is a member.
2625    </description>
2626  </query>
2627 
2628  <query id="GET_BIOMATERIAL_ON_PLATE" type="HQL">
2629    <sql>
2630      SELECT {1}
2631      FROM MeasuredBioMaterialData mbm
2632      JOIN mbm.bioWell bw
2633      WHERE bw.bioPlate = :bioPlate
2634    </sql>
2635    <description>
2636      A HQL query that gets MeasuredBioMaterial:s
2637      located on a given bioplate.
2638    </description>
2639  </query>
2640  <query id="FIND_USED_TYPES_IN_ANYTOANY" type="SQL">
2641    <sql>
2642      SELECT [a].[from_type] FROM [AnyToAny] [a]
2643      UNION
2644      SELECT [a].[to_type] FROM [AnyToAny] [a]
2645    </sql>
2646    <description>
2647      An SQL query that selects all used item types in any-to-any
2648      links. It must select both the the 'from' and 'to' item type.
2649    </description>
2650  </query>
2651  <query id="SELECT_STRAY_ANYTOANY" type="SQL">
2652    <sql>
2653      SELECT [a].[id]
2654      FROM [AnyToAny] [a]
2655      LEFT JOIN [{1}] [t]
2656        ON ([t].[id] = [a].[from_id] AND [a].[from_type] = :type)
2657        OR ([t].[id] = [a].[to_id] AND [a].[to_type] = :type)
2658      WHERE [t].[id] IS NULL
2659      AND ([a].[from_type] = :type OR [a].[to_type] = :type)
2660    </sql>
2661    <description>
2662      An SQL query that selects the ID of all any-to-any links were
2663      either the 'from' or 'to' item is missing. A single query
2664      is used to delete all items of a specific type (both
2665      'from' and 'to).
2666    </description>
2667  </query>
2668  <query id="DELETE_STRAY_ANYTOANY" type="HQL">
2669    <sql>
2670      DELETE FROM AnyToAnyData
2671      WHERE id IN (:ids)
2672    </sql>
2673    <description>
2674      A HQL query that deletes all any-to-any links with the
2675      id's given in the list.
2676    </description>
2677  </query>
2678  <query id="FIND_USED_TYPES_IN_CHANGEHISTORY" type="HQL">
2679    <sql>
2680      SELECT DISTINCT ch.itemType FROM ChangeHistoryDetailData ch
2681    </sql>
2682    <description>
2683      An HQL query that selects all used item types in the change
2684      history table.
2685    </description>
2686  </query>
2687  <query id="DELETE_STRAY_CHANGEHISTORY" type="HQL">
2688    <sql>
2689      DELETE FROM ChangeHistoryDetailData
2690      WHERE id IN (:ids)
2691    </sql>
2692    <description>
2693      A HQL query that deletes all change history entries with the
2694      id's given in the list.
2695    </description>
2696  </query>
2697  <query id="SELECT_STRAY_CHANGEHISTORY" type="SQL">
2698    <sql>
2699      SELECT [ch].[id]
2700      FROM [ChangeHistoryDetails] [ch]
2701      LEFT JOIN [{1}] [t]
2702        ON ([t].[id] = [ch].[item_id] AND [ch].[item_type] = :type)
2703      WHERE [t].[id] IS NULL
2704      AND [ch].[item_type] = :type
2705    </sql>
2706    <description>
2707      An SQL query that selects the ID of all change history entries
2708      that references a missing item of a specified type.
2709    </description>
2710  </query>
2711  <query id="DBLOG_GET_ANNOTATIONTYPE_INFO" type="HQL">
2712    <sql>
2713      SELECT at.name, at.valueType, at.disableLogOfValues
2714      FROM AnnotationTypeData at
2715      WHERE at.id = :annotationTypeId
2716    </sql>
2717    <description>
2718      An HQL query that loads the 'name', 'valueType' and 'disableLogOfValues' flag
2719      for an annotation type given the ID.
2720    </description>
2721  </query>
2722  <query id="DBLOG_GET_ANNOTATION_ITEMTYPE" type="HQL">
2723    <sql>
2724      SELECT a.itemType
2725      FROM AnnotationSetData a
2726      WHERE a.id = :annotationSetId
2727    </sql>
2728    <description>
2729      An HQL query that loads the item type value an annotation
2730      set with a given ID belongs to.
2731    </description>
2732  </query>
2733  <query id="DBLOG_GET_ITEMID_WITH_ANNOTATION" type="HQL">
2734    <sql>
2735      SELECT i.id
2736      FROM {1} i
2737      WHERE i.annotationSet = :annotationSetId
2738    </sql>
2739    <description>
2740      An HQL query that loads the ID of the item that
2741      is associated with a given annotation set.
2742    </description>
2743  </query>
2744  <query id="DBLOG_GET_NAME_FOR_ITEM" type="HQL">
2745    <sql>
2746      SELECT i.name
2747      FROM {1} i
2748      WHERE i.id = :id
2749    </sql>
2750    <description>
2751      An HQL query that loads the name of a an item.
2752    </description>
2753  </query>
2754  <query id="DBLOG_GET_FILESET_ITEMTYPE" type="HQL">
2755    <sql>
2756      SELECT fs.itemType
2757      FROM FileSetData fs
2758      WHERE fs.id = :fileSetId
2759    </sql>
2760    <description>
2761      An HQL query that loads the item type value a file set
2762      set with a given ID belongs to.
2763    </description>
2764  </query>
2765  <query id="DBLOG_GET_ITEMID_WITH_FILESET" type="HQL">
2766    <sql>
2767      SELECT i.id
2768      FROM {1} i
2769      WHERE i.fileSet = :fileSetId
2770    </sql>
2771    <description>
2772      An HQL query that loads the ID of the item that
2773      is associated with a given file set.
2774    </description>
2775  </query>
2776  <query id="GET_GROUPS_WITH_NONHIDDENMEMBERS" type="HQL">
2777    <sql>
2778      SELECT grp.id
2779      FROM GroupData grp
2780      WHERE grp.hiddenMembers = false
2781      AND grp.id IN (:groups)
2782    </sql>
2783    <description>
2784      A HQL query that selects the ID of the groups among a given set of
2785      groups that has 'hiddenMembers=false'
2786    </description>
2787  </query>
2788  <query id="GET_BIOPLATES_FOR_BIOPLATETYPE" type="HQL">
2789    <sql>
2790      SELECT {1}
2791      FROM BioPlateData bpl
2792      WHERE bpl.bioPlateType = :bioPlateType
2793    </sql>
2794    <description>
2795      A HQL query that gets the bioplates using a given type.
2796    </description>
2797  </query>
2798 
2799  <query id="GET_BIOPLATETYPE_WITH_NAME" type="HQL">
2800    <sql>
2801      SELECT bpt
2802      FROM BioPlateTypeData bpt
2803      WHERE bpt.name = :name
2804    </sql>
2805    <description>
2806      A HQL query that gets the bioplate type with a given name.
2807    </description>
2808  </query>
2809  <query id="GET_PROJECTS_FOR_PERMISSION_TEMPLATE" type="HQL">
2810    <sql>
2811      SELECT {1}
2812      FROM ProjectData prj
2813      WHERE prj.permissionTemplate = :permissionTemplate
2814    </sql>
2815    <description>
2816      A HQL query that gets the projects that are using a given permission
2817      template.
2818    </description>
2819  </query>
2820
2821  <query id="SET_GROUP_TO_NULL_ON_DISK_USAGE" type="HQL">
2822    <sql>
2823      UPDATE DiskUsageData du
2824        SET du.group = null
2825        WHERE du.group = :group
2826    </sql>
2827    <description>
2828      An HQL update-query that sets group to null on all
2829      diskusage that are associated with a given group.
2830    </description>
2831  </query>
2832
2833  <query id="CLEAR_ORIGINAL_BIOMATERIAL_ON_BIOWELLS" type="HQL">
2834    <sql>
2835      UPDATE BioWellData bw
2836      SET bw.originalBioMaterial = null
2837      WHERE bw.originalBioMaterial = :bioMaterial
2838    </sql>
2839    <description>
2840      An HQL update-query that for a given biomaterial clears the
2841      link on all biowells were it is set as the original biomaterial.
2842    </description>
2843  </query>
2844
2845  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATEEVENT" type="HQL">
2846    <sql>
2847      UPDATE BioMaterialEventData bme
2848      SET bme.bioPlateEventParticipant = null
2849      WHERE bme.bioPlateEventParticipant =ANY (
2850        SELECT bep FROM BioPlateEventParticipantData bep
2851        WHERE bep.event = :event
2852      )
2853    </sql>
2854    <description>
2855      An HQL update-query that clears the references to a given
2856      bioplate event on all biomaterial events that links to it
2857      (via the bioplate event participant table).
2858    </description>
2859  </query>
2860
2861  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_BIOPLATE" type="HQL">
2862    <sql>
2863      UPDATE BioMaterialEventData bme
2864      SET bme.bioPlateEventParticipant = null
2865      WHERE bme.bioPlateEventParticipant =ANY (
2866        SELECT bep FROM BioPlateEventParticipantData bep
2867        WHERE bep.bioPlate = :bioPlate
2868      )
2869    </sql>
2870    <description>
2871      An HQL update-query that clears the references to all bioplate
2872      event participants on biomaterial events for a given bioplate.
2873    </description>
2874  </query>
2875
2876  <query id="CLEAR_PARTICIPANT_ON_BIOMATERIALEVENTS_FOR_PARTICIPANT" type="HQL">
2877    <sql>
2878      UPDATE BioMaterialEventData bme
2879      SET bme.bioPlateEventParticipant = null
2880      WHERE bme.bioPlateEventParticipant = :participant
2881    </sql>
2882    <description>
2883      An HQL update-query that clears the references to a given bioplate
2884      event participant on all related biomaterial events.
2885    </description>
2886  </query>
2887
2888  <query id="GET_BIOPLATEEVENTS_FOR_BIOPLATEEVENTTYPE" type="HQL">
2889    <sql>
2890      SELECT {1}
2891      FROM BioPlateEventData bpe
2892      WHERE bpe.eventType = :eventType
2893    </sql>
2894    <description>
2895      An HQL update-query that gets the bioplate events that are
2896      of a given bioplate event type.
2897    </description>
2898  </query>
2899 
2900  <query id="GET_JAR_PATH_FROM_TABLE" type="SQL">
2901    <sql>
2902      SELECT [id], [jar_path] FROM [{1}] [t]
2903      where [t].[jar_file] IS NULL AND NOT [t].[jar_path] IS NULL
2904    </sql>
2905    <description>
2906      An SQL query that selects the ID and JAR_PATH column from a given table
2907      where the existing JAR_PATH has a value and the existing JAR_FILE is
2908      null.
2909    </description>
2910  </query>
2911
2912  <query id="SET_JAR_FILE_IN_TABLE" type="SQL">
2913    <sql>
2914      UPDATE [{1}] SET [jar_file] = :file WHERE id = :id
2915    </sql>
2916    <description>
2917      An SQL query that updates the JAR_FILE with the given value.
2918    </description>
2919  </query>
2920 
2921  <query id="DROP_COLUMN" type="SQL">
2922    <sql>
2923      ALTER TABLE [{1}] DROP COLUMN [{2}]
2924    </sql>
2925    <description>
2926      An SQL query that drops a column (2) from a table (1).
2927    </description>
2928  </query>
2929 
2930  <query id="DROP_NOT_NULL_CONSTRAINT" type="SQL">
2931    <sql>
2932      ALTER TABLE [{1}] ALTER COLUMN [{2}] DROP NOT NULL
2933    </sql>
2934    <description>
2935      An SQL query that drops a NOT NULL contraint from column (2) in a table (1).
2936    </description>
2937  </query>
2938
2939  <query id="DROP_TABLE" type="SQL">
2940    <sql>
2941      DROP TABLE [{1}]
2942    </sql>
2943    <description>
2944      An SQL query that drops a table (1).
2945    </description>
2946  </query>
2947
2948  <query id="CONVERT_LABELEDEXTRACTS_TO_EXTRACTS" type="SQL">
2949    <sql>
2950      UPDATE [BioMaterials]
2951      SET [discriminator] = 3
2952      WHERE [discriminator] = 4
2953    </sql>
2954    <description>
2955      An SQL query that convert labeled extract to extract.
2956    </description>
2957  </query>
2958
2959  <query id="GET_HYBRIDIZATIONS" type="SQL">
2960    <sql>
2961      SELECT
2962        [id], [version],
2963        [arrayslide_id], [num_arrays],
2964        [annotationset_id], [name],
2965        [description], [removed],
2966        [itemkey_id], [projectkey_id],
2967        [owner]
2968      FROM
2969        [Hybridizations]
2970    </sql>
2971    <description>
2972      An SQL query that load all BASE 2.17 hybridizations.
2973    </description>
2974  </query>
2975
2976  <query id="UPDATE_BIOASSAYID_FROM_HYBID" type="SQL">
2977    <sql>
2978      UPDATE [BioMaterialEvents]
2979      SET [physicalbioassay_id] = :bioAssayId
2980      WHERE [hybridization_id] = :hybId
2981    </sql>
2982    <description>
2983      An SQL query that sets the physicalbioassay_id
2984      for a given hybridization_id
2985    </description>
2986  </query>
2987
2988  <query id="GET_SCANS" type="SQL">
2989    <sql>
2990      SELECT
2991        [id], [version],
2992        [entry_date], [hybridization_id],
2993        [hardware_id], [protocol_id],
2994        [annotationset_id], [name],
2995        [description], [removed],
2996        [itemkey_id], [projectkey_id],
2997        [owner]
2998      FROM
2999        [Scans]
3000    </sql>
3001    <description>
3002      An SQL query that load all BASE 2.17 scans.
3003    </description>
3004  </query>
3005
3006  <query id="GET_IMAGES" type="SQL">
3007    <sql>
3008      SELECT
3009        [id], [version],
3010        [file_id]
3011      FROM
3012        [Images]
3013      WHERE [scan_id] = :scanId
3014    </sql>
3015    <description>
3016      An SQL query that load BASE 2.17 image files for a given scan.
3017    </description>
3018  </query>
3019
3020  <query id="GET_PROTOCOLTYPES" type="SQL">
3021    <sql>
3022      SELECT
3023        [id], [version],
3024        [entry_date], [name],
3025        [description], [removed],
3026        [system_id]
3027      FROM
3028        [ProtocolTypes]
3029    </sql>
3030    <description>
3031      An SQL query that load all BASE 2.17 protocol types.
3032    </description>
3033  </query>
3034
3035  <query id="GET_HARDWARETYPES" type="SQL">
3036    <sql>
3037      SELECT
3038        [id], [version],
3039        [entry_date], [name],
3040        [description], [removed],
3041        [system_id]
3042      FROM
3043        [HardwareTypes]
3044    </sql>
3045    <description>
3046      An SQL query that load all BASE 2.17 hardware types.
3047    </description>
3048  </query>
3049 
3050  <query id="GET_SOFTWARETYPES" type="SQL">
3051    <sql>
3052      SELECT
3053        [id], [version],
3054        [entry_date], [name],
3055        [description], [system_id]
3056      FROM
3057        [SoftwareTypes]
3058    </sql>
3059    <description>
3060      An SQL query that load all BASE 2.17 software types.
3061    </description>
3062  </query>
3063
3064  <query id="GET_FILETYPES" type="SQL">
3065    <sql>
3066      SELECT
3067        [id], [version],
3068        [entry_date], [name],
3069        [description], [system_id]
3070      FROM
3071        [FileTypes]
3072    </sql>
3073    <description>
3074      An SQL query that load all BASE 2.17 file types.
3075    </description>
3076  </query>
3077
3078  <query id="GET_RAWBIOASSAYS" type="SQL">
3079    <sql>
3080      SELECT
3081        [id], [scan_id],
3082        [array_num]
3083      FROM [RawBioAssays]
3084      WHERE NOT [scan_id] IS NULL
3085    </sql>
3086    <description>
3087      An SQL query that load scan and array num for all raw bioassays
3088      that has a scan parent.
3089    </description>
3090  </query>
3091
3092  <query id="FIND_EXTRACT_FOR_RAWBIOASSAY_POSITION" type="SQL">
3093    <sql>
3094      SELECT bm2.[biomaterial_id]
3095      FROM [DerivedBioAssays] dba
3096      INNER JOIN [ParentPhysicalBioAssays] pba ON pba.[derivedbioassay_id] = dba.[id]
3097      INNER JOIN [BioMaterialEvents] bme ON bme.[physicalbioassay_id] = pba.[physicalbioassay_id]
3098      INNER JOIN [BioMaterialEventSources2] bm2 ON bm2.[event_id]=bme.[id]
3099      WHERE bm2.[position] = :position AND dba.[id] = :derivedBioAssayId
3100    </sql>
3101    <description>
3102      An SQL query that tries to find the extract id given a
3103      derived bioassay and the bioassay position.
3104    </description>
3105  </query>
3106 
3107  <query id="UPDATE_RAWBIOASSAY" type="SQL">
3108    <sql>
3109      UPDATE [RawBioAssays]
3110      SET [bioassay_id] = :parentBioAssayId,
3111      [extract_id] = :extractId
3112      WHERE [id] = :rawBioAssayId
3113    </sql>
3114    <description>
3115      An SQL query that update the parent bioassay and extract
3116      for a given raw bioassay.
3117    </description>
3118  </query>
3119
3120
3121  <query id="COPY_BIOMATERIALEVENTSOURCES" type="SQL">
3122    <sql>
3123      INSERT INTO [BioMaterialEventSources2]
3124      (
3125        [id], [version],
3126        [biomaterial_id], [event_id],
3127        [used_quantity], [position]
3128      )
3129      SELECT
3130        {1}, 0,
3131        [biomaterial_id], [event_id],
3132        [used_quantity], [dummy]
3133      FROM [BioMaterialEventSources]
3134    </sql>
3135    <description>
3136      An SQL query that load copy BASE 2.17 biomaterial
3137      event sources to the new table.
3138    </description>
3139  </query>
3140
3141  <query id="COPY_SAMPLE_BIOSOURCE_PARENT_LINK" type="SQL">
3142    <sql>
3143      INSERT INTO [BioMaterialEventSources2]
3144      (
3145        [id], [version],
3146        [biomaterial_id], [event_id],
3147        [used_quantity], [position]
3148      )
3149      SELECT
3150        {1}, 0,
3151        bm.[parent_id], evt.[id],
3152        null, 1
3153      FROM [BioMaterials] bm
3154      INNER JOIN [BioMaterialEvents] evt ON bm.[id]=evt.[biomaterial_id] AND evt.[event_type]=1
3155      WHERE bm.[discriminator] = 2 AND NOT bm.[parent_id] IS NULL
3156    </sql>
3157    <description>
3158      An SQL query that copy Sample--BioSource parent
3159      links to the BioMaterialEventSources2 table.
3160    </description>
3161  </query>
3162
3163  <query id="NULLIFY_ALL_BIOMATERIAL_PARENTS" type="SQL">
3164    <sql>
3165      UPDATE [BioMaterials]
3166      SET [parent_type] = NULL, [parent_id] = NULL
3167    </sql>
3168    <description>
3169      An SQL query that nullify all biomaterial parent
3170      information.
3171    </description>
3172  </query>
3173
3174  <query id="GET_BIOMATERIAL_PARENT_INFO" type="SQL">
3175    <sql>
3176      SELECT bm.[id], bm.[discriminator], evt.[biomaterial_id]
3177      FROM [BioMaterialEventSources2] bm2
3178      INNER JOIN [BioMaterialEvents] evt ON bm2.[event_id]=evt.[id] AND evt.[event_type]=1
3179      INNER JOIN [BioMaterials] bm ON bm2.[biomaterial_id]=bm.[id]
3180      ORDER BY evt.[biomaterial_id]
3181    </sql>
3182    <description>
3183      An SQL query that get parent biomaterial information. We need
3184      parent_id, parent_type and child_id ordered by child_id
3185    </description>
3186  </query>
3187
3188
3189  <query id="SET_BIOMATERIAL_PARENT" type="SQL">
3190    <sql>
3191      UPDATE [BioMaterials]
3192      SET [parent_type] = :parentType, [parent_id] = :parentId
3193      WHERE [id] = :childId
3194    </sql>
3195    <description>
3196      An SQL query that set the biomaterial parent info for a single
3197      biomaterial.
3198    </description>
3199  </query>
3200
3201  <query id="SET_LABELEDEXTRACT_SUBTYPE" type="SQL">
3202    <sql>
3203      UPDATE [BioMaterials]
3204      SET [subtype_id]=:subtype
3205      WHERE [label_id] IS NOT NULL
3206    </sql>
3207    <description>
3208      An SQL query that sets the subtype of labeled extracts
3209    </description>
3210  </query>
3211
3212  <query id="SET_SUBTYPE_ON_ALL" type="SQL">
3213    <sql>
3214      UPDATE [{1}]
3215      SET [subtype_id]=:subtype
3216    </sql>
3217    <description>
3218      An SQL query that sets the subtype
3219      of all items in a table
3220    </description>
3221  </query>
3222
3223  <query id="UPDATE_ANNOTATIONSET_ITEM" type="SQL">
3224    <sql>
3225      UPDATE [AnnotationSets]
3226      SET [item_id] = :newId, [item_type] = {1}
3227      WHERE [id] = :id
3228    </sql>
3229    <description>
3230      An SQL query that update the item_type and item_id
3231      on annotation set.
3232    </description>
3233  </query>
3234
3235  <query id="UPDATE_ANYTOANY_FROMITEM" type="SQL">
3236    <sql>
3237      UPDATE [AnyToAny]
3238      SET [from_id] = :newId, [from_type] = {2}
3239      WHERE [from_id] = :oldId AND [from_type] = {1}
3240    </sql>
3241    <description>
3242      An SQL query that update the from_type and from_id
3243      on any-to-any.
3244    </description>
3245  </query>
3246 
3247  <query id="UPDATE_ANYTOANY_TOITEM" type="SQL">
3248    <sql>
3249      UPDATE [AnyToAny]
3250      SET [to_id] = :newId, [to_type] = {2}
3251      WHERE [to_id] = :oldId AND [to_type] = {1}
3252    </sql>
3253    <description>
3254      An SQL query that update the to_type and to_id
3255      on any-to-any.
3256    </description>
3257  </query>
3258 
3259  <query id="UPDATE_CHANGEHISTORYDETAILS_ITEM" type="SQL">
3260    <sql>
3261      UPDATE [ChangeHistoryDetails]
3262      SET [item_id] = :newId, [item_type] = {2}
3263      WHERE [item_id] = :oldId AND [item_type] = {1}
3264    </sql>
3265    <description>
3266      An SQL query that update the item_type and item_id
3267      on change history details.
3268    </description>
3269  </query>
3270 
3271  <query id="UPDATE_ITEMVALUES_ITEM" type="SQL">
3272    <sql>
3273      UPDATE [ItemValues]
3274      SET [data_class_id] = :newId, [data_class] = :newClass
3275      WHERE [data_class_id] = :oldId AND [data_class] = :oldClass
3276    </sql>
3277    <description>
3278      An SQL query that update the data_class_id and data_class
3279      on item values.
3280    </description>
3281  </query>
3282
3283  <query id="UPDATE_ITEMVALUES_CLASS" type="SQL">
3284    <sql>
3285      UPDATE [ItemValues]
3286      SET [data_class] = :newClass
3287      WHERE [data_class] = :oldClass
3288    </sql>
3289    <description>
3290      An SQL query that update the data_class
3291      on item values.
3292    </description>
3293  </query>
3294
3295  <query id="UPDATE_ITEMTYPE" type="SQL">
3296    <sql>
3297      UPDATE [{1}]
3298      SET [{2}] = {4}
3299      WHERE [{2}] = {3}
3300    </sql>
3301    <description>
3302      An SQL query that update the item-type column on
3303      a generic table.
3304    </description>
3305  </query>
3306
3307  <query id="UPDATE_SUBTYPEID_FROM_OLDTYPEID" type="SQL">
3308    <sql>
3309      UPDATE [{1}]
3310      SET [{2}] = :subtypeId
3311      WHERE [{3}] = :oldTypeId
3312    </sql>
3313    <description>
3314      An SQL query that update the subtype_id column on
3315      a generic table.
3316    </description>
3317  </query>
3318
3319
3320  <query id="DELETE_PLUGINGUICONTEXTS_FOR_ITEMTYPE" type="SQL">
3321    <sql>
3322      DELETE FROM [PluginDefinitionGuiContexts]
3323      WHERE [item_type] = :itemType
3324    </sql>
3325    <description>
3326      An SQL query that delete plug-in gui contexts for
3327      a given item type.
3328    </description>
3329  </query>
3330
3331  <query id="DELETE_PLUGINKEYS_FOR_ITEMTYPE" type="SQL">
3332    <sql>
3333      DELETE FROM [PluginKeys]
3334      WHERE [key_id] IN (
3335        SELECT k.[id]
3336        FROM [Keys] k
3337        WHERE k.[item_type] = :itemType
3338      )
3339    </sql>
3340    <description>
3341      An SQL query that delete plug-in keys referencing keys
3342      for a given item type.
3343    </description>
3344  </query>
3345
3346
3347  <query id="GET_SUBTYPABLE_ITEMS_FOR_SUBTYPE_OF_CLASS" type="HQL">
3348    <sql>
3349      SELECT {1}
3350      FROM {2} sub
3351      WHERE sub.itemSubtype = :subtype
3352    </sql>
3353    <description>
3354      Get all items that are subtyped with a subtype for a given class.
3355    </description>
3356  </query>
3357 
3358  <query id="GET_ITEMLISTS_FOR_SUBTYPE" type="HQL">
3359    <sql>
3360      SELECT {1}
3361      FROM ItemListData il
3362      WHERE il.itemSubtype = :subtype
3363    </sql>
3364    <description>
3365      A Hibernate query that gets ITEMLISTS for a given item subtype.
3366    </description>
3367  </query>
3368 
3369  <query id="GET_MIMETYPES_FOR_FILETYPE" type="HQL">
3370    <sql>
3371      SELECT {1}
3372      FROM MimeTypeData mt
3373      WHERE mt.fileType = :subtype
3374    </sql>
3375    <description>
3376      A Hibernate query that gets MIME types for a given item subtype.
3377    </description>
3378  </query>
3379 
3380  <query id="GET_DATAFILETYPES_FOR_FILETYPE" type="HQL">
3381    <sql>
3382      SELECT {1}
3383      FROM DataFileTypeData dft
3384      WHERE dft.genericType = :subtype
3385    </sql>
3386    <description>
3387      A Hibernate query that gets Data file types for a given item subtype.
3388    </description>
3389  </query>
3390 
3391  <query id="UPDATE_FILESETMEMBER_FILETYPE" type="HQL">
3392    <sql>
3393      UPDATE FileSetMemberData mbr
3394      SET mbr.dataFileType = :newType
3395      WHERE mbr.dataFileType = :oldType
3396    </sql>
3397    <description>
3398      A Hibernate query that update the data file type of all
3399      file set members with a given old data file type.
3400    </description>
3401  </query>
3402 
3403  <query id="DISABLE_ALL_PLUGINS" type="HQL">
3404    <sql>
3405      UPDATE PluginDefinitionData pl
3406      SET pl.disabled = true
3407    </sql>
3408    <description>
3409      A Hibernate query that disable all plug-ins.
3410    </description>
3411  </query>
3412 
3413  <query id="GET_PROJECT_DEFAULT_ANYTOANY" type="HQL">
3414    <sql>
3415      SELECT a FROM AnyToAnyData a
3416      WHERE a.fromType = 24 AND a.name LIKE 'default_%'
3417    </sql>
3418    <description>
3419      A Hibernate query that load all any-to-any links containing
3420      project default items.
3421    </description>
3422  </query>
3423 
3424  <query id="GET_MD5_PASSWORDS" type="SQL">
3425    <sql>
3426      SELECT [id], [md5password] FROM [Passwords]
3427    </sql>
3428    <description>
3429      An SQL query that load all md5 passwords.
3430    </description>
3431  </query>
3432
3433  <query id="SET_ENCRYPTED_PASSWORD" type="SQL">
3434    <sql>
3435      UPDATE [Passwords]
3436      SET [crypted_password] = :cryptedPassword
3437      WHERE [id] = :id
3438    </sql>
3439    <description>
3440      An SQL query that set the encrypted password for a given entry.
3441    </description>
3442  </query>
3443 
3444  <query id="GET_VIRTUALDBS_FOR_REPORTERCLONETEMPLATE" type="HQL">
3445    <sql>
3446      SELECT {1}
3447      FROM VirtualDbData vdb
3448      WHERE vdb.reporterCloneTemplate = :reporterCloneTemplate
3449    </sql>
3450    <description>
3451      A Hibernate query that get virtual databases
3452      that are using a given reporter clone template.
3453    </description>
3454  </query>
3455
3456  <query id="GET_ALL_ANNOTATIONTYPE_IDS_FOR_USER" type="SQL">
3457    <sql>
3458      SELECT [at].[id]
3459      FROM [AnnotationTypes] [at]
3460      WHERE [at].[owner] = :owner
3461      OR [at].[itemkey_id] IN (:itemKeys)
3462      OR [at].[projectkey_id] IN (:projectKeys)
3463    </sql>
3464    <description>
3465      An SQL query that load the ID of all the annotation types
3466      that the current user has access to. We need to set owner,
3467      item keys and project keys as parameters.
3468    </description>
3469  </query>
3470
3471  <query id="COPY_PARENT_PHYSICAL_BIOASSAYS" type="SQL">
3472    <sql>
3473      INSERT INTO [ParentPhysicalBioAssays] ([physicalbioassay_id], [derivedbioassay_id])
3474      SELECT [bioassay_id], [id] FROM [DerivedBioAssays]
3475    </sql>
3476    <description>
3477      An SQL query that copy the parent physical bioassays
3478      to the new (in BASE 3.2) ParentPhysicalBioAssays table
3479    </description>
3480  </query>
3481
3482
3483  <query id="COPY_PARENT_DERIVED_BIOASSAYS" type="SQL">
3484    <sql>
3485      INSERT INTO [ParentDerivedBioAssays] ([parentbioassay_id], [derivedbioassay_id])
3486      SELECT [parent_id], [id] FROM [DerivedBioAssays] WHERE NOT [parent_id] IS NULL
3487    </sql>
3488    <description>
3489      An SQL query that copy the parent derived bioassays
3490      to the new (in BASE 3.2) ParentDerivedBioAssays table
3491    </description>
3492  </query>
3493
3494  <query id="SET_ISROOT_ON_DERIVED_BIOASSAYS" type="SQL">
3495    <sql>
3496      UPDATE [DerivedBioAssays] SET [is_root] = ([parent_id] IS NULL)
3497    </sql>
3498    <description>
3499      An SQL query that set the is_root property on DerivedBioAssays table.
3500    </description>
3501  </query>
3502 
3503  <query id="GET_ITEMSUBTYPE_WITH_NAME_AND_ITEMTYPE" type="HQL">
3504    <sql>
3505      SELECT st FROM ItemSubtypeData st
3506      WHERE st.name = :name AND st.itemType = :itemType
3507    </sql>
3508    <description>
3509      A Hibernate query that load an item subtype given the name
3510      and main item type.
3511    </description>
3512  </query>
3513 
3514  <query id="SET_DISABLE_LOG_FOR_ANNOTATION_TYPES" type="HQL">
3515    <sql>
3516      UPDATE AnnotationTypeData at
3517      SET at.disableLogOfValues = false
3518      WHERE at.disableLogOfValues IS NULL
3519    </sql>
3520    <description>
3521      An HQL query that set the disableLogOfValues=false for all annotation types
3522      with a null value.
3523    </description>
3524  </query>
3525
3526 
3527</predefined-queries>
Note: See TracBrowser for help on using the repository browser.