Compare commits

...

356 Commits

Author SHA1 Message Date
Diamantis Tziotzios e8aef281d4 Merge branch 'Development' 2024-02-22 11:09:31 +02:00
Diamantis Tziotzios 00c6978594 no message 2024-02-22 11:07:51 +02:00
Diamantis Tziotzios 3adb518e61 fixes 2024-02-14 22:10:15 +02:00
Konstantina Galouni eb74ef86b9 rich-text-editor.component.ts: Removed "backgroundColor" from toolbarHiddenButtons & added in customClasses "Highlight" option with custom "highlight" class | _type.scss: Added rules for "blockquote" and ".highlight" (added by rich text editor). 2024-02-13 13:23:13 +02:00
Diamantis Tziotzios a1ee9c82bc fixes 2024-01-31 17:55:08 +02:00
Diamantis Tziotzios 5e5bd39313 no message 2024-01-30 13:26:31 +02:00
Diamantis Tziotzios 5e99cef60e default blueprint update 2024-01-24 16:25:46 +02:00
Diamantis Tziotzios cc7edc2f49 final fixes for #9384 #9153 #9409 #9420 2024-01-24 16:17:06 +02:00
Diamantis Tziotzios a1849c64ca Merge branch 'Development' of https://code-repo.d4science.org/MaDgiK-CITE/argos into Development
# Conflicts:
#	dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts
2024-01-24 14:48:38 +02:00
Diamantis Tziotzios 192220161b fixes 2024-01-24 14:47:37 +02:00
George Kalampokis 87758c3e9a Fix various issues with adding/removing Dataset Templates 2024-01-24 14:31:46 +02:00
Diamantis Tziotzios 83342f5afa docx template update 2024-01-17 17:49:52 +02:00
Diamantis Tziotzios 65cdb3b6ea fixes for #9384 #9153 #9162 #9265 2024-01-17 16:50:12 +02:00
Diamantis Tziotzios 536ba9b900 Fixes for #9152 #9153 #9162 #9265 #9266 #9311 #9312 2024-01-09 09:42:58 +02:00
Alexandros Mandilaras 6bd3302788 sql script fix 2023-11-23 15:16:11 +02:00
Diamantis Tziotzios 4970f5812f fix issues #9152 #9153 #9204 #9208 2023-11-23 13:15:50 +02:00
Diamantis Tziotzios 9fed92dbcb fixes for #9109 #9146 #9148 #9149 #9152 #9153 #9156 #9157 #9158 #9160 #9162 #9163 #9164 #9166 2023-11-03 13:24:01 +02:00
Diamantis Tziotzios 44dab9c19a gitignore changes 2023-11-01 09:41:22 +02:00
Alexandros Mandilaras 54f911d826 typo fixes in greek and english translations 2023-10-23 10:12:17 +03:00
Diamantis Tziotzios 9879050eab cleanup 2023-10-19 17:28:36 +03:00
Diamantis Tziotzios 8a41a7dcd9 Fixes for #9033 #9107 #9105 #9105 2023-10-19 17:27:37 +03:00
Diamantis Tziotzios d60cc144d5 #9033 Description Templates - change "Other" API label to "Custom" 2023-10-18 16:10:12 +03:00
Georgios Kakaletris 9c37e5a073 Update 'README.md' 2023-10-18 12:31:03 +02:00
Georgios Kakaletris 444c1aacb1 Update 'README.md' 2023-10-18 12:27:40 +02:00
Diamantis Tziotzios 59d7383947 added basque contributors at static pages 2023-10-17 13:48:50 +03:00
Diamantis Tziotzios 6caa1af134 Added Basque language 2023-10-16 18:21:22 +03:00
George Kalampokis 74a6019a72 Fix some styling and compilation errors 2023-10-10 12:10:52 +03:00
George Kalampokis 5c903c0f48 Add missing files 2023-10-10 12:04:06 +03:00
George Kalampokis ec8f6a6d48 Add Authentication support for the remote fetcher and rework dataset template's autocomplete sources 2023-10-10 12:03:59 +03:00
Bernaldo Mihasi ecd86f413a show prefilling pop up if only at least one dataset profile has enabled prefilling property 2023-10-06 11:22:23 +03:00
Bernaldo Mihasi c238615b50 add enable prefilling property in description templates 2023-10-06 09:36:35 +03:00
Bernaldo Mihasi 10d0f1fb0e make word list labels and delete icons in finalized description templates disabled 2023-10-05 17:47:00 +03:00
Bernaldo Mihasi 846405435c bug fixes 2023-10-05 09:33:28 +03:00
Bernaldo Mihasi dfc9e14003 update i18n 2023-10-04 17:03:50 +03:00
Bernaldo Mihasi bc1894586b 1) update dmp blueprint listing table view, 2) create clone functionality for dmp blueprints, 3) section description is not required in editor, 4) in the deletion of a dmp blueprint check if any dmps are accosiated with it 2023-10-04 09:43:16 +03:00
Bernaldo Mihasi 2bf0a857bc bug fixes: 1) when creating description template type check only for non deleted types, 2) dmp docx/pdf export: check if system fields exist 3) when creating/updating dmp check if value for extra fields is set, 4) when unchecking the 'Description Templates' checkbox in the blueprint editor, clear any templates selected 2023-10-02 13:57:00 +03:00
Bernaldo Mihasi 3d10e8ad28 add type attribute in xml import/export of a description template 2023-10-02 10:14:14 +03:00
Bernaldo Mihasi 53b61853e1 bug fixes 2023-10-02 09:34:58 +03:00
Bernaldo Mihasi d644b1dc91 [wip] dmp xml upload changes, including section and extra fields information 2023-10-02 09:34:21 +03:00
Bernaldo Mihasi 6b544e4702 bug fixes 2023-09-27 16:57:25 +03:00
Bernaldo Mihasi 0bd3422903 check if blueprint is valid when finalizing in editor 2023-09-27 16:20:54 +03:00
Bernaldo Mihasi 2f4e123ac9 bug fixes 2023-09-27 12:54:18 +03:00
Bernaldo Mihasi c99267d6cc #8998 - implement import/export functionality for dmp blueprints 2023-09-26 09:35:59 +03:00
Bernaldo Mihasi 32c45520b4 make router link for add description buttons pointing to dmp editor 2023-09-25 10:36:04 +03:00
Bernaldo Mihasi 4cef17e999 fix routing in save-and-add-new button in dataset editor 2023-09-22 13:15:32 +03:00
Bernaldo Mihasi 34580f917f check if grant exists in word/pdf export 2023-09-22 12:57:47 +03:00
Bernaldo Mihasi 56a70636c3 min multiplicity check for descriptions in dmp finalization 2023-09-22 11:10:08 +03:00
Bernaldo Mihasi 0c9601d6f0 fix argument passed in getSingleBlueprint 2023-09-22 11:09:04 +03:00
Bernaldo Mihasi 5f3ab00009 [wip] add control in dataset creation/prefilling dialog for max multiplicity of a description template in a dmp section, add control in dmp finalization for min multiplicity of a description template in a dmp section 2023-09-22 09:34:12 +03:00
Bernaldo Mihasi beac6be706 add missing grant checks 2023-09-22 09:31:12 +03:00
Bernaldo Mihasi fbad63ee76 use dmp label in export file names if grant does not exist 2023-09-22 09:29:51 +03:00
Bernaldo Mihasi 9cc42c57e9 comment out download/import xml of a blueprint 2023-09-21 10:21:00 +03:00
Bernaldo Mihasi 79aaf23bb6 add missing grant checks 2023-09-21 10:20:32 +03:00
Bernaldo Mihasi b68070aa01 [wip] add control for the min/max multiplicity of a description template used in a section of a dmp 2023-09-21 09:35:04 +03:00
Bernaldo Mihasi db08662cac fix bug when creating new version or clone a dmp 2023-09-21 09:33:27 +03:00
Bernaldo Mihasi 3c0dce93a8 disable system fields/description templates multiple select input and prefill them if any values exist when blueprint is finalized 2023-09-21 09:31:30 +03:00
Bernaldo Mihasi 69548e5a8b check if grant exists in dmp/dataset elastic entities 2023-09-21 09:29:18 +03:00
Bernaldo Mihasi 367861c050 fix bugs: saving extra fields in dmp, showing draft blueprints when min or max of a description template are not set 2023-09-20 09:34:39 +03:00
Bernaldo Mihasi 93c5918251 make grant funder not mandatory for the creation/new version/clone of dmp 2023-09-18 17:48:54 +03:00
Bernaldo Mihasi bfa310a074 show available profiles of dataset in edit page 2023-09-13 16:04:44 +03:00
Bernaldo Mihasi ec952820b1 update i18n 2023-09-13 15:56:40 +03:00
Bernaldo Mihasi b1a832074d small fixes, (wip) remove description template chip from dmp editor 2023-09-13 15:55:38 +03:00
Diamantis Tziotzios cf6e041154 Merge remote-tracking branch 'origin/refactorArgosModel' into Development
# Conflicts:
#	dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java
#	dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html
2023-09-13 10:01:57 +03:00
Bernaldo Mihasi c1858d582c no message 2023-09-12 15:39:08 +03:00
Bernaldo Mihasi 29f5b6a6cc fix editing dmp page, add section templates to new dataset page 2023-09-12 15:38:23 +03:00
Bernaldo Mihasi 6154a5fa51 fix associated dmps bugs in DMP table, new/existing DmpDatasetProfile entries were not saved/updated 2023-09-12 15:36:06 +03:00
Bernaldo Mihasi 6f5fcabc79 add db scripts: inserting default blueprint, attach that blueprint as profile of each dmp, make each dataset section index correspond to the default blueprint last section 2023-09-12 15:24:25 +03:00
Bernaldo Mihasi bbe4975176 add hasTemplates property to sections, it indicates if descriptions templates can be added in a section 2023-09-11 08:59:47 +03:00
Bernaldo Mihasi 4219d90039 add "DmpSectionIndex" column to descriptions in order to know in which section of a dmp the description belongs, add "data" column in DmpDatasetProfile table, data stores in which sections a description template is saved 2023-09-11 08:57:09 +03:00
Bernaldo Mihasi 6073c4cd85 [WIP] refactor dmp export following the blueprint schema 2023-09-11 08:42:30 +03:00
Bernaldo Mihasi cd80e78e40 add status to description template types, fix bugs in editor/listing 2023-09-11 08:40:03 +03:00
George Kalampokis 5019bc4271 Add manual addition of total users in prometheus 2023-08-04 11:55:46 +03:00
Bernaldo Mihasi 3564cc16ff update i18n - link new 2023-08-03 17:07:35 +03:00
Diamantis Tziotzios 3b76397c24 conf cleanup 2023-08-03 13:27:01 +03:00
Bernaldo Mihasi 78946de1b5 change images source in emails to base64
(cherry picked from commit b94aa51489)
2023-08-03 13:26:27 +03:00
Diamantis Tziotzios c39c162979 Merge branch 'Development' of https://code-repo.d4science.org/MaDgiK-CITE/argos into Development 2023-08-03 13:17:59 +03:00
Konstantinos Triantafyllou 655483b8e2 Dateset Edtitor: Scroll to top in Main info. Add checkVisibility in recursion of progress bar status calculation. Increase time of selected entry in tableofcontents 2023-08-03 13:11:19 +03:00
Bernaldo Mihasi 17dbd198ad fix dmp blueprint editor screen 2023-08-03 13:10:36 +03:00
Bernaldo Mihasi b94aa51489 change images source in emails to base64 2023-08-03 11:19:33 +03:00
Diamantis Tziotzios b6cade6e88 metrics change
(cherry picked from commit 903026e2c2)
2023-08-03 10:28:56 +03:00
Diamantis Tziotzios 903026e2c2 metrics change 2023-08-03 10:28:18 +03:00
Bernaldo Mihasi 59cba483b6 Merge branch 'Development' of https://code-repo.d4science.org/MaDgiK-CITE/argos into Development 2023-08-01 11:24:27 +03:00
Bernaldo Mihasi 30abe4d4c9 #8952 - fix bug when merging two accounts did not have consistent behaviour. 2023-08-01 11:23:06 +03:00
Konstantinos Triantafyllou a4555f7303 Fix progress-bar for dmp editor. Fix table of contents in creation of DMP. On save of new dmp, change location instead of route. 2023-07-31 16:38:20 +03:00
Bernaldo Mihasi 634d49ea35 #8916 - when merging acoounts, save the main profile user as collaborator to elastic dmps/datasets 2023-07-27 10:07:40 +03:00
Bernaldo Mihasi e01709f886 #8936 - fix bug when pid of object fetched was integer(PIC typed) instead of string 2023-07-27 10:06:04 +03:00
Bernaldo Mihasi 09d6528f8f #8855 - #8856 - #8901 - #8902 [wip] implementing dmp blueprints 2023-07-25 15:51:29 +03:00
Bernaldo Mihasi 128b47d9c3 #8845 - #8846: adding description template types, creation of description template type field in the dataset template editor, [wip] creation of admin page for creation/editing/deleting of description template types 2023-07-25 15:27:15 +03:00
Bernaldo Mihasi bc279b1610 #8843 - 1. refactor the DatasetProfile Table to DescriptionTemplate name 2. add scripts for the new DescriptionTemplateType table 3. update english localization + frontend 2023-07-25 15:04:39 +03:00
Konstantinos Triantafyllou a737fec19d Progress Bar: Add condition for visibillity if a field has id. 2023-07-25 14:48:13 +03:00
Bernaldo Mihasi 3fc307c831 #8912: adding new metadata/registries api in the configs 2023-07-21 17:04:41 +03:00
Bernaldo Mihasi ee90ac37b6 no message 2023-07-20 13:34:56 +03:00
Bernaldo Mihasi 0918e55ac9 fix bug in dataset template editor when a field is an admin-input api and couldn't fetch results 2023-07-20 13:07:05 +03:00
Bernaldo Mihasi 2db9ea613f catch error in prefilling when source mapping does not exist in the api's response 2023-07-20 13:00:24 +03:00
Konstantina Galouni e878310b72 #8834: Home page: Drafts query for both Datasets and DMPs.
1. RecentActivityCriteria.java: Added in RecentActivityCriteria field "private Integer status;", to be able to get only drafts.
2. DashBoardManager.java: In method "getNewRecentActivity()", add in Dataset and DMP requests status in criteria.
2023-07-17 18:10:49 +03:00
Konstantina Galouni e4af3bcbe9 Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development 2023-07-17 18:06:05 +03:00
Konstantina Galouni 77f40570ac #8834: Home page: Drafts query for both Datasets and DMPs.
1. recent-activity-criteria.ts: Added in RecentActivityCriteria optional field "public status?: Number;" (to get only drafts).
2. drafts.component.ts & drafts.component.html: Updated calls and display to query for both Datasets and DMPs (same as recent-edited-activity, but include only drafts).
4. recent-edited-activity.component.ts: Removed old unnecessary logs.
2023-07-17 18:04:39 +03:00
Konstantinos Triantafyllou 7bc4f4055c Fix progress indicator in prifilled dataset form. #8764 2023-07-17 17:38:25 +03:00
Konstantinos Triantafyllou aec7126fd3 Add valid condition in progress calculatiion of a form 2023-07-17 16:34:43 +03:00
Bernaldo Mihasi dd6a2a0df7 adding key property in the prefilling model as the identifier of the prefilling repository 2023-07-17 10:29:06 +03:00
Bernaldo Mihasi 1715463422 fix bugs in rda json export when rda semantics don't correspond to valid dataset field input type 2023-07-14 13:56:08 +03:00
Bernaldo Mihasi a8ce14af70 #8726 - adding openaire prefilling 2023-07-14 13:47:01 +03:00
Bernaldo Mihasi 1a15e1ddde add missing logger to Prefilling Mapper 2023-07-03 17:09:15 +03:00
Bernaldo Mihasi 000882cbdb 1) fix bug when tags don't show after saving the dataset
2) save the email when user logs in with orcid
3) refactor unlink, delete credential of user to be unlinked
2023-07-03 11:40:35 +03:00
Bernaldo Mihasi 1c0562d7e7 catch error when a field's external api is not available and interrupts prefilling process 2023-06-26 14:16:41 +03:00
Bernaldo Mihasi 8fbc20c823 no message 2023-06-23 10:43:03 +03:00
Bernaldo Mihasi 469a8b4def add config properties to zenodo.json 2023-06-23 10:33:58 +03:00
Bernaldo Mihasi cb972c394c change maDmpTarget type in prefilling to semanticTarget 2023-06-22 13:47:01 +03:00
Bernaldo Mihasi d996acdcc4 #8842 - add notification templates html files to application properties 2023-06-21 13:09:20 +03:00
Bernaldo Mihasi 741179a53f #8740 - multiple configuration for a deposit repository 2023-06-21 12:46:37 +03:00
Bernaldo Mihasi 3630727fed dmp profile bug fixes: 1) dmp profile was not saved 2) if you select external autocomplete field and change it to another type, the external field was saved 2023-06-21 12:20:30 +03:00
Bernaldo Mihasi 34e4761811 bug fixes regarding tickets: #8739, #8763, #8833 2023-06-21 12:17:22 +03:00
Bernaldo Mihasi dfa2f0cd38 #8737 - make elastic fetch 100 inner hits instead of the default 3. 2023-06-21 12:05:51 +03:00
Bernaldo Mihasi 3d367b0589 #8765 - make pids coming from apis as hypelinks in export 2023-06-21 12:00:20 +03:00
Bernaldo Mihasi b6505cda4e refactor signing of saml2 authentication request 2023-06-21 11:51:26 +03:00
Diamantis Tziotzios 50c96ef821 Merge branch 'Development' 2023-06-20 09:39:15 +03:00
Konstantina Galouni 1a2a93a95f #8738 - Disable input fields in finalised DMPs/datasets.
1. dataset-editor.component.html & form-composite-field.component.html & form-field.component.html & form-section.component.html: Added [editable] parameter input in <rich-text-editor-component> or [disabled] attribute in inputs, buttons, <ngx-dropzone> and <mat-select> to disable then when form is disabled & do not add "pointer" class when form is disabled.
2. form-field.component.ts: For DatasetIdentifier and Validation view styles, when removing and re-adding control, check if form was disabled and disable it again.
3. form-section.component.ts: In method "addMultipleField()", return without doing anything when form is disabled.
2023-06-16 14:36:24 +03:00
Konstantina Galouni eb4f1d23e1 dataset-description.component.html: [Bug fix] Removed forgotten log {{form | json}} from html. 2023-06-16 14:19:07 +03:00
Konstantina Galouni 985b3de385 rich-text-editor.component.ts: Removed "backgroundColor" from toolbarHiddenButtons | Do not show (x) close to clear the input when editable is false. 2023-06-16 14:10:52 +03:00
Bernaldo Mihasi 2aa1f76aab use sha256 with rsa keys for saml2, fix bug for authentication request's id 2023-06-13 15:47:18 +03:00
Bernaldo Mihasi 5cd1803e3a fix bug where empty input was saved in multiple auto complete fields 2023-06-13 11:52:50 +03:00
Bernaldo Mihasi 1f666a5bf9 create saml2 authentication request in backend 2023-06-13 09:48:54 +03:00
Bernaldo Mihasi 4c9652abc3 saml2 metadata creation for sp 2023-06-12 15:05:51 +03:00
Bernaldo Mihasi ce50a72ac1 seperate tags in dataset editor using enter or comma 2023-06-07 13:54:31 +03:00
Bernaldo Mihasi f20b420c2c disable unlink action in profile section when email is the as the main profile's mail 2023-06-06 11:16:19 +03:00
Bernaldo Mihasi 730b60598a fix bug when dmp has been deposited in a repository and that repository does not exist any more. 2023-06-01 12:15:22 +03:00
Konstantina Galouni 4bac942059 co-branding.html & styles.css & section.css: #8333 - Updated splash page - added section "Accessing to ARGOS / OpenDMP source code". 2023-05-30 13:21:30 +03:00
Bernaldo Mihasi 22dc9647f3 remove unused variable 2023-05-23 17:18:06 +03:00
Bernaldo Mihasi b2f2a79a5d add unlink functionality in profile section, when an email is unlinked that account is starting from scratch resulting in an empty dashboard. 2023-05-23 17:15:11 +03:00
Bernaldo Mihasi 5e764559cf fix typo (semantics) 2023-05-19 12:34:08 +03:00
Bernaldo Mihasi a3ee9dccda update deposit base repository version 2023-05-18 15:48:12 +03:00
Bernaldo Mihasi 758539eaa0 add zenodo related identifiers for schematics 2023-05-17 13:51:21 +03:00
Bernaldo Mihasi af8fddb89c #7911 - read pid and pid type from external api respones so as to save those values in the dataset field 2023-05-17 13:45:12 +03:00
Konstantina Galouni b435994c51 #8148 - [Bug fix] drafts.component.ts & recent-edited-activity.component.ts & recent-edited-dataset-activity.component.ts & recent-edited-dmp-activity.component.ts: Updated check to redirect to first page, if page parameter is bigger than the latest page. 2023-05-15 00:43:45 +03:00
Konstantina Galouni 0adc7044ab h2020.docx: [Bug fix] Updated image of Argos in h2020.docx DMP template | DataManagementPlanManager.java & DatasetManager.java: Added parameter "isDataset" in fillFirstPage() | WordBuilder.java: [Bug fix] Added parameter isDataset in fillFirstPage() and added some checks in description.
(cherry picked from commit c9b4b35e39)
2023-05-09 10:33:44 +03:00
Konstantinos Triantafyllou 0d9b6f9622 Fix bug where on long click, blur value was added in the list of chips. 2023-05-03 12:34:17 +03:00
Bernaldo Mihasi 5d5ebe7a55 update about, glossary, terms pages when language changes. 2023-05-02 13:48:07 +03:00
Bernaldo Mihasi 7c347569fd update user guide when language changes. 2023-05-02 12:56:09 +03:00
Konstantinos Triantafyllou 50169222c7 Fix infinite loop in home page when total number of results is less than the page size 2023-04-28 16:10:32 +03:00
Konstantinos Triantafyllou e84398f667 Close autocomplete panel if a blur value is added. 2023-04-28 12:56:01 +03:00
Bernaldo Mihasi a1fd03a444 fix out of memory error in management endpoints. 2023-04-26 17:27:21 +03:00
Bernaldo Mihasi 8c30c558b2 User Guide, ToS, FAQ, Glossary, About html pages can now be dynamically updated so that they can be changed per installation. 2023-04-26 17:25:59 +03:00
Konstantina Galouni 2715db7365 #8148 - Added paging functionality with load more/ less buttons in home page, for the existing 4 tabs - ordering and keyword are also added in the url and they are resolved on page reload.
1. i18n/: Added properties "GENERAL.ACTIONS.LOAD-LESS" and "GENERAL.ACTIONS.NO-MORE-AVAILABLE".
2. dashboard.component.html: Added aria-label on each <mat-tab> | Added on <mat-tab-group> bindings for [selectedIndex] and (selectedTabChange), to define the active tab.
3. dashboard.component.ts: Added field currentType: string = "recent"; | Set currentType by url params | Added method get indexFromCurrentType(), to return the active tab index.
4. drafts.component.html & recent-edited-activity.component.html & recent-edited-dataset-activity.component.html & recent-edited-dmp-activity.component.html: Added button "LOAD-LESS" and message "NO-MORE-AVAILABLE" to the end of the list.
5. drafts.component.ts & recent-edited-activity.component.ts & recent-edited-dataset-activity.component.ts & recent-edited-dmp-activity.component.ts:
   a. Added fields @ViewChild("...") resultsContainer, offsetLess: number = 0, hasMoreResults:boolean = true, page: number = 1 and @Input() isActive: boolean = false.
   b. Read url params, set offsets and query filters and update url.
   c. Renamed "loadMore()" to "loadNextOrPrevious()" and added parameter more: boolean = true.
2023-04-25 17:55:31 +03:00
Diamantis Tziotzios eb1abb1f24 more css changes 2023-04-25 11:26:20 +03:00
Diamantis Tziotzios 92f56c073c more css changes 2023-04-25 11:10:45 +03:00
Diamantis Tziotzios 6585fcf391 update lang files to make app name configurable. 2023-04-24 16:11:38 +03:00
Bernaldo Mihasi 5d7e2cb307 add seperator keycodes for schematics field 2023-04-20 16:43:15 +03:00
Konstantinos Triantafyllou 681f73b865 Dataset template editor: On multiplicity changed, reset multiplicity values including table view and placeholder. 2023-04-20 16:01:21 +03:00
Konstantinos Triantafyllou ef0816524f Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development 2023-04-20 15:27:53 +03:00
Konstantinos Triantafyllou b6709bac3c Increase debounce time in multi auto complete in order to avoid addition of search value and first option from dropdown in chips'list. 2023-04-20 15:27:38 +03:00
Bernaldo Mihasi 7b12d7b46d temporarily endpoint for appending "rda." in schematic values of dataset profiles 2023-04-20 10:12:55 +03:00
Bernaldo Mihasi 5733796674 update i18n 2023-04-18 11:50:21 +03:00
Diamantis Tziotzios 89922eaecc Merge remote-tracking branch 'origin/semantics' into Development 2023-04-18 11:19:48 +03:00
Bernaldo Mihasi 11a9abae42 version change in base deposit repository 2023-04-18 10:51:13 +03:00
Bernaldo Mihasi 8293535bb0 add zenodo properties in schematics 2023-04-18 09:41:01 +03:00
Bernaldo Mihasi f822e06881 upload new version for dataset template from xml file 2023-04-09 13:21:08 +03:00
Konstantina Galouni c9b4b35e39 h2020.docx: [Bug fix] Updated image of Argos in h2020.docx DMP template | DataManagementPlanManager.java & DatasetManager.java: Added parameter "isDataset" in fillFirstPage() | WordBuilder.java: [Bug fix] Added parameter isDataset in fillFirstPage() and added some checks in description. 2023-04-05 11:13:26 +03:00
Konstantinos Triantafyllou fbaa175436 Finilize from dataset overview will redirect the editor and then trigger Finalize button. 2023-03-30 12:19:09 +03:00
Bernaldo Mihasi 63c866d74f set creator in new/cloned/newVersioned dmp 2023-03-30 11:44:50 +03:00
Bernaldo Mihasi b6b7a2444c add xml attributes in dmp xml export 2023-03-30 11:44:00 +03:00
Bernaldo Mihasi 18a200f099 no message 2023-03-27 15:25:19 +03:00
Bernaldo Mihasi 18ccb3ca0c changes in dmp deposit model 2023-03-27 15:24:50 +03:00
Bernaldo Mihasi a90f21b6aa fix issues in dmp xml export 2023-03-27 15:21:12 +03:00
Bernaldo Mihasi 376bb2ca53 changes in dmp deposit model 2023-03-27 14:59:47 +03:00
Bernaldo Mihasi 969df0357a migrate rda properties in dataset profiles definitions in db to schematics 2023-03-27 14:58:45 +03:00
Bernaldo Mihasi c35bc2efed remove rda property from models 2023-03-27 14:52:37 +03:00
Konstantinos Triantafyllou 8c708f470d Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development 2023-03-15 15:56:50 +02:00
Konstantinos Triantafyllou 6ca77c2df2 Ticket 8391: DMP Editor: Add dialog before Discard. Dataset Editor: On Discard reset the form instead of go back in dmp editor. 2023-03-15 15:55:57 +02:00
Konstantina Galouni 13e62fd409 h2020.docx & WordBuilder.java: Updated h2020.docx DMP template and added export of DMP description.
(cherry picked from commit 28c1c9b71d)
2023-03-14 10:23:35 +02:00
Bernaldo Mihasi 519cb260c6 fix issue with users returned as empty array, add researchers in response 2023-03-07 09:44:16 +02:00
Diamantis Tziotzios 34176bcb70 hr lang update 2023-03-03 13:01:38 +02:00
Bernaldo Mihasi 759c80420f Merge branch 'Development' of https://code-repo.d4science.org/MaDgiK-CITE/argos into Development 2023-03-03 11:45:54 +02:00
Bernaldo Mihasi 87c9730524 puplic api return total count in response 2023-03-03 11:44:21 +02:00
Diamantis Tziotzios 35f9bbcf56 logo change 2023-03-03 11:41:28 +02:00
Diamantis Tziotzios 7af27c73cf Merge branch 'css-config-changes' into Development 2023-03-03 10:24:34 +02:00
Diamantis Tziotzios 9ebefa8369 Merge branch 'public_api_update' into Development 2023-03-03 10:23:52 +02:00
Diamantis Tziotzios 7185b5d117 Merge commit '180e02c829a8fb35056124d5afdbec3835a94b62' 2023-02-28 16:08:32 +02:00
Konstantina Galouni 28c1c9b71d h2020.docx & WordBuilder.java: Updated h2020.docx DMP template and added export of DMP description. 2023-02-28 11:01:44 +02:00
Konstantinos Triantafyllou 180e02c829 Ticket 8389: Fix undo finalazation appears even finalized wasn't successful. Also fix issue where the buttons are remaining disabled when user press No in the dialog of finalization. On undo finalization do a save in order to be sync with the backend. 2023-02-23 15:51:46 +02:00
Konstantinos Triantafyllou 4c7dee3ece Ticket 8390: Remove separator key codes in the default multiple auto complete input and added in invitation-dialog. 2023-02-23 13:01:56 +02:00
Diamantis Tziotzios 806ce4f584 hr lang update 2023-02-22 18:21:28 +02:00
Konstantinos Triantafyllou 3219132e86 Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development 2023-02-21 15:30:36 +02:00
Konstantinos Triantafyllou c2aba649af CHange condition of depositRepos in dmp-overview in order to chech also the length of the array. 2023-02-21 15:30:26 +02:00
Bernaldo Mihasi e2505039df cleanup unused code 2023-02-21 14:09:33 +02:00
Bernaldo Mihasi b273ca4ed7 search for schematics fields in prefilling 2023-02-21 12:44:48 +02:00
Bernaldo Mihasi 0c57bba0b4 rda json dmp import/export 2023-02-21 11:57:34 +02:00
Bernaldo Mihasi 9a8fc5e92e schematics implementation, xml import export of dataset profiles 2023-02-21 11:46:44 +02:00
Bernaldo Mihasi e22e348330 cleanup unused code 2023-02-21 11:41:07 +02:00
Diamantis Tziotzios 6c5cb97050 hr lang update 2023-02-14 21:04:30 +02:00
Bernaldo Mihasi ab124e87ea add new filters(grantLike, funderLike, collaboratorsLike) 2023-02-14 12:16:11 +02:00
Diamantis Tziotzios 72daadee7e configurable list of languages 2023-02-11 14:38:13 +02:00
Diamantis Tziotzios 554eb96824 css update 2023-02-10 18:05:11 +02:00
Diamantis Tziotzios 34d63438e0 css changes to add configurability 2023-02-10 15:08:23 +02:00
Konstantinos Triantafyllou 8b34d55706 Fix repositories list update after deposit 2023-01-31 17:39:17 +02:00
Konstantinos Triantafyllou 6924d82c80 Change selected DOI from the first element to the selected one 2023-01-24 12:20:05 +02:00
Konstantinos Triantafyllou 34f8e4f96d Fix after deposit action in dmp overwiew. 2023-01-24 12:13:58 +02:00
Bernaldo Mihasi 8f74c36205 no message 2023-01-23 15:30:39 +02:00
Konstantina Galouni 1d45bddeca #8350 - Added tracking of download Dataset & DMP exports in Matomo.
1. matomo-service.ts: Added method "trackDownload()".
2. drafts.component.ts & recent-edited-activity.component.ts & recent-edited-dataset-activity.component.ts & recent-edited-dmp-activity.component.ts & dataset-wizard.component.ts & dataset-listing-item.component.ts & dataset-overview.component.ts & dmp-editor.component.ts & dmp-listing-item.component.ts & dmp-overview.component.ts: Added calls to this.matomoService.trackDownload() for "datasets/" or "dmps/" with the file type (/docx, /xml, /pdf, /json) and the id.
2023-01-20 19:02:12 +02:00
Konstantina Galouni a1dbd72bce #8337 - Added export button in dataset and dmp editors
1. dataset-profile-editor.component.html: Updated how save button appears (save separated from arrow).
2. dataset-profile-editor.component.scss: Commented paddings from .template_action_btn.
3. dataset-wizard.component.html: Added export button | Updated how save button appears (save separated from arrow).
4. dataset-wizard.component.scss: Added class .dataset-export-btn.
5. dmp-editor.component.html: Added export button.
6. dmp-editor.component.scss: Added class .dmp-export-btn.
7. i18n/: Added in language files properties for disabled export button inside editors (DMP-EDITOR.ACTIONS.DISABLED-EXPORT, DATASET-EDITOR.ACTIONS.DISABLED-EXPORT).
2023-01-20 18:53:54 +02:00
Konstantinos Triantafyllou 455e3c8fe0 Revert condition in deposit button, that deleted by mistake in last commit. 2023-01-20 17:29:48 +02:00
Konstantinos Triantafyllou 13d03e4459 Change deposit in DMPs: Modal changed to dropdown in deposit action and change DOI display 2023-01-20 14:56:29 +02:00
Bernaldo Mihasi 57a400f817 update repository base version 2023-01-18 09:37:34 +02:00
Bernaldo Mihasi 030f1ccf8e add repository logo 2023-01-17 14:41:04 +02:00
Diamantis Tziotzios 95c9d599e1 pom update 2023-01-17 10:31:34 +02:00
Diamantis Tziotzios 26bd59de21 repojar conf 2023-01-17 09:54:16 +02:00
Diamantis Tziotzios 4dccaa93b8 Merge branch 'multipleRepos' into Development 2023-01-16 14:11:43 +02:00
Konstantinos Triantafyllou 3e5dc85e04 Fix visibility dependencies for table view. Add missing question titles if a field is table. 2023-01-10 13:08:56 +02:00
Bernaldo Mihasi 66b2596036 delete files used for deposit in tmp storage 2022-12-27 09:44:43 +02:00
Konstantinos Triantafyllou 2f5f34948e Add all fields in field-value pipe. 2022-12-19 18:02:53 +02:00
Bernaldo Mihasi 749dbefc38 1. return bad request when deposition failed and returned null
2. close modal with repositories after a successful deposition
2022-12-19 16:07:03 +02:00
Bernaldo Mihasi 976d0221ce no message 2022-12-19 11:37:49 +02:00
Bernaldo Mihasi 80fba7c655 Merge branch 'multipleRepos' of https://code-repo.d4science.org/MaDgiK-CITE/argos into multipleRepos 2022-12-13 11:00:27 +02:00
Bernaldo Mihasi fbc274282c fix deposit base dependancy in web 2022-12-13 10:55:32 +02:00
Diamantis Tziotzios ec985bf271 Dockerfile update 2022-12-13 10:46:36 +02:00
Bernaldo Mihasi d0cde3c4c4 cleanup deposit since they are moved in another git repository 2022-12-13 10:12:12 +02:00
Bernaldo Mihasi 39d709f41d no message 2022-12-13 09:46:00 +02:00
Bernaldo Mihasi c6d37806c8 drop column doi from dmp and refactor code(replace single doi with list of dois) 2022-12-08 13:12:54 +02:00
Bernaldo Mihasi 8c95b16164 add temp storage in zenodo repository 2022-12-08 13:06:52 +02:00
Bernaldo Mihasi ad00695d4e fix bug allowing invalid characters in pdf name 2022-12-08 13:04:55 +02:00
Bernaldo Mihasi 572be373e5 don't deposit empty supportingFiles.zip when no files are uploaded in datasets 2022-12-08 13:02:08 +02:00
Konstantina Galouni 1171a38ad1 hr.json: #8296 - Updated Croatian localization file. 2022-12-07 17:32:27 +02:00
George Kalampokis 5f131b9823 Remove thread sleeps when trying to load config files and removed principal from Exception Handling Controller 2022-12-06 14:34:11 +02:00
Diamantis Tziotzios e1a3e9b7bc Dockerfile update 2022-12-06 11:55:06 +02:00
Bernaldo Mihasi b7e69d5fdf repo config using enviroment variables instead of static strings 2022-12-06 11:50:54 +02:00
George Kalampokis 6caef3e890 Remove thread sleeps when trying to load config files and removed principal from Exception Handling Controller 2022-11-30 18:19:40 +02:00
Bernaldo Mihasi 679354f699 deposit datasets' attached files in zip format 2022-11-30 09:43:03 +02:00
Konstantinos Triantafyllou c9c99be603 Merge branch 'table-field' into Development 2022-11-29 10:19:15 +02:00
Konstantinos Triantafyllou a2d07c93c8 Table View: Change columns text from truncate to wrap 2022-11-29 09:55:47 +02:00
Diamantis Tziotzios 75007286fc elasticsearch cert change 2022-11-25 17:03:25 +02:00
Diamantis Tziotzios ccc102a52d add more elastic logs 2022-11-25 16:03:59 +02:00
Bernaldo Mihasi ed79d27cdc when making a new version in dataverse delete previous files 2022-11-25 11:20:45 +02:00
Konstantinos Triantafyllou 9fd963a480 Add table view in preview of datataset profile editor and dataset editor. 2022-11-24 21:28:18 +02:00
Bernaldo Mihasi da211ca756 update dockerfile to include directory with repository jars 2022-11-24 17:31:16 +02:00
Bernaldo Mihasi 7a0e1c89f2 when finalizing a dmp and its access rights are open, make it publicly available in Argos 2022-11-24 16:29:11 +02:00
Diamantis Tziotzios 93320f7c94 Merge branch 'Development' 2022-11-22 15:03:08 +02:00
Bernaldo Mihasi 573aab059b remove redundant parameter in deposit interface 2022-11-22 09:58:47 +02:00
Bernaldo Mihasi 5e2639848b dmps are deposited in dataverse as datasets under a parent predefined dataverse collenction
when a new dmp version is created and deposited, the corresponding dataset in dataverse/collection in zenodo create a new version too
deposit dmps as published not drafts
2022-11-22 09:40:05 +02:00
George Kalampokis 0888b7cd74 Enable health and metrics built-in endpoints 2022-11-21 14:06:59 +02:00
Bernaldo Mihasi 6c13d3b68f when new version is deposited, create dataset in existing dataverse 2022-11-14 09:34:49 +02:00
Konstantinos Triantafyllou 925fc3ce4a Merge branch 'Development' into table-field 2022-11-10 17:54:28 +02:00
Bernaldo Mihasi b4490cb0f3 [WIP] implement dataverse repository deposit 2022-11-10 10:12:11 +02:00
Konstantina Galouni 2bbf89e779 HtmlToWorldBuilder.java & WordBuilder.java: Added methods for exporting inputs of a question as table. 2022-11-08 14:39:23 +02:00
Diamantis Tziotzios 876d99ce38 Merge commit '18dcabbac2599d35246f91204efbb25238106565' 2022-11-03 14:20:16 +02:00
Diamantis Tziotzios 0cd20605f0 user guide image update 2022-11-02 15:39:42 +02:00
Bernaldo Mihasi 6b2bc3c1e0 cleanup code, add authorizationUrl and recordUrl in repositories config 2022-11-02 13:31:42 +02:00
Bernaldo Mihasi 59e26dbb8d [WIP] EntityDoi table 2022-11-02 09:41:40 +02:00
Konstantina Galouni 37724380e9 #7276 - Added tableView true/false option in multiplicity 2022-11-01 16:24:28 +02:00
Bernaldo Mihasi 7d624a2daa [WIP] system deposit authentication, using default repo token 2022-10-27 09:32:26 +03:00
Bernaldo Mihasi ab66a5f1da [WIP] implement zenodo repository deposit, add authentication for depositions 2022-10-26 13:50:01 +03:00
Bernaldo Mihasi 18dcabbac2 #7892 - prefill rda field only when a new dataset is created or a new version is made 2022-10-25 09:36:11 +03:00
Bernaldo Mihasi 7dd2030eb3 [WIP] create deposit interface and implement multiple deposit repositories 2022-10-24 09:35:49 +03:00
Diamantis Tziotzios 49ce0efb40 user guide images added 2022-10-19 11:06:54 +03:00
Konstantinos Triantafyllou 9f1c0352ea Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development 2022-10-19 01:48:57 +03:00
Konstantinos Triantafyllou 4a54915a8e Fix some bugs in dataset editor while navigating with buttons and scroll in the table of contents 2022-10-19 01:48:48 +03:00
Konstantina Galouni 4dd338d08e #8149 - [Bug fix] Updated condition to check if current user is owner of DMP/ Dataset (drafts.component.ts & recent-edited-activity.component.ts & recent-edited-dataset-activity.component.ts & recent-edited-dmp-activity.component.ts & dataset-listing-item.component.ts & dmp-clone.component.ts & dmp-listing-item.component.ts). 2022-10-18 14:01:26 +03:00
Bernaldo Mihasi 20f618a5d7 fix request body examples in publicapi 2022-10-18 09:39:46 +03:00
Konstantinos Triantafyllou 3361b6aff6 Redesign steps in dataset editor #7545 2022-10-17 15:32:05 +03:00
Konstantina Galouni dc197a5abc #8143 - form-field.component.html: [Bug fix] Updated check to set disabled attribute or not in the button. 2022-10-12 16:22:58 +03:00
Diamantis Tziotzios b018dd42db fixed default language support 2022-10-11 18:52:08 +03:00
Bernaldo Mihasi 2b692fa579 fix public api paths 2022-10-10 11:56:48 +03:00
Konstantinos Triantafyllou 6720504b7b Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development 2022-10-05 16:23:02 +03:00
Konstantinos Triantafyllou fd2ec314a0 Add next-previous buttons in dataset editot in order to navigate through chapters 2022-10-05 16:22:47 +03:00
Bernaldo Mihasi ef327a0a57 expose public api 2022-10-04 13:06:49 +03:00
Konstantina Galouni 4cab6ca160 dmp-editor.component.ts: [Bug fix - #8073] Set value of "status" field of formGroup to DmpStatus.Draft, after reset() is called. 2022-09-16 10:32:29 +03:00
Bernaldo Mihasi 5087a37e15 dockerization 2022-09-13 10:35:56 +03:00
Konstantina Galouni 6a4d67de0c faqs.html & faq-content.component.html: #7972 - Updated faqs according to document. 2022-09-05 14:19:15 +03:00
argirok 0d5f6de7c7 update language to Polski 2022-07-29 10:40:45 +03:00
argirok 19d8218dea Added pl.json and update localization files 2022-07-29 10:39:39 +03:00
Konstantina Galouni 49e42e9cba h2020_dataset.docx & WordBuilder.java & DataManagementPlanManager.java & DatasetManager.java: Updated footer of Dataset template to set title of DMP and Dataset. 2022-07-28 17:30:44 +03:00
George Kalampokis 7a71110033 Fix critical issue with open file handle leak on user guide folder
(cherry picked from commit fa723c07ae)
2022-07-28 17:14:13 +03:00
George Kalampokis fa723c07ae Fix critical issue with open file handle leak on user guide folder 2022-07-28 11:23:39 +03:00
Konstantina Galouni a2228a5fb6 #7597, #7893, #7895, #7898: Updated DMP template file (h2020.docx) for export | Added Dataset template file (h2020_dataset.docx) for export | Updated indentation on exported docs.
1. h2020.docx, h2020_dataset.docx: Updated DMP template & Added Dataset template.
2. application.properties, application-devel.properties, application-production.properties, application-staging.properties: Added property for dataset template file path configuration.h2020datasettemplate=documents/h2020_dataset.docx
3. ConfigLoader.java: Added method XWPFDocument getDatasetDocument();
4. DefaultConfigLoader.java: Added fiedls and methods for loading Dataset template (h2020_dataset.docx).
5. DataManagementPlanManager.java, DatasetManager.java, , HtmlToWorldBuilder.java, WordBuilder.java: Updated header/footer/first page in exports for DMPs and Datasets  | Updated indentation in exports.
2022-07-26 17:00:54 +03:00
Konstantina Galouni 9b4c7aeb6f DataManagementPlanManager.java: #7893 - Added description of Datasets on DMP exported word file. 2022-07-12 12:52:04 +03:00
Konstantinos Triantafyllou b21693bff1 Change all buttons width: 101px to min-width: 101px 2022-07-11 16:49:09 +03:00
Konstantinos Triantafyllou 989f07787c Fix autocomplete in multiplicity items by using parent field id. 2022-07-11 16:34:06 +03:00
Konstantina Galouni e329ef763a form-section.component.html: Updated classes of comment field parent and wrapperClasses so that it looks full width in all views. 2022-06-23 15:51:28 +03:00
Konstantinos Triantafyllou 304a6cfdb3 Backend: Fix a bug with compareTo of a field throwing an error because ordinal is not exists. FrontEnd: Initialize visibility rules for multiple fields coming from service according to their parents. 2022-06-23 15:38:48 +03:00
Konstantina Galouni 18e98938d5 WordBuilder.java: #7869 - In exported file fix hidden question title and a. /b. /c for empty answers.
a. fix hidden question title when more than 1 multiplicity answers,
b. fix hidden question title when  no value in the last multiplicity answer,
c. Do not show a. / b. / c.... for empty multiplicity answers,
d. Do not show a. / b. / c.... when more than 1 multiplicity answers, but only one with value.
2022-06-23 15:32:05 +03:00
argirok b1788c2dc2 update croatian language file hr.json 2022-06-21 12:51:51 +03:00
Diamantis Tziotzios 2ecce0acb0 elastic conf changes 2022-06-14 14:22:59 +03:00
Bernaldo Mihasi 8b26ff19b6 Merge branch 'Development' of https://code-repo.d4science.org/MaDgiK-CITE/argos into Development 2022-06-14 10:25:53 +03:00
Bernaldo Mihasi 9c4d246ef5 heading changes on export template 2022-06-14 10:24:35 +03:00
Konstantina Galouni 772a041851 WordBuilder.java: #7837 - In exported file add comment filed as ParagraphStyle.HTML instead of ParagraphStyle.COMMENT. 2022-06-14 10:14:48 +03:00
Bernaldo Mihasi 0ac5902bfd 1. export redesign based on new word template
2. orcid researchers in export are clickable
2022-06-13 15:16:48 +03:00
Konstantina Galouni 941cca8103 form-section-inner.component.html & form-section.component.html: Updated comment field to use <rich-text-editor> instead of <input> and <mat-hint>. 2022-06-10 17:00:36 +03:00
Bernaldo Mihasi 73be5d9a98 1. export redesign: multiplicity #ref 7834, multiple select #ref 7836
2. fix bug in license api export
2022-06-08 16:27:47 +03:00
Bernaldo Mihasi 3433f58506 Add ssl support for elasticsearch 2022-06-08 16:23:49 +03:00
George Kalampokis 0235406246 Improve image caption styling 2022-06-07 14:52:48 +03:00
George Kalampokis 7985b13cca Add image caption on Word/Pdf export 2022-06-07 13:10:06 +03:00
George Kalampokis 54c5017609 Add Export attribute on Dataset Profile's Field. By Default is set to true. The attribute determines if the field value will be included in the word/pdf export 2022-06-07 11:00:13 +03:00
George Kalampokis 5cd79a6368 When Exporting DMP to word/pdf sort it's Datasets based on creation date 2022-06-07 10:56:44 +03:00
George Kalampokis ea8407eece Fix critical issue when uploading Dataset Template 2022-06-07 10:33:37 +03:00
Diamantis Tziotzios 91566c9710 Merge branch 'saml2' into Development 2022-06-01 10:45:19 +03:00
Konstantina Galouni 79bc95b099 [Bug fix] DatasetProfileManager.java: In method "createNewVersionDatasetProfile()", do not set label and language from oldDatasetProfile. 2022-05-31 16:51:59 +03:00
Konstantina Galouni d7ee7b8d93 Question titles in dataset template with <textarea> | Bug fix in "Save & Continue" functionality of dataset templates | Added "Update & Continue" functionality in dataset templates | Changed placeholder text in the prefilling search box.
1. dataset-profile-editor-composite-field.component.html: #7792 - use <textarea> instead of <input> for question titles.
2. dataset-profile-editor-field.component.ts: #7790 - Set default value "unchecked" for checkbox.
3. dataset-profile.service.ts: In methods "createForm()" and "newVersion" updated response type from DatasetProfileEditorModel to string (id is returned only) and use httpClient instead of http.
4. dataset-profile-editor.component.html:
   a. [Bug fix] Fix conditions in action buttons (Save/Update/Finalize)
   b. On "Update" action button, added update dropdown options "Update & Continue", "Update & Close" and set default behavior "Update & Continue".
   c. On save dropdown options, used DATASET-PROFILE-EDITOR.ACTIONS instead of DATASET-WIZARD.ACTIONS.
5. dataset-profile-editor.component.ts:
   a. [Bug fix] #7791 - Created method "afterSave()" to be called in "onSubmit()" method when api calls return
   b. Added optional parameter "close: boolean = false" in method "updateAndFinalize".
6. i18n/:
   a. Added DATASET-WIZARD.ACTIONS.SAVE-AND-CONTINUE, DATASET-WIZARD.ACTIONS.SAVE-AND-CLOSE, DATASET-WIZARD.ACTIONS.UPDATE-AND-CONTINUE, DATASET-WIZARD.ACTIONS.UPDATE-AND-CLOSE.
   b. #7750 - Changed placeholder text in the prefilling search box (DATASET-CREATE-WIZARD.PREFIL-STEP.SEARCH).
2022-05-31 16:49:15 +03:00
George Kalampokis e8a87765ee Fix authorization issue with Dataset Templates not showing to their original creators (that are not Admins) 2022-05-31 16:14:25 +03:00
argirok 03f7afede8 update openaire publication API to accept DOI query 2022-05-30 16:15:16 +03:00
George Kalampokis 11b0db21ac Reconfigure Zenodo prefilling query in order to query doi and conceptdoi alongside the title (ref #7802) 2022-05-30 11:59:49 +03:00
George Kalampokis 757b1f70e8 Change default filterType to remote (ref #7799 & #7800) 2022-05-26 15:03:45 +03:00
George Kalampokis 66511d2ed6 Further stability improvement over external urls query 2022-05-25 18:06:54 +03:00
George Kalampokis 0f4b209427 Add {query} field for external urls with configurable queries and make ORCID query more strict (similar to orcid's website) (ref #7798) 2022-05-25 17:37:20 +03:00
George Kalampokis 3aff6ac90e Allow to update Dataset Templates by uploading dataset Template .xml files (ref #7793) 2022-05-25 14:50:00 +03:00
Diamantis Tziotzios 14c267c97e Merge branch 'Development'
# Conflicts:
#	dmp-backend/web/src/main/resources/config/application-production.properties
2022-05-13 11:58:34 +03:00
George Kalampokis 912a3cc095 Order datasets on DMP listing (ref #7746) 2022-05-11 18:13:35 +03:00
Bernaldo Mihasi 3c3b9ef398 Merge branch 'Development' of https://code-repo.d4science.org/MaDgiK-CITE/argos into Development 2022-05-04 11:13:47 +03:00
Bernaldo Mihasi cfd0707f2a bug fix: license api-fields didnt get prefilled 2022-05-04 11:11:25 +03:00
George Kalampokis 78bceeb8ae Reorganize and Rename (english only) DMP Editor Fields (ref #7700) 2022-05-04 11:10:06 +03:00
George Kalampokis b891907724 Merge remote-tracking branch 'origin/Development' into Development 2022-05-04 10:25:31 +03:00
George Kalampokis afa602bf39 Fix issue with Dataset Editor when trying to save an incomplete or invalid form, the save buttons stay locked (ref #7725) 2022-05-04 10:25:13 +03:00
Konstantina Galouni 579bb58afc #7699: rich-text-editor.component.ts: Clear any formatting on paste and add plain text | Added h1-h6 tags in customClasses | Enable "removeFormat" button (clear formatting added from editor options). 2022-05-03 18:06:32 +03:00
Diamantis Tziotzios b04b35d62b Merge branch 'Development'
# Conflicts:
#	dmp-backend/web/src/main/resources/RDACommonStandards.txt
2022-02-25 12:19:29 +02:00
Diamantis Tziotzios 7a8375b988 Merge commit '2cb985c23c4ceda99efc78bcc8e77b3eceeb0bcf'
# Conflicts:
#	dmp-backend/elastic/src/main/java/eu/eudat/elastic/criteria/DatasetCriteria.java
#	dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java
#	dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dmp.java
#	dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java
#	dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DmpRepository.java
#	dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java
#	dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/criteria/DmpCriteriaMapper.java
#	dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/word/WordBuilder.java
#	dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanListingModel.java
2021-12-09 12:18:39 +02:00
Diamantis Tziotzios 895dbcf098 Revert "user guide path fix"
This reverts commit bd15b1e2c7.
2021-07-07 20:39:41 +03:00
Diamantis Tziotzios bd15b1e2c7 user guide path fix 2021-07-07 20:39:22 +03:00
George Kalampokis faabd343a9 Improve error handling
(cherry picked from commit d5cd90814a)
2021-07-06 13:41:09 +03:00
George Kalampokis e5a929f259 Fix issues with xml import and issues with zenodo deposit
(cherry picked from commit efe177f0b1)
2021-07-06 13:40:15 +03:00
George Kalampokis d1fc10854c Fix issue with zenodo depositions
(cherry picked from commit c57e10a033)
2021-07-06 12:15:49 +03:00
George Kalampokis 2537923dc0 Fix various critical issues
(cherry picked from commit 244bfa5c54)
2021-07-05 11:10:11 +03:00
George Kalampokis c1adbe283a Improvements over MS Word Document export
(cherry picked from commit 4e3b98f1ff)
2021-06-30 18:48:20 +03:00
George Kalampokis 1c365a191e Minor Update
(cherry picked from commit 295750684f)
2021-06-30 18:48:13 +03:00
Kristian Ntavidi 82c5586067 Dataset and dmp overview fix.
* Fix edit issue when multiple users have ownership of the same dmp/dataset.

(cherry picked from commit fd9d35aad3)
2021-06-30 13:38:53 +03:00
George Kalampokis 04f230dff1 Fix critical issue with dataset's copy dropdown
(cherry picked from commit d1e3aae36d)
2021-06-30 12:52:32 +03:00
George Kalampokis 72d88d9db4 Fix listing issues and improve elastic query
(cherry picked from commit dcd7f24cac)
2021-06-29 14:25:38 +03:00
George Kalampokis 143a4c0214 Reduce severity
(cherry picked from commit 03b7699973)
2021-06-25 19:31:45 +03:00
George Kalampokis e7e5ed02b3 Add query db fallback for DMPs
(cherry picked from commit d1df83f689)
2021-06-25 19:28:29 +03:00
George Kalampokis b5fcc5971e Fix various library issues with postgres and elastic
(cherry picked from commit 4a4042d621)
2021-06-25 12:46:09 +03:00
Diamantis Tziotzios c16c35225f Merge branch 'Development' 2021-06-25 08:50:27 +03:00
Diamantis Tziotzios f5d266554b Merge commit 'ca91c14114b8994d41fdf2b97fc6d1a4d82ffa4e' 2021-05-19 14:22:47 +03:00
Diamantis Tziotzios db31597fc0 Merge branch 'Development' 2020-10-07 10:58:45 +03:00
Diamantis Tziotzios 9f5054668e Merge branch 'Development'
* Development: (72 commits)
  splash screen fixes
  splash spell error fix
  Properly remove associate Collaborators from a DMP
  splash changes
  Fixed issue with DMP filter on public datasets
  Fixed issue when using the copy dataset dialog
  Minor styling improvement over DMP Overview
  Code clean up
  Add support for newer versions of java (11) (expirimental)
  Add Zenodo file visibility field for DMP (ref #274)
  Fixed issue not passing DMP Extra Properties on clones and new Versions
  Add DMP Zenodo license field (ref #274)
  more splash screen changes
  Allow splash to send contact emails
  splash screen changes
  Hide Uri field on Dataset Editor (ref #275)
  When logging in remove the cookie consent popup
  Fixed minor issues with RDA Mapping
  Add currency field type for dataset templates
  Add DMP language a placeholder on UI
  ...

# Conflicts:
#	dmp-backend/web/src/main/resources/RDACommonStandards.txt
#	dmp-backend/web/src/main/resources/config/application-production.properties
2020-07-03 11:00:07 +03:00
George Kalampokis 38986ef67b no message 2020-06-16 17:58:31 +03:00
Diamantis Tziotzios bff260b85b config file changes 2020-06-16 17:54:50 +03:00
George Kalampokis 9519300dc4 Removed deprecated configurations and added additional RDA Common Standards for dataset Templates
(cherry picked from commit 5b0a66ce06)
2020-05-29 12:07:59 +03:00
George Kalampokis 9373d3e038 Fixed logback paths
(cherry picked from commit 33ec8b81c0)
2020-05-20 15:39:27 +03:00
dtziotzios d971f02a94 Merge branch 'Development'
# Conflicts:
#	dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java
#	dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java
2020-05-13 17:29:52 +03:00
Georgios Kakaletris d3915e26e7 Update LICENSE 2020-05-09 00:03:50 +02:00
George Kalampokis c028aad615 Fixed and improved file export system
(cherry picked from commit 71ccd76896)
2020-04-02 18:44:40 +03:00
Diamantis Tziotzios 4ee39074a3 Merge commit '8ca2b912d40ece8bf0fbcda5c49f1ef7f5f6fdfd' 2020-04-02 13:33:08 +03:00
Diamantis Tziotzios 1b4952a909 Merge branch 'Development' 2020-01-31 18:26:27 +02:00
Diamantis Tziotzios 3ada5a0d3d Merge branch 'Development' 2019-11-26 11:41:02 +02:00
Diamantis Tziotzios 63ee865dd9 Merge commit 'c8358f22dd5d108b7f270f97724d6bab1582c2c5' 2019-11-22 18:08:55 +02:00
Diamantis Tziotzios 2a52138124 Merge branch 'Development' 2019-09-17 18:47:39 +03:00
Diamantis Tziotzios 7cf64c18f2 Merge branch 'Development' 2019-09-17 11:31:58 +03:00
Diamantis Tziotzios 71d317bab7 license file 2019-06-19 08:59:52 +02:00
Ioannis Kalyvas cd8b3448f5 Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot 2018-06-28 12:39:39 +03:00
Ioannis Kalyvas c3d4cb6fdd no message 2018-06-28 12:33:43 +03:00
Ioannis Kalyvas b0ccac191f no message 2018-03-06 17:33:55 +02:00
Ioannis Kalyvas 3b1f37ef22 no message 2018-03-06 17:27:24 +02:00
Ioannis Kalyvas b8e040ee94 Merge branch 'master' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot
# Conflicts:
#	dmp-backend/src/main/java/eu/eudat/helpers/Transformers.java
2018-03-06 17:21:46 +02:00
Ioannis Kalyvas 50444a0b73 Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot
# Conflicts:
#	dmp-backend/src/main/java/eu/eudat/helpers/Transformers.java
#	dmp-frontend/src/index.html
2018-03-06 17:02:13 +02:00
Diamantis Tziotzios 85bdb7fad1 Merge branch 'Development'
# Conflicts:
#	dmp-backend/src/main/java/eu/eudat/helpers/Transformers.java
2018-02-12 10:23:41 +02:00
annabakouli b2e49fbb8a no message 2018-01-18 12:55:35 +02:00
Diamantis Tziotzios bfc6b63067 Merge branch 'Development'
# Conflicts:
#	dmp-backend/src/main/java/rest/entities/DMPs.java
#	dmp-backend/src/main/java/rest/entities/DataRepositories.java
#	dmp-backend/src/main/java/rest/entities/DatasetProfiles.java
#	dmp-backend/src/main/java/rest/entities/Datasets.java
#	dmp-backend/src/main/java/rest/entities/DmpProfiles.java
#	dmp-backend/src/main/java/rest/entities/Organisations.java
#	dmp-backend/src/main/java/rest/entities/Projects.java
#	dmp-backend/src/main/java/rest/entities/Registries.java
#	dmp-backend/src/main/java/rest/entities/Researchers.java
#	dmp-backend/src/main/java/rest/entities/Services.java
#	dmp-backend/src/main/java/rest/entities/Users.java
#	dmp-frontend/src/app/app.component.ts
#	dmp-frontend/src/app/login/googgle-sign-in/googgle-sign-in.component.ts
#	dmp-frontend/src/assets/custom.js
#	dmp-frontend/src/index.html
2018-01-18 12:45:51 +02:00
Nikolaos Laskaris 9941c96dc2 Minor edits 2017-11-27 16:08:13 +02:00
Nikolaos Laskaris 06272c79da -- 2017-11-23 17:34:35 +02:00
Nikolaos Laskaris a00eec68d8 fixed glitches of google-sign-in component 2017-11-23 13:13:20 +02:00
700 changed files with 31069 additions and 7112 deletions

11
.env
View File

@ -1,6 +1,5 @@
TAG=6.3.0
ENV=prod
PROFILE=production
AOT=aot
ELASTIC_VERSION=6.3.0
ELASTIC_PASSWORD=changeme
PROFILE=docker
# Version of Elastic products
ELK_VERSION=7.17.4
STACK_VERSION=7.17.4

3
.gitignore vendored
View File

@ -46,3 +46,6 @@ ELK.Docker/shared/data-elk/
.settings/
bin/
*.classpath
openDMP/dmp-backend/uploads/
openDMP/dmp-backend/tmp/
dmp-frontend/.angular/

69
README.md Normal file
View File

@ -0,0 +1,69 @@
**Important note: The deployment, troubleshooting, maintenance and operation of on-premises / self-served OpenDMP instances for development, testing or production use, shall be the sole responsibility of the adopter. No support is guaranteed by OpenDMP implentation team for issues that may be encountered during deployment, extension or operation of such installations.**
**Documentation is provided on a best-effort basis for the code and processes around the development, deployment and operation of OpenDMP. If you find any misalignment of the actual processes with the related documentation, please let us know so that the misalignment is addressed for the benefit of future adopters.**
# Using Docker Compose with Argos
ARGOS is an open extensible service that simplifies the management, validation, monitoring and maintenance and of Data Management Plans. It allows actors (researchers, managers, supervisors etc) to create actionable DMPs that may be freely exchanged among infrastructures for carrying out specific aspects of the Data management process in accordance with the intentions and commitment of Data owners.
## Before running the docker compose commands, configurations must be set
### Database
First of all, database must be configured
The only file that has to be changed is **/dmp-db-scema/Docker/dmp-db.env**
```bash
ADMIN_USER: Admin username (app)
ADMIN_PASSWORD: Admin password (app)
POSTGRES_DB: database name
POSTGRES_USER: Admin username (database)
POSTGRES_PASSWORD: Admin password (database)
```
### Backend
Secondly, a few more options should be asigned
The file **/dmp-backend/web/src/main/resources/config/application-docker.properties** contains all the necessary properties
Values to be modified:
```bash
database.url: the url that is used to connect to database (JDBC based)
database.username: database admin username
database.password: database admin password
elasticsearch.*(optional): setup elastic, check Elasticsearch(optional) section below
google.login.clientId(optional): google as login provider
```
**NOTE:** if you want to configure and integrate other providers, check this reference [Setup configurable login](https://code-repo.d4science.org/MaDgiK-CITE/argos/wiki/Page-2A:-Setup-configurable-login)
If you provide google.login.clientId, then the same value should be set in the field named **loginProviders.googleConfiguration.clientId** which belongs to **/dmp-frontend/src/assets/config/config.json**
## You are ready to build and run the entire application using Docker-compose
1. Go to the project's root directory
2. Type in the **Terminal** `docker volume create --name=dmpdata`
3. Type in the **Terminal** `docker-compose up -d --build`
4. After it's complete your application is running on [http://localhost:8080](http://localhost:8080)
### Elasticsearch(optional)
If you want to set up elasticsearch, you will need the password for the **elastic** user
After your application is running, type in the **Terminal** `docker exec -it elasticsearch /bin/sh`
Run the command `cat data/passwords.txt` in the shell and save its output
Finally, run `exit` to get back to your terminal
The elastic's password that you get has to be set in the **elasticsearch.password** property in the backend configuration
Rerun the application
1. Type in the **Terminal** `docker-compose down`
2. Type in the **Terminal** `docker-compose up -d --build`

View File

@ -1 +1 @@
PROFILE=staging
PROFILE=docker

View File

@ -1,22 +1,22 @@
FROM maven:3-jdk-8-alpine AS MAVEN_BUILD
FROM maven:3-jdk-11 AS MAVEN_BUILD
COPY pom.xml /build/
COPY data /build/data/
COPY elastic /build/elastic/
COPY logging /build/logging/
#COPY logging /build/logging/
COPY queryable /build/queryable/
COPY web /build/web/
WORKDIR /build/
RUN mvn package
RUN mvn package -q
FROM openjdk:8-jre-alpine
FROM amazoncorretto:11
WORKDIR /app
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app.jar

View File

@ -12,4 +12,4 @@ RUN mvn package
FROM adoptopenjdk/openjdk11:alpine-jre
WORKDIR /app
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app/app.jar
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Dspring.profiles.active=${PROF}", "-Dspring.config.additional-location=/files/config/", "-jar","/app/app.jar"]
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Dspring.profiles.active=${PROF}", "-Dspring.config.additional-location=/files/config/", "-cp", "/app/app.jar", "-Dloader.path=/files/repo-jars", "org.springframework.boot.loader.PropertiesLauncher"]

View File

@ -25,5 +25,10 @@
<artifactId>elastic</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.20</version>
</dependency>
</dependencies>
</project>

View File

@ -1,9 +1,9 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.queryable.queryableentity.DataEntity;
import io.swagger.annotations.ApiModelProperty;
public abstract class Criteria<T> {
@ApiModelProperty(value = "like", name = "like", dataType = "String", allowEmptyValue = true, example = "\"\"")
private String like;
public String getLike() {

View File

@ -0,0 +1,16 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DMPProfile;
public class DataManagementPlanBlueprintCriteria extends Criteria<DMPProfile> {
private Integer status;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.entities.Grant;
import java.util.Date;
@ -10,6 +11,7 @@ import java.util.UUID;
public class DataManagementPlanCriteria extends Criteria<DMP> {
private Date periodStart;
private Date periodEnd;
private DMPProfile profile;
private List<eu.eudat.data.entities.Grant> grants;
private boolean allVersions;
private List<UUID> groupIds;
@ -37,6 +39,13 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
this.periodEnd = periodEnd;
}
public DMPProfile getProfile() {
return profile;
}
public void setProfile(DMPProfile profile) {
this.profile = profile;
}
public List<Grant> getGrants() {
return grants;
}

View File

@ -1,13 +1,13 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
public enum DatasetProfileFilter {
DMPs((short) 0), Datasets((short) 1);
@ -25,7 +25,7 @@ public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
case 1:
return Datasets;
default:
throw new RuntimeException("Unsupported DatasetProfile filter");
throw new RuntimeException("Unsupported DescriptionTemplate filter");
}
}
}

View File

@ -1,11 +1,11 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import java.util.UUID;
public class DatasetProfileWizardCriteria extends Criteria<DatasetProfile> {
public class DatasetProfileWizardCriteria extends Criteria<DescriptionTemplate> {
private UUID id;
public UUID getId() {

View File

@ -42,6 +42,8 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
if (criteria.getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
if (criteria.getProfile() != null)
query.where((builder, root) -> builder.equal(root.get("profile"), criteria.getProfile()));
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
if (!criteria.getAllVersions())
@ -75,7 +77,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
}
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("datasetprofile").get("id").in(criteria.getDatasetTemplates()));
}
if (criteria.getGrantStatus() != null) {
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
@ -87,7 +89,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
}
if (criteria.hasDoi()) {
query.where((builder, root) -> builder.not(builder.isNull(root.get("doi"))));
query.where((builder, root) -> builder.not(builder.isNull(root.join("dois").get("id"))));
}
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
return query;

View File

@ -1,6 +1,7 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.DMPProfile;
@ -15,4 +16,6 @@ public interface DMPProfileDao extends DatabaseAccessLayer<DMPProfile, UUID> {
QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria);
QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria);
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMPProfile;
@ -65,4 +66,20 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
return query;
}
@Override
public QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria){
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
if (criteria.getStatus() != null) {
if (criteria.getStatus() == DMPProfile.Status.FINALIZED.getValue()) {
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.FINALIZED.getValue()));
} else if (criteria.getStatus() == DMPProfile.Status.SAVED.getValue()) {
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.SAVED.getValue()));
}
}
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
return query;
}
}

View File

@ -80,7 +80,7 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
query.where((builder, root) -> root.get("profile").get("id").in(criteria.getDatasetTemplates()));
if (criteria.hasDoi()) {
query.where((builder, root) -> builder.not(builder.isNull(root.get("dmp").get("doi"))));
query.where((builder, root) -> builder.not(builder.isNull(root.join("dmp").join("dois").get("id"))));
}
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()));

View File

@ -3,7 +3,6 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DatasetExternalDataset;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;

View File

@ -2,18 +2,23 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.queryable.QueryableList;
import java.util.List;
import java.util.UUID;
public interface DatasetProfileDao extends DatabaseAccessLayer<DatasetProfile, UUID> {
public interface DatasetProfileDao extends DatabaseAccessLayer<DescriptionTemplate, UUID> {
QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria);
QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria);
QueryableList<DatasetProfile> getAll();
QueryableList<DescriptionTemplate> getAll();
QueryableList<DatasetProfile> getAuthenticated(QueryableList<DatasetProfile> query, UUID principal, List<Integer> roles);
QueryableList<DescriptionTemplate> getAuthenticated(QueryableList<DescriptionTemplate> query, UUID principal, List<Integer> roles);
List<DescriptionTemplate> getAllIds();
Long countWithType(DescriptionTemplateType type);
}

View File

@ -3,8 +3,8 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
@ -15,21 +15,22 @@ import org.springframework.stereotype.Component;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("datasetProfileDao")
public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implements DatasetProfileDao {
public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> implements DatasetProfileDao {
@Autowired
public DatasetProfileDaoImpl(DatabaseService<DatasetProfile> databaseService) {
public DatasetProfileDaoImpl(DatabaseService<DescriptionTemplate> databaseService) {
super(databaseService);
}
@Override
public QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria) {
QueryableList<DatasetProfile> query = getDatabaseService().getQueryable(DatasetProfile.class);
public QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria) {
QueryableList<DescriptionTemplate> query = getDatabaseService().getQueryable(DescriptionTemplate.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
if (!criteria.getAllVersions())
@ -62,9 +63,9 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
query.where(((builder, root) -> root.get("id").in(criteria.getIds())));
}
if (criteria.getFinalized()) {
query.where(((builder, root) -> builder.equal(root.get("status"), DatasetProfile.Status.FINALIZED.getValue())));
query.where(((builder, root) -> builder.equal(root.get("status"), DescriptionTemplate.Status.FINALIZED.getValue())));
} else {
query.where(((builder, root) -> builder.notEqual(root.get("status"), DatasetProfile.Status.DELETED.getValue())));
query.where(((builder, root) -> builder.notEqual(root.get("status"), DescriptionTemplate.Status.DELETED.getValue())));
}
if (criteria.getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
@ -72,43 +73,48 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
}
@Override
public DatasetProfile createOrUpdate(DatasetProfile item) {
return this.getDatabaseService().createOrUpdate(item, DatasetProfile.class);
public DescriptionTemplate createOrUpdate(DescriptionTemplate item) {
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplate.class);
}
@Override
public DatasetProfile find(UUID id) {
return getDatabaseService().getQueryable(DatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
public DescriptionTemplate find(UUID id) {
return getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public QueryableList<DatasetProfile> getAll() {
return getDatabaseService().getQueryable(DatasetProfile.class);
public QueryableList<DescriptionTemplate> getAll() {
return getDatabaseService().getQueryable(DescriptionTemplate.class);
}
@Override
public void delete(DatasetProfile item) {
public List<DescriptionTemplate> getAllIds(){
return getDatabaseService().getQueryable(DescriptionTemplate.class).withFields(Collections.singletonList("id")).toList();
}
@Override
public void delete(DescriptionTemplate item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DatasetProfile> asQueryable() {
return this.getDatabaseService().getQueryable(DatasetProfile.class);
public QueryableList<DescriptionTemplate> asQueryable() {
return this.getDatabaseService().getQueryable(DescriptionTemplate.class);
}
@Async
@Override
public CompletableFuture<DatasetProfile> createOrUpdateAsync(DatasetProfile item) {
public CompletableFuture<DescriptionTemplate> createOrUpdateAsync(DescriptionTemplate item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DatasetProfile find(UUID id, String hint) {
public DescriptionTemplate find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public QueryableList<DatasetProfile> getAuthenticated(QueryableList<DatasetProfile> query, UUID principal, List<Integer> roles) {
public QueryableList<DescriptionTemplate> getAuthenticated(QueryableList<DescriptionTemplate> query, UUID principal, List<Integer> roles) {
if (roles != null && !roles.isEmpty()) {
query.where((builder, root) -> {
Join userJoin = root.join("users", JoinType.LEFT);
@ -120,4 +126,9 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
return query;
}
@Override
public Long countWithType(DescriptionTemplateType type) {
return this.getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("type"), type)).count();
}
}

View File

@ -1,7 +1,6 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DatasetService;
import java.util.UUID;

View File

@ -2,8 +2,6 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DatasetExternalDataset;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DatasetService;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -0,0 +1,10 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DescriptionTemplateType;
import java.util.UUID;
public interface DescriptionTemplateTypeDao extends DatabaseAccessLayer<DescriptionTemplateType, UUID> {
DescriptionTemplateType findFromName(String name);
}

View File

@ -0,0 +1,65 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("descriptionTemplateTypeDao")
public class DescriptionTemplateTypeDaoImpl extends DatabaseAccess<DescriptionTemplateType> implements DescriptionTemplateTypeDao {
@Autowired
public DescriptionTemplateTypeDaoImpl(DatabaseService<DescriptionTemplateType> databaseService) {
super(databaseService);
}
@Override
public DescriptionTemplateType findFromName(String name){
try {
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.and(builder.equal(root.get("name"), name), builder.notEqual(root.get("status"), DescriptionTemplateType.Status.DELETED.getValue()))).getSingle();
}
catch(Exception e){
return null;
}
}
@Override
@Transactional
public DescriptionTemplateType createOrUpdate(DescriptionTemplateType item) {
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplateType.class);
}
@Override
public DescriptionTemplateType find(UUID id) {
return getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
}
@Override
public void delete(DescriptionTemplateType item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DescriptionTemplateType> asQueryable() {
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.notEqual((root.get("status")), DescriptionTemplateType.Status.DELETED.getValue()));
}
@Async
@Override
public CompletableFuture<DescriptionTemplateType> createOrUpdateAsync(DescriptionTemplateType item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DescriptionTemplateType find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,9 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DMPDatasetProfile;
import java.util.UUID;
public interface DmpDatasetProfileDao extends DatabaseAccessLayer<DMPDatasetProfile, UUID> {
}

View File

@ -0,0 +1,52 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Content;
import eu.eudat.data.entities.DMPDatasetProfile;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Service("dmpDatasetProfileDao")
public class DmpDatasetProfileDaoImpl extends DatabaseAccess<DMPDatasetProfile> implements DmpDatasetProfileDao {
@Autowired
public DmpDatasetProfileDaoImpl(DatabaseService<DMPDatasetProfile> databaseService) {
super(databaseService);
}
@Override
public DMPDatasetProfile createOrUpdate(DMPDatasetProfile item) {
return this.getDatabaseService().createOrUpdate(item, DMPDatasetProfile.class);
}
@Override
@Async
public CompletableFuture<DMPDatasetProfile> createOrUpdateAsync(DMPDatasetProfile item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DMPDatasetProfile find(UUID id) {
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public DMPDatasetProfile find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(DMPDatasetProfile item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DMPDatasetProfile> asQueryable() {
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class);
}
}

View File

@ -0,0 +1,10 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.EntityDoi;
import java.util.UUID;
public interface EntityDoiDao extends DatabaseAccessLayer<EntityDoi, UUID> {
EntityDoi findFromDoi(String doi);
}

View File

@ -0,0 +1,56 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.EntityDoi;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("EntityDoiDao")
public class EntityDoiDaoImpl extends DatabaseAccess<EntityDoi> implements EntityDoiDao {
@Autowired
public EntityDoiDaoImpl(DatabaseService<EntityDoi> databaseService){
super(databaseService);
}
@Override
public EntityDoi createOrUpdate(EntityDoi item) {
return this.getDatabaseService().createOrUpdate(item, EntityDoi.class);
}
@Override
public CompletableFuture<EntityDoi> createOrUpdateAsync(EntityDoi item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public EntityDoi find(UUID id) {
return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public EntityDoi findFromDoi(String doi) {
return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("doi"), doi)).getSingle();
}
@Override
public EntityDoi find(UUID id, String hint) {
return null;
}
@Override
public void delete(EntityDoi item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<EntityDoi> asQueryable() {
return this.getDatabaseService().getQueryable(EntityDoi.class);
}
}

View File

@ -3,7 +3,9 @@ package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.FileUpload;
import java.util.List;
import java.util.UUID;
public interface FileUploadDao extends DatabaseAccessLayer<FileUpload, UUID> {
List<FileUpload> getFileUploads(UUID entityId);
}

View File

@ -7,6 +7,7 @@ import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@ -33,6 +34,11 @@ public class FileUploadDaoImpl extends DatabaseAccess<FileUpload> implements Fil
return getDatabaseService().getQueryable(FileUpload.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
}
@Override
public List<FileUpload> getFileUploads(UUID entityId) {
return this.getDatabaseService().getQueryable(FileUpload.class).where((builder, root) -> builder.equal(root.get("entityId"), entityId)).toList();
}
@Override
public FileUpload find(UUID id, String hint) {
return null;

View File

@ -25,7 +25,12 @@ import java.util.stream.Collectors;
name = "fullyDetailed",
attributeNodes = {
@NamedAttributeNode("grant"), @NamedAttributeNode("profile"),
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}),
@NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")
},
subgraphs = {
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")})
}
),
@NamedEntityGraph(
name = "dmpRecentActivity",
attributeNodes = {
@ -107,12 +112,8 @@ public class DMP implements DataEntity<DMP, UUID> {
/*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
private String associatedDmps;*/
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPDatasetProfile\"",
joinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")}
)
private Set<DatasetProfile> associatedDmps;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dmp")
private Set<DMPDatasetProfile> associatedDmps;
@ManyToOne(fetch = FetchType.LAZY)
@ -181,8 +182,8 @@ public class DMP implements DataEntity<DMP, UUID> {
@Convert(converter = DateToUTCConverter.class)
private Date publishedAt;
@Column(name = "\"DOI\"")
private String doi;
@OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY)
private Set<EntityDoi> dois;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Project\"")
@ -269,10 +270,10 @@ public class DMP implements DataEntity<DMP, UUID> {
this.grant = grant;
}
public Set<DatasetProfile> getAssociatedDmps() {
public Set<DMPDatasetProfile> getAssociatedDmps() {
return associatedDmps;
}
public void setAssociatedDmps(Set<DatasetProfile> associatedDmps) {
public void setAssociatedDmps(Set<DMPDatasetProfile> associatedDmps) {
this.associatedDmps = associatedDmps;
}
@ -339,12 +340,12 @@ public class DMP implements DataEntity<DMP, UUID> {
this.publishedAt = publishedAt;
}
public String getDoi() {
return doi;
}
public void setDoi(String doi) {
this.doi = doi;
}
public Set<EntityDoi> getDois() {
return dois;
}
public void setDois(Set<EntityDoi> dois) {
this.dois = dois;
}
public Project getProject() {
return project;
@ -380,7 +381,7 @@ public class DMP implements DataEntity<DMP, UUID> {
if (entity.getStatus().equals(DMPStatus.FINALISED.getValue())) this.setFinalizedAt(new Date());
if (entity.isPublic) this.setPublishedAt(new Date());
if (entity.getUsers() != null) this.users = entity.getUsers();
if (entity.getDoi() != null && entity.getDoi().trim().isEmpty()) this.doi = entity.doi;
this.dois = entity.getDois();
this.extraProperties = entity.getExtraProperties();
}

View File

@ -0,0 +1,76 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"DMPDatasetProfile\"")
public class DMPDatasetProfile implements DataEntity<DMPDatasetProfile, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@ManyToOne
@JoinColumn(name = "\"dmp\"")
private DMP dmp;
@ManyToOne
@JoinColumn(name = "\"datasetprofile\"")
private DescriptionTemplate datasetprofile;
@Column(name = "\"data\"")
private String data;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public DMP getDmp() {
return dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public DescriptionTemplate getDatasetprofile() {
return datasetprofile;
}
public void setDatasetprofile(DescriptionTemplate datasetprofile) {
this.datasetprofile = datasetprofile;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
@Override
public void update(DMPDatasetProfile entity) {
this.dmp = entity.getDmp();
this.datasetprofile = entity.getDatasetprofile();
this.data = entity.getData();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DMPDatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
}

View File

@ -100,6 +100,9 @@ public class Dataset implements DataEntity<Dataset, UUID> {
@JoinColumn(name = "\"DMP\"", nullable = false)
private DMP dmp;
@Column(name = "\"DmpSectionIndex\"")
private Integer dmpSectionIndex;
@Column(name = "\"Uri\"")
private String uri;
@ -110,7 +113,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
@ManyToOne(fetch = FetchType.LAZY)
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Profile\"")
private DatasetProfile profile;
private DescriptionTemplate profile;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml")
@ -232,6 +235,12 @@ public class Dataset implements DataEntity<Dataset, UUID> {
this.dmp = dmp;
}
public Integer getDmpSectionIndex() {
return dmpSectionIndex;
}
public void setDmpSectionIndex(Integer dmpSectionIndex) {
this.dmpSectionIndex = dmpSectionIndex;
}
public String getUri() {
return uri;
@ -249,10 +258,10 @@ public class Dataset implements DataEntity<Dataset, UUID> {
}
public DatasetProfile getProfile() {
public DescriptionTemplate getProfile() {
return profile;
}
public void setProfile(DatasetProfile profile) {
public void setProfile(DescriptionTemplate profile) {
this.profile = profile;
}
@ -328,6 +337,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
this.setRegistries(entity.getRegistries());
this.setDmp(entity.getDmp());
this.setDmpSectionIndex(entity.getDmpSectionIndex());
this.setStatus(entity.getStatus());
this.setProfile(entity.getProfile());
this.setModified(new Date());

View File

@ -14,8 +14,8 @@ import java.util.UUID;
@Entity
@Table(name = "\"DatasetProfile\"")
public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
@Table(name = "\"DescriptionTemplate\"")
public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>{
public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
@ -79,19 +79,21 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
@Column(name = "\"Version\"", nullable = false)
private Short version;
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPDatasetProfile\"",
joinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")}
)
private List<DMP> dmps;
@OneToMany(fetch = FetchType.LAZY)
private Set<DMP> dmps;
@Column(name = "\"Language\"", nullable = false)
private String language;
@OneToMany(mappedBy = "datasetProfile", fetch = FetchType.LAZY)
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Type\"", nullable = false)
private DescriptionTemplateType type;
@OneToMany(mappedBy = "descriptionTemplate", fetch = FetchType.LAZY)
private Set<UserDatasetProfile> users;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "datasetprofile")
private Set<DMPDatasetProfile> associatedDmps;
public String getDescription() {
return description;
@ -156,26 +158,31 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public DescriptionTemplateType getType() {
return type;
}
public void setType(DescriptionTemplateType type) {
this.type = type;
}
public Set<UserDatasetProfile> getUsers() {
return users;
}
public void setUsers(Set<UserDatasetProfile> users) {
this.users = users;
}
@Override
public String toString() {
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + ", language=" + language + "]";
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + ", language=" + language + ", type=" + type +"]";
}
@Override
public void update(DatasetProfile entity) {
public void update(DescriptionTemplate entity) {
}
@Override
@ -184,7 +191,7 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
}
@Override
public DatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
public DescriptionTemplate buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}

View File

@ -0,0 +1,89 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"DescriptionTemplateType\"")
public class DescriptionTemplateType implements DataEntity<DescriptionTemplateType, UUID> {
public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALIZED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Description Template Type Status");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Name\"", nullable = false)
private String name;
@Column(name = "\"Status\"", nullable = false)
private Short status;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
@Override
public void update(DescriptionTemplateType entity) {
this.name = entity.name;
this.status = entity.status;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DescriptionTemplateType buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(!base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
}

View File

@ -0,0 +1,121 @@
package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Entity
@Table(name = "\"EntityDoi\"")
public class EntityDoi implements DataEntity<EntityDoi, UUID> {
public enum EntityType {
DMP
}
@Id
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Enumerated(EnumType.STRING)
@Type(type = "eu.eudat.configurations.typedefinition.PostgreSQLEnumType")
@Column(name = "\"EntityType\"", nullable = false)
private EntityType entityType;
@Column(name = "\"RepositoryId\"", nullable = false)
private String repositoryId;
@Column(name = "\"Doi\"", nullable = false)
private String doi;
@Column(name = "\"CreatedAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date createdAt;
@Column(name = "\"UpdatedAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date updatedAt;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"EntityId\"", nullable = false)
private DMP entityId;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public EntityType getEntityType() {
return entityType;
}
public void setEntityType(EntityType entityType) {
this.entityType = entityType;
}
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getDoi() {
return doi;
}
public void setDoi(String doi) {
this.doi = doi;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public DMP getEntityId() {
return entityId;
}
public void setEntityId(DMP entityId) {
this.entityId = entityId;
}
@Override
public void update(EntityDoi doi) {
this.entityType = doi.getEntityType();
this.repositoryId = doi.getRepositoryId();
this.doi = doi.getDoi();
this.createdAt = doi.getCreatedAt();
this.updatedAt = doi.getUpdatedAt();
this.entityId = doi.getEntityId();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public EntityDoi buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
if (fields.contains(currentBase + "entityId"))
this.entityId = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields , base.isEmpty() ? "entityId" : base + "." + "entityId")).collect(Collectors.toList()).get(0);
return this;
}
}

View File

@ -22,8 +22,8 @@ public class UserDatasetProfile implements DataEntity<UserDatasetProfile, UUID>
private UserInfo user;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"datasetProfile\"")
private DatasetProfile datasetProfile;
@JoinColumn(name = "\"descriptionTemplate\"")
private DescriptionTemplate descriptionTemplate;
@Column(name = "role")
private Integer role;
@ -44,12 +44,12 @@ public class UserDatasetProfile implements DataEntity<UserDatasetProfile, UUID>
this.user = user;
}
public DatasetProfile getDatasetProfile() {
return datasetProfile;
public DescriptionTemplate getDatasetProfile() {
return descriptionTemplate;
}
public void setDatasetProfile(DatasetProfile datasetProfile) {
this.datasetProfile = datasetProfile;
public void setDatasetProfile(DescriptionTemplate descriptionTemplate) {
this.descriptionTemplate = descriptionTemplate;
}
public Integer getRole() {

View File

@ -3,12 +3,14 @@ package eu.eudat.data.query.definition;
import eu.eudat.data.dao.criteria.Criteria;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.queryableentity.DataEntity;
import io.swagger.annotations.ApiModelProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class Query<C extends Criteria<T>, T extends DataEntity> implements CriteriaQuery<C, T> {
private static final Logger logger = LoggerFactory.getLogger(Query.class);
private C criteria;
@ApiModelProperty(value = "query", name = "query", dataType = "String", hidden = true)
private QueryableList<T> query;
public static class QueryBuilder<C extends Criteria<T>, T extends DataEntity, Q extends Query<C, T>> {

View File

@ -6,12 +6,16 @@ import eu.eudat.data.query.definition.helpers.ColumnOrderings;
import eu.eudat.data.query.definition.helpers.SelectionFields;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.queryableentity.DataEntity;
import io.swagger.annotations.ApiModelProperty;
public abstract class TableQuery<C extends Criteria<T>, T extends DataEntity<T, K>, K> extends Query<C, T> implements TableCriteriaQuery<C, T> {
private ColumnOrderings orderings;
@ApiModelProperty(hidden = true)
private SelectionFields selection;
@ApiModelProperty(value = "length", name = "length", dataType = "Integer", example = "2")
private Integer length;
@ApiModelProperty(value = "offset", name = "offset", dataType = "Integer", example = "0")
private Integer offset;
public Integer getLength() {

View File

@ -1,11 +1,14 @@
package eu.eudat.data.query.definition.helpers;
import io.swagger.annotations.ApiModelProperty;
import java.util.LinkedList;
import java.util.List;
public class ColumnOrderings {
@ApiModelProperty(value = "fields", name = "fields", dataType = "List<String>", example = "[]")
private List<String> fields;
public List<String> getFields() {

View File

@ -1,8 +1,11 @@
package eu.eudat.data.query.definition.helpers;
import io.swagger.annotations.ApiModelProperty;
public class SelectionFields {
@ApiModelProperty(value = "fields", name = "fields", dataType = "String[]", example = "[]")
private String[] fields;
public String[] getFields() {

View File

@ -0,0 +1,27 @@
package eu.eudat.data.query.items.dmpblueprint;
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class DataManagementPlanBlueprintTableRequest extends TableQuery<DataManagementPlanBlueprintCriteria, DMPProfile, UUID> {
@Override
public QueryableList<DMPProfile> applyCriteria() {
QueryableList<DMPProfile> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
if (this.getCriteria().getStatus() != null)
query.where((builder, root) -> builder.equal(root.get("status"), this.getCriteria().getStatus()));
return query;
}
@Override
public QueryableList<DMPProfile> applyPaging(QueryableList<DMPProfile> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -1,25 +1,24 @@
package eu.eudat.data.query.items.item.datasetprofile;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.definition.Query;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria,DatasetProfile, UUID> {
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
@Override
public QueryableList<DatasetProfile> applyCriteria() {
QueryableList<DatasetProfile> query = this.getQuery();
public QueryableList<DescriptionTemplate> applyCriteria() {
QueryableList<DescriptionTemplate> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query;
}
@Override
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
return PaginationService.applyPaging(items, this);
}
}

View File

@ -1,15 +1,13 @@
package eu.eudat.data.query.items.item.datasetprofile;
import eu.eudat.data.dao.criteria.DatasetProfileWizardCriteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.definition.Query;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria,DatasetProfile> {
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria, DescriptionTemplate> {
@Override
public QueryableList<DatasetProfile> applyCriteria() {
public QueryableList<DescriptionTemplate> applyCriteria() {
return null;
}
}

View File

@ -1,23 +1,23 @@
package eu.eudat.data.query.items.table.datasetprofile;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DatasetProfile, UUID> {
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
@Override
public QueryableList<DatasetProfile> applyCriteria() {
QueryableList<DatasetProfile> query = this.getQuery();
public QueryableList<DescriptionTemplate> applyCriteria() {
QueryableList<DescriptionTemplate> query = this.getQuery();
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
return query;
}
@Override
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
return null;
}
}

View File

@ -231,7 +231,9 @@ public class Dataset implements ElasticEntity<Dataset> {
if (this.group != null) {
builder.field("group", this.group.toString());
}
builder.field("grant", this.grant.toString());
if (this.grant != null) {
builder.field("grant", this.grant.toString());
}
if (collaborators != null) {
builder.startArray("collaborators");
this.collaborators.forEach(x -> {
@ -300,7 +302,9 @@ public class Dataset implements ElasticEntity<Dataset> {
this.status = Short.valueOf((String) fields.get("status"));
this.dmp = UUID.fromString((String) fields.get("dmp"));
this.group = UUID.fromString((String) fields.get("group"));
this.grant = UUID.fromString((String) fields.get("grant"));
if (fields.get("grant") != null) {
this.grant = UUID.fromString((String) fields.get("grant"));
}
if (fields.get("created") != null)
this.created = Date.from(Instant.parse((String) fields.get("created")));
if (fields.get("modified") != null)

View File

@ -1,14 +1,18 @@
package eu.eudat.elastic.entities;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
private UUID id;
private String name;
private Map<String, Object> data;
public UUID getId() {
return id;
@ -26,11 +30,25 @@ public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
this.name = name;
}
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
@Override
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
builder.startObject();
builder.field("id", this.id.toString());
builder.field("name", this.name);
if(this.data != null) {
builder.field("data", new ObjectMapper().writeValueAsString(this.data));
}
else{
builder.field("data", "");
}
builder.endObject();
return builder;
}
@ -39,6 +57,12 @@ public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
public DatasetTempalate fromElasticEntity(Map<String, Object> fields) {
this.id = UUID.fromString((String) fields.get("id"));
this.name = (String) fields.get("name");
try {
this.data = new ObjectMapper().readValue((String) fields.get("data"), new TypeReference<Map<String, Object>>() {});
}
catch (Exception e){
this.data = new HashMap<>();
}
return this;
}
}

View File

@ -57,7 +57,7 @@ public class Dmp implements ElasticEntity<Dmp> {
private Date modified;
private Date finalizedAt;
private Date publishedAt;
private String doi;
private List<Doi> dois;
public UUID getId() {
return id;
@ -203,12 +203,12 @@ public class Dmp implements ElasticEntity<Dmp> {
this.publishedAt = publishedAt;
}
public String getDoi() {
return doi;
public List<Doi> getDois() {
return dois;
}
public void setDoi(String doi) {
this.doi = doi;
public void setDois(List<Doi> dois) {
this.dois = dois;
}
@Override
@ -280,7 +280,17 @@ public class Dmp implements ElasticEntity<Dmp> {
builder.field(MapKey.MODIFIED.getName(), this.modified);
builder.field(MapKey.FINALIZEDAT.getName(), this.finalizedAt);
builder.field(MapKey.PUBLISHEDAT.getName(), this.publishedAt);
builder.field(MapKey.DOI.getName(), this.doi);
if (this.dois != null && !this.dois.isEmpty()) {
builder.startArray(MapKey.DOIS.getName());
this.dois.forEach(doi -> {
try {
doi.toElasticEntity(builder);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
});
builder.endArray();
}
builder.endObject();
return builder;
}
@ -313,7 +323,9 @@ public class Dmp implements ElasticEntity<Dmp> {
if (fields.get(MapKey.DATASETS.getName()) != null) {
this.datasets = ((List<HashMap<String, Object>>) fields.get(MapKey.DATASETS.getName())).stream().map(map -> new Dataset().fromElasticEntity(map)).collect(Collectors.toList());
}
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
if (fields.containsKey(MapKey.GRANT.getName()) && fields.get(MapKey.GRANT.getName()) != null) {
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
}
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
}
@ -329,8 +341,8 @@ public class Dmp implements ElasticEntity<Dmp> {
if (fields.get(MapKey.PUBLISHEDAT.getName()) != null) {
this.publishedAt = Date.from(Instant.parse(fields.get(MapKey.PUBLISHEDAT.getName()).toString()));
}
if (fields.get(MapKey.DOI.getName()) != null) {
this.doi = fields.get(MapKey.DOI.getName()).toString();
if (fields.get(MapKey.DOIS.getName()) != null) {
this.dois = ((List<HashMap<String, Object>>) fields.get(MapKey.DOIS.getName())).stream().map(map -> new Doi().fromElasticEntity(map)).collect(Collectors.toList());
}
}
return this;
@ -355,7 +367,7 @@ public class Dmp implements ElasticEntity<Dmp> {
MODIFIED ("modified"),
FINALIZEDAT ("finalizedAt"),
PUBLISHEDAT ("publishedAt"),
DOI ("doi");
DOIS ("dois");
private final String name;

View File

@ -0,0 +1,65 @@
package eu.eudat.elastic.entities;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException;
import java.util.Map;
import java.util.UUID;
public class Doi implements ElasticEntity<Doi>{
private UUID id;
private String repositoryId;
private String doi;
private UUID dmp;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getRepositoryId() {
return repositoryId;
}
public void setRepositoryId(String repositoryId) {
this.repositoryId = repositoryId;
}
public String getDoi() {
return doi;
}
public void setDoi(String doi) {
this.doi = doi;
}
public UUID getDmp() {
return dmp;
}
public void setDmp(UUID dmp) {
this.dmp = dmp;
}
@Override
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
builder.startObject();
builder.field("id", this.id.toString());
builder.field("repositoryId", this.repositoryId);
builder.field("doi", this.doi);
builder.field("dmp", this.dmp.toString());
builder.endObject();
return builder;
}
@Override
public Doi fromElasticEntity(Map<String, Object> fields) {
if (fields == null || fields.isEmpty()) {
return null;
}
this.id = UUID.fromString((String) fields.get("id"));
this.repositoryId = (String) fields.get("repositoryId");
this.doi = (String) fields.get("doi");
this.dmp = UUID.fromString((String) fields.get("dmp"));
return this;
}
}

View File

@ -146,7 +146,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
}
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.tags"}, null)));
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.tags"}, null)).setSize(this.environment.getProperty("elasticsearch.innerHitsSize", Integer.class)));
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset())*/.fetchSource("datasets.tags", null);
/*if (criteria.getSize() > 0) {
searchSourceBuilder.size(criteria.getSize());
@ -206,7 +206,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
}
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.id"}, null)));
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.id"}, null)).setSize(this.environment.getProperty("elasticsearch.innerHitsSize", Integer.class)));
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset()).size(criteria.getSize())*/.fetchSource("datasets.id", null);
sortBuilders.forEach(searchSourceBuilder::sort);
searchRequest.source(searchSourceBuilder);
@ -261,6 +261,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
}
if (criteria.getDatasetTemplates() != null && criteria.getDatasetTemplates().size() > 0) {
criteria.setDatasetTemplates(criteria.getDatasetTemplates().stream().filter(Objects::nonNull).collect(Collectors.toList()));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.template", criteria.getDatasetTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
}
@ -269,14 +270,17 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
}
if (criteria.getDmps() != null && criteria.getDmps().size() > 0) {
criteria.setDmps(criteria.getDmps().stream().filter(Objects::nonNull).collect(Collectors.toList()));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.dmp", criteria.getDmps().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
criteria.setGroupIds(criteria.getGroupIds().stream().filter(Objects::nonNull).collect(Collectors.toList()));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.group", criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
}
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
criteria.setGrants(criteria.getGrants().stream().filter(Objects::nonNull).collect(Collectors.toList()));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.grant", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
}
@ -285,6 +289,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
}
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
criteria.setCollaborators(criteria.getCollaborators().stream().filter(Objects::nonNull).collect(Collectors.toList()));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.collaborators.id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
}
@ -295,10 +300,12 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
}
if (criteria.getOrganiztions() != null && criteria.getOrganiztions().size() > 0) {
criteria.setOrganiztions(criteria.getOrganiztions().stream().filter(Objects::nonNull).collect(Collectors.toList()));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.organizations.id", criteria.getOrganiztions()));
}
if (criteria.getTags() != null && criteria.getTags().size() > 0) {
criteria.setTags(criteria.getTags().stream().filter(Objects::nonNull).collect(Collectors.toList()));
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.tags.name", criteria.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
}

View File

@ -30,6 +30,7 @@ public abstract class ElasticRepository<T extends ElasticEntity,C extends Criter
}
} catch (IOException e) {
logger.warn("Unable to connect to Elastic Services");
logger.error(e.getMessage(), e);
this.client = null;
}
}

View File

@ -42,7 +42,7 @@
<org.junit.version>4.11</org.junit.version>
<log4j.version>1.2.17</log4j.version>
<log4j2.version>2.15.0</log4j2.version>
<slf4j.version>1.7.12</slf4j.version>
<slf4j.version>1.7.15</slf4j.version>
<!--<jetty.version>11.0.5
</jetty.version>--> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
<logback.version>1.2.3</logback.version>
@ -173,13 +173,13 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.0</version>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
<version>4.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
@ -327,6 +327,18 @@
<packaging.type>jar</packaging.type>
</properties>
</profile>
<profile>
<id>intellij-properties-launcher</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-loader</artifactId>
<version>2.5.2</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>production</id>
<properties>

View File

@ -26,13 +26,16 @@
<artifactId>queryable</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.eudat</groupId>
<artifactId>elastic</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>repositorydepositbase</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
@ -43,6 +46,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
@ -95,6 +102,16 @@
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<!-- facebook Login -->
<dependency>
@ -209,6 +226,40 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.9.RELEASE</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>eu.eudat.EuDatApplication</mainClass>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/dependency-jars/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -8,7 +8,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"eu.eudat", "eu.eudat.depositinterface"})
@EnableAsync
public class EuDatApplication extends SpringBootServletInitializer {
private static final Logger logger = LoggerFactory.getLogger(EuDatApplication.class);

View File

@ -4,11 +4,15 @@ import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
import org.apache.http.nio.reactor.IOReactorException;
import org.apache.http.nio.reactor.IOReactorExceptionHandler;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.slf4j.Logger;
@ -18,7 +22,17 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
/**
* Created by ikalyvas on 7/5/2018.
@ -56,12 +70,46 @@ public class ElasticSearchConfiguration {
}
});
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost(this.environment.getProperty("elasticsearch.host"),
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "http"))
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
.setDefaultCredentialsProvider(credentialsProvider).setConnectionManager(new PoolingNHttpClientConnectionManager(ioReactor))));
RestHighLevelClient client;
if(this.environment.getProperty("elasticsearch.usingssl", Boolean.class)){
// Path caCertificatePath = Paths.get(this.environment.getProperty("elasticsearch.certPath"));
// CertificateFactory factory =
// CertificateFactory.getInstance("X.509");
// Certificate trustedCa;
// try (InputStream is = Files.newInputStream(caCertificatePath)) {
// trustedCa = factory.generateCertificate(is);
// }
// KeyStore trustStore = KeyStore.getInstance("pkcs12");
// trustStore.load(null, null);
// trustStore.setCertificateEntry("ca", trustedCa);
//
// TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
// tmf.init(trustStore);
//
// SSLContext sslContext = SSLContext.getInstance("TLS");
// sslContext.init(null, tmf.getTrustManagers(), null);
SSLContextBuilder sslBuilder = SSLContexts.custom()
.loadTrustMaterial(null, (x509Certificates, s) -> true);
final SSLContext sslContext = sslBuilder.build();
client = new RestHighLevelClient(
RestClient.builder(
new HttpHost(this.environment.getProperty("elasticsearch.host"),
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "https"))
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
.setDefaultCredentialsProvider(credentialsProvider).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).setSSLContext(sslContext))
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000).setSocketTimeout(120000))
);
}
else {
client = new RestHighLevelClient(
RestClient.builder(
new HttpHost(this.environment.getProperty("elasticsearch.host"),
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "http"))
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
.setDefaultCredentialsProvider(credentialsProvider).setConnectionManager(new PoolingNHttpClientConnectionManager(ioReactor))));
}
return client;
}catch (IOReactorException ex) {
throw new RuntimeException(ex);

View File

@ -24,7 +24,7 @@ import java.util.Properties;
*/
@Configuration
@EnableTransactionManagement
@Profile({ "production", "staging" })
@Profile({ "production", "staging", "docker" })
@ComponentScan(basePackages = {"eu.eudat.data.entities"})
public class ProductionDatabaseConfiguration {

View File

@ -20,7 +20,7 @@ import java.util.LinkedList;
import java.util.List;
@Service("dynamicFunderConfiguration")
@Profile({ "production", "staging" })
@Profile({ "production", "staging", "docker" })
public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicFunderConfigurationProdImpl.class);

View File

@ -24,7 +24,7 @@ import java.util.List;
* Created by ikalyvas on 3/23/2018.
*/
@Service("dynamicGrantConfiguration")
@Profile({ "production", "staging" })
@Profile({ "production", "staging", "docker" })
public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationProdImpl.class);

View File

@ -21,7 +21,7 @@ import java.util.LinkedList;
import java.util.List;
@Service("dynamicProjectConfiguration")
@Profile({ "production", "staging" })
@Profile({ "production", "staging", "docker" })
public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfiguration{
private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationProdImpl.class);

View File

@ -0,0 +1,39 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.MaterialManager;
import eu.eudat.logic.managers.MetricsManager;
import eu.eudat.types.MetricNames;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.stream.Stream;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/material/about/"})
public class AboutController {
private Environment environment;
private MaterialManager materialManager;
@Autowired
public AboutController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
this.environment = environment;
this.materialManager = materialManager;
}
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
public ResponseEntity<byte[]> getAbout(@PathVariable(name = "lang") String lang) throws IOException {
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("about.path"))))) {
return this.materialManager.getResponseEntity(lang, paths);
}
}
}

View File

@ -1,5 +1,6 @@
package eu.eudat.controllers;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.UserDatasetProfile;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
@ -16,7 +17,6 @@ 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.listingmodels.UserInfoListingModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.types.ApiMessageCode;
@ -32,7 +32,6 @@ import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static eu.eudat.types.Authorities.ADMIN;
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
@ -58,41 +57,42 @@ public class Admin extends BaseController {
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) {
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
DatasetProfile shortenProfile = profile.toShort();
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
modelDefinition.setType(getApiContext().getOperationsContext().getDatabaseRepository().getDescriptionTemplateTypeDao().findFromName(profile.getType()));
modelDefinition.setGroupId(UUID.randomUUID());
modelDefinition.setVersion((short) 0);
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
userDatasetProfile.setDatasetProfile(datasetProfile);
userDatasetProfile.setDatasetProfile(descriptionTemplate);
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
userDatasetProfile.setUser(userInfo);
userDatasetProfile.setRole(0);
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
datasetProfileManager.storeDatasetProfileUsers(descriptionTemplate, profile);
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricsManager.datasetTemplateStatus.get(datasetProfile.getStatus()) );
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricsManager.datasetTemplateStatus.get(descriptionTemplate.getStatus()) );
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
DatasetProfile shortenProfile = profile.toShort();
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
DescriptionTemplate datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
datasetprofile.setDefinition(modelDefinition.getDefinition());
Short oldStatus = datasetprofile.getStatus();
datasetprofile.setStatus(modelDefinition.getStatus());
datasetprofile.setLabel(modelDefinition.getLabel());
datasetprofile.setDescription(modelDefinition.getDescription());
datasetprofile.setLanguage(modelDefinition.getLanguage());
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
if (datasetProfile.getStatus() == 1 && oldStatus == 0) {
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
datasetProfileManager.storeDatasetProfileUsers(descriptionTemplate, profile);
if (descriptionTemplate.getStatus() == 1 && oldStatus == 0) {
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricNames.ACTIVE);
}
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
@ -102,7 +102,7 @@ public class Admin extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/newVersion/{id}"}, produces = "application/json")
public ResponseEntity newVersionDatasetProfile(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
try {
eu.eudat.data.entities.DatasetProfile modelDefinition = this.datasetProfileManager.createNewVersionDatasetProfile(id, profile);
DescriptionTemplate modelDefinition = this.datasetProfileManager.createNewVersionDatasetProfile(id, profile);
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
} catch (DatasetProfileNewVersionException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
@ -124,8 +124,8 @@ public class Admin extends BaseController {
}
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition);
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile);
@ -145,7 +145,7 @@ public class Admin extends BaseController {
public @ResponseBody
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
try {
eu.eudat.data.entities.DatasetProfile ret = AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
DescriptionTemplate ret = AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (DatasetProfileWithDatasetsExeption exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
@ -156,36 +156,45 @@ public class Admin extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
public ResponseEntity getDatasetProfileXml(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
if (contentType.equals("application/xml")) {
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
DescriptionTemplate profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(profile);
datasetProfile.setStatus(profile.getStatus());
datasetProfile.setDescription(profile.getDescription());
datasetProfile.setLanguage(profile.getLanguage());
datasetProfile.setType(profile.getType().getName());
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
} else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
@RequestMapping(method = RequestMethod.POST, value = {"/upload", "/upload/{id}"})
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws IllegalAccessException, IOException {
@PathVariable(value = "id", required = false) String id,
@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
userDatasetProfile.setDatasetProfile(datasetProfile);
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
userDatasetProfile.setUser(userInfo);
userDatasetProfile.setRole(0);
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
DescriptionTemplate modelDefinition;
if (id == null) {
modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
userDatasetProfile.setDatasetProfile(descriptionTemplate);
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
userDatasetProfile.setUser(userInfo);
userDatasetProfile.setRole(0);
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
} else {
modelDefinition = datasetProfileManager.createNewVersionDatasetProfile(id, datasetProfileEntity);
}
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
}
@RequestMapping(method = RequestMethod.GET, value = {"/getRDACommonStandards"}, produces = "application/json")
public ResponseEntity getRDACommonStandards(@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<String>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(configLoader.getRdaProperties()));
@RequestMapping(method = RequestMethod.GET, value = {"/getSemantics"}, produces = "application/json")
public ResponseEntity<ResponseItem<List<String>>> getSemantics(@RequestParam(value = "query", required = false) String query, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
List<String> semantics = this.datasetProfileManager.getSemantics(query);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<String>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(semantics));
}
}

View File

@ -2,7 +2,10 @@ package eu.eudat.controllers;
import eu.eudat.data.dao.criteria.RequestItem;
import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
import eu.eudat.exceptions.dmpblueprint.DmpBlueprintUsedException;
import eu.eudat.logic.managers.DataManagementProfileManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
@ -10,6 +13,7 @@ import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
@ -26,6 +30,7 @@ import java.io.IOException;
import java.util.List;
import static eu.eudat.types.Authorities.ADMIN;
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
/**
* Created by ikalyvas on 3/21/2018.
@ -51,6 +56,14 @@ public class DMPProfileController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/blueprint"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMPProfile>> createOrUpdateBlueprint(@RequestBody DataManagementPlanBlueprintListingModel dataManagementPlan, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
this.dataManagementProfileManager.createOrUpdateBlueprint(dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataManagementPlanProfileListingModel>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
@ -58,6 +71,13 @@ public class DMPProfileController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel));
}
@RequestMapping(method = RequestMethod.GET, value = {"/getSingleBlueprint/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> getSingleBlueprint(@PathVariable String id, Principal principal) {
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanBlueprintListingModel));
}
@RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception {
@ -65,24 +85,51 @@ public class DMPProfileController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.POST, value = {"/getPagedBlueprint"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanBlueprintListingModel>>> getPagedBlueprint(@Valid @RequestBody DataManagementPlanBlueprintTableRequest dataManagementPlanBlueprintTableRequest, Principal principal) throws Exception {
DataTableData<DataManagementPlanBlueprintListingModel> dataTable = this.dataManagementProfileManager.getPagedBlueprint(dataManagementPlanBlueprintTableRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanBlueprintListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
DataManagementPlanBlueprintListingModel dmpBlueprint = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
dmpBlueprint.setLabel(dmpBlueprint.getLabel() + " new ");
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().payload(dmpBlueprint));
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Void>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
try {
this.dataManagementProfileManager.inactivate(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (DmpBlueprintUsedException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException, IOException {
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IOException {
if (contentType.equals("application/xml")) {
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id, principal);
return this.dataManagementProfileManager.getDocument(dataManagementPlanProfileListingModel,dataManagementPlanProfileListingModel.getLabel());
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
return this.dataManagementProfileManager.getDocument(dataManagementPlanBlueprintListingModel);
}else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException,Exception{
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename());
this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint dmpBlueprintModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
DataManagementPlanBlueprintListingModel dmpBlueprint = dmpBlueprintModel.toDmpProfileCompositeModel(file.getOriginalFilename());
this.dataManagementProfileManager.createOrUpdateBlueprint(dmpBlueprint, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
}

View File

@ -9,12 +9,10 @@ import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.managers.DataManagementPlanManager;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
@ -152,7 +150,7 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
ResponseEntity<ResponseItem<DataManagementPlanOverviewModel>> getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
// try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
@ -184,7 +182,21 @@ public class DMPs extends BaseController {
public @ResponseBody
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
try {
return this.dataManagementPlanManager.getRDAJsonDocument(id, principal);
FileEnvelope rdaJsonDocument = this.dataManagementPlanManager.getRDAJsonDocument(id, principal);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(rdaJsonDocument.getFile().length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + rdaJsonDocument.getFilename());
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
InputStream resource = new FileInputStream(rdaJsonDocument.getFile());
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
resource.close();
Files.deleteIfExists(rdaJsonDocument.getFile().toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(new ResponseItem<>().message(e.getMessage()).status(ApiMessageCode.ERROR_MESSAGE));
}
@ -248,7 +260,7 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<UUID>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
UUID cloneId = this.dataManagementPlanManager.clone(dataManagementPlan, principal);
UUID cloneId = this.dataManagementPlanManager.clone(id, dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId));
}
@ -321,21 +333,6 @@ public class DMPs extends BaseController {
}
}
/*
* DOI Generation
* */
@RequestMapping(method = RequestMethod.POST, value = {"/createZenodoDoi/{id}"})
public ResponseEntity<ResponseItem<String>> createZenodoDoi(@PathVariable String id, Principal principal) {
try {
String zenodoDOI = this.dataManagementPlanManager.createZenodoDoi(UUID.fromString(id), principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(zenodoDOI));
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan: " + e.getMessage()));
}
}
/*
* Data Index
* */

View File

@ -1,6 +1,7 @@
package eu.eudat.controllers;
import eu.eudat.data.dao.criteria.RequestItem;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.managers.AdminManager;
import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
@ -8,6 +9,7 @@ import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
import eu.eudat.models.data.helpers.common.AutoCompleteOptionsLookupItem;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.properties.PropertiesModel;
import eu.eudat.models.data.security.Principal;
@ -55,7 +57,7 @@ public class DatasetProfileController extends BaseController {
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN})Principal principal) {
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id);
DescriptionTemplate profile = this.datasetProfileManager.clone(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<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
@ -63,11 +65,19 @@ public class DatasetProfileController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> 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 = this.datasetProfileManager.queryForField(datasetProfile.getDefinition(), lookupItem.getCriteria().getFieldID());
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID()));
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = this.datasetProfileManager.queryForField(descriptionTemplate.getDefinition(), lookupItem.getCriteria().getFieldID());
AutoCompleteData data = (AutoCompleteData) modelfield.getData();
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
return ResponseEntity.status(HttpStatus.OK).body(items);
}
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocompleteOptions"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<Object> getDataForAutocompleteOptions(@RequestBody RequestItem<AutoCompleteOptionsLookupItem> lookupItem) {
AutoCompleteData data = new AutoCompleteData();
data.setAutoCompleteSingleDataList(lookupItem.getCriteria().getAutoCompleteSingleDataList());
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
return ResponseEntity.status(HttpStatus.OK).body(items);
}
}

View File

@ -6,6 +6,7 @@ import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,5 +43,12 @@ public class DatasetProfiles extends BaseController {
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
}
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getAllWithPrefilling"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>> getAllWithPrefilling(@RequestBody DatasetProfileTableRequestItem tableRequestItem) {
List<DatasetProfileWithPrefillingPropertyModel> datasetProfileTableData = this.datasetProfileManager.getAllWithPrefilling(tableRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.controllers;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DescriptionTemplate;
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;
@ -117,7 +118,7 @@ public class Datasets extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
ResponseEntity<ResponseItem<DatasetOverviewModel>> getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
// try {
DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, principal, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
@ -202,7 +203,7 @@ public class Datasets extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json")
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) {
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
DescriptionTemplate 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);
@ -256,7 +257,8 @@ public class Datasets extends BaseController {
public @ResponseBody
ResponseEntity<ResponseItem<DatasetWizardModel>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) throws Exception {
DatasetWizardModel dataset = new DatasetWizardModel().fromDataModel(this.datasetManager.createOrUpdate(profile, principal));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dataset));
dataset.setTags(profile.getTags());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dataset));
}
@Transactional

View File

@ -0,0 +1,84 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.DepositManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.doi.DepositCode;
import eu.eudat.models.data.doi.DepositRequest;
import eu.eudat.models.data.doi.Doi;
import eu.eudat.models.data.doi.RepositoryConfig;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.types.Authorities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/deposit/"})
public class DepositController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(DepositController.class);
private DepositManager depositManager;
@Autowired
public DepositController(ApiContext apiContext, DepositManager depositManager){
super(apiContext);
this.depositManager = depositManager;
}
@RequestMapping(method = RequestMethod.GET, value = {"/repos"})
public @ResponseBody
ResponseEntity<ResponseItem<List<RepositoryConfig>>> getAvailableRepos(@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
List<RepositoryConfig> ids = this.depositManager.getAvailableRepos();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RepositoryConfig>>().status(ApiMessageCode.NO_MESSAGE).payload(ids));
}
@RequestMapping(method = RequestMethod.POST, value = {"/getAccessToken"})
public @ResponseBody
ResponseEntity<ResponseItem<String>> getAccessToken(@RequestBody DepositCode depositCode, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
String accessToken = this.depositManager.authenticate(depositCode.getRepositoryId(), depositCode.getCode());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.NO_MESSAGE).payload(accessToken));
}
@RequestMapping(method = RequestMethod.POST, value = {"/createDoi"})
public @ResponseBody
ResponseEntity<ResponseItem<Doi>> createDoi(@RequestBody DepositRequest depositRequest, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
try {
Doi doi = this.depositManager.deposit(depositRequest, principal);
if(doi != null){
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Doi>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(doi));
}
else{
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Doi>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan"));
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Doi>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan: " + e.getMessage()));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/logo/{repositoryId}"})
public @ResponseBody
ResponseEntity<ResponseItem<String>> getLogo(@PathVariable("repositoryId") String repositoryId, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
try {
String encodedLogo = this.depositManager.getRepositoryLogo(repositoryId);
if(encodedLogo != null){
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully loaded " + repositoryId + "'s logo.").payload(encodedLogo));
}
else{
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message(repositoryId + " has no logo").payload(null));
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to load " + repositoryId + "'s logo: " + e.getMessage()));
}
}
}

View File

@ -0,0 +1,94 @@
package eu.eudat.controllers;
import eu.eudat.exceptions.descriptiontemplate.DescriptionTemplatesWithTypeException;
import eu.eudat.logic.managers.DescriptionTemplateTypeManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.descriptiontemplatetype.DescriptionTemplateTypeModel;
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.types.ApiMessageCode;
import eu.eudat.types.Authorities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import java.util.UUID;
import static eu.eudat.types.Authorities.ADMIN;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/descriptionTemplateType/"})
public class DescriptionTemplateTypeController extends BaseController {
private DescriptionTemplateTypeManager descriptionTemplateTypeManager;
@Autowired
public DescriptionTemplateTypeController(ApiContext apiContext, DescriptionTemplateTypeManager descriptionTemplateTypeManager){
super(apiContext);
this.descriptionTemplateTypeManager = descriptionTemplateTypeManager;
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"create"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> create(@RequestBody DescriptionTemplateTypeModel type, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
try {
this.descriptionTemplateTypeManager.create(type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
catch(DescriptionTemplatesWithTypeException e){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"update"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> update(@RequestBody DescriptionTemplateTypeModel type, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
try {
this.descriptionTemplateTypeManager.update(type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Updated"));
}
catch(DescriptionTemplatesWithTypeException e){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"get"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DescriptionTemplateTypeModel>>> get(@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
DataTableData<DescriptionTemplateTypeModel> dataTable = this.descriptionTemplateTypeManager.get();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DescriptionTemplateTypeModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.GET, value = {"get/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> getSingle(@PathVariable(value = "id") UUID id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
try {
DescriptionTemplateTypeModel typeModel = this.descriptionTemplateTypeManager.getSingle(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.NO_MESSAGE).payload(typeModel));
}
catch(DescriptionTemplatesWithTypeException e){
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> delete(@PathVariable(value = "id") UUID id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
try{
this.descriptionTemplateTypeManager.delete(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted"));
}
catch(DescriptionTemplatesWithTypeException e){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.UNSUCCESS_DELETE).message(e.getMessage()));
}
}
}

View File

@ -32,16 +32,16 @@ public class EmailMergeConfirmation {
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"/{emailToken}"})
public @ResponseBody
ResponseEntity<ResponseItem> emailConfirmation(@PathVariable(value = "emailToken") String token) {
ResponseEntity<ResponseItem<String>> emailConfirmation(@PathVariable(value = "emailToken") String token) {
try {
this.emailConfirmationManager.confirmEmail(token);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
String emailToBeMerged = this.emailConfirmationManager.confirmEmail(token);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().payload(emailToBeMerged).status(ApiMessageCode.SUCCESS_MESSAGE));
} catch
(HasConfirmedEmailException | TokenExpiredException ex) {
if (ex instanceof TokenExpiredException) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.NO_MESSAGE));
} else {
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE));
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem<String>().status(ApiMessageCode.WARN_MESSAGE));
}
}
}

View File

@ -0,0 +1,57 @@
package eu.eudat.controllers;
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.managers.UnlinkEmailConfirmationManager;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.userinfo.UserUnlinkRequestModel;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
@RestController
@CrossOrigin
@RequestMapping(value = "api/emailUnlinkConfirmation")
public class EmailUnlinkConfirmation {
private UnlinkEmailConfirmationManager unlinkEmailConfirmationManager;
@Autowired
public EmailUnlinkConfirmation(UnlinkEmailConfirmationManager unlinkEmailConfirmationManager){
this.unlinkEmailConfirmationManager = unlinkEmailConfirmationManager;
}
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"/{emailToken}"})
public @ResponseBody
ResponseEntity<ResponseItem> emailConfirmation(@PathVariable(value = "emailToken") String token) {
try {
this.unlinkEmailConfirmationManager.confirmEmail(token);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (TokenExpiredException | HasConfirmedEmailException ex) {
if (ex instanceof TokenExpiredException) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE));
}
else {
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE));
}
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem> sendUnlinkConfirmationEmail(@RequestBody UserUnlinkRequestModel requestModel, Principal principal) {
try {
this.unlinkEmailConfirmationManager.sendConfirmationEmail(requestModel.getEmail(), principal, requestModel.getUserId(), requestModel.getProvider());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Could not send unlink email."));
}
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.MaterialManager;
import eu.eudat.logic.managers.MetricsManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.stream.Stream;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/material/faq/"})
public class FaqController {
private Environment environment;
private MaterialManager materialManager;
@Autowired
public FaqController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
this.environment = environment;
this.materialManager = materialManager;
}
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
public ResponseEntity<byte[]> getFaq(@PathVariable(name = "lang") String lang) throws IOException {
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("faq.path"))))) {
return this.materialManager.getResponseEntity(lang, paths);
}
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.MaterialManager;
import eu.eudat.logic.managers.MetricsManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.stream.Stream;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/material/glossary/"})
public class GlossaryController {
private Environment environment;
private MaterialManager materialManager;
@Autowired
public GlossaryController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
this.environment = environment;
this.materialManager = materialManager;
}
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
public ResponseEntity<byte[]> getGlossary(@PathVariable(name = "lang") String lang) throws IOException {
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("glossary.path"))))) {
return this.materialManager.getResponseEntity(lang, paths);
}
}
}

View File

@ -0,0 +1,54 @@
package eu.eudat.controllers;
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.admin.composite.DatasetProfile;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import static eu.eudat.types.Authorities.ADMIN;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/management/"})
public class ManagementController extends BaseController {
private DatasetProfileManager datasetProfileManager;
@Autowired
public ManagementController(ApiContext apiContext, DatasetProfileManager datasetProfileManager){
super(apiContext);
this.datasetProfileManager = datasetProfileManager;
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/addSemantics"})
public ResponseEntity addSemanticsInDatasetProfiles(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
try {
this.datasetProfileManager.addSemanticsInDatasetProfiles();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (Exception exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/addRdaInSemantics"})
public ResponseEntity addRdaInSemanticsInDatasetProfiles(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
try {
this.datasetProfileManager.addRdaInSemanticsInDatasetProfiles();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (Exception exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
}

View File

@ -11,6 +11,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@RestController
@ -26,8 +27,8 @@ public class Prefillings {
}
@RequestMapping(method = RequestMethod.GET, value = {"/prefilling/list"}, produces = "application/json")
public ResponseEntity<ResponseItem<List<Prefilling>>> getPrefillingList(@RequestParam String like, @RequestParam String configId) {
List<Prefilling> prefillingList = prefillingManager.getPrefillings(like, configId);
public ResponseEntity<ResponseItem<List<Prefilling>>> getPrefillingList(@RequestParam String like) {
List<Prefilling> prefillingList = prefillingManager.getPrefillings(like);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Prefilling>>().payload(prefillingList).status(ApiMessageCode.NO_MESSAGE));
}
@ -36,4 +37,10 @@ public class Prefillings {
DatasetWizardModel datasetWizardModel = prefillingManager.getPrefilledDataset(id, configId, profileId);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().payload(datasetWizardModel).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/prefilling/generateUsingData"}, produces = "application/json")
public ResponseEntity<ResponseItem<DatasetWizardModel>> getPrefillingDataset(@RequestBody Map<String, Object> data, @RequestParam String configId, @RequestParam UUID profileId) throws Exception {
DatasetWizardModel datasetWizardModel = prefillingManager.getPrefilledDatasetUsingData(data, configId, profileId);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().payload(datasetWizardModel).status(ApiMessageCode.NO_MESSAGE));
}
}

View File

@ -1,8 +1,7 @@
package eu.eudat.controllers;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.Funder;
import eu.eudat.data.entities.Project;
import eu.eudat.logic.managers.DatasetManager;
@ -23,7 +22,6 @@ import org.springframework.web.bind.annotation.*;
import javax.transaction.Transactional;
import javax.validation.Valid;
import java.util.UUID;
@RestController
@CrossOrigin
@ -48,9 +46,9 @@ public class QuickWizardController extends BaseController {
Funder funderEntity;
//Create Funder
if (quickWizard.getFunder() == null) {
throw new Exception("Funder is a mandatory entity");
funderEntity = null;
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
throw new Exception("Funder is a mandatory entity");
funderEntity = null;
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder(), principal);
} else {
@ -60,9 +58,9 @@ public class QuickWizardController extends BaseController {
eu.eudat.data.entities.Grant grantEntity;
//Create Grant
if (quickWizard.getGrant() == null) {
throw new Exception("Grant is a mandatory entity");
grantEntity = null;
} else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
throw new Exception("Grant is a mandatory entity");
grantEntity = null;
} else if (quickWizard.getGrant().getExistGrant() == null) {
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant(), principal);
} else {
@ -88,7 +86,7 @@ public class QuickWizardController extends BaseController {
quickWizard.getDmp().setId(dmpEntity.getId());
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
DataManagementPlan dmp = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, principal);
DatasetProfile profile = quickWizard.getDmp().getDatasetProfile();
DescriptionTemplate profile = quickWizard.getDmp().getDatasetProfile();
DatasetWizardModel datasetWizardModel = dataset.toDataModel(dmp, profile);
this.datasetManager.createOrUpdate(datasetWizardModel, principal);
}
@ -100,7 +98,7 @@ public class QuickWizardController extends BaseController {
public @ResponseBody
ResponseEntity<ResponseItem<DatasetCreateWizardModel>> addDatasetWizard(@RequestBody DatasetCreateWizardModel datasetCreateWizardModel, Principal principal) throws Exception{
for(DatasetDescriptionQuickWizardModel dataset : datasetCreateWizardModel.getDatasets().getDatasetsList()){
DatasetProfile profile = new DatasetProfile();
DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getId());
profile.setLabel(datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getLabel());
this.datasetManager.createOrUpdate(dataset.toDataModel(datasetCreateWizardModel.getDmpMeta().getDmp(), profile), principal);

View File

@ -0,0 +1,79 @@
package eu.eudat.controllers;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.saml2.Saml2ConfigurableProvider;
import eu.eudat.logic.security.validators.configurableProvider.Saml2SSOUtils;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.saml2.AuthnRequestModel;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
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 java.nio.charset.StandardCharsets;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/saml2/"})
public class Saml2MetadataController extends BaseController {
private final ConfigLoader configLoader;
@Autowired
public Saml2MetadataController(ApiContext apiContext, ConfigLoader configLoader) {
super(apiContext);
this.configLoader = configLoader;
}
@RequestMapping(method = RequestMethod.GET, value = {"metadata/{configurableProviderId}"})
public @ResponseBody
ResponseEntity getMetadata(@PathVariable String configurableProviderId) {
Saml2ConfigurableProvider saml2ConfigurableProvider = (Saml2ConfigurableProvider) this.configLoader.getConfigurableProviders().getProviders().stream()
.filter(prov -> prov.getConfigurableLoginId().equals(configurableProviderId))
.findFirst().orElse(null);
if (saml2ConfigurableProvider != null) {
try {
String metadataXml = Saml2SSOUtils.getMetadata(saml2ConfigurableProvider);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(metadataXml.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + configurableProviderId + ".xml");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
return new ResponseEntity<>(metadataXml.getBytes(StandardCharsets.UTF_8),
responseHeaders,
HttpStatus.OK);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to fetch metadata."));
}
}
else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to fetch metadata."));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"authnRequest/{configurableProviderId}"})
public @ResponseBody
ResponseEntity getAuthnRequest(@PathVariable String configurableProviderId) {
Saml2ConfigurableProvider saml2ConfigurableProvider = (Saml2ConfigurableProvider) this.configLoader.getConfigurableProviders().getProviders().stream()
.filter(prov -> prov.getConfigurableLoginId().equals(configurableProviderId))
.findFirst().orElse(null);
if (saml2ConfigurableProvider != null) {
try {
AuthnRequestModel authnRequest = Saml2SSOUtils.getAuthnRequest(saml2ConfigurableProvider);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<AuthnRequestModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(authnRequest));
}
catch (Exception e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create authentication request."));
}
}
else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Unknown provider."));
}
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.MaterialManager;
import eu.eudat.logic.managers.MetricsManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.stream.Stream;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/material/termsofservice/"})
public class TermsOfServiceController {
private Environment environment;
private MaterialManager materialManager;
@Autowired
public TermsOfServiceController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
this.environment = environment;
this.materialManager = materialManager;
}
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
public ResponseEntity<byte[]> getTermsOfService(@PathVariable(name = "lang") String lang) throws IOException {
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("termsofservice.path"))))) {
return this.materialManager.getResponseEntity(lang, paths);
}
}
}

View File

@ -1,5 +1,6 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.MaterialManager;
import eu.eudat.logic.managers.MetricsManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.models.data.helpers.responses.ResponseItem;
@ -20,6 +21,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -31,43 +33,19 @@ import static eu.eudat.types.Authorities.ADMIN;
public class UserGuideController {
private Environment environment;
private final MetricsManager metricsManager;
private MaterialManager materialManager;
@Autowired
public UserGuideController(Environment environment, MetricsManager metricsManager) {
public UserGuideController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
this.environment = environment;
this.metricsManager = metricsManager;
this.materialManager = materialManager;
}
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
public ResponseEntity getUserGuide(@PathVariable(name = "lang") String lang) throws IOException {
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
Stream<Path> walk = Files.walk(Paths.get(this.environment.getProperty("userguide.path")));
List<String> result = walk.filter(Files::isRegularFile)
.map(Path::toString).collect(Collectors.toList());
String fileName = result.stream().filter(guide -> guide.contains("_" + lang)).findFirst().orElse(null);
if (fileName == null) {
fileName = result.stream().filter(guide -> guide.contains("_en")).findFirst().get();
public ResponseEntity<byte[]> getUserGuide(@PathVariable(name = "lang") String lang) throws IOException {
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
return this.materialManager.getResponseEntity(lang, paths);
}
InputStream is = new FileInputStream(fileName);
Path path = Paths.get(fileName);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(is.available());
responseHeaders.setContentType(MediaType.TEXT_HTML);
responseHeaders.set("Content-Disposition", "attachment;filename=" + path.getFileName().toString());
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
byte[] content = new byte[is.available()];
is.read(content);
is.close();
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
@RequestMapping(value = "current", method = RequestMethod.POST)

View File

@ -88,16 +88,6 @@ public class Users extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<UserListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.GET, value = {"/hasDOIToken"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Boolean>> hasDOIToken(Principal principal) throws NullEmailException {
try {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().payload(this.userManager.isDOITokenValid(principal)).status(ApiMessageCode.NO_MESSAGE));
} catch (NonValidTokenException | ExpiredTokenException | IOException e) {
return ResponseEntity.status(460).body(new ResponseItem<Boolean>().payload(false).status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/registerDOIToken"}, consumes = "application/json", produces = "application/json")
public @ResponseBody

View File

@ -1,9 +1,11 @@
package eu.eudat.controllers.controllerhandler;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.types.Authorities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
@ -25,7 +27,7 @@ public class ControllerErrorHandler {
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ResponseItem<Exception> processValidationError(Principal principal, Exception ex) throws Exception {
public ResponseItem<Exception> processValidationError( Exception ex) throws Exception {
logger.error(ex.getMessage(), ex);
return new ResponseItem<Exception>().message(ex.getMessage()).status(ApiMessageCode.DEFAULT_ERROR_MESSAGE);
}

View File

@ -3,6 +3,7 @@ package eu.eudat.criteria;
public class RecentActivityCriteria {
private String like;
private String order;
private Integer status;
public String getLike() {
return like;
@ -19,4 +20,12 @@ public class RecentActivityCriteria {
public void setOrder(String order) {
this.order = order;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@ -0,0 +1,9 @@
package eu.eudat.exceptions.descriptiontemplate;
public class DescriptionTemplatesWithTypeException extends RuntimeException {
public DescriptionTemplatesWithTypeException(String message) {
super(message);
}
}

View File

@ -0,0 +1,18 @@
package eu.eudat.exceptions.dmpblueprint;
public class DmpBlueprintUsedException extends RuntimeException {
public DmpBlueprintUsedException() {
}
public DmpBlueprintUsedException(String message) {
super(message);
}
public DmpBlueprintUsedException(String message, Throwable cause) {
super(message, cause);
}
public DmpBlueprintUsedException(Throwable cause) {
super(cause);
}
}

View File

@ -1,8 +1,9 @@
package eu.eudat.logic.builders.entity;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.logic.builders.Builder;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DatasetProfile;
import java.util.Date;
import java.util.Set;
@ -11,12 +12,14 @@ import java.util.UUID;
/**
* Created by ikalyvas on 2/15/2018.
*/
public class DatasetProfileBuilder extends Builder<DatasetProfile> {
public class DatasetProfileBuilder extends Builder<DescriptionTemplate> {
private UUID id;
private String label;
private DescriptionTemplateType type;
private Set<Dataset> dataset;
private String definition;
@ -41,6 +44,11 @@ public class DatasetProfileBuilder extends Builder<DatasetProfile> {
return this;
}
public DatasetProfileBuilder type(DescriptionTemplateType type) {
this.type = type;
return this;
}
public DatasetProfileBuilder dataset(Set<Dataset> dataset) {
this.dataset = dataset;
return this;
@ -77,17 +85,18 @@ public class DatasetProfileBuilder extends Builder<DatasetProfile> {
}
@Override
public DatasetProfile build() {
DatasetProfile datasetProfile = new DatasetProfile();
datasetProfile.setCreated(created);
datasetProfile.setStatus(status);
datasetProfile.setId(id);
datasetProfile.setDataset(dataset);
datasetProfile.setDefinition(definition);
datasetProfile.setDescription(description);
datasetProfile.setModified(modified);
datasetProfile.setLabel(label);
datasetProfile.setLanguage(language);
return datasetProfile;
public DescriptionTemplate build() {
DescriptionTemplate descriptionTemplate = new DescriptionTemplate();
descriptionTemplate.setCreated(created);
descriptionTemplate.setStatus(status);
descriptionTemplate.setId(id);
descriptionTemplate.setDataset(dataset);
descriptionTemplate.setDefinition(definition);
descriptionTemplate.setDescription(description);
descriptionTemplate.setModified(modified);
descriptionTemplate.setLabel(label);
descriptionTemplate.setLanguage(language);
descriptionTemplate.setType(type);
return descriptionTemplate;
}
}

View File

@ -2,6 +2,8 @@ package eu.eudat.logic.managers;
import eu.eudat.data.dao.entities.DatasetDao;
import eu.eudat.data.dao.entities.DatasetProfileDao;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
import eu.eudat.logic.builders.entity.DatasetProfileBuilder;
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel;
@ -17,8 +19,9 @@ import java.util.UUID;
public class AdminManager {
public static eu.eudat.data.entities.DatasetProfile generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext) {
public static DescriptionTemplate generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext) throws Exception {
ViewStyleModel viewStyleModel = new ViewStyleModel();
viewStyleModel.setEnablePrefilling(profile.isEnablePrefilling());
viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section.class));
viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Page.class));
Document viewStyleDoc = XmlBuilder.getDocument();
@ -34,22 +37,31 @@ public class AdminManager {
profile.setLanguage("en");
}
eu.eudat.data.entities.DatasetProfile datasetProfile = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
DescriptionTemplateType type;
try {
type = apiContext.getOperationsContext().getDatabaseRepository().getDescriptionTemplateTypeDao().findFromName(profile.getType());
}
catch (Exception e) {
throw new Exception("Description template type '" + profile.getType() + "' could not be found.");
}
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
.status(profile.getStatus()).created(new Date()).description(profile.getDescription()).language(profile.getLanguage())
.type(type)
.build();
if (datasetProfile.getGroupId() == null) {
datasetProfile.setGroupId(UUID.randomUUID());
if (descriptionTemplate.getGroupId() == null) {
descriptionTemplate.setGroupId(UUID.randomUUID());
}
if (datasetProfile.getVersion() == null) {
datasetProfile.setVersion((short)1);
if (descriptionTemplate.getVersion() == null) {
descriptionTemplate.setVersion((short)1);
}
return datasetProfile;
return descriptionTemplate;
}
public static eu.eudat.models.data.admin.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) {
public static eu.eudat.models.data.admin.composite.DatasetProfile generateDatasetProfileModel(DescriptionTemplate profile) {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = viewStyleDoc.getDocumentElement();
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);
@ -60,12 +72,12 @@ public class AdminManager {
}
public static eu.eudat.data.entities.DatasetProfile inactivate(DatasetProfileDao datasetProfileRepository, DatasetDao datasetDao, String id) {
public static DescriptionTemplate inactivate(DatasetProfileDao datasetProfileRepository, DatasetDao datasetDao, String id) {
eu.eudat.data.dao.criteria.DatasetCriteria datasetsForThatDatasetProfile = new eu.eudat.data.dao.criteria.DatasetCriteria();
datasetsForThatDatasetProfile.setProfileDatasetId(UUID.fromString(id));
if (datasetDao.getWithCriteria(datasetsForThatDatasetProfile).count() == 0) {
eu.eudat.data.entities.DatasetProfile detasetProfile = datasetProfileRepository.find(UUID.fromString(id));
detasetProfile.setStatus(eu.eudat.data.entities.DatasetProfile.Status.DELETED.getValue());
DescriptionTemplate detasetProfile = datasetProfileRepository.find(UUID.fromString(id));
detasetProfile.setStatus(DescriptionTemplate.Status.DELETED.getValue());
detasetProfile = datasetProfileRepository.createOrUpdate(detasetProfile);
return detasetProfile;
} else {

View File

@ -91,7 +91,9 @@ public class DashBoardManager {
for (DMP dmp : dmps) {
numberOfDatasets = numberOfDatasets + dmp.getDataset().stream()
.filter(item -> item.getStatus() == Dataset.Status.FINALISED.getValue()).count();
grants.add(dmp.getGrant());
if (dmp.getGrant() != null) {
grants.add(dmp.getGrant());
}
}
statistics.setTotalDataManagementPlanCount((long) dmps.size());
@ -200,14 +202,14 @@ public class DashBoardManager {
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
/*CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
.withHint("grantRecentActivity")
.orderBy((builder, root) -> builder.desc(root.get("modified")))
.take(numberofactivities)
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
.whenComplete((grantActivities, throwable) -> activity.setRecentGrantActivities(grantActivities));
.whenComplete((grantActivities, throwable) -> activity.setRecentGrantActivities(grantActivities));*/
CompletableFuture.allOf(grants, dmps, datasets).join();
CompletableFuture.allOf(/*grants, */dmps, datasets).join();
return activity;
}
@ -221,11 +223,17 @@ public class DashBoardManager {
}
DatasetCriteria datasetCriteria = new DatasetCriteria();
datasetCriteria.setLike(tableRequest.getCriteria().getLike());
if(tableRequest.getCriteria().getStatus() != null) {
datasetCriteria.setStatus(tableRequest.getCriteria().getStatus());
}
datasetCriteria.setAllVersions(false);
datasetCriteria.setIsPublic(!isAuthenticated);
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
dataManagementPlanCriteria.setAllVersions(false);
dataManagementPlanCriteria.setLike(tableRequest.getCriteria().getLike());
if(tableRequest.getCriteria().getStatus() != null) {
dataManagementPlanCriteria.setStatus(tableRequest.getCriteria().getStatus());
}
dataManagementPlanCriteria.setIsPublic(!isAuthenticated);
dataManagementPlanCriteria.setOnlyPublic(!isAuthenticated);

View File

@ -2,21 +2,29 @@ package eu.eudat.logic.managers;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.criteria.RequestItem;
import eu.eudat.data.dao.entities.DMPProfileDao;
import eu.eudat.data.dao.entities.DatasetDao;
import eu.eudat.data.dao.entities.DatasetProfileDao;
import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
import eu.eudat.exceptions.dmpblueprint.DmpBlueprintUsedException;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpProfile;
import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpProfile;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DmpProfileExternalAutoComplete;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field;
import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpBlueprint;
import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpBlueprint;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.queryable.QueryableList;
@ -78,6 +86,20 @@ public class DataManagementProfileManager {
return dataTable;
}
public DataTableData<DataManagementPlanBlueprintListingModel> getPagedBlueprint(DataManagementPlanBlueprintTableRequest dataManagementPlanBlueprintTableRequest, Principal principal) throws Exception {
QueryableList<DMPProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().getWithCriteriaBlueprint(dataManagementPlanBlueprintTableRequest.getCriteria());
QueryableList<DMPProfile> pagedItems = PaginationManager.applyPaging(items, dataManagementPlanBlueprintTableRequest);
DataTableData<DataManagementPlanBlueprintListingModel> dataTable = new DataTableData<>();
CompletableFuture itemsFuture = pagedItems
.selectAsync(item -> new DataManagementPlanBlueprintListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> dataTable.setData(resultList));
CompletableFuture countFuture = items.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
CompletableFuture.allOf(itemsFuture, countFuture).join();
return dataTable;
}
public DataManagementPlanProfileListingModel getSingle(String id, Principal principal) throws InstantiationException, IllegalAccessException {
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = new DataManagementPlanProfileListingModel();
@ -85,6 +107,45 @@ public class DataManagementProfileManager {
return dataManagementPlanProfileListingModel;
}
public DataManagementPlanBlueprintListingModel getSingleBlueprint(String id, Principal principal) {
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = new DataManagementPlanBlueprintListingModel();
dataManagementPlanBlueprintListingModel.fromDataModel(dmpProfile);
return dataManagementPlanBlueprintListingModel;
}
public boolean fieldInBlueprint(String id, SystemFieldType type, Principal principal) {
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
return this.fieldInBlueprint(dmpProfile, type, principal);
}
public boolean fieldInBlueprint(DMPProfile dmpProfile, SystemFieldType type, Principal principal) {
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
dmpBlueprint.fromDataModel(dmpProfile);
for(Section section: dmpBlueprint.getDefinition().getSections()){
for(FieldModel field: section.getFields()){
if(field.getCategory().equals(FieldCategory.SYSTEM)){
SystemField systemField = field.toSystemField();
if(systemField.getType().equals(type)){
return true;
}
}
}
}
return false;
}
public List<Integer> sectionIndexesForDescriptionTemplate(DMPProfile dmpProfile, UUID descriptionTemplateId) {
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
dmpBlueprint.fromDataModel(dmpProfile);
List<Integer> sectionIndexes = new ArrayList<>();
for(int i = 0; i < dmpBlueprint.getDefinition().getSections().size(); i++) {
Section section = dmpBlueprint.getDefinition().getSections().get(i);
if(section.getHasTemplates() && section.getDescriptionTemplates().stream().anyMatch(x -> x.getDescriptionTemplateId().equals(descriptionTemplateId))) sectionIndexes.add(i);
}
return sectionIndexes;
}
public List<DataManagementPlanProfileListingModel> getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
QueryableList<DMPProfile> items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item));
@ -96,8 +157,25 @@ public class DataManagementProfileManager {
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
}
public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
FileEnvelope envelope = getXmlDocument(dmpProfile, label);
public void createOrUpdateBlueprint(DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel, Principal principal) throws Exception {
DMPProfile dmpProfile = dataManagementPlanBlueprintListingModel.toDataModel();
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
}
public void inactivate(String id) {
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
dataManagementPlanCriteria.setProfile(dmpProfile);
if (dmpProfile.getStatus() == DMPProfile.Status.SAVED.getValue() || databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).count() == 0) {
dmpProfile.setStatus(DMPProfile.Status.DELETED.getValue());
databaseRepository.getDmpProfileDao().createOrUpdate(dmpProfile);
} else {
throw new DmpBlueprintUsedException("This blueprint can not deleted, because DMPs are associated with it");
}
}
public ResponseEntity<byte[]> getDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException {
FileEnvelope envelope = getXmlDocument(dmpProfile);
InputStream resource = new FileInputStream(envelope.getFile());
logger.info("Mime Type of " + envelope.getFilename() + " is " +
new MimetypesFileTypeMap().getContentType(envelope.getFile()));
@ -116,18 +194,18 @@ public class DataManagementProfileManager {
HttpStatus.OK);
}
public FileEnvelope getXmlDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws InstantiationException, IllegalAccessException, IOException {
ExportXmlBuilderDmpProfile xmlBuilder = new ExportXmlBuilderDmpProfile();
public FileEnvelope getXmlDocument(DataManagementPlanBlueprintListingModel dmpProfile) throws IOException {
ExportXmlBuilderDmpBlueprint xmlBuilder = new ExportXmlBuilderDmpBlueprint();
File file = xmlBuilder.build(dmpProfile, environment);
FileEnvelope fileEnvelope = new FileEnvelope();
fileEnvelope.setFile(file);
fileEnvelope.setFilename(label);
fileEnvelope.setFilename(dmpProfile.getLabel());
return fileEnvelope;
}
public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile createDmpProfileFromXml(MultipartFile multiPartFile) {
ImportXmlBuilderDmpProfile xmlBuilder = new ImportXmlBuilderDmpProfile();
public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint createDmpProfileFromXml(MultipartFile multiPartFile) {
ImportXmlBuilderDmpBlueprint xmlBuilder = new ImportXmlBuilderDmpBlueprint();
try {
return xmlBuilder.build(convert(multiPartFile));
} catch (IOException e) {

View File

@ -289,6 +289,45 @@ public class DatasetManager {
.stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
.collect(Collectors.toList()).size() == 0 && !datasetEntity.getDmp().isPublic())
throw new UnauthorisedException();
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
dataset.fromDataModel(datasetEntity);
// Creates the Criteria to get all version of DescriptionTemplate in question.
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
UUID profileId = datasetEntity.getProfile().getGroupId();
List<UUID> uuidList = new LinkedList<>();
uuidList.add(profileId);
profileCriteria.setGroupIds(uuidList);
profileCriteria.setAllVersions(true);
List<DescriptionTemplate> profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria)
.orderBy(((builder, root) -> builder.desc(root.get("version"))))
.toList();
List<DescriptionTemplate> profileVersionsIncluded = new LinkedList<>();
// Iterate through the versions and remove those that are not included in the DMP of the dataset in question.
for (DescriptionTemplate version : profileVersions) {
for (AssociatedProfile p : dataset.getDmp().getProfiles()) {
if (version.getId().toString().equals(p.getDescriptionTemplateId().toString())) {
profileVersionsIncluded.add(version);
}
}
}
// Sort the list with the included Versions.
Stream<DescriptionTemplate> sorted = profileVersionsIncluded.stream().sorted(Comparator.comparing(DescriptionTemplate::getVersion).reversed());
// Make the Stream into List and get the first item.
List<DescriptionTemplate> profiles = sorted.collect(Collectors.toList());
if (profiles.isEmpty())
throw new NoSuchElementException("No profiles found for the specific Dataset");
DescriptionTemplate profile = profiles.get(0);
// Check if the dataset is on the latest Version.
boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString());
dataset.setIsProfileLatestVersion(latestVersion);
eu.eudat.elastic.entities.Dataset datasetElastic;
try {
datasetElastic = datasetRepository.exists() ?
@ -297,45 +336,6 @@ public class DatasetManager {
logger.warn(ex.getMessage());
datasetElastic = null;
}
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
dataset.fromDataModel(datasetEntity);
// Creates the Criteria to get all version of DatasetProfile in question.
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
UUID profileId = datasetEntity.getProfile().getGroupId();
List<UUID> uuidList = new LinkedList<>();
uuidList.add(profileId);
profileCriteria.setGroupIds(uuidList);
profileCriteria.setAllVersions(true);
List<eu.eudat.data.entities.DatasetProfile> profileVersions = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria)
.orderBy(((builder, root) -> builder.desc(root.get("version"))))
.toList();
List<DatasetProfile> profileVersionsIncluded = new LinkedList<>();
// Iterate through the versions and remove those that are not included in the DMP of the dataset in question.
for (DatasetProfile version : profileVersions) {
for (AssociatedProfile p : dataset.getDmp().getProfiles()) {
if (version.getId().toString().equals(p.getId().toString())) {
profileVersionsIncluded.add(version);
}
}
}
// Sort the list with the included Versions.
Stream<DatasetProfile> sorted = profileVersionsIncluded.stream().sorted(Comparator.comparing(DatasetProfile::getVersion).reversed());
// Make the Stream into List and get the first item.
List<DatasetProfile> profiles = sorted.collect(Collectors.toList());
if (profiles.isEmpty())
throw new NoSuchElementException("No profiles found for the specific Dataset");
DatasetProfile profile = profiles.get(0);
// Check if the dataset is on the latest Version.
boolean latestVersion = profile.getVersion().toString().equals(datasetEntity.getProfile().getVersion().toString());
dataset.setIsProfileLatestVersion(latestVersion);
if (datasetElastic != null && datasetElastic.getTags() != null && !datasetElastic.getTags().isEmpty()) {
dataset.setTags(datasetElastic.getTags());
}
@ -396,29 +396,45 @@ public class DatasetManager {
return pagedDatasetProfile;
}
private XWPFDocument getWordDocument(ConfigLoader configLoader, eu.eudat.data.entities.Dataset datasetEntity, VisibilityRuleService visibilityRuleService) throws IOException {
WordBuilder wordBuilder = new WordBuilder(this.environment);
private XWPFDocument getWordDocument(ConfigLoader configLoader, eu.eudat.data.entities.Dataset datasetEntity, VisibilityRuleService visibilityRuleService, Principal principal) throws IOException {
WordBuilder wordBuilder = new WordBuilder(this.environment, configLoader);
DatasetWizardModel dataset = new DatasetWizardModel();
XWPFDocument document = configLoader.getDocument();
XWPFDocument document = configLoader.getDatasetDocument();
wordBuilder.addParagraphContent(datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
eu.eudat.data.entities.DMP dmpEntity = datasetEntity.getDmp();
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException();
wordBuilder.fillFirstPage(dmpEntity, datasetEntity, document, true);
wordBuilder.fillFooter(dmpEntity, datasetEntity, document, true);
int powered_pos = wordBuilder.findPosOfPoweredBy(document);
XWPFParagraph powered_par = null;
XWPFParagraph argos_img_par = null;
if(powered_pos != -1) {
powered_par = document.getParagraphArray(powered_pos);
argos_img_par = document.getParagraphArray(powered_pos + 1);
}
// wordBuilder.addParagraphContent(datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
// Space below Dataset title.
XWPFParagraph parBreakDataset = document.createParagraph();
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
datasetTemplateParagraph.setStyle("Heading2");
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
runDatasetTemplate1.setText("Template: ");
runDatasetTemplate1.setBold(true);
runDatasetTemplate1.setFontSize(12);
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
runDatasetTemplate.setText(datasetEntity.getProfile().getLabel());
runDatasetTemplate.setColor("2E75B6");
runDatasetTemplate.setBold(true);
runDatasetTemplate.setFontSize(12);
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO);
// XWPFParagraph parBreakDataset = document.createParagraph();
//
// XWPFParagraph datasetTemplateParagraph = document.createParagraph();
// datasetTemplateParagraph.setStyle("Heading2");
// XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
// runDatasetTemplate1.setText("Template: ");
// runDatasetTemplate1.setBold(true);
// runDatasetTemplate1.setFontSize(12);
// XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
// runDatasetTemplate.setText(datasetEntity.getProfile().getLabel());
// runDatasetTemplate.setColor("2E75B6");
// runDatasetTemplate.setBold(true);
// runDatasetTemplate.setFontSize(12);
//
// wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO);
/*XWPFParagraph externalReferencesParagraph = document.createParagraph();
externalReferencesParagraph.setStyle("Heading2");
@ -460,7 +476,7 @@ public class DatasetManager {
properties = jObject.toMap();
}
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
// wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, datasetEntity);
visibilityRuleService.setProperties(properties);
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
@ -469,8 +485,20 @@ public class DatasetManager {
// File exportFile = new File(label + ".docx");
// Removes the top empty headings.
for (int i = 0; i < 6; i++) {
document.removeBodyElement(0);
// for (int i = 0; i < 6; i++) {
// document.removeBodyElement(0);
// }
if(powered_pos != -1) {
document.getLastParagraph().setPageBreak(false);
document.createParagraph();
document.setParagraph(powered_par, document.getParagraphs().size() - 1);
document.createParagraph();
document.setParagraph(argos_img_par, document.getParagraphs().size() - 1);
document.removeBodyElement(powered_pos + 1);
document.removeBodyElement(powered_pos + 1);
}
return document;
@ -481,7 +509,7 @@ public class DatasetManager {
}
private XWPFDocument getLightWordDocument(ConfigLoader configLoader, DatasetWizardModel dataset, VisibilityRuleService visibilityRuleService) throws IOException {
WordBuilder wordBuilder = new WordBuilder(this.environment);
WordBuilder wordBuilder = new WordBuilder(this.environment, configLoader);
XWPFDocument document = configLoader.getDocument();
// Space below Dataset title.
@ -493,7 +521,7 @@ public class DatasetManager {
properties = jObject.toMap();
}
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
visibilityRuleService.setProperties(properties);
visibilityRuleService.buildVisibilityContext(dataset.getDatasetProfileDefinition().getRules());
wordBuilder.build(document, dataset.getDatasetProfileDefinition(), visibilityRuleService);
@ -521,7 +549,7 @@ public class DatasetManager {
exportEnvelope.setFilename(label + ".docx");
String uuid = UUID.randomUUID().toString();
File exportFile = new File(this.environment.getProperty("temp.temp") + uuid + ".docx");
XWPFDocument document = getWordDocument(configLoader, datasetEntity, visibilityRuleService);
XWPFDocument document = getWordDocument(configLoader, datasetEntity, visibilityRuleService, principal);
FileOutputStream out = new FileOutputStream(exportFile);
document.write(out);
out.close();
@ -689,7 +717,7 @@ public class DatasetManager {
public String checkDatasetValidation(Dataset dataset) throws Exception {
List<String> datasetProfileValidators = new LinkedList<>();
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(dataset.getProfile().getId());
DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(dataset.getProfile().getId());
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
@ -947,9 +975,9 @@ public class DatasetManager {
// Checks if XML datasetProfileId GroupId matches the one selected.
try {
eu.eudat.data.entities.DatasetProfile importDatasetProfile = databaseRepository.getDatasetProfileDao().find(UUID.fromString(importModel.getDatasetProfileId()));
eu.eudat.data.entities.DatasetProfile latestVersionDatasetProfile = databaseRepository.getDatasetProfileDao().find(UUID.fromString(datasetProfileId));
if (latestVersionDatasetProfile.getGroupId() != importDatasetProfile.getGroupId()) {
DescriptionTemplate importDescriptionTemplate = databaseRepository.getDatasetProfileDao().find(UUID.fromString(importModel.getDatasetProfileId()));
DescriptionTemplate latestVersionDescriptionTemplate = databaseRepository.getDatasetProfileDao().find(UUID.fromString(datasetProfileId));
if (latestVersionDescriptionTemplate.getGroupId() != importDescriptionTemplate.getGroupId()) {
throw new Exception();
}
} catch (Exception e) {
@ -982,7 +1010,7 @@ public class DatasetManager {
entity.setStatus((short) 0);
entity.setCreated(new Date());
entity.setModified(new Date());
DatasetProfile profile = new DatasetProfile();
DescriptionTemplate profile = new DescriptionTemplate();
profile.setId(UUID.fromString(datasetProfileId));
entity.setProfile(profile);
@ -1006,18 +1034,10 @@ public class DatasetManager {
public DatasetWizardModel datasetUpdateProfile(String id) {
DatasetWizardModel dataset = new DatasetWizardModel();
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
eu.eudat.elastic.entities.Dataset datasetElastic;
try {
datasetElastic = datasetRepository.exists() ?
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
} catch (Exception ex) {
logger.warn(ex.getMessage());
datasetElastic = null;
}
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
dataset.fromDataModel(datasetEntity);
// Creates the Criteria to get all version of DatasetProfile in question.
// Creates the Criteria to get all version of DescriptionTemplate in question.
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
UUID profileId = datasetEntity.getProfile().getGroupId();
List<UUID> uuidList = new LinkedList<>();
@ -1025,7 +1045,7 @@ public class DatasetManager {
profileCriteria.setGroupIds(uuidList);
// Gets the latest version of the datasetProfile.
eu.eudat.data.entities.DatasetProfile item = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria).getSingle();
DescriptionTemplate item = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria).getSingle();
// Sets the latest version of dataet Profile to the Dataset in question.
dataset.setDatasetProfileDefinition(getLatestDatasetProfile(datasetEntity, item));
@ -1034,6 +1054,14 @@ public class DatasetManager {
// Now at latest version.
dataset.setIsProfileLatestVersion(true);
eu.eudat.elastic.entities.Dataset datasetElastic;
try {
datasetElastic = datasetRepository.exists() ?
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
} catch (Exception ex) {
logger.warn(ex.getMessage());
datasetElastic = null;
}
if (datasetElastic != null && datasetElastic.getTags() != null && !datasetElastic.getTags().isEmpty()) {
dataset.setTags(datasetElastic.getTags());
}
@ -1043,7 +1071,7 @@ public class DatasetManager {
return dataset;
}
public PagedDatasetProfile getLatestDatasetProfile(Dataset datasetEntity, DatasetProfile profile) {
public PagedDatasetProfile getLatestDatasetProfile(Dataset datasetEntity, DescriptionTemplate profile) {
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
datasetprofile.setStatus(datasetEntity.getStatus());
if (datasetEntity.getProperties() != null) {
@ -1060,7 +1088,7 @@ public class DatasetManager {
datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue());
datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId());
QueryableList<DatasetProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
QueryableList<DescriptionTemplate> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
List<DatasetProfileListingModel> listingModels = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
DataTableData<DatasetProfileListingModel> data = new DataTableData<>();
@ -1108,26 +1136,28 @@ public class DatasetManager {
List<Tag> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream).filter(StreamDistinctBy.distinctByKey(Tag::getId)).collect(Collectors.toList());
Set<JsonNode> tagNodes = new HashSet<>();
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "renderStyle", "tags", true));
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "rdaProperty", "dataset.keyword"));
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "schematics", "rda.dataset.keyword"));
if(wizardModel.getTags() == null){
wizardModel.setTags(new ArrayList<>());
}
if (!tagNodes.isEmpty()) {
tagNodes.forEach(node -> {
JsonNode value = node.get("value");
if (!value.toString().equals("\"\"") && !value.toString().equals("null") && value.toString().startsWith("[")) {
String stringValue = value.toString().replaceAll("=", ":");
JSONArray values = new JSONArray(stringValue);
values.iterator().forEachRemaining(element -> {
Map<String, Object> data = ((JSONObject) element).toMap();
this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString());
});
} else {
List<String> values = Arrays.asList(value.textValue().split(", "));
List<Tag> tagValues = values.stream().map(stringValue -> new Tag(stringValue, stringValue)).collect(Collectors.toList());
tagValues.iterator().forEachRemaining(tag -> {
this.addTag(tags, wizardModel.getTags(), tag.getId(), tag.getName());
});
if (!value.toString().equals("\"\"") && !value.toString().equals("null")) {
if (value.toString().startsWith("[")) {
String stringValue = value.toString().replaceAll("=", ":");
JSONArray values = new JSONArray(stringValue);
values.iterator().forEachRemaining(element -> {
Map<String, Object> data = ((JSONObject) element).toMap();
this.addTag(tags, wizardModel.getTags(), data.get("id").toString(), data.get("name").toString());
});
} else {
List<String> values = Arrays.asList(value.textValue().split(", "));
List<Tag> tagValues = values.stream().map(stringValue -> new Tag(stringValue, stringValue)).collect(Collectors.toList());
tagValues.iterator().forEachRemaining(tag -> {
this.addTag(tags, wizardModel.getTags(), tag.getId(), tag.getName());
});
}
}
});
}
@ -1153,10 +1183,10 @@ public class DatasetManager {
DatasetListingModel listingModel = new DatasetListingModel().fromDataModel(item);
/*DatasetProfileCriteria criteria = new DatasetProfileCriteria();
criteria.setGroupIds(Collections.singletonList(item.getProfile().getGroupId()));
List<DatasetProfile> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
List<DescriptionTemplate> profiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).toList();
boolean islast = false;
if (!profiles.isEmpty()) {
profiles = profiles.stream().sorted(Comparator.comparing(DatasetProfile::getVersion)).collect(Collectors.toList());
profiles = profiles.stream().sorted(Comparator.comparing(DescriptionTemplate::getVersion)).collect(Collectors.toList());
islast = profiles.get(0).getId().equals(item.getProfile().getId());
}
listingModel.setProfileLatestVersion(islast);*/

View File

@ -1,25 +1,28 @@
package eu.eudat.logic.managers;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.UserDatasetProfile;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException;
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
import eu.eudat.logic.proxy.config.*;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.proxy.config.entities.GeneralUrls;
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.data.admin.composite.DatasetProfile;
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field;
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
import eu.eudat.models.data.helpers.common.DataTableData;
@ -33,24 +36,31 @@ 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.*;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.activation.MimetypesFileTypeMap;
import javax.transaction.Transactional;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.*;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@ -59,27 +69,30 @@ public class DatasetProfileManager {
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
private static final List<String> cache = new ArrayList<>();
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private Environment environment;
private final ApiContext apiContext;
private final DatabaseRepository databaseRepository;
private final Environment environment;
private final ConfigLoader configLoader;
private final MetricsManager metricsManager;
private final RemoteFetcher remoteFetcher;
@Autowired
public DatasetProfileManager(ApiContext apiContext, Environment environment, MetricsManager metricsManager) {
public DatasetProfileManager(ApiContext apiContext, Environment environment, ConfigLoader configLoader, MetricsManager metricsManager, RemoteFetcher remoteFetcher) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.environment = environment;
this.configLoader = configLoader;
this.metricsManager = metricsManager;
this.remoteFetcher = remoteFetcher;
}
@Transactional
public eu.eudat.models.data.admin.composite.DatasetProfile getDatasetProfile(String id) {
eu.eudat.data.entities.DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
datasetprofile.setLabel(profile.getLabel());
datasetprofile.setStatus(profile.getStatus());
datasetprofile.setDescription(profile.getDescription());
datasetprofile.setType(profile.getType().getName());
datasetprofile.setLanguage(profile.getLanguage());
datasetprofile.setUsers(new ArrayList<>());
retrieveUsers(profile, datasetprofile);
@ -87,40 +100,55 @@ public class DatasetProfileManager {
}
public List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException {
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
QueryableList<DatasetProfile> pagedItems = datasetProfileAutocompleteRequest.applyPaging(items);
QueryableList<DescriptionTemplate> items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
QueryableList<DescriptionTemplate> pagedItems = datasetProfileAutocompleteRequest.applyPaging(items);
List<DatasetProfileAutocompleteItem> datasetProfiles = pagedItems.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item));
return datasetProfiles;
}
public DatasetProfile clone(String id) {
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
public DescriptionTemplate clone(String id) {
DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
profile.setId(null);
return profile;
}
public DataTableData<DatasetProfileListingModel> getPaged(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) throws Exception {
QueryableList<DatasetProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
QueryableList<DatasetProfile> authItems = null;
QueryableList<DescriptionTemplate> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
QueryableList<DescriptionTemplate> authItems = null;
if (principal.getAuthz().contains(Authorities.ADMIN)) {
authItems = items;
} else if (principal.getAuthz().contains(Authorities.DATASET_PROFILE_MANAGER)) {
List<Integer> roles = Collections.singletonList(1);
List<Integer> roles = Arrays.asList(0, 1);
authItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getAuthenticated(items, principal.getId(), roles);
}
QueryableList<DatasetProfile> pagedItems = PaginationManager.applyPaging(authItems, datasetProfileTableRequestItem);
QueryableList<DescriptionTemplate> pagedItems = PaginationManager.applyPaging(authItems, datasetProfileTableRequestItem);
List<DatasetProfileListingModel> datasetProfiles = pagedItems.select(item -> new DatasetProfileListingModel().fromDataModel(item));
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build();
}
public List<DatasetProfileListingModel> getAll(DatasetProfileTableRequestItem tableRequestItem) throws IllegalAccessException, InstantiationException {
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(tableRequestItem.getCriteria());
QueryableList<DescriptionTemplate> items = databaseRepository.getDatasetProfileDao().getWithCriteria(tableRequestItem.getCriteria());
List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
return datasetProfiles;
}
public List<DatasetProfileWithPrefillingPropertyModel> getAllWithPrefilling(DatasetProfileTableRequestItem tableRequestItem) {
List<DatasetProfileWithPrefillingPropertyModel> datasetProfiles = new ArrayList<>();
if (!tableRequestItem.getCriteria().getIds().isEmpty()) {
tableRequestItem.getCriteria().getIds().forEach(id -> {
DatasetProfile datasetProfile = this.getDatasetProfile(id.toString());
DatasetProfileWithPrefillingPropertyModel profileModel = new DatasetProfileWithPrefillingPropertyModel();
profileModel.setId(id);
profileModel.setLabel(datasetProfile.getLabel());
profileModel.setEnablePrefilling(datasetProfile.isEnablePrefilling());
datasetProfiles.add(profileModel);
});
}
return datasetProfiles;
}
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);
@ -133,10 +161,10 @@ public class DatasetProfileManager {
return field;
}
public static List<ExternalAutocompleteFieldModel> getAutocomplete(AutoCompleteData data, String like) {
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
public List<ExternalAutocompleteFieldModel> getAutocomplete(AutoCompleteData data, String like) {
/*List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
SimpleClientHttpRequestFactory simpleFactory = new SimpleClientHttpRequestFactory();
RestTemplate restTemplate = new RestTemplate(simpleFactory);
HttpHeaders headers = new HttpHeaders();
DocumentContext jsonContext = null;
@ -155,7 +183,7 @@ public class DatasetProfileManager {
if (url.contains("zenodo")) {
url = url.replace("?", "/?");
}
url = url.replace("{like}", like.equals("") ? "*" : like);
url = url.replace("%20", " ");
url = url.replace("%22", "\"");
@ -171,7 +199,7 @@ public class DatasetProfileManager {
headers.setContentType(MediaType.APPLICATION_JSON);
entity = new HttpEntity<>("parameters", headers);
response = restTemplate.exchange(url, HttpMethod.GET, entity, Object.class);
jsonContext = JsonPath.parse(response.getBody());
jsonItems = jsonContext.read(singleData.getOptionsRoot() + "['" + singleData.getAutoCompleteOptions().getLabel() + "','" + singleData.getAutoCompleteOptions().getValue() + "','" + singleData.getAutoCompleteOptions().getSource() + "','" + "uri" + "']");
@ -197,8 +225,72 @@ public class DatasetProfileManager {
}
return result.stream().sorted(Comparator.comparing(ExternalAutocompleteFieldModel::getLabel)).collect(Collectors.toList());
//return result;
*/
List<ExternalAutocompleteFieldModel> result = new LinkedList<>();
ExternalUrlCriteria urlCriteria = new ExternalUrlCriteria();
GeneralUrls genericUrls = new GeneralUrls();
int ordinal = 1;
List<Map<String, String>> rawResults = new ArrayList<>();
genericUrls.setFetchMode(FetchStrategy.FIRST);
urlCriteria.setLike(like);
for (AutoCompleteData.AutoCompleteSingleData singleData : data.getAutoCompleteSingleDataList()) {
UrlConfiguration urlConfiguration = new UrlConfiguration();
try {
URI uri;
if (singleData.getUrl().contains("?")) {
uri = new URI(singleData.getUrl().substring(0, singleData.getUrl().lastIndexOf("?")));
} else {
uri = new URI(singleData.getUrl());
}
String source = singleData.getAutoCompleteOptions().getSource();
source = source != null && !source.isEmpty() ? source : uri.getHost();
String uriString = singleData.getAutoCompleteOptions().getUri();
uriString = uriString != null && !uriString.isEmpty() ? uriString : "uri";
String parsedUrl = singleData.getUrl();
parsedUrl = parsedUrl.replace("%20", " ");
parsedUrl = parsedUrl.replace("%22", "\"");
while (parsedUrl.contains("&amp;")) {
parsedUrl = parsedUrl.replace("&amp;", "&");
}
urlConfiguration.setUrl(parsedUrl);
urlConfiguration.setOrdinal(ordinal);
urlConfiguration.setType("External");
urlConfiguration.setContentType(MediaType.APPLICATION_JSON_VALUE);
urlConfiguration.setFirstpage("1");
urlConfiguration.setRequestType(singleData.getMethod() != null ? singleData.getMethod() : "GET");
DataUrlConfiguration dataUrlConfiguration = new DataUrlConfiguration();
dataUrlConfiguration.setPath(singleData.getOptionsRoot());
DataFieldsUrlConfiguration fieldsUrlConfiguration = new DataFieldsUrlConfiguration();
fieldsUrlConfiguration.setId(singleData.getAutoCompleteOptions().getValue());
fieldsUrlConfiguration.setName(singleData.getAutoCompleteOptions().getLabel());
fieldsUrlConfiguration.setSource(singleData.getAutoCompleteOptions().getSource().isEmpty()? null : singleData.getAutoCompleteOptions().getSource());
fieldsUrlConfiguration.setUri(uriString);
dataUrlConfiguration.setFieldsUrlConfiguration(fieldsUrlConfiguration);
urlConfiguration.setKey(source);
urlConfiguration.setLabel(source);
urlConfiguration.setData(dataUrlConfiguration);
if (singleData.getHasAuth()) {
AuthenticationConfiguration authenticationConfiguration = new AuthenticationConfiguration();
authenticationConfiguration.setAuthUrl(singleData.getAuth().getUrl());
authenticationConfiguration.setAuthMethod(singleData.getAuth().getMethod());
authenticationConfiguration.setAuthTokenPath(singleData.getAuth().getPath());
authenticationConfiguration.setAuthRequestBody(singleData.getAuth().getBody());
authenticationConfiguration.setType(singleData.getAuth().getType());
urlConfiguration.setAuth(authenticationConfiguration);
}
genericUrls.getUrls().add(urlConfiguration);
List<Map<String, String>> singleResults = this.remoteFetcher.getExternalGeneric(urlCriteria, genericUrls);
if (!singleResults.isEmpty() && !singleResults.get(0).containsKey("source") && !singleData.getAutoCompleteOptions().getSource().isEmpty()) {
singleResults.forEach(singleResult -> singleResult.put("source", singleData.getAutoCompleteOptions().getSource()));
}
rawResults.addAll(singleResults);
genericUrls.getUrls().clear();
} catch (URISyntaxException e) {
logger.error(e.getMessage(), e);
}
}
rawResults.forEach(item -> result.add(new ExternalAutocompleteFieldModel(parseItem(item.get("pid")), parseItem(item.get("name")), parseItem(item.get("source")), parseItem(item.get("uri")))));
return result;
}
private static String parseItem(Object item) {
@ -269,36 +361,36 @@ public class DatasetProfileManager {
return convFile;
}
public eu.eudat.data.entities.DatasetProfile createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception {
// Getting the DatasetProfile which we will create its new version.
eu.eudat.data.entities.DatasetProfile oldDatasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
public DescriptionTemplate createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception {
// Getting the DescriptionTemplate which we will create its new version.
DescriptionTemplate oldDescriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
// Getting the DatasetProfile with the latest Version.
// Getting the DescriptionTemplate with the latest Version.
DatasetProfileCriteria criteria = new DatasetProfileCriteria();
LinkedList<UUID> list = new LinkedList<>();
list.push(oldDatasetProfile.getGroupId());
list.push(oldDescriptionTemplate.getGroupId());
criteria.setGroupIds(list);
criteria.setAllVersions(false);
QueryableList<DatasetProfile> datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria);
eu.eudat.data.entities.DatasetProfile latestVersionDatasetProfile = datasetProfileQueryableList.getSingle();
QueryableList<DescriptionTemplate> datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria);
DescriptionTemplate latestVersionDescriptionTemplate = datasetProfileQueryableList.getSingle();
if (latestVersionDatasetProfile.getVersion().equals(oldDatasetProfile.getVersion())){
if (latestVersionDescriptionTemplate.getVersion().equals(oldDescriptionTemplate.getVersion())){
eu.eudat.models.data.admin.composite.DatasetProfile sortedProfile = profile.toShort();
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext);
modelDefinition.setLabel(oldDatasetProfile.getLabel());
modelDefinition.setVersion((short) (oldDatasetProfile.getVersion() + 1));
modelDefinition.setGroupId(oldDatasetProfile.getGroupId());
modelDefinition.setLanguage(oldDatasetProfile.getLanguage());
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext);
// modelDefinition.setLabel(oldDescriptionTemplate.getLabel());
modelDefinition.setVersion((short) (oldDescriptionTemplate.getVersion() + 1));
modelDefinition.setGroupId(oldDescriptionTemplate.getGroupId());
// modelDefinition.setLanguage(oldDescriptionTemplate.getLanguage());
apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
eu.eudat.data.entities.DatasetProfile datasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
this.storeDatasetProfileUsers(datasetProfile, profile);
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
this.storeDatasetProfileUsers(descriptionTemplate, profile);
return modelDefinition;
} else {
throw new DatasetProfileNewVersionException("Version to update not the latest.");
}
}
public void storeDatasetProfileUsers(DatasetProfile entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
public void storeDatasetProfileUsers(DescriptionTemplate entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
if (model.getUsers() != null && !model.getUsers().isEmpty()) {
if (entity.getUsers() == null) {
entity.setUsers(new HashSet<>());
@ -333,7 +425,7 @@ public class DatasetProfileManager {
}
@Transactional
public void retrieveUsers(DatasetProfile entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
public void retrieveUsers(DescriptionTemplate entity, eu.eudat.models.data.admin.composite.DatasetProfile model) {
if (entity.getUsers() != null && !entity.getUsers().isEmpty()) {
model.setUsers(entity.getUsers().stream().filter(userDatasetProfile -> userDatasetProfile.getRole() < 2).map(userDatasetProfile -> {
UserInfoListingModel userInfoListingModel = new UserInfoListingModel();
@ -363,4 +455,79 @@ public class DatasetProfileManager {
}
}
public List<String> getSemantics(String query) {
List<Semantic> semantics = configLoader.getSemantics();
List<String> filteredSemantics = semantics.stream().map(Semantic::getName).collect(Collectors.toList());
if(query != null && !query.isEmpty()){
filteredSemantics = semantics.stream().filter(x -> x.getCategory().contains(query) || x.getName().contains(query)).map(Semantic::getName).collect(Collectors.toList());
}
return filteredSemantics;
}
public void addSemanticsInDatasetProfiles() throws XPathExpressionException {
List<DescriptionTemplate> ids = this.databaseRepository.getDatasetProfileDao().getAllIds();
for(DescriptionTemplate dp: ids){
DescriptionTemplate descriptionTemplate = this.databaseRepository.getDatasetProfileDao().find(dp.getId());
Document document = XmlBuilder.fromXml(descriptionTemplate.getDefinition());
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
XPathExpression expr = xpath.compile("//rdaCommonStandard");
NodeList rdaProperties = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
for(int i = 0; i < rdaProperties.getLength(); i++){
Node rdaPropertyNode = rdaProperties.item(i);
String rdaProperty = rdaPropertyNode.getTextContent();
Element schematics = document.createElement("schematics");
Node fieldParent = rdaPropertyNode.getParentNode();
if(rdaProperty != null && !rdaProperty.isEmpty()){
Element schematic = document.createElement("schematic");
schematic.setTextContent("rda." + rdaProperty);
schematics.appendChild(schematic);
}
fieldParent.insertBefore(schematics, rdaPropertyNode);
fieldParent.removeChild(rdaPropertyNode);
}
this.updateDatasetProfileXml(document, descriptionTemplate);
}
}
public void addRdaInSemanticsInDatasetProfiles() throws XPathExpressionException {
List<DescriptionTemplate> ids = this.databaseRepository.getDatasetProfileDao().getAllIds();
for(DescriptionTemplate dp: ids){
DescriptionTemplate descriptionTemplate = this.databaseRepository.getDatasetProfileDao().find(dp.getId());
Document document = XmlBuilder.fromXml(descriptionTemplate.getDefinition());
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
XPathExpression expr = xpath.compile("//schematic");
NodeList schematics = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
for (int i = 0; i < schematics.getLength(); i++) {
Node schematicNode = schematics.item(i);
String schematicRda = schematicNode.getTextContent();
if (schematicRda != null && !schematicRda.isEmpty() && !schematicRda.startsWith("rda.")) {
schematicNode.setTextContent("rda." + schematicRda);
}
}
this.updateDatasetProfileXml(document, descriptionTemplate);
}
}
private void updateDatasetProfileXml(Document document, DescriptionTemplate descriptionTemplate) {
try {
DOMSource domSource = new DOMSource(document);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(domSource, result);
String newDefinition = writer.toString();
if(newDefinition != null){
descriptionTemplate.setDefinition(newDefinition);
this.databaseRepository.getDatasetProfileDao().createOrUpdate(descriptionTemplate);
}
}
catch(TransformerException ex) {
logger.error(ex.getMessage(), ex);
}
}
}

View File

@ -5,7 +5,7 @@ import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.dao.entities.DatasetProfileDao;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
@ -40,12 +40,12 @@ public class DatasetWizardManager {
return new LinkedList<>();
}
DatasetProfileCriteria criteria = new DatasetProfileCriteria();
criteria.setIds(dataManagementPlan.getProfiles().stream().map(AssociatedProfile::getId).collect(Collectors.toList()));
List<DatasetProfile> datasetProfiles = profileDao.getWithCriteria(criteria).toList();
criteria.setIds(dataManagementPlan.getProfiles().stream().map(AssociatedProfile::getDescriptionTemplateId).collect(Collectors.toList()));
List<DescriptionTemplate> descriptionTemplates = profileDao.getWithCriteria(criteria).toList();
criteria.setIds(null);
criteria.setGroupIds(datasetProfiles.stream().map(DatasetProfile::getGroupId).collect(Collectors.toList()));
datasetProfiles = profileDao.getWithCriteria(criteria).toList();
List<AssociatedProfile> profiles = datasetProfiles.stream().map(profile -> new AssociatedProfile().fromData(profile)).collect(Collectors.toList());
criteria.setGroupIds(descriptionTemplates.stream().map(DescriptionTemplate::getGroupId).collect(Collectors.toList()));
descriptionTemplates = profileDao.getWithCriteria(criteria).toList();
List<AssociatedProfile> profiles = descriptionTemplates.stream().map(profile -> new AssociatedProfile().fromData(profile)).collect(Collectors.toList());
return profiles;
}

View File

@ -0,0 +1,67 @@
package eu.eudat.logic.managers;
import eu.eudat.depositinterface.repository.RepositoryDeposit;
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
import eu.eudat.models.data.doi.DepositRequest;
import eu.eudat.models.data.doi.Doi;
import eu.eudat.models.data.doi.RepositoryConfig;
import eu.eudat.models.data.security.Principal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Component
public class DepositManager {
private static final Logger logger = LoggerFactory.getLogger(DepositManager.class);
private List<RepositoryDeposit> repositories;
private DataManagementPlanManager dataManagementPlanManager;
@Autowired
public DepositManager(List<RepositoryDeposit> repositories, DataManagementPlanManager dataManagementPlanManager){
this.repositories = repositories;
this.dataManagementPlanManager = dataManagementPlanManager;
}
public List<RepositoryConfig> getAvailableRepos() {
List<RepositoryConfig> reposConfigModel = new ArrayList<>();
for (RepositoryDeposit r: this.repositories) {
List<RepositoryDepositConfiguration> repoConf = r.getConfiguration();
if(repoConf != null) {
for(RepositoryDepositConfiguration cf: repoConf){
RepositoryConfig repoModel = new RepositoryConfig();
reposConfigModel.add(repoModel.toModel(cf));
}
}
}
return reposConfigModel;
}
public String authenticate(String id, String code) {
for(RepositoryDeposit r: this.repositories){
if(r.getConfiguration().stream().anyMatch(x -> x.getRepositoryId().equals(id))){
return r.authenticate(id, code);
}
}
return null;
}
public Doi deposit(DepositRequest depositRequest, Principal principal) throws Exception {
return this.dataManagementPlanManager.createDoi(depositRequest, principal);
}
public String getRepositoryLogo(String repositoryId){
for(RepositoryDeposit r: this.repositories){
Optional<RepositoryDepositConfiguration> cf = r.getConfiguration().stream().filter(x -> x.getRepositoryId().equals(repositoryId)).findFirst();
if(cf.isPresent()){
return cf.get().isHasLogo() ? r.getLogo(repositoryId) : null;
}
}
return null;
}
}

View File

@ -0,0 +1,84 @@
package eu.eudat.logic.managers;
import eu.eudat.data.entities.DescriptionTemplateType;
import eu.eudat.exceptions.descriptiontemplate.DescriptionTemplatesWithTypeException;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.descriptiontemplatetype.DescriptionTemplateTypeModel;
import eu.eudat.models.data.helpers.common.DataTableData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Component
public class DescriptionTemplateTypeManager {
private static final Logger logger = LoggerFactory.getLogger(DescriptionTemplateTypeManager.class);
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
@Autowired
public DescriptionTemplateTypeManager(ApiContext apiContext, DatabaseRepository databaseRepository) {
this.apiContext = apiContext;
this.databaseRepository = databaseRepository;
}
public DataTableData<DescriptionTemplateTypeModel> get() {
List<DescriptionTemplateType> types = this.databaseRepository.getDescriptionTemplateTypeDao().asQueryable().toList();
List<DescriptionTemplateTypeModel> typesModelList = types.stream().map(type -> new DescriptionTemplateTypeModel().fromDataModel(type)).collect(Collectors.toList());
DataTableData<DescriptionTemplateTypeModel> dataTableData = new DataTableData<>();
dataTableData.setData(typesModelList);
dataTableData.setTotalCount((long) typesModelList.size());
return dataTableData;
}
public DescriptionTemplateTypeModel getSingle(UUID id) throws Exception {
DescriptionTemplateType type = this.databaseRepository.getDescriptionTemplateTypeDao().find(id);
if (type != null) {
return new DescriptionTemplateTypeModel().fromDataModel(type);
}
else {
throw new DescriptionTemplatesWithTypeException("No description template type found with this id");
}
}
public void create(DescriptionTemplateTypeModel type) throws Exception {
DescriptionTemplateType existed = this.databaseRepository.getDescriptionTemplateTypeDao().findFromName(type.getName());
if (existed == null) {
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type.toDataModel());
}
else {
throw new DescriptionTemplatesWithTypeException("There is already a description template type with that name.");
}
}
public void update(DescriptionTemplateTypeModel type) throws Exception {
DescriptionTemplateType existed = this.databaseRepository.getDescriptionTemplateTypeDao().findFromName(type.getName());
if (existed != null) {
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type.toDataModel());
}
else {
throw new DescriptionTemplatesWithTypeException("No description template type found.");
}
}
public void delete(UUID id) throws DescriptionTemplatesWithTypeException {
DescriptionTemplateType type = this.databaseRepository.getDescriptionTemplateTypeDao().find(id);
if (type != null) {
Long descriptionsWithType = this.databaseRepository.getDatasetProfileDao().countWithType(type);
if(descriptionsWithType == 0) {
type.setStatus(DescriptionTemplateType.Status.DELETED.getValue());
this.databaseRepository.getDescriptionTemplateTypeDao().createOrUpdate(type);
}
else{
throw new DescriptionTemplatesWithTypeException("This type can not deleted, because Descriptions are associated with it");
}
}
}
}

View File

@ -48,6 +48,9 @@ public class EmailConfirmationManager {
// Checks if mail is used by another user. If it is, merges the new the old.
Long existingUsers = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).count();
if (existingUsers > 0) {
Credential credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userInfo"), user)).getSingle();
credential.setEmail(loginConfirmationEmail.getEmail());
databaseRepository.getCredentialDao().createOrUpdate(credential);
UserInfo oldUser = databaseRepository.getUserInfoDao().asQueryable().where((builder, root) -> builder.equal(root.get("email"), loginConfirmationEmail.getEmail())).getSingle();
mergeNewUserToOld(user, oldUser);
expireUserToken(user);
@ -57,6 +60,12 @@ public class EmailConfirmationManager {
user.setEmail(loginConfirmationEmail.getEmail());
databaseRepository.getUserInfoDao().createOrUpdate(user);
Credential credential = databaseRepository.getCredentialDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("userInfo"), user)).getSingle();
if(credential.getEmail() == null){
credential.setEmail(user.getEmail());
databaseRepository.getCredentialDao().createOrUpdate(credential);
}
databaseRepository.getLoginConfirmationEmailDao().createOrUpdate(loginConfirmationEmail);
}

View File

@ -140,6 +140,7 @@ public class GrantManager {
grants.add(grant);
}
grants = grants.stream().filter(grant -> grant.getLabel() != null).collect(Collectors.toList());
grants.sort(Comparator.comparing(Grant::getLabel));
grants = grants.stream().filter(listHelper.distinctByKey(Grant::getLabel)).collect(Collectors.toList());
return grants;

View File

@ -0,0 +1,51 @@
package eu.eudat.logic.managers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Component
public class MaterialManager {
@Autowired
public MaterialManager(){}
public ResponseEntity<byte[]> getResponseEntity(String lang, Stream<Path> paths) throws IOException {
List<String> result = paths.filter(Files::isRegularFile)
.map(Path::toString).collect(Collectors.toList());
String fileName = result.stream().filter(about -> about.contains("_" + lang)).findFirst().orElse(null);
if (fileName == null) {
fileName = result.stream().filter(about -> about.contains("_en")).findFirst().get();
}
InputStream is = new FileInputStream(fileName);
Path path = Paths.get(fileName);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(is.available());
responseHeaders.setContentType(MediaType.TEXT_HTML);
responseHeaders.set("Content-Disposition", "attachment;filename=" + path.getFileName().toString());
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
byte[] content = new byte[is.available()];
is.read(content);
is.close();
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
}

View File

@ -5,6 +5,10 @@ import eu.eudat.data.entities.EmailConfirmation;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.entities.UserToken;
import eu.eudat.elastic.criteria.DmpCriteria;
import eu.eudat.elastic.entities.Collaborator;
import eu.eudat.elastic.entities.Dmp;
import eu.eudat.elastic.repository.DmpRepository;
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.services.ApiContext;
@ -25,21 +29,25 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import javax.transaction.Transactional;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Component
public class MergeEmailConfirmationManager {
private static Logger logger = LoggerFactory.getLogger(MergeEmailConfirmationManager.class);
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private DmpRepository dmpRepository;
@Autowired
public MergeEmailConfirmationManager(ApiContext apiContext) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.dmpRepository = apiContext.getOperationsContext().getElasticRepository().getDmpRepository();
}
@Transactional
public void confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException {
public String confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException {
EmailConfirmation loginConfirmationEmail = apiContext.getOperationsContext()
.getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle();
@ -49,7 +57,7 @@ public class MergeEmailConfirmationManager {
UserInfo userToBeMerged = databaseRepository.getUserInfoDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
String userToBeMergedEmail = userToBeMerged.getEmail();
try {
Map<String, Object> map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), HashMap.class);
UUID otherUserId = UUID.fromString((String) map.get("userId"));
@ -64,6 +72,8 @@ public class MergeEmailConfirmationManager {
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return userToBeMergedEmail;
}
public void sendConfirmationEmail(String email, Principal principal, UUID userId, Integer provider) throws HasConfirmedEmailException {
@ -91,6 +101,38 @@ public class MergeEmailConfirmationManager {
userDmp.setUser(newUser);
databaseRepository.getUserDmpDao().createOrUpdate(userDmp);
});
try {
DmpCriteria dmpCriteria = new DmpCriteria();
dmpCriteria.setCollaborators(Collections.singletonList(oldUser.getId()));
List<Dmp> elasticDmpsIds = dmpRepository.query(dmpCriteria);
for(Dmp dmpId: elasticDmpsIds){
Dmp dmp = dmpRepository.findDocument(dmpId.getId().toString());
if(dmp.getDatasets() != null) {
dmp.getDatasets().forEach(dataset -> {
if(dataset.getCollaborators() != null) {
for (Collaborator collaborator : dataset.getCollaborators()) {
if (collaborator.getId().equals(oldUser.getId().toString())) {
collaborator.setId(newUser.getId().toString());
collaborator.setName(newUser.getName());
}
}
}
});
}
if(dmp.getCollaborators() != null) {
for (Collaborator collaborator : dmp.getCollaborators()) {
if (collaborator.getId().equals(oldUser.getId().toString())) {
collaborator.setId(newUser.getId().toString());
collaborator.setName(newUser.getName());
}
}
}
dmpRepository.createOrUpdate(dmp);
}
}
catch (IOException e){
logger.warn("Warning: Could not fetch dmps from elastic.", e);
}
oldUser.setUserStatus((short)1);
oldUser.setEmail(null);
List<Credential> credentials = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userInfo"), oldUser)).toList();

View File

@ -1,7 +1,7 @@
package eu.eudat.logic.managers;
import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.types.MetricNames;
import io.micrometer.prometheus.PrometheusMeterRegistry;
@ -17,15 +17,13 @@ import javax.annotation.PostConstruct;
import javax.transaction.Transactional;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -35,8 +33,8 @@ public class MetricsManager {
private final Map<String, Gauge> gauges;
public static final Map<Short, String> datasetTemplateStatus = Stream.of(new Object[][] {
{ DatasetProfile.Status.SAVED.getValue(), MetricNames.DRAFT },
{ DatasetProfile.Status.FINALIZED.getValue(), MetricNames.ACTIVE },
{ DescriptionTemplate.Status.SAVED.getValue(), MetricNames.DRAFT },
{ DescriptionTemplate.Status.FINALIZED.getValue(), MetricNames.ACTIVE },
}).collect(Collectors.toMap(data -> (Short) data[0], data -> (String) data[1]));
public void increaseValue(String name, int amount, String label) {
@ -179,8 +177,12 @@ public class MetricsManager {
calculateValue(MetricNames.USERS, (int) userManager.countActiveUsers().intValue(), MetricNames.LOGGEDIN);
calculateValue(MetricNames.USERS, (int) userManager.countAllUsers().intValue(), MetricNames.TOTAL);
long files = Files.list(Paths.get(this.environment.getProperty("userguide.path"))).count();
calculateValue(MetricNames.LANGUAGES, (int) files, null);
try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
long files = paths.count();
calculateValue(MetricNames.LANGUAGES, (int) files, null);
} catch (Exception e) {
logger.error("Could not calculate languages.");
}
calculateValue(MetricNames.INSTALLATIONS, 1, null);
calculateValue(MetricNames.NEXUS + MetricNames.INSTALLATIONS, 1, null);
@ -404,9 +406,9 @@ public class MetricsManager {
criteria.setStatus(1);
criteria.setAllVersions(false);
if (countNexus) criteria.setPeriodStart(getNexusDate());
List<DatasetProfile> datasetProfiles = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
List<DescriptionTemplate> descriptionTemplates = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
DatasetCriteria datasetCriteria = new DatasetCriteria();
datasetCriteria.setDatasetTemplates(datasetProfiles.stream().map(DatasetProfile::getId).collect(Collectors.toList()));
datasetCriteria.setDatasetTemplates(descriptionTemplates.stream().map(DescriptionTemplate::getId).collect(Collectors.toList()));
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getProfile().getId()).stream().distinct().count();
}

View File

@ -60,20 +60,20 @@ public class NotificationManager {
case DMP_MODIFIED:
case DATASET_MODIFIED:
subjectTemplate = this.environment.getProperty("notification.modified.subject");
contentTemplate = mailService.getMailTemplateContent("classpath:templates/notifications/modifiedNotification.html");
contentTemplate = mailService.getMailTemplateContent(this.environment.getProperty("notification.modified.template"));
break;
case DMP_PUBLISH:
subjectTemplate = this.environment.getProperty("notification.publish.subject");
contentTemplate = mailService.getMailTemplateContent("classpath:templates/notifications/publishNotification.html");
contentTemplate = mailService.getMailTemplateContent(this.environment.getProperty("notification.publish.template"));
break;
case DMP_FINALISED:
subjectTemplate = this.environment.getProperty("notification.finalised.subject");
contentTemplate = mailService.getMailTemplateContent("classpath:templates/notifications/finalisedNotification.html");
contentTemplate = mailService.getMailTemplateContent(this.environment.getProperty("notification.finalised.template"));
break;
case DMP_MODIFIED_FINALISED:
case DATASET_MODIFIED_FINALISED:
subjectTemplate = this.environment.getProperty("notification.modifiedFinalised.subject");
contentTemplate = mailService.getMailTemplateContent("classpath:templates/notifications/modifiedFinalisedNotification.html");
contentTemplate = mailService.getMailTemplateContent(this.environment.getProperty("notification.modified_finalised.template"));
break;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DescriptionTemplate;
import eu.eudat.logic.mapper.prefilling.PrefillingMapper;
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
@ -11,10 +12,7 @@ import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.prefilling.Prefilling;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@ -28,29 +26,52 @@ public class PrefillingManager {
private final ConfigLoader configLoader;
private final ObjectMapper objectMapper;
private final DatasetManager datasetManager;
private final LicenseManager licenseManager;
private final PrefillingMapper prefillingMapper;
@Autowired
public PrefillingManager(ApiContext apiContext, ConfigLoader configLoader, DatasetManager datasetManager) {
public PrefillingManager(ApiContext apiContext, ConfigLoader configLoader, DatasetManager datasetManager, LicenseManager licenseManager, PrefillingMapper prefillingMapper) {
this.apiContext = apiContext;
this.configLoader = configLoader;
this.objectMapper = new ObjectMapper();
this.prefillingMapper = prefillingMapper;
this.objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.datasetManager = datasetManager;
this.licenseManager = licenseManager;
}
public List<Prefilling> getPrefillings(String like, String configId) {
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
public List<Prefilling> getPrefillings(String like) {
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria();
externalUrlCriteria.setLike(like);
List<Map<String, String>> map = apiContext.getOperationsContext().getRemoteFetcher().getExternalGeneric(externalUrlCriteria, prefillingConfig.getPrefillingSearch());
return map.stream().map(submap -> objectMapper.convertValue(submap, Prefilling.class)).collect(Collectors.toList());
List<Prefilling> prefillings = new ArrayList<>();
List<Map<String, String>> map;
Map<String, PrefillingConfig> prefillingConfigs = configLoader.getExternalUrls().getPrefillings();
for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {
map = apiContext.getOperationsContext().getRemoteFetcher().getExternalGeneric(externalUrlCriteria, prefillingConfig.getPrefillingSearch());
prefillings.addAll(map.stream().map(submap -> objectMapper.convertValue(submap, Prefilling.class)).collect(Collectors.toList()));
if (prefillingConfig.getPrefillingSearch().getUrlConfig().isDataInListing()) {
List<Map<String, Object>> mapData = apiContext.getOperationsContext().getRemoteFetcher().getExternalGenericWithData(externalUrlCriteria, prefillingConfig.getPrefillingSearch());
for (int i = 0; i < mapData.size(); i++) {
prefillings.get(i).setData(mapData.get(i));
}
prefillings = prefillings.stream().filter(prefilling -> prefilling.getData() != null).collect(Collectors.toList());
}
}
return prefillings;
}
public DatasetWizardModel getPrefilledDataset(String prefillId, String configId, UUID profileId) throws Exception {
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
Map<String, Object> prefillingEntity = getSingle(prefillingGet.getUrl(), prefillId);
DatasetProfile datasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
return PrefillingMapper.mapPrefilledEntityToDatasetWizard(prefillingEntity, prefillingGet, prefillingConfig.getType(), datasetProfile, datasetManager);
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
return prefillingMapper.mapPrefilledEntityToDatasetWizard(prefillingEntity, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager);
}
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> data, String configId, UUID profileId) throws Exception {
PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId);
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId);
return prefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager);
}
private Map<String, Object> getSingle(String url, String id) {

View File

@ -0,0 +1,93 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.Credential;
import eu.eudat.data.entities.EmailConfirmation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.entities.UserToken;
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
import eu.eudat.logic.builders.entity.UserTokenBuilder;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.security.Principal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class UnlinkEmailConfirmationManager {
private static Logger logger = LoggerFactory.getLogger(UnlinkEmailConfirmationManager.class);
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
@Autowired
public UnlinkEmailConfirmationManager(ApiContext apiContext) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
}
@Transactional
public void confirmEmail(String token) throws TokenExpiredException, HasConfirmedEmailException {
EmailConfirmation loginConfirmationEmail = apiContext.getOperationsContext()
.getDatabaseRepository().getLoginConfirmationEmailDao().asQueryable()
.where((builder, root) -> builder.equal(root.get("token"), UUID.fromString(token))).getSingle();
if (loginConfirmationEmail.getExpiresAt().compareTo(new Date()) < 0)
throw new TokenExpiredException("Token has expired.");
if(loginConfirmationEmail.getIsConfirmed())
throw new HasConfirmedEmailException("Email is already confirmed.");
// UserInfo userAskingForUnlink = databaseRepository.getUserInfoDao().asQueryable()
// .where((builder, root) -> builder.equal(root.get("id"), loginConfirmationEmail.getUserId())).getSingle();
try {
Map<String, Object> map = new ObjectMapper().readValue(loginConfirmationEmail.getData(), new TypeReference<Map<String, Object>>() {});
String emailTobeUnlinked = (String) map.get("email");
Integer provider = Integer.valueOf((String) map.get("provider"));
unlinkUser(emailTobeUnlinked, provider);
loginConfirmationEmail.setIsConfirmed(true);
databaseRepository.getLoginConfirmationEmailDao().createOrUpdate(loginConfirmationEmail);
}
catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Transactional
private void unlinkUser(String emailTobeUnlinked, Integer provider){
Credential credential = databaseRepository.getCredentialDao().asQueryable()
.where((builder, root) -> builder.and(builder.equal(root.get("email"), emailTobeUnlinked), builder.equal(root.get("provider"), provider))).getSingle();
if(credential != null) {
databaseRepository.getCredentialDao().delete(credential);
}
}
public void sendConfirmationEmail(String email, Principal principal, UUID userId, Integer provider) {
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
if (user.getEmail() != null && !user.getEmail().equals(email)) {
apiContext.getUtilitiesService().getConfirmationEmailService().createUnlinkConfirmationEmail(
databaseRepository.getLoginConfirmationEmailDao(),
apiContext.getUtilitiesService().getMailService(),
email,
userId,
principal,
provider
);
}
}
}

Some files were not shown because too many files have changed in this diff Show More