CoreController.java
/*
* Copyright 2023 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gringlobal.brapi.v2.impl;
import java.io.IOException;
import java.sql.SQLException;
import org.gringlobal.brapi.BaseBrAPIController;
import org.gringlobal.brapi.BrAPIPage;
import org.gringlobal.brapi.v2.BrAPIv2Facade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import uk.ac.hutton.ics.brapi.resource.base.ArrayResult;
import uk.ac.hutton.ics.brapi.resource.base.BaseResult;
@RestController("brApi21core")
@RequestMapping(BaseBrAPIController.BRAPIv2_BASE)
public class CoreController extends BaseBrAPIController {
@Autowired
private BrAPIv2Facade brAPIv2Facade;
@GetMapping("/commoncropnames")
public BaseResult<ArrayResult<String>> getCommonCropNames(final BrAPIPage page) throws SQLException, IOException {
var p = brAPIv2Facade.getCommonCropNames(page.toPageRequest());
return arrayResult(p);
}
@GetMapping("/studytypes")
public BaseResult<ArrayResult<String>> getStudyTypes(final BrAPIPage page) throws Exception {
var p = brAPIv2Facade.getStudyTypes(page.toPageRequest());
return arrayResult(p);
}
}