Changeset 934


Ignore:
Timestamp:
Oct 8, 2010, 2:47:23 PM (13 years ago)
Author:
j.saito@…
Message:

Adjusted CommunicationManager? to match closer with CommunicationManager? in SAM.
Added support for "token" notation of REST services directly in Study and Assay domain classes.
Cleaned up and tested communication further.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/RestController.groovy

    r910 r934  
    8686                def user = params.user
    8787                Study.findAllByOwner(requestUser).each { study ->
    88                         studies.push( [ 'title':study.title, 'studyToken':study.code ] )
     88                        studies.push( [ 'title':study.title, 'studyToken':study.getToken()] )
    8989                }
    9090                render studies as JSON
     
    131131                        if(study && study.owner == requestUser) study.assays.each{ assay ->
    132132                                //if (assay.module.url.equals(params.moduleURL)) {
    133                                 def map = ['name':assay.name, 'assayToken':assay.externalAssayID]
     133                                def map = ['name':assay.name, 'assayToken':assay.getToken()]
    134134                                        assays.push( map )
    135135                                //}
     
    159159                        assay.getSamples().each { sample ->
    160160                                def item = [
    161                                         'sampleToken'         : sample.name,
    162                                         'material'            : sample.material.name,
    163                                         'subject'             : sample.parentSubject.name,
    164                                         'event'               : sample.parentEvent.template.name,
    165                                         'startTime'           : sample.parentEvent.getStartTimeString()
     161                                        'sampleToken' : sample.name,
     162                                        'material'        : sample.material.name,
     163                                        'subject'         : sample.parentSubject.name,
     164                                        'event'           : sample.parentEvent.template.name,
     165                                        'startTime'       : sample.parentEvent.getStartTimeString()
    166166                                ]
    167167                                items.push item
     
    170170                render items as JSON
    171171        }
    172 
    173 
    174 
    175172
    176173
     
    198195                                def name = field.name
    199196                                def value = study.getFieldValue( name )
    200                                 if(name=="code") { name = "studyToken" }
    201197                                items[name] = value
    202198                        }
     
    227223                                def name = field.name
    228224                                def value = assay.getFieldValue( name )
    229                                 if(name=="externalAssayID") { name = "assayToken" }
    230225                                items[name] = value
    231226                        }
     
    272267                                                def name = field.name
    273268                                                def value = sample.getFieldValue( name )
    274                                                 if(name=="name") { name = "sampleToken" }
    275269                                                items[name] = value
    276270                        }
  • trunk/grails-app/domain/dbnp/studycapturing/Assay.groovy

    r859 r934  
    5353                return name;
    5454        }
     55
     56    def getToken() {
     57                return externalAssayID
     58    }
    5559}
  • trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy

    r861 r934  
    2929        Term material           // material of the sample (should normally be bound to the BRENDA ontology)
    3030
    31         def getExternalSampleId() { name }
    3231
    3332        /**
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r900 r934  
    5555        }
    5656
    57         // The external study ID is currently defined as the code of the study.
     57        // The external identifier (studyToken) is currently the code of the study.
    5858        // It is used from within dbNP submodules to refer to particular study in this GSCF instance.
    59         def getExternalStudyId() { code }
     59        def getToken() { code }
    6060
    6161        /**
  • trunk/src/groovy/dbnp/rest/common/CommunicationManager.groovy

    r835 r934  
    3030    def public static DSPServerURL  = "http://localhost:8080/gscf"
    3131
    32      
     32
    3333
    3434    /**
     
    109109                        def map = [:]
    110110                    def args = strangeGroovyArgs[0]        // groovy nests the parameters of the methods in some other array
    111                         for( i in 0..(params.size-1) ) {
    112                                 def param = params[i]
    113                             map[param] = args[i]
    114                         }
     111
     112                        if(params.size > 0 )
     113                        {
     114                                for( i in 0..(params.size-1) ) {
     115                                        def param = params[i]
     116                                        map[param] = args[i]
     117                                }
     118                        }
     119
    115120                        return closure( getRestResource( serverURL, restName, map ) )
    116121                }
     
    154159        def url = GSCFServerURL + '/rest'
    155160                addRestWrapper( url , 'getStudies' )
    156                 addRestWrapper( url , 'getSubjects', ['externalStudyID'] )
    157                 addRestWrapper( url , 'getAssays',   ['externalStudyID'] )
    158                 addRestWrapper( url , 'getSamples',  ['externalAssayID'] )
    159     }
     161        addRestWrapper( url , 'getSubjects', ['studyToken'] )
     162                addRestWrapper( url , 'getAssays',   ['studyToken','moduleURL'] )
     163                addRestWrapper( url , 'getSamples',  ['assayToken'] )
     164        }
    160165
    161166
     
    173178                // register method that links to the SAM view for showing a SimpleAssay
    174179        // parameters: externalAssayID
    175                 addViewWrapper( 'getAssayShowURL', url, 'simpleAssay/showByExternalID', ['externalAssayID'] )
     180                addViewWrapper( 'getAssayShowURL', url, 'simpleAssay/show', ['externalAssayID'] )
    176181
    177182                // register method that links to the SAM view for editing a SimpleAssay
     
    192197                //                               ["studies":[NuGO PPS human study],
    193198                //               "samples":[[ [...], dbnp.studycapturing.Sample: 1]]]
    194                 def closure1 = { map ->
    195                     def studies = []
    196                     def samples = []
     199                def closure = { map ->
     200                    def studies = []   
     201                    def assays  = []   
    197202                        def studiesHQ = "from dbnp.studycapturing.Study as s where s.code=?"
    198203                        map['studyIds'].each { studies.add( dbnp.studycapturing.Study.find(studiesHQ,[it]) ) }
    199                         map['Samples'].each { samSample ->
    200                                 def sampleID = samSample['externalSampleID']
    201                             def sampleHQ = "from dbnp.studycapturing.Sample as a where a.externalSampleID='${sampleID}'"
    202                                 def sample = dbnp.studycapturing.Sample.find(sampleHQ)
    203                                 samples.add( [samSample,sample] )
    204                         }
    205                         return [studies:studies, samples:samples]
    206                 }
    207 
    208                 addRestWrapper( url+'/rest', 'getQueryResult',  ['query'], closure1 )
     204                        map['assays'].each { samAssay ->
     205                                def assayID = samAssay['externalAssayID']
     206                            def assayHQ = "from dbnp.studycapturing.Assay as a where a.externalAssayID='${assayID}'"
     207                                def assay = dbnp.studycapturing.Assay.find(assayHQ)
     208                                assays.add( [samAssay,assay] )
     209                        } 
     210                        return [studies:studies, assays:assays]
     211                }
     212
     213                addRestWrapper( url+'/rest', 'getQueryResult',  ['query'], closure )
    209214
    210215
Note: See TracChangeset for help on using the changeset viewer.