source: trunk/grails-app/controllers/SearchableController.groovy @ 196

Last change on this file since 196 was 196, checked in by jahn, 10 years ago

Sample selection of the query controller: added buttons for subgroup selection, controller changes for passing on subselections, and some JS for selecting the checkboxes. The actual function of the checkboxes has to be clearified. When I check only subject, should the parent subject also be ticked? Or should it be the other way round? Plenty needs to be done in this step of the query still.

File size: 4.0 KB
Line 
1
2/*
3 * Copyright 2007 the original author or authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18import org.compass.core.engine.SearchEngineQueryParseException
19
20/**
21 * Basic web interface for Grails Searchable Plugin
22 *
23 * @author Adem and Jahn
24 */
25class SearchableController {
26    def searchableService
27
28    def selectsample = {
29
30            println "in selectsample: "
31            params.each{println it}
32
33            // prepare showing all studies selected in the previous view
34            def selectedStudies = []
35            def selectedStudyIds = params['selectedStudyIds']
36
37            if(selectedStudyIds!=null)
38            {
39                 def list = selectedStudyIds.findAll(/(\d)+/)
40                 selectedStudies = list.collect{ dbnp.studycapturing.Study.get(it) }
41            }
42            else
43            {
44                 def tmpList = []
45                 def studyList = dbnp.studycapturing.Study.list()
46                 selectedStudyIds = []
47                 params.each{ key,values->
48                     if (values=="on")  tmpList.add(key)
49                 }
50
51                 for (i in studyList)
52                     if (tmpList.contains(i.getId().toString()))
53                     {
54                         selectedStudyIds.add(i.id)
55                         selectedStudies.add(i)
56                     }
57           }
58
59
60
61        // subgroups
62        // provide list of subgroups depending on the type of subgrouping
63        // selected by the user
64        def subgroups = []
65        def submitButton = params["submit"]  // this button's value determines the kind of subgrouping
66
67        switch(submitButton)
68        {
69             case "Subject Groups":
70                  render(params)
71                  render("Subject Groups")
72                  subgroups=["subject group 1","subject group 2"]
73                  render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
74                  break
75             case "Event Groups":
76                  render("Event Groups")
77                  subgroups=["event group 1","event group 2"]
78                  render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
79                  break
80             case "Starting Time Groups":
81                  render("Starting Time Groups")
82                  subgroups=["time group 1","time group 2"]
83                  render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
84                  break
85             case ">> Execute and continue with biomarker selection":
86                  render("Starting Time Groups")
87                  break
88             case "<< Back to study selection":
89                  break
90        }
91        render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
92    }
93
94
95
96    /**
97     * Index page with search form and results
98     */
99    def index = {
100        if (!params.q?.trim()) {
101            return [:]
102        }
103        try {
104            return [searchResult: searchableService.search(params.q, params)]
105        } catch (SearchEngineQueryParseException ex) {
106            return [parseException: true]
107        }
108    }
109
110    /**
111     * Perform a bulk index of every searchable object in the database
112     */
113    def indexAll = {
114        Thread.start {
115            searchableService.index()
116        }
117        render("bulk index started in a background thread")
118    }
119
120    /**
121     * Perform a bulk index of every searchable object in the database
122     */
123    def unindexAll = {
124        searchableService.unindex()
125        render("unindexAll done")
126    }
127
128
129    def subjectGroups = { render ("hello") }
130
131
132}
Note: See TracBrowser for help on using the repository browser.