Opened 16 years ago

Closed 16 years ago

#1047 closed defect (fixed)

Type.BOOLEAN.parseString() doesn't convert strings as expected

Reported by: Johan Vallon-Christersson Owned by: Nicklas Nordborg
Priority: critical Milestone: BASE 2.7.1
Component: core Version:
Keywords: Cc:

Description

When importing Raw data (type = Agilent), data from the file is mapped to property 'Normalization' (see below, lines from raw-data-types.xml, revision 4027). In the data file the mapped column contains 1's and 0's. In BASE, however, all imported values are set to FALSE.

1156 	    <property
1157 	      name="IsNormalization"
1158 	      title="Normalization"
1159 	      description="A boolean flag which indicates if a feature is used to measure dye bias. A 1 incidates the value was used."
1160 	      column="is_normalization"
1161 	      type="boolean"
1162 	      averagemethod="none"


The same erroneous behavior is observed for other boolean raw data properties.

Change History (6)

comment:1 by Nicklas Nordborg, 16 years ago

Component: corepluginscore
Milestone: BASE 2.7.1
Priority: blockercritical

It seems like the current implementation which falls back to Hibernate only recognize the string "true" as a true value. All other values are considered false.

The workaround is to change all 1's to "true".

To fix this the Type.BOOLEAN.parseString() method needs to be added to override the default behavior that calls Hibernate functions for this. We should instead call Values.getBoolean() which converts null, "", "no" and "false" to false and all other values to "true".

NOTE! This change may affect backwards compatibility for applications using the Type.BOOLEAN.parseString() method and should be listed in the documentation.

comment:2 by Johan Vallon-Christersson, 16 years ago

Would the fix you describe convert "0" to "false"?

comment:3 by Nicklas Nordborg, 16 years ago

Yes, "0" is also converted to "false". I missed it in the list. Here is the complete list again:

  • null, "", "0", "no", "false" is converted to false
  • All other values are converted to true

comment:4 by Nicklas Nordborg, 16 years ago

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:5 by Nicklas Nordborg, 16 years ago

Summary: For Raw data properties (type=boolean) all imported values (1's and 0's) are set to FALSE.Type.BOOLEAN.parseString() doesn't convert strings as expected

I have to change the list again. 'null' shouldn't be converted to false, it should still be 'null'. I also discovered that only lower-case strings are converted correctly, but this will also be fixed. See #1053.

comment:6 by Nicklas Nordborg, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [4329]) Fixes #1047: Type.BOOLEAN.parseString() doesn't convert strings as expected

Note: See TracTickets for help on using tickets.