Opened 14 years ago

Closed 14 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 Changed 14 years ago by Nicklas Nordborg

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 Changed 14 years ago by Johan Vallon-Christersson

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

comment:3 Changed 14 years ago by Nicklas Nordborg

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 Changed 14 years ago by Nicklas Nordborg

Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:5 Changed 14 years ago by Nicklas Nordborg

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 Changed 14 years ago by Nicklas Nordborg

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.