CropsController.java

  1. /*
  2.  * Copyright 2020 Global Crop Diversity Trust
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package org.gringlobal.brapi.v1;

  17. import org.gringlobal.brapi.BaseBrAPIController;
  18. import org.gringlobal.brapi.BrAPIPage;
  19. import org.gringlobal.brapi.BrAPIResponse;
  20. import org.gringlobal.service.BrAPIService;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.web.bind.annotation.GetMapping;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RestController;

  25. /**
  26.  * The BrAPI CropsController.
  27.  */
  28. @RestController("brapiCrops")
  29. @RequestMapping(CropsController.BRAPIv1_BASE)
  30. public class CropsController extends BaseBrAPIController {

  31.     @Autowired
  32.     private BrAPIService brapiService;

  33.     /**
  34.      * Get germplasm data by id
  35.      *
  36.      * @param page the page
  37.      * @return
  38.      */
  39.     @GetMapping(value = "/commoncropnames")
  40.     public BrAPIResponse<String> commonCropNames(final BrAPIPage page) {
  41.         return new BrAPIResponse<>(brapiService.getCrops(page.toPageRequest()));
  42.     }

  43. }