Skip to content
Snippets Groups Projects
Commit c7b2ab0e authored by Daniel Hornung's avatar Daniel Hornung
Browse files

FIX: POV.java: Fixed unit-induced value conversion.

parent 268b0792
No related branches found
No related tags found
2 merge requests!66REL: prepare release 0.8.0,!62Fix large integer queries
Pipeline #24678 passed
...@@ -63,6 +63,7 @@ public class POV implements EntityFilterInterface { ...@@ -63,6 +63,7 @@ public class POV implements EntityFilterInterface {
private DateTimeInterface vDatetime; private DateTimeInterface vDatetime;
private final String aggregate; private final String aggregate;
private String targetSet = null; private String targetSet = null;
private String unitStr = null;
private Unit unit = null; private Unit unit = null;
private Long stdUnitSig = null; private Long stdUnitSig = null;
private Double vDoubleConvertedToStdUnit = null; private Double vDoubleConvertedToStdUnit = null;
...@@ -112,7 +113,6 @@ public class POV implements EntityFilterInterface { ...@@ -112,7 +113,6 @@ public class POV implements EntityFilterInterface {
// parse value to int/double/datetime // parse value to int/double/datetime
if (this.value != null) { if (this.value != null) {
String unitStr = null;
// try and parse as integer // try and parse as integer
try { try {
...@@ -122,7 +122,7 @@ public class POV implements EntityFilterInterface { ...@@ -122,7 +122,7 @@ public class POV implements EntityFilterInterface {
throw new NumberFormatException(); throw new NumberFormatException();
} }
final String vIntStr = m.group(1); final String vIntStr = m.group(1);
unitStr = m.group(2); this.unitStr = m.group(2);
this.vInt = Integer.parseInt(vIntStr); this.vInt = Integer.parseInt(vIntStr);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
this.vInt = null; this.vInt = null;
...@@ -138,7 +138,7 @@ public class POV implements EntityFilterInterface { ...@@ -138,7 +138,7 @@ public class POV implements EntityFilterInterface {
throw new NumberFormatException(); throw new NumberFormatException();
} }
final String vDoubleStr = m.group(1); final String vDoubleStr = m.group(1);
unitStr = m.group(2); this.unitStr = m.group(2);
this.vDouble = Double.parseDouble(vDoubleStr); this.vDouble = Double.parseDouble(vDoubleStr);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
...@@ -146,16 +146,17 @@ public class POV implements EntityFilterInterface { ...@@ -146,16 +146,17 @@ public class POV implements EntityFilterInterface {
} }
} }
if (this.vDouble != null && unitStr != null && unitStr.length() > 0) { if ((this.vDouble != null || this.vInt != null)
&& this.unitStr != null
&& this.unitStr.length() > 0) {
try { try {
this.unit = getUnit(unitStr); this.unit = getUnit(this.unitStr);
} catch (final ParserException e) { } catch (final ParserException e) {
e.printStackTrace(); e.printStackTrace();
throw new UnsupportedOperationException("Could not parse the unit."); throw new UnsupportedOperationException("Could not parse the unit.");
} }
this.stdUnitSig = this.unit.normalize().getSignature(); this.stdUnitSig = this.unit.normalize().getSignature();
this.vDoubleConvertedToStdUnit = this.unit.convert(this.vDouble);
} }
// try and parse as datetime // try and parse as datetime
try { try {
...@@ -285,6 +286,11 @@ public class POV implements EntityFilterInterface { ...@@ -285,6 +286,11 @@ public class POV implements EntityFilterInterface {
} }
callPOV.setDouble(8, this.vDouble); callPOV.setDouble(8, this.vDouble);
} }
// finally: do unit conversion
if (this.unitStr != null && this.unitStr.length() > 0) {
this.vDoubleConvertedToStdUnit =
this.unit.convert(this.vDouble != null ? this.vDouble : vDoubleSubst);
}
} else { } else {
callPOV.setNull(7, INTEGER); callPOV.setNull(7, INTEGER);
callPOV.setNull(8, DOUBLE); callPOV.setNull(8, DOUBLE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment