2017-12-15 00:01:26 +01:00
|
|
|
package eu.eudat.controllers;
|
2017-10-23 18:06:24 +02:00
|
|
|
|
2017-12-04 11:20:21 +01:00
|
|
|
import java.util.Date;
|
2017-10-23 18:06:24 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
import eu.eudat.entities.DatasetProfile;
|
|
|
|
import eu.eudat.entities.DatasetProfileRuleset;
|
|
|
|
import eu.eudat.entities.DatasetProfileViewstyle;
|
2017-12-21 10:26:11 +01:00
|
|
|
import eu.eudat.managers.DatasetProfileManager;
|
|
|
|
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteItem;
|
|
|
|
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteRequest;
|
2018-01-03 11:44:54 +01:00
|
|
|
import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
|
|
|
import eu.eudat.models.datasetprofile.DatasetProfileTableRequestItem;
|
|
|
|
import eu.eudat.models.helpers.DataTableData;
|
2017-12-21 10:26:11 +01:00
|
|
|
import eu.eudat.models.helpers.responses.ResponseItem;
|
2018-01-04 10:32:39 +01:00
|
|
|
import eu.eudat.services.ApiContext;
|
2017-10-23 18:06:24 +02:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
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.ResponseBody;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
2017-12-15 00:01:26 +01:00
|
|
|
import eu.eudat.dao.entities.DMPDao;
|
|
|
|
import eu.eudat.dao.entities.DMPProfileDao;
|
|
|
|
import eu.eudat.dao.entities.DataRepositoryDao;
|
|
|
|
import eu.eudat.dao.entities.DatasetDao;
|
|
|
|
import eu.eudat.dao.entities.DatasetProfileDao;
|
|
|
|
import eu.eudat.dao.entities.DatasetProfileRulesetDao;
|
|
|
|
import eu.eudat.dao.entities.DatasetProfileViewstyleDao;
|
|
|
|
import eu.eudat.dao.entities.OrganisationDao;
|
|
|
|
import eu.eudat.dao.entities.ProjectDao;
|
|
|
|
import eu.eudat.dao.entities.RegistryDao;
|
|
|
|
import eu.eudat.dao.entities.ResearcherDao;
|
|
|
|
import eu.eudat.dao.entities.ServiceDao;
|
2017-10-23 18:06:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
2018-01-22 08:41:31 +01:00
|
|
|
public class DatasetProfiles extends BaseController {
|
2017-12-21 10:26:11 +01:00
|
|
|
|
2018-01-22 08:41:31 +01:00
|
|
|
@Autowired
|
|
|
|
public DatasetProfiles(ApiContext apiContext) {
|
|
|
|
super(apiContext);
|
|
|
|
}
|
2017-12-21 10:26:11 +01:00
|
|
|
|
2018-01-22 08:41:31 +01:00
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/get"}, produces = "application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseEntity<ResponseItem<List<DatasetProfileAutocompleteItem>>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) {
|
|
|
|
try {
|
|
|
|
List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = DatasetProfileManager.getWithCriteria(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileAutocompleteRequest);
|
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.OK).payload(datasetProfileAutocompleteItems));
|
|
|
|
} catch (Exception ex) {
|
|
|
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.BAD_REQUEST));
|
|
|
|
}
|
|
|
|
}
|
2018-01-03 11:44:54 +01:00
|
|
|
|
2018-01-22 08:41:31 +01:00
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/getPaged"}, produces = "application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) {
|
|
|
|
try {
|
|
|
|
DataTableData<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getPaged(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileTableRequestItem);
|
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(HttpStatus.OK).payload(datasetProfileTableData));
|
|
|
|
} catch (Exception ex) {
|
|
|
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(HttpStatus.BAD_REQUEST));
|
|
|
|
}
|
|
|
|
}
|
2018-01-03 11:44:54 +01:00
|
|
|
|
2018-01-22 08:41:31 +01:00
|
|
|
@RequestMapping(method = RequestMethod.GET, value = {"/datasetprofiles/getAll"}, produces = "application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseEntity<ResponseItem<List<DatasetProfileListingModel>>> getAll() {
|
|
|
|
try {
|
|
|
|
List<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getAll(this.getApiContext().getDatabaseRepository().getDatasetProfileDao());
|
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(HttpStatus.OK).payload(datasetProfileTableData));
|
|
|
|
} catch (Exception ex) {
|
|
|
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<DatasetProfileListingModel>>().status(HttpStatus.BAD_REQUEST));
|
|
|
|
}
|
|
|
|
}
|
2017-10-23 18:06:24 +02:00
|
|
|
}
|
|
|
|
|