Ignore:
Timestamp:
Feb 7, 2011, 4:07:54 PM (10 years ago)
Author:
robert@…
Message:
  • Number of seconds for the rest controller to keep data in cache is now a configuration option
  • After searching, it is possible to choose which action to perform on the search results.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/groovy/dbnp/query/StudySearch.groovy

    r1487 r1501  
    2424class StudySearch extends Search {
    2525        private static final log = LogFactory.getLog(this);
    26        
     26
    2727        public StudySearch() {
    2828                super();
     
    6363         */
    6464        @Override
    65         void execute() {
    66                 super.execute();
    67 
     65        void executeAnd() {
    6866                def studies = Study.list().findAll { it.canRead( this.user ) };
    6967
     
    8179                studies = filterOnSamplingEventCriteria( studies );
    8280                studies = filterOnAssayCriteria( studies );
     81
     82                studies = filterOnModuleCriteria( studies );
     83
     84                // Save matches
     85                results = studies;
     86        }
     87
     88        /**
     89         * Searches for studies based on the given criteria. Only one criteria have to be satisfied and
     90         * criteria for the different entities are satisfied as follows:
     91         *
     92         *              Study.title = 'abc'
     93         *                              The returned study will have title 'abc'
     94         *
     95         *              Subject.species = 'human'
     96         *                              The returned study will have one or more subjects with species = 'human'
     97         *
     98         *              Sample.name = 'sample 1'
     99         *                              The returned study will have one or more samples with name = 'sample 1'
     100         *
     101         *              Event.startTime = '0s'
     102         *                              The returned study will have one or more events with start time = '0s'
     103         *
     104         *              Assay.module = 'metagenomics'
     105         *                              The returned study will have one or more assays with module = 'metagenomics'
     106         *
     107         * When searching the system doesn't look at the connections between different entities. This means,
     108         * the system doesn't look for human subjects having a sample with name 'sample 1'. The sample 1 might
     109         * as well belong to a mouse subject and still the study satisfies the criteria.
     110         *
     111         * When searching for more than one criterion per entity, these are taken separately. Searching for
     112         *
     113         *              Subject.species = 'human'
     114         *              Subject.name = 'Jan'
     115         *
     116         *  will result in all studies having a human subject or a subject named 'Jan'. Studies with only a
     117         *  mouse subject named 'Jan' or a human subject named 'Kees' will satisfy the criteria.
     118         *
     119         */
     120        @Override
     121        void executeOr() {
     122                def allStudies = Study.list().findAll { it.canRead( this.user ) };
     123
     124                // If no criteria are found, return all studies
     125                if( !criteria || criteria.size() == 0 ) {
     126                        results = allStudies;
     127                        return;
     128                }
     129
     130                // Perform filters
     131                def studies = []
     132                studies = ( studies + filterOnStudyCriteria( allStudies - studies ) ).unique();
     133                studies = ( studies + filterOnSubjectCriteria( allStudies - studies ) ).unique();
     134                studies = ( studies + filterOnSampleCriteria( allStudies - studies ) ).unique();
     135                studies = ( studies + filterOnEventCriteria( allStudies - studies ) ).unique();
     136                studies = ( studies + filterOnSamplingEventCriteria( allStudies - studies ) ).unique();
     137                studies = ( studies + filterOnAssayCriteria( allStudies - studies ) ).unique();
    83138               
    84                 studies = filterOnModuleCriteria( studies );
     139                studies = ( studies + filterOnModuleCriteria( allStudies - studies ) ).unique();
    85140               
    86141                // Save matches
Note: See TracChangeset for help on using the changeset viewer.