Changeset 1482 for trunk/src/groovy/dbnp/query/StudySearch.groovy
- Timestamp:
- Feb 2, 2011, 4:40:22 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/groovy/dbnp/query/StudySearch.groovy
r1458 r1482 16 16 17 17 import java.util.List; 18 import java.util.Map; 18 19 19 20 import dbnp.studycapturing.* 20 21 import org.dbnp.gdt.* 22 import org.apache.commons.logging.LogFactory; 21 23 22 24 class StudySearch extends Search { 25 private static final log = LogFactory.getLog(this); 26 23 27 public StudySearch() { 28 super(); 24 29 this.entity = "Study"; 25 30 } … … 59 64 @Override 60 65 void execute() { 61 // TODO: check for authorization for these studies? 62 def studies = Study.list(); 66 super.execute(); 63 67 68 def studies = Study.list().findAll { it.canRead( this.user ) }; 69 64 70 // If no criteria are found, return all studies 65 71 if( !criteria || criteria.size() == 0 ) { … … 75 81 studies = filterOnSamplingEventCriteria( studies ); 76 82 studies = filterOnAssayCriteria( studies ); 77 83 78 84 studies = filterOnModuleCriteria( studies ); 79 85 … … 81 87 results = studies; 82 88 } 83 89 84 90 /** 85 91 * Filters the given list of studies on the study criteria … … 97 103 */ 98 104 protected List filterOnSubjectCriteria( List studies ) { 99 return filterOnTemplateEntityCriteria(studies, "Subject", { study, criterion -> 105 return filterOnTemplateEntityCriteria(studies, "Subject", { study, criterion -> 100 106 return study.subjects?.collect { criterion.getFieldValue( it ); } 101 107 }) … … 119 125 */ 120 126 protected List filterOnEventCriteria( List studies ) { 121 return filterOnTemplateEntityCriteria(studies, "Event", { study, criterion -> 127 return filterOnTemplateEntityCriteria(studies, "Event", { study, criterion -> 122 128 return study.events?.collect { criterion.getFieldValue( it ); } 123 129 }) 124 130 } 125 131 126 132 /** 127 * Filters the given list of studies on the sampling event criteria128 * @param studies Original list of studies129 * @return List with all studies that match the event-criteria130 */131 132 return filterOnTemplateEntityCriteria(studies, "SamplingEvent", { study, criterion -> 133 * Filters the given list of studies on the sampling event criteria 134 * @param studies Original list of studies 135 * @return List with all studies that match the event-criteria 136 */ 137 protected List filterOnSamplingEventCriteria( List studies ) { 138 return filterOnTemplateEntityCriteria(studies, "SamplingEvent", { study, criterion -> 133 139 return study.samplingEvents?.collect { criterion.getFieldValue( it ); } 134 140 }) 135 136 141 } 142 137 143 /** 138 144 * Filters the given list of studies on the assay criteria … … 145 151 }) 146 152 } 153 154 /** 155 * Returns the saved field data that could be shown on screen. This means, the data 156 * is filtered to show only data of the query results. Also, the study title and sample 157 * name are filtered out, in order to be able to show all data on the screen without 158 * checking further 159 * 160 * @return Map with the entity id as a key, and a field-value map as value 161 */ 162 public Map getShowableResultFields() { 163 Map showableFields = super.getShowableResultFields() 164 showableFields.each { sampleElement -> 165 sampleElement.value = sampleElement.value.findAll { fieldElement -> 166 fieldElement.key != "Study title" && fieldElement.key != "Subject species" 167 } 168 } 169 return showableFields 170 } 147 171 }
Note: See TracChangeset
for help on using the changeset viewer.