Changeset 2010
- Timestamp:
- Sep 8, 2011, 4:13:40 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/visualization/VisualizeController.groovy
r2009 r2010 203 203 def fields = [] 204 204 def source = "GSCF" 205 206 def domainObjects = [207 "subjects": Subject,208 "events": Event,209 "samples": Sample,210 "samplingEvents": SamplingEvent,211 "assays": Assay,212 "studies": Study ]213 214 def templateObjects = [215 "subjects": study?.samples?.parentSubject,216 "events": study?.samples?.parentEventGroup?.events,217 "samples": study?.samples,218 "samplingEvents": study?.samples?.parentEventGroup?.samplingEvents,219 "assays": study?.assays,220 "studies": study ]221 205 222 206 if( type == "domainfields" ) 223 collection = domainObject s[ category ]?.giveDomainFields();207 collection = domainObjectCallback( category )?.giveDomainFields(); 224 208 else 225 collection = templateObject s[ category ]?.template?.fields209 collection = templateObjectCallback( category, study )?.template?.fields 226 210 227 211 collection?.unique() … … 326 310 def studyIds, rowIds, columnIds, visualizationType; 327 311 328 def inputData = params.get( 'data' ); 329 try{ 330 def input_object = JSON.parse(inputData) 331 332 studyIds = input_object.get('studies')*.id 333 rowIds = input_object.get('rows')*.id 334 columnIds = input_object.get('columns')*.id 335 visualizationType = "barchart" 336 } catch(Exception e) { 337 /* TODO: Find a way to handle these kinds of exceptions without breaking the user interface. 338 Doing things in this way results in the user interface getting a 400. 339 returnError(400, "An error occured while retrieving the user input") 340 infoMessage = "An error occured while retrieving the user input." 341 log.error("VisualizationController: parseGetDataParams: "+e) 342 return sendInfoMessage() 343 */ 344 } 312 studyIds = params.list( 'study' ); 313 rowIds = params.list( 'rows' ); 314 columnIds = params.list( 'columns' ); 315 visualizationType = params.get( 'types') 345 316 346 317 return [ "studyIds" : studyIds, "rowIds": rowIds, "columnIds": columnIds, "visualizationType": visualizationType ]; … … 618 589 619 590 /** 591 * Returns the domain object that should be used with the given entity string 592 * 593 * For example: 594 * What object should be consulted if the user asks for "studies" 595 * Response: Study 596 * @return Domain object that should be used with the given entity string 597 */ 598 protected def domainObjectCallback( String entity ) { 599 switch( entity ) { 600 case "Study": 601 case "studies": 602 return Study 603 case "Subject": 604 case "subjects": 605 return Subject 606 case "Sample": 607 case "samples": 608 return Sample 609 case "Event": 610 case "events": 611 return Event 612 case "SamplingEvent": 613 case "samplingEvents": 614 return SamplingEvent 615 case "Assay": 616 case "assays": 617 return Assay 618 } 619 } 620 621 /** 622 * Returns the objects within the given study that should be used with the given entity string 623 * 624 * For example: 625 * What object should be consulted if the user asks for "samples" 626 * Response: study.samples 627 * @return List of domain objects that should be used with the given entity string 628 */ 629 protected def templateObjectCallback( String entity, Study study ) { 630 switch( entity ) { 631 case "Study": 632 case "studies": 633 return study 634 case "Subject": 635 case "subjects": 636 return study?.samples?.parentSubject 637 case "Sample": 638 case "samples": 639 return study?.samples 640 case "Event": 641 case "events": 642 return study?.samples?.parentEventGroup?.events 643 case "SamplingEvent": 644 case "samplingEvents": 645 return study?.samples?.parentEventGroup?.samplingEvents 646 case "Assay": 647 case "assays": 648 return study?.assays 649 } 650 } 651 652 /** 620 653 * Computes the mean value and Standard Error of the mean (SEM) for the given values 621 654 * @param values List of values to compute the mean and SEM for. Strings and null … … 799 832 // Domainfield or memberclass 800 833 try{ 801 switch( parsedField.type ) { 802 case "Study": 803 case "studies": 804 return determineCategoryFromClass(Study.class.getDeclaredField(parsedField.name).type) 805 break 806 case "Subject": 807 case "subjects": 808 return determineCategoryFromClass(Subject.class.getDeclaredField(parsedField.name).type) 809 break 810 case "Sample": 811 case "samples": 812 return determineCategoryFromClass(Sample.class.getDeclaredField(parsedField.name).type) 813 break 814 case "Event": 815 case "events": 816 return determineCategoryFromClass(Event.class.getDeclaredField(parsedField.name).type) 817 break 818 case "SamplingEvent": 819 case "samplingEvents": 820 return determineCategoryFromClass(SamplingEvent.class.getDeclaredField(parsedField.name).type) 821 break 822 case "Assay": 823 case "assays": 824 return determineCategoryFromClass(Assay.class.getDeclaredField(parsedField.name).type) 825 break 826 } 834 return determineCategoryFromClass(domainObjectCallback( parsedField.type )?.fields[parsedField.name].type) 827 835 } catch(Exception e){ 828 836 log.error("VisualizationController: determineFieldType: "+e) -
trunk/grails-app/views/visualize/index.gsp
r2004 r2010 66 66 <div class="menu_arrow"> </div> 67 67 <div class="menu_item" id="menu_go"> 68 < div id="button_visualize" onClick="visualize();">Visualize</div>68 <button id="button_visualize" onClick="visualize(); return false;" >Visualize</button> 69 69 <input type="checkbox" name="autovis" id="autovis" CHECKED/><span style="font-size: small;">auto</span></div> 70 70 <div class="menu_spacer"> </div> -
trunk/web-app/css/visualization.css
r2003 r2010 146 146 147 147 #button_visualize { 148 border-style: outset;149 border-width: 2px;150 border-color: gray;151 148 margin: 4px; 152 149 padding: 10px; -
trunk/web-app/js/visualization.js
r2008 r2010 17 17 ); 18 18 $("#menu_go").unbind('mouseover').unbind('mouseout'); 19 20 $('#button_visualize').mousedown(function() {21 $('#button_visualize').css("border-style", 'inset');22 });23 $('#button_visualize').mouseup(function() {24 $('#button_visualize').css("border-style", 'outset');25 });26 27 19 }); 28 20 … … 48 40 } 49 41 42 clearStep(".menu_item"); 43 50 44 // Add all fields to the lists 51 var returnData = data.returnData; 52 $.each( returnData, function( idx, field ) { 53 $( '#rows, #columns' ).append( $( "<option>" ).val( field.id ).text( field.name ) ); 54 }); 55 56 clearStep(".menu_item"); 57 $( "#menu_study" ).find("div.menu_item_info").html("<br />"+$( '#study option:selected' ).text()); 58 $( "#menu_study" ).addClass("menu_item_done"); 59 $( "#menu_row, #menu_column" ).addClass("menu_item_fill"); 45 if( data.returnData ) { 46 var returnData = data.returnData; 47 $.each( returnData, function( idx, field ) { 48 $( '#rows, #columns' ).append( $( "<option>" ).val( field.id ).text( field.name ) ); 49 }); 50 51 $( "#menu_study" ).find("div.menu_item_info").html("<br />"+$( '#study option:selected' ).text()); 52 $( "#menu_study" ).addClass("menu_item_done"); 53 $( "#menu_row, #menu_column" ).addClass("menu_item_fill"); 54 } 60 55 } 61 56 },'menu_study'); … … 280 275 */ 281 276 function gatherData( type ) { 282 var data = {}; 283 284 // different types of request require different data arrays 285 // However, some data is required for all types. For that reason, 286 // the fallthrough option in the switch statement is used. 287 switch( type ) { 288 case "getData": 289 var typeElement = $( '#type' ); 290 data[ "type" ] = { "id": typeElement.val() }; 291 case "getVisualizationTypes": 292 var rowsElement = $( '#rows' ); 293 var columnsElement = $( '#columns' ); 294 data[ "rows" ] = [ 295 { "id": rowsElement.val() } 296 ]; 297 data[ "columns" ] = [ 298 { "id": columnsElement.val() } 299 ]; 300 case "getFields": 301 var studyElement = $( '#study' ); 302 data[ "studies" ] = [ 303 { "id": studyElement.val() } 304 ]; 305 306 case "getStudies": 307 } 308 309 return data; 277 // For simplicity, we send the whole form to the server. In the 278 // future this might be enhanced, based on the given type 279 return $( 'form#visualizationForm' ).serialize(); 310 280 } 311 281 … … 347 317 $.ajax($.extend({ 348 318 url: visualizationUrls[ action ], 349 data: "data=" + JSON.stringify( data ),319 data: data, 350 320 dataType: "json", 351 321 }, ajaxParameters ) );
Note: See TracChangeset
for help on using the changeset viewer.