Changeset 1171


Ignore:
Timestamp:
Nov 18, 2010, 3:20:10 PM (13 years ago)
Author:
t.w.abma@…
Message:
  • added add / modify to date template chooser
  • added some JS to handle select boxes, when choosing study the study chooser dropdown disappears
  • added encryption to select box, necessary to let the template add/remove popup work correctly
  • added "encrypted" variable to Config, used by the date template dropdown
Location:
trunk/grails-app
Files:
5 edited

Legend:

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

    r1155 r1171  
    187187                // @see ImporterController
    188188                importableEntities: [
    189                         event: [name: 'Event', entity: 'dbnp.studycapturing.Event'],
    190                         sample: [name: 'Sample', entity: 'dbnp.studycapturing.Sample'],
    191                         study: [name: 'Study', entity: 'dbnp.studycapturing.Study'],
    192                         subject: [name: 'Subject', entity: 'dbnp.studycapturing.Subject'],
    193                         samplingevent: [name: 'SamplingEvent', entity: 'dbnp.studycapturing.SamplingEvent']
     189                        event: [name: 'Event', entity: 'dbnp.studycapturing.Event', encrypted:''],
     190                        sample: [name: 'Sample', entity: 'dbnp.studycapturing.Sample', encrypted:''],
     191                        study: [name: 'Study', entity: 'dbnp.studycapturing.Study', encrypted:''],
     192                        subject: [name: 'Subject', entity: 'dbnp.studycapturing.Subject', encrypted:''],
     193                        samplingevent: [name: 'SamplingEvent', entity: 'dbnp.studycapturing.SamplingEvent', encrypted:'']
    194194
    195195                ]
  • trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy

    r1165 r1171  
    2929import grails.plugins.springsecurity.Secured
    3030
     31import cr.co.arquetipos.crypto.Blowfish
     32
    3133@Secured(['IS_AUTHENTICATED_REMEMBERED'])
    3234class ImporterController {
     
    4143        // should do a check what is in the url, strip it?
    4244        session.import_referer = params.redirectTo
     45
     46        grailsApplication.config.gscf.domain.importableEntities.each {           
     47            it.value.encrypted =
     48                                Blowfish.encryptBase64(
     49                                        it.value.entity.toString().replaceAll(/^class /, ''),
     50                                        grailsApplication.config.crypto.shared.secret
     51                                )
     52        }
     53
    4354        render(view:"index_simple",
    4455               model:[studies:Study.findAllWhere(owner:AuthenticationService.getLoggedInUser()),
     
    8192        def wb = handleUpload('importfile')
    8293        def selectedentities = []
    83         def entity = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity
    84         def entityClass = Class.forName(entity, true, this.getClass().getClassLoader())
    85 
     94        //def entity = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity
     95        def entityName = Blowfish.decryptBase64(
     96                            params.entity,
     97                            grailsApplication.config.crypto.shared.secret
     98                         )
     99
     100        def entityClass = Class.forName(entityName, true, this.getClass().getClassLoader())
     101       
    86102        // Initialize some session variables
    87103        session.importer_workbook = wb
    88104        session.importer_study = Study.get(params.study.id.toInteger())
    89        
     105
    90106        // Is the current logged in user allowed to write to this study?
    91107        if (session.importer_study.canWrite(AuthenticationService.getLoggedInUser())) {
     
    103119       
    104120            // Initialize 'selected entities', used to show entities above the columns
    105             session.importer_header.each {
    106                 selectedentities.add([name:params.entity, columnindex:it.key.toInteger()])
     121            session.importer_header.each {               
     122                selectedentities.add([name:entityName, columnindex:it.key.toInteger()])
    107123            }
    108124
     
    328344    * @return JSON object containing the found templates
    329345    */
    330     def ajaxGetTemplatesByEntity = {
    331         def entityClass = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity
    332        
     346    def ajaxGetTemplatesByEntity = {       
     347        def entityName = Blowfish.decryptBase64(
     348                        params.entity,
     349                        grailsApplication.config.crypto.shared.secret
     350                    )
     351
     352        //def entityClass = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity
     353        def entityClass = entityName
    333354
    334355        // fetch all templates for a specific entity
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r1164 r1171  
    345345                                               break
    346346                        case Event          :  break
    347                         case Sample         :  break
     347                        case Sample         :
     348                                               break
    348349                        case SamplingEvent  :  break
    349350                        default             :  // unknown entity
  • trunk/grails-app/views/importer/common/_properties_horizontal.gsp

    r1143 r1171  
    1515<g:form name="propertiesform" action="saveProperties">
    1616    <table>
    17           <g:each var="stdentity" in ="${standardentities}">         
    18              
    19               <% if (selectedentities.any { it.name.toLowerCase() == stdentity.value.name.toLowerCase() } && stdentity.value.name!="") { %>
     17          <g:each var="stdentity" in ="${standardentities}">           
     18              <% if (selectedentities.any { it.name.toLowerCase() == stdentity.value.entity.toLowerCase() } && stdentity.value.entity!="") { %>
    2019              <tr><td colspan="2"><h4>${stdentity.value.name}</h4></td></tr>         
    2120                <tr>
    2221                <g:each var="selentity" in="${selectedentities}">                   
    23                     <g:if test="${selentity.name.toLowerCase()==stdentity.value.name.toLowerCase()}">
     22                    <g:if test="${selentity.name.toLowerCase()==stdentity.value.entity.toLowerCase()}">
    2423                            <td class="header" width="200px">
    2524                                <b>${header[selentity.columnindex.toInteger()].name}</b>
  • trunk/grails-app/views/importer/index_simple.gsp

    r1148 r1171  
    3535    var items = data
    3636
    37     // If a study has been selected, don't show the "Choose study" field, otherwise do
    38     if ($('#'+'entity').val() == 'study')
     37    // If a study has been selected, don't show the "Choose study" field, otherwise do   
     38    if ($('#'+'entity :selected').text() == 'Study')
    3939      $('#studyfield').hide();
    4040    else $('#studyfield').show();
    4141
    4242    // set the entity name for the data template chooser
    43     //alert ( "das" + $('select[name=template_id]').attr('entity') )
     43    //if ($('#'+'entity').val() == 'event')
    4444
    4545    //$('select[name=template_id]').attr('entity', $('#'+'entity').val());
     46    $('select[name=template_id]').attr('entity', $('#'+'entity').val());
     47
    4648
    4749    if (items) {
     
    7274       rel     : 'typetemplate',
    7375       url     : '/gscf/templateEditor',
    74        vars    : 'thentity', // can be a comma separated list of variable names to pass on
     76       vars    : 'entity', // can be a comma separated list of variable names to pass on
    7577       label   : 'add / modify ...',
    7678       style   : 'modify',
     
    162164                from="${entities}"             
    163165                optionValue="${{it.value.name}}"
    164                 optionKey="key"
     166                optionKey="${{it.value.encrypted}}"
    165167                noSelection="['':'-Choose type of data-']"
    166168                onChange="${remoteFunction( controller: 'importer',
     
    175177            </td>
    176178            <td>
    177                 <g:select rel="typetemplate" entity="hoi" name="template_id" optionKey="id" optionValue="name" from="[]" />
     179                <g:select rel="typetemplate" entity="none" name="template_id" optionKey="id" optionValue="name" from="[]" />
    178180            </td>
    179181        </tr>
Note: See TracChangeset for help on using the changeset viewer.