<commit_before>
/*
 * Copyright 2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.compass.core.engine.SearchEngineQueryParseException

/**
 * Basic web interface for Grails Searchable Plugin
 *
 * @author <NAME> Jahn
 */
class SearchableController {
    def searchableService

    def selectsample = {

            println "in selectsample: "
            params.each{println it}

            // prepare showing all studies selected in the previous view
            def selectedStudies = []
            def selectedStudyIds = params['selectedStudyIds']

            if(selectedStudyIds!=null)
	    {
                 def list = selectedStudyIds.findAll(/(\d)+/)
		 selectedStudies = list.collect{ dbnp.studycapturing.Study.get(it) }
            }
            else
            {
                 def tmpList = []
                 def studyList = dbnp.studycapturing.Study.list()
                 selectedStudyIds = []
                 params.each{ key,values->
                     if (values=="on")  tmpList.add(key)
	         }

                 for (i in studyList)
                     if (tmpList.contains(i.getId().toString()))
                     {
                         selectedStudyIds.add(i.id)
                         selectedStudies.add(i)
                     }
           }



        // subgroups
	// provide list of subgroups depending on the type of subgrouping
	// selected by the user
        def subgroups = []
        def submitButton = params["submit"]  // this button's value determines the kind of subgrouping

        switch(submitButton)
	{
	     case "Subject Groups":
	          render(params)
	          render("Subject Groups")
		  subgroups=["subject group 1","subject group 2"]
	          render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
	          break
	     case "Event Groups":
	          render("Event Groups")
		  subgroups=["event group 1","event group 2"]
	          render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
	          break
	     case "Starting Time Groups":
	          render("Starting Time Groups")
		  subgroups=["time group 1","time group 2"]
	          render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
	          break
             case ">> Execute and continue with biomarker selection":
	          render("Starting Time Groups")
	          break
             case "<< Back to study selection":
	          break
	}<commit_msg>Towards finishing the subGrouping for subjects.<commit_after>
/*
 * Copyright 2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.compass.core.engine.SearchEngineQueryParseException

/**
 * Basic web interface for Grails Searchable Plugin
 *
 * @author <NAME> Jahn
 */
class SearchableController {
    def searchableService

    def selectsample = {

            println "in selectsample: "
            params.each{println it}

            // prepare showing all studies selected in the previous view
            def selectedStudies = []
            def selectedStudyIds = params['selectedStudyIds']

            if(selectedStudyIds!=null)
	    {
                 def list = selectedStudyIds.findAll(/(\d)+/)
		 selectedStudies = list.collect{ dbnp.studycapturing.Study.get(it) }
            }
            else
            {
                 def tmpList = []
                 def studyList = dbnp.studycapturing.Study.list()
                 selectedStudyIds = []
                 params.each{ key,values->
                     if (values=="on")  tmpList.add(key)
	         }

                 for (i in studyList)
                     if (tmpList.contains(i.getId().toString()))
                     {
                         selectedStudyIds.add(i.id)
                         selectedStudies.add(i)
                     }
           }


        // subgroups
	// provide list of subgroups depending on the type of subgrouping
	// selected by the user
        def subgroups = []
        def submitButton = params["submit"]  // this button's value determines the kind of subgrouping

        switch(submitButton)
	{
	     case "Subject Groups":
	          render(params)
	          render("Subject Groups")
                  def studyGroups = []
		  if(selectedStudies!=null)
		  {
		     selectedStudies.each{ study ->
		         study.groups.each{ group -> studyGroups.add[group] }
		     }
		     println "study groups: "
		     studyGroups.each{x-> println x}
		  }

		  // testing:
		  // there is a lack of data in the mockup
		  // as long as there are no groups in the bootstart,
		  // we use this
		  subgroups = studyGroups.size()<=0 ?
		      ["subject group 1","subject group 2"] : studyGroups

	          render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
	          break
	     case "Event Groups":
	          render("Event Groups")
		  subgroups=["event group 1","event group 2"]
	          render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
	          break
	     case "Starting Time Groups":
	          render("Starting Time Groups")
		  subgroups=["time group 1","time group 2"]
	          render(view:"selectsample",model:[selectedStudies:selectedStudies,selectedStudyIds:selectedStudyIds,subgroups:subgroups])
	          break
             case ">> Execute and continue with biomarker selection":
	          render("Starting Time Groups")
	          break
             case "<< Back to study selection":
	          break
	}
{'fraction_non_alphanumeric': 0.08910745742806811, 'fraction_numerical': 0.0042571931884908985, 'mean_word_length': 2.1570898980537536, 'pattern_counts': {'":': 10, '<': 10, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1882405', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1609, 'n_words': 515}