From 632577b17178bdd4b9edeba0d9734d5447686cf2 Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Fri, 1 Feb 2019 18:56:55 +0200 Subject: [PATCH 1/2] Removes obsolete methods and changes url names on frontend services and backend controllers. --- .../main/java/eu/eudat/controllers/Admin.java | 35 +++++++++++++++---- .../controllers/DMPProfileController.java | 21 +++++------ .../eudat/controllers/DataRepositories.java | 13 ++++--- .../controllers/DatasetProfileController.java | 11 +++--- .../eu/eudat/controllers/DatasetProfiles.java | 16 ++++----- .../eudat/controllers/ExternalDatasets.java | 34 ++++-------------- .../eu/eudat/controllers/Organisations.java | 6 ++-- .../java/eu/eudat/controllers/Registries.java | 9 +++-- .../eu/eudat/controllers/Researchers.java | 14 ++++---- .../java/eu/eudat/controllers/Services.java | 2 +- .../eu/eudat/controllers/TagController.java | 4 +-- .../DataManagementProfileManager.java | 4 ++- .../logic/managers/DataRepositoryManager.java | 4 ++- .../logic/managers/DatasetProfileManager.java | 13 +++---- .../managers/ExternalDatasetManager.java | 5 +-- .../eudat/logic/managers/RegistryManager.java | 4 ++- .../logic/managers/ResearcherManager.java | 6 ++-- .../OrganisationsExternalSourcesModel.java | 4 ++- .../dataset-profile.service.ts | 2 +- .../core/services/dmp/dmp-profile.service.ts | 6 +--- .../extternal-data-repository.service.ts | 4 +-- .../dataset/external-dataset.service.ts | 18 +--------- .../external-sources.service.ts | 1 + .../registry/external-registry.service.ts | 2 +- .../researcher/external-researcher.service.ts | 2 +- .../service/external-service.service.ts | 2 +- 26 files changed, 121 insertions(+), 121 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java index aa9b021ea..bbfb69cff 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java @@ -1,12 +1,16 @@ package eu.eudat.controllers; import eu.eudat.core.logger.Logger; +import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.logic.managers.AdminManager; +import eu.eudat.logic.managers.DatasetProfileManager; import eu.eudat.logic.managers.UserManager; import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.helpers.LoggerService; import eu.eudat.models.data.admin.composite.DatasetProfile; +import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; +import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.user.composite.PagedDatasetProfile; @@ -24,16 +28,19 @@ import static eu.eudat.types.Authorities.ADMIN; @RestController @CrossOrigin -@RequestMapping(value = {"/api"}) +@RequestMapping(value = {"/api/admin/"}) public class Admin extends BaseController { + DatasetProfileManager datasetProfileManager; + @Autowired - public Admin(ApiContext apiContext, Logger logger) { + public Admin(ApiContext apiContext,DatasetProfileManager datasetProfileManager, Logger logger) { super(apiContext); + this.datasetProfileManager = datasetProfileManager; } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json") public ResponseEntity addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { //this.getLoggerService().info(principal, "Admin Added Dataset Profile"); eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext()); @@ -42,7 +49,7 @@ public class Admin extends BaseController { } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp/{id}"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json") public ResponseEntity> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext()); eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); @@ -51,7 +58,7 @@ public class Admin extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE)); } - @RequestMapping(method = RequestMethod.GET, value = {"/admin/get/{id}"}, produces = "application/json") + @RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json") public ResponseEntity> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); @@ -59,7 +66,14 @@ public class Admin extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile)); } - @RequestMapping(method = RequestMethod.POST, value = {"/admin/preview"}, consumes = "application/json",produces = "application/json") + @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getPaged"}, produces = "application/json") + public @ResponseBody + ResponseEntity>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception { + DataTableData datasetProfileTableData = this.datasetProfileManager.getPaged(this.getApiContext(), datasetProfileTableRequestItem); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); + } + + @RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json",produces = "application/json") public ResponseEntity> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext()); eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = UserManager.generateDatasetProfileModel(modelDefinition); @@ -67,4 +81,13 @@ public class Admin extends BaseController { pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile)); } + + @org.springframework.transaction.annotation.Transactional + @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json") + public ResponseEntity> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN})Principal principal) { + eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(this.getApiContext(), id); + eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); + datasetprofile.setLabel(profile.getLabel() + " new "); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(datasetprofile)); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java index c23f4f146..b3edb0287 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java @@ -27,38 +27,33 @@ import java.util.List; @RequestMapping(value = {"/api/dmpprofile"}) public class DMPProfileController extends BaseController { + private DataManagementProfileManager dataManagementProfileManager; + @Autowired - public DMPProfileController(ApiContext apiContext) { + public DMPProfileController(ApiContext apiContext, DataManagementProfileManager dataManagementProfileManager) { super(apiContext); + this.dataManagementProfileManager = dataManagementProfileManager; } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/createOrUpdate"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> createOrUpdate(@RequestBody DataManagementPlanProfileListingModel dataManagementPlan, Principal principal) throws Exception { - DataManagementProfileManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal); + this.dataManagementProfileManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created")); } @RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json") public @ResponseBody ResponseEntity> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException { - DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = new DataManagementProfileManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpProfileDao(), id, principal); + DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpProfileDao(), id, principal); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel)); } @RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception { - DataTableData dataTable = new DataManagementProfileManager().getPaged(this.getApiContext(), dataManagementPlanProfileTableRequest, principal); + DataTableData dataTable = this.dataManagementProfileManager.getPaged(this.getApiContext(), dataManagementPlanProfileTableRequest, principal); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); } - - @RequestMapping(method = RequestMethod.POST, value = {"/get"}, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity>> getWithCriteria(@RequestBody DataManagementPlanProfileCriteriaRequest dataManagementPlanCriteria, Principal principal) throws InstantiationException, IllegalAccessException { - List dataTable = new DataManagementProfileManager().getWithCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpProfileDao(), dataManagementPlanCriteria); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); - } - } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DataRepositories.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DataRepositories.java index 37d67abe2..f3db8148d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DataRepositories.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DataRepositories.java @@ -23,15 +23,18 @@ import java.util.Map; @RestController @CrossOrigin -@RequestMapping(value = {"/api"}) +@RequestMapping(value = {"/api/external/datarepos"}) public class DataRepositories extends BaseController { + private DataRepositoryManager dataRepositoryManager; + @Autowired - public DataRepositories(ApiContext apiContext) { + public DataRepositories(ApiContext apiContext, DataRepositoryManager dataRepositoryManager) { super(apiContext); + this.dataRepositoryManager = dataRepositoryManager; } - @RequestMapping(method = RequestMethod.GET, value = {"/external/datarepos"}, produces = "application/json") + @RequestMapping(method = RequestMethod.GET, produces = "application/json") public @ResponseBody ResponseEntity>>> listExternalDataRepositories( @RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type @@ -41,10 +44,10 @@ public class DataRepositories extends BaseController { } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/datarepos/create"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> create(@RequestBody eu.eudat.models.data.datarepository.DataRepositoryModel dataRepositoryModel, Principal principal) throws Exception { - DataRepository dataRepository = DataRepositoryManager.create(this.getApiContext(), dataRepositoryModel); + DataRepository dataRepository = this.dataRepositoryManager.create(this.getApiContext(), dataRepositoryModel); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(dataRepository).status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfileController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfileController.java index 102daf447..ec89e71f2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfileController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfileController.java @@ -36,9 +36,12 @@ import static eu.eudat.types.Authorities.ANONYMOUS; @RequestMapping(value = {"/api"}) public class DatasetProfileController extends BaseController { + private DatasetProfileManager datasetProfileManager; + @Autowired - public DatasetProfileController(ApiContext apiContext) { + public DatasetProfileController(ApiContext apiContext, DatasetProfileManager datasetProfileManager) { super(apiContext); + this.datasetProfileManager = datasetProfileManager; } @Transactional @@ -57,7 +60,7 @@ public class DatasetProfileController extends BaseController { @Transactional @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json") public ResponseEntity> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN})Principal principal) { - eu.eudat.data.entities.DatasetProfile profile = new DatasetProfileManager().clone(this.getApiContext(), id); + eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(this.getApiContext(), id); eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); datasetprofile.setLabel(profile.getLabel() + " new "); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(datasetprofile)); @@ -66,9 +69,9 @@ public class DatasetProfileController extends BaseController { @RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json") public ResponseEntity getDataForAutocomplete(@RequestBody RequestItem lookupItem) throws XPathExpressionException { eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID())); - eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = DatasetProfileManager.queryForField(datasetProfile.getDefinition(), lookupItem.getCriteria().getFieldID()); + eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = this.datasetProfileManager.queryForField(datasetProfile.getDefinition(), lookupItem.getCriteria().getFieldID()); AutoCompleteData data = (AutoCompleteData) modelfield.getData(); - List> items = DatasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike()); + List> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike()); return ResponseEntity.status(HttpStatus.OK).body(items); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfiles.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfiles.java index 81f22d470..42533ea2a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfiles.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetProfiles.java @@ -22,29 +22,25 @@ import java.util.List; @RequestMapping(value = {"/api"}) public class DatasetProfiles extends BaseController { + private DatasetProfileManager datasetProfileManager; + @Autowired - public DatasetProfiles(ApiContext apiContext) { + public DatasetProfiles(ApiContext apiContext, DatasetProfileManager datasetProfileManager) { super(apiContext); + this.datasetProfileManager = datasetProfileManager; } @RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/get"}, produces = "application/json") public @ResponseBody ResponseEntity>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws InstantiationException, IllegalAccessException { - List datasetProfileAutocompleteItems = DatasetProfileManager.getWithCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileAutocompleteRequest); + List datasetProfileAutocompleteItems = this.datasetProfileManager.getWithCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileAutocompleteRequest); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileAutocompleteItems)); } - @RequestMapping(method = RequestMethod.POST, value = {"/admin/datasetprofiles/getPaged"}, produces = "application/json") - public @ResponseBody - ResponseEntity>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception { - DataTableData datasetProfileTableData = DatasetProfileManager.getPaged(this.getApiContext(), datasetProfileTableRequestItem); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); - } - @RequestMapping(method = RequestMethod.GET, value = {"/datasetprofiles/getAll"}, produces = "application/json") public @ResponseBody ResponseEntity>> getAll() throws InstantiationException, IllegalAccessException { - List datasetProfileTableData = DatasetProfileManager.getAll(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao()); + List datasetProfileTableData = this.datasetProfileManager.getAll(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao()); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/ExternalDatasets.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/ExternalDatasets.java index bcab9aefe..0f13b0f10 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/ExternalDatasets.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/ExternalDatasets.java @@ -25,42 +25,22 @@ import java.util.UUID; @RestController @CrossOrigin -@RequestMapping(value = {"/api"}) +@RequestMapping(value = {"/api/externaldatasets/"}) public class ExternalDatasets extends BaseController { + private ExternalDatasetManager externalDatasetManager; + @Autowired - public ExternalDatasets(ApiContext apiContext) { + public ExternalDatasets(ApiContext apiContext, ExternalDatasetManager externalDatasetManager) { super(apiContext); - } - - @RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getPaged"}, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity>> getPaged(@RequestBody ExternalDatasetTableRequest datasetTableRequest, Principal principal) throws Exception { - DataTableData dataTable = new ExternalDatasetManager().getPaged(this.getApiContext(), datasetTableRequest); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); - } - - @RequestMapping(method = RequestMethod.GET, value = {"/external/datasets"}, produces = "application/json") - public @ResponseBody - ResponseEntity>> getWithExternal( - @RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type, Principal principal - ) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException { - List dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext(), query, this.getApiContext().getOperationsContext().getRemoteFetcher()); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE)); - } - - @RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getSingle/{id}"}, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseItem getWithExternal(@PathVariable UUID id, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException { - ExternalDatasetListingModel externalDatasetModel = new ExternalDatasetManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getExternalDatasetDao(), id); - return new ResponseItem().payload(externalDatasetModel).status(ApiMessageCode.NO_MESSAGE); + this.externalDatasetManager = externalDatasetManager; } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/create"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> create(@RequestBody eu.eudat.models.data.externaldataset.ExternalDatasetModel externalDatasetModel, Principal principal) throws Exception { - ExternalDataset externalDataset = ExternalDatasetManager.create(this.getApiContext(), externalDatasetModel); + ExternalDataset externalDataset = this.externalDatasetManager.create(this.getApiContext(), externalDatasetModel); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(externalDataset).status(ApiMessageCode.SUCCESS_MESSAGE)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Organisations.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Organisations.java index 579514236..fa6230cf6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Organisations.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Organisations.java @@ -20,9 +20,11 @@ import java.util.Map; @RequestMapping(value = {"/api"}) public class Organisations extends BaseController { + private OrganisationsExternalSourcesModel organisationsExternalSourcesModel; @Autowired - public Organisations(ApiContext apiContext) { + public Organisations(ApiContext apiContext, OrganisationsExternalSourcesModel organisationsExternalSourcesModel) { super(apiContext); + this.organisationsExternalSourcesModel = organisationsExternalSourcesModel; } @RequestMapping(method = RequestMethod.GET, value = {"/external/organisations"}, produces = "application/json") @@ -31,7 +33,7 @@ public class Organisations extends BaseController { @RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type ) throws HugeResultSet, NoURLFound { List> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getOrganisations(query, type); - OrganisationsExternalSourcesModel projectsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos); + OrganisationsExternalSourcesModel projectsExternalSourcesModel = this.organisationsExternalSourcesModel.fromExternalItem(remoteRepos); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(projectsExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Registries.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Registries.java index 50ec910e9..38b45f8f3 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Registries.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Registries.java @@ -25,9 +25,12 @@ import java.util.Map; @RequestMapping(value = {"/api"}) public class Registries extends BaseController { + private RegistryManager registryManager; + @Autowired - public Registries(ApiContext apiContext) { + public Registries(ApiContext apiContext, RegistryManager registryManager) { super(apiContext); + this.registryManager = registryManager; } @RequestMapping(method = RequestMethod.GET, value = {"/external/registries"}, produces = "application/json") @@ -39,10 +42,10 @@ public class Registries extends BaseController { } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/registries/create"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, value = {"/registries"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> create(@RequestBody RegistryModel registryModel, Principal principal) throws Exception { - Registry registry = RegistryManager.create(this.getApiContext(), registryModel); + Registry registry = this.registryManager.create(this.getApiContext(), registryModel); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(registry).status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Researchers.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Researchers.java index a8cf8c045..7c7fdd7ab 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Researchers.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Researchers.java @@ -26,32 +26,34 @@ import java.util.Map; public class Researchers extends BaseController { + private ResearcherManager researcherManager; @Autowired - public Researchers(ApiContext apiContext) { + public Researchers(ApiContext apiContext, ResearcherManager researcherManager) { super(apiContext); + this.researcherManager = researcherManager; } - @RequestMapping(method = RequestMethod.GET, value = {"/external/researchers"}, produces = "application/json") + /*@RequestMapping(method = RequestMethod.GET, value = {"/external/researchers"}, produces = "application/json") public @ResponseBody ResponseEntity> listExternalResearchers( @RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type) throws HugeResultSet, NoURLFound { List> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getResearchers(query, type); ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE)); - } + }*/ @RequestMapping(method = RequestMethod.POST, value = {"/researchers/getWithExternal"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest, Principal principal) throws HugeResultSet, NoURLFound { - List dataTable = new ResearcherManager().getCriteriaWithExternal(this.getApiContext(), this.getApiContext().getOperationsContext().getRemoteFetcher(), researcherCriteriaRequest); + List dataTable = this.researcherManager.getCriteriaWithExternal(this.getApiContext(), this.getApiContext().getOperationsContext().getRemoteFetcher(), researcherCriteriaRequest); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE)); } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/researchers/create"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> create(@RequestBody eu.eudat.models.data.researcher.Researcher researcher, Principal principal) throws Exception { - ResearcherManager.create(this.getApiContext(), researcher); + this.researcherManager.create(this.getApiContext(), researcher); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Services.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Services.java index 0956e3fdc..94877577d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Services.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Services.java @@ -40,7 +40,7 @@ public class Services extends BaseController { } @Transactional - @RequestMapping(method = RequestMethod.POST, value = {"/services/create"}, consumes = "application/json", produces = "application/json") + @RequestMapping(method = RequestMethod.POST, value = {"/services"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> create(@RequestBody ServiceModel serviceModel, Principal principal) throws Exception { Service service = ServiceManager.create(this.getApiContext(), serviceModel); diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java index 8a48e14d6..1101a634a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java @@ -35,13 +35,13 @@ public class TagController extends BaseController { this.datasetRepository = tagRepository; } - @Transactional + /*@Transactional @RequestMapping(method = RequestMethod.POST, value = {"/tag/create"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity> create(@RequestBody Dataset dataset) throws IOException { Dataset tagEntity = this.datasetRepository.createOrUpdate(dataset); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().payload(dataset).status(ApiMessageCode.SUCCESS_MESSAGE)); - } + }*/ @RequestMapping(method = RequestMethod.GET, value = {"/external/tags"}, produces = "application/json") public @ResponseBody diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java index 448478f6b..2afb85cd5 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java @@ -9,6 +9,7 @@ import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel; import eu.eudat.models.data.security.Principal; import eu.eudat.queryable.QueryableList; import eu.eudat.logic.services.ApiContext; +import org.springframework.stereotype.Component; import java.util.List; import java.util.UUID; @@ -17,6 +18,7 @@ import java.util.concurrent.CompletableFuture; /** * Created by ikalyvas on 3/21/2018. */ +@Component public class DataManagementProfileManager { public DataTableData getPaged(ApiContext apiContext, DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception { @@ -51,7 +53,7 @@ public class DataManagementProfileManager { return datamanagementPlans; } - public static void createOrUpdate(ApiContext apiContext, DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel, Principal principal) throws Exception { + public void createOrUpdate(ApiContext apiContext, DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel, Principal principal) throws Exception { DMPProfile dmpProfile = dataManagementPlanProfileListingModel.toDataModel(); apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataRepositoryManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataRepositoryManager.java index 7a9fef17d..85542226d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataRepositoryManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataRepositoryManager.java @@ -4,12 +4,14 @@ import eu.eudat.data.entities.DataRepository; import eu.eudat.data.entities.Researcher; import eu.eudat.logic.services.ApiContext; import eu.eudat.models.data.datarepository.DataRepositoryModel; +import org.springframework.stereotype.Component; /** * Created by ikalyvas on 9/3/2018. */ +@Component public class DataRepositoryManager { - public static DataRepository create(ApiContext apiContext, eu.eudat.models.data.datarepository.DataRepositoryModel dataRepositoryModel) throws Exception { + public DataRepository create(ApiContext apiContext, eu.eudat.models.data.datarepository.DataRepositoryModel dataRepositoryModel) throws Exception { DataRepository dataRepository = dataRepositoryModel.toDataModel(); return apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().createOrUpdate(dataRepository); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index f40c07b64..78ebb8a69 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -17,6 +17,7 @@ import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.queryable.QueryableList; import org.springframework.http.*; +import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -24,10 +25,10 @@ import org.w3c.dom.Element; import javax.xml.xpath.*; import java.util.*; - +@Component public class DatasetProfileManager { - public static List getWithCriteria(DatasetProfileDao datasetProfileRepository, DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException { + public List getWithCriteria(DatasetProfileDao datasetProfileRepository, DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException { QueryableList items = datasetProfileRepository.getWithCriteria(datasetProfileAutocompleteRequest.getCriteria()); List datasetProfiles = items.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item)); return datasetProfiles; @@ -40,20 +41,20 @@ public class DatasetProfileManager { return profile; } - public static DataTableData getPaged(ApiContext apiContext, DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception { + public DataTableData getPaged(ApiContext apiContext, DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception { QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria()); QueryableList pagedItems = PaginationManager.applyPaging(items, datasetProfileTableRequestItem); List datasetProfiles = pagedItems.select(item -> new DatasetProfileListingModel().fromDataModel(item)); return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build(); } - public static List getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException { + public List getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException { QueryableList items = datasetProfileRepository.getAll(); List datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); return datasetProfiles; } - public static eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException { + public eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field queryForField(String xml, String fieldId) throws XPathExpressionException { eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field field = new Field(); Document document = XmlBuilder.fromXml(xml); XPathFactory xpathFactory = XPathFactory.newInstance(); @@ -65,7 +66,7 @@ public class DatasetProfileManager { return field; } - public static List> getAutocomplete(AutoCompleteData data, String like) { + public List> getAutocomplete(AutoCompleteData data, String like) { List> result = new LinkedList<>(); RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ExternalDatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ExternalDatasetManager.java index b0579b146..43300e9d8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ExternalDatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ExternalDatasetManager.java @@ -13,11 +13,12 @@ import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.proxy.fetching.RemoteFetcher; import eu.eudat.queryable.QueryableList; import eu.eudat.logic.services.ApiContext; +import org.springframework.stereotype.Component; import java.util.List; import java.util.UUID; - +@Component public class ExternalDatasetManager { public DataTableData getPaged(ApiContext apiContext, ExternalDatasetTableRequest externalDatasetTableRequest) throws Exception { @@ -41,7 +42,7 @@ public class ExternalDatasetManager { return externalDatasetModel; } - public static ExternalDataset create(ApiContext apiContext, eu.eudat.models.data.externaldataset.ExternalDatasetModel externalDatasetModel) throws Exception { + public ExternalDataset create(ApiContext apiContext, eu.eudat.models.data.externaldataset.ExternalDatasetModel externalDatasetModel) throws Exception { ExternalDataset externalDataset = externalDatasetModel.toDataModel(); return apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().createOrUpdate(externalDataset); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RegistryManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RegistryManager.java index 285caae5d..e7ffe9f44 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RegistryManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RegistryManager.java @@ -5,12 +5,14 @@ import eu.eudat.data.entities.Registry; import eu.eudat.logic.services.ApiContext; import eu.eudat.models.data.datarepository.DataRepositoryModel; import eu.eudat.models.data.registries.RegistryModel; +import org.springframework.stereotype.Component; /** * Created by ikalyvas on 9/3/2018. */ +@Component public class RegistryManager { - public static Registry create(ApiContext apiContext, RegistryModel registryModel) throws Exception { + public Registry create(ApiContext apiContext, RegistryModel registryModel) throws Exception { Registry registry = registryModel.toDataModel(); return apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().createOrUpdate(registry); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java index 724d1e7ba..68d5fb91b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java @@ -10,6 +10,7 @@ import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.proxy.fetching.RemoteFetcher; import eu.eudat.queryable.QueryableList; import eu.eudat.logic.services.ApiContext; +import org.springframework.stereotype.Component; import java.util.List; import java.util.Map; @@ -17,14 +18,15 @@ import java.util.Map; /** * Created by ikalyvas on 2/5/2018. */ +@Component public class ResearcherManager { - public static Researcher create(ApiContext apiContext, eu.eudat.models.data.researcher.Researcher researcher) throws Exception { + public Researcher create(ApiContext apiContext, eu.eudat.models.data.researcher.Researcher researcher) throws Exception { Researcher researcherEntity = researcher.toDataModel(); return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity); } - public static List getCriteriaWithExternal(ApiContext apiContext, RemoteFetcher remoteFetcher, ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSet, NoURLFound { + public List getCriteriaWithExternal(ApiContext apiContext, RemoteFetcher remoteFetcher, ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSet, NoURLFound { QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria()); List researchers = items.select(item -> new eu.eudat.models.data.dmp.Researcher().fromDataModel(item)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/external/OrganisationsExternalSourcesModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/external/OrganisationsExternalSourcesModel.java index 97e688bf4..8a9afa217 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/external/OrganisationsExternalSourcesModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/external/OrganisationsExternalSourcesModel.java @@ -1,9 +1,11 @@ package eu.eudat.models.data.external; +import org.springframework.stereotype.Component; + import java.util.List; import java.util.Map; - +@Component public class OrganisationsExternalSourcesModel extends ExternalListingItem { @Override public OrganisationsExternalSourcesModel fromExternalItem(List> values) { diff --git a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts index 16ccf85a7..32ccf858c 100644 --- a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts +++ b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts @@ -39,6 +39,6 @@ export class DatasetProfileService { } clone(id: string): Observable { - return this.http.post(environment.Server + 'datasetprofile/clone/' + id, {}); + return this.http.post(this.actionUrl + 'datasetprofile/clone/' + id, {}); } } diff --git a/dmp-frontend/src/app/core/services/dmp/dmp-profile.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp-profile.service.ts index 851c27427..f44cf70ee 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp-profile.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp-profile.service.ts @@ -29,10 +29,6 @@ export class DmpProfileService { } createDmp(dataManagementPlanModel: DmpProfile): Observable { - return this.http.post(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers }); - } - - getAll(criteria: RequestItem): Observable { - return this.http.post(this.actionUrl + 'get/', criteria, { headers: this.headers }); + return this.http.post(this.actionUrl, dataManagementPlanModel, { headers: this.headers }); } } diff --git a/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts b/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts index 58e2ab577..43a8d6f3c 100644 --- a/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts @@ -9,11 +9,11 @@ export class ExternalDataRepositoryService { private actionUrl: string; constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'datarepos/'; + this.actionUrl = environment.Server + 'external/datarepos'; } create(dataRepoModel: DataRepositoryModel): Observable { - return this.http.post(this.actionUrl + 'create', dataRepoModel); + return this.http.post(this.actionUrl , dataRepoModel); } } diff --git a/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts b/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts index 103777966..19ef67bd5 100644 --- a/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts @@ -16,23 +16,7 @@ export class ExternalDatasetService { this.actionUrl = environment.Server + 'externaldatasets/'; } - getPaged(dataTableRequest: DataTableRequest): Observable> { - return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest); - } - - /* get(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'get', requestItem); - }*/ - - getWithExternal(requestItem: RequestItem): Observable { - return this.http.post(this.actionUrl + 'getWithExternal', requestItem); - } - - getSingle(id: string): Observable { - return this.http.get(this.actionUrl + 'getSingle/' + id); - } - create(externalDatasetModel: ExternalDatasetModel): Observable { - return this.http.post(this.actionUrl + 'create', externalDatasetModel); + return this.http.post(this.actionUrl, externalDatasetModel); } } diff --git a/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts b/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts index 11cac4e6d..94b684044 100644 --- a/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts @@ -65,6 +65,7 @@ export class ExternalSourcesService { return this.http.get(this.actionUrl + 'organisations' + '?query=' + like, { headers: this.headers }); }//organizationscriteria.criteria.like + // TODO: currently not used. public searchDMPProfiles(like: string): Observable { return this.http.get(this.actionUrl + 'datasetprofiles/get' + '?query=' + like, { headers: this.headers }); } diff --git a/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts b/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts index 0006f62f0..163390444 100644 --- a/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts @@ -13,6 +13,6 @@ export class ExternalRegistryService { } create(registerModel: RegistryModel): Observable { - return this.http.post(this.actionUrl + 'create', registerModel); + return this.http.post(this.actionUrl, registerModel); } } diff --git a/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts b/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts index 1ccc52750..f51c9cd78 100644 --- a/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts @@ -13,7 +13,7 @@ export class ExternalResearcherService { } public createResearcher(researcher: ResearcherModel) { - return this.http.post(this.actionUrl + 'create', researcher); + return this.http.post(this.actionUrl, researcher); } } diff --git a/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts b/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts index ef556b667..45e7e9193 100644 --- a/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts @@ -13,7 +13,7 @@ export class ExternalServiceService { } create(serviceModel: ServiceModel): Observable { - return this.http.post(this.actionUrl + 'create', serviceModel); + return this.http.post(this.actionUrl, serviceModel); } } From ab460fe5c45aeec41f15cc70ffc5d1f9835a0651 Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Mon, 4 Feb 2019 11:37:42 +0200 Subject: [PATCH 2/2] Fixes bug when ElasticSearch is down. --- .../eudat/logic/managers/DatasetManager.java | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index 91e841d4b..824ded24e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -49,14 +49,22 @@ public class DatasetManager { public DataTableData getPaged(ApiContext apiContext, DatasetTableRequest datasetTableRequest, Principal principal) throws Exception { DatasetCriteria datasetCriteria = new DatasetCriteria(); datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags()); - List datasets = apiContext.getOperationsContext().getDatasetRepository().exists() ? - apiContext.getOperationsContext().getDatasetRepository().query(datasetCriteria) : new LinkedList<>(); + List datasets; + try { + datasets = datasetCriteria.getTags() != null && datasetCriteria.getTags().size() > 0 && apiContext.getOperationsContext().getDatasetRepository().exists() ? + apiContext.getOperationsContext().getDatasetRepository().query(datasetCriteria) : new LinkedList<>(); + } + catch (Exception ex){ + datasets = null; + } UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build(); QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class)); - if (datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()) { - if (!datasets.isEmpty()) - items.where((builder, root) -> root.get("id").in(datasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList()))); + if (datasets != null && datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()) { + if (!datasets.isEmpty()){ + List finalDatasets = datasets; + items.where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList()))); + } else items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()})); } @@ -81,14 +89,21 @@ public class DatasetManager { public DataTableData getPaged(ApiContext apiContext, DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception { DatasetCriteria datasetCriteria = new DatasetCriteria(); datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags()); - List datasets = apiContext.getOperationsContext().getDatasetRepository().exists() ? - apiContext.getOperationsContext().getDatasetRepository().query(datasetCriteria) : new LinkedList<>(); - + List datasets; + try{ + datasets = datasetCriteria.getTags() != null && datasetCriteria.getTags().size() > 0 && apiContext.getOperationsContext().getDatasetRepository().exists() ? + apiContext.getOperationsContext().getDatasetRepository().query(datasetCriteria) : new LinkedList<>(); + } + catch (Exception ex){ + datasets = null; + } datasetTableRequest.setQuery(apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class))); QueryableList items = datasetTableRequest.applyCriteria(); - if (datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()) { - if (!datasets.isEmpty()) - items.where((builder, root) -> root.get("id").in(datasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList()))); + if (datasets != null && datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()) { + if (!datasets.isEmpty()) { + List finalDatasets = datasets; + items.where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList()))); + } else items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()})); } @@ -111,8 +126,14 @@ public class DatasetManager { public DatasetWizardModel getSingle(DatasetDao datatasetRepository, DatasetRepository elasticDatasetRepository, String id) throws InstantiationException, IllegalAccessException, IOException { DatasetWizardModel dataset = new DatasetWizardModel(); eu.eudat.data.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class)); - eu.eudat.elastic.entities.Dataset datasetElastic = elasticDatasetRepository.exists() ? - elasticDatasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset(); + eu.eudat.elastic.entities.Dataset datasetElastic; + try{ + datasetElastic = elasticDatasetRepository.exists() ? + elasticDatasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset(); + } + catch (Exception ex){ + datasetElastic = new eu.eudat.elastic.entities.Dataset(); + } dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity)); dataset.fromDataModel(datasetEntity); dataset.setTags(datasetElastic.getTags());