Changeset 1512
- Timestamp:
- Feb 10, 2011, 1:04:32 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/RestController.groovy
r1482 r1512 419 419 * Example 3: two sampleTokens given. 420 420 * Query: 421 * http://localhost:8080/gscf/rest/getSamples/query?assayToken=PPSH-Glu-A&sampleToken=5_A 421 * http://localhost:8080/gscf/rest/getSamples/query?assayToken=PPSH-Glu-A&sampleToken=5_A&sampleToken=6_A 422 422 * 423 423 * Result: 424 424 * [{"sampleToken":"5_A","material":"blood plasma","subject":"5","event":"Blood extraction","startTime":"4 days, 6 hours"}, 425 425 * {"sampleToken":"6_A","material":"blood plasma","subject":"6","event":"Blood extraction","startTime":"4 days, 6 hours"}] 426 * 427 * 428 * Example 4: no assaytoken given 429 * Query: 430 * http://localhost:8080/gscf/rest/getSamples/query?sampleToken=5_A&sampleToken=6_A 431 * 432 * Result: 433 * [{"sampleToken":"5_A","material":"blood plasma","subject":"5","event":"Blood extraction","startTime":"4 days, 6 hours"}, 434 * {"sampleToken":"6_A","material":"blood plasma","subject":"6","event":"Blood extraction","startTime":"4 days, 6 hours"}] 435 * 426 436 */ 427 437 def getSamples = { 428 438 def items = [] 439 def samples 429 440 if( params.assayToken ) { 430 441 def assay = Assay.findByAssayUUID( params.assayToken ); … … 437 448 } 438 449 439 def samples = assay.getSamples() // on all samples 440 441 if( params.sampleToken ) { // or on a subset of samples? 442 def sampleTokens = (params.sampleToken instanceof String) ? 443 [params.sampleToken] : params.sampleToken 444 samples = [] 445 sampleTokens.each{ sampleToken -> 446 samples.addAll(assay.getSamples().find{ sample -> sampleToken == sample.giveUUID() }) 447 } 448 } 449 450 samples.each { sample -> 451 452 def item = [ 453 'sampleToken' : sample.giveUUID(), 454 'material' : sample.material?.name, 455 'subject' : sample.parentSubject?.name, 456 'event' : sample.parentEvent?.template?.name, 457 'startTime' : sample.parentEvent?.getStartTimeString() 458 ] 459 460 sample.giveFields().each { field -> 461 def name = field.name 462 def value = sample.getFieldValue( name ) 463 if(name!='material') 464 { 465 item[name]=value 466 } 467 } 468 469 if(sample.parentEvent) { 470 def parentEvent = sample.parentEvent 471 def eventHash = [:] 472 parentEvent.giveFields().each { field -> 473 def name = field.name 474 if( name !='sampleTemplate' && name != 'fields') { 475 def value = parentEvent.getFieldValue( name ) 476 eventHash[name]=value 477 } 478 } 479 item['eventObject'] = eventHash 480 } 481 482 if(sample.parentSubject) { 483 def parentSubject = sample.parentSubject 484 def subject = [:] 485 parentSubject.giveFields().each { field -> 486 def name = field.name 487 if( name!='fields') { 488 def value = parentSubject.getFieldValue( name ) 489 subject[name]=value 490 } 491 } 492 item['subjectObject'] = subject 493 } 494 495 items.push item 496 } 450 samples = assay.getSamples() // on all samples 497 451 } else { 498 452 // Assay not found … … 500 454 return false 501 455 } 502 } 456 } else { 457 // Find all samples from studies the user can read 458 def studies = Study.list().findAll { it.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ) ) }; 459 samples = studies*.getSamples().flatten(); 460 } 461 462 // Check whether only a subset of samples should be returned 463 if( params.sampleToken ) { 464 def sampleTokens = params.list( "sampleToken" ); 465 samples = samples.findAll { sampleTokens.contains( it.giveUUID() ) } 466 } 467 468 samples.each { sample -> 469 470 def item = [ 471 'sampleToken' : sample.giveUUID(), 472 'material' : sample.material?.name, 473 'subject' : sample.parentSubject?.name, 474 'event' : sample.parentEvent?.template?.name, 475 'startTime' : sample.parentEvent?.getStartTimeString() 476 ] 477 478 sample.giveFields().each { field -> 479 def name = field.name 480 def value = sample.getFieldValue( name ) 481 if(name!='material') 482 { 483 item[name]=value 484 } 485 } 486 487 if(sample.parentEvent) { 488 def parentEvent = sample.parentEvent 489 def eventHash = [:] 490 parentEvent.giveFields().each { field -> 491 def name = field.name 492 if( name !='sampleTemplate' && name != 'fields') { 493 def value = parentEvent.getFieldValue( name ) 494 eventHash[name]=value 495 } 496 } 497 item['eventObject'] = eventHash 498 } 499 500 if(sample.parentSubject) { 501 def parentSubject = sample.parentSubject 502 def subject = [:] 503 parentSubject.giveFields().each { field -> 504 def name = field.name 505 if( name!='fields') { 506 def value = parentSubject.getFieldValue( name ) 507 subject[name]=value 508 } 509 } 510 item['subjectObject'] = subject 511 } 512 513 items.push item 514 } 515 503 516 render items as JSON 504 517 } -
trunk/grails-app/controllers/dbnp/query/AdvancedQueryController.groovy
r1501 r1512 4 4 import org.dbnp.gdt.* 5 5 6 // TODO: Make use of the searchable-plugin possibilities instead of querying the database directly6 // TODO: Make use of the searchable-plugin or Lucene possibilities instead of querying the database directly 7 7 8 8 /** … … 113 113 redirect( action: "index" ); 114 114 return; 115 } 116 117 // Attach all objects to the current hibernate thread, because the 118 // object might be attached to an old thread, since the results are 119 // saved in session 120 s.getResults().each { 121 it.attach(); 115 122 } 116 123 … … 613 620 if( json[ s.entity ] ) { 614 621 json[ s.entity ].each { action -> 615 def url = module.url + "/action/" + action.name 616 url += "?entity=" + s.entity 622 def url = action.url ?: module.url + "/action/" + action.name 623 624 if( url.find( /\?/ ) ) 625 url += "&" 626 else 627 url += "?" 628 629 url += "entity=" + s.entity 617 630 url += "&" + s.filterResults(selectedIds).collect { "tokens=" + it.giveUUID() }.join( "&" ) 618 631 actions << [ -
trunk/grails-app/views/advancedQuery/_criteria.gsp
r1501 r1512 3 3 <g:each in="${criteria}" var="criterion" status="j"> 4 4 <li> 5 <span class="entityfield">${criterion.entityField() }</span>5 <span class="entityfield">${criterion.entityField().toLowerCase()}</span> 6 6 <span class="operator">${criterion.operator}</span> 7 7 <span class="value"> -
trunk/grails-app/views/advancedQuery/_resultbuttons.gsp
r1501 r1512 1 <p class="options"> 2 <g:link class="searchIn" action="searchIn" id="${queryId}">Search within results</g:link><br /> 1 <p class="options multiple"> 2 <g:if test="${search.getNumResults() == 0}"> 3 <a href="#" onClick="return false;" class="searchIn disabled">Search within results</a> 4 </g:if> 5 <g:else> 6 <g:link class="searchIn" action="searchIn" id="${queryId}">Search within results</g:link> 7 </g:else> 8 <br /> 9 3 10 <g:link class="search" action="index">Search again</g:link><br /> 4 11 <g:link class="discard" action="discard" id="${queryId}">Discard results</g:link><br /> 5 12 <g:link class="listPrevious" action="list">Previous searches</g:link> 6 13 </p> 7 <p class="options ">14 <p class="options multiple"> 8 15 <g:each in="${actions}" var="action"> 9 <a class="performAction ${action.name}" href="${action.url}" onClick="performAction( $('form#results'), '${action.name}', '${action.module}' ); return false;">${action.description}</a><br /> 16 <g:if test="${search.getNumResults() == 0}"> 17 <a href="#" onClick="return false;" class="performAction ${action.name} disabled">${action.description}</a> 18 </g:if> 19 <g:else> 20 <a class="performAction ${action.name}" href="${action.url}" onClick="performAction( $('form#results'), '${action.name}', '${action.module}' ); return false;">${action.description}</a> 21 </g:else> 22 <br /> 10 23 </g:each> 11 24 </p> -
trunk/grails-app/views/advancedQuery/index.gsp
r1501 r1512 50 50 </g:if> 51 51 52 <form id="input_criteria"> 52 <div id="searchForm"> 53 <form id="input_criteria"> 53 54 <h2>Add criterium</h2> 54 55 <p class="explanation"> … … 78 79 <option value="<">Lower than</option> 79 80 <option value="<=">Lower than or equals</option> 80 </select> 81 81 </select> 82 82 83 <label for="value">Value</label> 83 84 <input class='text' type="text" name="value" /> 84 85 85 86 <input class="button" type="button" onClick="addCriterium();" value="Add" /> 86 </form> 87 88 <div id="searchForm"> 87 </form> 89 88 <g:form action="search" method="get"> 90 89 <label for="entity">Search for</label><g:select from="${entitiesToSearchFor}" optionKey="key" optionValue="value" name="entity" /><br /> … … 97 96 <input type="submit" value="Run query" class="submitcriteria" disabled="disabled" /> 98 97 </g:form> 98 99 <br clear="all" /> 99 100 </div> 100 101 <p class="options"> -
trunk/grails-app/views/advancedQuery/list.gsp
r1501 r1512 72 72 <td>${search.getNumResults()}</td> 73 73 <td><g:formatDate date="${search.executionDate}" format="HH:mm" /></td> 74 <td><g:link action="show" id="${search.id}"> Show</g:link>75 <td><g:link action="discard" id="${search.id}"> Discard</g:link>74 <td><g:link action="show" id="${search.id}"><img border="0" src="${fam.icon(name: 'application_form_magnify')}" alt="Show" /></g:link> 75 <td><g:link action="discard" id="${search.id}"><img border="0" src="${fam.icon(name: 'basket_remove')}" alt="Discard" /></g:link> 76 76 </tr> 77 77 </g:each> … … 81 81 82 82 <p class="options"> 83 <a href="#" class="combine" onClick="combineResults( $( '#searchform' ) ); return false;">Combine results</a> <br />84 <a href="#" class="searchIn" onClick="searchWithinResults( $( '#searchform' ) ); return false;">Search within results</a> <br />85 <g:link class="search" action="index">Search again</g:link> <br />86 <a href="#" class="discard" onClick="discardResults( $( '#searchform' ) ); return false;">Discard results</a> <br />83 <a href="#" class="combine" onClick="combineResults( $( '#searchform' ) ); return false;">Combine results</a> 84 <a href="#" class="searchIn" onClick="searchWithinResults( $( '#searchform' ) ); return false;">Search within results</a> 85 <g:link class="search" action="index">Search again</g:link> 86 <a href="#" class="discard" onClick="discardResults( $( '#searchform' ) ); return false;">Discard results</a> 87 87 </p> 88 88 <br clear="all" /> 89 89 </body> 90 90 </html> -
trunk/grails-app/views/advancedQuery/results.gsp
r1501 r1512 11 11 <h1>Query results</h1> 12 12 13 <p> 14 Your search for: 15 </p> 16 <g:render template="criteria" model="[criteria: search.getCriteria()]" /> 17 <p> 18 resulted in ${search.getNumResults()} results. 19 </p> 20 13 <div class="searchoptions"> 14 ${search.getNumResults()} <g:if test="${search.getNumResults() == 1}">result</g:if><g:else>results</g:else> found with 15 <g:render template="criteria" model="[criteria: search.getCriteria()]" /> 16 </div> 21 17 <g:if test="${search.getNumResults() > 0}"> 22 18 <% -
trunk/grails-app/views/advancedQuery/sampleresults.gsp
r1501 r1512 11 11 <h1>Query results</h1> 12 12 13 <p> 14 Your search for samples with: 15 </p> 16 <g:render template="criteria" model="[criteria: search.getCriteria()]" /> 17 <p> 18 resulted in ${search.getNumResults()} <g:if test="${search.getNumResults() == 1}">sample</g:if><g:else>samples</g:else>. 19 </p> 20 13 <div class="searchoptions"> 14 ${search.getNumResults()} <g:if test="${search.getNumResults() == 1}">sample</g:if><g:else>samples</g:else> found with 15 <g:render template="criteria" model="[criteria: search.getCriteria()]" /> 16 </div> 21 17 <g:if test="${search.getNumResults() > 0}"> 22 18 <% -
trunk/grails-app/views/advancedQuery/studyresults.gsp
r1501 r1512 11 11 <h1>Query results</h1> 12 12 13 <p> 14 Your search for studies with: 15 </p> 16 <g:render template="criteria" model="[criteria: search.getCriteria()]" /> 17 <p> 18 resulted in ${search.getNumResults()} <g:if test="${search.getNumResults() == 1}">study</g:if><g:else>studies</g:else>. 19 </p> 13 <div class="searchoptions"> 14 ${search.getNumResults()} <g:if test="${search.getNumResults() == 1}">study</g:if><g:else>studies</g:else> found with 15 <g:render template="criteria" model="[criteria: search.getCriteria()]" /> 16 </div> 20 17 <g:if test="${search.getNumResults() > 0}"> 21 18 <% -
trunk/grails-app/views/common/_topnav.gsp
r1439 r1512 48 48 </ul> 49 49 </li> 50 <li><g:link controller="advancedQuery">Query</g:link></li> 50 51 <sec:ifAllGranted roles="ROLE_ADMIN"> 51 52 <li> -
trunk/web-app/css/advancedQuery.css
r1501 r1512 1 1 label { display: inline-block; zoom: 1; *display: inline; width: 110px; margin-top: 10px; } 2 3 #searchForm { position: relative; border: 1px solid #666666; padding: 5px 10px; margin: 10px 0; } 2 4 3 5 #searchForm ul#criteria { margin-left: 110px; padding-left: 0px; margin-top: -19px; list-style-type: none; } … … 5 7 #searchForm ul#criteria li span, 6 8 #searchForm ul#criteria li a { display: inline-block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 5px; } 7 #searchForm ul#criteria li .entityfield { width: 200px; }9 #searchForm ul#criteria li .entityfield { width: 180px; } 8 10 #searchForm ul#criteria li .operator { width: 100px; } 9 11 #searchForm ul#criteria li .value { width: 240px; } … … 15 17 #searchForm ul#criteria li:hover span { text-decoration: line-through; } 16 18 17 #input_criteria { display: block; float: right; width: 260px; border : 1px solid #666; padding: 10px; }19 #input_criteria { display: block; float: right; width: 260px; border-left: 1px solid #666; padding: 10px; position: relative; height: 100%; } 18 20 #input_criteria h2 { margin-top: 2px; margin-bottom: 8px; font-weight: bold; } 19 21 #input_criteria label { width: 80px; margin-top: 8px; } … … 24 26 .ui-menu-item .entity { color: #666; font-style: italic; } 25 27 26 .options { float: left; width: 300px; } 28 .searchoptions { font-size: 10px; margin-bottom: 3px; } 29 .searchoptions label { margin-top: 4px; } 30 .searchoptions ul#criteria { list-style-type: none; margin-left: 0; padding-left: 0; display: inline; } 31 .searchoptions ul#criteria li { margin-left: 0; padding-left: 0; display: inline; } 32 33 /** Options buttons **/ 34 .options { margin-top: 8px; } 35 .options.multiple { float: left; width: 300px; } 36 27 37 .options a { 28 38 font-size: 10px; 29 39 font-weight: bold; 30 margin-left: 3px; 31 margin-right: 3px; 40 margin-right: 10px; 32 41 padding-top: 2px; 33 42 padding-bottom: 2px; … … 35 44 padding-left: 28px; 36 45 } 46 47 #content .options a.disabled { color: #aaa; cursor: default; } 37 48 38 49 .options a.performAction { -
trunk/web-app/css/datatables/demo_table_jui.css
r1507 r1512 75 75 } 76 76 77 .dataTables_wrapper { font-size: 10px; } 77 78 78 79 /*
Note: See TracChangeset
for help on using the changeset viewer.