[137] | 1 | |
---|
[85] | 2 | <%@ page import="dbnp.studycapturing.Study" %> |
---|
[536] | 3 | <%@ page import="dbnp.studycapturing.EventGroup" %> |
---|
[497] | 4 | <%@ page import="dbnp.studycapturing.RelTime" %> |
---|
[85] | 5 | <html> |
---|
[91] | 6 | <head> |
---|
| 7 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
---|
| 8 | <meta name="layout" content="main" /> |
---|
[467] | 9 | <g:set var="entityName" value="${message(code: 'study.label', default: 'Study')}" /> |
---|
| 10 | <title><g:message code="default.show.label" args="[entityName]" /></title> |
---|
| 11 | <script type="text/javascript"> |
---|
| 12 | // Flag whether the timelines have been loaded |
---|
| 13 | var timelineloaded = false; |
---|
| 14 | |
---|
| 15 | // Number of timelines that should be loaded |
---|
[629] | 16 | var numTimelines = ${studyList?.size()}; |
---|
[467] | 17 | |
---|
| 18 | // This method is called on the event body.onLoad |
---|
| 19 | $(function() { |
---|
| 20 | $("#tabs").tabs({ |
---|
| 21 | show: function(event, ui) { |
---|
| 22 | // If the events tab is shown, the timeline should be redrawn |
---|
[536] | 23 | if( ui.tab.hash == '#events-timeline' && !timelineloaded ) { |
---|
[467] | 24 | loadTimeline( 'eventstimeline', 'eventtitles', 0 ); |
---|
| 25 | timelineloaded = true; |
---|
| 26 | } |
---|
| 27 | } |
---|
| 28 | }); |
---|
| 29 | }); |
---|
| 30 | </script> |
---|
| 31 | <link rel="stylesheet" type="text/css" href="${resource(dir: 'css', file: 'studies.css')}"/> |
---|
[91] | 32 | |
---|
[467] | 33 | <!-- Include scripts for the SIMILE timeline. See http://simile-widgets.org/wiki/ --> |
---|
| 34 | <script type="text/javascript"> |
---|
| 35 | Timeline_ajax_url="${resource(dir: 'js', file: 'timeline-simile/timeline_ajax/simile-ajax-api.js')}"; |
---|
| 36 | Timeline_urlPrefix='${resource(dir: 'js', file: 'timeline-simile/')}'; |
---|
| 37 | Timeline_parameters='bundle=true'; |
---|
| 38 | </script> |
---|
| 39 | <script src="${resource(dir: 'js', file: 'timeline-simile/timeline-api.js')}" type="text/javascript"></script> |
---|
| 40 | <script src="${resource(dir: 'js', file: 'timeline-simile/custom-timeline.js')}" type="text/javascript"></script> |
---|
| 41 | <script src="${resource(dir: 'js', file: 'jquery-callback-1.2.js')}" type="text/javascript"></script> |
---|
| 42 | |
---|
| 43 | <!-- Create the JSON objects for the timeline with events --> |
---|
| 44 | <script type="text/javascript"> |
---|
| 45 | /* |
---|
| 46 | * Creates timeline bands for displaying different timelines |
---|
| 47 | * |
---|
| 48 | * @returns array with BandInfo objects, as described on http://simile-widgets.org/wiki/Timeline_GettingStarted |
---|
| 49 | */ |
---|
| 50 | function createTimelineBands( timelineNr ) { |
---|
| 51 | var bandInfos = []; |
---|
| 52 | var eventSources = []; |
---|
| 53 | var overviewEventSource = new Timeline.DefaultEventSource(); |
---|
| 54 | |
---|
| 55 | // The way the timeline should look. See http://www.linuxjournal.com/article/9301 |
---|
| 56 | var theme = Timeline.ClassicTheme.create(); |
---|
| 57 | var emptyEtherPainter = new Timeline.EmptyEtherPainter( { theme: theme } ) |
---|
| 58 | |
---|
| 59 | // Now create the bands for all studies, and add them to one timeline |
---|
| 60 | // Multiple timeline on one page do not seem to work |
---|
| 61 | <g:set var="bandNr" value="${0}" /> |
---|
| 62 | <g:each in="${studyList}" var="study" status="timelineNr"> |
---|
| 63 | // The date that the timeline should start on |
---|
| 64 | var dateStr = "<g:formatDate format="yyyy/MM/dd HH:mm:ss" date="${study.startDate}"/>"; |
---|
| 65 | firstDate = new Date ( dateStr ); |
---|
| 66 | |
---|
| 67 | //------------- Eventgroup overview --------------- |
---|
| 68 | |
---|
| 69 | <g:set var="datesBandNr" value="${bandNr}" /> |
---|
| 70 | // Add an empty band to show the dates |
---|
| 71 | bandInfos[${bandNr}] = |
---|
| 72 | Timeline.createBandInfo({ |
---|
| 73 | width: 40, |
---|
| 74 | intervalUnit: Timeline.DateTime.DAY, |
---|
| 75 | intervalPixels: 40, |
---|
| 76 | showEventText: false, |
---|
| 77 | date: firstDate, |
---|
| 78 | timeZone: +1, |
---|
| 79 | layout: 'original', |
---|
| 80 | theme: theme |
---|
| 81 | }); |
---|
| 82 | bandTitleInfo[ timelineNr ][ ${bandNr} ] = { |
---|
| 83 | title: "${study.title}", |
---|
| 84 | subjects: "", |
---|
| 85 | className: "studytitle" |
---|
| 86 | }; |
---|
| 87 | |
---|
| 88 | <g:set var="bandNr" value="${bandNr+1}" /> |
---|
[536] | 89 | <% |
---|
| 90 | def sortedEventGroups = study.eventGroups.sort( { a, b -> |
---|
| 91 | return a.name <=> b.name; |
---|
| 92 | } as Comparator ); |
---|
[467] | 93 | |
---|
[536] | 94 | def orphans = study.getOrphanEvents(); |
---|
[629] | 95 | if( orphans?.size() > 0 ) { |
---|
[536] | 96 | sortedEventGroups.add( new EventGroup( |
---|
| 97 | id: -1, |
---|
| 98 | name: 'No group', |
---|
| 99 | events: orphans, |
---|
| 100 | subjects: [] |
---|
| 101 | )); |
---|
| 102 | } |
---|
[467] | 103 | |
---|
[536] | 104 | %> |
---|
| 105 | <g:each in="${sortedEventGroups}" var="eventGroup" status="i"> |
---|
| 106 | |
---|
[467] | 107 | //------------- Eventgroup ${bandNr} --------------- |
---|
| 108 | |
---|
| 109 | // Create an eventsource for all events |
---|
| 110 | eventSources[${bandNr}] = new Timeline.DefaultEventSource(); |
---|
| 111 | |
---|
| 112 | // Load events for this eventsource (using jquery) |
---|
[536] | 113 | var event_url = '${createLink(controller:'study', action:'events', id:( eventGroup.id ? eventGroup.id : -1 ), params: [ startDate: study.startDate.getTime(), study: study.id ])}'; |
---|
[467] | 114 | $.getJSON(event_url, $.callback( _loadJSONEvents, [0, ${bandNr}, eventSources[${bandNr}], overviewEventSource, event_url] ) ); |
---|
| 115 | |
---|
| 116 | // Create a new timeline band |
---|
| 117 | bandInfos[${bandNr}] = |
---|
| 118 | Timeline.createBandInfo({ |
---|
| 119 | eventSource: eventSources[${bandNr}], |
---|
| 120 | width: 30, |
---|
| 121 | intervalUnit: Timeline.DateTime.DAY, |
---|
| 122 | intervalPixels: 40, |
---|
| 123 | date: firstDate, |
---|
| 124 | timeZone: +1, |
---|
| 125 | syncWith: 1, |
---|
| 126 | layout: 'original', |
---|
| 127 | theme: theme |
---|
| 128 | }); |
---|
| 129 | |
---|
| 130 | // Make sure the date isn't printed by using the empty ether painter |
---|
| 131 | bandInfos[${bandNr}].etherPainter = emptyEtherPainter; |
---|
| 132 | |
---|
| 133 | // Add a title to the bandinfo |
---|
[522] | 134 | <% |
---|
| 135 | sortedGroupSubjects = eventGroup.subjects.sort( { a, b -> a.name <=> b.name } as Comparator ); |
---|
| 136 | def simpleSubjects = sortedGroupSubjects.name.join( ', ' ); |
---|
| 137 | |
---|
| 138 | // We can only show appr. 30 characters per line and as many lines as there are events |
---|
| 139 | def charsPerLine = 30; |
---|
[629] | 140 | def numEvents = eventGroup.events?.size(); |
---|
[522] | 141 | def maxChars = numEvents * charsPerLine; |
---|
| 142 | |
---|
| 143 | // If the subjects will fit, show them all |
---|
[629] | 144 | if( simpleSubjects?.size() < maxChars ) { |
---|
[522] | 145 | showSubjects = simpleSubjects; |
---|
| 146 | } else { |
---|
| 147 | // Always add the first name |
---|
| 148 | def subjectNames = sortedGroupSubjects[0]?.name; |
---|
| 149 | |
---|
| 150 | // Continue adding names until the length is to long |
---|
| 151 | id = 0; |
---|
| 152 | sortedGroupSubjects.each { subject -> |
---|
| 153 | if( id > 0 ) { |
---|
[629] | 154 | println( "ID: " + id + " - " + subjectNames?.size() + " - " + subject.name?.size() + " - " + maxChars ); |
---|
| 155 | if( subjectNames?.size() + subject.name?.size() < maxChars - 15 ) { |
---|
[522] | 156 | subjectNames += ", " + subject.name; |
---|
| 157 | } else { |
---|
| 158 | return; |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | id++; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | // Add a postfix |
---|
[629] | 165 | subjectNames += " and " + ( sortedGroupSubjects?.size() - id ) + " more"; |
---|
[522] | 166 | |
---|
| 167 | showSubjects = subjectNames; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | %> |
---|
[467] | 172 | bandTitleInfo[ timelineNr ][ ${bandNr} ] = { |
---|
| 173 | title: "${eventGroup.name}", |
---|
[536] | 174 | className: "<g:if test="${ eventGroup.id == -1 || !eventGroup.id }">no_group</g:if>", |
---|
[522] | 175 | subjects: "${showSubjects}" |
---|
[467] | 176 | }; |
---|
| 177 | |
---|
| 178 | <g:set var="bandNr" value="${bandNr+1}" /> |
---|
| 179 | </g:each> |
---|
| 180 | |
---|
| 181 | // Synchronize all bands |
---|
[536] | 182 | <g:each in="${sortedEventGroups}" var="eventGroup" status="i"> |
---|
[467] | 183 | bandInfos[${i + datesBandNr +1}].syncWith = ${datesBandNr}; |
---|
| 184 | </g:each> |
---|
| 185 | |
---|
| 186 | </g:each> |
---|
| 187 | |
---|
| 188 | return bandInfos; |
---|
| 189 | } |
---|
| 190 | </script> |
---|
[95] | 191 | </head> |
---|
| 192 | <body> |
---|
[135] | 193 | |
---|
[453] | 194 | <div class="body" id="studies"> |
---|
[237] | 195 | <h1><g:message code="default.show.label" args="[entityName]" /></h1> |
---|
| 196 | <g:if test="${flash.message}"> |
---|
| 197 | <div class="message">${flash.message}</div> |
---|
| 198 | </g:if> |
---|
| 199 | <div class="dialog"> |
---|
| 200 | <div id="tabs"> |
---|
| 201 | <ul> |
---|
| 202 | <li><a href="#study">Study Information</a></li> |
---|
| 203 | <li><a href="#subjects">Subjects</a></li> |
---|
[536] | 204 | <li><a href="#events-timeline">Events timeline</a></li> |
---|
| 205 | <li><a href="#events-table">Events table</a></li> |
---|
[237] | 206 | <li><a href="#assays">Assays</a></li> |
---|
[536] | 207 | <li><a href="#samples">Samples</a></li> |
---|
[370] | 208 | <li><a href="#persons">Persons</a></li> |
---|
[442] | 209 | <li><a href="#publications">Publications</a></li> |
---|
[237] | 210 | </ul> |
---|
[223] | 211 | |
---|
[237] | 212 | <div id="study"> |
---|
[442] | 213 | <table> |
---|
[453] | 214 | <!-- only show the head section if there are multiple studies --> |
---|
[454] | 215 | <g:if test="${multipleStudies}"> |
---|
[453] | 216 | <thead> |
---|
| 217 | <tr> |
---|
| 218 | <th></th> |
---|
| 219 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 220 | <th>${studyInstance.title}</th> |
---|
| 221 | </g:each> |
---|
| 222 | </tr> |
---|
| 223 | </thead> |
---|
| 224 | </g:if> |
---|
| 225 | <% |
---|
| 226 | // Determine a union of the fields from all studies, in order |
---|
| 227 | // to show a proper list. We want every field to appear just once, |
---|
| 228 | // so the list is filtered for unique values |
---|
[629] | 229 | studyFields = studyList[0].giveDomainFields() + studyList*.giveTemplateFields()?.flatten().unique() |
---|
[453] | 230 | %> |
---|
[442] | 231 | <!-- Show all template and domain fields, if filled --> |
---|
[453] | 232 | <g:each in="${studyFields}" var="field"> |
---|
| 233 | <% |
---|
| 234 | // If a value is not set for any of the selected studies, the |
---|
| 235 | // field should not appear in the list |
---|
[629] | 236 | showField = true in studyList.collect { it.fieldExists( field.name ) && it.getFieldValue( field.name ) != null }?.flatten() |
---|
[453] | 237 | %> |
---|
| 238 | <g:if test="${showField}"> |
---|
[442] | 239 | <tr> |
---|
| 240 | <td>${field}</td> |
---|
[453] | 241 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 242 | <td>${studyInstance.getFieldValue(field.name)}</td> |
---|
| 243 | </g:each> |
---|
[442] | 244 | </tr> |
---|
| 245 | </g:if> |
---|
| 246 | </g:each> |
---|
[210] | 247 | |
---|
[442] | 248 | <!-- Add some extra fields --> |
---|
| 249 | <tr> |
---|
| 250 | <td>Events</td> |
---|
[453] | 251 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 252 | <td> |
---|
[629] | 253 | <g:if test="${studyInstance.giveEventTemplates()?.size()==0}"> |
---|
[453] | 254 | - |
---|
| 255 | </g:if> |
---|
| 256 | <g:else> |
---|
| 257 | ${studyInstance.giveEventTemplates().name.join(", ")} |
---|
| 258 | </g:else> |
---|
| 259 | </td> |
---|
| 260 | </g:each> |
---|
[442] | 261 | </tr> |
---|
| 262 | <tr> |
---|
| 263 | <td>Sampling events</td> |
---|
[453] | 264 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 265 | <td> |
---|
[629] | 266 | <g:if test="${studyInstance.giveSamplingEventTemplates()?.size()==0}"> |
---|
[453] | 267 | - |
---|
| 268 | </g:if> |
---|
| 269 | <g:else> |
---|
| 270 | ${studyInstance.giveSamplingEventTemplates().name.join(", ")} |
---|
| 271 | </g:else> |
---|
| 272 | </td> |
---|
| 273 | </g:each> |
---|
[442] | 274 | </tr> |
---|
| 275 | <tr> |
---|
| 276 | <td>Readers</td> |
---|
[453] | 277 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 278 | <td> |
---|
[629] | 279 | <g:if test="${studyInstance.readers?.size()==0}"> |
---|
[453] | 280 | - |
---|
| 281 | </g:if> |
---|
| 282 | <g:else> |
---|
| 283 | <g:each in="${studyInstance.readers}" var="r" status="i"> |
---|
| 284 | <g:if test="${i > 0}">, </g:if> |
---|
| 285 | <g:link controller="user" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link> |
---|
| 286 | </g:each> |
---|
| 287 | </g:else> |
---|
| 288 | </td> |
---|
| 289 | </g:each> |
---|
[442] | 290 | </tr> |
---|
| 291 | <tr> |
---|
| 292 | <td>Editors</td> |
---|
[453] | 293 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 294 | <td> |
---|
[629] | 295 | <g:if test="${studyInstance.editors?.size()==0}"> |
---|
[453] | 296 | - |
---|
| 297 | </g:if> |
---|
| 298 | <g:else> |
---|
| 299 | <g:each in="${studyInstance.editors}" var="r" status="i"> |
---|
| 300 | <g:if test="${i > 0}">, </g:if> |
---|
| 301 | <g:link controller="user" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link> |
---|
| 302 | </g:each> |
---|
| 303 | </g:else> |
---|
| 304 | </td> |
---|
| 305 | </g:each> |
---|
[442] | 306 | </tr> |
---|
[370] | 307 | |
---|
[442] | 308 | </table> |
---|
[237] | 309 | </div> |
---|
[141] | 310 | |
---|
[237] | 311 | <div id="subjects"> |
---|
[453] | 312 | |
---|
[629] | 313 | <g:if test="${studyList*.subjects?.flatten()?.size()==0}"> |
---|
[453] | 314 | No subjects in the selected studies |
---|
| 315 | </g:if> |
---|
| 316 | <g:else> |
---|
[237] | 317 | <table> |
---|
[442] | 318 | <thead> |
---|
[237] | 319 | <tr> |
---|
[454] | 320 | <g:if test="${multipleStudies}"> |
---|
| 321 | <th></th> |
---|
| 322 | </g:if> |
---|
[442] | 323 | <g:each in="${new dbnp.studycapturing.Subject().giveDomainFields()}" var="field"> |
---|
| 324 | <th>${field}</th> |
---|
| 325 | </g:each> |
---|
[453] | 326 | |
---|
| 327 | <% |
---|
| 328 | // Determine a union of the fields for all different |
---|
| 329 | // subjects in all studies. In order to show a proper list. |
---|
| 330 | // We want every field to appear just once, |
---|
| 331 | // so the list is filtered for unique values |
---|
[629] | 332 | subjectTemplates = studyList*.giveSubjectTemplates()?.flatten().unique() |
---|
[536] | 333 | if( !subjectTemplates ) { |
---|
| 334 | subjectTemplates = []; |
---|
| 335 | subjectFields = []; |
---|
| 336 | } else { |
---|
[629] | 337 | subjectFields = subjectTemplates*.fields?.flatten().unique() |
---|
[536] | 338 | if( !subjectFields ) { |
---|
| 339 | subjectFields = []; |
---|
| 340 | } |
---|
| 341 | } |
---|
[453] | 342 | |
---|
[536] | 343 | /* |
---|
[453] | 344 | * These lines are rewritten because |
---|
| 345 | * performance sucked |
---|
| 346 | * |
---|
| 347 | * // These took about 9 seconds (for 31 subjects and |
---|
[629] | 348 | * allSubjects = studyList*.subjects?.flatten() |
---|
[453] | 349 | * |
---|
| 350 | * subjectFields = subjectFields.findAll { subjectField -> |
---|
| 351 | * ( true in allSubjects.collect { subject -> subject.fieldExists( subjectField.name ) && subject.getFieldValue( subjectField.name ) != null }.flatten() ) |
---|
| 352 | * } |
---|
| 353 | */ |
---|
| 354 | |
---|
| 355 | // Filter out all fields that are left blank for all subjects |
---|
[629] | 356 | allSubjects = studyList*.subjects?.flatten() |
---|
[453] | 357 | |
---|
| 358 | showSubjectFields = [] |
---|
| 359 | subjectFields.each { subjectField -> |
---|
| 360 | for( subject in allSubjects ) |
---|
| 361 | { |
---|
| 362 | // If the field is filled for this subject, we have to |
---|
| 363 | // show the field and should not check any other |
---|
| 364 | // subjects (hence the break) |
---|
| 365 | if( subject.fieldExists( subjectField.name ) && subject.getFieldValue( subjectField.name ) ) { |
---|
| 366 | showSubjectFields << subjectField; |
---|
| 367 | break; |
---|
| 368 | } |
---|
| 369 | } |
---|
| 370 | } |
---|
| 371 | %> |
---|
| 372 | |
---|
| 373 | <g:each in="${showSubjectFields}" var="field"> |
---|
[442] | 374 | <th>${field}</th> |
---|
| 375 | </g:each> |
---|
[453] | 376 | |
---|
[442] | 377 | </tr> |
---|
| 378 | </thead> |
---|
[453] | 379 | |
---|
| 380 | <g:set var="i" value="${1}" /> |
---|
| 381 | |
---|
| 382 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 383 | <% |
---|
| 384 | // Sort subjects by name |
---|
| 385 | subjects = studyInstance.subjects; |
---|
| 386 | sortedSubjects = subjects.sort( { a, b -> a.name <=> b.name } as Comparator ) |
---|
| 387 | %> |
---|
| 388 | |
---|
| 389 | <g:each in="${sortedSubjects}" var="subject" status="j"> |
---|
| 390 | <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> |
---|
[454] | 391 | <g:if test="${multipleStudies && j==0}"> |
---|
[629] | 392 | <td class="studytitle" rowspan="${sortedSubjects?.size()}"> |
---|
[453] | 393 | ${studyInstance.title} |
---|
| 394 | </td> |
---|
| 395 | </g:if> |
---|
| 396 | <g:each in="${subject.giveDomainFields()}" var="field"> |
---|
| 397 | <td>${subject.getFieldValue(field.name)}</td> |
---|
| 398 | </g:each> |
---|
| 399 | |
---|
| 400 | <g:each in="${showSubjectFields}" var="field"> |
---|
| 401 | <td> |
---|
| 402 | <g:if test="${subject.fieldExists(field.name)}"> |
---|
| 403 | ${subject.getFieldValue(field.name)} |
---|
| 404 | </g:if> |
---|
| 405 | <g:else> |
---|
| 406 | N/A |
---|
| 407 | </g:else> |
---|
| 408 | </td> |
---|
| 409 | </g:each> |
---|
| 410 | |
---|
| 411 | </tr> |
---|
| 412 | <g:set var="i" value="${i + 1}" /> |
---|
[237] | 413 | </g:each> |
---|
| 414 | </g:each> |
---|
| 415 | </table> |
---|
[453] | 416 | </g:else> |
---|
[237] | 417 | </div> |
---|
[141] | 418 | |
---|
[536] | 419 | <div id="events-timeline"> |
---|
[629] | 420 | <g:if test="${studyList*.events?.flatten()?.size()==0 && studyInstance*.samplingEvents?.flatten()?.size()==0 }"> |
---|
[453] | 421 | No events in these studies |
---|
[258] | 422 | </g:if> |
---|
| 423 | <g:else> |
---|
[467] | 424 | <g:each in="${studyList}" var="study" status="i"> |
---|
| 425 | <div style="margin: 10px; "> |
---|
| 426 | <div class="eventtitles" id="eventtitles-${i}"></div> |
---|
| 427 | <div class="eventstimeline" id="eventstimeline-${i}"></div> |
---|
| 428 | </div> |
---|
| 429 | </g:each> |
---|
| 430 | <noscript> |
---|
[370] | 431 | <table> |
---|
[442] | 432 | <thead> |
---|
| 433 | <tr> |
---|
[454] | 434 | <g:if test="${multipleStudies}"> |
---|
| 435 | <th></th> |
---|
| 436 | </g:if> |
---|
[442] | 437 | <th>Start time</th> |
---|
| 438 | <th>Duration</th> |
---|
| 439 | <th>Type</th> |
---|
| 440 | <th>Sampling event</th> |
---|
| 441 | <th>Parameters</th> |
---|
| 442 | </tr> |
---|
| 443 | </thead> |
---|
[370] | 444 | |
---|
[453] | 445 | <g:set var="i" value="${1}" /> |
---|
[442] | 446 | |
---|
[453] | 447 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 448 | <% |
---|
| 449 | // Sort events by starttime and duration |
---|
| 450 | events = studyInstance.events + studyInstance.samplingEvents; |
---|
| 451 | sortedEvents = events.sort( { a, b -> |
---|
[754] | 452 | //a.startTime == b.startTime ? |
---|
| 453 | //a.getDuration().getValue() <=> b.getDuration().getValue() : |
---|
| 454 | a.startTime <=> b.startTime |
---|
[453] | 455 | } as Comparator ) |
---|
| 456 | %> |
---|
| 457 | |
---|
| 458 | <g:each in="${sortedEvents}" var="event" status="j"> |
---|
| 459 | <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> |
---|
[454] | 460 | <g:if test="${multipleStudies && j==0}"> |
---|
[629] | 461 | <td class="studytitle" rowspan="${sortedEvents?.size()}"> |
---|
[453] | 462 | ${studyInstance.title} |
---|
| 463 | </td> |
---|
[370] | 464 | </g:if> |
---|
[754] | 465 | <td>${event.getStartTimeString()}</td> |
---|
[805] | 466 | <td>${((event.getClass() == 'Event') ? event.getDurationString() : '')}</td> |
---|
[453] | 467 | <td>${event.template.name}</td> |
---|
| 468 | <td> |
---|
| 469 | <g:if test="${event instanceof dbnp.studycapturing.SamplingEvent}"> |
---|
| 470 | <g:checkBox name="samplingEvent" disabled="${true}" value="${true}"/> |
---|
[370] | 471 | </g:if> |
---|
[453] | 472 | <g:else> |
---|
| 473 | <g:checkBox name="event" disabled="${true}" value="${false}" /> |
---|
| 474 | </g:else> |
---|
| 475 | </td> |
---|
| 476 | <td> |
---|
| 477 | <g:set var="fieldCounter" value="${1}" /> |
---|
| 478 | <g:each in="${event.giveTemplateFields()}" var="field"> |
---|
| 479 | <g:if test="${event.getFieldValue(field.name)}"> |
---|
| 480 | <g:if test="${fieldCounter > 1}">, </g:if> |
---|
| 481 | ${field.name} = ${event.getFieldValue( field.name )} |
---|
| 482 | <g:set var="fieldCounter" value="${fieldCounter + 1}" /> |
---|
| 483 | </g:if> |
---|
| 484 | </g:each> |
---|
| 485 | </td> |
---|
| 486 | </tr> |
---|
| 487 | |
---|
| 488 | <g:set var="i" value="${i + 1}" /> |
---|
| 489 | </g:each> |
---|
[237] | 490 | </g:each> |
---|
[370] | 491 | </table> |
---|
| 492 | |
---|
[467] | 493 | </noscript> |
---|
| 494 | |
---|
[370] | 495 | </g:else> |
---|
[237] | 496 | </div> |
---|
[210] | 497 | |
---|
[536] | 498 | <div id="events-table"> |
---|
[629] | 499 | <g:if test="${studyList*.eventGroups?.flatten()?.size()==0}"> |
---|
[258] | 500 | No event groups in this study |
---|
| 501 | </g:if> |
---|
| 502 | <g:else> |
---|
[453] | 503 | <% |
---|
| 504 | // Determine a union of the event templates for all different |
---|
| 505 | // eventgroups in all studies, in order to show a proper list. |
---|
| 506 | // We want every field to appear just once, |
---|
| 507 | // so the list is filtered for unique values |
---|
[629] | 508 | groupTemplates = studyList*.giveAllEventTemplates()?.flatten().unique() |
---|
[453] | 509 | %> |
---|
[370] | 510 | <table> |
---|
[453] | 511 | <thead> |
---|
[370] | 512 | <tr> |
---|
[454] | 513 | <g:if test="${multipleStudies}"> |
---|
| 514 | <th></th> |
---|
| 515 | </g:if> |
---|
[453] | 516 | <th>Name</th> |
---|
[629] | 517 | <th colspan="${groupTemplates?.size()}">Events</th> |
---|
[453] | 518 | <th>Subjects</th> |
---|
| 519 | </tr> |
---|
| 520 | <tr> |
---|
[454] | 521 | <g:if test="${multipleStudies}"> |
---|
| 522 | <th></th> |
---|
| 523 | </g:if> |
---|
[453] | 524 | <th></th> |
---|
| 525 | <g:each in="${groupTemplates}" var="eventTemplate"> |
---|
| 526 | <th>${eventTemplate.name}</th> |
---|
| 527 | </g:each> |
---|
| 528 | <th></th> |
---|
| 529 | </tr> |
---|
| 530 | </thead> |
---|
[258] | 531 | |
---|
[453] | 532 | <g:set var="i" value="${1}" /> |
---|
| 533 | |
---|
| 534 | <g:each in="${studyList}" var="studyInstance"> |
---|
[536] | 535 | <% |
---|
| 536 | def sortedEventGroups = studyInstance.eventGroups.sort( { a, b -> |
---|
| 537 | return a.name <=> b.name; |
---|
| 538 | } as Comparator ); |
---|
[453] | 539 | |
---|
[536] | 540 | def orphans = studyInstance.getOrphanEvents(); |
---|
[629] | 541 | if( orphans?.size() > 0 ) { |
---|
[536] | 542 | sortedEventGroups.add( new EventGroup( |
---|
| 543 | id: -1, |
---|
| 544 | name: 'No group', |
---|
| 545 | events: orphans, |
---|
| 546 | subjects: [] |
---|
| 547 | )); |
---|
| 548 | } |
---|
| 549 | |
---|
| 550 | %> |
---|
| 551 | <g:each in="${sortedEventGroups}" var="eventGroup" status="j"> |
---|
[453] | 552 | <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> |
---|
[454] | 553 | <g:if test="${multipleStudies && j==0}"> |
---|
[629] | 554 | <td class="studytitle" rowspan="${sortedEventGroups?.size()}"> |
---|
[453] | 555 | ${studyInstance.title} |
---|
| 556 | </td> |
---|
| 557 | </g:if> |
---|
| 558 | <td>${eventGroup.name}</td> |
---|
| 559 | |
---|
| 560 | <g:each in="${groupTemplates}" var="currentEventTemplate"> |
---|
| 561 | <td> |
---|
| 562 | <g:each in="${eventGroup.events}" var="event"> |
---|
| 563 | <g:if test="${event.template.name==currentEventTemplate.name}"> |
---|
| 564 | |
---|
| 565 | <g:set var="fieldCounter" value="${1}" /> |
---|
| 566 | <g:each in="${event.giveTemplateFields()}" var="field"> |
---|
| 567 | <g:if test="${event.getFieldValue(field.name)}"> |
---|
| 568 | <g:if test="${fieldCounter > 1}">, </g:if> |
---|
| 569 | ${field.name} = ${event.getFieldValue( field.name )} |
---|
| 570 | <g:set var="fieldCounter" value="${fieldCounter + 1}" /> |
---|
| 571 | </g:if> |
---|
| 572 | </g:each> |
---|
| 573 | </g:if> |
---|
| 574 | </g:each> |
---|
| 575 | </td> |
---|
| 576 | </g:each> |
---|
[370] | 577 | <td> |
---|
[453] | 578 | <% sortedGroupSubjects = eventGroup.subjects.sort( { a, b -> a.name <=> b.name } as Comparator ) %> |
---|
| 579 | ${sortedGroupSubjects.name.join( ', ' )} |
---|
| 580 | </td> |
---|
| 581 | </tr> |
---|
[370] | 582 | |
---|
[453] | 583 | <g:set var="i" value="${i + 1}" /> |
---|
| 584 | </g:each> |
---|
| 585 | |
---|
[258] | 586 | </g:each> |
---|
[453] | 587 | |
---|
[370] | 588 | </table> |
---|
[258] | 589 | </g:else> |
---|
[237] | 590 | </div> |
---|
| 591 | |
---|
| 592 | <div id="assays"> |
---|
[629] | 593 | <g:if test="${studyList*.assays?.flatten()?.size()==0}"> |
---|
[453] | 594 | No assays in these studies |
---|
[237] | 595 | </g:if> |
---|
| 596 | <g:else> |
---|
| 597 | <table> |
---|
[442] | 598 | <thead> |
---|
[237] | 599 | <tr> |
---|
[454] | 600 | <g:if test="${multipleStudies}"> |
---|
| 601 | <th></th> |
---|
| 602 | </g:if> |
---|
[442] | 603 | <th width="100">Assay Name</th> |
---|
| 604 | <th width="100">Module</th> |
---|
| 605 | <th>Type</th> |
---|
| 606 | <th width="150">Platform</th> |
---|
| 607 | <th>Url</th> |
---|
| 608 | <th>Samples</th> |
---|
| 609 | </tr> |
---|
| 610 | </thead> |
---|
[453] | 611 | <g:set var="i" value="${1}" /> |
---|
| 612 | |
---|
| 613 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 614 | <g:each in="${studyInstance.assays}" var="assay" status="j"> |
---|
| 615 | <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> |
---|
[454] | 616 | <g:if test="${multipleStudies && j==0}"> |
---|
[629] | 617 | <td class="studytitle" rowspan="${studyInstance.assays?.size()}"> |
---|
[453] | 618 | ${studyInstance.title} |
---|
| 619 | </td> |
---|
| 620 | </g:if> |
---|
| 621 | <td>${assay.name}</td> |
---|
| 622 | <td>${assay.module.name}</td> |
---|
| 623 | <td>${assay.module.type}</td> |
---|
| 624 | <td>${assay.module.platform}</td> |
---|
| 625 | <td>${assay.module.url}</td> |
---|
| 626 | <td> |
---|
| 627 | <% sortedAssaySamples = assay.samples.sort( { a, b -> a.name <=> b.name } as Comparator ) %> |
---|
| 628 | ${sortedAssaySamples.name.join( ', ' )} |
---|
| 629 | </td> |
---|
| 630 | </tr> |
---|
| 631 | <g:set var="i" value="${i + 1}" /> |
---|
| 632 | |
---|
| 633 | </g:each> |
---|
[211] | 634 | </g:each> |
---|
[237] | 635 | </table> |
---|
| 636 | </g:else> |
---|
| 637 | </div> |
---|
| 638 | |
---|
[536] | 639 | <div id="samples"> |
---|
| 640 | |
---|
[629] | 641 | <g:if test="${studyList*.samples.flatten()?.size()==0}"> |
---|
[536] | 642 | No samples in the selected studies |
---|
| 643 | </g:if> |
---|
| 644 | <g:else> |
---|
| 645 | <table> |
---|
| 646 | <thead> |
---|
| 647 | <tr> |
---|
| 648 | <g:if test="${multipleStudies}"> |
---|
| 649 | <th></th> |
---|
| 650 | </g:if> |
---|
| 651 | <g:each in="${new dbnp.studycapturing.Sample().giveDomainFields()}" var="field"> |
---|
| 652 | <th>${field}</th> |
---|
| 653 | </g:each> |
---|
| 654 | |
---|
| 655 | <% |
---|
| 656 | // Determine a union of the fields for all different |
---|
| 657 | // samples in all studies. In order to show a proper list. |
---|
| 658 | // We want every field to appear just once, |
---|
| 659 | // so the list is filtered for unique values |
---|
| 660 | sampleTemplates = studyList*.giveSampleTemplates().flatten().unique() |
---|
| 661 | |
---|
| 662 | if( !sampleTemplates ) { |
---|
| 663 | sampleTemplates = []; |
---|
| 664 | sampleFields = []; |
---|
| 665 | showSampleFields = []; |
---|
| 666 | } else { |
---|
| 667 | sampleFields = sampleTemplates*.fields.flatten().unique() |
---|
| 668 | if( !sampleFields ) { |
---|
| 669 | sampleFields = []; |
---|
| 670 | showSampleFields = []; |
---|
| 671 | } else { |
---|
| 672 | // Filter out all fields that are left blank for all samples |
---|
| 673 | allSamples = studyList*.samples.flatten() |
---|
| 674 | |
---|
| 675 | showSampleFields = []; |
---|
| 676 | sampleFields.each { sampleField -> |
---|
| 677 | for( sample in allSamples ) |
---|
| 678 | { |
---|
| 679 | // If the field is filled for this subject, we have to |
---|
| 680 | // show the field and should not check any other |
---|
| 681 | // samples (hence the break) |
---|
| 682 | if( sample.fieldExists( sampleField.name ) && sample.getFieldValue( sampleField.name ) ) { |
---|
| 683 | showSampleFields << sampleField; |
---|
| 684 | break; |
---|
| 685 | } |
---|
| 686 | } |
---|
| 687 | } |
---|
| 688 | } |
---|
| 689 | } |
---|
| 690 | %> |
---|
| 691 | |
---|
| 692 | <g:each in="${showSampleFields}" var="field"> |
---|
| 693 | <th>${field}</th> |
---|
| 694 | </g:each> |
---|
| 695 | |
---|
| 696 | </tr> |
---|
| 697 | </thead> |
---|
| 698 | |
---|
| 699 | <g:set var="i" value="${1}" /> |
---|
| 700 | |
---|
| 701 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 702 | <% |
---|
| 703 | // Sort samples by name |
---|
| 704 | samples = studyInstance.samples; |
---|
| 705 | sortedSamples = samples.sort( { a, b -> a.name <=> b.name } as Comparator ) |
---|
| 706 | %> |
---|
| 707 | |
---|
| 708 | <g:each in="${sortedSamples}" var="sample" status="j"> |
---|
| 709 | <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> |
---|
| 710 | <g:if test="${multipleStudies && j==0}"> |
---|
[629] | 711 | <td class="studytitle" rowspan="${sortedSamples?.size()}"> |
---|
[536] | 712 | ${studyInstance.title} |
---|
| 713 | </td> |
---|
| 714 | </g:if> |
---|
| 715 | <g:each in="${sample.giveDomainFields()}" var="field"> |
---|
| 716 | <td>${sample.getFieldValue(field.name)}</td> |
---|
| 717 | </g:each> |
---|
| 718 | |
---|
| 719 | <g:each in="${showSampleFields}" var="field"> |
---|
| 720 | <td> |
---|
| 721 | <g:if test="${sample.fieldExists(field.name)}"> |
---|
| 722 | ${sample.getFieldValue(field.name)} |
---|
| 723 | </g:if> |
---|
| 724 | <g:else> |
---|
| 725 | N/A |
---|
| 726 | </g:else> |
---|
| 727 | </td> |
---|
| 728 | </g:each> |
---|
| 729 | |
---|
| 730 | </tr> |
---|
| 731 | <g:set var="i" value="${i + 1}" /> |
---|
| 732 | </g:each> |
---|
| 733 | </g:each> |
---|
| 734 | |
---|
| 735 | </table> |
---|
| 736 | </g:else> |
---|
| 737 | </div> |
---|
| 738 | |
---|
[370] | 739 | <div id="persons"> |
---|
[453] | 740 | <% |
---|
| 741 | // Determine a list of all persons |
---|
| 742 | allPersons = studyList*.persons*.person.flatten().unique() |
---|
| 743 | %> |
---|
[629] | 744 | <g:if test="${allPersons?.size()==0}"> |
---|
[453] | 745 | No persons involved in these studies |
---|
[370] | 746 | </g:if> |
---|
| 747 | <g:else> |
---|
| 748 | <table> |
---|
| 749 | <tr> |
---|
[442] | 750 | <thead> |
---|
| 751 | <th>Name</th> |
---|
| 752 | <th>Affiliations</th> |
---|
| 753 | <th>Phone</th> |
---|
| 754 | <th>Email</th> |
---|
[454] | 755 | <g:if test="${multipleStudies}"> |
---|
| 756 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 757 | <th>${studyInstance.title}</th> |
---|
| 758 | </g:each> |
---|
| 759 | </g:if> |
---|
| 760 | <g:else> |
---|
| 761 | <th>Role</th> |
---|
| 762 | </g:else> |
---|
[442] | 763 | </thead> |
---|
[370] | 764 | </tr> |
---|
[453] | 765 | <g:each in="${allPersons}" var="person" status="i"> |
---|
[442] | 766 | <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> |
---|
[453] | 767 | <td>${person.firstName} ${person.prefix} ${person.lastName}</td> |
---|
[370] | 768 | <td> |
---|
[453] | 769 | ${person.affiliations.join(', ')} |
---|
[370] | 770 | </td> |
---|
[453] | 771 | <td>${person.phone}</td> |
---|
| 772 | <td>${person.email}</td> |
---|
| 773 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 774 | <% |
---|
| 775 | studyperson = studyInstance.persons.find { it.person == person } |
---|
| 776 | %> |
---|
| 777 | <td> |
---|
| 778 | <g:if test="${studyperson}"> |
---|
| 779 | ${studyperson.role.name} |
---|
| 780 | </g:if> |
---|
| 781 | </td> |
---|
| 782 | </g:each> |
---|
| 783 | |
---|
[370] | 784 | </tr> |
---|
| 785 | </g:each> |
---|
| 786 | </table> |
---|
| 787 | </g:else> |
---|
| 788 | </div> |
---|
[442] | 789 | |
---|
| 790 | <div id="publications"> |
---|
[453] | 791 | <% |
---|
| 792 | // Determine a list of all persons |
---|
| 793 | allPublications = studyList*.publications.flatten().unique() |
---|
| 794 | %> |
---|
[629] | 795 | <g:if test="${allPublications?.size()==0}"> |
---|
[453] | 796 | No publications attached to these studies |
---|
[442] | 797 | </g:if> |
---|
| 798 | <g:else> |
---|
| 799 | <table> |
---|
| 800 | <tr> |
---|
| 801 | <thead> |
---|
| 802 | <th>Title</th> |
---|
| 803 | <th>Authors</th> |
---|
| 804 | <th>Comments</th> |
---|
[454] | 805 | |
---|
| 806 | <g:if test="${multipleStudies}"> |
---|
| 807 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 808 | <th>${studyInstance.title}</th> |
---|
| 809 | </g:each> |
---|
| 810 | </g:if> |
---|
[442] | 811 | </thead> |
---|
| 812 | </tr> |
---|
[453] | 813 | <g:each in="${allPublications}" var="publication" status="i"> |
---|
[442] | 814 | <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> |
---|
| 815 | <td>${publication.title}</td> |
---|
| 816 | <td> |
---|
[453] | 817 | ${publication.authorsList} |
---|
[442] | 818 | </td> |
---|
[453] | 819 | <td>${publication.comments}</td> |
---|
[454] | 820 | <g:if test="${multipleStudies}"> |
---|
| 821 | <g:each in="${studyList}" var="studyInstance"> |
---|
| 822 | <td> |
---|
| 823 | <g:if test="${publication in studyInstance.publications}"> |
---|
| 824 | x |
---|
| 825 | </g:if> |
---|
| 826 | </td> |
---|
| 827 | </g:each> |
---|
| 828 | </g:if> |
---|
[442] | 829 | </tr> |
---|
| 830 | </g:each> |
---|
| 831 | </table> |
---|
| 832 | </g:else> |
---|
| 833 | </div> |
---|
| 834 | |
---|
[141] | 835 | </div> |
---|
[95] | 836 | </div> |
---|
[237] | 837 | <br> |
---|
| 838 | <div class="buttons"> |
---|
| 839 | <g:form> |
---|
[629] | 840 | <g:if test="${studyList?.size() == 1}"> |
---|
[453] | 841 | <g:set var="studyInstance" value="${studyList[0]}" /> |
---|
| 842 | <g:hiddenField name="id" value="${studyInstance?.id}" /> |
---|
[578] | 843 | <span class="button"><g:link class="edit" controller="wizard" params="[jump:'edit']" id="${studyInstance?.id}">${message(code: 'default.button.edit.label', default: 'Edit')}</g:link></span> |
---|
[453] | 844 | <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span> |
---|
| 845 | </g:if> |
---|
[442] | 846 | <span class="button"><g:link class="backToList" action="list">Back to list</g:link></span> |
---|
[237] | 847 | </g:form> |
---|
| 848 | </div> |
---|
[453] | 849 | |
---|
[91] | 850 | </div> |
---|
| 851 | </body> |
---|
[85] | 852 | </html> |
---|