Changeset 1027


Ignore:
Timestamp:
Nov 1, 2010, 12:42:49 PM (13 years ago)
Author:
robert@…
Message:

Implemented compare templates feature and fixed show studies overview (tickets #7 and #137)

Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/application.properties

    r1022 r1027  
    11#Grails Metadata file
    2 #Tue Oct 26 15:12:32 CEST 2010
     2#Tue Oct 26 16:55:24 CEST 2010
    33app.grails.version=1.3.5
    44app.name=gscf
  • trunk/grails-app/conf/BootStrapStudies.groovy

    r1014 r1027  
    480480                        name: 'SAM module for clinical data',
    481481                        platform: 'clinical measurements',
    482                         consumer: samURL
     482                        url: samURL
    483483                ).with { if (!validate()) { errors.each { println it} } else save()}
    484484
     
    487487                        name: 'Metabolomics module',
    488488                        platform: 'GCMS/LCMS',
    489                         consumer: nmcdspURL
     489                        url: nmcdspURL
    490490                ).with { if (!validate()) { errors.each { println it} } else save()}
    491491
  • trunk/grails-app/controllers/RestController.groovy

    r1017 r1027  
    145145                        if(study) {
    146146                                // Check whether the person is allowed to read the data of this study
    147 /*
    148147                                if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
    149148                                        response.sendError(401)
    150149                                        return false
    151150                                }
    152 */
     151                               
    153152                                def items = [:]
    154153                                study.giveFields().each { field ->
     
    283282
    284283                                assays.each{ assay ->
    285                                         if (assay.module.consumer.equals(params.consumer )) {
     284                                        if (assay.module.url.equals(params.consumer )) {
    286285                                                if(assay) {
    287286                                                        def map = [:]
  • trunk/grails-app/controllers/dbnp/studycapturing/TemplateEditorController.groovy

    r996 r1027  
    1616import dbnp.data.*
    1717import dbnp.studycapturing.*
     18
    1819import dbnp.authentication.AuthenticationService
     20import grails.plugins.springsecurity.Secured
     21
    1922import cr.co.arquetipos.crypto.Blowfish
    2023import grails.converters.*
    2124import java.lang.reflect.*;
    2225
     26@Secured(['IS_AUTHENTICATED_REMEMBERED'])
    2327class TemplateEditorController {
    2428    def entityName;
    2529    def entity;
    26 
    2730        def AuthenticationService
     31
     32        /**
     33     * Fires after every action and determines the layout of the page
     34     */
     35    def afterInterceptor = { model, modelAndView ->
     36      if ( params['standalone'] ) {
     37        model.layout = 'main';
     38        model.extraparams = [ 'standalone': 'true' ] ;
     39      } else {
     40        model.layout = 'dialog';
     41        model.extraparams = [] ;
     42      }
     43    }
    2844       
    2945        /**
     
    8197
    8298                // redirect to template editor page of the specified entity
    83                 redirect(action: "index",params:[entity: resultEntity])
     99                params.entity = resultEntity
     100                redirect(action: "index", params:params)
    84101        }
    85 
    86102
    87103    /**
     
    110126    }
    111127
     128    /**
     129     * compare two or more templates
     130     */
     131    def compare = {
     132        // Check whether a right entity is given
     133        if( !_checkEntity() ) {
     134                        return
     135                }
     136
     137        // fetch all templates for this entity
     138        def templates = Template.findAllByEntity(entity)
     139
     140                // Find all available fields
     141                def allFields = TemplateField.findAllByEntity( entity ).sort { a, b -> a.name <=> b.name }
     142
     143                // Generate a human readable entity name
     144                def parts = entityName.tokenize( '.' );
     145                def humanReadableEntity = parts[ parts.size() - 1 ];
     146
     147        return [
     148            entity: entity,
     149            templates: templates,
     150                        allFields: allFields,
     151            encryptedEntity: params.entity,
     152            humanReadableEntity: humanReadableEntity,
     153                        ontologies: params.ontologies,
     154                        templateEntities: this.templateEntityList()
     155        ];
     156    }
     157
    112158        /**
    113159         * Shows the editing of a template
     
    138184                def parts = entityName.tokenize( '.' );
    139185                def humanReadableEntity = parts[ parts.size() - 1 ];
    140 
    141 
    142186
    143187                // Find all available fields
     
    836880
    837881    }
     882
     883        def templateEntityList = {
     884                def entities = [
     885                        [ name: 'Study', entity: 'dbnp.studycapturing.Study' ],
     886                        [ name: 'Subject', entity: 'dbnp.studycapturing.Subject' ],
     887                        [ name: 'Event', entity: 'dbnp.studycapturing.Event' ],
     888                        [ name: 'Sampling Event', entity: 'dbnp.studycapturing.SamplingEvent' ],
     889                        [ name: 'Sample', entity: 'dbnp.studycapturing.Sample' ],
     890                        [ name: 'Assay', entity: 'dbnp.studycapturing.Assay' ]
     891                ]
     892
     893                entities.each {
     894                        // add the entity class name to the element
     895                        // do we have crypto information available?
     896                        if (grailsApplication.config.crypto) {
     897                                // generate a Blowfish encrypted and Base64 encoded string.
     898                                it.encoded = URLEncoder.encode(
     899                                        Blowfish.encryptBase64(
     900                                                it.entity.toString().replaceAll(/^class /, ''),
     901                                                grailsApplication.config.crypto.shared.secret
     902                                        )
     903                                )
     904                        } else {
     905                                // base64 only; this is INSECURE! As this class
     906                                // is instantiated elsewehere. Possibly exploitable!
     907                                it.encoded = URLEncoder.encode(it.entity.toString().replaceAll(/^class /, '').bytes.encodeBase64())
     908                        }
     909                }
     910
     911                return entities
     912        }
    838913}
  • trunk/grails-app/domain/dbnp/studycapturing/AssayModule.groovy

    r1014 r1027  
    1212        String platform
    1313
    14         /** Consumer id (e.g., OAuth consuemr key) of module where instance is located */
    15         String consumer
     14        /** The base URL at which the module instance is located. This is also used
     15         * as a consumer parameter to identify the module in the authentication process.
     16         */
     17        String url
    1618
    1719        static constraints = {
  • trunk/grails-app/domain/dbnp/studycapturing/Template.groovy

    r996 r1027  
    8989         */
    9090        public Template( Template otherTemplate) {
    91                 this()
    92 
    93                 //authenticationService = new AuthenticationService()
    94 
    95                 this.name = otherTemplate.name + " (Copy)"
    96                 this.description = otherTemplate.description
    97                 this.entity = otherTemplate.entity
    98                 this.owner = otherTemplate.owner
    99 
    100                 // The fields are copied by reference
    101                 this.fields = otherTemplate.fields
     91                this( otherTemplate, otherTemplate.owner )
    10292        }
    10393
  • trunk/grails-app/views/study/show.gsp

    r1009 r1027  
    240240                  <td>${field}</td>
    241241                  <g:each in="${studyList}" var="studyInstance">
    242                     <td>${studyInstance.getFieldValue(field.name)}</td>
     242                    <td>
     243                                          <g:if test="${studyInstance.fieldExists(field.name)}">
     244                                                ${studyInstance.getFieldValue(field.name)}
     245                                          </g:if>
     246                                          <g:else>
     247                                                -
     248                                          </g:else>
     249                                        </td>
    243250                  </g:each>
    244251                </tr>
  • trunk/grails-app/views/templateEditor/elements/_liTemplate.gsp

    r959 r1027  
    11<li id="template_${template.id}"class="ui-state-default">
    22  <g:if test="${template.inUse()}">
    3         <g:render template="elements/liTemplateNonEditable" model="['template': template]"/>
     3        <g:render template="elements/liTemplateNonEditable" model="['template': template, , 'standalone': standalone]"/>
    44  </g:if>
    55  <g:else>
    6         <g:render template="elements/liTemplateEditable" model="['template': template]"/>
     6        <g:render template="elements/liTemplateEditable" model="['template': template, 'standalone': standalone]"/>
    77  </g:else>
    88</li>
  • trunk/grails-app/views/templateEditor/elements/_liTemplateEditable.gsp

    r996 r1027  
    77${template.name}
    88
    9 
    109<form class="templateField_form" id="template_${template.id}_form" action="updateTemplate">
    1110        <g:hiddenField name="id" value="${template.id}" />
    1211        <g:hiddenField name="version" value="${template.version}" />
     12        <g:hiddenField name="standalone" value="${standalone}" />
    1313        <g:render template="elements/templateForm" model="['template': template]"/>
    1414        <div class="templateFieldButtons">
  • trunk/grails-app/views/templateEditor/elements/_liTemplateNonEditable.gsp

    r996 r1027  
    1212        <g:hiddenField name="id" value="${template.id}" />
    1313        <g:hiddenField name="version" value="${template.version}" />
     14        <g:hiddenField name="standalone" value="${standalone}" />
    1415        <g:render template="elements/templateForm" model="['template': template]"/>
    1516        <div class="templateFieldButtons">
  • trunk/grails-app/views/templateEditor/index.gsp

    r996 r1027  
    1717<html>
    1818        <head>
    19                 <meta name="layout" content="dialog"/>
     19                <meta name="layout" content="${layout}"/>
    2020                <title>template editor</title>
    2121                <script src="${createLinkTo(dir: 'js', file: 'templateEditor.js')}" type="text/javascript"></script>
    2222                <link rel="stylesheet" href="${createLinkTo(dir: 'css', file: 'templateEditor.css')}" />
     23                <style type="text/css">
     24                  #content .templateEditorStep { font-size: 0.8em; }
     25                </style>
     26                <script type="text/javascript" language="javascript">
     27                  var standalone = ${extraparams?.standalone ? 'true' : 'false'};
     28                </script>
    2329        </head>
    2430        <body>
     
    3238                                <li class="empty ui-state-default" <g:if test="${templates.size() > 0 }">style='display: none;'</g:if>>There are no templates for ${humanReadableEntity}. Use the 'Add template' button to add fields.</li>
    3339                                <g:each in="${templates}" var="currentTemplate">
    34                                   <g:render template="elements/liTemplate" model="['template': currentTemplate]"/>
     40                                  <g:render template="elements/liTemplate" model="['template': currentTemplate, 'extraparams': extraparams]"/>
    3541                                </g:each>
    3642                        </ul>
     
    4450                                        <g:hiddenField name="entity" value="${encryptedEntity}" />
    4551                                        <g:hiddenField name="ontologies" value="${ontologies}" />
     52                                        <g:hiddenField name="standalone" value="${extraparams?.standalone}" />
    4653                                        <g:render template="elements/templateForm" model="['template': null]"/>
    4754                                        <div class="templateFieldButtons">
     
    5562                                <g:hiddenField name="entity" value="${encryptedEntity}" />
    5663                                <g:hiddenField name="ontologies" value="${ontologies}" />
     64                                <g:hiddenField name="standalone" value="${extraparams?.standalone}" />
    5765                                <input type="hidden" name="template" id="templateSelect" value="${template?.id}">
    5866                        </g:form>
    5967                </div>
    60 
     68                <br clear="all" />
    6169                <div id="wait" class="wait">
    6270                  &nbsp;
  • trunk/grails-app/views/templateEditor/template.gsp

    r996 r1027  
    1717<html>
    1818        <head>
    19                 <meta name="layout" content="dialog"/>
     19                <meta name="layout" content="${layout}"/>
    2020                <title>template editor</title>
    2121                <script src="${createLinkTo(dir: 'js', file: 'templateEditor.js')}" type="text/javascript"></script>
     
    2626                  <script type="text/javascript" src="${resource(dir: 'js', file: 'ontology-chooser.js')}"></script>
    2727                </g:else>
     28
     29                <style type="text/css">
     30                  #content .templateEditorStep { font-size: 0.8em; }
     31                </style>
    2832        </head>
    2933        <body>
     
    8084                <g:if test="${template}">
    8185                        <div class="templateEditorStep" id="step2_selectedFields">
    82                                 <h3 class="templateName">${template.name} (<a class="switch" href="${createLink(action:'index')}?entity=${encryptedEntity.encodeAsURL()}">switch</a>)</h3>
     86                                <h3 class="templateName">${template.name} (<a class="switch" href="${createLink(action:'index',params: extraparams + [ 'entity': encryptedEntity ])}">switch</a>)</h3>
    8387
    8488                                <p>Currently, this template contains the following fields. Drag fields to reorder. Drag fields to the list of available fields to remove the field from the template.</p>
     
    117121                        </div>
    118122                </g:if>
    119 
     123                <br clear="all" />
    120124                <div id="ontologyDialog">
    121125                  <g:render template="ontologyDialog" />
  • trunk/web-app/css/templateEditor.css

    r996 r1027  
    9797.wait { display: none; }
    9898
     99/* Compare templates view */
     100.dataTables_length { float: left; width: 40%; }
     101.dataTables_filter { float: right; width: 50%; text-align: right; }
     102table#compare_templates { clear: both; }
     103.dataTables_info { float: left; width: 40%; line-height: 25px; }
     104.dataTables_paginate { float: right; text-align: right; width: 50%; padding-top: 5px; }
     105
     106.paging_full_numbers span.paginate_active { background:none repeat scroll 0 0 #2E6AB1; color:#FFFFFF; }
     107.paging_full_numbers span.paginate_button, .paging_full_numbers span.paginate_active {
     108        border:1px solid #CCCCCC; margin-right:2px; padding:1px 6px; text-decoration:none;
     109        cursor: pointer;
     110}
     111
     112
     113
     114
    99115/* Add Ontology dialog */
    100116#addOntology { list-style-type: none; padding-left: 0; }
Note: See TracChangeset for help on using the changeset viewer.