2018-01-17 13:03:51 +01:00
|
|
|
package eu.eudat.controllers;
|
|
|
|
|
|
|
|
import eu.eudat.managers.DatasetManager;
|
|
|
|
import eu.eudat.managers.ExternalDatasetManager;
|
|
|
|
import eu.eudat.managers.ProjectManager;
|
|
|
|
import eu.eudat.models.criteria.ExternalDatasetCriteria;
|
|
|
|
import eu.eudat.models.dataset.DatasetTableRequest;
|
|
|
|
import eu.eudat.models.externaldataset.ExternalDatasetListingModel;
|
|
|
|
import eu.eudat.models.externaldataset.ExternalDatasetTableRequest;
|
|
|
|
import eu.eudat.models.helpers.DataTableData;
|
|
|
|
import eu.eudat.models.helpers.responses.ResponseItem;
|
|
|
|
import eu.eudat.models.listingmodels.DatasetListingModel;
|
|
|
|
import eu.eudat.models.project.Project;
|
|
|
|
import eu.eudat.models.project.ProjectCriteriaRequest;
|
|
|
|
import eu.eudat.models.security.Principal;
|
|
|
|
import eu.eudat.services.ApiContext;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by ikalyvas on 1/17/2018.
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
|
|
|
public class ExternalDatasets extends BaseController{
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
public ExternalDatasets(ApiContext apiContext) {
|
|
|
|
super(apiContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getPaged"}, consumes = "application/json", produces = "application/json")
|
|
|
|
public @ResponseBody ResponseItem<DataTableData<ExternalDatasetListingModel>> getPaged(@RequestBody ExternalDatasetTableRequest datasetTableRequest, Principal principal) {
|
|
|
|
try {
|
|
|
|
DataTableData<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getPaged(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), datasetTableRequest);
|
|
|
|
return new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-17 13:20:48 +01:00
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/external/datasets"}, consumes = "application/json", produces = "application/json")
|
2018-01-17 13:03:51 +01:00
|
|
|
public @ResponseBody ResponseItem<List<ExternalDatasetListingModel>> getWithExternal(@RequestBody ExternalDatasetCriteria externalDatasetCriteria, Principal principal) {
|
|
|
|
try {
|
|
|
|
List<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), externalDatasetCriteria, this.getApiContext().getRemoteFetcher());
|
|
|
|
return new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(HttpStatus.OK);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<List<ExternalDatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getSingle/{id}"}, consumes = "application/json", produces = "application/json")
|
|
|
|
public @ResponseBody ResponseItem<ExternalDatasetListingModel> getWithExternal(@PathVariable UUID id, Principal principal) {
|
|
|
|
try {
|
|
|
|
ExternalDatasetListingModel externalDatasetModel = new ExternalDatasetManager().getSingle(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), id);
|
|
|
|
return new ResponseItem<ExternalDatasetListingModel>().payload(externalDatasetModel ).status(HttpStatus.OK);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<ExternalDatasetListingModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|