117 lines
5.0 KiB
Java
117 lines
5.0 KiB
Java
package eu.eudat.controllers;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import javax.transaction.Transactional;
|
|
import javax.validation.Valid;
|
|
|
|
import eu.eudat.entities.DMP;
|
|
import eu.eudat.models.dmp.DataManagementPlan;
|
|
import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
|
|
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
|
import eu.eudat.models.helpers.DataTableData;
|
|
import eu.eudat.models.helpers.responses.*;
|
|
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
|
import eu.eudat.models.security.Principal;
|
|
import eu.eudat.validators.DataManagementPlanTableRequestValidator;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.ApplicationContext;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
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;
|
|
import eu.eudat.dao.entities.UserInfoDao;
|
|
import eu.eudat.managers.DataManagementPlanManager;
|
|
|
|
|
|
@RestController
|
|
@CrossOrigin
|
|
public class DMPs extends BaseController {
|
|
@Autowired
|
|
public DMPs(ApplicationContext applicationContext){
|
|
super(applicationContext);
|
|
}
|
|
@Autowired private DataRepositoryDao dataRepositoryDao;
|
|
@Autowired private DatasetDao datasetDao;
|
|
@Autowired private DatasetProfileDao datasetProfileDao;
|
|
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
|
|
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
|
|
@Autowired private DMPDao dMPDao;
|
|
@Autowired private DMPProfileDao dMPProfileDao;
|
|
@Autowired private OrganisationDao organisationDao;
|
|
@Autowired private ProjectDao projectDao;
|
|
@Autowired private RegistryDao registryDao;
|
|
@Autowired private ResearcherDao researcherDao;
|
|
@Autowired private ServiceDao serviceDao;
|
|
@Autowired private UserInfoDao userInfoDao;
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/getPaged" }, consumes = "application/json", produces="application/json")
|
|
public @ResponseBody ResponseItem<DataTableData<DataManagementPlanListingModel>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
|
try {
|
|
DataTableData<DataManagementPlanListingModel> dataTable = new DataManagementPlanManager().getPaged(dMPDao, dataManagementPlanTableRequest);
|
|
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
|
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
}
|
|
}
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = { "/dmps/getSingle/{id}" }, produces="application/json")
|
|
public @ResponseBody ResponseItem<DataManagementPlan> getSingle(@PathVariable String id) {
|
|
try {
|
|
eu.eudat.models.dmp.DataManagementPlan project = new DataManagementPlanManager().getSingle(dMPDao, id);
|
|
return new ResponseItem<DataManagementPlan>().status(HttpStatus.OK).payload(project);
|
|
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
return new ResponseItem<DataManagementPlan>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
}
|
|
}
|
|
|
|
@Transactional
|
|
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/createOrUpdate" }, consumes = "application/json", produces="application/json")
|
|
public @ResponseBody ResponseItem<DMP> createOrUpdate(@RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan, Principal principal) {
|
|
try{
|
|
DataManagementPlanManager.createOrUpdate(dMPDao,projectDao,researcherDao,userInfoDao,organisationDao,dataManagementPlan,principal);
|
|
return new ResponseItem<DMP>().status(HttpStatus.CREATED);
|
|
}catch (Exception ex){
|
|
ex.printStackTrace();
|
|
return new ResponseItem<DMP>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/get" }, consumes = "application/json", produces="application/json")
|
|
public @ResponseBody ResponseItem<List<DataManagementPlan>> getWithCriteria(@RequestBody DataManagementPlanCriteriaRequest dataManagementPlanCriteria) {
|
|
try {
|
|
List<DataManagementPlan> dataTable = new DataManagementPlanManager().getWithCriteria(dMPDao, dataManagementPlanCriteria);
|
|
|
|
return new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.OK).payload(dataTable);
|
|
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
return new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
}
|
|
}
|
|
|
|
}
|
|
|