-
Notifications
You must be signed in to change notification settings - Fork 1
Implement Dynamic Observation Levels #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: brapi-server-v2
Are you sure you want to change the base?
Changes from all commits
0f0dce1
fab5f05
7aa2e93
0c6878a
6822f8b
47f5521
0ce831e
c12dc37
1fdd5eb
5399628
35e5675
6afd444
8b7414c
6011699
a08dc2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package io.swagger.api.pheno; | ||
|
|
||
| import io.swagger.annotations.*; | ||
| import io.swagger.model.pheno.*; | ||
| import jakarta.validation.Valid; | ||
| import org.brapi.test.BrAPITestServer.exceptions.BrAPIServerException; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2024-05-21T16:32:22.556Z[GMT]") | ||
| @Api(value = "observationlevelnames", description = "the observationlevelnames API") | ||
| public interface ObservationLevelNamesApi { | ||
| @ApiOperation(value = "Get the Observation Level Names", nickname = "observationlevelnamesGet", notes = "Call to retrieve the list of supported observation level names. Observation levels indicate the granularity level at which the measurements are taken. `levelName` defines the level, `levelOrder` defines where that level exists in the hierarchy of levels. `levelOrder`s lower numbers are at the top of the hierarchy (ie field > 0) and higher numbers are at the bottom of the hierarchy (ie plant > 6). The values are used to supply the `observationLevel` parameter in the observation unit details call.", response = ObservationLevelListResponse.class, authorizations = { | ||
| @Authorization(value = "AuthorizationToken") }, tags = { "Observation level names", }) | ||
| @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ObservationLevelListResponse.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 = "/observationlevelnames", produces = { "application/json" }, method = RequestMethod.GET) | ||
| ResponseEntity<ObservationLevelListResponse> observationlevelnamesGet( | ||
| @ApiParam(value = "programDbId") @Valid @RequestParam(value = "programDbId", required = false) String programDbId, | ||
| @ApiParam(value = "all") @Valid @RequestParam(value = "all", required = false) Boolean all, | ||
| @ApiParam(value = "HTTP HEADER - Token used for Authorization <strong> Bearer {token_string} </strong>") @RequestHeader(value = "Authorization", required = false) String authorization) | ||
| throws BrAPIServerException; | ||
|
|
||
| @ApiOperation(value = "Get the Observation Level Names", nickname = "observationlevelnamesGet", notes = "Call to save a list of observation level names", response = ObservationLevelListResponse.class, authorizations = { | ||
| @Authorization(value = "AuthorizationToken") }, tags = { "Observation level names", }) | ||
| @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ObservationLevelListResponse.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 = "/observationlevelnames", produces = { "application/json" }, method = RequestMethod.POST) | ||
| ResponseEntity<ObservationLevelListResponse> observationlevelnamesPost( | ||
| @ApiParam(value = "") @Valid @RequestBody List<ObservationLevelNewRequest> body, | ||
| @ApiParam(value = "HTTP HEADER - Token used for Authorization <strong> Bearer {token_string} </strong>") @RequestHeader(value = "Authorization", required = false) String authorization) | ||
| throws BrAPIServerException; | ||
|
|
||
| @ApiOperation(value = "Get the Observation Level Names", nickname = "observationlevelnamesGet", notes = "Call to save a list of observation level names", response = ObservationLevelListResponse.class, authorizations = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a missed copy/paste, should have value, nickname, and notes updated for DELETE instead of GET |
||
| @Authorization(value = "AuthorizationToken") }, tags = { "Observation level names", }) | ||
| @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ObservationLevelListResponse.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 = "/observationlevelnames/{observationlevelnameDbId}", produces = { "application/json" }, method = RequestMethod.DELETE) | ||
| ResponseEntity<ObservationLevelListResponse> observationlevelnamesDelete( | ||
| @ApiParam(value = "The unique ID of this generic list", required = true) @PathVariable("observationlevelnameDbId") String observationLevelNameDbId, | ||
| @ApiParam(value = "HTTP HEADER - Token used for Authorization <strong> Bearer {token_string} </strong>") @RequestHeader(value = "Authorization", required = false) String authorization) | ||
| throws BrAPIServerException; | ||
|
|
||
| @ApiOperation(value = "Update an existing Observation Level Name", nickname = "observationlevelnamesDbIdPut", notes = "Update an existing Observation Level Name", response = ObservationLevelListResponse.class, authorizations = { | ||
| @Authorization(value = "AuthorizationToken") }, tags = { "Observation Units", }) | ||
| @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ObservationUnitHierarchyLevel.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 = "/observationlevelnames/{observationlevelnameDbId}", produces = { "application/json" }, consumes = { | ||
| "application/json" }, method = RequestMethod.PUT) | ||
| ResponseEntity<ObservationLevelSingleResponse> observationlevelnamesDbIdPut( | ||
| @ApiParam(value = "The unique ID of the specific Observation Level Name", required = true) @PathVariable("observationlevelnameDbId") String observationlevelnameDbId, | ||
| @ApiParam(value = "") @Valid @RequestBody ObservationLevelNewRequest body, | ||
| @ApiParam(value = "HTTP HEADER - Token used for Authorization <strong> Bearer {token_string} </strong>") @RequestHeader(value = "Authorization", required = false) String authorization) | ||
| throws BrAPIServerException; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package io.swagger.model.pheno; | ||
|
|
||
| public class ObservationLevelNewRequest extends ObservationUnitHierarchyLevel { | ||
| private Boolean global = null; | ||
|
|
||
| public Boolean getGlobal() { | ||
| return global; | ||
| } | ||
|
|
||
| public void setGlobal(Boolean value) { | ||
| this.global = value; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| package io.swagger.model.pheno; | ||
|
|
||
| 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 io.swagger.model.pheno.ObservationLevelListResponseResult; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import jakarta.validation.Valid; | ||
|
|
||
|
|
||
| /** | ||
| * ObservationLevelListResponse | ||
| */ | ||
| @Validated | ||
| @javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:32:22.556Z[GMT]") | ||
| public class ObservationLevelSingleResponse implements BrAPIResponse<ObservationUnitHierarchyLevel> { | ||
| @JsonProperty("@context") | ||
| private Context _atContext = null; | ||
|
|
||
| @JsonProperty("metadata") | ||
| private Metadata metadata = null; | ||
|
|
||
| @JsonProperty("result") | ||
| private ObservationUnitHierarchyLevel result = null; | ||
|
|
||
| public ObservationLevelSingleResponse _atContext(Context _atContext) { | ||
| this._atContext = _atContext; | ||
| return this; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| public void set_atContext(Context _atContext) { | ||
| this._atContext = _atContext; | ||
| } | ||
|
|
||
| public ObservationLevelSingleResponse 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 ObservationLevelSingleResponse result(ObservationUnitHierarchyLevel result) { | ||
| this.result = result; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Get result | ||
| * @return result | ||
| **/ | ||
| @ApiModelProperty(required = true, value = "") | ||
|
|
||
|
|
||
| @Valid | ||
| public ObservationUnitHierarchyLevel getResult() { | ||
| return result; | ||
| } | ||
|
|
||
| public void setResult(ObservationUnitHierarchyLevel result) { | ||
| this.result = result; | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public boolean equals(java.lang.Object o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| ObservationLevelSingleResponse observationLevelSingleResponse = (ObservationLevelSingleResponse) o; | ||
| return Objects.equals(this._atContext, observationLevelSingleResponse._atContext) && | ||
| Objects.equals(this.metadata, observationLevelSingleResponse.metadata) && | ||
| Objects.equals(this.result, observationLevelSingleResponse.result); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(_atContext, metadata, result); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| StringBuilder sb = new StringBuilder(); | ||
| sb.append("class ObservationLevelListResponse {\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 "); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,26 +2,40 @@ | |
|
|
||
| import java.util.Objects; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| public class ObservationUnitHierarchyLevel { | ||
|
|
||
| @JsonProperty("levelNameDbId") | ||
| private String levelNameDbId = null; | ||
|
|
||
| @JsonProperty("levelName") | ||
| private ObservationUnitHierarchyLevelEnum levelName = null; | ||
| private String levelName = null; | ||
|
|
||
| @JsonProperty("levelOrder") | ||
| private Integer levelOrder = null; | ||
|
|
||
| public ObservationUnitHierarchyLevel levelName(ObservationUnitHierarchyLevelEnum levelName) { | ||
| this.levelName = levelName; | ||
| return this; | ||
| @JsonProperty("programDbId") | ||
| private String programDbId = null; | ||
|
|
||
| // NOTE: This property is NOT used for lookups, only responses. | ||
| @JsonProperty("programName") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Also it would be nice to keep the BrAPI java client in sync with brapi server changes. We may have to have a version that is ahead of the brapi spec to support some of the stuff that's been added to the brapi server. |
||
| private String programName = null; | ||
|
|
||
| public String getLevelNameDbId() { | ||
| return levelNameDbId; | ||
| } | ||
|
|
||
| public void setLevelNameDbId(String value) { | ||
| this.levelNameDbId = value; | ||
| } | ||
|
|
||
| public ObservationUnitHierarchyLevelEnum getLevelName() { | ||
| public String getLevelName() { | ||
| return levelName; | ||
| } | ||
|
|
||
| public void setLevelName(ObservationUnitHierarchyLevelEnum levelName) { | ||
| public void setLevelName(String levelName) { | ||
| this.levelName = levelName; | ||
| } | ||
|
|
||
|
|
@@ -38,6 +52,22 @@ public void setLevelOrder(Integer levelOrder) { | |
| this.levelOrder = levelOrder; | ||
| } | ||
|
|
||
| public String getProgramDbId() { | ||
| return programDbId; | ||
| } | ||
|
|
||
| public void setProgramDbId(String value) { | ||
| this.programDbId = value; | ||
| } | ||
|
|
||
| public String getProgramName() { | ||
| return programName; | ||
| } | ||
|
|
||
| public void setProgramName(String value) { | ||
| this.programName = value; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(java.lang.Object o) { | ||
| if (this == o) { | ||
|
|
@@ -47,13 +77,12 @@ public boolean equals(java.lang.Object o) { | |
| return false; | ||
| } | ||
| ObservationUnitHierarchyLevel observationUnitHierarchyLevel = (ObservationUnitHierarchyLevel) o; | ||
| return Objects.equals(this.levelName, observationUnitHierarchyLevel.levelName) | ||
| && Objects.equals(this.levelOrder, observationUnitHierarchyLevel.levelOrder); | ||
| return Objects.equals(this.levelNameDbId, observationUnitHierarchyLevel.levelNameDbId); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(levelName, levelOrder); | ||
| return Objects.hash(levelNameDbId); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -63,7 +92,9 @@ public String toString() { | |
|
|
||
| sb.append(" levelName: ").append(toIndentedString(levelName)).append("\n"); | ||
| sb.append(" levelOrder: ").append(toIndentedString(levelOrder)).append("\n"); | ||
| sb.append("}"); | ||
| sb.append(" levelNameDbId: ").append(toIndentedString(levelNameDbId)).append("\n"); | ||
| sb.append(" programDbId: ").append(toIndentedString(programDbId)).append("\n"); | ||
| sb.append(" programName: ").append(toIndentedString(programName)).append("\n"); | ||
| return sb.toString(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a missed copy/paste, should have value, nickname, and notes updated for POST instead of GET