2017-12-15 00:01:26 +01:00
|
|
|
package eu.eudat.controllers;
|
2017-10-06 19:20:05 +02:00
|
|
|
|
2019-05-10 10:33:48 +02:00
|
|
|
import eu.eudat.data.query.items.table.organisations.OrganisationsTableRequest;
|
|
|
|
import eu.eudat.logic.managers.OrganisationsManager;
|
2018-06-27 12:29:21 +02:00
|
|
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
|
|
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
|
|
import eu.eudat.logic.services.ApiContext;
|
2019-05-10 10:33:48 +02:00
|
|
|
import eu.eudat.models.data.dmp.Organisation;
|
|
|
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
2018-08-31 16:12:31 +02:00
|
|
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
2019-05-10 10:33:48 +02:00
|
|
|
import eu.eudat.models.data.security.Principal;
|
2018-01-23 16:21:38 +01:00
|
|
|
import eu.eudat.types.ApiMessageCode;
|
2017-10-06 19:20:05 +02:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
2018-02-16 11:34:02 +01:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2017-10-06 19:20:05 +02:00
|
|
|
|
2019-05-10 10:33:48 +02:00
|
|
|
import javax.validation.Valid;
|
2018-02-16 11:34:02 +01:00
|
|
|
import java.util.List;
|
2017-10-06 19:20:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
2018-02-09 16:54:41 +01:00
|
|
|
@RequestMapping(value = {"/api"})
|
2018-02-16 11:34:02 +01:00
|
|
|
public class Organisations extends BaseController {
|
|
|
|
|
2019-05-10 10:33:48 +02:00
|
|
|
private OrganisationsManager organisationsManager;
|
2020-01-16 12:34:12 +01:00
|
|
|
private ApiContext apiContext;
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
@Autowired
|
2019-09-17 10:45:09 +02:00
|
|
|
public Organisations(ApiContext apiContext, OrganisationsManager organisationsManager) {
|
2018-02-16 11:34:02 +01:00
|
|
|
super(apiContext);
|
2019-05-10 10:33:48 +02:00
|
|
|
this.organisationsManager = organisationsManager;
|
2018-02-16 11:34:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = {"/external/organisations"}, produces = "application/json")
|
|
|
|
public @ResponseBody
|
2020-01-16 12:34:12 +01:00
|
|
|
ResponseEntity<ResponseItem<List<Organisation>>> listExternalOrganisations(
|
2018-08-31 16:12:31 +02:00
|
|
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
|
|
|
|
) throws HugeResultSet, NoURLFound {
|
2020-01-16 12:34:12 +01:00
|
|
|
List<Organisation> organisations = organisationsManager.getCriteriaWithExternal(query, type);
|
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Organisation>>().payload(organisations).status(ApiMessageCode.NO_MESSAGE));
|
2018-02-16 11:34:02 +01:00
|
|
|
}
|
2017-10-06 19:20:05 +02:00
|
|
|
|
2019-05-10 10:33:48 +02:00
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/internal/organisations"}, produces = "application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseEntity<ResponseItem<DataTableData<Organisation>>> getPaged(@Valid @RequestBody OrganisationsTableRequest organisationsTableRequest, Principal principal) throws Exception{
|
|
|
|
DataTableData<Organisation> organisationDataTableData = this.organisationsManager.getPagedOrganisations(organisationsTableRequest, principal);
|
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Organisation>>().payload(organisationDataTableData).status(ApiMessageCode.NO_MESSAGE));
|
|
|
|
}
|
2019-05-14 13:12:31 +02:00
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/public/organisations"}, produces = "application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseEntity<ResponseItem<DataTableData<Organisation>>> getPublicPaged(@Valid @RequestBody OrganisationsTableRequest organisationsTableRequest) throws Exception{
|
|
|
|
DataTableData<Organisation> organisationDataTableData = this.organisationsManager.getPublicPagedOrganisations(organisationsTableRequest);
|
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Organisation>>().payload(organisationDataTableData).status(ApiMessageCode.NO_MESSAGE));
|
|
|
|
}
|
2017-10-06 19:20:05 +02:00
|
|
|
}
|
|
|
|
|