use of org.openforis.idm.model.RealRange in project collect by openforis.
the class RealRangeValidator method evaluate.
@Override
public ValidationResultFlag evaluate(RealRangeAttribute node) {
RealRange range = node.getValue();
if (range != null) {
Double from = range.getFrom();
Double to = range.getTo();
if (!(from == null || to == null)) {
boolean valid = to >= from;
return ValidationResultFlag.valueOf(valid);
}
}
return ValidationResultFlag.OK;
}
use of org.openforis.idm.model.RealRange in project collect by openforis.
the class JSONValueParser method parseRealRange.
public RealRange parseRealRange(RangeAttributeDefinition attrDef, String value) {
Map<String, Object> map = parseJSONToMap(value);
if (map == null) {
return null;
}
Double from = getDouble(map, RealRange.FROM_FIELD);
Double to = getDouble(map, RealRange.TO_FIELD);
if (to == null) {
to = from;
}
Integer unitId = getInteger(map, RealRange.UNIT_ID_FIELD);
Unit unit = attrDef.getActualUnit(unitId);
return new RealRange(from, to, unit);
}
use of org.openforis.idm.model.RealRange in project collect by openforis.
the class ComparisonExpressionTest method testGtLtWrongOnRange.
@Test
public void testGtLtWrongOnRange() throws InvalidExpressionException {
monthlyConsumption.setValue(new RealRange(0.0, 15.0));
monthlyConsumption.updateSummaryInfo();
Assert.assertFalse(evaluateExpression(energySource, "monthly_consumption > 10 and monthly_consumption < 14.5"));
}
use of org.openforis.idm.model.RealRange in project collect by openforis.
the class ComparisonExpressionTest method testGtLtOnRange.
@Test
public void testGtLtOnRange() throws InvalidExpressionException {
monthlyConsumption.setValue(new RealRange(11.0, 13.0));
monthlyConsumption.updateSummaryInfo();
Assert.assertTrue(evaluateExpression(energySource, "monthly_consumption > 10 and monthly_consumption < 14.5"));
}
use of org.openforis.idm.model.RealRange in project collect by openforis.
the class ComparisonExpressionTest method testGteqLtOnRange.
@Test
public void testGteqLtOnRange() throws InvalidExpressionException {
monthlyConsumption.setValue(new RealRange(10.1, 13.0));
monthlyConsumption.updateSummaryInfo();
Assert.assertTrue(evaluateExpression(energySource, "monthly_consumption >= 10.1 and monthly_consumption < 14.5"));
}
Aggregations