2017-12-20 15:52:09 +01:00
|
|
|
package eu.eudat.controllers;
|
|
|
|
|
2017-12-22 14:42:47 +01:00
|
|
|
import eu.eudat.dao.entities.*;
|
2017-12-20 15:52:09 +01:00
|
|
|
import eu.eudat.managers.DatasetManager;
|
|
|
|
import eu.eudat.managers.DatasetWizardManager;
|
2017-12-22 14:42:47 +01:00
|
|
|
import eu.eudat.managers.UserManager;
|
2017-12-20 15:52:09 +01:00
|
|
|
import eu.eudat.models.dataset.DatasetTableRequest;
|
|
|
|
import eu.eudat.models.datasetwizard.DataManagentPlanListingModel;
|
2017-12-21 10:26:11 +01:00
|
|
|
import eu.eudat.models.datasetwizard.DatasetProfileWizardAutocompleteRequest;
|
2017-12-20 15:52:09 +01:00
|
|
|
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
|
2017-12-22 14:42:47 +01:00
|
|
|
import eu.eudat.models.datasetwizard.DatasetWizardModel;
|
2017-12-21 10:26:11 +01:00
|
|
|
import eu.eudat.models.dmp.AssociatedProfile;
|
2017-12-20 15:52:09 +01:00
|
|
|
import eu.eudat.models.dmp.DataManagementPlan;
|
|
|
|
import eu.eudat.models.helpers.DataTableData;
|
|
|
|
import eu.eudat.models.helpers.responses.ResponseItem;
|
|
|
|
import eu.eudat.models.listingmodels.DatasetListingModel;
|
|
|
|
import eu.eudat.models.security.Principal;
|
2017-12-22 14:42:47 +01:00
|
|
|
import org.json.JSONObject;
|
2017-12-20 15:52:09 +01:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
2017-12-22 14:42:47 +01:00
|
|
|
import javax.transaction.Transactional;
|
2017-12-20 15:52:09 +01:00
|
|
|
import java.util.List;
|
2017-12-22 14:42:47 +01:00
|
|
|
import java.util.Map;
|
2017-12-20 15:52:09 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by ikalyvas on 12/20/2017.
|
|
|
|
*/
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
|
|
|
@RequestMapping( value = { "/datasetwizard" })
|
|
|
|
public class DatasetWizardController {
|
|
|
|
|
2017-12-22 14:42:47 +01:00
|
|
|
@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;
|
|
|
|
|
2017-12-20 15:52:09 +01:00
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = { "/userDmps" }, produces="application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseItem<List<DataManagentPlanListingModel>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) {
|
|
|
|
try {
|
|
|
|
List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(dMPDao,datasetWizardAutocompleteRequest,principal);
|
|
|
|
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.OK).payload(dataManagementPlans);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2017-12-21 10:26:11 +01:00
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = { "/getAvailableProfiles" }, produces="application/json")
|
|
|
|
public @ResponseBody ResponseItem<List<AssociatedProfile>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, Principal principal) {
|
|
|
|
try {
|
|
|
|
List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(dMPDao,datasetProfileWizardAutocompleteRequest);
|
|
|
|
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.OK).payload(dataManagementPlans);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2017-12-22 14:42:47 +01:00
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = { "/getSingle/{id}" }, produces="application/json")
|
|
|
|
public @ResponseBody ResponseItem<DatasetWizardModel> getPaged(@PathVariable String id) {
|
|
|
|
try {
|
|
|
|
DatasetWizardModel dataset = new DatasetManager().getSingle(datasetDao, id);
|
|
|
|
|
|
|
|
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).payload(dataset);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
@RequestMapping(method = RequestMethod.POST, value = { "/createOrUpdate" }, produces="application/json")
|
|
|
|
public @ResponseBody ResponseItem<eu.eudat.entities.Dataset> createOrUpdate(@RequestBody DatasetWizardModel profile) {
|
|
|
|
try {
|
|
|
|
eu.eudat.entities.Dataset dataset= DatasetManager.createOrUpdate(datasetDao, dataRepositoryDao,serviceDao,registryDao,profile);
|
|
|
|
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.OK).payload(dataset);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2017-12-20 15:52:09 +01:00
|
|
|
}
|