Changeset 2126


Ignore:
Timestamp:
Dec 5, 2011, 4:50:49 PM (12 years ago)
Author:
robert@…
Message:

Solved ticket #519 with null values being retrieved from the modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/visualization/VisualizeController.groovy

    r2124 r2126  
    527527                        def sampleToken = sample.sampleUUID;
    528528                        def index = sampleTokens.findIndexOf { it == sampleToken }
    529 
    530                         if( index > -1 ) {
     529                                               
     530                                                // Store the measurement value if found and if it is not JSONObject$Null
     531                                                // See http://grails.1312388.n4.nabble.com/The-groovy-truth-of-JSONObject-Null-td3661040.html
     532                                                // for this comparison
     533                        if( index > -1  && !measurements[ index ].equals( null ) ) {
    531534                            data << measurements[ index ];
    532535                        } else {
     
    567570         */
    568571        def aggregateData( data, fieldInfo, aggregation ) {
    569                 // If no aggregation is requested, we just return the original object
    570                 if( aggregation == "none" )
    571                         return data
     572                // If no aggregation is requested, we just return the original object (but filtering out null values)
     573                if( aggregation == "none" ) {
     574                        def filteredData = [:];
     575                       
     576                        // Create a copy of the data object
     577                        data.each {
     578                                filteredData[ it.key ] = it.value;
     579                        }
     580                       
     581                        // Loop through all values and return all null-values (and the same indices on other elements
     582                        fieldInfo.keySet().each { fieldName ->
     583                                // If values are found, do filtering. If not, skip this one
     584                                if( fieldInfo[ fieldName ] != null ) {
     585                                        // Find all non-null values in this list
     586                                        def indices = filteredData[ fieldName ].findIndexValues { it != null };
     587                                       
     588                                        // Remove the non-null values from each data object
     589                                        filteredData.each { key, value ->
     590                                                if( value && value instanceof Collection )
     591                                                        filteredData[ key ] = value[ indices ];
     592                                        }
     593                                }
     594                        }
     595                         
     596                        return filteredData
     597                }
    572598               
    573599                // Determine the categorical fields
Note: See TracChangeset for help on using the changeset viewer.