2017-12-15 00:01:26 +01:00
|
|
|
package eu.eudat.controllers;
|
2017-10-04 11:48:21 +02:00
|
|
|
|
2017-11-03 18:55:04 +01:00
|
|
|
import java.util.Date;
|
2017-10-04 11:48:21 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
import eu.eudat.entities.DMP;
|
|
|
|
import eu.eudat.entities.Dataset;
|
|
|
|
import eu.eudat.entities.DatasetProfile;
|
|
|
|
import eu.eudat.entities.UserInfo;
|
2017-12-15 13:25:21 +01:00
|
|
|
import eu.eudat.managers.DatasetManager;
|
|
|
|
import eu.eudat.models.dataset.DatasetTableRequest;
|
|
|
|
import eu.eudat.models.helpers.DataTableData;
|
2017-12-17 22:34:24 +01:00
|
|
|
import eu.eudat.models.helpers.responses.*;
|
2017-12-19 17:22:30 +01:00
|
|
|
import eu.eudat.models.listingmodels.DatasetListingModel;
|
2018-01-08 12:44:48 +01:00
|
|
|
import eu.eudat.models.security.Principal;
|
2018-01-04 10:32:39 +01:00
|
|
|
import eu.eudat.services.ApiContext;
|
2017-10-04 11:48:21 +02:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
2018-01-19 12:11:22 +01:00
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
2017-10-04 11:48:21 +02:00
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
2018-01-12 09:05:44 +01:00
|
|
|
public class Datasets extends BaseController {
|
2017-12-15 13:25:21 +01:00
|
|
|
|
2018-01-12 09:05:44 +01:00
|
|
|
@Autowired
|
|
|
|
public Datasets(ApiContext apiContext) {
|
|
|
|
super(apiContext);
|
|
|
|
}
|
2017-12-15 13:25:21 +01:00
|
|
|
|
2018-01-12 09:05:44 +01:00
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/datasets/getPaged"}, consumes = "application/json", produces = "application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseItem<DataTableData<DatasetListingModel>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) {
|
|
|
|
try {
|
|
|
|
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext(), datasetTableRequest, principal);
|
|
|
|
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2017-12-15 13:25:21 +01:00
|
|
|
|
2018-01-19 12:11:22 +01:00
|
|
|
@Transactional
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = {"/datasets/makepublic/{id}"}, produces = "application/json")
|
|
|
|
public @ResponseBody ResponseItem<Dataset> makePublic(@PathVariable UUID id, Principal principal) {
|
|
|
|
try {
|
|
|
|
DatasetManager.makePublic(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
|
|
|
|
return new ResponseItem<Dataset>().status(HttpStatus.OK).message("Dataset Has Been Made Public");
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-04 11:48:21 +02:00
|
|
|
}
|
|
|
|
|