Changeset 1261


Ignore:
Timestamp:
Dec 13, 2010, 11:50:28 AM (13 years ago)
Author:
s.h.sikkema@…
Message:

Changed jumbar layout to simple iframe for modules

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/application.properties

    r1256 r1261  
    1717plugins.hibernate=1.3.5
    1818plugins.jquery=1.4.3.2
    19 plugins.jumpbar=0.1.2
     19plugins.jumpbar=0.1.4
    2020plugins.mail=0.9
    2121plugins.oauth=0.10
  • trunk/grails-app/conf/BuildConfig.groovy

    r1232 r1261  
    4747//grails.plugin.location.'grom' = '../grom'
    4848//grails.plugin.location.'ajax-flow' = '../AjaxFlow'
     49//grails.plugin.location.'jumpbar' = '../jumpbar'
  • trunk/grails-app/conf/Config.groovy

    r1199 r1261  
    9393                        metabolomics {
    9494                                url = "http://test.metabolomics.dbnp.org"
     95               
    9596                        }
    9697                }
  • trunk/grails-app/controllers/dbnp/studycapturing/AssayController.groovy

    • Property svn:keywords changed from Author Date Rev to Date Author Rev
    r959 r1261  
    33class AssayController {
    44
     5    def assayService
     6    def authenticationService
     7   
    58    static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
    69
     
    115118        }
    116119    }
     120
     121    /**
     122     * Shows a page where an assay from a study can be selected
     123     *
     124     * @param none
     125     */
     126    def selectAssay = {
     127        def user = authenticationService.getLoggedInUser()
     128        def studies = Study.findAllByOwner(user)
     129        def assays = Assay.findAllByParent(studies[0])
     130
     131        [userStudies: studies, assays: assays]
     132    }
     133
     134    /**
     135     * Exports all assay information as an Excel file.
     136     *
     137     * @param params.id Assay id
     138     */
     139    def exportAssayAsExcel = {
     140        Assay assay = Assay.get(params.id)
     141
     142        if (!assay) {
     143            flash.errorMessage = "No assay found with id: $params.id."
     144            redirect action: 'selectAssay'
     145            return
     146        }
     147
     148        // TODO: refactor into service
     149
     150        // Gather sample meta data from GSCF
     151        def samples = assay.samples
     152
     153        def collectUsedTemplateFields = { templateEntityList ->
     154
     155            def templateFields = templateEntityList*.giveFields().flatten().unique().findAll{it}
     156            def usedTemplateFields = templateFields.findAll{ tf ->
     157
     158                templateEntityList.any { it.fieldExists(tf.name) && it.getFieldValue(tf.name) }
     159            }
     160
     161            def m = [:]
     162            usedTemplateFields.each { tf ->
     163                m["${tf.name}"] = templateEntityList.collect{ it.fieldExists(tf.name) ? it.getFieldValue(tf.name) : '' }
     164            }
     165            m
     166        }
     167
     168        // get all sample related subjects
     169        def assayData = [
     170                'Subject Data':         collectUsedTemplateFields(samples*.parentSubject.unique()),
     171                'Sampling Event Data':  collectUsedTemplateFields(samples*.parentEvent.unique()),
     172                'Event Data':           collectUsedTemplateFields(samples*.parentEventGroup.events.flatten().unique()),
     173                'Sample Data':          collectUsedTemplateFields(samples)]
     174
     175        // Gather sample meta data from the module
     176
     177        // - sample metadata
     178
     179        // Gather measurement data from the module
     180
     181        // - measurements
     182
     183        // Write to excel
     184
     185        println assayData
     186
     187        try {
     188            assayService.exportAssayDataAsExcelFile(assayData)
     189        } catch (Exception e) {
     190            flash.errorMessage = e.message
     191            redirect action: 'selectAssay'
     192        }
     193    }
    117194}
  • trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy

    • Property svn:keywords changed from Author Date Rev to Date Author Rev
    r1245 r1261  
    367367    }
    368368
    369     /*def edit = {
    370         def studyInstance = Study.get(params.id)
    371         if (!studyInstance) {
    372             flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}"
    373             redirect(action: "list")
    374         }
    375         else {
    376             return [studyInstance: studyInstance]
    377         }
    378     }
    379 
    380     def update = {
    381         def studyInstance = Study.get(params.id)
    382         if (studyInstance) {
    383             if (params.version) {
    384                 def version = params.version.toLong()
    385                 if (studyInstance.version > version) {
    386                    
    387                     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")
    388                     render(view: "edit", model: [studyInstance: studyInstance])
    389                     return
    390                 }
    391             }
    392             studyInstance.properties = params
    393             if (!studyInstance.hasErrors() && studyInstance.save(flush: true)) {
    394                 flash.message = "${message(code: 'default.updated.message', args: [message(code: 'study.label', default: 'Study'), studyInstance.id])}"
    395                 redirect(action: "show", id: studyInstance.id)
    396             }
    397             else {
    398                 render(view: "edit", model: [studyInstance: studyInstance])
    399             }
    400         }
    401         else {
    402             flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}"
    403             redirect(action: "list")
    404         }
    405     }
    406 */
     369    /**
     370     * Renders assay names and id's as JSON
     371     */
     372    def ajaxGetAssays = {
     373
     374        def study = Study.read(params.id)
     375        render study?.assays?.collect{[name: it.name, id: it.id]} as JSON
     376    }
     377
     378
    407379}
  • trunk/grails-app/views/study/show_assays.gsp

    • Property svn:keywords set to Date Author Rev
    r1213 r1261  
    3131                  <td>${assay.module.name}</td>
    3232                  <td>${assay.module.platform}</td>
    33                   %{--<td><a href="${assay.module.url}/assay/${assay.externalAssayID}">view</a></td>--}%
    34                   <td><jumpbar:link
    35                         linkDest="${createLink(action:'show', id:studyInstance.id)}/#Assays"
    36                         linkText='Go back to GSCF'
    37                         frameSource="${assay.module.url}/assay/showByToken/${assay.externalAssayID}"
    38                         pageTitle="Assay View in Module">
     33                  <td>
     34          <jumpbar:link frameSource="${assay.module.url}/assay/showByToken/${assay.externalAssayID}" pageTitle="Metabolomics Module">
    3935                        view
    4036                  </jumpbar:link></td>
  • trunk/test/unit/dbnp/studycapturing/AssayControllerTests.groovy

    r959 r1261  
    22
    33import grails.test.*
     4
     5import dbnp.data.Term
    46
    57/**
     
    2022    protected void setUp() {
    2123        super.setUp()
     24
     25        mockDomain(Term,          [ new Term(id: 1, name: 'Human')])
     26
     27        mockDomain(TemplateField, [ new TemplateField(id: 1, name: 'tf1', type: TemplateFieldType.STRING),
     28                                    new TemplateField(id: 2, name: 'tf2', type: TemplateFieldType.STRING),
     29                                    new TemplateField(id: 3, name: 'tf3', type: TemplateFieldType.STRING)])
     30
     31        mockDomain(Template,      [ new Template(id: 1, fields: [TemplateField.get(1), TemplateField.get(2)]),
     32                                    new Template(id: 2, fields: [TemplateField.get(3)])])
     33
     34        mockDomain(Subject,       [ new Subject(id: 1, name:'subject1', template: Template.get(1), species: Term.get(1)),
     35                                    new Subject(id: 2, name:'subject2', template: Template.get(2), species: Term.get(1))])
     36
     37        mockDomain(SamplingEvent, [ new SamplingEvent(id:1, startTime: 2, duration: 5, sampleTemplate: new Template())])
     38
     39        mockDomain(Event,         [ new Event(id: 1, startTime: 6, endTime: 7)])//, new Event(id: 2, startTime: 8, endTime: 9)])
     40
     41        mockDomain(EventGroup,    [ new EventGroup(id:1, events: [Event.get(1)]) ])
     42
     43        mockDomain(Sample,        [ new Sample(id: 1, name:'sample1', parentSubject: Subject.get(1), parentEvent: SamplingEvent.get(1), parentEventGroup: EventGroup.get(1)),
     44                                    new Sample(id: 2, name:'sample2', parentSubject: Subject.get(2), parentEvent: SamplingEvent.get(1))])
     45
     46        mockDomain(Assay,         [ new Assay(id: 1, samples:[Sample.get(1),Sample.get(2)]),
     47                                    new Assay(id: 2, samples:[])])
     48
     49        Subject.get(1).setFieldValue('tf1', 'tfv1')
     50        Subject.get(1).setFieldValue('tf2', 'tfv2')
     51        Subject.get(2).setFieldValue('tf3', 'tfv3')
    2252    }
    2353
     
    2656    }
    2757
    28     void testSomething() {
     58    void testWrongAssayID() {
     59        mockParams.id = 3
    2960
     61        controller.exportAssayAsExcel()
     62
     63        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
     64        assertEquals 'Error message', 'No assay found with id: 3.', mockFlash.errorMessage
     65    }
     66
     67    void testExceptionHandling() {
     68        mockParams.id = 1
     69
     70        controller.assayService = [exportAssayDataAsExcelFile:{throw new Exception('msg')}]
     71        controller.exportAssayAsExcel()
     72
     73        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
     74        assertEquals 'Error message', 'msg', mockFlash.errorMessage
     75    }
     76
     77    void testEmptySampleList() {
     78        mockParams.id = 2
     79
     80        def passedAssayData = []
     81
     82        controller.assayService = [exportAssayDataAsExcelFile:{a -> passedAssayData = a}]
     83        controller.exportAssayAsExcel()
     84
     85        assertEquals 'Assay data', [], passedAssayData*.value.flatten()
     86    }
     87
     88    void testTemplateFieldsAreCollected() {
     89
     90        mockParams.id = 1
     91
     92        Map passedAssayData
     93
     94        controller.assayService = [exportAssayDataAsExcelFile:{a -> passedAssayData = a}]
     95        controller.exportAssayAsExcel()
     96
     97        def sample1index = passedAssayData.'Sample Data'.'name'.findIndexOf{it == 'sample1'}
     98        def sample2index = passedAssayData.'Sample Data'.'name'.findIndexOf{it == 'sample2'}
     99
     100        assertEquals 'Subject template field', ['tfv1',''], passedAssayData.'Subject Data'.tf1[sample1index, sample2index]
     101        assertEquals 'Subject template field', ['tfv2',''], passedAssayData.'Subject Data'.tf2[sample1index, sample2index]
     102        assertEquals 'Subject template field', ['','tfv3'], passedAssayData.'Subject Data'.tf3[sample1index, sample2index]
     103        assertEquals 'Subject species template field', ['Human', 'Human'], passedAssayData.'Subject Data'.species*.toString()
     104        assertEquals 'Subject name template field', ['subject1','subject2'], passedAssayData.'Subject Data'.name[sample1index, sample2index]
     105
     106        assertEquals 'Sampling event template fields', [2], passedAssayData.'Sampling Event Data'.startTime
     107        assertEquals 'Sampling event template fields', [5], passedAssayData.'Sampling Event Data'.duration
     108        assertEquals 'Sampling event template fields', '[null]', passedAssayData.'Sampling Event Data'.sampleTemplate.toString()
     109        assertEquals 'Event template fields', [6], passedAssayData.'Event Data'.startTime
     110        assertEquals 'Event template fields', [7], passedAssayData.'Event Data'.endTime
     111        assertEquals 'Sample template fields', ['sample1', 'sample2'], passedAssayData.'Sample Data'.name[sample1index, sample2index]
    30112    }
    31113}
  • trunk/test/unit/dbnp/studycapturing/StudyControllerTests.groovy

    r959 r1261  
    44class StudyControllerTests extends ControllerUnitTestCase {
    55    protected void setUp() {
     6
    67        super.setUp()
     8        mockDomain(Study, [ new Study(id: 1, assays: [[id:1, name:'assay1'], [id:2, name:'assay2']]),
     9                            new Study(id: 2, assays: [])])
     10
    711    }
    812
     
    1115    }
    1216
    13     void testSomething() {
     17    void testAjaxGetAssays() {
    1418
     19        mockParams.id = 1
     20        controller.ajaxGetAssays()
     21        assertEquals '[{"name":"assay1","id":1},{"name":"assay2","id":2}]', mockResponse.contentAsString
     22    }
     23
     24
     25    void testAjaxGetAssaysEmptyList() {
     26
     27        mockParams.id = 2
     28        controller.ajaxGetAssays()
     29        assertEquals '[]', mockResponse.contentAsString
    1530    }
    1631}
Note: See TracChangeset for help on using the changeset viewer.