From de1c604a6fefe27cdd00d20c59f5759cee1f83cf Mon Sep 17 00:00:00 2001 From: Guille Date: Fri, 11 Jan 2019 08:49:35 +0100 Subject: [PATCH] Detect temporal fields of forms uploaded before upgrading to v2.0 - They can lack their FormElementModel - They can be metadata fields - They can have a FormElementModel without child elements --- .../query/submission/QueryByUIFilterGroup.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opendatakit/aggregate/query/submission/QueryByUIFilterGroup.java b/src/main/java/org/opendatakit/aggregate/query/submission/QueryByUIFilterGroup.java index 02f8727106..288d9e0d36 100644 --- a/src/main/java/org/opendatakit/aggregate/query/submission/QueryByUIFilterGroup.java +++ b/src/main/java/org/opendatakit/aggregate/query/submission/QueryByUIFilterGroup.java @@ -148,15 +148,13 @@ public QueryByUIFilterGroup(IForm form, FilterGroup filterGroup, CompletionFlag super.addFilter(fem, op, compareValue); break; case JRDATETIME: - if (fem.getFormDataModel() == null && fem.getElementName().contains("meta-")) + case JRDATE: + case JRTIME: + if (isLegacyTemporalField(fem)) super.addFilter(fem, op, compareValue); - else if (fem.getFormDataModel() != null) - super.addFilterChildren(fem, column.getChildColumnCode(), op, compareValue); else - throw new IllegalArgumentException("Unrecognized dateTime field"); + super.addFilterChildren(fem, column.getChildColumnCode(), op, compareValue); break; - case JRDATE: - case JRTIME: case GEOPOINT: super.addFilterChildren(fem, column.getChildColumnCode(), op, compareValue); break; @@ -166,6 +164,11 @@ else if (fem.getFormDataModel() != null) } + private boolean isLegacyTemporalField(FormElementModel fem) { + return fem.getFormDataModel() == null && fem.getElementName().contains("meta-") + || fem.getFormDataModel().getChildren().isEmpty(); + } + public Object getCompareValue(FormElementModel fem, String value) { switch (fem.getElementType()) { case BOOLEAN: