Changeset 1610


Ignore:
Timestamp:
Mar 9, 2011, 9:28:13 PM (12 years ago)
Author:
robert@…
Message:

Improved simple import wizard to be able to import events

Location:
trunk/grails-app
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/SimpleWizardController.groovy

    r1609 r1610  
    166166                columns {
    167167                        on( "next" ) {
     168                                flow.editImportedData = params.get( 'editAfterwards' ) ? true : false;
    168169                                handleColumns( flow.study, params, flow ) ? success() : error()
    169170                        }.to "checkImportedEntities"
     
    174175                        action {
    175176                                // Only continue to the next page if the information entered is correct
    176                                 if( flow.imported.numInvalidEntities > 0 ) {
     177                                if( flow.editImportedData || flow.imported.numInvalidEntities > 0 ) {
    177178                                        missingFields();
    178179                                } else {
     
    271272                                        flow.study.addToAssays( flow.assay );
    272273                                }
     274                               
     275                                println "Events: " + flow.study.events
     276                                println "Samples: " + flow.study.samples
     277                                println "Eventgroups" + flow.study.eventGroups
    273278                               
    274279                                if( flow.study.save( flush: true ) ) {
     
    725730                                                                study.addToSamples( entity );
    726731                                                        }
     732                                                       
     733                                                        // If an eventgroup is created, add it to the study
     734                                                        // The eventgroup must have a unique name, but the user shouldn't be bothered with it
     735                                                        // Add 'group ' + samplename and it that is not unique, add a number to it
     736                                                        if( entity.parentEventGroup ) {
     737                                                                study.addToEventGroups( entity.parentEventGroup )
     738
     739                                                                entity.parentEventGroup.name = "Group " + entity.name
     740                                                                while( !entity.parentEventGroup.validate() ) {
     741                                                                        entity.parentEventGroup.getErrors().each { println it }
     742                                                                        entity.parentEventGroup.name += "" + Math.floor( Math.random() * 100 )
     743                                                                }
     744                                                        }
     745                                                       
    727746                                                        break;
    728747                                                case Subject:
     
    737756                                                        break;
    738757                                                case SamplingEvent:
     758                                                        // Sampling events have a 'sampleTemplate' value, which should be filled by the
     759                                                        // template that is chosen for samples.
     760                                                        if( !entity.getFieldValue( 'sampleTemplate' ) ) {
     761                                                                entity.setFieldValue( 'sampleTemplate', flow.sampleForm.template.Sample.name )
     762                                                        }
     763                                               
    739764                                                        if( !preferredIdentifier || !study.samplingEvents?.find( equalClosure ) ) {
    740765                                                                study.addToSamplingEvents( entity );
     
    925950                                                // If no id is given for the subject, it has been entered in this wizard, but
    926951                                                // not yet saved. In that case, it is always OK
    927                                                 if( subject.id && eventGroup.subjects[0]?.id == subject.id )
     952                                                if( subject.id && eventGroup.subjects && eventGroup.subjects.toList()[0]?.id == subject.id )
    928953                                                        numEventGroups++
    929954                                        }
     
    944969                                        // not yet saved. In that case, it is always OK
    945970                                        if( sample.parentSubject && sample.parentSubject.id) {
    946                                                 if( !sample.parentEventGroup.subjects || sample.parentEventGroup.subjects[0]?.id != sample.parentSubject.id ) {
     971                                                if( !sample.parentEventGroup.subjects || sample.parentEventGroup.subjects.toList()[0]?.id != sample.parentSubject.id ) {
    947972                                                        flash.message = "The structure of the eventgroups of one or more samples is too complex"
    948973                                                        simplicity = false;
     
    953978                                        // not yet saved. In that case, it is always OK
    954979                                        if( sample.parentEvent && sample.parentEvent.id) {
    955                                                 if( !sample.parentEventGroup.samplingEvents || sample.parentEventGroup.samplingEvents[0]?.id != sample.parentEvent.id ) {
     980                                                if( !sample.parentEventGroup.samplingEvents || sample.parentEventGroup.samplingEvents.toList()[0]?.id != sample.parentEvent.id ) {
    956981                                                        flash.message = "The structure of the eventgroups of one or more samples is too complex"
    957982                                                        simplicity = false;
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r1609 r1610  
    232232                        'Subject': s?.parentSubject,
    233233                        'SamplingEvent': s?.parentEvent,
    234                         'Event': s?.parentEventGroup?.events?.getAt(0)
     234                        'Event': s?.parentEventGroup?.events?.toList()?.getAt(0)
    235235                ]
    236236        }
  • trunk/grails-app/views/simpleWizard/simpleWizard/columns.gsp

    r1609 r1610  
    8888                                </table>
    8989                        </div>
     90                       
     91                        <p>
     92                                <input type="checkbox" name="editAfterwards" value="1" /> Edit data after importing
     93                        </p>
    9094                </g:form>
    9195                       
  • trunk/grails-app/views/simpleWizard/simpleWizard/missingFields.gsp

    r1609 r1610  
    99<body>
    1010        <div class="simpleWizard">
    11                 <h1>Missing properties</h1>
     11                <h1>Edit properties</h1>
    1212       
    1313                <g:if test="${error}">
     
    2727                        <span class="info">
    2828                                <span class="title">Fill in missing properties</span>
    29                                 A number of records could not be succesfully imported. Fields giving an error are indicated by a red color. Please correct them before continuing.
     29                                <g:if test="${imported.numInvalidEntities > 0}">
     30                                        A number of records could not be succesfully imported. Fields giving an error are indicated by a red color. Please correct them before continuing.
     31                                </g:if>
     32                                <g:else>
     33                                        The imported data is shown below. You can edit the data before continuing.
     34                                </g:else>
    3035                               
    3136                                <g:if test="${imported.errors}">
  • trunk/grails-app/views/simpleWizard/simpleWizard/samples.gsp

    r1609 r1610  
    5959                                            </td>
    6060                                        </tr>
    61 
     61                                        <tr>
     62                                            <td>
     63                                                <div id="datatemplate">Choose type of event template:</div>
     64                                            </td>
     65                                            <td>
     66                                                        <g:select rel="template" entity="${encodedEntity.Event}" name="event_template_id" noSelection="${[null: '- no event template -']}" optionKey="id" optionValue="name" from="${templates.Event}"  value="${sampleForm?.templateId?.Event}" />
     67                                            </td>
     68                                        </tr>
    6269                                        <tr>
    6370                                            <td>
Note: See TracChangeset for help on using the changeset viewer.