Commit f10c959f authored by R.W.Majeed's avatar R.W.Majeed
Browse files

fixed NPE when element concept/value is missing

parent 8dc957c4
...@@ -77,7 +77,6 @@ public class Concept{ ...@@ -77,7 +77,6 @@ public class Concept{
String concept = this.id; String concept = this.id;
MapFeedback mf = new MapFeedback(); MapFeedback mf = new MapFeedback();
Object value = this.value.valueOf(map, row, mf);
if( mf.isActionDrop() ){ if( mf.isActionDrop() ){
return null; // ignore this fact return null; // ignore this fact
} }
...@@ -94,23 +93,28 @@ public class Concept{ ...@@ -94,23 +93,28 @@ public class Concept{
unit = this.unit.valueOf(map, row); unit = this.unit.valueOf(map, row);
} }
// TODO: use type of column this.value to infer value type // TODO: use type of column this.value to infer value type
if( value == null ){ Object val = null;
if( this.value != null ){
// Objects.requireNonNull(this.value, "No value for concept: "+id);
val = this.value.valueOf(map, row, mf);
}
if( val == null ){
// no value // no value
o.setValue(null); o.setValue(null);
}else if( value instanceof String ){ }else if( val instanceof String ){
// string // string
o.setValue(new StringValue((String)value)); o.setValue(new StringValue((String)val));
// TODO: set unit // TODO: set unit
}else if( value instanceof BigDecimal ){ }else if( val instanceof BigDecimal ){
// numeric // numeric
NumericValue v = new NumericValue((BigDecimal)value,unit); NumericValue v = new NumericValue((BigDecimal)val,unit);
o.setValue(v); o.setValue(v);
}else if( value instanceof Long ){ }else if( val instanceof Long ){
// numeric // numeric
NumericValue v = new NumericValue((Long)value,unit); NumericValue v = new NumericValue((Long)val,unit);
o.setValue(v); o.setValue(v);
}else{ }else{
throw new ParseException("Unsupported value type for concept id "+this.id+": "+value.getClass()); throw new ParseException("Unsupported value type for concept id "+this.id+": "+val.getClass());
} }
// TODO: modifiers // TODO: modifiers
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment