112 lines
6.7 KiB
Java
112 lines
6.7 KiB
Java
package eu.eudat.controllers.v2;
|
|
|
|
import eu.eudat.authorization.Permission;
|
|
import eu.eudat.commons.enums.ExternalReferencesType;
|
|
import eu.eudat.controllers.BaseController;
|
|
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.logic.services.externalreferences.ExternalReferencesService;
|
|
import eu.eudat.logic.services.externalreferences.FunderService;
|
|
import eu.eudat.logic.services.externalreferences.ProjectService;
|
|
import eu.eudat.models.data.ExternalReference;
|
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
import eu.eudat.types.ApiMessageCode;
|
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.management.InvalidApplicationException;
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@RequestMapping(path = {"api/external-references"})
|
|
public class ExternalReferencesController extends BaseController {
|
|
|
|
private final FunderService funderService;
|
|
private final ExternalReferencesService externalReferencesService;
|
|
private final ProjectService projectService;
|
|
private final AuthorizationService authorizationService;
|
|
|
|
@Autowired
|
|
public ExternalReferencesController(
|
|
ApiContext apiContext,
|
|
FunderService funderService,
|
|
ExternalReferencesService externalReferencesService,
|
|
ProjectService projectService,
|
|
AuthorizationService authorizationService) {
|
|
super(apiContext);
|
|
this.funderService = funderService;
|
|
this.externalReferencesService = externalReferencesService;
|
|
this.projectService = projectService;
|
|
this.authorizationService = authorizationService;
|
|
}
|
|
|
|
// @PostMapping(path = {"funders"}, consumes = "application/json", produces = "application/json")
|
|
// public @ResponseBody ResponseEntity<ResponseItem<List<Funder>>> getWithExternal(@RequestBody FunderCriteriaRequest funderCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
//
|
|
// List<Funder> dataTable = this.funderService.getCriteriaWithExternal(funderCriteria);
|
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Funder>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
// }
|
|
//
|
|
// @PostMapping(path = {"projects"}, consumes = "application/json", produces = "application/json")
|
|
// public @ResponseBody
|
|
// ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
//
|
|
// List<Project> dataTable = this.projectService.getCriteriaWithExternal(projectCriteria);
|
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
// }
|
|
|
|
|
|
|
|
@GetMapping(path = {"{externalType}"}, produces = "application/json")
|
|
public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference>>> listExternalReferecnes(@PathVariable(value = "externalType") int externalType,
|
|
@RequestParam(value = "query", required = false) String query,
|
|
@RequestParam(value = "type", required = false) String type
|
|
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
ExternalReferencesType externalReferencesType = ExternalReferencesType.of((short) externalType);
|
|
|
|
List<ExternalReference> externalReferences = this.externalReferencesService.getExternalReference(externalReferencesType, query, type);
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
|
|
}
|
|
|
|
// @Transactional
|
|
// @PostMapping(path = {"data-repo/persist"}, consumes = "application/json", produces = "application/json")
|
|
// public @ResponseBody
|
|
// ResponseEntity<ResponseItem<ExternalReference>> createExternalReferecnes(@RequestBody ExternalReference externalReference) throws Exception {
|
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
//
|
|
// ExternalReference newExternalReference = this.externalReferencesService.createDataRepo(externalReference);
|
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
// }
|
|
|
|
|
|
|
|
|
|
// @GetMapping(path = {"{externalType}"}, produces = "application/json")
|
|
// public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference2>>> listExternalReferecnes2(@RequestParam(value = "externalType") String externalType, @RequestParam(value = "query", required = false) String query,
|
|
// @RequestParam(value = "type", required = false) String type
|
|
// ) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
//
|
|
// List<ExternalReference2> externalReferences = this.externalReferencesService.getExternalReference2(externalType, query, type);
|
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference2>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
|
|
// }
|
|
//
|
|
// @Transactional
|
|
// @PostMapping(value = {"{externalType}/persist"}, consumes = "application/json", produces = "application/json")
|
|
// public @ResponseBody
|
|
// ResponseEntity<ResponseItem<ExternalReference2>> create(@RequestBody ExternalReference2 externalReference) throws Exception {
|
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
//
|
|
// ExternalReference2 newExternalReference = this.externalReferencesService.create(externalReference);
|
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference2>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
// }
|
|
|
|
}
|