Skip to content

Commit

Permalink
Fix bug where missing operation is not validated
Browse files Browse the repository at this point in the history
  • Loading branch information
Idane committed Dec 21, 2020
1 parent 86a8dd9 commit ae52237
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public void validateAndFillFilterFieldMetadata(List<FilterField> filterFields, E
if(filterField.isValidated()) {
continue;
}
if(filterField.getOperation() == null) {
throw new IllegalStateException("A FilterField must have an operation");
}

boolean isJunction = filterField.getOperation() == FilterFieldOperation.And || filterField.getOperation() == FilterFieldOperation.Or || filterField.getOperation() == FilterFieldOperation.Not || filterField.getOperation() == FilterFieldOperation.RawJunction;
if(isJunction) {
if(filterField.getChildren() != null && !filterField.getChildren().isEmpty()) {
Expand Down Expand Up @@ -199,7 +203,7 @@ public void validateAndFillFilterFieldMetadata(List<FilterField> filterFields, E
}
}
}
filterField.setValidated(true);
filterField.validate();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class FilterField implements Serializable {

private List<FilterField> children;

private boolean validated = false;
private transient boolean validated = false;

public FilterField() {
}
Expand Down Expand Up @@ -98,10 +98,6 @@ public boolean isValidated() {
return validated;
}

public void setValidated(boolean validated) {
this.validated = validated;
}

public Object[] getValues() {
if(values != null) {
return Arrays.stream(values).map(x -> castToType(x)).collect(Collectors.toList()).toArray();
Expand Down Expand Up @@ -138,6 +134,10 @@ public void setChildren(List<FilterField> children) {
this.children = children;
}

public void validate() {
this.validated = true;
}

@Override
public String toString() {
return "FilterField [" +
Expand Down

0 comments on commit ae52237

Please sign in to comment.