package eu.eudat.controllers; import eu.eudat.data.query.items.item.researcher.ResearcherCriteriaRequest; import eu.eudat.logic.managers.ResearcherManager; import eu.eudat.logic.proxy.config.exceptions.HugeResultSet; import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.services.ApiContext; import eu.eudat.models.data.dmp.Researcher; import eu.eudat.models.data.external.ResearchersExternalSourcesModel; import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.security.Principal; import eu.eudat.types.ApiMessageCode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @RestController @CrossOrigin @RequestMapping(value = {"/api"}) public class Researchers extends BaseController { private ResearcherManager researcherManager; @Autowired public Researchers(ApiContext apiContext, ResearcherManager researcherManager) { super(apiContext); this.researcherManager = researcherManager; } /*@RequestMapping(method = RequestMethod.GET, value = {"/external/researchers"}, produces = "application/json") public @ResponseBody ResponseEntity> listExternalResearchers( @RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type) throws HugeResultSet, NoURLFound { List> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getResearchers(query, type); ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE)); }*/ @RequestMapping(method = RequestMethod.POST, value = {"/researchers/getWithExternal"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest, Principal principal) throws HugeResultSet, NoURLFound { List dataTable = this.researcherManager.getCriteriaWithExternal(this.getApiContext(), this.getApiContext().getOperationsContext().getRemoteFetcher(), researcherCriteriaRequest); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE)); } @Transactional @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> create(@RequestBody eu.eudat.models.data.researcher.Researcher researcher, Principal principal) throws Exception { this.researcherManager.create(this.getApiContext(), researcher); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); } }