use of org.activityinfo.model.form.FormInstance in project activityinfo by bedatadriven.
the class RepeatingSubFormPanel method render.
private void render() {
List<FormInstance> instances = Lists.newArrayList(getInstances());
Collections.sort(instances, new Comparator<FormInstance>() {
@Override
public int compare(FormInstance o1, FormInstance o2) {
return getCreationTime(o1).compareTo(getCreationTime(o2));
}
});
for (FormInstance instance : instances) {
addForm(instance);
}
panel.add(addButton);
}
use of org.activityinfo.model.form.FormInstance in project activityinfo by bedatadriven.
the class RelevanceExpressionTest method text.
@Test
public void text() {
FormInstance instance = new FormInstance(ResourceId.generateSubmissionId(formClass), formClass.getId());
instance.set(TEXT_FIELD_ID, "1");
eval(String.format("{%s}==\"1\"", TEXT_FIELD_ID.asString()), true, instance);
eval(String.format("{%s}!=\"1\"", TEXT_FIELD_ID.asString()), false, instance);
}
use of org.activityinfo.model.form.FormInstance in project activityinfo by bedatadriven.
the class RelevanceExpressionTest method enumType.
@Test
public void enumType() {
FormInstance instance = new FormInstance(ResourceId.generateSubmissionId(formClass), formClass.getId());
instance.set(GENDER_FIELD_ID, enumFieldValue(GENDER_FIELD_ID, "Male"));
eval(String.format("{%s}=={%s}", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), true, instance);
eval(String.format("{%s}!={%s}", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), false, instance);
eval(String.format("{%s}=={%s}", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Female").getId()), false, instance);
eval(String.format("({%s}=={%s})&&({%s}!={%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId(), GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Female").getId()), true, instance);
// contains all
eval(String.format("containsAll({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), true, instance);
eval(String.format("containsAll({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Female").getId()), false, instance);
eval(String.format("containsAll({%s},{%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId(), enumValue(GENDER_FIELD_ID, "Female").getId()), true, instance);
eval(String.format("containsAny({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), true, instance);
eval(String.format("containsAny({%s},{%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId(), enumValue(GENDER_FIELD_ID, "Female").getId()), true, instance);
eval(String.format("containsAny({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Female").getId()), false, instance);
// enum with 2 values
instance.set(GENDER_FIELD_ID, new EnumValue(enumValue(GENDER_FIELD_ID, "Male").getId(), enumValue(GENDER_FIELD_ID, "Female").getId()));
eval(String.format("containsAny({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), true, instance);
eval(String.format("containsAll({%s},{%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId(), enumValue(GENDER_FIELD_ID, "Female").getId()), true, instance);
eval(String.format("notContainsAll({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), true, instance);
eval(String.format("notContainsAll({%s},{%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId(), enumValue(GENDER_FIELD_ID, "Female").getId()), false, instance);
eval(String.format("notContainsAny({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), false, instance);
eval(String.format("notContainsAny({%s},{%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId(), enumValue(GENDER_FIELD_ID, "Female").getId()), false, instance);
instance.set(GENDER_FIELD_ID, new EnumValue());
eval(String.format("{%s}=={%s}", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Female").getId()), false, instance);
eval(String.format("containsAll({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), false, instance);
eval(String.format("containsAll({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Female").getId()), false, instance);
eval(String.format("containsAny({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Male").getId()), false, instance);
eval(String.format("containsAny({%s},{%s})", GENDER_FIELD_ID.asString(), enumValue(GENDER_FIELD_ID, "Female").getId()), false, instance);
}
use of org.activityinfo.model.form.FormInstance in project activityinfo by bedatadriven.
the class SkipExpressionTest method quantity.
@Test
public void quantity() {
FormInstance instance = new FormInstance(ResourceId.generateSubmissionId(formClass), formClass.getId());
instance.set(QUANTITY_FIELD_ID, 3);
eval(String.format("{%s}==3", QUANTITY_FIELD_ID.asString()), true, instance);
eval(String.format("{%s}==3.0", QUANTITY_FIELD_ID.asString()), true, instance);
eval(String.format("{%s}!=3", QUANTITY_FIELD_ID.asString()), false, instance);
}
use of org.activityinfo.model.form.FormInstance in project activityinfo by bedatadriven.
the class SkipExpressionTest method text.
@Test
public void text() {
FormInstance instance = new FormInstance(ResourceId.generateSubmissionId(formClass), formClass.getId());
instance.set(TEXT_FIELD_ID, "1");
eval(String.format("{%s}==\"1\"", TEXT_FIELD_ID.asString()), true, instance);
eval(String.format("{%s}!=\"1\"", TEXT_FIELD_ID.asString()), false, instance);
}
Aggregations