Changeset 246


Ignore:
Timestamp:
Mar 8, 2010, 6:25:07 PM (14 years ago)
Author:
duh
Message:
  • increased session lifetime to 7 days
  • improved wizard study template selector
  • wizard study page now contains study template fields (which are not yet handled)
  • added protocol selector to event descriptions page
  • renamed the 'blood sampling' protocol to 'Blood sampling' (it was duplicately named 'Liver sampling')
Location:
trunk/grails-app
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BaseFilters.groovy

    r172 r246  
    2424                                        session.style = 'default_style'
    2525                                }
     26
     27                                // set session lifetime to 1 week
     28                                session.setMaxInactiveInterval(604800)
    2629                        }
    2730                }
  • trunk/grails-app/conf/BootStrap.groovy

    r239 r246  
    2020        def init = {servletContext ->
    2121                // define timezone
    22                 System.setProperty('user.timezone', 'CET')     
     22                System.setProperty('user.timezone', 'CET')
    2323
    2424                if (GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) {
     
    134134
    135135                        def bloodSamplingProtocol = new Protocol(
    136                                 name: 'Liver sampling'
     136                                name: 'Blood sampling'
    137137                        ).with { if (!validate()) { errors.each { println it} } else save()}
    138138
  • trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy

    r240 r246  
    9191                        }
    9292                        on("switchTemplate") {
    93                                 println "switching template..."
    94                                 println params
    9593                                this.handleStudy(flow, flash, params)
    9694                        }.to "study"
     
    159157                        }.to "subjects"
    160158                        on("next") {
    161                                 println flow.subjectTemplates
    162                                 println flow.subjects
    163159                                flash.errors = new LinkedHashMap()
    164160
     
    200196                                // fetch classification by name (as posted by the form)
    201197                                //params.classification = Term.findByName(params.classification)
     198
     199                                // fetch protocol by name (as posted by the form)
     200                                params.protocol = Protocol.findByName(params.protocol)
    202201
    203202                                // transform checkbox form value to boolean
     
    452451
    453452                // if a template is selected, get template instance
    454                 if (params.get('template')) {
    455                         params.template = Template.findByName(params.get('template'))
     453                def template = params.remove('template')
     454                if (template instanceof String && template.size() > 0) {
     455                        params.template = Template.findByName(template)
     456                } else if (template instanceof Template) {
     457                        params.template = template
    456458                }
    457459
     
    489491                        it.name = params.get('eventDescription_' + id + '_name')
    490492                        it.description = params.get('eventDescription_' + id + '_description')
     493                        it.protocol = Protocol.findByName(params.get('eventDescription_' + id + '_protocol'))
    491494                        //it.classification = Term.findByName(params.get('eventDescription_' + id + '_classification'))
    492495                        it.isSamplingEvent = (params.containsKey('eventDescription_' + id + '_isSamplingEvent'))
  • trunk/grails-app/domain/dbnp/studycapturing/Protocol.groovy

    r190 r246  
    2222        reference(nullable: true, blank: true)
    2323    }
     24
     25        /**
     26         * overloaded toString method
     27         * @return String
     28         */
     29        def String toString() {
     30                return this.name;
     31        }
    2432}
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r236 r246  
    4141                owner(nullable: true, blank: true)
    4242                title(nullable: false, blank: false)
    43                 template(nullable: true, blank: true)
     43                template(nullable: false, blank: false)
    4444        }
    4545
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r240 r246  
    4646         * @param Closure body
    4747         */
    48         def ajaxButton = { attrs, body ->
     48        def ajaxButton = {attrs, body ->
    4949                // get the jQuery version
    5050                def jQueryVersion = grailsApplication.getMetadata()['plugins.jquery']
     
    8787                        button = button.replaceFirst(/data\:jQuery/, "data:\'_eventId_${elementName}=1&\'+jQuery")
    8888                }
    89  
     89
    9090                // add an after success function call?
    9191                // usefull for performing actions on success data (hence on refreshed
     
    106106                // replace double semi colons
    107107                button = button.replaceAll(/;{2,}/, ';')
    108                
     108
    109109                // render button
    110110                out << button
     
    116116         * @see WizardTagLib::baseElement (ajaxSubmitOnChange)
    117117         */
    118         def ajaxSubmitJs = { attrs, body ->
     118        def ajaxSubmitJs = {attrs, body ->
    119119                // define AJAX provider
    120120                setProvider([library: ajaxProvider])
     
    130130
    131131                // strip the button part to only leave the Ajax call
    132                 button = button.replaceFirst(/<[^\"]*\"jQuery.ajax/,'jQuery.ajax')
    133                 button = button.replaceFirst(/return false.*/,'')
     132                button = button.replaceFirst(/<[^\"]*\"jQuery.ajax/, 'jQuery.ajax')
     133                button = button.replaceFirst(/return false.*/, '')
    134134
    135135                // change form if a form attribute is present
     
    166166         * Example initial webflow action to work with this javascript:
    167167         * ...
    168          * mainPage {
    169          *      render(view: "/wizard/index")
    170          *      onRender {
    171          *              flow.page = 1
    172          *      }
    173          *      on("next").to "pageOne"
    174          * }
    175          * ...
     168         * mainPage {*  render(view: "/wizard/index")
     169         *      onRender {*             flow.page = 1
     170         *}*    on("next").to "pageOne"
     171         *}* ...
    176172         *
    177173         * @param Map attributes
    178174         * @param Closure body
    179175         */
    180         def ajaxFlowRedirect = { attrs, body ->
     176        def ajaxFlowRedirect = {attrs, body ->
    181177                // generate javascript
    182178                out << '<script type="text/javascript">'
     
    207203        /**
    208204         * generate a base form element
    209          * @param String        inputElement name
    210          * @param Map           attributes
    211          * @param Closure       help content
    212          */
    213         def baseElement = { inputElement, attrs, help ->
     205         * @param String inputElement name
     206         * @param Map attributes
     207         * @param Closure help content
     208         */
     209        def baseElement = {inputElement, attrs, help ->
    214210                // work variables
    215211                def description = attrs.remove('description')
    216212                def addExampleElement = attrs.remove('addExampleElement')
    217                 def addExample2Element  = attrs.remove('addExample2Element')
     213                def addExample2Element = attrs.remove('addExample2Element')
    218214
    219215                // got an ajax onchange action?
     
    247243                out << ' <div class="input">'
    248244                out << renderedElement
    249                 if(help()) {
     245                if (help()) {
    250246                        out << '        <div class="helpIcon"></div>'
    251247                }
     
    255251                if (addExampleElement) {
    256252                        def exampleAttrs = new LinkedHashMap()
    257                         exampleAttrs.name = attrs.get('name')+'Example'
    258                         exampleAttrs.class  = 'isExample'
     253                        exampleAttrs.name = attrs.get('name') + 'Example'
     254                        exampleAttrs.class = 'isExample'
    259255                        exampleAttrs.disabled = 'disabled'
    260256                        exampleAttrs.size = 30
     
    266262                if (addExample2Element) {
    267263                        def exampleAttrs = new LinkedHashMap()
    268                         exampleAttrs.name = attrs.get('name')+'Example2'
    269                         exampleAttrs.class  = 'isExample'
     264                        exampleAttrs.name = attrs.get('name') + 'Example2'
     265                        exampleAttrs.class = 'isExample'
    270266                        exampleAttrs.disabled = 'disabled'
    271267                        exampleAttrs.size = 30
     
    290286         * @param Closure body  (help text)
    291287         */
    292         def textFieldElement = { attrs, body ->
     288        def textFieldElement = {attrs, body ->
    293289                // set default size, or scale to max length if it is less than the default size
    294290                if (!attrs.get("size")) {
     
    308304        }
    309305
    310 
    311306        /**
    312307         * render a select form element
     
    314309         * @param Closure body  (help text)
    315310         */
    316         def selectElement = { attrs, body ->
     311        def selectElement = {attrs, body ->
    317312                baseElement.call(
    318313                        'select',
     
    327322         * @param Closure body  (help text)
    328323         */
    329         def checkBoxElement = { attrs, body ->
     324        def checkBoxElement = {attrs, body ->
    330325                baseElement.call(
    331326                        'checkBox',
     
    341336         * @param Closure body  (help text)
    342337         */
    343         def dateElement = { attrs, body ->
     338        def dateElement = {attrs, body ->
    344339                // transform value?
    345340                if (attrs.value instanceof Date) {
     
    347342                        attrs.value = String.format('%td/%<tm/%<tY', attrs.value)
    348343                }
    349                
     344
    350345                // set some textfield values
    351346                attrs.maxlength = (attrs.maxlength) ? attrs.maxlength : 10
    352347                attrs.addExampleElement = true
    353                
     348
    354349                // render a normal text field
    355350                //out << textFieldElement(attrs,body)
     
    366361         * @param Closure body  (help text)
    367362         */
    368         def timeElement = { attrs, body ->
     363        def timeElement = {attrs, body ->
    369364                // transform value?
    370365                if (attrs.value instanceof Date) {
     
    384379                )
    385380        }
    386        
     381
    387382        /**
    388383         * Template form element
    389          * @param Map           attributes
    390          * @param Closure       help content
    391          */
    392         def speciesElement = { attrs, body ->
     384         * @param Map attributes
     385         * @param Closure help content
     386         */
     387        def speciesElement = {attrs, body ->
    393388                // render template element
    394389                baseElement.call(
     
    401396        /**
    402397         * Button form element
    403          * @param Map           attributes
    404          * @param Closure       help content
    405          */
    406         def buttonElement = { attrs, body ->
     398         * @param Map attributes
     399         * @param Closure help content
     400         */
     401        def buttonElement = {attrs, body ->
    407402                // render template element
    408403                baseElement.call(
     
    417412         * @param Map attrs
    418413         */
    419         def speciesSelect = { attrs ->
     414        def speciesSelect = {attrs ->
    420415                // fetch the speciesOntology
    421416                // note that this is a bit nasty, probably the ontologyName should
     
    437432        /**
    438433         * Template form element
    439          * @param Map           attributes
    440          * @param Closure       help content
    441          */
    442         def templateElement = { attrs, body ->
     434         * @param Map attributes
     435         * @param Closure help content
     436         */
     437        def templateElement = {attrs, body ->
    443438                // render template element
    444439                baseElement.call(
     
    448443                )
    449444        }
    450        
     445
    451446        /**
    452447         * render a template select element
    453448         * @param Map attrs
    454449         */
    455         def templateSelect = { attrs ->
     450        def templateSelect = {attrs ->
    456451                def entity = attrs.remove('entity')
    457452
    458453                // fetch templates
    459                 attrs.from = (entity) ? Template.findAllByEntity(entity) : Template.findAll()
     454                if (attrs.remove('addDummy')) {
     455                        attrs.from = ['']
     456                        if (entity && entity instanceof Class) {
     457                                Template.findAllByEntity(entity).each() {
     458                                        attrs.from[attrs.from.size()] = it
     459                                }
     460                        }
     461                } else {
     462                        attrs.from = (entity) ? Template.findAllByEntity(entity) : Template.findAll()
     463                }
    460464
    461465                // got a name?
     
    465469
    466470                // got result?
    467                 if (attrs.from.size() >0) {
     471                if (attrs.from.size() > 0) {
    468472                        out << select(attrs)
    469473                } else {
     
    476480        /**
    477481         * Term form element
    478          * @param Map           attributes
    479          * @param Closure       help content
    480          */
    481         def termElement = { attrs, body ->
     482         * @param Map attributes
     483         * @param Closure help content
     484         */
     485        def termElement = {attrs, body ->
    482486                // render term element
    483487                baseElement.call(
     
    492496         * @param Map attrs
    493497         */
    494         def termSelect = { attrs ->
     498        def termSelect = {attrs ->
    495499                // fetch all terms
    496500                attrs.from = Term.findAll()     // for now, all terms as we cannot identify terms as being treatment terms...
     
    504508        }
    505509
    506         def show = { attrs ->
     510        /**
     511         * Protocol form element
     512         * @param Map attributes
     513         * @param Closure help content
     514         */
     515        def protocolElement = {attrs, body ->
     516                // render protocol element
     517                baseElement.call(
     518                        'protocolSelect',
     519                        attrs,
     520                        body
     521                )
     522        }
     523
     524        /**
     525         * render a protocol select element
     526         * @param Map attrs
     527         */
     528        def protocolSelect = {attrs ->
     529                // fetch all protocold
     530                attrs.from = Protocol.findAll() // for now, all protocols
     531
     532                // got a name?
     533                if (!attrs.name) {
     534                        attrs.name = 'protocol'
     535                }
     536
     537                out << select(attrs)
     538        }
     539
     540        def show = {attrs ->
    507541                // is object parameter set?
    508542                def o = attrs.object
     
    520554         * @param Map attributes
    521555         */
    522         def templateColumnHeaders = { attrs ->
     556        def templateColumnHeaders = {attrs ->
    523557                def template = attrs.remove('template')
    524558
     
    533567         * @param Map attributes
    534568         */
    535         def templateColumns = { attrs, body ->
    536                 def subject                     = attrs.remove('subject')
    537                 def subjectId           = attrs.remove('id')
    538                 def template            = attrs.remove('template')
    539                 def intFields           = subject.templateIntegerFields
    540                 def stringFields        = subject.templateStringFields
    541                 def floatFields         = subject.templateFloatFields
    542                 def termFields          = subject.templateTermFields
     569        def templateColumns = {attrs, body ->
     570                def subject = attrs.remove('subject')
     571                def subjectId = attrs.remove('id')
     572                def template = attrs.remove('template')
     573                def intFields = subject.templateIntegerFields
     574                def stringFields = subject.templateStringFields
     575                def floatFields = subject.templateFloatFields
     576                def termFields = subject.templateTermFields
    543577
    544578                // output columns for these subjectFields
     
    555589                                                        from: it.listEntries,
    556590                                                        value: (stringFields) ? stringFields.get(it.name) : ''
    557                                                 )                                               
     591                                                )
    558592                                        } else {
    559593                                                out << '<span class="warning">no values!!</span>'
     
    576610                                default:
    577611                                        // unsupported field type
    578                                         out << '<span class="warning">!'+it.type+'</span>'
     612                                        out << '<span class="warning">!' + it.type + '</span>'
    579613                                        //out << subject.getFieldValue(it.name)
    580614                                        break;
     
    584618                }
    585619        }
     620
     621        /**
     622         * render form elements based on an entity's template
     623         * @param Map attributes
     624         * @param String body
     625         */
     626        def templateElements = {attrs ->
     627                def entity = (attrs.get('entity'))
     628                def template = (entity && entity instanceof TemplateEntity) ? entity.template : null
     629
     630                // got a template?
     631                if (template) {
     632                        // render template fields
     633                        template.fields.each() {
     634                                switch (it.type) {
     635                                        case 'STRINGLIST':
     636                                                if (!it.listEntries.isEmpty()) {
     637                                                        out << selectElement(
     638                                                                description: it.name,
     639                                                                name: it.name,
     640                                                                from: it.listEntries,
     641                                                                value: attrs
     642                                                        )
     643                                                } else {
     644                                                        out << '<span class="warning">no values!!</span>'
     645                                                }
     646                                                break
     647                                        case 'STRING':
     648                                                out << textFieldElement(
     649                                                        description: it.name,
     650                                                        name: it.name
     651                                                )
     652                                                break
     653                                        case 'DATE':
     654                                                out << dateElement(
     655                                                        description: it.name,
     656                                                        name: it.name
     657                                                )
     658                                                break
     659                                        case 'INTEGER':
     660                                                out << textFieldElement(
     661                                                        description: it.name,
     662                                                        name: it.name
     663                                                )
     664                                                break
     665                                        case 'DOUBLE':
     666                                                out << textFieldElement(
     667                                                        description: it.name,
     668                                                        name: it.name
     669                                                )
     670                                                break
     671                                        default:
     672                                                out << "unkown field type '" + it.type + "'<br/>"
     673                                                break
     674                                }
     675                        }
     676                }
     677        }
    586678}
  • trunk/grails-app/views/wizard/pages/_eventDescriptions.gsp

    r238 r246  
    2323        </span>
    2424
    25         <span class="info">
    26                 <span class="title">Note!</span>
    27                 Currently 'classification' display all terms because there is no way to machine interpret
    28                 the different values. So please -for now- make sure to pick the Ontology reference applicable for
    29                 events until this particular challenge is solved.
    30         </span>
    31 
    3225        <wizard:textFieldElement name="name" description="Name" error="name" value="${values?.name}">
    3326                The name of the event description you are creating
     
    3629                A short description summarizing your event description
    3730        </wizard:textFieldElement>
     31        <wizard:protocolElement name="protocol" description="Protocol" error="protocol" value="${values?.protocol}" >
     32                Select the protocol for this event description
     33        </wizard:protocolElement>
    3834        <wizard:checkBoxElement name="isSamplingEvent" description="Sampling event" error="isSamplingEvent" value="${values?.isSamplingEvent}">
    3935                Is this a sampling event description?
     
    4743                        <div class="column">name</div>
    4844                        <div class="column">description</div>
     45                        <div class="column">protocol</div>
    4946                        <div class="column">sampling event</div>
    5047                        <div class="column">protocol</div>
     
    5855                        <div class="column"><g:textField name="eventDescription_${i}_name" value="${eventDescription.name}" size="12" maxlength="12" /></div>
    5956                        <div class="column"><g:textField name="eventDescription_${i}_description" value="${eventDescription.description}" size="12" maxlength="12" /></div>
     57                        <div class="column"><wizard:protocolSelect name="eventDescription_${i}_protocol" value="${eventDescription.protocol}" /></div>
    6058                        <div class="column"><g:checkBox name="eventDescription_${i}_isSamplingEvent" value="${eventDescription.isSamplingEvent}" /></div>
    6159                        <div class="column"><g:if test="${eventDescription.protocol}">${eventDescription.protocol}</g:if><g:else>-</g:else></div>
  • trunk/grails-app/views/wizard/pages/_study.gsp

    r240 r246  
    2121        </span>
    2222       
    23         <wizard:templateElement name="template" description="Template" value="${study?.template}" entity="${dbnp.studycapturing.Subject}" ajaxOnChange="switchTemplate" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" >
     23        <wizard:templateElement name="template" description="Template" value="${study?.template}" entity="${dbnp.studycapturing.Study}" addDummy="true" ajaxOnChange="switchTemplate" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" >
    2424                The template to use for this study
    2525        </wizard:templateElement>
     
    4545        <span class="info">
    4646                <span class="title">TODO</span>
    47                 This page should also contain the template fields of the study template selected above (if available). This is
    48                 scheduled for implementation in a later version
     47                Below you will see the template fields of the study template selected above. These fields are not yet
     48                properly handled so you can ignore them for now... To be completed at a later stage
    4949        </span>
    5050       
     51        <wizard:templateElements entity="${study}" />
     52
    5153</wizard:pageContent>
Note: See TracChangeset for help on using the changeset viewer.