Documentation

This commit is contained in:
Francesco
2023-09-30 12:14:08 +02:00
parent fa51f11109
commit a6da47775f
8 changed files with 77 additions and 26 deletions

View File

@@ -6,6 +6,11 @@ import java.util.Set;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* The filter request for faceted search. It is implemented as a
* set of filters that can be stacked on top of each other.
*
*/
public class FacetedSearchRequest implements FilterRequest {
private Set<QueryFilter> filters;

View File

@@ -3,9 +3,23 @@ package tech.ailef.dbadmin.external.dto;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* Describes a request that contains parameters that are used
* to filter results.
*
*/
public interface FilterRequest {
/**
* Converts the request to a MultiValue map that can be
* later converted into a query string
* @return
*/
public MultiValueMap<String, String> computeParams();
/**
* Empty filtering request
* @return an empty map
*/
public static MultiValueMap<String, String> empty() {
return new LinkedMultiValueMap<>();
}

View File

@@ -4,6 +4,10 @@ import java.util.Objects;
import tech.ailef.dbadmin.external.dbmapping.DbField;
/**
* A single filter in a FacetedSearchRequest. This describes a
* single boolean condition on the value of a specific field.
*/
public class QueryFilter {
private DbField field;
@@ -17,14 +21,26 @@ public class QueryFilter {
this.value = value;
}
/**
* Returns the field of the boolean condition
* @return
*/
public DbField getField() {
return field;
}
/**
* Returns the operator of the boolean condition
* @return
*/
public CompareOperator getOp() {
return op;
}
/**
* Returns the value of the boolean condition
* @return
*/
public String getValue() {
return value;
}

View File

@@ -53,30 +53,6 @@ public interface Utils {
}
/**
* Converts a set of query filters applied with the faceted search feature
* to a multi value map
* @param filters
* @return
*/
// public static MultiValueMap<String, String> computeParams(Set<QueryFilter> filters) {
// MultiValueMap<String, String> r = new LinkedMultiValueMap<>();
// if (filters == null)
// return r;
//
// r.put("filter_field", new ArrayList<>());
// r.put("filter_op", new ArrayList<>());
// r.put("filter_value", new ArrayList<>());
//
// for (QueryFilter filter : filters) {
// r.get("filter_field").add(filter.getField().getJavaName());
// r.get("filter_op").add(filter.getOp().toString());
// r.get("filter_value").add(filter.getValue());
// }
//
// return r;
// }
/**
* Converts a multi value map of parameters containing query filters applied
* with the faceted search feature into a set of QueryFilter objects