Changeset 454


Ignore:
Timestamp:
May 21, 2010, 10:04:49 AM (13 years ago)
Author:
roberth
Message:

Improved study list to be able to handle one or more studies. Also improved performance issues with Subject and Sample classes. I have set the domainFields property to a static property, filled it in the class description and attached an ontology to it in the bootstrap (because it can't be done in the class description). It might not be the prettiest solution, it does improve the performance of the study detail page and study comparison with 90%.

Location:
trunk/grails-app
Files:
1 deleted
5 edited

Legend:

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

    r453 r454  
    1919                // define timezone
    2020                System.setProperty('user.timezone', 'CET')
     21
     22                // Ontologies must be connected to the templatefields in runtime
     23                // because the Ontology.findByNcboId is not available otherwise
     24                TemplateEntity.getField( Subject.domainFields, 'species' ).ontologies = [Ontology.findByNcboId(1132)]
     25                TemplateEntity.getField( Sample.domainFields, 'material' ).ontologies = [Ontology.findByNcboId(1005)]
    2126
    2227                // we could also check if we are in development by GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT
  • trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy

    r453 r454  
    11package dbnp.studycapturing
    22/**
    3  * 888       888 888    888 8888888888 8888888b.  8888888888
    4  * 888   o   888 888    888 888        888   Y88b 888
    5  * 888  d8b  888 888    888 888        888    888 888
    6  * 888 d888b 888 8888888888 8888888    888   d88P 8888888
    7  * 888d88888b888 888    888 888        8888888P"  888
    8  * 88888P Y88888 888    888 888        888 T88b   888
    9  * 8888P   Y8888 888    888 888        888  T88b  888
    10  * 888P     Y888 888    888 8888888888 888   T88b 8888888888
    11  *
    12  * 8888888 .d8888b.     88888888888 888    888 8888888888
    13  *   888  d88P  Y88b        888     888    888 888
    14  *   888  Y88b.             888     888    888 888
    15  *   888   "Y888b.          888     8888888888 8888888
    16  *   888      "Y88b.        888     888    888 888
    17  *   888        "888        888     888    888 888
    18  *   888  Y88b  d88P        888     888    888 888
    19  * 8888888 "Y8888P"         888     888    888 8888888888
    20  *
    21  *   888888        d8888 888     888     d8888 8888888b.   .d88888b.   .d8888b.
    22  *     "88b       d88888 888     888    d88888 888  "Y88b d88P" "Y88b d88P  Y88b
    23  *      888      d88P888 888     888   d88P888 888    888 888     888 888    888
    24  *      888     d88P 888 Y88b   d88P  d88P 888 888    888 888     888 888
    25  *      888    d88P  888  Y88b d88P  d88P  888 888    888 888     888 888
    26  *      888   d88P   888   Y88o88P  d88P   888 888    888 888     888 888    888
    27  *      88P  d8888888888    Y888P  d8888888888 888  .d88P Y88b. .d88P Y88b  d88P
    28  *      888 d88P     888     Y8P  d88P     888 8888888P"   "Y88888P"   "Y8888P"
    29  *    .d88P
    30  *  .d88P"
    31  * 888P"
    32  *
    33  *  .d8888b.  888  .d8888b.  888  .d8888b.  888
    34  * d88P  Y88b 888 d88P  Y88b 888 d88P  Y88b 888
    35  *      .d88P 888      .d88P 888      .d88P 888
    36  *    .d88P"  888    .d88P"  888    .d88P"  888
    37  *    888"    888    888"    888    888"    888
    38  *    888     Y8P    888     Y8P    888     Y8P
    39  *             "              "              "
    40  *    888     888    888     888    888     888
    41  *
    42  *
    43  * TODO: add PROPER class and method documentation, just like have
    44  *       agreed upon hundreds of times!!!!
     3 * Controller class for studies
    454 */
    465class StudyController {
     
    5918    /**
    6019     * Shows a comparison of multiple studies using the show view
    61      *
    6220     *
    6321     */
    6422    def list_extended = {
    65        
     23        def startTime = System.currentTimeMillis()
    6624        params.max = Math.min(params.max ? params.int('max') : 10, 100)
    6725       
    68         render(view:'show',model:[studyList: Study.list(params), studyInstanceTotal: Study.count() ] )
     26        def studyList = Study.list(params)
     27        render(view:'show',model:[studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ) ] )
    6928    }
    7029
     
    8746
    8847    def show = {
     48        def startTime = System.currentTimeMillis()
    8949
    9050        def studyInstance = Study.get(params.id)
     
    9757            // use the same view for showing the study and comparing multiple
    9858            // studies
    99             [studyList: [ studyInstance ] ]
     59            [studyList: [ studyInstance ], multipleStudies: false ]
    10060        }
    10161    }
  • trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy

    r408 r454  
    1919         * @return List
    2020         */
    21         List<TemplateField> giveDomainFields() {
     21        List<TemplateField> giveDomainFields() { return Sample.domainFields }
     22        static List<TemplateField> domainFields =
    2223                [
    2324                        new TemplateField(
     
    2728                        new TemplateField(
    2829                                name: 'material',
    29                                 type: TemplateFieldType.ONTOLOGYTERM,
    30                                 ontologies: [Ontology.findByNcboId(1005)])
     30                                type: TemplateFieldType.ONTOLOGYTERM )
    3131                ]
    32         }
    3332
    3433        static constraints = {
  • trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy

    r408 r454  
    2121         * @return List
    2222         */
    23         List<TemplateField> giveDomainFields() {
     23        List<TemplateField> giveDomainFields() { return Subject.domainFields }
     24        static List<TemplateField> domainFields =
    2425                [
    2526                        new TemplateField(
     
    2930                        new TemplateField(
    3031                                name: 'species',
    31                                 type: TemplateFieldType.ONTOLOGYTERM,
    32                                 ontologies: [Ontology.findByNcboId(1132)])
     32                                type: TemplateFieldType.ONTOLOGYTERM)
    3333                ]
    34         }
    3534}
  • trunk/grails-app/views/study/show.gsp

    r453 r454  
    3939          <table>
    4040            <!-- only show the head section if there are multiple studies -->
    41             <g:if test="${studyList.size()>1}">
     41            <g:if test="${multipleStudies}">
    4242              <thead>
    4343                <tr>
     
    144144              <thead>
    145145                <tr>
    146                   <th></th>
     146                  <g:if test="${multipleStudies}">
     147                    <th></th>
     148                  </g:if>
    147149                  <g:each in="${new dbnp.studycapturing.Subject().giveDomainFields()}" var="field">
    148150                    <th>${field}</th>
     
    187189                      }
    188190                    }
    189                      
    190191                  %>
    191192
     
    208209                <g:each in="${sortedSubjects}" var="subject" status="j">
    209210                  <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    210                     <g:if test="${j==0}">
     211                    <g:if test="${multipleStudies && j==0}">
    211212                      <td class="studytitle" rowspan="${sortedSubjects.size()}">
    212213                        ${studyInstance.title}
     
    245246                <thead>
    246247                  <tr>
    247                     <th></th>
     248                    <g:if test="${multipleStudies}">
     249                      <th></th>
     250                    </g:if>
    248251                    <th>Start time</th>
    249252                    <th>Duration</th>
     
    269272                  <g:each in="${sortedEvents}" var="event" status="j">
    270273                    <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    271                       <g:if test="${j==0}">
     274                      <g:if test="${multipleStudies && j==0}">
    272275                        <td class="studytitle" rowspan="${sortedEvents.size()}">
    273276                          ${studyInstance.title}
     
    321324              <thead>
    322325                <tr>
    323                   <th></th>
     326                  <g:if test="${multipleStudies}">
     327                    <th></th>
     328                  </g:if>
    324329                  <th>Name</th>
    325330                  <th colspan="${groupTemplates.size()}">Events</th>
     
    327332                </tr>
    328333                <tr>
    329                   <th></th>
     334                  <g:if test="${multipleStudies}">
     335                    <th></th>
     336                  </g:if>
    330337                  <th></th>
    331338                  <g:each in="${groupTemplates}" var="eventTemplate">
     
    342349                <g:each in="${studyInstance.eventGroups}" var="eventGroup" status="j">
    343350                  <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    344                     <g:if test="${j==0}">
     351                    <g:if test="${multipleStudies && j==0}">
    345352                      <td class="studytitle" rowspan="${studyInstance.eventGroups.size()}">
    346353                        ${studyInstance.title}
     
    389396              <thead>
    390397                <tr>
    391                   <th></th>
     398                  <g:if test="${multipleStudies}">
     399                    <th></th>
     400                  </g:if>
    392401                  <th width="100">Assay Name</th>
    393402                  <th width="100">Module</th>
     
    403412                <g:each in="${studyInstance.assays}" var="assay" status="j">
    404413                  <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
    405                     <g:if test="${j==0}">
     414                    <g:if test="${multipleStudies && j==0}">
    406415                      <td class="studytitle" rowspan="${studyInstance.assays.size()}">
    407416                        ${studyInstance.title}
     
    442451                  <th>Phone</th>
    443452                  <th>Email</th>
    444                   <g:each in="${studyList}" var="studyInstance">
    445                     <th>${studyInstance.title}</th>
    446                   </g:each>
     453                  <g:if test="${multipleStudies}">
     454                    <g:each in="${studyList}" var="studyInstance">
     455                      <th>${studyInstance.title}</th>
     456                    </g:each>
     457                  </g:if>
     458                  <g:else>
     459                    <th>Role</th>
     460                  </g:else>
    447461                </thead>
    448462              </tr>
     
    487501                  <th>Authors</th>
    488502                  <th>Comments</th>
    489                   <g:each in="${studyList}" var="studyInstance">
    490                     <th>${studyInstance.title}</th>
    491                   </g:each>
     503
     504                  <g:if test="${multipleStudies}">
     505                    <g:each in="${studyList}" var="studyInstance">
     506                      <th>${studyInstance.title}</th>
     507                    </g:each>
     508                  </g:if>
    492509                </thead>
    493510              </tr>
     
    499516                  </td>
    500517                  <td>${publication.comments}</td>
    501                   <g:each in="${studyList}" var="studyInstance">
    502                     <td>
    503                       <g:if test="${publication in studyInstance.publications}">
    504                         x
    505                       </g:if>
    506                     </td>
    507                   </g:each>
     518                  <g:if test="${multipleStudies}">
     519                    <g:each in="${studyList}" var="studyInstance">
     520                      <td>
     521                        <g:if test="${publication in studyInstance.publications}">
     522                          x
     523                        </g:if>
     524                      </td>
     525                    </g:each>
     526                  </g:if>
    508527                </tr>
    509528              </g:each>
Note: See TracChangeset for help on using the changeset viewer.