Search in sources :

Example 1 with BooleanAttribute

use of org.openforis.idm.model.BooleanAttribute in project collect by openforis.

the class ExpressionTest method testTrueThisBoolean.

@Test
public void testTrueThisBoolean() throws InvalidExpressionException {
    BooleanAttribute gpsRealtime = EntityBuilder.addValue(cluster, "gps_realtime", Boolean.TRUE);
    Assert.assertTrue((Boolean) evaluateExpression(cluster, gpsRealtime, "$this"));
}
Also used : BooleanAttribute(org.openforis.idm.model.BooleanAttribute) Test(org.junit.Test)

Example 2 with BooleanAttribute

use of org.openforis.idm.model.BooleanAttribute in project collect by openforis.

the class ExpressionTest method testNotWithThisTrueBoolean.

@Test
public void testNotWithThisTrueBoolean() throws InvalidExpressionException {
    BooleanAttribute gpsRealtime = EntityBuilder.addValue(cluster, "gps_realtime", Boolean.TRUE);
    Assert.assertFalse((Boolean) evaluateExpression(cluster, gpsRealtime, "not($this)"));
}
Also used : BooleanAttribute(org.openforis.idm.model.BooleanAttribute) Test(org.junit.Test)

Example 3 with BooleanAttribute

use of org.openforis.idm.model.BooleanAttribute in project collect by openforis.

the class ExpressionTest method testNotWithThisFalseBoolean.

@Test
public void testNotWithThisFalseBoolean() throws InvalidExpressionException {
    BooleanAttribute gpsRealtime = EntityBuilder.addValue(cluster, "gps_realtime", Boolean.FALSE);
    Assert.assertTrue((Boolean) evaluateExpression(cluster, gpsRealtime, "not($this = true())"));
}
Also used : BooleanAttribute(org.openforis.idm.model.BooleanAttribute) Test(org.junit.Test)

Example 4 with BooleanAttribute

use of org.openforis.idm.model.BooleanAttribute in project collect by openforis.

the class RecordUpdater method applyInitialValue.

private Value applyInitialValue(Attribute<?, ?> attr) {
    Value value = null;
    if (!attr.getDefinition().isCalculated()) {
        if (attr.isEmpty() && isDefaultValueToBeApplied(attr)) {
            value = performDefaultValueApply(attr);
        }
        if (attr instanceof BooleanAttribute && ((BooleanAttributeDefinition) attr.getDefinition()).isAffirmativeOnly() && attr.isEmpty()) {
            BooleanAttribute boolAttr = (BooleanAttribute) attr;
            value = new BooleanValue(false);
            boolAttr.setValue((BooleanValue) value);
            boolAttr.updateSummaryInfo();
        }
    }
    return value;
}
Also used : BooleanAttribute(org.openforis.idm.model.BooleanAttribute) BooleanValue(org.openforis.idm.model.BooleanValue) Value(org.openforis.idm.model.Value) BooleanValue(org.openforis.idm.model.BooleanValue) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition)

Example 5 with BooleanAttribute

use of org.openforis.idm.model.BooleanAttribute in project collect by openforis.

the class ExpressionTest method testFalseThisBoolean.

@Test
public void testFalseThisBoolean() throws InvalidExpressionException {
    BooleanAttribute gpsRealtime = EntityBuilder.addValue(cluster, "gps_realtime", Boolean.FALSE);
    Assert.assertFalse((Boolean) evaluateExpression(cluster, gpsRealtime, "$this"));
}
Also used : BooleanAttribute(org.openforis.idm.model.BooleanAttribute) Test(org.junit.Test)

Aggregations

BooleanAttribute (org.openforis.idm.model.BooleanAttribute)6 Test (org.junit.Test)4 NodePointer (org.apache.commons.jxpath.ri.model.NodePointer)1 DynamicPropertyPointer (org.apache.commons.jxpath.ri.model.dynamic.DynamicPropertyPointer)1 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)1 BooleanValue (org.openforis.idm.model.BooleanValue)1 Value (org.openforis.idm.model.Value)1