diff --git a/src/main/java/io/swagger/api/core/ListsApi.java b/src/main/java/io/swagger/api/core/ListsApi.java
index b4c95e98..398c7cb5 100644
--- a/src/main/java/io/swagger/api/core/ListsApi.java
+++ b/src/main/java/io/swagger/api/core/ListsApi.java
@@ -5,13 +5,10 @@
*/
package io.swagger.api.core;
+import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.model.BrAPIResponse;
import io.swagger.model.Model202AcceptedSearchResponse;
-import io.swagger.model.core.ListNewRequest;
-import io.swagger.model.core.ListResponse;
-import io.swagger.model.core.ListSearchRequest;
-import io.swagger.model.core.ListsListResponse;
-import io.swagger.model.core.ListsSingleResponse;
+import io.swagger.model.core.*;
import io.swagger.annotations.*;
import org.brapi.test.BrAPITestServer.exceptions.BrAPIServerException;
@@ -166,4 +163,15 @@ ResponseEntity extends BrAPIResponse> searchListsSearchResultsDbIdGet(
@ApiParam(value = "pageSize") @Valid @RequestParam(value = "pageSize", required = false) Integer pageSize,
@ApiParam(value = "HTTP HEADER - Token used for Authorization Bearer {token_string} ") @RequestHeader(value = "Authorization", required = false) String authorization) throws BrAPIServerException;
+ @ApiOperation(value = "Submit a search request for List Items", nickname = "searchListByItemRequest", notes = "Advanced searching for the list item resource. See Search Services for additional implementation details.", response = ListItemsListResponse.class, authorizations = {
+ @Authorization(value = "AuthorizationToken") }, tags = { "Lists", })
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ListItemsListResponse.class),
+ @ApiResponse(code = 400, message = "Bad Request", response = String.class),
+ @ApiResponse(code = 401, message = "Unauthorized", response = String.class),
+ @ApiResponse(code = 403, message = "Forbidden", response = String.class) })
+ @RequestMapping(value = "/search/lists/{listDbId}/items", produces = { "application/json" }, consumes = {
+ "application/json" }, method = RequestMethod.POST)
+ ResponseEntity extends BrAPIResponse> searchListByItemRequest(@ApiParam(value = "") @Valid @RequestBody JsonNode body,
+ @ApiParam(value = "Permanent unique identifier of list to perform search on", required = true) @PathVariable("listDbId") String listDbId,
+ @ApiParam(value = "HTTP HEADER - Token used for Authorization Bearer {token_string} ") @RequestHeader(value = "Authorization", required = false) String authorization) throws BrAPIServerException;
}
diff --git a/src/main/java/io/swagger/api/germ/GermplasmApi.java b/src/main/java/io/swagger/api/germ/GermplasmApi.java
index 1990ba83..a7f9d959 100644
--- a/src/main/java/io/swagger/api/germ/GermplasmApi.java
+++ b/src/main/java/io/swagger/api/germ/GermplasmApi.java
@@ -143,6 +143,7 @@ ResponseEntity germplasmGet(
@ApiParam(value = "progenyDbId") @Valid @RequestParam(value = "progenyDbId", required = false) String progenyDbId,
@ApiParam(value = "commonCropName") @Valid @RequestParam(value = "commonCropName", required = false) String commonCropName,
@ApiParam(value = "programDbId") @Valid @RequestParam(value = "programDbId", required = false) String programDbId,
+ @ApiParam(value = "programName") @Valid @RequestParam(value = "programName", required = false) String programName,
@ApiParam(value = "externalReferenceID") @Valid @RequestParam(value = "externalReferenceID", required = false) String externalReferenceID,
@ApiParam(value = "externalReferenceId") @Valid @RequestParam(value = "externalReferenceId", required = false) String externalReferenceId,
@ApiParam(value = "externalReferenceSource") @Valid @RequestParam(value = "externalReferenceSource", required = false) String externalReferenceSource,
diff --git a/src/main/java/io/swagger/model/FilterBy.java b/src/main/java/io/swagger/model/FilterBy.java
new file mode 100644
index 00000000..acbc03e7
--- /dev/null
+++ b/src/main/java/io/swagger/model/FilterBy.java
@@ -0,0 +1,24 @@
+package io.swagger.model;
+
+public class FilterBy {
+
+ private String filterOn;
+ private String value;
+
+ public String getFilterOn() {
+ return filterOn;
+ }
+
+ public void setFilterOn(String filterOn) {
+ this.filterOn = filterOn;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
diff --git a/src/main/java/io/swagger/model/SearchRequest.java b/src/main/java/io/swagger/model/SearchRequest.java
index 8ad217c4..7999746f 100644
--- a/src/main/java/io/swagger/model/SearchRequest.java
+++ b/src/main/java/io/swagger/model/SearchRequest.java
@@ -2,9 +2,15 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.model.sort.SortBy;
+import org.brapi.test.BrAPITestServer.exceptions.BrAPIServerException;
+import org.brapi.test.BrAPITestServer.model.dto.SortAndFilterEntityColumnInfo;
+import org.brapi.test.BrAPITestServer.model.dto.EntityType;
+import org.springframework.http.HttpStatus;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
public abstract class SearchRequest {
@JsonIgnore
@@ -25,6 +31,20 @@ public abstract class SearchRequest {
@JsonProperty("externalReferenceSources")
protected List externalReferenceSources = null;
+ @JsonProperty("filterBy")
+ protected List filterBy = null;
+
+ @JsonProperty("sortBy")
+ protected List sortBy = null;
+
+ @JsonIgnore
+ protected Map sortFilterEntityColumnNamesByRequestName = null;
+
+ @JsonIgnore
+ public List getExternalReferenceIds() {
+ return externalReferenceIds;
+ }
+
final public SearchRequest page(Integer page) {
this.page = page;
return this;
@@ -119,4 +139,76 @@ public void addExternalReferenceItem(String externalReferenceId, String external
}
}
+
+ public List getFilterBy() {
+ return filterBy;
+ }
+
+ public void setFilterBy(List filterBy) throws BrAPIServerException {
+
+ if (filterBy == null || filterBy.isEmpty()) {
+ return;
+ }
+
+ Map allowedSortFilterNames = getEntityColInfoBySubmittedNameMap();
+
+ for (FilterBy filterByItem : filterBy) {
+
+ if (filterByItem.getFilterOn() == null || filterByItem.getFilterOn().isEmpty()) {
+ throw new BrAPIServerException(HttpStatus.BAD_REQUEST, "filterOn attribute not provided in element of filterBy list.");
+ }
+
+ if (filterByItem.getValue() == null || filterByItem.getValue().isEmpty()) {
+ throw new BrAPIServerException(HttpStatus.BAD_REQUEST, "value attribute not provided in element of filterBy list.");
+ }
+
+ SortAndFilterEntityColumnInfo sortAndFilterEntityColumnInfo = allowedSortFilterNames.get(filterByItem.getFilterOn());
+
+ if (sortAndFilterEntityColumnInfo == null) {
+ throw new BrAPIServerException(HttpStatus.BAD_REQUEST,
+ String.format("Supplied filterColumn [%s] not available in allowed names [%s]", filterByItem.getFilterOn(), allowedSortFilterNames.keySet())
+ );
+ }
+
+ if (sortAndFilterEntityColumnInfo.getEntityType() == EntityType.BOOLEAN) {
+ // TODO: Add support for this when it becomes relevant for BI or when there is time.
+ throw new BrAPIServerException(HttpStatus.BAD_REQUEST, String.format("Filtering not implemented for column name [%s] with associated data type [%s]", sortAndFilterEntityColumnInfo.getEntityColumnName(), EntityType.BOOLEAN));
+ }
+ }
+ this.filterBy = filterBy;
+ }
+
+ public List getSortByElements() {
+ return sortBy;
+ }
+
+ public void setSortBy(List sortBy) throws BrAPIServerException {
+
+ if (sortBy == null || sortBy.isEmpty()) {
+ return;
+ }
+
+ Map allowedSortFilterNames = getEntityColInfoBySubmittedNameMap();
+
+ for (SortBy sortByItem : sortBy) {
+ if (sortByItem.getSortedOn() == null || sortByItem.getSortedOn().isEmpty()) {
+ throw new BrAPIServerException(HttpStatus.BAD_REQUEST, "sortedOn attribute not provided in element of sortBy list");
+ }
+
+ SortAndFilterEntityColumnInfo sortColumnEntityNameAndType = getEntityColInfoBySubmittedNameMap().get(sortByItem.getSortedOn());
+
+ if (sortColumnEntityNameAndType == null) {
+ throw new BrAPIServerException(HttpStatus.BAD_REQUEST,
+ String.format("Supplied sortColumn [%s] not available in allowed names [%s]", sortByItem.getSortedOn(), allowedSortFilterNames.keySet())
+ );
+ }
+ }
+
+ this.sortBy = sortBy;
+ }
+
+ @JsonIgnore
+ public Map getEntityColInfoBySubmittedNameMap() throws BrAPIServerException {
+ throw new BrAPIServerException(HttpStatus.BAD_REQUEST, String.format("Sort/Filtering not implemented for %s", this.getClass().getSimpleName()));
+ }
}
diff --git a/src/main/java/io/swagger/model/core/GermplasmListSearchRequest.java b/src/main/java/io/swagger/model/core/GermplasmListSearchRequest.java
new file mode 100644
index 00000000..5768d82b
--- /dev/null
+++ b/src/main/java/io/swagger/model/core/GermplasmListSearchRequest.java
@@ -0,0 +1,33 @@
+package io.swagger.model.core;
+
+import io.swagger.model.germ.GermplasmSearchRequest;
+import org.brapi.test.BrAPITestServer.model.dto.SortAndFilterEntityColumnInfo;
+import org.brapi.test.BrAPITestServer.model.dto.EntityType;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class GermplasmListSearchRequest extends GermplasmSearchRequest {
+
+ // The only real difference in this request is that there's an extra sort/filter field that GermplasmSearchRequest doesn't have.
+ // It is specific to lists. In general, other EntityListSearchRequests like this one should look the same, but have different base search requests.
+ private static final Map
+ LIST_ALLOWED_FIELDS;
+
+ static {
+ Map fields =
+ copyAllowedSortAndFilterFields();
+
+ fields.put(
+ "listItemPosition",
+ new SortAndFilterEntityColumnInfo("*listItem.positionIndexedBy1", EntityType.NUMBER, false, true)
+ );
+
+ LIST_ALLOWED_FIELDS = Collections.unmodifiableMap(fields);
+ }
+
+ @Override
+ public Map getEntityColInfoBySubmittedNameMap() {
+ return LIST_ALLOWED_FIELDS;
+ }
+}
diff --git a/src/main/java/io/swagger/model/core/ListItem.java b/src/main/java/io/swagger/model/core/ListItem.java
new file mode 100644
index 00000000..a3f70dd2
--- /dev/null
+++ b/src/main/java/io/swagger/model/core/ListItem.java
@@ -0,0 +1,95 @@
+package io.swagger.model.core;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.validation.annotation.Validated;
+
+/**
+ * ListItem
+ */
+@Validated
+@javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
+public class ListItem {
+ @JsonProperty("listItemDbId")
+ private String listItemDbId = null;
+
+ @JsonProperty("position")
+ private Integer position = null;
+
+ // This represents the actual value stored in the list_item table
+ @JsonProperty("item")
+ private String item = null;
+
+ /**
+ * The unique identifier for a List
+ * @return listDbId
+ **/
+ @ApiModelProperty(example = "6f621cfa", required = true, value = "The unique identifier for a List")
+
+
+ public String getListItemDbId() {
+ return listItemDbId;
+ }
+
+ public void setListItemDbId(String listItemDbId) {
+ this.listItemDbId = listItemDbId;
+ }
+
+ public Integer getPosition() {
+ return position;
+ }
+
+ public void setPosition(Integer position) {
+ this.position = position;
+ }
+
+ public String getItem() {
+ return item;
+ }
+
+ public void setItem(String item) {
+ this.item = item;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ListItem ListItem = (ListItem) o;
+ return Objects.equals(this.listItemDbId, ListItem.listItemDbId) &&
+ super.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(listItemDbId, super.hashCode());
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ListItem {\n");
+ sb.append(" ").append(toIndentedString(super.toString())).append("\n");
+ sb.append(" listDbId: ").append(toIndentedString(listItemDbId)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(java.lang.Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
+
diff --git a/src/main/java/io/swagger/model/core/ListItemWithFullItem.java b/src/main/java/io/swagger/model/core/ListItemWithFullItem.java
new file mode 100644
index 00000000..abe035c0
--- /dev/null
+++ b/src/main/java/io/swagger/model/core/ListItemWithFullItem.java
@@ -0,0 +1,83 @@
+package io.swagger.model.core;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.validation.annotation.Validated;
+
+/**
+ * ListItemWithFullItem
+ */
+@Validated
+@javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
+public class ListItemWithFullItem {
+ @JsonProperty("listItem")
+ private ListItem listItem = null;
+
+ // The full actual BrAPI model object of the list item is supplied/written into here
+ @JsonProperty("item")
+ private T item = null;
+
+ /**
+ * The unique identifier for a List
+ * @return listItem
+ **/
+ @ApiModelProperty(example = "6f621cfa", required = true, value = "The unique identifier for a List")
+
+
+ public ListItem getListItem() {
+ return listItem;
+ }
+
+ public void setListItem(ListItem listItem) {
+ this.listItem = listItem;
+ }
+
+ public T getItem() {
+ return item;
+ }
+
+ public void setItem(T item) {
+ this.item = item;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ListItemWithFullItem listItemWithFullItem = (ListItemWithFullItem) o;
+ return Objects.equals(this.listItem, listItemWithFullItem.listItem) &&
+ super.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(listItem, super.hashCode());
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ListItemWithFullItem {\n");
+ sb.append(" ").append(toIndentedString(super.toString())).append("\n");
+ sb.append(" listItem: ").append(toIndentedString(listItem)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(java.lang.Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/main/java/io/swagger/model/core/ListItemsListResponse.java b/src/main/java/io/swagger/model/core/ListItemsListResponse.java
new file mode 100644
index 00000000..7b70e536
--- /dev/null
+++ b/src/main/java/io/swagger/model/core/ListItemsListResponse.java
@@ -0,0 +1,134 @@
+package io.swagger.model.core;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.model.BrAPIResponse;
+import io.swagger.model.Context;
+import io.swagger.model.Metadata;
+
+import org.springframework.validation.annotation.Validated;
+import jakarta.validation.Valid;
+
+/**
+ * ListItemsListResponse
+ */
+@Validated
+@javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
+public class ListItemsListResponse implements BrAPIResponse> {
+ @JsonProperty("@context")
+ private Context _atContext = null;
+
+ @JsonProperty("metadata")
+ private Metadata metadata = null;
+
+ // This piece of data is used by the brapi client to determine and populate the exact data model return type of ListItemWithFullItem.item
+ @JsonProperty("resultListType")
+ private ListTypes resultListType = null;
+
+ @JsonProperty("result")
+ private ListItemsListResponseResult result = null;
+
+ public ListItemsListResponse() {
+ this._atContext = new Context();
+ this._atContext.add("context");
+ }
+
+
+ public void set_atContext(Context _atContext) {
+ this._atContext = _atContext;
+ }
+ public ListItemsListResponse metadata(Metadata metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * Get metadata
+ *
+ * @return metadata
+ **/
+ @ApiModelProperty(required = true, value = "")
+
+
+ @Valid
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ public ListItemsListResponse result(ListItemsListResponseResult result) {
+ this.result = result;
+ return this;
+ }
+
+ /**
+ * Get result
+ *
+ * @return result
+ **/
+ @ApiModelProperty(required = true, value = "")
+
+
+ @Valid
+ public ListItemsListResponseResult getResult() {
+ return result;
+ }
+
+ public void setResult(ListItemsListResponseResult result) {
+ this.result = result;
+ }
+
+ public ListTypes getResultListType() {
+ return resultListType;
+ }
+
+ public void setResultListType(ListTypes resultListType) {
+ this.resultListType = resultListType;
+ }
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ListItemsListResponse listItemsListResponse = (ListItemsListResponse) o;
+ return Objects.equals(this._atContext, listItemsListResponse._atContext)
+ && Objects.equals(this.metadata, listItemsListResponse.metadata)
+ && Objects.equals(this.result, listItemsListResponse.result);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(_atContext, metadata, result);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ListItemsListResponse {\n");
+
+ sb.append(" _atContext: ").append(toIndentedString(_atContext)).append("\n");
+ sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
+ sb.append(" result: ").append(toIndentedString(result)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(java.lang.Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
diff --git a/src/main/java/io/swagger/model/core/ListItemsListResponseResult.java b/src/main/java/io/swagger/model/core/ListItemsListResponseResult.java
new file mode 100644
index 00000000..892a2dba
--- /dev/null
+++ b/src/main/java/io/swagger/model/core/ListItemsListResponseResult.java
@@ -0,0 +1,87 @@
+package io.swagger.model.core;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.model.BrAPIResponseResult;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.springframework.validation.annotation.Validated;
+import jakarta.validation.Valid;
+
+/**
+ * ListItemsListResponseResult
+ */
+@Validated
+@javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
+public class ListItemsListResponseResult implements BrAPIResponseResult> {
+ @JsonProperty("data")
+ @Valid
+ private List> data = new ArrayList>();
+
+ public ListItemsListResponseResult data(List> data) {
+ this.data = data;
+ return this;
+ }
+
+ public ListItemsListResponseResult addDataItem(ListItemWithFullItem dataItem) {
+ this.data.add(dataItem);
+ return this;
+ }
+
+ /**
+ * Get data
+ * @return data
+ **/
+ @ApiModelProperty(required = true, value = "")
+
+ @Valid
+ public List> getData() {
+ return data;
+ }
+
+ public void setData(List> data) {
+ this.data = data;
+ }
+
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ListItemsListResponseResult listItemsListResponseResult = (ListItemsListResponseResult) o;
+ return Objects.equals(this.data, listItemsListResponseResult.data);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(data);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ListItemsListResponseResult {\n");
+
+ sb.append(" data: ").append(toIndentedString(data)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(java.lang.Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/main/java/io/swagger/model/core/SortBy.java b/src/main/java/io/swagger/model/core/SortBy.java
deleted file mode 100644
index 8a132a3e..00000000
--- a/src/main/java/io/swagger/model/core/SortBy.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package io.swagger.model.core;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonValue;
-
-public enum SortBy {
-
- STUDYDBID("studyDbId"),
-
- STARTDATE("startDate"),
-
- ENDDATE("endDate"),
-
- TRIALDBID("trialDbId"),
-
- TRIALNAME("trialName"),
-
- PROGRAMDBID("programDbId"),
-
- LOCATIONDBID("locationDbId"),
-
- SEASONDBID("seasonDbId"),
-
- STUDYTYPE("studyType"),
-
- STUDYNAME("studyName"),
-
- STUDYLOCATION("studyLocation"),
-
- PROGRAMNAME("programName"),
-
- GERMPLASMDBID("germplasmDbId"),
-
- OBSERVATIONVARIABLEDBID("observationVariableDbId");
-private String value;
-
- SortBy(String value) {
- this.value = value;
- }
-
- @Override
- @JsonValue
- public String toString() {
- return String.valueOf(value);
- }
-
- @JsonCreator
- public static SortBy fromValue(String text) {
- for (SortBy b : SortBy.values()) {
- if (String.valueOf(b.value).equals(text)) {
- return b;
- }
- }
- return null;
- }
-}
diff --git a/src/main/java/io/swagger/model/core/StudySearchRequest.java b/src/main/java/io/swagger/model/core/StudySearchRequest.java
index 0b26436b..a9c3c9cd 100644
--- a/src/main/java/io/swagger/model/core/StudySearchRequest.java
+++ b/src/main/java/io/swagger/model/core/StudySearchRequest.java
@@ -1,14 +1,41 @@
package io.swagger.model.core;
+import java.util.Map;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.model.SearchRequest;
+import org.brapi.test.BrAPITestServer.model.dto.SortAndFilterEntityColumnInfo;
+import org.brapi.test.BrAPITestServer.model.dto.EntityType;
+
import java.util.ArrayList;
import java.util.List;
public class StudySearchRequest extends SearchRequest {
+
+ // Key - allowed sort or field filter name for this entity
+ // Value = entity field name and type that represents the submitted field. Used later on in query building.
+ private static final Map ALLOWED_SORT_AND_FILTER_FIELDS =
+ Map.ofEntries(
+ Map.entry("commonCropName", new SortAndFilterEntityColumnInfo("crop.cropName", EntityType.TEXT)),
+ Map.entry("externalReferenceId", new SortAndFilterEntityColumnInfo("*externalReferences.externalReferenceId", EntityType.TEXT, true, false)),
+ Map.entry("externalReferenceSource", new SortAndFilterEntityColumnInfo("*externalReferences.externalReferenceSource", EntityType.TEXT, true, false)),
+ Map.entry("germplasmDbId", new SortAndFilterEntityColumnInfo("*obsunit.germplasm.id", EntityType.UUID, true, false)),
+ Map.entry("locationDbId", new SortAndFilterEntityColumnInfo("location.id", EntityType.UUID)),
+ Map.entry("observationVariableDbId", new SortAndFilterEntityColumnInfo("*observation.observationVariable.id", EntityType.UUID, true, false)),
+ Map.entry("programDbId", new SortAndFilterEntityColumnInfo("trial.program.id", EntityType.UUID)),
+ Map.entry("programName", new SortAndFilterEntityColumnInfo("trial.program.name", EntityType.TEXT)),
+ Map.entry("seasonDbId", new SortAndFilterEntityColumnInfo("*season.id", EntityType.UUID, true, false)),
+ Map.entry("studyCode", new SortAndFilterEntityColumnInfo("studyCode", EntityType.TEXT)),
+ Map.entry("studyDbId", new SortAndFilterEntityColumnInfo("id", EntityType.UUID)),
+ Map.entry("studyLocation", new SortAndFilterEntityColumnInfo("location.id", EntityType.UUID)),
+ Map.entry("studyPUI", new SortAndFilterEntityColumnInfo("studyPUI", EntityType.TEXT)),
+ Map.entry("trialDbId", new SortAndFilterEntityColumnInfo("trial.id", EntityType.UUID)),
+ Map.entry("studyType", new SortAndFilterEntityColumnInfo("studyType", EntityType.TEXT)),
+ Map.entry("studyName", new SortAndFilterEntityColumnInfo("studyName", EntityType.TEXT))
+ );
+
@JsonProperty("commonCropNames")
private List commonCropNames = null;
@@ -54,12 +81,6 @@ public class StudySearchRequest extends SearchRequest {
@JsonProperty("seasonDbIds")
private List seasonDbIds = null;
- @JsonProperty("sortBy")
- private SortBy sortBy = null;
-
- @JsonProperty("sortOrder")
- private SortOrder sortOrder = null;
-
@JsonProperty("studyCodes")
private List studyCodes = null;
@@ -376,32 +397,6 @@ public void setSeasonDbIds(List seasonDbIds) {
this.seasonDbIds = seasonDbIds;
}
- public StudySearchRequest sortBy(SortBy sortBy) {
- this.sortBy = sortBy;
- return this;
- }
-
- public SortBy getSortBy() {
- return sortBy;
- }
-
- public void setSortBy(SortBy sortBy) {
- this.sortBy = sortBy;
- }
-
- public StudySearchRequest sortOrder(SortOrder sortOrder) {
- this.sortOrder = sortOrder;
- return this;
- }
-
- public SortOrder getSortOrder() {
- return sortOrder;
- }
-
- public void setSortOrder(SortOrder sortOrder) {
- this.sortOrder = sortOrder;
- }
-
public StudySearchRequest studyCodes(List studyCodes) {
this.studyCodes = studyCodes;
return this;
@@ -492,7 +487,6 @@ public boolean equals(java.lang.Object o) {
&& Objects.equals(this.active, studySearchRequest.active)
&& Objects.equals(this.seasonDbIds, studySearchRequest.seasonDbIds)
&& Objects.equals(this.sortBy, studySearchRequest.sortBy)
- && Objects.equals(this.sortOrder, studySearchRequest.sortOrder)
&& Objects.equals(this.studyCodes, studySearchRequest.studyCodes)
&& Objects.equals(this.studyPUIs, studySearchRequest.studyPUIs)
&& Objects.equals(this.studyTypes, studySearchRequest.studyTypes) && super.equals(o);
@@ -503,7 +497,7 @@ public int hashCode() {
return Objects.hash(commonCropNames, programDbIds, programNames, trialDbIds, trialNames, studyDbIds, studyNames,
locationDbIds, locationNames, germplasmDbIds, germplasmNames, observationVariableDbIds,
observationVariableNames, externalReferenceIds, externalReferenceSources, active, seasonDbIds, sortBy,
- sortOrder, studyCodes, studyPUIs, studyTypes, super.hashCode());
+ studyCodes, studyPUIs, studyTypes, super.hashCode());
}
@Override
@@ -529,7 +523,6 @@ public String toString() {
sb.append(" active: ").append(toIndentedString(active)).append("\n");
sb.append(" seasonDbIds: ").append(toIndentedString(seasonDbIds)).append("\n");
sb.append(" sortBy: ").append(toIndentedString(sortBy)).append("\n");
- sb.append(" sortOrder: ").append(toIndentedString(sortOrder)).append("\n");
sb.append(" studyCodes: ").append(toIndentedString(studyCodes)).append("\n");
sb.append(" studyPUIs: ").append(toIndentedString(studyPUIs)).append("\n");
sb.append(" studyTypes: ").append(toIndentedString(studyTypes)).append("\n");
@@ -583,8 +576,6 @@ public Integer getTotalParameterCount() {
count += this.seasonDbIds.size();
if (this.sortBy != null)
count += 1;
- if (this.sortOrder != null)
- count += 1;
if (this.studyCodes != null)
count += this.studyCodes.size();
if (this.studyPUIs != null)
@@ -593,4 +584,9 @@ public Integer getTotalParameterCount() {
count += this.studyTypes.size();
return count;
}
+
+ @Override
+ public Map getEntityColInfoBySubmittedNameMap() {
+ return ALLOWED_SORT_AND_FILTER_FIELDS;
+ }
}
diff --git a/src/main/java/io/swagger/model/core/TrialSearchRequest.java b/src/main/java/io/swagger/model/core/TrialSearchRequest.java
index 830dde51..f703010e 100644
--- a/src/main/java/io/swagger/model/core/TrialSearchRequest.java
+++ b/src/main/java/io/swagger/model/core/TrialSearchRequest.java
@@ -1,13 +1,32 @@
package io.swagger.model.core;
-import java.util.Objects;
+import java.util.*;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.model.SearchRequest;
-import java.util.ArrayList;
-import java.util.List;
+import org.brapi.test.BrAPITestServer.model.dto.SortAndFilterEntityColumnInfo;
+import org.brapi.test.BrAPITestServer.model.dto.EntityType;
+
import java.time.LocalDate;
public class TrialSearchRequest extends SearchRequest {
+
+ // Key - allowed sort or field filter name for this entity
+ // Value = entity field name and type that represents the submitted field. Used later on in query building.
+ private static final Map ALLOWED_SORT_AND_FILTER_FIELDS =
+ Map.of(
+ "trialName", new SortAndFilterEntityColumnInfo("trialName", EntityType.TEXT),
+ "createdDate", new SortAndFilterEntityColumnInfo("createdDate", EntityType.TEXT),
+ "createdBy", new SortAndFilterEntityColumnInfo("createdBy", EntityType.TEXT),
+ "trialDbId", new SortAndFilterEntityColumnInfo("id", EntityType.UUID),
+ "programDbId",new SortAndFilterEntityColumnInfo("program.id", EntityType.UUID),
+ "startDate", new SortAndFilterEntityColumnInfo("startDate", EntityType.TEXT),
+ "endDate", new SortAndFilterEntityColumnInfo("endDate", EntityType.TEXT),
+ "active", new SortAndFilterEntityColumnInfo("active", EntityType.BOOLEAN),
+ "programName", new SortAndFilterEntityColumnInfo("program.name", EntityType.TEXT),
+ "locationDbId", new SortAndFilterEntityColumnInfo("*studies.location.id", EntityType.UUID, true, false)
+ );
+
@JsonProperty("commonCropNames")
private List commonCropNames = null;
@@ -50,28 +69,6 @@ public class TrialSearchRequest extends SearchRequest {
@JsonProperty("trialPUIs")
private List trialPUIs = null;
- @JsonProperty("sortBy")
- private SortBy sortBy = null;
-
- @JsonProperty("sortOrder")
- private SortOrder sortOrder = null;
-
- public SortBy getSortBy() {
- return sortBy;
- }
-
- public void setSortBy(SortBy sortBy) {
- this.sortBy = sortBy;
- }
-
- public SortOrder getSortOrder() {
- return sortOrder;
- }
-
- public void setSortOrder(SortOrder sortOrder) {
- this.sortOrder = sortOrder;
- }
-
public TrialSearchRequest commonCropNames(List commonCropNames) {
this.commonCropNames = commonCropNames;
return this;
@@ -445,4 +442,9 @@ public Integer getTotalParameterCount() {
count += this.trialPUIs.size();
return count;
}
+
+ @Override
+ public Map getEntityColInfoBySubmittedNameMap() {
+ return ALLOWED_SORT_AND_FILTER_FIELDS;
+ }
}
diff --git a/src/main/java/io/swagger/model/germ/GermplasmNewRequest.java b/src/main/java/io/swagger/model/germ/GermplasmNewRequest.java
index 253783e7..7317f374 100644
--- a/src/main/java/io/swagger/model/germ/GermplasmNewRequest.java
+++ b/src/main/java/io/swagger/model/germ/GermplasmNewRequest.java
@@ -97,6 +97,12 @@ public class GermplasmNewRequest extends BrAPIDataModel {
@JsonProperty("taxonIds")
private List taxonIds = null;
+ @JsonProperty("programDbId")
+ private String programDbId = null;
+
+ @JsonProperty("programName")
+ private String programName = null;
+
public String getBreedingMethodName() {
return breedingMethodName;
}
@@ -510,6 +516,22 @@ public void setTaxonIds(List taxonIds) {
this.taxonIds = taxonIds;
}
+ public String getProgramDbId() {
+ return programDbId;
+ }
+
+ public void setProgramDbId(String programDbId) {
+ this.programDbId = programDbId;
+ }
+
+ public String getProgramName() {
+ return programName;
+ }
+
+ public void setProgramName(String programName) {
+ this.programName = programName;
+ }
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
@@ -550,7 +572,9 @@ public boolean equals(java.lang.Object o) {
&& Objects.equals(this.subtaxa, germplasmNewRequest.subtaxa)
&& Objects.equals(this.subtaxaAuthority, germplasmNewRequest.subtaxaAuthority)
&& Objects.equals(this.synonyms, germplasmNewRequest.synonyms)
- && Objects.equals(this.taxonIds, germplasmNewRequest.taxonIds);
+ && Objects.equals(this.taxonIds, germplasmNewRequest.taxonIds)
+ && Objects.equals(this.programDbId, germplasmNewRequest.programDbId)
+ && Objects.equals(this.programName, germplasmNewRequest.programName);
}
@Override
@@ -560,7 +584,7 @@ public int hashCode() {
countryOfOriginCode, defaultDisplayName, documentationURL, donors, externalReferences, genus,
germplasmName, germplasmOrigin, germplasmPUI, germplasmPreprocessing, instituteCode, instituteName,
pedigree, seedSource, seedSourceDescription, species, speciesAuthority, storageTypes, subtaxa,
- subtaxaAuthority, synonyms, taxonIds);
+ subtaxaAuthority, synonyms, taxonIds, programDbId, programName);
}
@Override
@@ -600,6 +624,8 @@ public String toString() {
sb.append(" subtaxaAuthority: ").append(toIndentedString(subtaxaAuthority)).append("\n");
sb.append(" synonyms: ").append(toIndentedString(synonyms)).append("\n");
sb.append(" taxonIds: ").append(toIndentedString(taxonIds)).append("\n");
+ sb.append(" programDbId: ").append(toIndentedString(programDbId)).append("\n");
+ sb.append(" programName: ").append(toIndentedString(programName)).append("\n");
sb.append("}");
return sb.toString();
}
diff --git a/src/main/java/io/swagger/model/germ/GermplasmSearchRequest.java b/src/main/java/io/swagger/model/germ/GermplasmSearchRequest.java
index 36c58878..f25a5052 100644
--- a/src/main/java/io/swagger/model/germ/GermplasmSearchRequest.java
+++ b/src/main/java/io/swagger/model/germ/GermplasmSearchRequest.java
@@ -3,12 +3,35 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.model.SearchRequest;
+import org.brapi.test.BrAPITestServer.model.dto.SortAndFilterEntityColumnInfo;
+import org.brapi.test.BrAPITestServer.model.dto.EntityType;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
public class GermplasmSearchRequest extends SearchRequest {
+
+ // Key - allowed sort or field filter name for this entity
+ // Value = entity field name and type that represents the submitted field. Used later on in query building.
+ private static final Map ALLOWED_SORT_AND_FILTER_FIELDS =
+ Map.ofEntries(
+ // accessionNumber = GID for DeltaBreed
+ Map.entry("accessionNumber", new SortAndFilterEntityColumnInfo("accessionNumber", EntityType.NUMBER)),
+ Map.entry("defaultDisplayName", new SortAndFilterEntityColumnInfo("defaultDisplayName", EntityType.TEXT)),
+ Map.entry("breedingMethod", new SortAndFilterEntityColumnInfo("methodName", EntityType.TEXT)),
+ Map.entry("seedSource", new SortAndFilterEntityColumnInfo("seedSource", EntityType.TEXT)),
+ Map.entry("pedigree",new SortAndFilterEntityColumnInfo("pedigree.pedigreeString", EntityType.TEXT)),
+ Map.entry("femaleParentGID", new SortAndFilterEntityColumnInfo("femaleParentGid", EntityType.TEXT)),
+ Map.entry("maleParentGID", new SortAndFilterEntityColumnInfo("maleParentGid", EntityType.TEXT)),
+ Map.entry("createdDate", new SortAndFilterEntityColumnInfo("createdDate", EntityType.DATE)),
+ Map.entry("createdBy", new SortAndFilterEntityColumnInfo("createdBy", EntityType.TEXT)),
+ Map.entry("importEntryNumber", new SortAndFilterEntityColumnInfo("importEntryNumber", EntityType.NUMBER, false, true)),
+ Map.entry("synonyms", new SortAndFilterEntityColumnInfo("*synonyms.synonym", EntityType.TEXT, true, false))
+ );
+
+ protected static Map copyAllowedSortAndFilterFields() {
+ return new HashMap<>(ALLOWED_SORT_AND_FILTER_FIELDS);
+ }
+
@JsonProperty("accessionNumbers")
private List accessionNumbers = null;
@@ -574,6 +597,8 @@ private String toIndentedString(java.lang.Object o) {
@Override
@JsonIgnore
+ // TODO: NOTE - External Reference IDs, exref sources, germplasmNames and germplasmDbIds have been removed from the parameter count to speed up lookups and prevent async search requests.
+ // TODO: We would need to reconsider this if we decide to use parameter count as the way to trigger async requests when complete [BI-3021]
public Integer getTotalParameterCount() {
Integer count = 0;
if (this.accessionNumbers != null)
@@ -584,18 +609,10 @@ public Integer getTotalParameterCount() {
count += this.collections.size();
if (this.commonCropNames != null)
count += this.commonCropNames.size();
- if (this.externalReferenceIds != null)
- count += this.externalReferenceIds.size();
- if (this.externalReferenceSources != null)
- count += this.externalReferenceSources.size();
if (this.familyCodes != null)
count += this.familyCodes.size();
if (this.genus != null)
count += this.genus.size();
- if (this.germplasmDbIds != null)
- count += this.germplasmDbIds.size();
- if (this.germplasmNames != null)
- count += this.germplasmNames.size();
if (this.germplasmPUIs != null)
count += this.germplasmPUIs.size();
if (this.instituteCodes != null)
@@ -623,4 +640,9 @@ public Integer getTotalParameterCount() {
return count;
}
+
+ @Override
+ public Map getEntityColInfoBySubmittedNameMap() {
+ return ALLOWED_SORT_AND_FILTER_FIELDS;
+ }
}
diff --git a/src/main/java/io/swagger/model/sort/SortBy.java b/src/main/java/io/swagger/model/sort/SortBy.java
new file mode 100644
index 00000000..bb286fa6
--- /dev/null
+++ b/src/main/java/io/swagger/model/sort/SortBy.java
@@ -0,0 +1,30 @@
+package io.swagger.model.sort;
+
+public class SortBy {
+ private String sortedOn;
+ private SortOrder sortOrder = SortOrder.ASC;
+
+ public SortBy(String sortedOn,
+ SortOrder sortOrder) {
+ this.sortedOn = sortedOn;
+ this.sortOrder = sortOrder;
+ }
+
+ public SortBy() {}
+
+ public String getSortedOn() {
+ return sortedOn;
+ }
+
+ public void setSortedOn(String sortedOn) {
+ this.sortedOn = sortedOn;
+ }
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+}
diff --git a/src/main/java/io/swagger/model/core/SortOrder.java b/src/main/java/io/swagger/model/sort/SortOrder.java
similarity index 92%
rename from src/main/java/io/swagger/model/core/SortOrder.java
rename to src/main/java/io/swagger/model/sort/SortOrder.java
index 0e5b36bd..b8a85ebf 100644
--- a/src/main/java/io/swagger/model/core/SortOrder.java
+++ b/src/main/java/io/swagger/model/sort/SortOrder.java
@@ -1,4 +1,4 @@
-package io.swagger.model.core;
+package io.swagger.model.sort;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
@@ -26,6 +26,6 @@ public static SortOrder fromValue(String text) {
return b;
}
}
- return null;
+ return ASC;
}
}
diff --git a/src/main/java/org/brapi/test/BrAPITestServer/BrapiExceptionHandler.java b/src/main/java/org/brapi/test/BrAPITestServer/BrapiExceptionHandler.java
index 7ee15a60..fa6508f0 100644
--- a/src/main/java/org/brapi/test/BrAPITestServer/BrapiExceptionHandler.java
+++ b/src/main/java/org/brapi/test/BrAPITestServer/BrapiExceptionHandler.java
@@ -1,13 +1,12 @@
package org.brapi.test.BrAPITestServer;
import java.util.ArrayList;
+import java.util.Map;
import org.brapi.test.BrAPITestServer.exceptions.BrAPIServerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.MissingServletRequestParameterException;
@@ -70,4 +69,36 @@ private ResponseEntity