Ignore:
Timestamp:
Mar 10, 2010, 2:40:58 PM (10 years ago)
Author:
keesvb
Message:

Cleaned up BootStrap? (removed accidental multiple addition of eventGroup in PPSH study), cleaned up scaffolded classes in root package, removed obsolete BaseController?, added some code to Sandbox

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy

    r252 r253  
    1 /**
    2  * Home Controler
    3  *
    4  * My Description
    5  *
    6  * @author  Kees van Bochove
    7  * @since   20091028
    8  * @package studycapturing
    9  *
    10  * Revision information:
    11  * $Rev$
    12  * $Author$
    13  * $Date$
    14  */
    15 class StudyController extends BaseController {
    16     def scaffold = dbnp.studycapturing.Study
     1package dbnp.studycapturing
    172
    18     def list_extended = {
    19        
     3class StudyController {
     4
     5    //static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
     6
     7    def index = {
     8        redirect(action: "list", params: params)
    209    }
    2110
    22     def see = {
    23         render params
     11    def list = {
     12        params.max = Math.min(params.max ? params.int('max') : 10, 100)
     13        [studyInstanceList: Study.list(params), studyInstanceTotal: Study.count()]
    2414    }
     15
     16    /*def create = {
     17        def studyInstance = new Study()
     18        studyInstance.properties = params
     19        return [studyInstance: studyInstance]
     20    }
     21
     22    def save = {
     23        def studyInstance = new Study(params)
     24        if (studyInstance.save(flush: true)) {
     25            flash.message = "${message(code: 'default.created.message', args: [message(code: 'study.label', default: 'Study'), studyInstance.id])}"
     26            redirect(action: "show", id: studyInstance.id)
     27        }
     28        else {
     29            render(view: "create", model: [studyInstance: studyInstance])
     30        }
     31    }*/
     32
     33    def show = {
     34        def studyInstance = Study.get(params.id)
     35        if (!studyInstance) {
     36            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}"
     37            redirect(action: "list")
     38        }
     39        else {
     40            [studyInstance: studyInstance]
     41        }
     42    }
     43
     44    /*def edit = {
     45        def studyInstance = Study.get(params.id)
     46        if (!studyInstance) {
     47            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}"
     48            redirect(action: "list")
     49        }
     50        else {
     51            return [studyInstance: studyInstance]
     52        }
     53    }
     54
     55    def update = {
     56        def studyInstance = Study.get(params.id)
     57        if (studyInstance) {
     58            if (params.version) {
     59                def version = params.version.toLong()
     60                if (studyInstance.version > version) {
     61                   
     62                    studyInstance.errors.rejectValue("version", "default.optimistic.locking.failure", [message(code: 'study.label', default: 'Study')] as Object[], "Another user has updated this Study while you were editing")
     63                    render(view: "edit", model: [studyInstance: studyInstance])
     64                    return
     65                }
     66            }
     67            studyInstance.properties = params
     68            if (!studyInstance.hasErrors() && studyInstance.save(flush: true)) {
     69                flash.message = "${message(code: 'default.updated.message', args: [message(code: 'study.label', default: 'Study'), studyInstance.id])}"
     70                redirect(action: "show", id: studyInstance.id)
     71            }
     72            else {
     73                render(view: "edit", model: [studyInstance: studyInstance])
     74            }
     75        }
     76        else {
     77            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}"
     78            redirect(action: "list")
     79        }
     80    }
     81
     82    def delete = {
     83        def studyInstance = Study.get(params.id)
     84        if (studyInstance) {
     85            try {
     86                studyInstance.delete(flush: true)
     87                flash.message = "${message(code: 'default.deleted.message', args: [message(code: 'study.label', default: 'Study'), params.id])}"
     88                redirect(action: "list")
     89            }
     90            catch (org.springframework.dao.DataIntegrityViolationException e) {
     91                flash.message = "${message(code: 'default.not.deleted.message', args: [message(code: 'study.label', default: 'Study'), params.id])}"
     92                redirect(action: "show", id: params.id)
     93            }
     94        }
     95        else {
     96            flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}"
     97            redirect(action: "list")
     98        }
     99    }*/
    25100}
Note: See TracChangeset for help on using the changeset viewer.