Skip to content
Snippets Groups Projects
Commit 58c7d584 authored by jakubs's avatar jakubs
Browse files

SSDM-285: treat empty feature values as NaNs if all other values are numerical.

SVN: 31480
parent 53122497
No related branches found
No related tags found
No related merge requests found
...@@ -23,12 +23,13 @@ import java.util.Map; ...@@ -23,12 +23,13 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils;
import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.Geometry; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.Geometry;
import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellLocation; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellLocation;
/** /**
* Stores values of one feature for all wells (and optionally one chosen timepoint and/or * Stores values of one feature for all wells (and optionally one chosen timepoint and/or depth-scan).
* depth-scan).
* *
* @author Tomasz Pylak * @author Tomasz Pylak
*/ */
...@@ -95,7 +96,7 @@ public class FeatureValuesMap implements Serializable ...@@ -95,7 +96,7 @@ public class FeatureValuesMap implements Serializable
{ {
WellLocation wellLocation = entry.getKey(); WellLocation wellLocation = entry.getKey();
String value = entry.getValue(); String value = entry.getValue();
float floatValue = Float.parseFloat(value); float floatValue = parseFloatOrEmptyString(value);
map.put(wellLocation, floatValue); map.put(wellLocation, floatValue);
} catch (NumberFormatException ex) } catch (NumberFormatException ex)
{ {
...@@ -105,9 +106,22 @@ public class FeatureValuesMap implements Serializable ...@@ -105,9 +106,22 @@ public class FeatureValuesMap implements Serializable
return map; return map;
} }
private float parseFloatOrEmptyString(String value)
{
float floatValue;
if (StringUtils.isBlank(value))
{
floatValue = Float.NaN;
} else
{
floatValue = Float.parseFloat(value);
}
return floatValue;
}
/** /**
* Assuming that all values come from the set fixed of vocabulary terms calculates the mapping * Assuming that all values come from the set fixed of vocabulary terms calculates the mapping from vocabulary term into a unique term sequence
* from vocabulary term into a unique term sequence number.<br> * number.<br>
* Should be called when {@link #tryExtractFloatValues} returns null. * Should be called when {@link #tryExtractFloatValues} returns null.
* *
* @return mapping between wells and integer sequence numbers of terms casted to floats * @return mapping between wells and integer sequence numbers of terms casted to floats
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment