Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
3a60d78c81
|
@ -5,7 +5,9 @@ import java.util.UUID;
|
|||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.managers.DashBoardManager;
|
||||
import eu.eudat.models.dashboard.DashBoardStatistics;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
|
@ -19,21 +21,23 @@ import eu.eudat.managers.AdminManager;
|
|||
import eu.eudat.models.admin.composite.DatasetProfile;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Admin {
|
||||
public class Admin extends BaseController{
|
||||
|
||||
@Autowired private DatasetProfileDao datasetProfileDao;
|
||||
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
|
||||
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
|
||||
@Autowired
|
||||
public Admin(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/admin/addDmp" },consumes = "application/json", produces="application/json")
|
||||
public ResponseEntity<Object> addDmp(@RequestBody DatasetProfile profile){
|
||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile){
|
||||
try{
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile);
|
||||
datasetProfileDao.createOrUpdate(modelDefinition);
|
||||
this.getApiContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||
}catch(Exception ex){
|
||||
|
@ -48,9 +52,9 @@ public class Admin {
|
|||
try{
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile);
|
||||
|
||||
eu.eudat.entities.DatasetProfile datasetprofile = datasetProfileDao.find(UUID.fromString(id));
|
||||
eu.eudat.entities.DatasetProfile datasetprofile = this.getApiContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
||||
datasetProfileDao.createOrUpdate(datasetprofile);
|
||||
this.getApiContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
||||
}catch(Exception ex){
|
||||
|
@ -62,7 +66,7 @@ public class Admin {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/admin/get/{id}" }, produces="application/json")
|
||||
public ResponseEntity<Object> get(@PathVariable String id){
|
||||
try{
|
||||
eu.eudat.entities.DatasetProfile profile = datasetProfileDao.find(UUID.fromString(id));
|
||||
eu.eudat.entities.DatasetProfile profile = this.getApiContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
|
||||
}catch(Exception ex){
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.validators.DataManagementPlanTableRequestValidator;
|
||||
import eu.eudat.validators.DatasetProfileValidator;
|
||||
import eu.eudat.validators.ProjectModelValidator;
|
||||
import eu.eudat.validators.ProjectTableRequestValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -12,15 +15,22 @@ import org.springframework.web.bind.annotation.InitBinder;
|
|||
*/
|
||||
public abstract class BaseController {
|
||||
|
||||
private ApplicationContext springContext;
|
||||
private ApiContext apiContext;
|
||||
|
||||
public BaseController(ApplicationContext springContext){
|
||||
this.springContext = springContext;
|
||||
public ApiContext getApiContext() {
|
||||
return apiContext;
|
||||
}
|
||||
|
||||
public BaseController(ApiContext apiContext){
|
||||
this.apiContext = apiContext;
|
||||
}
|
||||
|
||||
@InitBinder()
|
||||
protected void initBinder(WebDataBinder binder) {
|
||||
if (binder.getTarget() != null && DataManagementPlanTableRequestValidator.supportsType((binder.getTarget().getClass()))) binder.addValidators(this.springContext.getBean("dataManagementPlanTableRequestValidator",DataManagementPlanTableRequestValidator.class));
|
||||
if (binder.getTarget() != null && ProjectTableRequestValidator.supportsType((binder.getTarget().getClass()))) binder.addValidators(this.springContext.getBean("projectTableRequestValidator",ProjectTableRequestValidator.class));
|
||||
if (binder.getTarget() != null && DataManagementPlanTableRequestValidator.supportsType((binder.getTarget().getClass()))) binder.addValidators(this.apiContext.getApplicationContext().getBean("dataManagementPlanTableRequestValidator",DataManagementPlanTableRequestValidator.class));
|
||||
if (binder.getTarget() != null && ProjectTableRequestValidator.supportsType((binder.getTarget().getClass()))) binder.addValidators(this.apiContext.getApplicationContext().getBean("projectTableRequestValidator",ProjectTableRequestValidator.class));
|
||||
if (binder.getTarget() != null && DatasetProfileValidator.supportsType((binder.getTarget().getClass()))) binder.addValidators(this.apiContext.getApplicationContext().getBean("datasetProfileValidator",DatasetProfileValidator.class));
|
||||
if (binder.getTarget() != null && ProjectModelValidator.supportsType((binder.getTarget().getClass()))) binder.addValidators(this.apiContext.getApplicationContext().getBean("projectModelValidator",ProjectModelValidator.class));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ 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.services.ApiContext;
|
||||
import eu.eudat.validators.DataManagementPlanTableRequestValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -41,29 +42,16 @@ 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;
|
||||
|
||||
@Autowired
|
||||
public DMPs(ApiContext apiContext){
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@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);
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataManagementPlanManager().getPaged(this.getApiContext().getDatabaseRepository().getDmpDao(), dataManagementPlanTableRequest);
|
||||
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -75,7 +63,7 @@ public class DMPs extends BaseController {
|
|||
@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);
|
||||
eu.eudat.models.dmp.DataManagementPlan project = new DataManagementPlanManager().getSingle(this.getApiContext().getDatabaseRepository().getDmpDao(), id);
|
||||
return new ResponseItem<DataManagementPlan>().status(HttpStatus.OK).payload(project);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -88,7 +76,7 @@ public class DMPs extends BaseController {
|
|||
@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);
|
||||
DataManagementPlanManager.createOrUpdate(this.getApiContext(),dataManagementPlan,principal);
|
||||
return new ResponseItem<DMP>().status(HttpStatus.CREATED);
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
|
@ -102,7 +90,7 @@ public class DMPs extends BaseController {
|
|||
@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);
|
||||
List<DataManagementPlan> dataTable = new DataManagementPlanManager().getWithCriteria(this.getApiContext().getDatabaseRepository().getDmpDao(), dataManagementPlanCriteria);
|
||||
|
||||
return new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.controllers;
|
|||
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
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.CrossOrigin;
|
||||
|
@ -17,16 +18,18 @@ import eu.eudat.models.dashboard.DashBoardStatistics;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class DashBoardController {
|
||||
public class DashBoardController extends BaseController{
|
||||
|
||||
@Autowired private DatasetDao datasetDao;
|
||||
@Autowired private DMPDao dMPDao;
|
||||
@Autowired private ProjectDao projectDao;
|
||||
@Autowired
|
||||
public DashBoardController(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dashboard/getStatistics" }, produces="application/json")
|
||||
public ResponseItem<DashBoardStatistics> getStatistics(Principal principal){
|
||||
try {
|
||||
DashBoardStatistics statistics = new DashBoardManager().getStatistics(datasetDao, dMPDao, projectDao);
|
||||
DashBoardStatistics statistics = new DashBoardManager().getStatistics(this.getApiContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getDatabaseRepository().getDmpDao()
|
||||
, this.getApiContext().getDatabaseRepository().getProjectDao());
|
||||
return new ResponseItem<DashBoardStatistics>().status(HttpStatus.OK).payload(statistics);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.UUID;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
import eu.eudat.entities.DataRepository;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -38,29 +39,17 @@ import eu.eudat.proxy.fetching.RemoteFetcher;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class DataRepositories {
|
||||
|
||||
@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 RemoteFetcher remoteFetcher;
|
||||
|
||||
public class DataRepositories extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public DataRepositories(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/datarepos" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<List<Map<String,String>>> listExternalDataRepositories(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getRepositories(query);
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getRepositories(query);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(remoteRepos);
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.models.components.commons.datafield.AutoCompleteData;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -31,17 +32,17 @@ import eu.eudat.utilities.builders.XmlBuilder;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class DatasetProfileController {
|
||||
public class DatasetProfileController extends BaseController{
|
||||
|
||||
@Autowired private DatasetProfileDao datasetProfileDao;
|
||||
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
|
||||
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
|
||||
@Autowired private DatasetDao datasetDao;
|
||||
@Autowired
|
||||
public DatasetProfileController(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetwizard/get/{id}" }, produces="application/json")
|
||||
public ResponseEntity<Object> getSingle(@PathVariable String id){
|
||||
try {
|
||||
eu.eudat.entities.Dataset dataset = datasetDao.find(UUID.fromString(id));
|
||||
eu.eudat.entities.Dataset dataset = this.getApiContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(dataset.getProfile());
|
||||
datasetprofile.setStatus(dataset.getStatus());
|
||||
if(dataset.getProperties()!=null){
|
||||
|
@ -61,13 +62,13 @@ public class DatasetProfileController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofile/save/{id}" }, consumes="application/json",produces="application/json")
|
||||
public ResponseEntity<Object> updateDataset(@PathVariable String id,@RequestBody PropertiesModel properties){
|
||||
try {
|
||||
eu.eudat.entities.Dataset dataset = datasetDao.find(UUID.fromString(id));
|
||||
eu.eudat.entities.Dataset dataset = this.getApiContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(id));
|
||||
Map<String,Object> values = new HashMap();
|
||||
properties.toMap(values);
|
||||
JSONObject jobject = new JSONObject(values);
|
||||
dataset.setProperties(jobject.toString());
|
||||
dataset.setStatus((short)properties.getStatus());
|
||||
datasetDao.createOrUpdate(dataset); //TODO
|
||||
this.getApiContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset); //TODO
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(properties);
|
||||
}
|
||||
|
@ -79,11 +80,8 @@ public class DatasetProfileController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/search/autocomplete" }, consumes="application/json",produces="application/json")
|
||||
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody AutoCompleteLookupItem lookupItem){
|
||||
try {
|
||||
eu.eudat.entities.Dataset dataset = datasetDao.find(UUID.fromString(lookupItem.getProfileID()));
|
||||
//Document viewStyleDoc = XmlBuilder.fromXml(dataset.getProfile().getViewstyle().getDefinition());
|
||||
//Element field = viewStyleDoc.getElementById(lookupItem.getFieldID());
|
||||
eu.eudat.entities.Dataset dataset = this.getApiContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(lookupItem.getProfileID()));
|
||||
eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field modelfield = new eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field();
|
||||
//modelfield.fromXml(field);
|
||||
AutoCompleteData data = new AutoCompleteData().fromData(modelfield.getData());
|
||||
|
||||
URL url = new URL(data.getUrl()+lookupItem.getSearchTerm());
|
||||
|
|
|
@ -16,6 +16,7 @@ import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
|||
import eu.eudat.models.datasetprofile.DatasetProfileTableRequestItem;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -43,26 +44,17 @@ import eu.eudat.dao.entities.ServiceDao;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class DatasetProfiles {
|
||||
|
||||
@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;
|
||||
public class DatasetProfiles extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public DatasetProfiles(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/datasetprofiles/get" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<DatasetProfileAutocompleteItem>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) {
|
||||
try {
|
||||
List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = DatasetProfileManager.getWithCriteria(datasetProfileDao,datasetProfileAutocompleteRequest);
|
||||
List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = DatasetProfileManager.getWithCriteria(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(),datasetProfileAutocompleteRequest);
|
||||
return new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.OK).payload(datasetProfileAutocompleteItems);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -73,7 +65,7 @@ public class DatasetProfiles {
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/datasetprofiles/getPaged" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DatasetProfileListingModel>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) {
|
||||
try {
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getPaged(datasetProfileDao,datasetProfileTableRequestItem);
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getPaged(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(),datasetProfileTableRequestItem);
|
||||
return new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(HttpStatus.OK).payload(datasetProfileTableData );
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -84,7 +76,7 @@ public class DatasetProfiles {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofiles/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<DatasetProfileListingModel>> getAll() {
|
||||
try {
|
||||
List<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getAll(datasetProfileDao);
|
||||
List<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getAll(this.getApiContext().getDatabaseRepository().getDatasetProfileDao());
|
||||
return new ResponseItem<List<DatasetProfileListingModel>>().status(HttpStatus.OK).payload(datasetProfileTableData );
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
|
|
@ -15,6 +15,7 @@ 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;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -31,28 +32,18 @@ import java.util.Map;
|
|||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping( value = { "/datasetwizard" })
|
||||
public class DatasetWizardController {
|
||||
|
||||
@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;
|
||||
public class DatasetWizardController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public DatasetWizardController(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@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);
|
||||
List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getDatabaseRepository().getDmpDao(),datasetWizardAutocompleteRequest,principal);
|
||||
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.OK).payload(dataManagementPlans);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -64,7 +55,7 @@ public class DatasetWizardController {
|
|||
@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);
|
||||
List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getDatabaseRepository().getDmpDao(),datasetProfileWizardAutocompleteRequest);
|
||||
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.OK).payload(dataManagementPlans);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -76,7 +67,7 @@ public class DatasetWizardController {
|
|||
@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);
|
||||
DatasetWizardModel dataset = new DatasetManager().getSingle(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
|
||||
|
||||
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).payload(dataset);
|
||||
} catch (Exception ex) {
|
||||
|
@ -89,7 +80,7 @@ public class DatasetWizardController {
|
|||
@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);
|
||||
eu.eudat.entities.Dataset dataset= DatasetManager.createOrUpdate(this.getApiContext(),profile);
|
||||
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.OK).payload(dataset);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
|
|
@ -13,6 +13,7 @@ import eu.eudat.models.dataset.DatasetTableRequest;
|
|||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.*;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -48,29 +49,17 @@ import javax.transaction.Transactional;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Datasets {
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
public class Datasets extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public Datasets(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasets/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DatasetListingModel>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) {
|
||||
try {
|
||||
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(datasetDao, datasetTableRequest);
|
||||
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext().getDatabaseRepository().getDatasetDao(), datasetTableRequest);
|
||||
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.UUID;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
import eu.eudat.entities.DMPProfile;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -34,28 +35,17 @@ import eu.eudat.entities.responses.IDLabelPair;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class DmpProfiles {
|
||||
public class DmpProfiles extends BaseController{
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
// MANAGE DMPPROFILE(S)
|
||||
@Autowired
|
||||
public DmpProfiles(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmpprofiles" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listDmpProfiles(){
|
||||
try {
|
||||
List<UUID> allIDs = dMPProfileDao.listAllIDs();
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getDMPProfileDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -69,7 +59,7 @@ public class DmpProfiles {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/dmpprofiles/{id}" })
|
||||
public @ResponseBody ResponseEntity<DMPProfile> getDmpProfile(@PathVariable("id") String id) {
|
||||
try {
|
||||
DMPProfile dmpProfile = dMPProfileDao.read(UUID.fromString(id));
|
||||
DMPProfile dmpProfile = this.getApiContext().getDatabaseRepository().getDMPProfileDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(dmpProfile);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -82,7 +72,7 @@ public class DmpProfiles {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/dmpprofile/listAllLabelIDs" })
|
||||
public @ResponseBody ResponseEntity<List<IDLabelPair>> listLabelIds(){
|
||||
try {
|
||||
List<IDLabelPair> allIDs = dMPProfileDao.listAllIDsLabels();
|
||||
List<IDLabelPair> allIDs = this.getApiContext().getDatabaseRepository().getDMPProfileDao().listAllIDsLabels();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -94,7 +84,7 @@ public class DmpProfiles {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/dmpprofile/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getAllDmpProfiles(){
|
||||
try {
|
||||
List<DMPProfile> allDmpProfiles = dMPProfileDao.getAll();
|
||||
List<DMPProfile> allDmpProfiles = this.getApiContext().getDatabaseRepository().getDMPProfileDao().getAll();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allDmpProfiles);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -107,7 +97,7 @@ public class DmpProfiles {
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/dmpprofile/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<DMPProfile> setDmpProfile(@RequestBody DMPProfile dmpprofile) {
|
||||
try {
|
||||
DMPProfile createdDMPProfile = dMPProfileDao.update(dmpprofile);
|
||||
DMPProfile createdDMPProfile = this.getApiContext().getDatabaseRepository().getDMPProfileDao().update(dmpprofile);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdDMPProfile);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
|
@ -121,7 +111,7 @@ public class DmpProfiles {
|
|||
DMPProfile dmpp = new DMPProfile();
|
||||
dmpp.setId(dmpprofile.getId());
|
||||
try {
|
||||
dMPProfileDao.delete(dmpp);
|
||||
this.getApiContext().getDatabaseRepository().getDMPProfileDao().delete(dmpp);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted DMP Profile!\"}");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete DMP Profile!\"}");
|
||||
|
|
|
@ -10,6 +10,7 @@ import eu.eudat.entities.Organisation;
|
|||
import eu.eudat.models.external.OrganisationsExternalSourcesModel;
|
||||
import eu.eudat.models.external.ProjectsExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -41,29 +42,17 @@ import eu.eudat.proxy.fetching.RemoteFetcher;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Organisations {
|
||||
|
||||
@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 RemoteFetcher remoteFetcher;
|
||||
public class Organisations extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public Organisations(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/organisations" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<OrganisationsExternalSourcesModel> listExternalOrganisations(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getOrganisations(query);
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getOrganisations(query);
|
||||
OrganisationsExternalSourcesModel projectsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
|
@ -83,7 +72,7 @@ public class Organisations {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/organisations" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listOrganisations(){
|
||||
try {
|
||||
List<UUID> allIDs = organisationDao.listAllIDs();
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getOrganisationDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -95,7 +84,7 @@ public class Organisations {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/organisations/{id}" })
|
||||
public @ResponseBody ResponseEntity<Organisation> getOrganisations(@PathVariable("id") String id) {
|
||||
try {
|
||||
Organisation organisation = organisationDao.read(UUID.fromString(id));
|
||||
Organisation organisation = this.getApiContext().getDatabaseRepository().getOrganisationDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(organisation);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -107,7 +96,7 @@ public class Organisations {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/organisation/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getAllOrganisations(){
|
||||
try {
|
||||
List<Organisation> allOrganisations = organisationDao.getAll();
|
||||
List<Organisation> allOrganisations = this.getApiContext().getDatabaseRepository().getOrganisationDao().getAll();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allOrganisations);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -120,7 +109,7 @@ public class Organisations {
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/organisation/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Organisation> setOrganisation(@RequestBody Organisation organisation) {
|
||||
try {
|
||||
Organisation createdOrganisation = organisationDao.update(organisation);
|
||||
Organisation createdOrganisation = this.getApiContext().getDatabaseRepository().getOrganisationDao().update(organisation);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdOrganisation);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
|
@ -134,7 +123,7 @@ public class Organisations {
|
|||
Organisation org = new Organisation();
|
||||
org.setId(organisation.getId());
|
||||
try {
|
||||
organisationDao.delete(org);
|
||||
this.getApiContext().getDatabaseRepository().getOrganisationDao().delete(org);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(null);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
|
|
|
@ -16,6 +16,7 @@ import eu.eudat.models.external.RegistriesExternalSourcesModel;
|
|||
import eu.eudat.models.helpers.responses.*;
|
||||
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.context.ApplicationContext;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -61,33 +62,14 @@ import eu.eudat.proxy.fetching.RemoteFetcher;
|
|||
public class Projects extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public Projects(ApplicationContext applicationContext){
|
||||
super(applicationContext);
|
||||
public Projects(ApiContext apiContext){
|
||||
super(apiContext);
|
||||
}
|
||||
@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;
|
||||
|
||||
@Autowired private RemoteFetcher remoteFetcher;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<eu.eudat.models.project.Project>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest) {
|
||||
try {
|
||||
DataTableData<eu.eudat.models.project.Project> dataTable = new ProjectManager().getPaged(projectDao, projectTableRequest);
|
||||
DataTableData<eu.eudat.models.project.Project> dataTable = new ProjectManager().getPaged(this.getApiContext().getDatabaseRepository().getProjectDao(), projectTableRequest);
|
||||
return new ResponseItem<DataTableData<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -99,7 +81,7 @@ public class Projects extends BaseController{
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/projects/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.models.project.Project> getPaged(@PathVariable String id) {
|
||||
try {
|
||||
eu.eudat.models.project.Project project = new ProjectManager().getSingle(projectDao, id);
|
||||
eu.eudat.models.project.Project project = new ProjectManager().getSingle(this.getApiContext().getDatabaseRepository().getProjectDao(), id);
|
||||
return new ResponseItem<eu.eudat.models.project.Project>().payload(project).status(HttpStatus.OK);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
@ -110,9 +92,9 @@ public class Projects extends BaseController{
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/createOrUpdate" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Project> addProject(@RequestBody eu.eudat.models.project.Project project, Principal principal) {
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Project> addProject(@Valid @RequestBody eu.eudat.models.project.Project project, Principal principal) {
|
||||
try {
|
||||
ProjectManager.createOrUpdate(projectDao,userInfoDao,project,principal);
|
||||
ProjectManager.createOrUpdate(this.getApiContext().getDatabaseRepository().getProjectDao(),this.getApiContext().getDatabaseRepository().getUserInfoDao(),project,principal);
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK);
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
|
@ -124,7 +106,7 @@ public class Projects extends BaseController{
|
|||
@RequestMapping(method = RequestMethod.DELETE, value = { "/projects/inactivate/{id}" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Project> inactivate(@PathVariable String id) {
|
||||
try {
|
||||
Project project = new ProjectManager().inactivate(projectDao,id);
|
||||
Project project = new ProjectManager().inactivate(this.getApiContext().getDatabaseRepository().getProjectDao(),id);
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK);
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
|
@ -135,7 +117,7 @@ public class Projects extends BaseController{
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/getWithExternal" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(projectDao, projectCriteria,remoteFetcher);
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(this.getApiContext().getDatabaseRepository().getProjectDao(), projectCriteria,this.getApiContext().getRemoteFetcher());
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
@ -146,7 +128,7 @@ public class Projects extends BaseController{
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/get" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> get(@RequestBody ProjectCriteriaRequest projectCriteria) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteria(projectDao, projectCriteria,remoteFetcher);
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteria(this.getApiContext().getDatabaseRepository().getProjectDao(), projectCriteria,this.getApiContext().getRemoteFetcher());
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
@ -160,7 +142,7 @@ public class Projects extends BaseController{
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/external/projects" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<ProjectsExternalSourcesModel> listExternalProjects(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getProjects(query);
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getProjects(query);
|
||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.entities.Registry;
|
|||
import eu.eudat.models.external.RegistriesExternalSourcesModel;
|
||||
import eu.eudat.models.external.ResearchersExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -42,28 +43,17 @@ import javax.transaction.Transactional;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Registries {
|
||||
|
||||
@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 RemoteFetcher remoteFetcher;
|
||||
public class Registries extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public Registries(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/registries" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<RegistriesExternalSourcesModel> listExternalRegistries(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getRegistries(query);
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getRegistries(query);
|
||||
RegistriesExternalSourcesModel registriesExternalSourcesModel = new RegistriesExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().payload(registriesExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
|
@ -83,7 +73,7 @@ public class Registries {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/registries" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listRegistries(){
|
||||
try {
|
||||
List<UUID> allIDs = registryDao.listAllIDs();
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getRegistryDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -95,7 +85,7 @@ public class Registries {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/registries/{id}" })
|
||||
public @ResponseBody ResponseEntity<Registry> getRegistries(@PathVariable("id") String id) {
|
||||
try {
|
||||
Registry registry = registryDao.read(UUID.fromString(id));
|
||||
Registry registry = this.getApiContext().getDatabaseRepository().getRegistryDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(registry);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -108,7 +98,7 @@ public class Registries {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/registries/listAllLabelIDs" })
|
||||
public @ResponseBody ResponseEntity<List<IDLabelPair>> listLabelIds(){
|
||||
try {
|
||||
List<IDLabelPair> allIDs = registryDao.listAllIDsLabels();
|
||||
List<IDLabelPair> allIDs = this.getApiContext().getDatabaseRepository().getRegistryDao().listAllIDsLabels();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -120,7 +110,7 @@ public class Registries {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/registry/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getAllRegistries(){
|
||||
try {
|
||||
List<Registry> allRegistries = registryDao.getAll();
|
||||
List<Registry> allRegistries = this.getApiContext().getDatabaseRepository().getRegistryDao().getAll();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allRegistries);
|
||||
|
||||
|
@ -134,7 +124,7 @@ public class Registries {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/registry/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Registry> setRegistry(@RequestBody Registry registry) {
|
||||
Registry createdRegistry = registryDao.update(registry);
|
||||
Registry createdRegistry = this.getApiContext().getDatabaseRepository().getRegistryDao().update(registry);
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdRegistry);
|
||||
} catch (Exception e) {
|
||||
|
@ -149,7 +139,7 @@ public class Registries {
|
|||
Registry r = new Registry();
|
||||
r.setId(registry.getId());
|
||||
try {
|
||||
registryDao.delete(r);
|
||||
this.getApiContext().getDatabaseRepository().getRegistryDao().delete(r);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted registry!\"}");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete registry!\"}");
|
||||
|
|
|
@ -10,6 +10,7 @@ import eu.eudat.entities.Researcher;
|
|||
import eu.eudat.models.external.ResearchersExternalSourcesModel;
|
||||
import eu.eudat.models.external.ServiceExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -41,28 +42,17 @@ import eu.eudat.proxy.fetching.RemoteFetcher;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Researchers {
|
||||
|
||||
@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 RemoteFetcher remoteFetcher;
|
||||
public class Researchers extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public Researchers(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/researchers" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<ResearchersExternalSourcesModel> listExternalResearchers(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getResearchers(query);
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getResearchers(query);
|
||||
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().payload(researchersExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
|
@ -82,7 +72,7 @@ public class Researchers {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/researchers" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listResearchers(){
|
||||
try {
|
||||
List<UUID> allIDs = researcherDao.listAllIDs();
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getResearcherDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -94,7 +84,7 @@ public class Researchers {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/researchers/{id}" })
|
||||
public @ResponseBody ResponseEntity<Researcher> getResearchers(@PathVariable("id") String id) {
|
||||
try {
|
||||
Researcher researcher = researcherDao.read(UUID.fromString(id));
|
||||
Researcher researcher = this.getApiContext().getDatabaseRepository().getResearcherDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(researcher);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -105,7 +95,7 @@ public class Researchers {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/researcher/getByEmail" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Researcher> getResearcherByEmail(@RequestParam("email") String email){
|
||||
try {
|
||||
Researcher researcher = researcherDao.getResearcherByEmail(email);
|
||||
Researcher researcher = this.getApiContext().getDatabaseRepository().getResearcherDao().getResearcherByEmail(email);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(researcher);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -118,7 +108,7 @@ public class Researchers {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/researcher/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<List<Researcher>> getAllResearchers(){
|
||||
try {
|
||||
List<Researcher> allResearchers = researcherDao.getAll();
|
||||
List<Researcher> allResearchers = this.getApiContext().getDatabaseRepository().getResearcherDao().getAll();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allResearchers);
|
||||
|
||||
|
@ -132,7 +122,7 @@ public class Researchers {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/researcher/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Researcher> setResearcher(@RequestBody Researcher researcher) {
|
||||
Researcher createdResearcher = researcherDao.update(researcher);
|
||||
Researcher createdResearcher = this.getApiContext().getDatabaseRepository().getResearcherDao().update(researcher);
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdResearcher);
|
||||
} catch (Exception e) {
|
||||
|
@ -147,7 +137,7 @@ public class Researchers {
|
|||
Researcher res = new Researcher();
|
||||
res.setId(researcher.getId());
|
||||
try {
|
||||
researcherDao.delete(res);
|
||||
this.getApiContext().getDatabaseRepository().getResearcherDao().delete(res);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted researcher!\"}");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete researcher!\"}");
|
||||
|
|
|
@ -9,6 +9,7 @@ import javax.transaction.Transactional;
|
|||
import eu.eudat.entities.Service;
|
||||
import eu.eudat.models.external.ServiceExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -40,28 +41,17 @@ import eu.eudat.proxy.fetching.RemoteFetcher;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Services {
|
||||
|
||||
@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 RemoteFetcher remoteFetcher;
|
||||
public class Services extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public Services(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/services" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<ServiceExternalSourcesModel> listExternalServices(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getServices(query);
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getServices(query);
|
||||
ServiceExternalSourcesModel serviceExternalSourcesModel = new ServiceExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().payload(serviceExternalSourcesModel).status(HttpStatus.OK);
|
||||
}
|
||||
|
@ -87,7 +77,7 @@ public class Services {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/services" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listServices(){
|
||||
try {
|
||||
List<UUID> allIDs = serviceDao.listAllIDs();
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getServiceDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -99,7 +89,7 @@ public class Services {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/services/{id}" })
|
||||
public @ResponseBody ResponseEntity<Service> getServices(@PathVariable("id") String id) {
|
||||
try {
|
||||
Service service = serviceDao.read(UUID.fromString(id));
|
||||
Service service = this.getApiContext().getDatabaseRepository().getServiceDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(service);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
|
@ -112,7 +102,7 @@ public class Services {
|
|||
@RequestMapping(method = RequestMethod.GET, value = { "/service/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getAllServices(){
|
||||
try {
|
||||
List<Service> allServices = serviceDao.getAll();
|
||||
List<Service> allServices = this.getApiContext().getDatabaseRepository().getServiceDao().getAll();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allServices);
|
||||
|
||||
|
@ -127,7 +117,7 @@ public class Services {
|
|||
@RequestMapping(method = RequestMethod.POST, value = { "/service/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Service> setService(@RequestBody Service service) {
|
||||
|
||||
Service createdService = serviceDao.update(service);
|
||||
Service createdService = this.getApiContext().getDatabaseRepository().getServiceDao().update(service);
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdService);
|
||||
} catch (Exception e) {
|
||||
|
@ -142,7 +132,7 @@ public class Services {
|
|||
System.out.println(service);
|
||||
|
||||
try {
|
||||
serviceDao.delete(service);
|
||||
this.getApiContext().getDatabaseRepository().getServiceDao().delete(service);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted Service entity!\"}");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Service entity!\"}");
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -55,28 +56,15 @@ import eu.eudat.helpers.Transformers;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Users {
|
||||
|
||||
@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;
|
||||
|
||||
public class Users extends BaseController{
|
||||
|
||||
@Autowired
|
||||
public Users(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/user/whoami" }, produces="application/json;charset=UTF-8")
|
||||
public @ResponseBody ResponseEntity<UserInfo> whoami(){
|
||||
|
||||
|
||||
String userID = null;
|
||||
try {
|
||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
|
@ -85,7 +73,7 @@ public class Users {
|
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
|
||||
UserInfo userInfo = userInfoDao.getUserInfo(userID);
|
||||
UserInfo userInfo = this.getApiContext().getDatabaseRepository().getUserInfoDao().getUserInfo(userID);
|
||||
|
||||
|
||||
if(userInfo==null) //this should normally never happer
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.entities.xmlmodels.datasetprofiledefinition;
|
||||
|
||||
import eu.eudat.models.components.commons.DefaultValue;
|
||||
import eu.eudat.models.components.commons.Multiplicity;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import eu.eudat.models.components.commons.ViewStyle;
|
||||
|
@ -10,6 +9,11 @@ import eu.eudat.models.components.commons.datafield.FieldData;
|
|||
import eu.eudat.utilities.XmlSerializable;
|
||||
import eu.eudat.utilities.builders.ModelBuilder;
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>{
|
||||
private String id;
|
||||
|
@ -18,6 +22,8 @@ public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>
|
|||
private DefaultValue defaultValue;
|
||||
private Visibility visible;
|
||||
private FieldData data;
|
||||
private List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> validations;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -58,6 +64,15 @@ public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>
|
|||
public void setVisible(Visibility visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> getValidations() {
|
||||
return validations;
|
||||
}
|
||||
|
||||
public void setValidations(List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> validations) {
|
||||
this.validations = validations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element rootElement = doc.createElement("field");
|
||||
|
@ -74,6 +89,14 @@ public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>
|
|||
defaultValue.setAttribute("type",this.defaultValue.getType());
|
||||
defaultValue.setAttribute("value",this.defaultValue.getValue());
|
||||
|
||||
Element validations = doc.createElement("validations");
|
||||
for(eu.eudat.models.admin.components.datasetprofile.Field.ValidationType validationType: this.validations){
|
||||
Element validation = doc.createElement("validation");
|
||||
validation.setAttribute("type",""+validationType.getValue());
|
||||
validations.appendChild(validation);
|
||||
}
|
||||
|
||||
rootElement.appendChild(validations);
|
||||
rootElement.appendChild(defaultValue);
|
||||
rootElement.appendChild(visibility);
|
||||
rootElement.appendChild(viewStyle);
|
||||
|
@ -105,6 +128,19 @@ public class Field implements DatabaseViewStyleDefinition,XmlSerializable<Field>
|
|||
this.data = new ModelBuilder().toFieldData(null, this.viewStyle.getRenderStyle(),dataElement);
|
||||
if(this.data!=null)this.data.fromXml(dataElement);
|
||||
|
||||
this.validations = new LinkedList<>();
|
||||
Element validations = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "validations");
|
||||
if(validations!=null){
|
||||
NodeList validationElements = validations.getChildNodes();
|
||||
for (int temp = 0; temp < validationElements.getLength(); temp++) {
|
||||
Node validationElement = validationElements.item(temp);
|
||||
if (validationElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||
int enumValue = Integer.parseInt(((Element)validationElement).getAttribute("type"));
|
||||
eu.eudat.models.admin.components.datasetprofile.Field.ValidationType validationType = eu.eudat.models.admin.components.datasetprofile.Field.ValidationType.fromInteger(enumValue);
|
||||
this.validations.add(validationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import eu.eudat.models.helpers.DataTableData;
|
|||
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
public class DataManagementPlanManager {
|
||||
|
@ -45,14 +46,14 @@ public class DataManagementPlanManager {
|
|||
return datamanagementPlans;
|
||||
}
|
||||
|
||||
public static void createOrUpdate(DMPDao dmpsRepository, ProjectDao projectDao,ResearcherDao researcherRepository, UserInfoDao userInfoDao, OrganisationDao organisationRepository, DataManagementPlan dataManagementPlan, Principal principal){
|
||||
public static void createOrUpdate(ApiContext apiContext, DataManagementPlan dataManagementPlan, Principal principal){
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp,organisationRepository);
|
||||
createResearchersIfTheyDontExist(newDmp,researcherRepository);
|
||||
UserInfo user = userInfoDao.read(principal.getId());
|
||||
createProjectIfItDoesntExist(newDmp,projectDao,user);
|
||||
createOrganisationsIfTheyDontExist(newDmp,apiContext.getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp,apiContext.getDatabaseRepository().getResearcherDao());
|
||||
UserInfo user = apiContext.getDatabaseRepository().getUserInfoDao().read(principal.getId());
|
||||
createProjectIfItDoesntExist(newDmp,apiContext.getDatabaseRepository().getProjectDao(),user);
|
||||
newDmp.setCreator(user);
|
||||
dmpsRepository.createOrUpdate(newDmp);
|
||||
apiContext.getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import eu.eudat.models.listingmodels.DatasetListingModel;
|
|||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.project.ProjectTableRequest;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
@ -50,12 +51,12 @@ public class DatasetManager {
|
|||
return dataset;
|
||||
}
|
||||
|
||||
public static eu.eudat.entities.Dataset createOrUpdate(DatasetDao datatasetRepository, DataRepositoryDao dataRepositoryDao, ServiceDao serviceDao, RegistryDao registryDao, DatasetWizardModel profile) throws InstantiationException, IllegalAccessException{
|
||||
public static eu.eudat.entities.Dataset createOrUpdate(ApiContext apiContext, DatasetWizardModel profile) throws InstantiationException, IllegalAccessException{
|
||||
eu.eudat.entities.Dataset dataset = profile.toDataModel();
|
||||
createRegistriesIfTheyDontExist(registryDao,dataset);
|
||||
createDataRepositoriesIfTheyDontExist(dataRepositoryDao,dataset);
|
||||
createServicesIfTheyDontExist(serviceDao,dataset);
|
||||
return datatasetRepository.createOrUpdate(dataset);
|
||||
createRegistriesIfTheyDontExist(apiContext.getDatabaseRepository().getRegistryDao(),dataset);
|
||||
createDataRepositoriesIfTheyDontExist(apiContext.getDatabaseRepository().getDataRepositoryDao(),dataset);
|
||||
createServicesIfTheyDontExist(apiContext.getDatabaseRepository().getServiceDao(),dataset);
|
||||
return apiContext.getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.models.admin.components.datasetprofile;
|
||||
|
||||
import eu.eudat.entities.xmlmodels.modeldefinition.*;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.utilities.ModelDefinition;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
|
@ -11,7 +12,29 @@ import eu.eudat.models.components.commons.Visibility;
|
|||
import eu.eudat.utilities.ViewStyleDefinition;
|
||||
import eu.eudat.utilities.builders.ModelBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Field implements ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field>,Comparable{
|
||||
|
||||
public enum ValidationType {
|
||||
REQUIRED((short) 1);
|
||||
private short value;
|
||||
private ValidationType(short value) { this.value = value; }
|
||||
public short getValue(){return value;}
|
||||
public static ValidationType fromInteger(int value) {
|
||||
switch (value) {
|
||||
case 1:
|
||||
return REQUIRED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Project Status");
|
||||
}
|
||||
}
|
||||
public static List<ValidationType> fromIntegers(List<Integer> values){
|
||||
return values.stream().map(ValidationType::fromInteger).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private Integer ordinal;
|
||||
private String value;
|
||||
|
@ -21,7 +44,7 @@ public class Field implements ViewStyleDefinition<eu.eudat.entities.xmlmodels.da
|
|||
private DefaultValue defaultValue;
|
||||
private Object data;
|
||||
private Visibility visible;
|
||||
|
||||
private List<ValidationType> validations;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -84,6 +107,14 @@ public class Field implements ViewStyleDefinition<eu.eudat.entities.xmlmodels.da
|
|||
this.visible = visible;
|
||||
}
|
||||
|
||||
public List<Integer> getValidations() {
|
||||
return this.validations.stream().map(item->(int)item.getValue()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void setValidations(List<Integer> validations) {
|
||||
this.validations = ValidationType.fromIntegers(validations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field field) {
|
||||
if(this.id == null||this.id.isEmpty())this.id = "field_"+RandomStringUtils.random(5, true, true);
|
||||
|
@ -94,6 +125,7 @@ public class Field implements ViewStyleDefinition<eu.eudat.entities.xmlmodels.da
|
|||
field.setData(new ModelBuilder().toFieldData(data, this.viewStyle.getRenderStyle()));
|
||||
field.setVisible(this.visible);
|
||||
field.setDefaultValue(this.defaultValue);
|
||||
field.setValidations(this.validations);
|
||||
return field;
|
||||
}
|
||||
@Override
|
||||
|
@ -104,6 +136,7 @@ public class Field implements ViewStyleDefinition<eu.eudat.entities.xmlmodels.da
|
|||
this.data = item.getData();
|
||||
this.visible = item.getVisible();
|
||||
this.defaultValue = item.getDefaultValue();
|
||||
this.validations = item.getValidations();
|
||||
}
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
|
|
|
@ -8,22 +8,12 @@ import java.util.Map;
|
|||
/**
|
||||
* Created by ikalyvas on 12/22/2017.
|
||||
*/
|
||||
public class ValidationErrorContext {
|
||||
private Map<String,String> error = new HashMap<>();
|
||||
|
||||
public Map<String, String> getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(Map<String, String> error) {
|
||||
this.error = error;
|
||||
}
|
||||
public class ValidationErrorContext extends HashMap<String,String>{
|
||||
|
||||
public ValidationErrorContext() {
|
||||
|
||||
}
|
||||
|
||||
public void addFieldError(String path, String message) {
|
||||
error.put(path,message);
|
||||
this.put(path,message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public class Field implements Comparable,PropertiesModelBuilder,ViewStyleDefinit
|
|||
private Multiplicity multiplicity;
|
||||
private Object data;
|
||||
private List<Field> multiplicityItems;
|
||||
private List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> validations;
|
||||
private Visibility visible;
|
||||
public List<Field> getMultiplicityItems() {
|
||||
return multiplicityItems;
|
||||
|
@ -104,6 +105,14 @@ public class Field implements Comparable,PropertiesModelBuilder,ViewStyleDefinit
|
|||
this.visible = visible;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> getValidations() {
|
||||
return validations;
|
||||
}
|
||||
|
||||
public void setValidations(List<eu.eudat.models.admin.components.datasetprofile.Field.ValidationType> validations) {
|
||||
this.validations = validations;
|
||||
}
|
||||
|
||||
public Field cloneForMultiplicity(String key, Map<String, Object> properties){
|
||||
Field newField = new Field();
|
||||
newField.id = key;
|
||||
|
@ -114,7 +123,7 @@ public class Field implements Comparable,PropertiesModelBuilder,ViewStyleDefinit
|
|||
newField.page = this.page;
|
||||
newField.defaultValue = this.defaultValue;
|
||||
newField.data = this.data;
|
||||
|
||||
newField.validations = this.validations;
|
||||
return newField;
|
||||
}
|
||||
|
||||
|
@ -126,6 +135,7 @@ public class Field implements Comparable,PropertiesModelBuilder,ViewStyleDefinit
|
|||
field.setData(new ModelBuilder().toFieldData(data, this.viewStyle.getRenderStyle()));
|
||||
field.setDefaultValue(this.defaultValue);
|
||||
field.setVisible(this.visible);
|
||||
field.setValidations(this.validations);
|
||||
return field;
|
||||
}
|
||||
@Override
|
||||
|
@ -136,6 +146,7 @@ public class Field implements Comparable,PropertiesModelBuilder,ViewStyleDefinit
|
|||
this.data = item.getData();
|
||||
this.defaultValue = item.getDefaultValue();
|
||||
this.visible= item.getVisible();
|
||||
this.validations = item.getValidations();
|
||||
}
|
||||
@Override
|
||||
public void fromJsonObject(Map<String, Object> properties) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.queryable.hibernatequeryablelist;
|
||||
|
||||
|
||||
|
||||
import eu.eudat.entities.DataEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.predicates.OrderByPredicate;
|
||||
|
@ -30,6 +29,7 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
private Integer offset;
|
||||
private Set<String> hints;
|
||||
private String hint;
|
||||
|
||||
public QueryableHibernateList(EntityManager manager, Class<T> tClass) {
|
||||
this.manager = manager;
|
||||
this.tClass = tClass;
|
||||
|
@ -43,6 +43,7 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
public void withHint(String hint) {
|
||||
this.hint = hint;
|
||||
}
|
||||
|
||||
public QueryableList<T> setHints(Set<String> hints) {
|
||||
this.hints = hints;
|
||||
return this;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.proxy.fetching.RemoteFetcher;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/3/2018.
|
||||
*/
|
||||
public interface ApiContext {
|
||||
DatabaseRepository getDatabaseRepository();
|
||||
ApplicationContext getApplicationContext();
|
||||
RemoteFetcher getRemoteFetcher();
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.proxy.fetching.RemoteFetcher;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/3/2018.
|
||||
*/
|
||||
@Service("apiContext")
|
||||
public class ApiContextImpl implements ApiContext{
|
||||
|
||||
private DatabaseRepository databaseRepository;
|
||||
private ApplicationContext applicationContext;
|
||||
private RemoteFetcher remoteFetcher;
|
||||
|
||||
@Autowired
|
||||
public void setDatabaseRepository(DatabaseRepository databaseRepository) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseRepository getDatabaseRepository() {
|
||||
return databaseRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteFetcher getRemoteFetcher() {
|
||||
return remoteFetcher;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setRemoteFetcher(RemoteFetcher remoteFetcher) {
|
||||
this.remoteFetcher = remoteFetcher;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.dao.entities.*;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/4/2018.
|
||||
*/
|
||||
public interface DatabaseRepository {
|
||||
DataRepositoryDao getDataRepositoryDao();
|
||||
DatasetDao getDatasetDao();
|
||||
DatasetProfileDao getDatasetProfileDao();
|
||||
DatasetRegistryDao getDatasetRegistryDao();
|
||||
DatasetServiceDao getDatasetServiceDao();
|
||||
DMPDao getDmpDao();
|
||||
DMPProfileDao getDMPProfileDao();
|
||||
DMPResearcherDao getDMPResearcherDao();
|
||||
OrganisationDao getOrganisationDao();
|
||||
ProjectDao getProjectDao();
|
||||
RegistryDao getRegistryDao();
|
||||
ResearcherDao getResearcherDao();
|
||||
ServiceDao getServiceDao();
|
||||
UserInfoDao getUserInfoDao();
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.dao.entities.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/4/2018.
|
||||
*/
|
||||
@Service("databaseRepository")
|
||||
public class DatabaseRepositoryImpl implements DatabaseRepository{
|
||||
|
||||
private DataRepositoryDao dataRepositoryDao;
|
||||
private DatasetDao datasetDao;
|
||||
private DatasetProfileDao datasetProfileDao;
|
||||
private DatasetRegistryDao datasetRegistryDao;
|
||||
private DatasetServiceDao datasetServiceDao;
|
||||
private DMPDao dmpDao;
|
||||
private DMPProfileDao dmpProfileDao;
|
||||
private DMPResearcherDao dmpResearcherDao;
|
||||
private OrganisationDao organisationDao;
|
||||
private ProjectDao projectDao;
|
||||
private RegistryDao registryDao;
|
||||
private ResearcherDao researcherDao;
|
||||
private ServiceDao serviceDao;
|
||||
private UserInfoDao userInfoDao;
|
||||
|
||||
@Autowired
|
||||
private void setDataRepositoryDao(DataRepositoryDao dataRepositoryDao) {
|
||||
this.dataRepositoryDao = dataRepositoryDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setDatasetDao(DatasetDao datasetDao) {
|
||||
this.datasetDao = datasetDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setDatasetProfileDao(DatasetProfileDao datasetProfileDao) {
|
||||
this.datasetProfileDao = datasetProfileDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setDatasetRegistryDao(DatasetRegistryDao datasetRegistryDao) {
|
||||
this.datasetRegistryDao = datasetRegistryDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setDatasetServiceDao(DatasetServiceDao datasetServiceDao) {
|
||||
this.datasetServiceDao = datasetServiceDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setDmpDao(DMPDao dmpDao) {
|
||||
this.dmpDao = dmpDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DMPProfileDao getDmpProfileDao() {
|
||||
return dmpProfileDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setDmpProfileDao(DMPProfileDao dmpProfileDao) {
|
||||
this.dmpProfileDao = dmpProfileDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DMPResearcherDao getDmpResearcherDao() {
|
||||
return dmpResearcherDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setDmpResearcherDao(DMPResearcherDao dmpResearcherDao) {
|
||||
this.dmpResearcherDao = dmpResearcherDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setOrganisationDao(OrganisationDao organisationDao) {
|
||||
this.organisationDao = organisationDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setProjectDao(ProjectDao projectDao) {
|
||||
this.projectDao = projectDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setRegistryDao(RegistryDao registryDao) {
|
||||
this.registryDao = registryDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setResearcherDao(ResearcherDao researcherDao) {
|
||||
this.researcherDao = researcherDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setServiceDao(ServiceDao serviceDao) {
|
||||
this.serviceDao = serviceDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setUserInfoDao(UserInfoDao userInfoDao) {
|
||||
this.userInfoDao = userInfoDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataRepositoryDao getDataRepositoryDao() {
|
||||
return dataRepositoryDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetDao getDatasetDao() {
|
||||
return datasetDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetProfileDao getDatasetProfileDao() {
|
||||
return datasetProfileDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetRegistryDao getDatasetRegistryDao() {
|
||||
return datasetRegistryDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetServiceDao getDatasetServiceDao() {
|
||||
return datasetServiceDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDao getDmpDao() {
|
||||
return dmpDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPProfileDao getDMPProfileDao() {
|
||||
return dmpProfileDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPResearcherDao getDMPResearcherDao() {
|
||||
return dmpResearcherDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganisationDao getOrganisationDao() {
|
||||
return organisationDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectDao getProjectDao() {
|
||||
return projectDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryDao getRegistryDao() {
|
||||
return registryDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResearcherDao getResearcherDao() {
|
||||
return researcherDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceDao getServiceDao() {
|
||||
return serviceDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfoDao getUserInfoDao() {
|
||||
return userInfoDao;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package eu.eudat.validators;
|
||||
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/2/2018.
|
||||
*/
|
||||
public abstract class ApiValidator implements Validator {
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package eu.eudat.validators;
|
||||
|
||||
import eu.eudat.models.admin.composite.DatasetProfile;
|
||||
import eu.eudat.models.project.ProjectTableRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/3/2018.
|
||||
*/
|
||||
@Component("datasetProfileValidator")
|
||||
public class DatasetProfileValidator implements Validator {
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return DatasetProfile.class.equals(aClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object obj, Errors errors) {
|
||||
DatasetProfile datasetProfile = (DatasetProfile) obj;
|
||||
if(datasetProfile.getLabel()==null){
|
||||
errors.rejectValue("label", "datasetprofile.label.null");
|
||||
}
|
||||
}
|
||||
public static boolean supportsType(Class<?> clazz) {
|
||||
return DatasetProfile.class.equals(clazz);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package eu.eudat.validators;
|
||||
|
||||
import eu.eudat.models.project.Project;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/3/2018.
|
||||
*/
|
||||
@Component("projectModelValidator")
|
||||
public class ProjectModelValidator implements Validator {
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return Project.class.equals(aClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object obj, Errors errors) {
|
||||
Project project = (Project)obj;
|
||||
if(project.getStartDate().after(project.getEndDate())){
|
||||
errors.rejectValue("startDate","project.startDate.overlapping");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean supportsType(Class<?> aClass){
|
||||
return Project.class.equals(aClass);
|
||||
}
|
||||
}
|
|
@ -3,3 +3,5 @@ datamanagementplanrequest.offset.negative=table offset cannot be negative
|
|||
projectTableRequest.periodStart.overlapping = Period Start cannot overlap Period End
|
||||
projectTableRequest.offset.negative=table offset cannot be negative
|
||||
projectTableRequest.length.negative=table length cannot be negative
|
||||
datasetprofile.label.null = Dataset Profile Label cannot be null
|
||||
project.startDate.overlapping = Period Start cannot overlap Period End
|
|
@ -61,7 +61,7 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
this.isNew = false;
|
||||
this.datasetWizardService.getSingle(itemId).map(data => data as DatasetWizardModel)
|
||||
.subscribe(data => {
|
||||
this.datasetWizardModel = new JsonSerializer<DatasetWizardModel>().fromJSONObject(data, DatasetWizardModel);
|
||||
this.datasetWizardModel = JsonSerializer.fromJSONObject(data, DatasetWizardModel);
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.datasetProfileAutoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetWizardService.getAvailableProfiles.bind(this.datasetWizardService), datasetProfileRequestItem);
|
||||
this.formGroup.get("dmp").valueChanges.subscribe(change=>{
|
||||
|
@ -126,7 +126,7 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
complete => {
|
||||
this.datasetWizardService.getSingle(complete.id).subscribe(
|
||||
result=>{
|
||||
this.datasetWizardModel = new JsonSerializer<DatasetWizardModel>().fromJSONObject(result,DatasetWizardModel);
|
||||
this.datasetWizardModel = JsonSerializer.fromJSONObject(result,DatasetWizardModel);
|
||||
}
|
||||
)
|
||||
this.onCallbackSuccess()
|
||||
|
|
|
@ -70,7 +70,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
this.isNew = false;
|
||||
this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel)
|
||||
.subscribe(data => {
|
||||
this.dataManagementPlan = new JsonSerializer<DataManagementPlanModel>().fromJSONObject(data, DataManagementPlanModel);
|
||||
this.dataManagementPlan = JsonSerializer.fromJSONObject(data, DataManagementPlanModel);
|
||||
this.formGroup = this.dataManagementPlan.buildForm();
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -61,7 +61,7 @@ export class DynamicFormComponent implements OnInit {
|
|||
this.createPagination();
|
||||
this.form = this.datasetProfileDefinitionModel.buildForm();
|
||||
this.visibilityRulesService.formGroup = this.form;
|
||||
let rules: Rule[] = new JsonSerializer<Rule>().fromJSONArray(this.datasetProfileDefinitionModel.rules, Rule);
|
||||
let rules: Rule[] = JsonSerializer.fromJSONArray(this.datasetProfileDefinitionModel.rules, Rule);
|
||||
this.visibilityRulesService.buildVisibilityRules(rules)
|
||||
this.progressbar = true;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export class HomepageComponent implements OnInit {
|
|||
|
||||
this.dashBoardService.getStatistics().subscribe(results => {
|
||||
//let data = results['payload'];
|
||||
this.dashboardStatisticsData = new JsonSerializer<DashboardStatisticsModel>().fromJSONObject(results, DashboardStatisticsModel);
|
||||
this.dashboardStatisticsData = JsonSerializer.fromJSONObject(results, DashboardStatisticsModel);
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ export class CompositeField extends BaseModel implements Serializable<CompositeF
|
|||
|
||||
fromJSONObject(item: any): CompositeField {
|
||||
|
||||
this.fields = new JsonSerializer<Field>().fromJSONArray(item.fields, Field);
|
||||
this.fields = JsonSerializer.fromJSONArray(item.fields, Field);
|
||||
this.ordinal = item.ordinal;
|
||||
this.id = item.id;
|
||||
this.title = item.title;
|
||||
this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity);
|
||||
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
||||
//this.multiplicity = new Multiplicity();
|
||||
//this.multiplicity.max = 2;
|
||||
if(item.multiplicityItems)this.multiplicityItems = new JsonSerializer<CompositeField>().fromJSONArray(item.multiplicityItems, CompositeField);
|
||||
if(item.multiplicityItems)this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, CompositeField);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ export class DatasetProfileDefinitionModel extends BaseModel implements Serializ
|
|||
public sections:Array<Section>
|
||||
fromJSONObject(item:any):DatasetProfileDefinitionModel{
|
||||
this.status = item.status;
|
||||
this.sections = new JsonSerializer<Section>().fromJSONArray(item.sections,Section);
|
||||
this.rules = new JsonSerializer<Rule>().fromJSONArray(item.rules,Rule);
|
||||
this.sections = JsonSerializer.fromJSONArray(item.sections,Section);
|
||||
this.rules = JsonSerializer.fromJSONArray(item.rules,Rule);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,12 @@ export class Field extends BaseModel implements Serializable<Field>, FormGenerat
|
|||
this.viewStyle = item.viewStyle;
|
||||
this.defaultVisibility = item.defaultVisibility;
|
||||
this.page = item.page;
|
||||
this.multiplicity = new JsonSerializer<Multiplicity>().fromJSONObject(item.multiplicity, Multiplicity);
|
||||
this.defaultValue = new JsonSerializer<DefaultValue>().fromJSONObject(item.defaultValue, DefaultValue);
|
||||
this.multiplicity = JsonSerializer.fromJSONObject(item.multiplicity, Multiplicity);
|
||||
this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue);
|
||||
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
|
||||
//this.multiplicity = new Multiplicity();
|
||||
//this.multiplicity.max = 2;
|
||||
if(item.multiplicityItems)this.multiplicityItems = new JsonSerializer<Field>().fromJSONArray(item.multiplicityItems, Field);
|
||||
if(item.multiplicityItems)this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, Field);
|
||||
this.data = item.data;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ export class FieldGroup extends BaseModel implements Serializable<FieldGroup>, F
|
|||
this.extendedDescription = item.extendedDescription;
|
||||
this.defaultVisibility = item.defaultVisibility;
|
||||
this.page = item.page;
|
||||
this.compositeFields = new JsonSerializer<CompositeField>().fromJSONArray(item.compositeFields, CompositeField);
|
||||
this.compositeFields = JsonSerializer.fromJSONArray(item.compositeFields, CompositeField);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@ export class Section extends BaseModel implements Serializable<Section>, FormGen
|
|||
public compositeFields: Array<CompositeField> = new Array<CompositeField>();
|
||||
|
||||
fromJSONObject(item: any): Section {
|
||||
this.sections = new JsonSerializer<Section>().fromJSONArray(item.sections, Section);
|
||||
this.sections = JsonSerializer.fromJSONArray(item.sections, Section);
|
||||
//this.fieldGroups = new JsonSerializer<FieldGroup>().fromJSONArray(item.fieldGroups, FieldGroup);
|
||||
this.page = item.page;
|
||||
this.defaultVisibility = item.defaultVisibility;
|
||||
this.id = item.id;
|
||||
this.title = item.title;
|
||||
this.description = item.description;
|
||||
this.compositeFields = new JsonSerializer<CompositeField>().fromJSONArray(item.fieldSets, CompositeField);
|
||||
this.compositeFields = JsonSerializer.fromJSONArray(item.fieldSets, CompositeField);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
|
|||
this.version = item.version;
|
||||
this.status = item.status;
|
||||
this.description = item.description;
|
||||
this.project = new JsonSerializer<ProjectModel>().fromJSONObject(item.project, ProjectModel);
|
||||
this.organisations = new JsonSerializer<OrganisationModel>().fromJSONArray(item.organisations, OrganisationModel);
|
||||
this.researchers = new JsonSerializer<ResearcherModel>().fromJSONArray(item.researchers, ResearcherModel);
|
||||
this.profiles = new JsonSerializer<ProfileModel>().fromJSONArray(item.profiles, ProfileModel);
|
||||
this.project = JsonSerializer.fromJSONObject(item.project, ProjectModel);
|
||||
this.organisations = JsonSerializer.fromJSONArray(item.organisations, OrganisationModel);
|
||||
this.researchers = JsonSerializer.fromJSONArray(item.researchers, ResearcherModel);
|
||||
this.profiles = JsonSerializer.fromJSONArray(item.profiles, ProfileModel);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ export class DatasetModel implements Serializable<DatasetModel> {
|
|||
this.uri = item.uri;
|
||||
this.status = item.status;
|
||||
this.description = item.description;
|
||||
this.services = new JsonSerializer<ServiceModel>().fromJSONArray(item.services, ServiceModel);
|
||||
this.registries = new JsonSerializer<RegisterModel>().fromJSONArray(item.registries, RegisterModel);
|
||||
this.dataRepositories = new JsonSerializer<DataRepositoryModel>().fromJSONArray(item.dataRepositories, DataRepositoryModel);
|
||||
this.services = JsonSerializer.fromJSONArray(item.services, ServiceModel);
|
||||
this.registries = JsonSerializer.fromJSONArray(item.registries, RegisterModel);
|
||||
this.dataRepositories = JsonSerializer.fromJSONArray(item.dataRepositories, DataRepositoryModel);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
|
|||
this.uri = item.uri;
|
||||
this.status = item.status;
|
||||
this.description = item.description;
|
||||
this.services = new JsonSerializer<ServiceModel>().fromJSONArray(item.services, ServiceModel);
|
||||
this.registries = new JsonSerializer<RegisterModel>().fromJSONArray(item.registries, RegisterModel);
|
||||
this.dataRepositories = new JsonSerializer<DataRepositoryModel>().fromJSONArray(item.dataRepositories, DataRepositoryModel);
|
||||
this.dmp = new JsonSerializer<DataManagementPlanModel>().fromJSONObject(item.dmp, DataManagementPlanModel);
|
||||
this.profile = new JsonSerializer<DatasetWizardModel>().fromJSONObject(item.profile, DatasetWizardModel);
|
||||
this.datasetProfileDefinition = new JsonSerializer<DatasetProfileDefinitionModel>().fromJSONObject(item.datasetProfileDefinition, DatasetProfileDefinitionModel);
|
||||
this.services = JsonSerializer.fromJSONArray(item.services, ServiceModel);
|
||||
this.registries = JsonSerializer.fromJSONArray(item.registries, RegisterModel);
|
||||
this.dataRepositories = JsonSerializer.fromJSONArray(item.dataRepositories, DataRepositoryModel);
|
||||
this.dmp = JsonSerializer.fromJSONObject(item.dmp, DataManagementPlanModel);
|
||||
this.profile = JsonSerializer.fromJSONObject(item.profile, DatasetWizardModel);
|
||||
this.datasetProfileDefinition = JsonSerializer.fromJSONObject(item.datasetProfileDefinition, DatasetProfileDefinitionModel);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
class="table-input" [matDatepicker]="startDate" formControlName="startDate" required>
|
||||
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #startDate></mat-datepicker>
|
||||
<mat-error *ngIf="formGroup.get('startDate').errors?.backendError">{{baseErrorModel.startDate}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('startDate').errors?.backendError">{{this.project.errorModel.startDate}}</mat-error>
|
||||
<mat-error *ngIf="formGroup.get('startDate').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
</td>
|
||||
|
|
|
@ -8,7 +8,7 @@ import { DataManagementPlanService } from "../../services/data-management-plan/d
|
|||
import { ProjectModel } from "../../models/projects/ProjectModel";
|
||||
import { ProjectService } from "../../services/project/project.service";
|
||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { FormGroup, AbstractControl, FormControl, FormArray } from "@angular/forms";
|
||||
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
||||
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
||||
import { TdDialogService } from "@covalent/core";
|
||||
|
@ -47,7 +47,7 @@ export class ProjectEditorComponent implements AfterViewInit {
|
|||
this.isNew = false;
|
||||
this.projectService.getSingle(itemId).map(data => data as ProjectModel)
|
||||
.subscribe(data => {
|
||||
this.project = new JsonSerializer<ProjectModel>().fromJSONObject(data, ProjectModel);
|
||||
this.project = JsonSerializer.fromJSONObject(data, ProjectModel);
|
||||
this.formGroup = this.project.buildForm();
|
||||
});
|
||||
} else {
|
||||
|
@ -60,7 +60,7 @@ export class ProjectEditorComponent implements AfterViewInit {
|
|||
}
|
||||
|
||||
formSubmit(): void {
|
||||
//this.touchAllFormFields(this.formGroup);
|
||||
this.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.onSubmit();
|
||||
}
|
||||
|
@ -85,9 +85,9 @@ export class ProjectEditorComponent implements AfterViewInit {
|
|||
this.router.navigate(['/projects']);
|
||||
}
|
||||
|
||||
onCallbackError(error: any) {
|
||||
this.setErrorModel(error.error);
|
||||
//this.validateAllFormFields(this.formGroup);
|
||||
onCallbackError(errorResponse: any) {
|
||||
this.setErrorModel(errorResponse.error);
|
||||
this.validateAllFormFields(this.formGroup);
|
||||
}
|
||||
|
||||
public setErrorModel(errorModel: BaseErrorModel) {
|
||||
|
@ -117,4 +117,36 @@ export class ProjectEditorComponent implements AfterViewInit {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
public touchAllFormFields(formControl: AbstractControl) {
|
||||
if (formControl instanceof FormControl) {
|
||||
formControl.markAsTouched();
|
||||
} else if (formControl instanceof FormGroup) {
|
||||
Object.keys(formControl.controls).forEach(item => {
|
||||
const control = formControl.get(item);
|
||||
this.touchAllFormFields(control);
|
||||
})
|
||||
}
|
||||
else if (formControl instanceof FormArray) {
|
||||
formControl.controls.forEach(item => {
|
||||
this.touchAllFormFields(item);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public validateAllFormFields(formControl: AbstractControl) {
|
||||
if (formControl instanceof FormControl) {
|
||||
formControl.updateValueAndValidity({ emitEvent: false })
|
||||
} else if (formControl instanceof FormGroup) {
|
||||
Object.keys(formControl.controls).forEach(item => {
|
||||
const control = formControl.get(item);
|
||||
this.validateAllFormFields(control);
|
||||
})
|
||||
}
|
||||
else if (formControl instanceof FormArray) {
|
||||
formControl.controls.forEach(item => {
|
||||
this.validateAllFormFields(item);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,7 +66,7 @@ export class AuthService {
|
|||
|
||||
return this.http.post(url, loginInfo, { headers: this.headers })
|
||||
.map((res: any) => {
|
||||
const principal = this.current(new JsonSerializer<Principal>().fromJSONObject(res.payload, Principal));
|
||||
const principal = this.current(JsonSerializer.fromJSONObject(res.payload, Principal));
|
||||
//this.loginContextSubject.next(true);
|
||||
return principal;
|
||||
})
|
||||
|
@ -101,7 +101,7 @@ export class AuthService {
|
|||
headers = headers.set('AuthToken', principal.token)
|
||||
return this.http.post(url, null, { headers: headers })
|
||||
.map((r: Response) => {
|
||||
const princ = this.current(new JsonSerializer<Principal>().fromJSONObject(r.json(), Principal));
|
||||
const princ = this.current(JsonSerializer.fromJSONObject(r.json(), Principal));
|
||||
//this.loginContextSubject.next(true);
|
||||
return princ;
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Serializable } from '../models/interfaces/Serializable';
|
||||
export class JsonSerializer<T extends Serializable<T>>{
|
||||
export class JsonSerializer{
|
||||
|
||||
public fromJSONArray(items: any[], type: { new(): T; }): T[] {
|
||||
public static fromJSONArray<T extends Serializable<T>>(items: any[], type: { new(): T; }): T[] {
|
||||
if(!items)return new Array<T>();
|
||||
const objectList: T[] = new Array<T>();
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
@ -10,7 +10,7 @@ export class JsonSerializer<T extends Serializable<T>>{
|
|||
return objectList;
|
||||
}
|
||||
|
||||
public fromJSONObject(item: any, type: { new(): T; }): T {
|
||||
public static fromJSONObject<T extends Serializable<T>>(item: any, type: { new(): T; }): T {
|
||||
if(!item)return null;
|
||||
return new type().fromJSONObject(item);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue