From 69fc698866802d2e666beb59be2dcac75314022a Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 15 Jul 2020 12:33:10 +0300 Subject: [PATCH 01/10] Unified datasets and datasetWizard Controllers --- .../controllers/DatasetWizardController.java | 224 ----------------- .../java/eu/eudat/controllers/Datasets.java | 230 +++++++++++++++++- .../dataset-wizard/dataset-wizard.service.ts | 4 +- .../dataset-external-autocomplete.service.ts | 2 +- 4 files changed, 220 insertions(+), 240 deletions(-) delete mode 100644 dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java deleted file mode 100644 index c2b9abc43..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java +++ /dev/null @@ -1,224 +0,0 @@ -package eu.eudat.controllers; - -import eu.eudat.data.entities.Dataset; -import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest; -import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest; -import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException; -import eu.eudat.exceptions.security.UnauthorisedException; -import eu.eudat.logic.managers.DatasetManager; -import eu.eudat.logic.managers.DatasetWizardManager; -import eu.eudat.logic.managers.UserManager; -import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; -import eu.eudat.logic.security.claims.ClaimedAuthorities; -import eu.eudat.logic.services.ApiContext; -import eu.eudat.logic.services.forms.VisibilityRuleService; -import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; -import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel; -import eu.eudat.models.data.datasetwizard.DatasetWizardModel; -import eu.eudat.models.data.dmp.AssociatedProfile; -import eu.eudat.models.data.helpers.responses.ResponseItem; -import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel; -import eu.eudat.models.data.security.Principal; -import eu.eudat.models.data.user.composite.PagedDatasetProfile; -import eu.eudat.types.ApiMessageCode; -import eu.eudat.types.Authorities; -import org.apache.poi.util.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.persistence.NoResultException; -import javax.transaction.Transactional; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.util.List; -import java.util.UUID; - -import static eu.eudat.types.Authorities.ANONYMOUS; - - -@RestController -@CrossOrigin -@RequestMapping(value = {"api/datasetwizard"}) -public class DatasetWizardController extends BaseController { - private static final Logger logger = LoggerFactory.getLogger(DatasetWizardController.class); - - private Environment environment; - private DatasetManager datasetManager; - private UserManager userManager; - private ConfigLoader configLoader; - - @Autowired - public DatasetWizardController(ApiContext apiContext, Environment environment, DatasetManager datasetManager, UserManager userManager, ConfigLoader configLoader) { - super(apiContext); - this.environment = environment; - this.datasetManager = datasetManager; - this.userManager = userManager; - this.configLoader = configLoader; - } - - @RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json") - public @ResponseBody - ResponseEntity>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) throws IllegalAccessException, InstantiationException { - List dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, principal); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans)); - } - - @RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json") - public @ResponseBody - ResponseEntity>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws IllegalAccessException, InstantiationException { - List dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), datasetProfileWizardAutocompleteRequest); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans)); - } - - @Transactional - @RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException { - try { - if (contentType.equals("application/xml")) { - VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService(); - return this.datasetManager.getDocument(id, visibilityRuleService, contentType, principal); - } else if (contentType.equals("application/msword")) { - FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); - InputStream resource = new FileInputStream(file.getFile()); - HttpHeaders responseHeaders = new HttpHeaders(); - responseHeaders.setContentLength(file.getFile().length()); - responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); - responseHeaders.set("Content-Disposition", "attachment;filename=" + file.getFilename()); - responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); - responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); - - byte[] content = IOUtils.toByteArray(resource); - resource.close(); - Files.deleteIfExists(file.getFile().toPath()); - return new ResponseEntity<>(content, - responseHeaders, - HttpStatus.OK); - } else { - DatasetWizardModel dataset = this.datasetManager.getSingle(id, principal); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); - } - } catch (Exception e) { - if (e instanceof UnauthorisedException) { - if (e instanceof UnauthorisedException) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); - } else if (e instanceof NoResultException) { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); - } else { - throw e; - } - } - } - return null; // ???? - } - - @RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity getSinglePublic(@PathVariable String id) throws Exception { - try { - DatasetWizardModel dataset = this.datasetManager.getSinglePublic(id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); - } - catch (Exception ex) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage())); - } - } - - @Transactional - @RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity> delete(@PathVariable(value = "id") UUID id, Principal principal) throws Exception { - new DatasetWizardManager().delete(this.getApiContext(), id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted")); - } - - @Transactional - @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) throws Exception { - this.datasetManager.createOrUpdate(profile, principal); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(null)); - } - - @RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"}) - public @ResponseBody - ResponseEntity getPDFDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException { - FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); - String fileName = file.getFilename(); - if (fileName.endsWith(".docx")){ - fileName = fileName.substring(0, fileName.length() - 5); - } - File pdffile = datasetManager.convertToPDF(file, environment); - InputStream resource = new FileInputStream(pdffile); - - HttpHeaders responseHeaders = new HttpHeaders(); - responseHeaders.setContentLength(pdffile.length()); - responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); - responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".pdf"); - responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); - responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); - - byte[] content = IOUtils.toByteArray(resource); - resource.close(); - Files.deleteIfExists(file.getFile().toPath()); - Files.deleteIfExists(pdffile.toPath()); - return new ResponseEntity<>(content, - responseHeaders, - HttpStatus.OK); - } - - @RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json") - public ResponseEntity> getSingle(@PathVariable String id) { - eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); - eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile); - PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); - pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile)); - } - - @Transactional - @RequestMapping(method = RequestMethod.GET, value = {"/{id}/unlock"}, produces = "application/json") - public @ResponseBody - ResponseEntity> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception { - try { - new DatasetWizardManager().unlock(this.getApiContext(), id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked")); - } catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage())); - } - } - - @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity datasetXmlImport(@RequestParam("file") MultipartFile file, @RequestParam("dmpId") String dmpId, @RequestParam("datasetProfileId") String datasetProfileId, Principal principal) { - try { - Dataset dataset = this.datasetManager.createDatasetFromXml(file, dmpId, datasetProfileId, principal); - if (dataset != null){ - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); - } - else { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful.")); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful.")); - } - } - - @RequestMapping(method = RequestMethod.GET, value = {"profile/{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity getSingleProfileUpdate(@PathVariable String id, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException { - DatasetWizardModel dataset = this.datasetManager.datasetUpdateProfile(id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java index 781237cab..00a7431b9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Datasets.java @@ -1,45 +1,84 @@ package eu.eudat.controllers; import eu.eudat.data.entities.Dataset; +import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest; +import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest; import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest; import eu.eudat.data.query.items.table.dataset.DatasetTableRequest; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; +import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException; import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.managers.DatasetWizardManager; +import eu.eudat.logic.managers.UserManager; +import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.services.ApiContext; +import eu.eudat.logic.services.forms.VisibilityRuleService; +import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.models.data.dataset.DatasetOverviewModel; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; +import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel; +import eu.eudat.models.data.datasetwizard.DatasetWizardModel; +import eu.eudat.models.data.dmp.AssociatedProfile; import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.responses.ResponseItem; +import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel; import eu.eudat.models.data.listingmodels.DatasetListingModel; import eu.eudat.models.data.security.Principal; +import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.types.ApiMessageCode; import eu.eudat.types.Authorities; +import org.apache.poi.util.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import javax.persistence.NoResultException; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.util.List; import java.util.Locale; import java.util.UUID; +import static eu.eudat.types.Authorities.ANONYMOUS; + @RestController @CrossOrigin @RequestMapping(value = {"/api/datasets/"}) public class Datasets extends BaseController { + private static final Logger logger = LoggerFactory.getLogger(Datasets.class); + private Environment environment; private DatasetManager datasetManager; + private ConfigLoader configLoader; + private UserManager userManager; @Autowired - public Datasets(ApiContext apiContext, DatasetManager datasetManager) { + public Datasets(ApiContext apiContext, Environment environment, DatasetManager datasetManager, ConfigLoader configLoader, UserManager userManager) { super(apiContext); + this.environment = environment; this.datasetManager = datasetManager; + this.configLoader = configLoader; + this.userManager = userManager; } + /* + * Data Retrieval + * */ + @RequestMapping(method = RequestMethod.POST, value = {"paged"}, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception { @@ -81,12 +120,46 @@ public class Datasets extends BaseController { // } } - @Transactional - @RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"}, produces = "application/json") + @javax.transaction.Transactional + @RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json") public @ResponseBody - ResponseEntity> makePublic(@PathVariable UUID id, Principal principal, Locale locale) throws Exception { - this.datasetManager.makePublic(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message(this.getApiContext().getHelpersService().getMessageSource().getMessage("dataset.public", new Object[]{}, locale))); + ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException { + try { + if (contentType.equals("application/xml")) { + VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService(); + return this.datasetManager.getDocument(id, visibilityRuleService, contentType, principal); + } else if (contentType.equals("application/msword")) { + FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); + InputStream resource = new FileInputStream(file.getFile()); + HttpHeaders responseHeaders = new HttpHeaders(); + responseHeaders.setContentLength(file.getFile().length()); + responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); + responseHeaders.set("Content-Disposition", "attachment;filename=" + file.getFilename()); + responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); + responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); + + byte[] content = IOUtils.toByteArray(resource); + resource.close(); + Files.deleteIfExists(file.getFile().toPath()); + return new ResponseEntity<>(content, + responseHeaders, + HttpStatus.OK); + } else { + DatasetWizardModel dataset = this.datasetManager.getSingle(id, principal); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); + } + } catch (Exception e) { + if (e instanceof UnauthorisedException) { + if (e instanceof UnauthorisedException) { + return ResponseEntity.status(HttpStatus.FORBIDDEN).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); + } else if (e instanceof NoResultException) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE)); + } else { + throw e; + } + } + } + return null; // ???? } @RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDatasets/paged"}, produces = "application/json") @@ -96,6 +169,143 @@ public class Datasets extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); } + @RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json") + public @ResponseBody + ResponseEntity>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) throws IllegalAccessException, InstantiationException { + List dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, principal); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans)); + } + + @RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json") + public @ResponseBody + ResponseEntity>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws IllegalAccessException, InstantiationException { + List dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), datasetProfileWizardAutocompleteRequest); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlans)); + } + + @RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"}, produces = "application/json") + public @ResponseBody + ResponseEntity getSinglePublic(@PathVariable String id) throws Exception { + try { + DatasetWizardModel dataset = this.datasetManager.getSinglePublic(id); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); + } + catch (Exception ex) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage())); + } + } + + @RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json") + public ResponseEntity> getSingle(@PathVariable String id) { + eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile); + PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile(); + pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile)); + } + + @RequestMapping(method = RequestMethod.GET, value = {"profile/{id}"}, produces = "application/json") + public @ResponseBody + ResponseEntity getSingleProfileUpdate(@PathVariable String id, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException { + DatasetWizardModel dataset = this.datasetManager.datasetUpdateProfile(id); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); + } + + /* + * Data Export + * */ + + @RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"}) + public @ResponseBody + ResponseEntity getPDFDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException { + FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); + String fileName = file.getFilename(); + if (fileName.endsWith(".docx")){ + fileName = fileName.substring(0, fileName.length() - 5); + } + File pdffile = datasetManager.convertToPDF(file, environment); + InputStream resource = new FileInputStream(pdffile); + + HttpHeaders responseHeaders = new HttpHeaders(); + responseHeaders.setContentLength(pdffile.length()); + responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM); + responseHeaders.set("Content-Disposition", "attachment;filename=" + fileName + ".pdf"); + responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition"); + responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type"); + + byte[] content = IOUtils.toByteArray(resource); + resource.close(); + Files.deleteIfExists(file.getFile().toPath()); + Files.deleteIfExists(pdffile.toPath()); + return new ResponseEntity<>(content, + responseHeaders, + HttpStatus.OK); + } + + /* + * Data Management + * */ + + @javax.transaction.Transactional + @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") + public @ResponseBody + ResponseEntity> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) throws Exception { + this.datasetManager.createOrUpdate(profile, principal); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(null)); + } + + @Transactional + @RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"}, produces = "application/json") + public @ResponseBody + ResponseEntity> makePublic(@PathVariable UUID id, Principal principal, Locale locale) throws Exception { + this.datasetManager.makePublic(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message(this.getApiContext().getHelpersService().getMessageSource().getMessage("dataset.public", new Object[]{}, locale))); + } + + @javax.transaction.Transactional + @RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json") + public @ResponseBody + ResponseEntity> delete(@PathVariable(value = "id") UUID id, Principal principal) throws Exception { + new DatasetWizardManager().delete(this.getApiContext(), id); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted")); + } + + @javax.transaction.Transactional + @RequestMapping(method = RequestMethod.GET, value = {"/{id}/unlock"}, produces = "application/json") + public @ResponseBody + ResponseEntity> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception { + try { + new DatasetWizardManager().unlock(this.getApiContext(), id); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked")); + } catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage())); + } + } + + /* + * Data Import + * */ + + @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) + public ResponseEntity datasetXmlImport(@RequestParam("file") MultipartFile file, @RequestParam("dmpId") String dmpId, @RequestParam("datasetProfileId") String datasetProfileId, Principal principal) { + try { + Dataset dataset = this.datasetManager.createDatasetFromXml(file, dmpId, datasetProfileId, principal); + if (dataset != null){ + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); + } + else { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful.")); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful.")); + } + } + + /* + * Data Index + * */ + @javax.transaction.Transactional @RequestMapping(method = RequestMethod.POST, value = {"/index"}) public @ResponseBody @@ -112,12 +322,6 @@ public class Datasets extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null)); } - @javax.transaction.Transactional - @RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity> delete(@PathVariable(value = "id") UUID id, Principal principal) throws Exception { - new DatasetWizardManager().delete(this.getApiContext(), id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted")); - } + } diff --git a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts b/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts index 3f1b65a33..4db5fc2ee 100644 --- a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts +++ b/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts @@ -19,7 +19,7 @@ export class DatasetWizardService { private headers = new HttpHeaders(); constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'datasetwizard/'; + this.actionUrl = configurationService.server + 'datasets/'; } // public userDmps(criteria: RequestItem): Observable { @@ -39,7 +39,7 @@ export class DatasetWizardService { } public delete(id: string): Observable { - return this.http.delete(this.actionUrl + id, { headers: this.headers }); + return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); } createDataset(datasetModel: DatasetWizardModel): Observable { diff --git a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts index 21d3f814a..35ee12a6f 100644 --- a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts +++ b/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts @@ -16,7 +16,7 @@ export class DatasetExternalAutocompleteService { private httpClient: HttpClient, private datasetProfileService: DatasetProfileService, private configurationService: ConfigurationService) { - this.actionUrl = configurationService.server + 'datasetwizard/'; + this.actionUrl = configurationService.server + 'datasets/'; } getDatasetProfileById(datasetProfileID) { From d40e9fadbfd66f06af867f036fb763ae0f024725 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 15 Jul 2020 12:35:22 +0300 Subject: [PATCH 02/10] Removed RDA JSON export from Datasets (it doesn't and it can't (cycling dependency)) --- .../core/services/dataset/dataset.service.ts | 7 ++++--- .../overview/dataset-overview.component.html | 5 +++-- .../overview/dataset-overview.component.ts | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset.service.ts index e7306d139..b56e3b19c 100644 --- a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts +++ b/dmp-frontend/src/app/core/services/dataset/dataset.service.ts @@ -90,7 +90,8 @@ export class DatasetService { return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: headerPdf }); } - public downloadJson(id: string): Observable> { - return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' }); - } + //GK: NO + // public downloadJson(id: string): Observable> { + // return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' }); + // } } diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html index 26ed8b1a1..6bef1df73 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html @@ -122,10 +122,11 @@ {{'GENERAL.FILE-TYPES.XML' | translate}} - - - +

{{ 'DMP-LISTING.ACTIONS.MAKE-PUBLIC' | translate }}

+ - @@ -132,7 +132,7 @@
-
+
@@ -145,7 +145,7 @@

{{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }}

-
+
diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.scss b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.scss index 1923ad102..f68c825f8 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.scss +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.scss @@ -30,14 +30,6 @@ // ********BUTTONS******** -.version-btn { - // width: 6.7em; - height: 1.8em; - border: 1px solid #707070; - border-radius: 4px; - background-color: transparent; -} - .id-btn { background: url("../../../../assets/images/NoPath.png") no-repeat center; width: 1em; @@ -194,7 +186,7 @@ } .doi-txt { - font-size: 0.8em; + font-size: 1em; letter-spacing: 0.009em; color: #7d7d7d; width: 12em; @@ -202,6 +194,7 @@ overflow: hidden; border: none; padding: 0px; + background-color: transparent; } .doi-panel { @@ -303,6 +296,17 @@ ::ng-deep .versions-select .mat-form-field-wrapper { background-color: transparent !important; padding-bottom: 0 !important; + width: 6.5rem; +} + +::ng-deep .versions-select .mat-form-field-wrapper .mat-form-field-flex { + padding: 0 0.5rem 0 0.625rem; + margin-bottom: 0.2rem; + font-weight: 500; +} + +::ng-deep mat-select .mat-select-arrow-wrapper { + vertical-align: bottom; } ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index ab89088c8..506537218 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -478,7 +478,10 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { if (result) { this.dmpService.publish(dmpId) .pipe(takeUntil(this._destroyed)) - .subscribe(() => { this.hasPublishButton = false }); + .subscribe(() => { + this.hasPublishButton = false; + this.reloadPage(); + }); } }); } diff --git a/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.html b/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.html index 689af7f41..6c083243a 100644 --- a/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.html +++ b/dmp-frontend/src/app/ui/misc/navigation/user-dialog/user-dialog.component.html @@ -3,7 +3,7 @@
@@ -62,7 +63,7 @@
-
FAQs
+
About
FAQs
@@ -188,8 +189,9 @@
diff --git a/dmp-frontend/src/assets/splash/about/how-it-works.html b/dmp-frontend/src/assets/splash/about/how-it-works.html index 7446523a2..622912912 100644 --- a/dmp-frontend/src/assets/splash/about/how-it-works.html +++ b/dmp-frontend/src/assets/splash/about/how-it-works.html @@ -35,6 +35,7 @@ How it works Roadmap faqs + Contributors
@@ -59,12 +60,12 @@
-
How it works
+
About
-
+
How it works
-

+

ARGOS is the joint effort of OpenAIRE and EUDAT to deliver an open platform for Data Management Planning that addresses FAIR and Open best practices and assumes no barriers for its use and adoption.

@@ -142,8 +143,9 @@
diff --git a/dmp-frontend/src/assets/splash/contact.html b/dmp-frontend/src/assets/splash/contact.html index 4126e1872..77231cacb 100644 --- a/dmp-frontend/src/assets/splash/contact.html +++ b/dmp-frontend/src/assets/splash/contact.html @@ -124,8 +124,9 @@
diff --git a/dmp-frontend/src/assets/splash/css/footer.css b/dmp-frontend/src/assets/splash/css/footer.css index 28cf11a9f..9a8a5b312 100644 --- a/dmp-frontend/src/assets/splash/css/footer.css +++ b/dmp-frontend/src/assets/splash/css/footer.css @@ -41,7 +41,7 @@ .conditions-policy { text-align: left; - text-decoration: underline; + text-decoration: underline !important; font-weight: 400; font-family: 'Roboto',sans-serif; font-size: 1rem; diff --git a/dmp-frontend/src/assets/splash/css/styles.css b/dmp-frontend/src/assets/splash/css/styles.css index 5bfb49ccf..1c2ff9e1e 100644 --- a/dmp-frontend/src/assets/splash/css/styles.css +++ b/dmp-frontend/src/assets/splash/css/styles.css @@ -135,7 +135,7 @@ p a { line-height: 2.75rem; font-family: 'Roboto', sans-serif; font-weight: 300; - color: #FFFFFF; + /* color: #FFFFFF; */ } .title-2 { @@ -323,3 +323,41 @@ hr { max-width: 900px; } } + +.card { + min-height: 14rem; + margin-bottom: 1.875rem; + box-shadow: 0px 3px 6px #00000029; +} + +.card-img { + transform: scale(0.5); +} + +.card-body { + display: flex; + flex-direction: column; + align-items: left; + justify-content: center; + padding: 1rem 1.25rem !important; +} + +.card-text-1 { + font-size: 1.125rem; + font-weight: bold; + text-transform: uppercase; +} + +.card-text-2 { + font-size: 1rem; + font-weight: 400; + opacity: 0.6; +} + +.flag { + border: 10px solid #EEEEEE; + border-radius: 50% !important; + padding-right: 0px !important; + padding-left: 0px !important; + transform: scale(0.45); +} diff --git a/dmp-frontend/src/assets/splash/index.html b/dmp-frontend/src/assets/splash/index.html index 626561f25..5805d69f4 100644 --- a/dmp-frontend/src/assets/splash/index.html +++ b/dmp-frontend/src/assets/splash/index.html @@ -371,8 +371,9 @@
diff --git a/dmp-frontend/src/assets/splash/resources/co-branding.html b/dmp-frontend/src/assets/splash/resources/co-branding.html index ba37601ad..8564ff5c6 100644 --- a/dmp-frontend/src/assets/splash/resources/co-branding.html +++ b/dmp-frontend/src/assets/splash/resources/co-branding.html @@ -102,8 +102,9 @@
diff --git a/dmp-frontend/src/assets/splash/resources/media-kit.html b/dmp-frontend/src/assets/splash/resources/media-kit.html index 527a2e005..53ed9559a 100644 --- a/dmp-frontend/src/assets/splash/resources/media-kit.html +++ b/dmp-frontend/src/assets/splash/resources/media-kit.html @@ -177,8 +177,9 @@
diff --git a/dmp-frontend/src/assets/splash/resources/user-guide.html b/dmp-frontend/src/assets/splash/resources/user-guide.html index 846eb1705..ad06ae075 100644 --- a/dmp-frontend/src/assets/splash/resources/user-guide.html +++ b/dmp-frontend/src/assets/splash/resources/user-guide.html @@ -108,8 +108,9 @@
From 182c2150691674587924ddbfa1ceeba9c3df8f17 Mon Sep 17 00:00:00 2001 From: gpapavgeri Date: Thu, 16 Jul 2020 18:32:56 +0300 Subject: [PATCH 05/10] minor changes in static pages --- .../src/assets/splash/about/contributors.html | 10 +- .../src/assets/splash/about/faqs.html | 8 +- .../src/assets/splash/about/how-it-works.html | 8 +- dmp-frontend/src/assets/splash/contact.html | 9 +- .../src/assets/splash/css/section.css | 7 + dmp-frontend/src/assets/splash/css/styles.css | 20 +-- dmp-frontend/src/assets/splash/index.html | 7 +- .../assets/splash/resources/co-branding.html | 65 +++++--- .../assets/splash/resources/media-kit.html | 142 +++++++++++------- .../assets/splash/resources/user-guide.html | 69 ++++++--- 10 files changed, 222 insertions(+), 123 deletions(-) diff --git a/dmp-frontend/src/assets/splash/about/contributors.html b/dmp-frontend/src/assets/splash/about/contributors.html index 9921203a3..45ad8b4df 100644 --- a/dmp-frontend/src/assets/splash/about/contributors.html +++ b/dmp-frontend/src/assets/splash/about/contributors.html @@ -63,10 +63,10 @@
About
-
Translators
+
Translators
- Flag of Greece + Flag of Greece

Athena Research & Innovation Center

Dimitra Aglamisi, Elli Papadopoulou

@@ -95,7 +95,7 @@
-
@@ -116,7 +116,7 @@
@@ -125,7 +125,7 @@
Unless otherwise indicated, all materials created by OpenAIRE are licenced under
  - +
diff --git a/dmp-frontend/src/assets/splash/about/faqs.html b/dmp-frontend/src/assets/splash/about/faqs.html index ec5a41823..c97557b21 100644 --- a/dmp-frontend/src/assets/splash/about/faqs.html +++ b/dmp-frontend/src/assets/splash/about/faqs.html @@ -66,7 +66,7 @@
About
-
FAQs
+
FAQs
@@ -168,7 +168,7 @@
-
@@ -189,7 +189,7 @@
@@ -198,7 +198,7 @@
Unless otherwise indicated, all materials created by OpenAIRE are licenced under
  - +
diff --git a/dmp-frontend/src/assets/splash/about/how-it-works.html b/dmp-frontend/src/assets/splash/about/how-it-works.html index 622912912..6252fbdf8 100644 --- a/dmp-frontend/src/assets/splash/about/how-it-works.html +++ b/dmp-frontend/src/assets/splash/about/how-it-works.html @@ -63,7 +63,7 @@
About
-
How it works
+
How it works

ARGOS is the joint effort of OpenAIRE and EUDAT to deliver an open platform for Data Management Planning @@ -122,7 +122,7 @@

-
@@ -143,7 +143,7 @@
@@ -152,7 +152,7 @@
Unless otherwise indicated, all materials created by OpenAIRE are licenced under
  - + diff --git a/dmp-frontend/src/assets/splash/contact.html b/dmp-frontend/src/assets/splash/contact.html index 77231cacb..9ff76cce4 100644 --- a/dmp-frontend/src/assets/splash/contact.html +++ b/dmp-frontend/src/assets/splash/contact.html @@ -36,6 +36,7 @@ How it works Roadmap faqs + Contributors @@ -67,7 +68,7 @@
Contact us to learn more
-
+
* Required fields
@@ -104,7 +105,7 @@
-
@@ -124,7 +125,7 @@
@@ -133,7 +134,7 @@
Unless otherwise indicated, all materials created by OpenAIRE are licenced under
  - + diff --git a/dmp-frontend/src/assets/splash/css/section.css b/dmp-frontend/src/assets/splash/css/section.css index 0f0ab10fc..f43025fb5 100644 --- a/dmp-frontend/src/assets/splash/css/section.css +++ b/dmp-frontend/src/assets/splash/css/section.css @@ -124,6 +124,7 @@ section.benefits { box-shadow: 0px 6px 15px #0000001A; border-radius: 36px; opacity: 1; + margin-bottom: 0.5rem; } .benefit-card-title { @@ -216,6 +217,12 @@ section.benefits { padding: 2rem 0rem; } +.list { + font-size: 0.87rem; + color: #212121; + opacity: 0.8; +} + section.media-kit-logo { background: #F3F3F3; opacity: 1; diff --git a/dmp-frontend/src/assets/splash/css/styles.css b/dmp-frontend/src/assets/splash/css/styles.css index 1c2ff9e1e..02cacc8d5 100644 --- a/dmp-frontend/src/assets/splash/css/styles.css +++ b/dmp-frontend/src/assets/splash/css/styles.css @@ -130,30 +130,30 @@ p a { } .title-1 { - text-align: left; - font-size: 2.37rem; line-height: 2.75rem; - font-family: 'Roboto', sans-serif; font-weight: 300; - /* color: #FFFFFF; */ + color: #FFFFFF; } .title-2 { - text-align: left; - font-size: 2.37rem; line-height: 2.75rem; - font-family: 'Roboto', sans-serif; font-weight: 700; color: #FFFFFF; } .title-3 { + opacity: 0.95; +} + +.title-3, .title-4 { + font-weight: 300; + color: #212121; +} + +.title-1, .title-2, .title-3, .title-4 { text-align: left; font-size: 2.37rem; font-family: 'Roboto', sans-serif; - font-weight: 300; - color: #212121; - opacity: 0.95; } .page-title { diff --git a/dmp-frontend/src/assets/splash/index.html b/dmp-frontend/src/assets/splash/index.html index 5805d69f4..d569ff587 100644 --- a/dmp-frontend/src/assets/splash/index.html +++ b/dmp-frontend/src/assets/splash/index.html @@ -36,6 +36,7 @@ How it works Roadmap faqs + Contributors @@ -350,7 +351,7 @@
-
@@ -371,7 +372,7 @@
@@ -380,7 +381,7 @@
Unless otherwise indicated, all materials created by OpenAIRE are licenced under
  - + diff --git a/dmp-frontend/src/assets/splash/resources/co-branding.html b/dmp-frontend/src/assets/splash/resources/co-branding.html index 8564ff5c6..7507fdfa3 100644 --- a/dmp-frontend/src/assets/splash/resources/co-branding.html +++ b/dmp-frontend/src/assets/splash/resources/co-branding.html @@ -9,14 +9,17 @@ - + - + @@ -24,7 +27,9 @@