source: trunk/api/core/conf/common-queries.xml @ 4506

Last change on this file since 4506 was 4506, checked in by Fredrik Levander, 10 years ago

Fixes #812. Querying only for distinct score types with at least one not null value for combined fdr. Ignoring Proteios score type.

File size: 33.4 KB
Line 
1<?xml version="1.0" ?>
2<!DOCTYPE predefined-queries SYSTEM "predefined-queries.dtd" >
3<!--
4  $Id: common-queries.xml 1618 2007-05-09 13:53:02Z fredrik $
5
6  Copyright (C) 2007 Gregory Vincic
7
8  This file is part of Proteios.
9  Available at http://www.proteios.org/
10
11  Proteios is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License
13  as published by the Free Software Foundation; either version 2
14  of the License, or (at your option) any later version.
15
16  Proteios is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  GNU General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330,
24  Boston, MA  02111-1307, USA.
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 org.proteios.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_PARENTGROUPS_IDS_FOR_GROUPS" type="HQL">
115    <sql>
116      SELECT DISTINCT gg.parentId
117      FROM GroupGroups gg
118      WHERE gg.childId IN (:groups)
119      AND gg.parentId NOT IN (:groups)
120    </sql>
121    <description>
122      Load the ID of all groups that are parents to at least one of
123      the given groups, excluding the given groups.
124    </description>
125  </query>
126
127  <query id="GET_PROJECT_IDS_FOR_OWNER" type="HQL">
128    <sql>
129      SELECT p.id
130      FROM ProjectData p
131      WHERE p.owner = :userId
132    </sql>
133    <description>
134      Load the ID of all projects where the given user is the owner.
135    </description>
136  </query>
137
138  <query id="GET_PROJECTINFO_FOR_USER" type="HQL">
139    <sql>
140      SELECT up
141      FROM UserProjects up
142      WHERE up.userId = :userId
143    </sql>
144    <description>
145      Load the UserProjects of all projects where the given user is a member.
146    </description>
147  </query>
148
149  <query id="GET_UNIQUE_SCORE_TYPES_IN_HITS_FOR_PROJECT" type="HQL">
150    <sql>
151      SELECT DISTINCT h.scoreType
152      FROM HitData h
153      WHERE h.project = :project
154      ORDER by h.scoreType
155    </sql>
156    <description>
157      Load all distinct (unique) score types in the Hits table for a project
158    </description>
159  </query>
160 
161    <query id="GET_UNIQUE_SCORE_TYPES_IN_HITS_FOR_PROJECT_WITH_FDR" type="HQL">
162    <sql>
163      SELECT DISTINCT h.scoreType
164      FROM HitData h
165      WHERE h.project = :project
166      AND h.combinedFDR IS NOT NULL
167      ORDER by h.scoreType
168    </sql>
169    <description>
170      Load all distinct (unique) score types in the Hits table for a project
171    </description>
172  </query>
173
174  <query id="GET_UNIQUE_PLATEIDS_IN_HITS_FOR_PROJECT" type="HQL">
175    <sql>
176      SELECT DISTINCT h.plateId
177      FROM HitData h
178      WHERE h.project = :project
179      ORDER by h.plateId
180    </sql>
181    <description>
182      Load all distinct (unique) plateIds in the Hits table for a project.
183    </description>
184  </query>
185
186  <query id="GET_UNIQUE_GELEXTERNALIDS_IN_HITS_FOR_PROJECT" type="HQL">
187    <sql>
188      SELECT DISTINCT h.gelExternalId
189      FROM HitData h
190      WHERE h.project = :project
191      ORDER by h.gelExternalId
192    </sql>
193    <description>
194      Load all distinct (unique) gelIds in the Hits table for a project.
195    </description>
196  </query>
197
198  <query id="GET_UNIQUE_LOCALSAMPLEIDS_IN_HITS_FOR_PROJECT" type="HQL">
199    <sql>
200      SELECT DISTINCT h.localSampleId
201      FROM HitData h
202      WHERE h.project = :project
203      ORDER by h.localSampleId
204    </sql>
205    <description>
206      Load all distinct (unique) localSampleIds in the Hits table for a project.
207    </description>
208  </query>
209
210  <query id="GET_UNIQUE_FRACTIONIDS_IN_HITS_FOR_PROJECT" type="HQL">
211    <sql>
212      SELECT DISTINCT h.fractionId
213      FROM HitData h
214      WHERE h.project = :project
215      ORDER by h.fractionId
216    </sql>
217    <description>
218      Load all distinct (unique) fractionIds in the Hits table for a project.
219    </description>
220  </query>
221 
222  <query id="GET_UNIQUE_REPLICATEIDS_IN_HITS_FOR_PROJECT" type="HQL">
223    <sql>
224      SELECT DISTINCT h.replicateId
225      FROM HitData h
226      WHERE h.project = :project
227      ORDER by h.replicateId
228    </sql>
229    <description>
230      Load all distinct (unique) replicateIds in the Hits table for a project.
231    </description>
232  </query>
233 
234  <query id="GET_UNIQUE_REPLICATEIDS_IN_HITS_FOR_LOCALSAMPLEID_IN_PROJECT" type="HQL">
235    <sql>
236      SELECT DISTINCT h.replicateId
237      FROM HitData h
238      WHERE h.project = :project AND h.localSampleId = :localSampleId
239      ORDER by h.replicateId
240    </sql>
241    <description>
242      Load all distinct (unique) replicateIds for a sampleLocalId in the Hits table for a project.
243    </description>
244  </query>
245 
246  <query id="GET_UNIQUE_PEPTIDE_SEQUENCES_IN_HITS_FOR_PROJECT" type="HQL">
247    <sql>
248      SELECT DISTINCT h.description
249      FROM HitData h
250      WHERE h.project = :project AND h.protein = false
251      ORDER by h.description
252    </sql>
253    <description>
254      Load all distinct (unique) peptide sequences in the Hits table for a project.
255    </description>
256  </query>
257 
258  <query id="GET_UNIQUE_CHARGES_IN_HITS_FOR_PROJECT" type="HQL">
259    <sql>
260      SELECT DISTINCT h.charge
261      FROM HitData h
262      WHERE h.project = :project
263      ORDER by h.charge
264    </sql>
265    <description>
266      Load all distinct (unique) charges in the Hits table for a project.
267    </description>
268  </query>
269 
270  <query id="GET_UNIQUE_EXTERNALIDS_IN_HITS_FOR_PROJECT" type="HQL">
271    <sql>
272      SELECT DISTINCT h.externalId
273      FROM HitData h
274      WHERE h.project = :project
275      ORDER by h.externalId
276    </sql>
277    <description>
278      Load all distinct (unique) external Ids in the Hits table for a project.
279    </description>
280  </query>
281
282  <query id="GET_UNIQUE_IDENTIFICATIONRESULTFILES_IN_HITS_FOR_PROJECT" type="HQL">
283    <sql>
284      SELECT DISTINCT h.identificationResultFile
285      FROM HitData h
286      WHERE h.project = :project
287      ORDER by h.identificationResultFile
288    </sql>
289    <description>
290      Load all distinct (unique) identification result file Ids in the Hits table for a project.
291    </description>
292  </query>
293
294  <query id="GET_UNIQUE_PEAKLISTFILES_IN_HITS_FOR_PROJECT" type="HQL">
295    <sql>
296      SELECT DISTINCT h.peakListFile
297      FROM HitData h
298      WHERE h.project = :project
299      ORDER by h.peakListFile
300    </sql>
301    <description>
302      Load all distinct (unique) peakList file Ids in the Hits table for a project.
303    </description>
304  </query>
305
306  <query id="GET_UNIQUE_PEAKLISTFILES_IN_HITS_FOR_IDENTIFICATIONRESULTFILE_IN_PROJECT" type="HQL">
307    <sql>
308      SELECT DISTINCT h.peakListFile
309      FROM HitData h
310      WHERE h.project = :project AND h.identificationResultFile = :identificationResultFile
311      ORDER by h.peakListFile
312    </sql>
313    <description>
314      Load all distinct (unique) peakList file Ids for an identification result file in the Hits table for a project.
315    </description>
316  </query>
317
318  <query id="GET_UNIQUE_IDENTIFICATIONRESULTFILES_IN_HITS_FOR_PEAKLISTFILE_IN_PROJECT" type="HQL">
319    <sql>
320      SELECT DISTINCT h.identificationResultFile
321      FROM HitData h
322      WHERE h.project = :project AND h.peakListFile = :peakListFile
323      ORDER by h.identificationResultFile
324    </sql>
325    <description>
326      Load all distinct (unique) identification result file Ids for a peakList file in the Hits table for a project.
327    </description>
328  </query>
329
330  <query id="GET_HIT_FOR_FEATURE_MSFILE_FOR_PROJECT" type="HQL">
331    <sql>
332      SELECT h
333      FROM HitData h
334      WHERE h.feature.msFile = :msFile AND h.project = :project
335    </sql>
336    <description>
337      Load all hits which have features with the given msFile in the Feature table for a project
338    </description>
339  </query>
340
341  <query id="GET_UNIQUE_MSFILES_IN_FEATURES_FOR_PROJECT" type="HQL">
342    <sql>
343      SELECT DISTINCT h.msFile
344      FROM FeatureData h
345      WHERE h.project = :project
346    </sql>
347    <description>
348      Load all distinct (unique) ms files in the Feature table for a project
349    </description>
350  </query>
351
352  <query id="GET_UNIQUE_FEATUREFILES_IN_FEATURES_FOR_PROJECT" type="HQL">
353    <sql>
354      SELECT DISTINCT h.featureFile
355      FROM FeatureData h
356      WHERE h.project = :project
357      ORDER by h.featureFile
358    </sql>
359    <description>
360      Load all distinct (unique) feature files in the Feature table for a project
361    </description>
362  </query>
363
364  <query id="GET_UNIQUE_MSFILES_IN_FEATURES_FOR_FEATUREFILE_IN_PROJECT" type="HQL">
365    <sql>
366      SELECT DISTINCT h.msFile
367      FROM FeatureData h
368      WHERE h.project = :project AND h.featureFile = :featureFile
369    </sql>
370    <description>
371      Load all distinct (unique) ms files for a feature file in the Feature table for a project
372    </description>
373  </query>
374
375  <query id="GET_UNIQUE_FEATUREFILES_IN_FEATURES_FOR_MSFILE_IN_PROJECT" type="HQL">
376    <sql>
377      SELECT DISTINCT h.featureFile
378      FROM FeatureData h
379      WHERE h.project = :project AND h.msFile = :msFile
380    </sql>
381    <description>
382      Load all distinct (unique) feature files for an ms file in the Feature table for a project
383    </description>
384  </query>
385
386  <query id="DELETE_FEATURES_FOR_MSFILE_IN_PROJECT" type="HQL">
387    <sql>
388      DELETE FeatureData f
389      WHERE f.project = :project AND f.msFile = :msFile
390    </sql>
391    <description>
392      Delete all features for an ms file in the Feature table for a project
393    </description>
394  </query>
395
396  <query id="GET_IDS_FOR_SEPARATION_METHODS_WITH_SEPARATION_EVENTS" type="HQL">
397    <sql>
398      SELECT separationMethod.id
399      FROM SeparationEventData bme
400      WHERE NOT bme.separationMethod IS NULL
401    </sql>
402    <description>
403      Load all separationMethod ids for separation methods with associated seapration events.
404    </description>
405  </query>
406 
407  <query id="GET_SEPARATIONMETHOD_FOR_EXTERNAL_ID" type="HQL">
408    <sql>
409      SELECT sm
410      FROM SeparationMethodData sm
411      WHERE sm.externalId = :externalId
412    </sql>
413    <description>
414      Load Separationmethod by the given externalId.
415    </description>
416  </query>
417
418  <query id="GET_PROJECTINFO_FOR_GROUPS" type="HQL">
419    <sql>
420      SELECT DISTINCT gp
421      FROM GroupProjects gp
422      WHERE gp.groupId IN (:groups)
423    </sql>
424    <description>
425      Load the GroupProjects of all projects where at least one of the given groups
426      is a member.
427    </description>
428  </query>
429
430  <query id="GET_USER_IDS_FOR_GROUPS" type="HQL">
431    <sql>
432      SELECT ug.userId
433      FROM UserGroups ug
434      WHERE ug.groupId IN (:groups)
435    </sql>
436    <description>
437      Load the ID of all users which is a member of at least one of the given groups.
438    </description>
439  </query>
440
441  <query id="GET_USERKEYS_FOR_USER" type="HQL">
442    <sql>
443      SELECT uk
444      FROM UserKeys uk
445      WHERE uk.userId = :userId
446    </sql>
447    <description>
448      Load the UserKeys for the given user.
449    </description>
450  </query>
451
452  <query id="GET_GROUPKEYS_FOR_GROUPS" type="HQL">
453    <sql>
454      SELECT gk
455      FROM GroupKeys gk
456      WHERE gk.groupId IN (:groups)
457    </sql>
458    <description>
459      Load the GroupKeys for the given groups.
460    </description>
461  </query>
462
463  <query id="GET_ROLEKEYS_FOR_USER" type="HQL">
464    <sql>
465      SELECT rk
466      FROM RoleKeys rk, UserRoles ur
467      WHERE rk.roleId = ur.roleId AND ur.userId = :userId
468      ORDER BY rk.keyId
469    </sql>
470    <description>
471      Load the RoleKeys for the roles where the given user is a member.
472    </description>
473  </query>
474
475  <query id="GET_PROJECTKEYS_FOR_PROJECT" type="HQL">
476    <sql>
477      SELECT pk
478      FROM ProjectKeys pk
479      WHERE pk.projectId = :projectId
480      ORDER BY pk.keyId
481    </sql>
482    <description>
483      Load the ProjectKeys for the given project.
484    </description>
485  </query>
486
487  <query id="GET_PERMISSION_FOR_USER_IN_PROJECT" type="HQL">
488    <sql>
489      SELECT up.permission
490      FROM UserProjects up
491      WHERE up.userId = :userId
492      AND up.projectId = :projectId
493    </sql>
494    <description>
495      Load the permission for the given user in the given project.
496    </description>
497  </query>
498
499  <query id="GET_PERMISSIONS_FOR_GROUPS_IN_PROJECT" type="HQL">
500    <sql>
501      SELECT gp.permission
502      FROM GroupProjects gp
503      WHERE gp.groupId IN (:groups)
504      AND gp.projectId = :projectId
505    </sql>
506    <description>
507      Load the permissions for the given groups in the given project.
508    </description>
509  </query>
510
511  <query id="GET_PROJECTKEY_IDS_FOR_COUNT" type="HQL">
512    <sql>
513      SELECT pk.keyId FROM ProjectKeys pk
514      GROUP BY pk.keyId
515      HAVING count(pk.projectId) = :numPermissions
516    </sql>
517    <description>
518      Load the ID of all project keys which have permissions for the
519      specified number of projects.
520    </description>
521  </query>
522
523  <query id="FIND_USED_PROJECTKEY_IDS" type="HQL">
524    <sql>
525      SELECT DISTINCT sd.projectKey.id
526      FROM org.proteios.core.data.ShareableData sd
527      WHERE NOT sd.projectKey IS NULL
528    </sql>
529    <description>
530      Load the ID of all project keys which are used by at least one
531      shareable item.
532    </description>
533  </query>
534 
535  <query id="SELECT_UNUSED_PROJECTKEYS" type="HQL">
536    <sql>
537      SELECT pk FROM ProjectKeyData pk
538      WHERE pk.id NOT IN (:used)
539    </sql>
540    <description>
541      Load all unused project keys given a list of the ID:s of all used
542      keys.
543    </description>
544  </query>
545
546  <query id="GET_ITEMKEY_IDS_FOR_USERCOUNT" type="HQL">
547    <sql>
548      SELECT ik.id FROM ItemKeyData ik
549      LEFT JOIN ik.users u
550      GROUP BY ik.id
551      HAVING COUNT(u.index) = :numPermissions
552    </sql>
553    <description>
554      Load the ID of all item keys which have permissions for the
555      specified number of users.
556    </description>
557  </query>
558
559  <query id="GET_ITEMKEY_IDS_FOR_GROUPCOUNT" type="HQL">
560    <sql>
561      SELECT ik.id FROM ItemKeyData ik
562      LEFT JOIN ik.groups g
563      WHERE ik.id IN (:candidates)
564      GROUP BY ik.id
565      HAVING count(g.index) = :numPermissions
566    </sql>
567    <description>
568      Load the ID of all item keys which have permissions for the
569      specified number of groups and are among the list of candidates.
570    </description>
571  </query>
572 
573  <query id="FIND_USED_ITEMKEY_IDS" type="HQL">
574    <sql>
575      SELECT DISTINCT sd.itemKey.id
576      FROM org.proteios.core.data.ShareableData sd
577      WHERE NOT sd.itemKey IS NULL
578    </sql>
579    <description>
580      Load the ID of all item keys which are used by at least one
581      shareable item.
582    </description>
583  </query>
584 
585  <query id="SELECT_UNUSED_ITEMKEYS" type="HQL">
586    <sql>
587      SELECT ik FROM ItemKeyData ik
588      WHERE ik.id NOT IN (:used)
589    </sql>
590    <description>
591      Load all unused item keys given a list of the ID:s of all used
592      keys.
593    </description>
594  </query>
595
596  <query id="COUNT_USERS_FOR_QUOTAGROUP" type="HQL">
597    <sql>
598      SELECT count(*)
599      FROM UserData usr
600      WHERE usr.quotaGroup = :theGroup
601    </sql>
602    <description>
603      Count the number of users having the specified group as
604      their quota group.
605    </description>
606  </query>
607 
608  <query id="COUNT_USERS_FOR_QUOTA" type="HQL">
609    <sql>
610      SELECT count(*)
611      FROM UserData u
612      WHERE u.quota = :quota
613    </sql>
614    <description>
615      A Hibernate query that counts the number of users
616      that has been assigned a given quota.
617    </description>
618  </query>
619 
620  <query id="COUNT_GROUPS_FOR_QUOTA" type="HQL">
621    <sql>
622      SELECT count(*)
623      FROM GroupData g
624      WHERE g.quota = :quota
625    </sql>
626    <description>
627      A Hibernate query that counts the number of groups
628      that has been assigned a given quota.
629    </description>
630  </query>
631
632  <query id="GET_SHAREABLE_ITEMS_FOR_ITEMKEY" type="HQL">
633    <sql>
634      SELECT s
635      FROM org.proteios.core.data.ShareableData s
636      WHERE s.itemKey = :itemKey
637    </sql>
638    <description>
639      Get all items beeing shared to the specified item key.
640    </description>
641  </query>
642
643  <query id="GET_SHAREABLE_ITEMS_FOR_PROJECTKEY" type="HQL">
644    <sql>
645      SELECT s
646      FROM org.proteios.core.data.ShareableData s
647      WHERE s.projectKey = :projectKey
648    </sql>
649    <description>
650      Get all items beeing shared to the specified project key.
651    </description>
652  </query>
653
654  <query id="GET_OWNABLE_ITEMS_FOR_USER" type="HQL">
655    <sql>
656      SELECT o
657      FROM org.proteios.core.data.OwnableData o
658      WHERE o.owner = :user
659    </sql>
660    <description>
661      Get all items that are owned by the specified user.
662    </description>
663  </query>
664 
665  <query id="LOAD_USER_CLIENT_SETTINGS" type="HQL">
666    <sql>
667      SELECT s
668      FROM UserClientSettingData s
669      WHERE s.user = :user AND s.client = :client
670    </sql>
671    <description>
672      Load all settings for the specified user and client application.
673    </description>
674  </query>
675 
676  <query id="LOAD_USER_DEFAULT_SETTINGS" type="HQL">
677    <sql>
678      SELECT s
679      FROM UserDefaultSettingData s
680      WHERE s.user = :user
681    </sql>
682    <description>
683      Load all default settings for the specified user.
684    </description>
685  </query>
686
687  <query id="LOAD_CLIENT_DEFAULT_SETTINGS" type="HQL">
688    <sql>
689      SELECT s
690      FROM ClientDefaultSettingData s
691      WHERE s.client = :client
692    </sql>
693    <description>
694      Load all default settings for the specified client application.
695    </description>
696  </query>
697 
698  <query id="GET_MIME_TYPE_FROM_EXTENSION" type="HQL">
699    <sql>
700      SELECT s
701      FROM org.proteios.core.data.MimeTypeData s
702      WHERE s.extension = :extension
703    </sql>
704    <description>
705      A Hibernate query that returns a MimeType given an extension.
706    </description>
707  </query>
708 
709  <query id="GET_MIME_TYPE_DATA_LIST" type="HQL">
710    <sql>
711      SELECT mt
712      FROM MimeTypeData mt
713    </sql>
714    <description>
715      A Hibernate query that returns a list of available MimeTypeData.
716    </description>
717  </query>
718 
719  <query id="GET_TOTAL_DISKUSAGE_FOR_USER" type="HQL">
720    <sql>
721      SELECT sum(du.bytes)
722      FROM DiskUsageData du
723      WHERE du.user = :user
724      AND du.location = :location
725    </sql>
726    <description>
727      A Hibernate query that returns the total used quota
728      for the specified user at the specified location.
729    </description>
730  </query>
731 
732  <query id="GET_SPECIFIC_DISKUSAGE_FOR_USER" type="HQL">
733    <sql>
734      SELECT sum(du.bytes)
735      FROM DiskUsageData du
736      WHERE du.user = :user
737      AND du.location = :location
738      AND du.quotaType = :quotaType
739    </sql>
740    <description>
741      A Hibernate query that returns the used quota for the
742      specific quota type for the specified user at the
743      specified location.
744    </description>
745  </query>
746
747  <query id="GET_TOTAL_DISKUSAGE_FOR_GROUP" type="HQL">
748    <sql>
749      SELECT sum(du.bytes)
750      FROM DiskUsageData du
751      WHERE du.group = :group
752      AND du.location = :location
753    </sql>
754    <description>
755      A Hibernate query that returns the total used quota
756      for the specified group at the specified location.
757    </description>
758  </query>
759
760  <query id="GET_SPECIFIC_DISKUSAGE_FOR_GROUP" type="HQL">
761    <sql>
762      SELECT sum(du.bytes)
763      FROM DiskUsageData du
764      WHERE du.group = :group
765      AND du.location = :location
766      AND du.quotaType = :quotaType
767    </sql>
768    <description>
769      A Hibernate query that returns the used quota for the
770      specific quota type for the specified group at the
771      specified location.
772    </description>
773  </query>
774
775  <query id="COUNT_FILES_IN_DIRECTORY" type="HQL">
776    <sql>
777      SELECT count(*)
778      FROM FileData f
779      WHERE f.directory = :directory
780    </sql>
781    <description>
782      A Hibernate query that counts the number of files
783      in a given directory.
784    </description>
785  </query>
786 
787  <query id="COUNT_FILES_FOR_FILETYPE" type="HQL">
788    <sql>
789      SELECT count(*)
790      FROM FileData f
791      WHERE f.fileType = :filetype
792    </sql>
793    <description>
794      A Hibernate query that counts the number of files
795      with a given filetype.
796    </description>
797  </query>
798
799  <query id="COUNT_SUBDIRECTORIES_IN_DIRECTORY" type="HQL">
800    <sql>
801      SELECT count(*)
802      FROM DirectoryData d
803      WHERE d.parent = :directory
804    </sql>
805    <description>
806      A Hibernate query that counts the number of subdirectories
807      in a given directory.
808    </description>
809  </query>
810 
811  <query id="COUNT_HOME_DIRECTORIES" type="HQL">
812    <sql>
813      SELECT COUNT(*)
814      FROM UserData usr
815      WHERE usr.homeDirectory = :directory
816    </sql>
817    <description>
818      A Hibernate query that counts the number of users having
819      the specified directory as home directory.
820    </description>
821  </query>
822
823  <query id="IS_PROJECT_DIRECTORY" type="HQL">
824    <sql>
825      SELECT count(*)
826      FROM ProjectData d
827      WHERE d.projectDirectory = :directory
828    </sql>
829    <description>
830      A Hibernate query that checks if the given directory is
831      connected to any project as it's main directory.
832    </description>
833  </query>
834 
835  <query id="GET_SUBDIRECTORIES" type="HQL">
836    <sql>
837      SELECT dir
838      FROM DirectoryData dir
839      WHERE dir.parent = :parent
840    </sql>
841    <description>
842      A Hibernate query that returns all subdirectories in a directory.
843    </description>
844  </query>
845 
846  <query id="GET_SUBDIRECTORY_WITH_NAME" type="HQL">
847    <sql>
848      SELECT dir
849      FROM DirectoryData dir
850      WHERE dir.name = :name
851      AND dir.parent = :parent
852    </sql>
853    <description>
854      A Hibernate query that returns the a subdirectory with the
855      specified name in a given directory.
856    </description>
857  </query>
858
859  <query id="GET_FILE_TYPE_WITH_NAME" type="HQL">
860    <sql>
861      SELECT ft
862      FROM FileTypeData ft
863      WHERE ft.name = :name
864    </sql>
865    <description>
866      A Hibernate query that returns the file type with the specified
867      name.
868    </description>
869  </query>
870 
871  <query id="GET_QUOTA_TYPE_WITH_NAME" type="HQL">
872    <sql>
873      SELECT qt
874      FROM QuotaTypeData qt
875      WHERE qt.name = :name
876    </sql>
877    <description>
878      A Hibernate query that returns the quota type with the specified
879      name.
880    </description>
881  </query>
882 
883  <query id="GET_QUOTA_WITH_NAME" type="HQL">
884    <sql>
885      SELECT q
886      FROM QuotaData q
887      WHERE q.name = :name
888    </sql>
889    <description>
890      A Hibernate query that returns the quota with the specified
891      name.
892    </description>
893  </query>
894 
895  <query id="GET_GROUP_WITH_NAME" type="HQL">
896    <sql>
897      SELECT grp
898      FROM GroupData grp
899      WHERE grp.name = :name
900    </sql>
901    <description>
902      A Hibernate query that returns the group with the specified
903      name.
904    </description>
905  </query>
906 
907  <query id="GET_ROLE_WITH_NAME" type="HQL">
908    <sql>
909      SELECT rle
910      FROM RoleData rle
911      WHERE rle.name = :name
912    </sql>
913    <description>
914      A Hibernate query that returns the role with the specified
915      name.
916    </description>
917  </query>
918 
919  <query id="GET_PROTOCOL_TYPE_WITH_NAME" type="HQL">
920    <sql>
921      SELECT pt
922      FROM ProtocolTypeData pt
923      WHERE pt.name = :name
924    </sql>
925    <description>
926      A Hibernate query that returns the protocol type with the specified
927      name.
928    </description>
929  </query>
930 
931  <query id="GET_SOFTWARE_TYPE_WITH_NAME" type="HQL">
932    <sql>
933      SELECT st
934      FROM SoftwareTypeData st
935      WHERE st.name = :name
936    </sql>
937    <description>
938      A Hibernate query that returns the software type with the specified
939      name.
940    </description>
941  </query>
942 
943  <query id="GET_SOFTWARE_WITH_NAME" type="HQL">
944    <sql>
945      SELECT sw
946      FROM SoftwareData sw
947      WHERE sw.name = :name
948    </sql>
949    <description>
950      A Hibernate query that returns the software with the specified
951      name.
952    </description>
953  </query>
954 
955  <query id="GET_HARDWARE_TYPE_WITH_NAME" type="HQL">
956    <sql>
957      SELECT ht
958      FROM HardwareTypeData ht
959      WHERE ht.name = :name
960    </sql>
961    <description>
962      A Hibernate query that returns the hardware type with the specified
963      name.
964    </description>
965  </query>
966 
967  <query id="GET_HARDWARE_WITH_NAME" type="HQL">
968    <sql>
969      SELECT hw
970      FROM HardwareData hw
971      WHERE hw.name = :name
972    </sql>
973    <description>
974      A Hibernate query that returns the hardware with the specified
975      name.
976    </description>
977  </query>
978 
979  <query id="GET_LABEL_WITH_NAME" type="HQL">
980    <sql>
981      SELECT lbl
982      FROM LabelData lbl
983      WHERE lbl.name = :name
984    </sql>
985    <description>
986      A Hibernate query that returns the label with the specified
987      name.
988    </description>
989  </query>
990 
991  <query id="GET_ANNOTATION_TYPE_WITH_NAME" type="HQL">
992    <sql>
993      SELECT at
994      FROM AnnotationTypeData at
995      WHERE at.name = :name
996    </sql>
997    <description>
998      A Hibernate query that returns the annotation type with the specified
999      name.
1000    </description>
1001  </query>
1002 
1003  <query id="GET_NEWS_WITH_NAME" type="HQL">
1004    <sql>
1005      SELECT nws
1006      FROM NewsData nws
1007      WHERE nws.name = :name
1008    </sql>
1009    <description>
1010      A Hibernate query that returns the news with the specified
1011      name.
1012    </description>
1013  </query>
1014
1015  <query id="GET_FILE_IN_DIRECTORY" type="HQL">
1016    <sql>
1017      SELECT f
1018      FROM FileData f
1019      WHERE f.directory = :directory
1020      AND f.name = :name
1021    </sql>
1022    <description>
1023      A Hibernate query that returns the file with the specified
1024      name in a given directory.
1025    </description>
1026  </query>
1027
1028  <query id="COUNT_PROTOCOLS_FOR_PROTOCOLTYPE" type="HQL">
1029    <sql>
1030      SELECT count(*)
1031      FROM ProtocolData p
1032      WHERE p.protocolType = :protocolType
1033    </sql>
1034    <description>
1035      Counts the protocols the uses a protocol type.
1036    </description>
1037  </query>
1038
1039  <query id="COUNT_BIOMATERIALEVENTS_FOR_PROTOCOL" type="HQL">
1040    <sql>
1041      SELECT count(*)
1042      FROM BioMaterialEventData bme
1043      WHERE bme.protocol = :protocol
1044    </sql>
1045    <description>
1046      A Hibernate query that counts the number of biomaterial
1047      events using a protocol.
1048    </description>
1049  </query>
1050
1051  <query id="FIND_USED_FILES" type="HQL">
1052    <sql>
1053      SELECT fad
1054      FROM org.proteios.core.data.FileAttachableData fad
1055      WHERE fad.file = :file
1056    </sql>
1057    <description>
1058      Load the files that is used by any FileAttachableData.
1059    </description>
1060  </query>
1061
1062  <query id="COUNT_HARDWARE_FOR_TYPE" type="HQL">
1063    <sql>
1064      SELECT count(*)
1065      FROM HardwareData hw
1066      WHERE hw.hardwareType = :hardwaretype
1067    </sql>
1068    <description>
1069      A Hibernate query that counts the number of hardware items
1070      of the given hardware type.
1071    </description>
1072  </query>
1073
1074  <query id="COUNT_SOFTWARE_FOR_SOFTWARETYPE" type="HQL">
1075    <sql>
1076      SELECT count(*)
1077      FROM SoftwareData sw
1078      WHERE sw.softwareType = :softwaretype
1079    </sql>
1080    <description>
1081      A Hibernate query that counts the number of software items
1082      of the given software type.
1083    </description>
1084  </query>
1085
1086  <query id="COUNT_ANNOTATIONS_FOR_ANNOTATIONTYPE" type="HQL">
1087    <sql>
1088      SELECT count(*)
1089      FROM AnnotationData a
1090      WHERE a.annotationType = :annotationType
1091    </sql>
1092    <description>
1093      A Hibernate query that counts the number of annotations
1094      of the given annotation type.
1095    </description>
1096  </query>
1097
1098  <query id="COUNT_SAMPLES_FOR_BIOSOURCE" type="HQL">
1099    <sql>
1100      SELECT count(*)
1101      FROM SampleData s
1102      WHERE s.parent = :biosource
1103    </sql>
1104    <description>
1105      A Hibernate query that counts the number of samples
1106      created from a given biosource.
1107    </description>
1108  </query>
1109
1110  <query id="COUNT_EXTRACTS_FOR_SAMPLE" type="HQL">
1111    <sql>
1112      SELECT count(*)
1113      FROM ExtractData e
1114      WHERE e.parent = :sample
1115    </sql>
1116    <description>
1117      A Hibernate query that counts the number of extracts
1118      created from a given sample.
1119    </description>
1120  </query>
1121 
1122  <query id="COUNT_LABELED_EXTRACTS_FOR_EXTRACT" type="HQL">
1123    <sql>
1124      SELECT count(*)
1125      FROM LabeledExtractData le
1126      WHERE le.parent = :extract
1127    </sql>
1128    <description>
1129      A Hibernate query that counts the number of labeled extracts
1130      created from a given extract.
1131    </description>
1132  </query>
1133
1134  <query id="COUNT_LABELED_EXTRACTS_FOR_LABEL" type="HQL">
1135    <sql>
1136      SELECT count(*)
1137      FROM LabeledExtractData le
1138      WHERE le.label = :label
1139    </sql>
1140    <description>
1141      A Hibernate query that counts the number of labeled extracts
1142      with the given label.
1143    </description>
1144  </query>
1145
1146  <query id="COUNT_SOURCEEVENTS_FOR_BIOMATERIAL" type="HQL">
1147    <sql>
1148      SELECT count(*)
1149      FROM BioMaterialEventData bme
1150      JOIN bme.sources src
1151      WHERE index(src) = :bioMaterial
1152    </sql>
1153    <description>
1154      A Hibernate query that counts the number of events a given
1155      biomaterial has been part of as a source biomaterial, ie. the number
1156      of pooled biomaterials that have been created from it.
1157    </description>
1158  </query>
1159
1160  <query id="GET_CREATION_EVENT_FOR_BIOMATERIAL" type="HQL">
1161    <sql>
1162      SELECT evt
1163      FROM BioMaterialEventData evt
1164      WHERE evt.bioMaterial = :bioMaterial
1165      AND evt.eventType = 1
1166    </sql>
1167    <description>
1168      A Hibernate query that returns the creation event for
1169      a biomaterial.
1170    </description>
1171  </query>
1172 
1173  <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL">
1174    <sql>
1175      SELECT count(*)
1176      FROM MessageData msg
1177      WHERE msg.to = :user AND msg.read = false AND msg.removed = false
1178    </sql>
1179    <description>
1180      A Hibernate query that counts the number of
1181      unread messages for a given user
1182    </description>
1183  </query>
1184 
1185  <query id="COUNT_PLUGINCONFIGURATIONS_FOR_PLUGINDEFINITION" type="HQL">
1186    <sql>
1187      SELECT count(*)
1188      FROM PluginConfigurationData pc
1189      WHERE pc.pluginDefinition = :pluginDefinition
1190    </sql>
1191    <description>
1192      A Hibernate query that counts the number of plugin configurations
1193      using a plugin definition.
1194    </description>
1195  </query>
1196 
1197  <query id="COUNT_JOBS_FOR_PLUGINCONFIGURATION" type="HQL">
1198    <sql>
1199      SELECT count(*)
1200      FROM JobData j
1201      WHERE j.pluginConfiguration = :pluginConfiguration
1202    </sql>
1203    <description>
1204      A Hibernate query that counts the number of jobs
1205      using a plugin configuration.
1206    </description>
1207  </query>
1208
1209  <query id="FIND_JOBS_IN_QUEUE" type="HQL">
1210    <sql>
1211      SELECT job
1212      FROM JobData job
1213      WHERE job.status = :status
1214      AND job.type = :type
1215      ORDER BY job.priority ASC, job.created ASC
1216    </sql>
1217    <description>
1218      A Hibernate query that loads plugin jobs in the job queue waiting to be
1219      executed sorted by priority and waiting type.
1220    </description>
1221  </query>
1222 
1223  <query id="GET_PLUGINTYPE_FOR_INTERFACENAME" type="HQL">
1224    <sql>
1225      SELECT plt
1226      FROM PluginTypeData plt
1227      WHERE plt.interfaceName = :interfaceName
1228    </sql>
1229    <description>
1230      Load a plugin type when you know the interface name.
1231    </description>
1232  </query>
1233
1234  <query id="GET_PLUGINDEFINITION_FOR_CLASSNAME" type="HQL">
1235    <sql>
1236      SELECT pd
1237      FROM PluginDefinitionData pd
1238      WHERE pd.className = :className
1239    </sql>
1240    <description>
1241      Load a plugin definition when you know the class name.
1242    </description>
1243  </query>
1244
1245  <query id="LOAD_CONTEXT_NAMES" type="HQL">
1246    <sql>
1247      SELECT ctx.id, ctx.name
1248      FROM ContextData ctx
1249      WHERE ctx.client = :client AND
1250      (ctx.user = :user OR ctx.public = true)
1251      AND ctx.itemType = :itemType
1252      AND ctx.subContext = :subContext
1253      ORDER BY ctx.name
1254    </sql>
1255    <description>
1256      A Hibernate query that selects the id and name of all contexts for
1257      a user and item type. The names should be sorted in ascending order.
1258    </description>
1259  </query>
1260 
1261  <query id="LOAD_CONTEXT_BY_NAME" type="HQL">
1262    <sql>
1263      SELECT ctx
1264      FROM ContextData ctx
1265      WHERE ctx.user = :user
1266      AND ctx.client = :client
1267      AND ctx.itemType = :itemType
1268      AND ctx.subContext  = :subContext
1269      AND ctx.name = :name
1270    </sql>
1271    <description>
1272      A Hibernate query that load a context given the user, client,
1273      item type, subcontext and name of the context.
1274    </description>
1275  </query>
1276 
1277  <query id="COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT" type="HQL">
1278    <sql>
1279      SELECT plg.mainType, count(*)
1280      FROM PluginDefinitionData plg
1281      JOIN plg.guiContexts gcx
1282      WHERE gcx.itemType = :itemType AND gcx.contextType = :contextType
1283      GROUP BY plg.mainType
1284    </sql>
1285    <description>
1286      A Hibernate query that counts the number of
1287      plugins available for a given GUI context grouped by
1288      the main type of the plugins.
1289    </description>
1290  </query>
1291 
1292  <query id="GET_SCHEMA_VERSION" type="HQL">
1293    <sql>
1294      SELECT sv
1295      FROM SchemaVersionData sv
1296    </sql>
1297    <description>
1298      A Hibernate query that loads the schema version (there should only be one record).
1299    </description>
1300  </query>
1301 
1302  <query id="SET_SCHEMA_VERSION" type="HQL">
1303    <sql>
1304      UPDATE SchemaVersionData sv
1305      SET sv.schemaVersion = :schemaVersion,
1306      sv.build = :build
1307    </sql>
1308    <description>
1309      A Hibernate query that updates the schema version and build number.
1310    </description>
1311  </query>
1312
1313  <query id="SET_PROJECT_TYPE" type="HQL">
1314    <sql>
1315      UPDATE ProjectData pd
1316      SET pd.projectType = 0
1317      WHERE pd.projectType IS NULL
1318    </sql>
1319    <description>
1320      A Hibernate query that updates the new column projectType when going from
1321schema 6 to 7
1322    </description>
1323  </query>
1324 
1325  <query id="SET_JOBS_ABORTED_BY_SERVER_SHUTDOWN" type="HQL">
1326    <sql>
1327      UPDATE JobData job
1328      SET job.statusMessage = :newStatusMessage,
1329      job.percentComplete = :newPercentComplete,
1330      job.status = :newStatus,
1331      job.ended = :newEnded
1332      WHERE job.status = :status AND job.type = :type
1333    </sql>
1334    <description>
1335      A Hibernate query that updates job properties.
1336    </description>
1337  </query>
1338 
1339  <query id="FIND_PENDING_JOBS" type="HQL">
1340    <sql>
1341      SELECT job
1342      FROM JobData job
1343      WHERE job.type = :type AND job.ended = null
1344      ORDER BY job.priority ASC, job.created ASC
1345    </sql>
1346    <description>
1347      A Hibernate query that loads pending jobs
1348      sorted by priority and creation time.
1349    </description>
1350  </query>
1351
1352  <query id="SET_COMPRESSED_ON_FILES" type="HQL">
1353    <sql>
1354      UPDATE FileData f
1355      SET
1356        f.compressed = false,
1357        f.compressedSize = f.size
1358      WHERE f.compressed IS NULL
1359    </sql>
1360    <description>
1361      A HQL query that sets the compressed property to false and the
1362      compressedSize to size for all files with a null value.
1363    </description>
1364  </query>
1365
1366</predefined-queries>
Note: See TracBrowser for help on using the repository browser.