+
+
+

{{ 'ABOUT.WELCOME' | translate }}

+

{{ 'ABOUT.WELCOME-MESSAGE' | translate }}

+
+
+
-
+

{{'DASHBOARD.DATASETS' | translate}} {{titlePrefix}}

-
+
@@ -15,11 +21,11 @@
- +
- +
diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss index 194373976..e69441181 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss +++ b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.scss @@ -11,6 +11,28 @@ } } +.header-image { + background: url("/assets/images/new-dashboard-bg.png") no-repeat; + background-size: cover; + margin-top: 70px; + min-height: 15em; + position: relative; + } + + .header-text-container { + background: rgba(255, 255, 255, 0.7); + position: absolute; + bottom: 0px; + padding-left: 5em; + padding-right: 10em; + padding-top: 2em; + padding-bottom: 2em; + } + + .explore-dmp-content { + padding: 30px 15px; + } + ::ng-deep .mat-paginator-container { flex-direction: row-reverse !important; justify-content: space-between !important; diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts index 5c433745b..b726c510e 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts @@ -17,6 +17,8 @@ import { TranslateService } from '@ngx-translate/core'; import { Observable, of as observableOf } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { ExternalTagEditorModel } from '../dataset-wizard/dataset-wizard-editor.model'; +import { AuthService } from '@app/core/services/auth/auth.service'; +import { isNullOrUndefined } from 'util'; @Component({ selector: 'app-dataset-listing-component', @@ -38,17 +40,24 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB dmpSearchEnabled = true; listingItems: DatasetListingModel[] = []; + isPublic: boolean = false; + constructor( private datasetService: DatasetService, private router: Router, private route: ActivatedRoute, private dmpService: DmpService, private language: TranslateService, + private authService: AuthService ) { super(); } ngOnInit() { + this.isPublic = this.router.url === '/explore'; + if (!this.isPublic && isNullOrUndefined(this.authService.current())) { + this.router.navigateByUrl("/explore"); + } this.route.params .pipe(takeUntil(this._destroyed)) .subscribe(async (params: Params) => { @@ -78,7 +87,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB this.breadCrumbs = observableOf([{ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), - url: "/datasets" + url: this.isPublic ? "/explore" : "/datasets" }]); } @@ -126,6 +135,13 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB if (value.datasetTemplates) { request.criteria.datasetTemplates = value.datasetTemplates.map(x => x.id) } + if(value.grantStatus) { + request.criteria.grantStatus = value.grantStatus; + } + request.criteria.isPublic = this.isPublic; + if (this.isPublic) { + request.criteria.allVersions = true; + } // if (this.itemId) { // // request.criteria.groupIds = [this.itemId]; // request.criteria.allVersions = true; diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html index d8fc539e5..eea41275e 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html @@ -1,5 +1,5 @@
- +
@@ -59,7 +59,7 @@
{{ dataset.profile }}
-
+
history diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts index ad11cf98b..719c87fda 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts @@ -12,6 +12,7 @@ export class DatasetListingItemComponent implements OnInit { @Input() dataset: DatasetListingModel; @Input() showDivider: boolean = true; + @Input() isPublic: boolean = false; @Output() onClick: EventEmitter = new EventEmitter(); isDraft: boolean; @@ -32,6 +33,10 @@ export class DatasetListingItemComponent implements OnInit { } } + getItemLink(): string[] { + return this.isPublic ? [`/datasets/publicEdit/${this.dataset.id}`] : [`/datasets/edit/${this.dataset.id}`]; + } + // grantClicked(dataset: DatasetListingModel) { // this.router.navigate(['/grants/edit/' + dataset.grantId]); From 5ec02a89def9e6ff2c257f4172e3aecac2e96a4d Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 12:41:27 +0200 Subject: [PATCH 097/160] Fixed some issues and added Dataset description on index --- .../elastic/criteria/DatasetCriteria.java | 10 +++---- .../eu/eudat/elastic/entities/Dataset.java | 11 ++++++++ .../elastic/repository/DatasetRepository.java | 27 +++++++++++-------- .../managers/DataManagementPlanManager.java | 1 + .../eudat/logic/managers/DatasetManager.java | 8 +++--- .../listing/dataset-listing.component.ts | 3 --- 6 files changed, 36 insertions(+), 24 deletions(-) diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/criteria/DatasetCriteria.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/criteria/DatasetCriteria.java index 98e12a67d..62d2fc5a4 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/criteria/DatasetCriteria.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/criteria/DatasetCriteria.java @@ -9,7 +9,7 @@ import java.util.UUID; * Created by ikalyvas on 7/5/2018. */ public class DatasetCriteria extends Criteria { - private String label; + private String like; private List datasetTemplates; private Short status; private List dmps; @@ -22,12 +22,12 @@ public class DatasetCriteria extends Criteria { private boolean isPublic; private Short grantStatus; - public String getLabel() { - return label; + public String getLike() { + return like; } - public void setLabel(String label) { - this.label = label; + public void setLike(String like) { + this.like = like; } public List getDatasetTemplates() { diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java index 88007bf6d..9cec9f0ba 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java @@ -46,6 +46,7 @@ public class Dataset implements ElasticEntity { private String id; private List tags = new LinkedList<>(); private String label; + private String description; private UUID template; private Short status; private UUID dmp; @@ -81,6 +82,14 @@ public class Dataset implements ElasticEntity { this.label = label; } + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + public UUID getTemplate() { return template; } @@ -166,6 +175,7 @@ public class Dataset implements ElasticEntity { builder.startObject(); builder.field("id", this.id); builder.field("label", this.label); + builder.field("description", this.description); builder.field("template", this.template.toString()); builder.field("status", this.status.toString()); builder.field("dmp", this.dmp.toString()); @@ -227,6 +237,7 @@ public class Dataset implements ElasticEntity { this.tags = ((List) fields.get("tags")).stream().map(hashMap -> new Tag().fromElasticEntity(hashMap)).collect(Collectors.toList()); } this.label = (String) fields.get("label"); + this.description = (String) fields.get("description"); this.template = UUID.fromString((String) fields.get("template")); this.status = Short.valueOf((String) fields.get("status")); this.dmp = UUID.fromString((String) fields.get("dmp")); diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java index 5693b2543..c7483514e 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java @@ -3,9 +3,6 @@ package eu.eudat.elastic.repository; import eu.eudat.elastic.criteria.DatasetCriteria; import eu.eudat.elastic.entities.Dataset; import eu.eudat.elastic.entities.Tag; -import org.elasticsearch.client.core.CountRequest; -import org.elasticsearch.client.core.CountResponse; -import org.elasticsearch.client.indices.GetIndexRequest; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.index.IndexRequest; @@ -13,6 +10,9 @@ import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.client.core.CountRequest; +import org.elasticsearch.client.core.CountResponse; +import org.elasticsearch.client.indices.GetIndexRequest; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.BoolQueryBuilder; @@ -26,8 +26,8 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.UUID; -import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service("datasetRepository") public class DatasetRepository extends ElasticRepository { @@ -53,23 +53,26 @@ public class DatasetRepository extends ElasticRepository query(DatasetCriteria criteria) throws ExecutionException, InterruptedException, IOException { + public List query(DatasetCriteria criteria) throws IOException { SearchRequest searchRequest = new SearchRequest("datasets"); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); CountRequest countRequest = new CountRequest("datasets"); - countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", new short[]{Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()}))); + countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())))); CountResponse countResponse = getClient().count(countRequest, RequestOptions.DEFAULT); Long count = countResponse.getCount(); searchSourceBuilder.size(count.intValue()); - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", new short[]{Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()})); + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList()))); if (criteria.isPublic()) { boolQuery = boolQuery.should(QueryBuilders.termQuery("public.keyword", "true")); } - if (criteria.getLabel() != null && !criteria.getLabel().isEmpty()) { - boolQuery = boolQuery.should(QueryBuilders.matchPhrasePrefixQuery("label", criteria.getLabel())); + if (criteria.getLike() != null && !criteria.getLike().isEmpty()) { + boolQuery = boolQuery.should(QueryBuilders.queryStringQuery("*" + criteria.getLike() + "*").fields(Stream.of(new Object[][] { + { "label", 1.0f }, + { "description", 1.0f }, + }).collect(Collectors.toMap(data -> (String) data[0], data -> (Float) data[1])))); } if (criteria.getDatasetTemplates() != null && criteria.getDatasetTemplates().size() > 0) { @@ -100,8 +103,10 @@ public class DatasetRepository extends ElasticRepository 0) { diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 4f355902c..9bc472165 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -926,6 +926,7 @@ public class DataManagementPlanManager { eu.eudat.elastic.entities.Dataset datasetElastic = new eu.eudat.elastic.entities.Dataset(); datasetElastic.setId(dataset1.getId().toString()); datasetElastic.setLabel(dataset1.getLabel()); + datasetElastic.setDescription(dataset1.getDescription()); datasetElastic.setTemplate(dataset1.getProfile().getId()); datasetElastic.setStatus(dataset1.getStatus()); datasetElastic.setDmp(dataset1.getDmp().getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index ddf444a0d..0608a940c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -52,7 +52,6 @@ import org.springframework.core.env.Environment; import org.springframework.core.io.FileSystemResource; import org.springframework.http.*; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.LinkedMultiValueMap; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; @@ -73,9 +72,7 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; import java.io.*; import java.math.BigInteger; -import java.net.URL; import java.nio.file.Files; -import java.nio.file.Paths; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -109,7 +106,7 @@ public class DatasetManager { public DataTableData getPaged(DatasetTableRequest datasetTableRequest, Principal principal) throws Exception { DatasetCriteria datasetCriteria = new DatasetCriteria(); - datasetCriteria.setLabel(datasetTableRequest.getCriteria().getLike()); + datasetCriteria.setLike(datasetTableRequest.getCriteria().getLike()); datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetTemplates()); if (datasetTableRequest.getCriteria().getStatus() != null) { datasetCriteria.setStatus(datasetTableRequest.getCriteria().getStatus().shortValue()); @@ -194,7 +191,7 @@ public class DatasetManager { public DataTableData getPaged(DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception { DatasetCriteria datasetCriteria = new DatasetCriteria(); - datasetCriteria.setLabel(datasetTableRequest.getCriteria().getLike()); + datasetCriteria.setLike(datasetTableRequest.getCriteria().getLike()); datasetCriteria.setDatasetTemplates(datasetTableRequest.getCriteria().getDatasetProfile()); datasetCriteria.setDmps(datasetTableRequest.getCriteria().getDmpIds()); datasetCriteria.setGrants(datasetTableRequest.getCriteria().getGrants()); @@ -593,6 +590,7 @@ public class DatasetManager { dataset.setId(datasetWizardModel.getId().toString()); dataset.setTags(datasetWizardModel.getTags()); dataset.setLabel(datasetWizardModel.getLabel()); + dataset.setDescription(datasetWizardModel.getDescription()); dataset.setTemplate(datasetWizardModel.getProfile()); dataset.setStatus(datasetWizardModel.getStatus()); dataset.setDmp(datasetWizardModel.getDmp().getId()); diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts index b726c510e..90d1550aa 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts @@ -139,9 +139,6 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB request.criteria.grantStatus = value.grantStatus; } request.criteria.isPublic = this.isPublic; - if (this.isPublic) { - request.criteria.allVersions = true; - } // if (this.itemId) { // // request.criteria.groupIds = [this.itemId]; // request.criteria.allVersions = true; From a21afab48a1c4a373cc137c75e2e9d8f51dae4fd Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 12:43:20 +0200 Subject: [PATCH 098/160] Add Last Public Version on Dataset Index --- .../eu/eudat/elastic/entities/Dataset.java | 11 +++++++++++ .../elastic/repository/DatasetRepository.java | 2 ++ .../managers/DataManagementPlanManager.java | 18 ++++++++++++------ .../eudat/logic/managers/DatasetManager.java | 5 +++++ .../app/core/query/dataset/dataset-criteria.ts | 2 +- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java index 9cec9f0ba..d4a205f94 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java @@ -54,6 +54,7 @@ public class Dataset implements ElasticEntity { private UUID grant; private List collaborators; private Boolean lastVersion; + private Boolean lastPublicVersion; private List organizations; private Boolean isPublic; private Short grantStatus; @@ -146,6 +147,14 @@ public class Dataset implements ElasticEntity { this.lastVersion = lastVersion; } + public Boolean getLastPublicVersion() { + return lastPublicVersion; + } + + public void setLastPublicVersion(Boolean lastPublicVersion) { + this.lastPublicVersion = lastPublicVersion; + } + public List getOrganizations() { return organizations; } @@ -196,6 +205,7 @@ public class Dataset implements ElasticEntity { builder.endArray(); } builder.field("lastVersion", this.lastVersion.toString()); + builder.field("lastPublicVersion", this.lastPublicVersion.toString()); if (organizations != null) { builder.startArray("organizations"); this.organizations.forEach(x -> { @@ -247,6 +257,7 @@ public class Dataset implements ElasticEntity { this.collaborators = ((List) fields.get("collaborators")).stream().map(hashMap -> new Collaborator().fromElasticEntity(hashMap)).collect(Collectors.toList()); } this.lastVersion = Boolean.parseBoolean((String) fields.get("lastVersion")); + this.lastPublicVersion = Boolean.parseBoolean((String) fields.get("lastPublicVersion")); if (fields.get("organizations") != null) { this.organizations = ((List) fields.get("organizations")).stream().map(hashMap -> new Organization().fromElasticEntity(hashMap)).collect(Collectors.toList()); } diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java index c7483514e..fe06427a9 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java @@ -67,6 +67,8 @@ public class DatasetRepository extends ElasticRepository { Organization organization = new Organization(); @@ -1316,12 +1317,17 @@ public class DataManagementPlanManager { throw new Exception("DMP is not finalized"); dmp.setPublic(true); apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp); - dmp.getDataset().forEach(dataset -> { - try { - datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(dataset)); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } + DataManagementPlanCriteria criteria = new DataManagementPlanCriteria(); + criteria.setGroupIds(Collections.singletonList(dmp.getGroupId())); + criteria.setAllVersions(true); + apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).toList().stream().forEach(dmp1 -> { + dmp1.getDataset().forEach(dataset -> { + try { + datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(dataset)); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + }); }); UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); sendNotification(dmp, user, NotificationType.DMP_PUBLISH); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index 0608a940c..64d91d344 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -609,9 +609,14 @@ public class DatasetManager { dmpCriteria.setGroupIds(Collections.singletonList(datasetWizardModel.getDmp().getGroupId())); apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream() .max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> dataset.setLastVersion(dmp.getId().equals(datasetWizardModel.getDmp().getId()))); + apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream().filter(DMP::isPublic) + .max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> dataset.setLastPublicVersion(dmp.getId().equals(datasetWizardModel.getDmp().getId()))); if (dataset.getLastVersion() == null) { dataset.setLastVersion(true); } + if (dataset.getLastPublicVersion() == null) { + dataset.setLastPublicVersion(false); + } if (datasetWizardModel.getDmp().getOrganisations() != null) { dataset.setOrganizations(datasetWizardModel.getDmp().getOrganisations().stream().map(org -> { Organization organization = new Organization(); diff --git a/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts b/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts index 393d5ab2a..8ec8a8edb 100644 --- a/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts +++ b/dmp-frontend/src/app/core/query/dataset/dataset-criteria.ts @@ -6,7 +6,7 @@ export class DatasetCriteria extends BaseCriteria { public status?: Number; public dmpIds?: string[] = []; public tags?: ExternalSourceItemModel[] = []; - public allVersions?: boolean = true; + public allVersions?: boolean = false; public role?: number; public organisations?: string[] = []; public collaborators?: string[] = []; From 5336ac935f8314c8c052520eef841c84d373f126 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 12:43:57 +0200 Subject: [PATCH 099/160] Improve language Editor Styling --- .../src/app/ui/language-editor/language-editor.component.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/dmp-frontend/src/app/ui/language-editor/language-editor.component.scss b/dmp-frontend/src/app/ui/language-editor/language-editor.component.scss index 8179d9fc7..a02699a28 100644 --- a/dmp-frontend/src/app/ui/language-editor/language-editor.component.scss +++ b/dmp-frontend/src/app/ui/language-editor/language-editor.component.scss @@ -38,6 +38,7 @@ .search-text { border: 0px solid rgb(218, 218, 218); border-radius: 6px; + width: 180px; } .search-text::placeholder { color: rgb(197, 194, 194); From 4822274a98dfa00e3b7408c75551e5419b6ca102 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 12:44:37 +0200 Subject: [PATCH 100/160] Fixed public dataset DMP Link --- .../listing/listing-item/dataset-listing-item.component.html | 2 +- .../listing/listing-item/dataset-listing-item.component.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html index eea41275e..6837ff834 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.html @@ -34,7 +34,7 @@
- + storage diff --git a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts index 719c87fda..e39083138 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/listing-item/dataset-listing-item.component.ts @@ -37,6 +37,10 @@ export class DatasetListingItemComponent implements OnInit { return this.isPublic ? [`/datasets/publicEdit/${this.dataset.id}`] : [`/datasets/edit/${this.dataset.id}`]; } + getDmpLink(): string[] { + return this.isPublic ? [`/explore-plans/overview/${this.dataset.dmpId}`] : [`/plans/edit/${this.dataset.dmpId}`]; + } + // grantClicked(dataset: DatasetListingModel) { // this.router.navigate(['/grants/edit/' + dataset.grantId]); From 89d609a46c8fe38db15c044f9c61b0251bb3cf80 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 15:29:37 +0200 Subject: [PATCH 101/160] Minor bugfix --- .../java/eu/eudat/elastic/repository/DatasetRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java index fe06427a9..aedde08bc 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java @@ -111,7 +111,7 @@ public class DatasetRepository extends ElasticRepository 0) { + if (criteria.getOrganiztions() != null && criteria.getOrganiztions().size() > 0) { boolQuery = boolQuery.should(QueryBuilders.termsQuery("organizations.id.keyword", criteria.getOrganiztions())); } From 2c765dbc527975e5c06fcd466ee7dc18464781d4 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 15:57:28 +0200 Subject: [PATCH 102/160] Fixed issue when canceling dataset edit after at least one change --- .../app/ui/dataset/dataset-wizard/dataset-wizard.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index fc97ae0ad..2e66c4bce 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -412,7 +412,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr if (!isNullOrUndefined(this.lock)) { this.lockService.unlockTarget(this.datasetWizardModel.id).pipe(takeUntil(this._destroyed)).subscribe( complete => { - this.location.back(); + this.publicMode ? this.router.navigate(['/explore']) : this.router.navigate(['/datasets']); }, error => { this.formGroup.get('status').setValue(DmpStatus.Draft); @@ -421,7 +421,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr ) } else { - this.location.back(); + this.publicMode ? this.router.navigate(['/explore']) : this.router.navigate(['/datasets']); } } From 37a1253b08826230c6e733943892b60d31f0810f Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 15:59:25 +0200 Subject: [PATCH 103/160] When checking for pre-existing Funders, grants and project get the last modified if found --- .../eu/eudat/logic/managers/DataManagementPlanManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 37cfd5d4b..f7b73dd76 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -760,7 +760,7 @@ public class DataManagementPlanManager { GrantCriteria criteria = new GrantCriteria(); if (grant.getReference() != null) { criteria.setReference(grant.getReference()); - eu.eudat.data.entities.Grant grantEntity = grantDao.getWithCriteria(criteria).getSingleOrDefault(); + eu.eudat.data.entities.Grant grantEntity = grantDao.getWithCriteria(criteria).toList().stream().max(Comparator.comparing(grant1 -> grant1.getModified().getTime())).orElse(null); if (grantEntity != null) grant.setId(grantEntity.getId()); else { grant.setType(Grant.GrantType.EXTERNAL.getValue()); @@ -782,7 +782,7 @@ public class DataManagementPlanManager { FunderCriteria criteria = new FunderCriteria(); if (funder.getReference() != null) { criteria.setReference(funder.getReference()); - eu.eudat.data.entities.Funder funderEntity = funderDao.getWithCritetia(criteria).getSingleOrDefault(); + eu.eudat.data.entities.Funder funderEntity = funderDao.getWithCritetia(criteria).toList().stream().max(Comparator.comparing(funder1 -> funder1.getModified().getTime())).orElse(null); if (funderEntity != null) funder.setId(funderEntity.getId()); else { funderDao.createOrUpdate(funder); @@ -800,7 +800,7 @@ public class DataManagementPlanManager { ProjectCriteria criteria = new ProjectCriteria(); if (project.getReference() != null) { criteria.setReference(project.getReference()); - eu.eudat.data.entities.Project projectEntity = projectDao.getWithCritetia(criteria).getSingleOrDefault(); + eu.eudat.data.entities.Project projectEntity = projectDao.getWithCritetia(criteria).toList().stream().max(Comparator.comparing(project1 -> project1.getModified().getTime())).orElse(null); if (projectEntity != null) project.setId(projectEntity.getId()); else { project.setType(Project.ProjectType.EXTERNAL.getValue()); From 761e6ad07817d67f428e4ec46ae42e35a3e4cf29 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 16:40:10 +0200 Subject: [PATCH 104/160] Minor bugfix --- .../src/main/java/eu/eudat/logic/managers/DatasetManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index 64d91d344..c3248fce5 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -513,7 +513,7 @@ public class DatasetManager { Dataset dataset1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset); datasetWizardModel.setId(dataset1.getId()); - if (datasetWizardModel.getDmp() == null) { + if (datasetWizardModel.getDmp().getGrant() == null) { datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dataset1.getDmp())); } updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); From 1d05c73745cce3c695f1e41f062a98c94be244a0 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 17:10:14 +0200 Subject: [PATCH 105/160] Even more bugfixes --- .../main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java | 2 +- .../dmp/wizard/listing/dmp-wizard-dataset-listing.component.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java index 4a238a953..f6b8d5b7f 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java @@ -32,7 +32,7 @@ public class DatasetDaoImpl extends DatabaseAccess implements DatasetDa @Override public QueryableList getWithCriteria(DatasetCriteria criteria) { QueryableList query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class); - if (criteria.getIsPublic()) { + if (criteria.getIsPublic() != null && criteria.getIsPublic()) { query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true)); query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue())); query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), diff --git a/dmp-frontend/src/app/ui/dmp/wizard/listing/dmp-wizard-dataset-listing.component.ts b/dmp-frontend/src/app/ui/dmp/wizard/listing/dmp-wizard-dataset-listing.component.ts index 210b7034b..351dea94f 100644 --- a/dmp-frontend/src/app/ui/dmp/wizard/listing/dmp-wizard-dataset-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/wizard/listing/dmp-wizard-dataset-listing.component.ts @@ -64,6 +64,7 @@ export class DmpWizardDatasetListingComponent extends BaseComponent implements O const request: DataTableRequest = new DataTableRequest(null, null, null); request.criteria = new DatasetCriteria(); request.criteria.dmpIds = [this.dmpId]; + request.criteria.allVersions = true; this.datasetService.getPaged(request) .pipe(takeUntil(this._destroyed)) .subscribe(items => { From 697a8908e14c944eeb697c6972d2ec9b6aa69529 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 17:14:16 +0200 Subject: [PATCH 106/160] Copy Tags when cloning or making new versions --- .../eu/eudat/logic/managers/DataManagementPlanManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index f7b73dd76..5d9381632 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -868,7 +868,9 @@ public class DataManagementPlanManager { .thenApplyAsync(entityDataset -> { Dataset newDataset = new Dataset(); try { - this.datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(entityDataset)); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(entityDataset); + datasetWizardModel.setTags(apiContext.getOperationsContext().getDatasetRepository().findDocument(dataset.getId().toString()).getTags()); + this.datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); } catch (IOException e) { logger.error(e.getMessage(), e); } @@ -952,7 +954,9 @@ public class DataManagementPlanManager { } datasetElastic.setPublic(dataset1.getDmp().isPublic()); datasetElastic.setGrantStatus(dataset1.getDmp().getGrant().getStatus()); + try { + datasetElastic.setTags(apiContext.getOperationsContext().getDatasetRepository().findDocument(dataset.getId().toString()).getTags()); apiContext.getOperationsContext().getDatasetRepository().createOrUpdate(datasetElastic); } catch (IOException e) { logger.error(e.getMessage(), e); From aca78cac8e1f9a9d2dbbccead910a3dc52ad9efb Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 17:33:55 +0200 Subject: [PATCH 107/160] When deleting DMP update dataset indexes of previous versions --- .../logic/managers/DataManagementPlanManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 5d9381632..1530f2b9f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -725,6 +725,18 @@ public class DataManagementPlanManager { DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid); oldDmp.setStatus(DMP.DMPStatus.DELETED.getValue()); apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(oldDmp); + DataManagementPlanCriteria criteria1 = new DataManagementPlanCriteria(); + criteria1.setAllVersions(true); + criteria1.setGroupIds(Collections.singletonList(oldDmp.getGroupId())); + apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria1).toList().forEach(dmp -> { + for (Dataset dataset: dmp.getDataset()) { + try { + datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(dataset)); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } + }); } private void createResearchersIfTheyDontExist(DMP newDmp, ResearcherDao researcherRepository, UserInfo user) { From f48e4b527507d4b56a12093f9d682e3067507a67 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 17:46:41 +0200 Subject: [PATCH 108/160] Keep tags consistent --- .../eudat/logic/managers/DataManagementPlanManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 1530f2b9f..361f508ad 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -731,7 +731,9 @@ public class DataManagementPlanManager { apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria1).toList().forEach(dmp -> { for (Dataset dataset: dmp.getDataset()) { try { - datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(dataset)); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setTags(apiContext.getOperationsContext().getDatasetRepository().findDocument(dataset.getId().toString()).getTags()); + this.datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); } catch (IOException e) { logger.error(e.getMessage(), e); } @@ -1339,7 +1341,9 @@ public class DataManagementPlanManager { apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria).toList().stream().forEach(dmp1 -> { dmp1.getDataset().forEach(dataset -> { try { - datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), new DatasetWizardModel().fromDataModel(dataset)); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setTags(apiContext.getOperationsContext().getDatasetRepository().findDocument(dataset.getId().toString()).getTags()); + this.datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); } catch (IOException e) { logger.error(e.getMessage(), e); } From d6c8803c9f51785b55d819291cc11e734be0310f Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 17 Mar 2020 18:03:43 +0200 Subject: [PATCH 109/160] Prevent showing duplicate Tags --- .../java/eu/eudat/controllers/TagController.java | 3 ++- .../eu/eudat/logic/managers/DatasetManager.java | 11 ++++++++++- .../logic/utilities/helpers/StreamDistinctBy.java | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/StreamDistinctBy.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java index 87f47f03b..dd54267e9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java @@ -8,6 +8,7 @@ import eu.eudat.elastic.repository.Repository; import eu.eudat.logic.proxy.config.exceptions.HugeResultSet; import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.services.ApiContext; +import eu.eudat.logic.utilities.helpers.StreamDistinctBy; import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.types.ApiMessageCode; import org.springframework.beans.factory.annotation.Autowired; @@ -47,7 +48,7 @@ public class TagController extends BaseController { //ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query); /*List> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getTags(externalUrlCriteria, type); TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(remoteRepos);*/ - List tags = this.getApiContext().getOperationsContext().getDatasetRepository().query(new DatasetCriteria()).stream().map(Dataset::getTags).flatMap(Collection::stream).collect(Collectors.toList()); + List tags = this.getApiContext().getOperationsContext().getDatasetRepository().query(new DatasetCriteria()).stream().map(Dataset::getTags).flatMap(Collection::stream).filter(StreamDistinctBy.distinctByKey(Tag::getId)).collect(Collectors.toList()); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(tags).status(ApiMessageCode.NO_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index c3248fce5..c7e61f8d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -15,6 +15,7 @@ import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequest import eu.eudat.elastic.criteria.DatasetCriteria; import eu.eudat.elastic.entities.Collaborator; import eu.eudat.elastic.entities.Organization; +import eu.eudat.elastic.entities.Tag; import eu.eudat.elastic.repository.DatasetRepository; import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.builders.BuilderFactory; @@ -588,7 +589,15 @@ public class DatasetManager { // if (datasetWizardModel.getTags() != null && !datasetWizardModel.getTags().isEmpty()) { eu.eudat.elastic.entities.Dataset dataset = new eu.eudat.elastic.entities.Dataset(); dataset.setId(datasetWizardModel.getId().toString()); - dataset.setTags(datasetWizardModel.getTags()); + DatasetCriteria criteria = new DatasetCriteria(); + criteria.setTags(datasetWizardModel.getTags()); + List tags = apiContext.getOperationsContext().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream).collect(Collectors.toList()); + if (tags.isEmpty()) { + datasetWizardModel.getTags().forEach(tag -> tag.setId(UUID.randomUUID().toString())); + dataset.setTags(datasetWizardModel.getTags()); + } else { + dataset.setTags(tags); + } dataset.setLabel(datasetWizardModel.getLabel()); dataset.setDescription(datasetWizardModel.getDescription()); dataset.setTemplate(datasetWizardModel.getProfile()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/StreamDistinctBy.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/StreamDistinctBy.java new file mode 100644 index 000000000..1cce2c822 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/StreamDistinctBy.java @@ -0,0 +1,15 @@ +package eu.eudat.logic.utilities.helpers; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; +import java.util.function.Predicate; + +public class StreamDistinctBy { + + public static Predicate distinctByKey( + Function keyExtractor) { + Map found = new ConcurrentHashMap<>(); + return t -> found.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; + } +} From e68bc2a8222a4138b9706de8c03e66a29b4d34eb Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 18 Mar 2020 10:22:39 +0200 Subject: [PATCH 110/160] Improve tag unique persistence --- .../src/main/java/eu/eudat/logic/managers/DatasetManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index c7e61f8d4..ce0744cc6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -28,6 +28,7 @@ import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.logic.utilities.documents.types.ParagraphStyle; import eu.eudat.logic.utilities.documents.word.WordBuilder; import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder; +import eu.eudat.logic.utilities.helpers.StreamDistinctBy; import eu.eudat.models.HintedModelFactory; import eu.eudat.models.data.datasetImport.DatasetImportField; import eu.eudat.models.data.datasetImport.DatasetImportPagedDatasetProfile; @@ -591,7 +592,8 @@ public class DatasetManager { dataset.setId(datasetWizardModel.getId().toString()); DatasetCriteria criteria = new DatasetCriteria(); criteria.setTags(datasetWizardModel.getTags()); - List tags = apiContext.getOperationsContext().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream).collect(Collectors.toList()); + List tags = apiContext.getOperationsContext().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream) + .filter(StreamDistinctBy.distinctByKey(Tag::getId)).filter(tag -> datasetWizardModel.getTags().stream().anyMatch(tag1 -> tag1.getName().equals(tag.getName()))).collect(Collectors.toList()); if (tags.isEmpty()) { datasetWizardModel.getTags().forEach(tag -> tag.setId(UUID.randomUUID().toString())); dataset.setTags(datasetWizardModel.getTags()); From 672055f9ca2417ad0977861d182d3a2c6863f008 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 18 Mar 2020 11:19:53 +0200 Subject: [PATCH 111/160] Fix issue when inserting dataset status on dataset listing --- .../dataset/listing/criteria/dataset-criteria.component.html | 4 ++-- .../ui/dataset/listing/criteria/dataset-criteria.component.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html index 401fe56a6..e7f535af9 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html +++ b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.html @@ -16,8 +16,8 @@
{{'CRITERIA.DATA-SETS.STATUS'| translate}}
- {{ 'TYPES.DATASET-STATUS.ANY' | translate }} - {{ 'TYPES.DATASET-STATUS.DRAFT' | translate }} + {{ 'TYPES.DATASET-STATUS.ANY' | translate }} + {{ 'TYPES.DATASET-STATUS.DRAFT' | translate }} {{ 'TYPES.DATASET-STATUS.FINALISED' | translate }}
diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts index 51cce7441..55c7d6a8f 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts @@ -173,6 +173,7 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O .pipe(takeUntil(this._destroyed)) .subscribe(x => this.controlModified()); // if (this.criteria == null) { this.criteria = {}; } + this.formGroup.patchValue({'status': this.status !== undefined ? this.status : 'null'}); } setCriteria(criteria: DatasetCriteria): void { From 7082b958acb5aa997b172452d301dad5cd726ae9 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 18 Mar 2020 11:22:10 +0200 Subject: [PATCH 112/160] Fix dashboard showing incorrect dmp and dataset counts --- .../controllers/DashBoardController.java | 3 +- .../logic/managers/DashBoardManager.java | 43 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DashBoardController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DashBoardController.java index 4fb4e00ca..dcb99e942 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DashBoardController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DashBoardController.java @@ -15,6 +15,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.io.IOException; import java.util.List; @RestController @@ -36,7 +37,7 @@ public class DashBoardController extends BaseController { } @RequestMapping(method = RequestMethod.GET, value = {"/dashboard/me/getStatistics"}, produces = "application/json") - public ResponseEntity> getStatistics(Principal principal) { + public ResponseEntity> getStatistics(Principal principal) throws IOException { DashBoardStatistics statistics = dashBoardManager.getMeStatistics(principal); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(statistics)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DashBoardManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DashBoardManager.java index 81b1b9755..e87c74dc8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DashBoardManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DashBoardManager.java @@ -1,14 +1,12 @@ package eu.eudat.logic.managers; -import eu.eudat.data.dao.criteria.DataManagementPlanCriteria; -import eu.eudat.data.dao.criteria.DatasetCriteria; -import eu.eudat.data.dao.criteria.OrganisationCriteria; -import eu.eudat.data.dao.criteria.GrantCriteria; +import eu.eudat.data.dao.criteria.*; import eu.eudat.data.dao.entities.DMPDao; import eu.eudat.data.dao.entities.DatasetDao; import eu.eudat.data.dao.entities.OrganisationDao; import eu.eudat.data.dao.entities.GrantDao; import eu.eudat.data.entities.*; +import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest; import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; @@ -21,9 +19,12 @@ import eu.eudat.types.searchbar.SearchBarItemType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.io.IOException; import java.util.LinkedList; import java.util.List; +import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; @Component public class DashBoardManager { @@ -40,13 +41,25 @@ public class DashBoardManager { public DashBoardStatistics getStatistics() { DashBoardStatistics statistics = new DashBoardStatistics(); - DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria(); + DataManagmentPlanPublicTableRequest publicTableRequest = new DataManagmentPlanPublicTableRequest(); + + DataManagementPlanPublicCriteria publicCriteria = new DataManagementPlanPublicCriteria(); + + publicCriteria.setAllVersions(false); + + publicTableRequest.setCriteria(publicCriteria); + + publicTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable()); + + List dmps = publicTableRequest.applyCriteria().toList(); + +// DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria(); OrganisationCriteria organisationCriteria = new OrganisationCriteria(); - dataManagementPlanCriteria.setAllVersions(false); - dataManagementPlanCriteria.setIsPublic(true); + /*dataManagementPlanCriteria.setAllVersions(false); + dataManagementPlanCriteria.setIsPublic(true);*/ organisationCriteria.setPublic(true); - List dmps = databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).toList(); +// List dmps = databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).toList(); long numberOfDatasets = 0; LinkedList grants = new LinkedList<>(); for (DMP dmp : dmps) { @@ -63,7 +76,8 @@ public class DashBoardManager { return statistics; } - public DashBoardStatistics getMeStatistics(Principal principal) { + public DashBoardStatistics getMeStatistics(Principal principal) throws IOException { + List datasets = null; DashBoardStatistics statistics = new DashBoardStatistics(); DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao(); DatasetDao datasetRepository = databaseRepository.getDatasetDao(); @@ -72,6 +86,12 @@ public class DashBoardManager { UserInfo user = new UserInfo(); user.setId(principal.getId()); DatasetCriteria datasetCriteria = new DatasetCriteria(); + if (apiContext.getOperationsContext().getDatasetRepository() != null) { + eu.eudat.elastic.criteria.DatasetCriteria datasetElasticCriteria = new eu.eudat.elastic.criteria.DatasetCriteria(); + datasetElasticCriteria.setAllowAllVersions(false); + datasetElasticCriteria.setPublic(false); + datasets = apiContext.getOperationsContext().getDatasetRepository().query(datasetElasticCriteria); + } datasetCriteria.setAllVersions(false); datasetCriteria.setIsPublic(false); DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria(); @@ -81,8 +101,9 @@ public class DashBoardManager { List roles = new LinkedList<>(); CompletableFuture dmpFuture = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria), principal.getId(), roles).countAsync() .whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats)); - CompletableFuture datasetFuture = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user, roles).countAsync() - .whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats)); + List finalDatasets = datasets; + CompletableFuture datasetFuture = datasetRepository.getAuthenticated(datasets !=null ? datasetRepository.asQueryable().where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList()))) : datasetRepository.getWithCriteria(datasetCriteria), user, roles).countAsync() + .whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats)); CompletableFuture grantFuture = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user).countAsync() .whenComplete((grantsStats, throwable) -> statistics.setTotalGrantCount(grantsStats)); CompletableFuture orgnanisationFuture = organisationRepository.getAuthenticated(organisationRepository.asQueryable().withHint("organisationRecentActivity"), user).countAsync() From aa1156f940f6be851fa59e2edf2d533fb5fbe370 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 18 Mar 2020 18:23:34 +0200 Subject: [PATCH 113/160] Add Form Data index for dataset --- .../eu/eudat/elastic/entities/Dataset.java | 11 ++ .../elastic/repository/DatasetRepository.java | 3 +- .../controllers/DatasetWizardController.java | 4 +- .../managers/DataManagementPlanManager.java | 15 ++- .../eudat/logic/managers/DatasetManager.java | 124 ++++++++++++++---- 5 files changed, 121 insertions(+), 36 deletions(-) diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java index d4a205f94..ee538c06b 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/entities/Dataset.java @@ -58,6 +58,7 @@ public class Dataset implements ElasticEntity { private List organizations; private Boolean isPublic; private Short grantStatus; + private String formData; public String getId() { return id; @@ -179,6 +180,14 @@ public class Dataset implements ElasticEntity { this.grantStatus = grantStatus; } + public String getFormData() { + return formData; + } + + public void setFormData(String formData) { + this.formData = formData; + } + @Override public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException { builder.startObject(); @@ -235,6 +244,7 @@ public class Dataset implements ElasticEntity { if (this.grantStatus != null) { builder.field("grantStatus", this.grantStatus.toString()); } + builder.field("formData", this.formData); builder.endObject(); return builder; } @@ -267,6 +277,7 @@ public class Dataset implements ElasticEntity { if (fields.get("grantStatus") != null) { this.grantStatus = Short.valueOf((String) fields.get("grantStatus")); } + this.formData = (String) fields.get("formData"); } return this; } diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java index aedde08bc..6e862df5f 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java @@ -71,9 +71,10 @@ public class DatasetRepository extends ElasticRepository (String) data[0], data -> (Float) data[1])))); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java index b5967aa67..bed8c804a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DatasetWizardController.java @@ -88,7 +88,7 @@ public class DatasetWizardController extends BaseController { VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService(); return this.datasetManager.getDocument(id, visibilityRuleService, contentType, principal); } else if (contentType.equals("application/msword")) { - File file = datasetManager.getWordDocument(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); + File file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); InputStream resource = new FileInputStream(file); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentLength(file.length()); @@ -152,7 +152,7 @@ public class DatasetWizardController extends BaseController { @RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"}) public @ResponseBody ResponseEntity getPDFDocument(@PathVariable String id, Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException { - File file = datasetManager.getWordDocument(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); + File file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal); String fileName = file.getName(); if (fileName.endsWith(".docx")){ fileName = fileName.substring(0, fileName.length() - 5); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 361f508ad..7711314f5 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -733,8 +733,9 @@ public class DataManagementPlanManager { try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setTags(apiContext.getOperationsContext().getDatasetRepository().findDocument(dataset.getId().toString()).getTags()); + datasetWizardModel.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(datasetWizardModel, dataset)); this.datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); - } catch (IOException e) { + } catch (Exception e) { logger.error(e.getMessage(), e); } } @@ -884,8 +885,9 @@ public class DataManagementPlanManager { try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(entityDataset); datasetWizardModel.setTags(apiContext.getOperationsContext().getDatasetRepository().findDocument(dataset.getId().toString()).getTags()); + datasetWizardModel.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(datasetWizardModel, entityDataset)); this.datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); - } catch (IOException e) { + } catch (Exception e) { logger.error(e.getMessage(), e); } newDataset.update(entityDataset); @@ -971,8 +973,12 @@ public class DataManagementPlanManager { try { datasetElastic.setTags(apiContext.getOperationsContext().getDatasetRepository().findDocument(dataset.getId().toString()).getTags()); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); + datasetWizardModel.setStatus(dataset1.getStatus()); + datasetWizardModel.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(datasetWizardModel, dataset1)); + datasetElastic.setFormData(this.datasetManager.getWordDocumentText(datasetWizardModel)); apiContext.getOperationsContext().getDatasetRepository().createOrUpdate(datasetElastic); - } catch (IOException e) { + } catch (Exception e) { logger.error(e.getMessage(), e); } }))); @@ -1343,8 +1349,9 @@ public class DataManagementPlanManager { try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setTags(apiContext.getOperationsContext().getDatasetRepository().findDocument(dataset.getId().toString()).getTags()); + datasetWizardModel.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(datasetWizardModel, dataset)); this.datasetManager.updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); - } catch (IOException e) { + } catch (Exception e) { logger.error(e.getMessage(), e); } }); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index ce0744cc6..94d245263 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -43,6 +43,7 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.queryable.QueryableList; import eu.eudat.types.Authorities; import org.apache.commons.io.IOUtils; +import org.apache.poi.xwpf.extractor.XWPFWordExtractor; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRun; @@ -64,6 +65,7 @@ import org.w3c.dom.NodeList; import javax.activation.MimetypesFileTypeMap; import javax.persistence.criteria.Join; import javax.persistence.criteria.JoinType; +import javax.transaction.Transactional; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; @@ -96,14 +98,16 @@ public class DatasetManager { private DatasetRepository datasetRepository; private BuilderFactory builderFactory; private UserManager userManager; + private ConfigLoader configLoader; @Autowired - public DatasetManager(ApiContext apiContext, UserManager userManager) { + public DatasetManager(ApiContext apiContext, UserManager userManager, ConfigLoader configLoader) { this.apiContext = apiContext; this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.datasetRepository = apiContext.getOperationsContext().getDatasetRepository(); this.builderFactory = apiContext.getOperationsContext().getBuilderFactory(); this.userManager = userManager; + this.configLoader = configLoader; } public DataTableData getPaged(DatasetTableRequest datasetTableRequest, Principal principal) throws Exception { @@ -331,15 +335,11 @@ public class DatasetManager { return pagedDatasetProfile; } - public File getWordDocument(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService, Principal principal) throws IOException { + private XWPFDocument getWordDocument(ConfigLoader configLoader, eu.eudat.data.entities.Dataset datasetEntity, VisibilityRuleService visibilityRuleService) throws IOException { WordBuilder wordBuilder = new WordBuilder(); DatasetWizardModel dataset = new DatasetWizardModel(); XWPFDocument document = configLoader.getDocument(); - eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class)); - if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers() - .stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()) - .collect(Collectors.toList()).size() == 0) - throw new UnauthorisedException(); + wordBuilder.addParagraphContent(datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO); // Space below Dataset title. @@ -410,10 +410,62 @@ public class DatasetManager { document.removeBodyElement(0); } + return document; + //FileOutputStream out = new FileOutputStream(exportFile); + // document.write(out); + // out.close(); + // return exportFile; + } + + private XWPFDocument getightWordDocument(ConfigLoader configLoader, DatasetWizardModel dataset, VisibilityRuleService visibilityRuleService) throws IOException { + WordBuilder wordBuilder = new WordBuilder(); + XWPFDocument document = configLoader.getDocument(); + + // Space below Dataset title. + XWPFParagraph parBreakDataset = document.createParagraph(); + + Map properties = new HashMap<>(); + if (dataset.getDatasetProfileDefinition() != null) { + JSONObject jObject = new JSONObject(propertiesModelToString(dataset.getDatasetProfileDefinition())); + properties = jObject.toMap(); + } + + wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO); + visibilityRuleService.setProperties(properties); + visibilityRuleService.buildVisibilityContext(dataset.getDatasetProfileDefinition().getRules()); + wordBuilder.build(document, dataset.getDatasetProfileDefinition(), visibilityRuleService); + + // Removes the top empty headings. + for (int i = 0; i < 6; i++) { + document.removeBodyElement(0); + } + + return document; + //FileOutputStream out = new FileOutputStream(exportFile); + // document.write(out); + // out.close(); + // return exportFile; + } + + public File getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService, Principal principal) throws IOException { + eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class)); + if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers() + .stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()) + .collect(Collectors.toList()).size() == 0) + throw new UnauthorisedException(); + String label = datasetEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", ""); + File exportFile = new File(label + ".docx"); + XWPFDocument document = getWordDocument(configLoader, datasetEntity, visibilityRuleService); FileOutputStream out = new FileOutputStream(exportFile); - document.write(out); - out.close(); - return exportFile; + document.write(out); + out.close(); + return exportFile; + } + + public String getWordDocumentText (DatasetWizardModel datasetEntity) throws Exception { + XWPFDocument document = getightWordDocument(this.configLoader, datasetEntity, this.apiContext.getUtilitiesService().getVisibilityRuleService()); + XWPFWordExtractor extractor = new XWPFWordExtractor(document); + return extractor.getText();/*.replaceAll("\n\\s*", " ");*/ } public FileEnvelope getXmlDocument(String id, VisibilityRuleService visibilityRuleService, Principal principal) throws InstantiationException, IllegalAccessException, IOException { @@ -488,9 +540,10 @@ public class DatasetManager { public eu.eudat.data.entities.Dataset createOrUpdate(DatasetWizardModel datasetWizardModel, Principal principal) throws Exception { Boolean sendNotification = false; + Dataset tempDataset = null; DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId()); if (datasetWizardModel.getId() != null) { - Dataset tempDataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId()); + tempDataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId()); if (tempDataset != null) { if (datasetWizardModel.getModified().getTime() != tempDataset.getModified().getTime()) { throw new Exception("Dataset has been modified already by another user."); @@ -502,7 +555,7 @@ public class DatasetManager { throw new Exception("DMP is finalized, therefore Dataset cannot be edited."); eu.eudat.data.entities.Dataset dataset = datasetWizardModel.toDataModel(); dataset.setDmp(dmp); - propertiesModelToString(datasetWizardModel, dataset); + dataset.setProperties(propertiesModelToString(datasetWizardModel.getDatasetProfileDefinition())); if (datasetWizardModel.getStatus() == (int) Dataset.Status.FINALISED.getValue()) checkDatasetValidation(dataset); UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build(); @@ -512,12 +565,13 @@ public class DatasetManager { createExternalDatasetsIfTheyDontExist(dataset); createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), dataset); createServicesIfTheyDontExist(dataset); - Dataset dataset1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset); datasetWizardModel.setId(dataset1.getId()); if (datasetWizardModel.getDmp().getGrant() == null) { datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dataset1.getDmp())); } + dataset1.setProfile(this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(datasetWizardModel.getProfile())); + datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1)); updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); if (sendNotification) { if (dataset1.getStatus() != Dataset.Status.FINALISED.getValue()) { @@ -578,27 +632,28 @@ public class DatasetManager { } } - private void propertiesModelToString(DatasetWizardModel datasetWizardModel, eu.eudat.data.entities.Dataset dataset) { + private String propertiesModelToString(PagedDatasetProfile pagedDatasetProfile) { Map values = new HashMap(); - PagedDatasetProfile properties = datasetWizardModel.getDatasetProfileDefinition(); - properties.toMap(values); + pagedDatasetProfile.toMap(values); JSONObject jobject = new JSONObject(values); - dataset.setProperties(jobject.toString()); + return jobject.toString(); } - public void updateTags(DatasetRepository datasetRepository, DatasetWizardModel datasetWizardModel) throws IOException { + public void updateTags(DatasetRepository datasetRepository, DatasetWizardModel datasetWizardModel) throws Exception { // if (datasetWizardModel.getTags() != null && !datasetWizardModel.getTags().isEmpty()) { eu.eudat.elastic.entities.Dataset dataset = new eu.eudat.elastic.entities.Dataset(); dataset.setId(datasetWizardModel.getId().toString()); - DatasetCriteria criteria = new DatasetCriteria(); - criteria.setTags(datasetWizardModel.getTags()); - List tags = apiContext.getOperationsContext().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream) - .filter(StreamDistinctBy.distinctByKey(Tag::getId)).filter(tag -> datasetWizardModel.getTags().stream().anyMatch(tag1 -> tag1.getName().equals(tag.getName()))).collect(Collectors.toList()); - if (tags.isEmpty()) { - datasetWizardModel.getTags().forEach(tag -> tag.setId(UUID.randomUUID().toString())); - dataset.setTags(datasetWizardModel.getTags()); - } else { - dataset.setTags(tags); + if (datasetWizardModel.getTags() != null && !datasetWizardModel.getTags().isEmpty()) { + DatasetCriteria criteria = new DatasetCriteria(); + criteria.setTags(datasetWizardModel.getTags()); + List tags = apiContext.getOperationsContext().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream) + .filter(StreamDistinctBy.distinctByKey(Tag::getId)).filter(tag -> datasetWizardModel.getTags().stream().anyMatch(tag1 -> tag1.getName().equals(tag.getName()))).collect(Collectors.toList()); + if (tags.isEmpty()) { + datasetWizardModel.getTags().forEach(tag -> tag.setId(UUID.randomUUID().toString())); + dataset.setTags(datasetWizardModel.getTags()); + } else { + dataset.setTags(tags); + } } dataset.setLabel(datasetWizardModel.getLabel()); dataset.setDescription(datasetWizardModel.getDescription()); @@ -638,10 +693,13 @@ public class DatasetManager { } dataset.setPublic(datasetWizardModel.getDmp().getPublic()); dataset.setGrantStatus(datasetWizardModel.getDmp().getGrant().getStatus()); + dataset.setFormData(this.getWordDocumentText(datasetWizardModel)); datasetRepository.createOrUpdate(dataset); // } } + + private void createRegistriesIfTheyDontExist(RegistryDao registryDao, eu.eudat.data.entities.Dataset dataset) { if (dataset.getRegistries() != null && !dataset.getRegistries().isEmpty()) { for (eu.eudat.data.entities.Registry registry : dataset.getRegistries()) { @@ -887,11 +945,19 @@ public class DatasetManager { if (principal.getAuthorities().contains(Authorities.ADMIN.getValue())) { this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().toList(); List datasetWizardModels = this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().toList() - .stream().map(dataset -> new DatasetWizardModel().fromDataModel(dataset)).collect(Collectors.toList()); + .stream().map(dataset -> { + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset)); + return datasetWizardModel; + }).collect(Collectors.toList()); datasetWizardModels.forEach(datasetWizardModel -> { try { + eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getDatasetRepository().findDocument(datasetWizardModel.getId().toString()); + if (dataset != null) { + datasetWizardModel.setTags(dataset.getTags()); + } updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel); - } catch (IOException e) { + } catch (Exception e) { logger.error(e.getMessage(), e); } }); From 097d45dc0b0117539118ba3f7d7898a127ff2c43 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 18 Mar 2020 18:25:04 +0200 Subject: [PATCH 114/160] Add days on log files --- dmp-backend/web/src/main/resources/logging/logback-devel.xml | 2 +- .../web/src/main/resources/logging/logback-production.xml | 2 +- dmp-backend/web/src/main/resources/logging/logback-staging.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/resources/logging/logback-devel.xml b/dmp-backend/web/src/main/resources/logging/logback-devel.xml index 9ea9f4d62..ddf6798c2 100644 --- a/dmp-backend/web/src/main/resources/logging/logback-devel.xml +++ b/dmp-backend/web/src/main/resources/logging/logback-devel.xml @@ -9,7 +9,7 @@ ${user.home}/openDMP/logs/openDMP.log - ${user.home}/openDMP/logs/openDMP-%d{yyyy-MM}.%i.log + ${user.home}/openDMP/logs/openDMP-%d{yyyy-MM-dd}.%i.log 100MB diff --git a/dmp-backend/web/src/main/resources/logging/logback-production.xml b/dmp-backend/web/src/main/resources/logging/logback-production.xml index ee78b6c5d..9b27c97dc 100644 --- a/dmp-backend/web/src/main/resources/logging/logback-production.xml +++ b/dmp-backend/web/src/main/resources/logging/logback-production.xml @@ -9,7 +9,7 @@ /files/logs/openDMP.log - /files/logs/openDMP-%d{yyyy-MM}.%i.log + /files/logs/openDMP-%d{yyyy-MM-dd}.%i.log 100MB diff --git a/dmp-backend/web/src/main/resources/logging/logback-staging.xml b/dmp-backend/web/src/main/resources/logging/logback-staging.xml index 5abe36da5..f1e40e210 100644 --- a/dmp-backend/web/src/main/resources/logging/logback-staging.xml +++ b/dmp-backend/web/src/main/resources/logging/logback-staging.xml @@ -9,7 +9,7 @@ /files/logs/openDMP.log - /files/logs/openDMP-%d{yyyy-MM}.%i.log + /files/logs/openDMP-%d{yyyy-MM-dd}.%i.log 100MB From b5877f997c33cbbb9a257c09534535aca7336990 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 19 Mar 2020 12:50:23 +0200 Subject: [PATCH 115/160] Fix and Improve Zenodo DOI creation --- .../managers/DataManagementPlanManager.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 7711314f5..a66f014df 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -1,6 +1,7 @@ package eu.eudat.logic.managers; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration; import eu.eudat.configurations.dynamicgrant.entities.Property; @@ -68,6 +69,8 @@ import org.springframework.http.*; import org.springframework.stereotype.Component; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; import org.w3c.dom.Document; @@ -1434,7 +1437,7 @@ public class DataManagementPlanManager { // First step, post call to Zenodo, to create the entry. RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); - headers.set("accept", "application/json"); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.setContentType(MediaType.APPLICATION_JSON); String createData = "{\n" + " \"metadata\": {\n" + @@ -1448,17 +1451,20 @@ public class DataManagementPlanManager { " \t\t\"affiliation\": \"OpenDMP\"}]\n" + " }\n" + "}"; - HttpEntity request = new HttpEntity<>(createData, headers); + JsonNode createDataJSON = new ObjectMapper().readTree(createData); + HttpEntity request = new HttpEntity<>(createDataJSON, headers); Map createResponse = null; LinkedHashMap links = null; - if (dmp.getVersion() == 0) { + String previousDOI = this.getPreviousDOI(dmp.getGroupId(), dmp.getId()); + try { + if (previousDOI == null) { String createUrl = this.environment.getProperty("zenodo.url") + "deposit/depositions" + "?access_token=" + this.environment.getProperty("zenodo.access_token"); - createResponse = restTemplate.postForObject(createUrl, request, Map.class); + createResponse = restTemplate.postForEntity(createUrl, request, Map.class).getBody(); links = (LinkedHashMap) createResponse.get("links"); } else { //It requires more than one step to create a new version //First, get the deposit related to the concept DOI - String listUrl = this.environment.getProperty("zenodo.url") + "deposit/depositions" + "?q=conceptdoi:\"" + this.getPreviousDOI(dmp.getGroupId(), dmp.getId()) + "\"&access_token=" + this.environment.getProperty("zenodo.access_token"); + String listUrl = this.environment.getProperty("zenodo.url") + "deposit/depositions" + "?q=conceptdoi:\"" + previousDOI + "\"&access_token=" + this.environment.getProperty("zenodo.access_token"); ResponseEntity listResponses = restTemplate.getForEntity(listUrl, Map[].class); createResponse = listResponses.getBody()[0]; links = (LinkedHashMap) createResponse.get("links"); @@ -1511,5 +1517,10 @@ public class DataManagementPlanManager { dmp.setDoi((String) publishResponce.get("conceptdoi")); apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp); return (String) publishResponce.get("conceptdoi"); + } catch (HttpClientErrorException | HttpServerErrorException ex) { + ObjectMapper ob = new ObjectMapper(); + Map parsedException = ob.readValue(ex.getResponseBodyAsString(), HashMap.class); + throw new IOException(parsedException.get("message"), ex); + } } } From 2dc5037afec8bc2fab36cbed2fc9487dce0e8c2f Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 19 Mar 2020 13:36:01 +0200 Subject: [PATCH 116/160] Fixed issue when impoting DMP with Organizations and/or researchers --- .../eu/eudat/logic/managers/DataManagementPlanManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index a66f014df..d655d8ba4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -635,7 +635,6 @@ public class DataManagementPlanManager { } - private void assignUser(DMP dmp, UserInfo userInfo) { UserDMP userDMP = new UserDMP(); userDMP.setDmp(dmp); @@ -1251,14 +1250,16 @@ public class DataManagementPlanManager { for (OrganisationImportModel org : dataManagementPlans.get(0).getOrganisationImportModels()) { eu.eudat.models.data.dmp.Organisation organisation = new eu.eudat.models.data.dmp.Organisation(); organisation.setLabel(org.getOrganaisationNameImport()); - organisation.setId(org.getOrganaisationReferenceImport()); + organisation.setReference(org.getOrganaisationReferenceImport()); + organisation.setKey(organisation.getReference().split(":")[0]); organisations.add(organisation); } List researchers = new LinkedList<>(); for (ResearcherImportModels res : dataManagementPlans.get(0).getResearchersImportModels()) { eu.eudat.models.data.dmp.Researcher researcher = new eu.eudat.models.data.dmp.Researcher(); researcher.setLabel(res.getResearcherImportName()); - researcher.setId(res.getResearcherImportReference()); + researcher.setReference(res.getResearcherImportReference()); + researcher.setKey(researcher.getReference().split(":")[0]); researchers.add(researcher); } From efe75b49328562ea1c29ea6ef7c0765edd8f5d45 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 19 Mar 2020 18:22:47 +0200 Subject: [PATCH 117/160] Minor fixes on DMP json export --- .../java/eu/eudat/logic/managers/DataManagementPlanManager.java | 2 +- .../java/eu/eudat/models/data/rda/DatasetRDAExportModel.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index d655d8ba4..e88e48524 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -1135,7 +1135,7 @@ public class DataManagementPlanManager { mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); - File file = new File(fileName); + File file = new File(fileName + ".json"); try { mapper.writeValue(file, rdaExportModel); } catch (IOException e) { diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index 0418feca3..c9f509020 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -315,7 +315,7 @@ public class DatasetRDAExportModel { if (rdaField.getRdaProperty().equals("dataset.metadata.language")) { metadataRda.setLanguage(rdaField.getRdaValue()); } - if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id")) { + if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id") && !rdaField.getRdaValue().isEmpty()) { JSONArray jsonArray = new JSONArray(rdaField.getRdaValue()); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); From 759016dd0b94240391481f829b73620ca5c91b74 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 20 Mar 2020 15:55:34 +0200 Subject: [PATCH 118/160] Fixed issue when retrieving Datasets from the Database when index return no results --- .../src/main/java/eu/eudat/logic/managers/DatasetManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index 94d245263..f8414faf4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -150,7 +150,7 @@ public class DatasetManager { items.where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList()))); } else { items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class)); - items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()})); + //items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()})); } } else { items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class)); From cbf8bca268c06a062313756ed1780a81097d1be1 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 20 Mar 2020 18:20:22 +0200 Subject: [PATCH 119/160] Add new RDA exporter --- .../managers/DataManagementPlanManager.java | 13 +- .../logic/managers/DatasetProfileManager.java | 4 +- .../eu/eudat/logic/managers/RDAManager.java | 38 + .../logic/utilities/json/JsonSearcher.java | 32 + .../commons/datafield/AutoCompleteData.java | 2 + .../commons/datafield/ComboBoxData.java | 11 + .../ExternalAutocompleteFieldModel.java | 12 +- .../data/rda/DatasetRDAExportModel.java | 3 +- .../java/eu/eudat/models/rda/Contact.java | 146 +++ .../java/eu/eudat/models/rda/ContactId.java | 154 ++++ .../java/eu/eudat/models/rda/Contributor.java | 181 ++++ .../eu/eudat/models/rda/ContributorId.java | 155 ++++ .../main/java/eu/eudat/models/rda/Cost.java | 374 ++++++++ .../java/eu/eudat/models/rda/Dataset.java | 839 ++++++++++++++++++ .../java/eu/eudat/models/rda/DatasetId.java | 156 ++++ .../eu/eudat/models/rda/Distribution.java | 412 +++++++++ .../main/java/eu/eudat/models/rda/Dmp.java | 774 ++++++++++++++++ .../main/java/eu/eudat/models/rda/DmpId.java | 156 ++++ .../java/eu/eudat/models/rda/FunderId.java | 154 ++++ .../java/eu/eudat/models/rda/Funding.java | 187 ++++ .../java/eu/eudat/models/rda/GrantId.java | 153 ++++ .../main/java/eu/eudat/models/rda/Host.java | 775 ++++++++++++++++ .../java/eu/eudat/models/rda/License.java | 113 +++ .../eudat/models/rda/MetadataStandardId.java | 153 ++++ .../java/eu/eudat/models/rda/Metadatum.java | 368 ++++++++ .../java/eu/eudat/models/rda/PidSystem.java | 63 ++ .../java/eu/eudat/models/rda/Project.java | 212 +++++ .../java/eu/eudat/models/rda/RDAModel.java | 58 ++ .../eudat/models/rda/SecurityAndPrivacy.java | 109 +++ .../eudat/models/rda/TechnicalResource.java | 109 +++ .../models/rda/mapper/ContactIdRDAMapper.java | 15 + .../models/rda/mapper/ContactRDAMapper.java | 16 + .../rda/mapper/ContributorIdRDAMapper.java | 16 + .../rda/mapper/ContributorRDAMapper.java | 20 + .../models/rda/mapper/DatasetIdRDAMapper.java | 17 + .../models/rda/mapper/DatasetRDAMapper.java | 100 +++ .../rda/mapper/DistributionRDAMapper.java | 39 + .../models/rda/mapper/DmpIdRDAMapper.java | 19 + .../eudat/models/rda/mapper/DmpRDAMapper.java | 51 ++ .../models/rda/mapper/FunderIdRDAMapper.java | 19 + .../models/rda/mapper/FundingRDAMapper.java | 25 + .../models/rda/mapper/GrantIdRDAMapper.java | 13 + .../models/rda/mapper/HostRDAMapper.java | 41 + .../models/rda/mapper/LicenseRDAMapper.java | 23 + .../models/rda/mapper/MetadataRDAMapper.java | 44 + .../mapper/MetadataStandardIdRDAMapper.java | 13 + .../models/rda/mapper/ProjectRDAMapper.java | 25 + .../mapper/SecurityAndPrivacyRDAMapper.java | 21 + .../mapper/TechnicalResourceRDAMapper.java | 21 + 49 files changed, 6447 insertions(+), 7 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index e88e48524..2710ec60c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -105,14 +105,16 @@ public class DataManagementPlanManager { private UtilitiesService utilitiesService; private DatabaseRepository databaseRepository; private Environment environment; + private RDAManager rdaManager; @Autowired - public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment) { + public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager) { this.apiContext = apiContext; this.datasetManager = datasetManager; this.utilitiesService = apiContext.getUtilitiesService(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.environment = environment; + this.rdaManager = rdaManager; } public DataTableData getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception { @@ -1129,15 +1131,20 @@ public class DataManagementPlanManager { eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id)); if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId())) throw new UnauthorisedException(); - RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); +// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); + String result = rdaManager.convertToRDA(dmp); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); File file = new File(fileName + ".json"); + OutputStream output = new FileOutputStream(file); try { - mapper.writeValue(file, rdaExportModel); +// mapper.writeValue(file, rdaExportModel); + output.write(result.getBytes()); + output.flush(); + output.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 079359827..81693e917 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -113,8 +113,8 @@ public class DatasetProfileManager { ResponseEntity response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class); DocumentContext jsonContext = JsonPath.parse(response.getBody()); - List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "']"); - jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource())))); + List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "','" + "uri" + "']"); + jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()), item.get("uri")))); return result; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java new file mode 100644 index 000000000..eb10fd753 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -0,0 +1,38 @@ +package eu.eudat.logic.managers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DMP; +import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.RDAModel; +import eu.eudat.models.rda.mapper.DmpRDAMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.text.SimpleDateFormat; + +@Component +public class RDAManager { + + private DmpRDAMapper dmpRDAMapper; + + @Autowired + public RDAManager(DmpRDAMapper dmpRDAMapper) { + this.dmpRDAMapper = dmpRDAMapper; + } + + @Transactional + public String convertToRDA(DMP dmp) throws JsonProcessingException { + String result = ""; + + Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + + result = mapper.writeValueAsString(rdaDmp); + + return result; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java new file mode 100644 index 000000000..ca2372b91 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -0,0 +1,32 @@ +package eu.eudat.logic.utilities.json; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class JsonSearcher { + + public static List findNodes(JsonNode root, String key, String value) { + List nodes = new ArrayList<>(); + for (Iterator it = root.elements(); it.hasNext(); ) { + JsonNode node = it.next(); + int found = 0; + for (Iterator iter = node.fieldNames(); iter.hasNext(); ) { + String fieldName = iter.next(); + if (fieldName.equals(key)) { + if (node.get(fieldName).asText().equals(value) || node.get(fieldName).asText().startsWith(value)) { + nodes.add(node); + found++; + } + } + + } + if (found == 0) { + nodes.addAll(findNodes(node, key, value)); + } + } + return nodes; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java index 8fbedc873..5b33f115d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java @@ -64,6 +64,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(optionElement.getAttribute("label")); this.autoCompleteOptions.setValue(optionElement.getAttribute("value")); this.autoCompleteOptions.setSource(optionElement.getAttribute("source")); + this.autoCompleteOptions.setUri(optionElement.getAttribute("uri")); } return this; } @@ -81,6 +82,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(options.get("label")); this.autoCompleteOptions.setValue(options.get("value")); this.autoCompleteOptions.setSource(options.get("source")); + this.autoCompleteOptions.setUri(options.get("uri")); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java index db67ea301..59bc6ea79 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java @@ -12,6 +12,7 @@ public abstract class ComboBoxData extends FieldData { private String label; private String value; private String source; + private String uri; public String getLabel() { return label; @@ -34,12 +35,21 @@ public abstract class ComboBoxData extends FieldData { this.source = source; } + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + @Override public Element toXml(Document doc) { Element option = doc.createElement("option"); option.setAttribute("label", this.label); option.setAttribute("value", this.value); option.setAttribute("source", this.source); + option.setAttribute("uri", this.uri); return option; } @@ -48,6 +58,7 @@ public abstract class ComboBoxData extends FieldData { this.label = item.getAttribute("label"); this.value = item.getAttribute("value"); this.source = item.getAttribute("source"); + this.uri = item.getAttribute("uri"); return this; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java index d57605a72..039c63acd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java @@ -4,11 +4,13 @@ public class ExternalAutocompleteFieldModel { private String id; private String label; private String source; + private String uri; - public ExternalAutocompleteFieldModel(String id, String label, String source) { + public ExternalAutocompleteFieldModel(String id, String label, String source, String uri) { this.id = id; this.label = label; this.source = source; + this.uri = uri; } public String getId() { @@ -31,4 +33,12 @@ public class ExternalAutocompleteFieldModel { public void setSource(String source) { this.source = source; } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index c9f509020..ccd79971f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -321,7 +321,8 @@ public class DatasetRDAExportModel { JSONObject jsonObject = jsonArray.getJSONObject(i); Map jsonObjectMap = jsonObject.toMap(); DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel(); - metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); +// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); + metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url")); metadataRDAExportModelList.add(metadataRda1); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java new file mode 100644 index 000000000..606a3ae2c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java @@ -0,0 +1,146 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Contact Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact_id", + "mbox", + "name" +}) +public class Contact implements Serializable +{ + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + private ContactId contactId; + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contact Person's E-mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contact person") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -2062619884605400321L; + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public ContactId getContactId() { + return contactId; + } + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public void setContactId(ContactId contactId) { + this.contactId = contactId; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java new file mode 100644 index 000000000..60454ea6c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contact ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContactId implements Serializable +{ + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + private String identifier; + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContactId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7066973565810615822L; + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContactId.Type getType() { + return type; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContactId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContactId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContactId.Type fromValue(String value) { + ContactId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java new file mode 100644 index 000000000..21dfe68c8 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java @@ -0,0 +1,181 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + + +/** + * The Contributor Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contributor_id", + "mbox", + "name", + "role" +}) +public class Contributor implements Serializable +{ + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + private ContributorId contributorId; + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contributor Mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contributor") + private String name; + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + @JsonDeserialize(as = java.util.LinkedHashSet.class) + @JsonPropertyDescription("Type of contributor") + private Set role = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3452606902359513114L; + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public ContributorId getContributorId() { + return contributorId; + } + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public void setContributorId(ContributorId contributorId) { + this.contributorId = contributorId; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public Set getRole() { + return role; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public void setRole(Set role) { + this.role = role; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java new file mode 100644 index 000000000..4045f5e0e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java @@ -0,0 +1,155 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contributor_id Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContributorId implements Serializable +{ + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a contact person") + private String identifier; + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContributorId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3089650417960767482L; + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContributorId.Type getType() { + return type; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContributorId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContributorId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContributorId.Type fromValue(String value) { + ContributorId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java new file mode 100644 index 000000000..db32ff641 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java @@ -0,0 +1,374 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Cost Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "currency_code", + "description", + "title", + "value" +}) +public class Cost implements Serializable +{ + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + @JsonPropertyDescription("Allowed values defined by ISO 4217") + private Cost.CurrencyCode currencyCode; + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Cost(s) Description") + private String description; + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Value") + private Double value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -322637784848035165L; + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public Cost.CurrencyCode getCurrencyCode() { + return currencyCode; + } + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public void setCurrencyCode(Cost.CurrencyCode currencyCode) { + this.currencyCode = currencyCode; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public Double getValue() { + return value; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public void setValue(Double value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CurrencyCode { + + AED("AED"), + AFN("AFN"), + ALL("ALL"), + AMD("AMD"), + ANG("ANG"), + AOA("AOA"), + ARS("ARS"), + AUD("AUD"), + AWG("AWG"), + AZN("AZN"), + BAM("BAM"), + BBD("BBD"), + BDT("BDT"), + BGN("BGN"), + BHD("BHD"), + BIF("BIF"), + BMD("BMD"), + BND("BND"), + BOB("BOB"), + BRL("BRL"), + BSD("BSD"), + BTN("BTN"), + BWP("BWP"), + BYN("BYN"), + BZD("BZD"), + CAD("CAD"), + CDF("CDF"), + CHF("CHF"), + CLP("CLP"), + CNY("CNY"), + COP("COP"), + CRC("CRC"), + CUC("CUC"), + CUP("CUP"), + CVE("CVE"), + CZK("CZK"), + DJF("DJF"), + DKK("DKK"), + DOP("DOP"), + DZD("DZD"), + EGP("EGP"), + ERN("ERN"), + ETB("ETB"), + EUR("EUR"), + FJD("FJD"), + FKP("FKP"), + GBP("GBP"), + GEL("GEL"), + GGP("GGP"), + GHS("GHS"), + GIP("GIP"), + GMD("GMD"), + GNF("GNF"), + GTQ("GTQ"), + GYD("GYD"), + HKD("HKD"), + HNL("HNL"), + HRK("HRK"), + HTG("HTG"), + HUF("HUF"), + IDR("IDR"), + ILS("ILS"), + IMP("IMP"), + INR("INR"), + IQD("IQD"), + IRR("IRR"), + ISK("ISK"), + JEP("JEP"), + JMD("JMD"), + JOD("JOD"), + JPY("JPY"), + KES("KES"), + KGS("KGS"), + KHR("KHR"), + KMF("KMF"), + KPW("KPW"), + KRW("KRW"), + KWD("KWD"), + KYD("KYD"), + KZT("KZT"), + LAK("LAK"), + LBP("LBP"), + LKR("LKR"), + LRD("LRD"), + LSL("LSL"), + LYD("LYD"), + MAD("MAD"), + MDL("MDL"), + MGA("MGA"), + MKD("MKD"), + MMK("MMK"), + MNT("MNT"), + MOP("MOP"), + MRU("MRU"), + MUR("MUR"), + MVR("MVR"), + MWK("MWK"), + MXN("MXN"), + MYR("MYR"), + MZN("MZN"), + NAD("NAD"), + NGN("NGN"), + NIO("NIO"), + NOK("NOK"), + NPR("NPR"), + NZD("NZD"), + OMR("OMR"), + PAB("PAB"), + PEN("PEN"), + PGK("PGK"), + PHP("PHP"), + PKR("PKR"), + PLN("PLN"), + PYG("PYG"), + QAR("QAR"), + RON("RON"), + RSD("RSD"), + RUB("RUB"), + RWF("RWF"), + SAR("SAR"), + SBD("SBD"), + SCR("SCR"), + SDG("SDG"), + SEK("SEK"), + SGD("SGD"), + SHP("SHP"), + SLL("SLL"), + SOS("SOS"), + SPL("SPL*"), + SRD("SRD"), + STN("STN"), + SVC("SVC"), + SYP("SYP"), + SZL("SZL"), + THB("THB"), + TJS("TJS"), + TMT("TMT"), + TND("TND"), + TOP("TOP"), + TRY("TRY"), + TTD("TTD"), + TVD("TVD"), + TWD("TWD"), + TZS("TZS"), + UAH("UAH"), + UGX("UGX"), + USD("USD"), + UYU("UYU"), + UZS("UZS"), + VEF("VEF"), + VND("VND"), + VUV("VUV"), + WST("WST"), + XAF("XAF"), + XCD("XCD"), + XDR("XDR"), + XOF("XOF"), + XPF("XPF"), + YER("YER"), + ZAR("ZAR"), + ZMW("ZMW"), + ZWD("ZWD"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Cost.CurrencyCode c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CurrencyCode(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Cost.CurrencyCode fromValue(String value) { + Cost.CurrencyCode constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java new file mode 100644 index 000000000..43a7ac0cd --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -0,0 +1,839 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "data_quality_assurance", + "dataset_id", + "description", + "distribution", + "issued", + "keyword", + "language", + "metadata", + "personal_data", + "preservation_statement", + "security_and_privacy", + "sensitive_data", + "technical_resource", + "title", + "type" +}) +public class Dataset implements Serializable +{ + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + @JsonPropertyDescription("Data Quality Assurance") + private List dataQualityAssurance = null; + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + @JsonPropertyDescription("Dataset ID") + private DatasetId datasetId; + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + @JsonPropertyDescription("To provide technical information on a specific instance of data.") + private List distribution = null; + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + @JsonPropertyDescription("Date of Issue") + private String issued; + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + @JsonPropertyDescription("Keywords") + private List keyword = null; + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the dataset expressed using ISO 639-3.") + private Dataset.Language language; + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + @JsonPropertyDescription("To describe metadata standards used.") + private List metadata = null; + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + @JsonPropertyDescription("If any personal data is contained. Allowed values: yes, no, unknown") + private Dataset.PersonalData personalData; + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + @JsonPropertyDescription("Preservation Statement") + private String preservationStatement; + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + @JsonPropertyDescription("To list all issues and requirements related to security and privacy") + private List securityAndPrivacy = null; + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + @JsonPropertyDescription("If any sensitive data is contained. Allowed values: yes, no, unknown") + private Dataset.SensitiveData sensitiveData; + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + @JsonPropertyDescription("To list all technical resources needed to implement a DMP") + private List technicalResource = null; + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") + private String type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6931119120629009399L; + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public List getDataQualityAssurance() { + return dataQualityAssurance; + } + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public void setDataQualityAssurance(List dataQualityAssurance) { + this.dataQualityAssurance = dataQualityAssurance; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public DatasetId getDatasetId() { + return datasetId; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public void setDatasetId(DatasetId datasetId) { + this.datasetId = datasetId; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public List getDistribution() { + return distribution; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public void setDistribution(List distribution) { + this.distribution = distribution; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public String getIssued() { + return issued; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public void setIssued(String issued) { + this.issued = issued; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public List getKeyword() { + return keyword; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public void setKeyword(List keyword) { + this.keyword = keyword; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public Dataset.Language getLanguage() { + return language; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public void setLanguage(Dataset.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public List getMetadata() { + return metadata; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public void setMetadata(List metadata) { + this.metadata = metadata; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public Dataset.PersonalData getPersonalData() { + return personalData; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public void setPersonalData(Dataset.PersonalData personalData) { + this.personalData = personalData; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public String getPreservationStatement() { + return preservationStatement; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public void setPreservationStatement(String preservationStatement) { + this.preservationStatement = preservationStatement; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public List getSecurityAndPrivacy() { + return securityAndPrivacy; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public void setSecurityAndPrivacy(List securityAndPrivacy) { + this.securityAndPrivacy = securityAndPrivacy; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public Dataset.SensitiveData getSensitiveData() { + return sensitiveData; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public void setSensitiveData(Dataset.SensitiveData sensitiveData) { + this.sensitiveData = sensitiveData; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public List getTechnicalResource() { + return technicalResource; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public void setTechnicalResource(List technicalResource) { + this.technicalResource = technicalResource; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.Language fromValue(String value) { + Dataset.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum PersonalData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.PersonalData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PersonalData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.PersonalData fromValue(String value) { + Dataset.PersonalData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SensitiveData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.SensitiveData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SensitiveData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.SensitiveData fromValue(String value) { + Dataset.SensitiveData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java new file mode 100644 index 000000000..c1cc1e57a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset ID Schema + *

+ * Dataset ID + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DatasetId implements Serializable +{ + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a dataset") + private String identifier; + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Dataset identifier type. Allowed values: handle, doi, ark, url, other") + private DatasetId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6295164005851378031L; + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DatasetId.Type getType() { + return type; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DatasetId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DatasetId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DatasetId.Type fromValue(String value) { + DatasetId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java new file mode 100644 index 000000000..d005e7564 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -0,0 +1,412 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "access_url", + "available_until", + "byte_size", + "data_access", + "description", + "download_url", + "format", + "host", + "license", + "title" +}) +public class Distribution implements Serializable +{ + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + @JsonPropertyDescription("A URL of the resource that gives access to a distribution of the dataset. e.g. landing page.") + private String accessUrl; + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + @JsonPropertyDescription("Indicates how long this distribution will be / should be available.") + private String availableUntil; + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + @JsonPropertyDescription("Size in bytes.") + private Integer byteSize; + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + @JsonPropertyDescription("Indicates access mode for data. Allowed values: open, shared, closed") + private Distribution.DataAccess dataAccess; + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + @JsonPropertyDescription("The URL of the downloadable file in a given format. E.g. CSV file or RDF file.") + private URI downloadUrl; + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + @JsonPropertyDescription("Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format.") + private List format = null; + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + @JsonPropertyDescription("To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored.") + private Host host; + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + @JsonPropertyDescription("To list all licenses applied to a specific distribution of data.") + private List license = null; + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6018365280419917902L; + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public String getAccessUrl() { + return accessUrl; + } + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public void setAccessUrl(String accessUrl) { + this.accessUrl = accessUrl; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public String getAvailableUntil() { + return availableUntil; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public void setAvailableUntil(String availableUntil) { + this.availableUntil = availableUntil; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public Integer getByteSize() { + return byteSize; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public void setByteSize(Integer byteSize) { + this.byteSize = byteSize; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public Distribution.DataAccess getDataAccess() { + return dataAccess; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public void setDataAccess(Distribution.DataAccess dataAccess) { + this.dataAccess = dataAccess; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public URI getDownloadUrl() { + return downloadUrl; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public void setDownloadUrl(URI downloadUrl) { + this.downloadUrl = downloadUrl; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public List getFormat() { + return format; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public void setFormat(List format) { + this.format = format; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public Host getHost() { + return host; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public void setHost(Host host) { + this.host = host; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public List getLicense() { + return license; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public void setLicense(List license) { + this.license = license; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum DataAccess { + + OPEN("open"), + SHARED("shared"), + CLOSED("closed"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Distribution.DataAccess c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private DataAccess(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Distribution.DataAccess fromValue(String value) { + Distribution.DataAccess constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java new file mode 100644 index 000000000..7cac25d62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -0,0 +1,774 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact", + "contributor", + "cost", + "created", + "dataset", + "description", + "dmp_id", + "ethical_issues_description", + "ethical_issues_exist", + "ethical_issues_report", + "language", + "modified", + "project", + "title" +}) +public class Dmp implements Serializable +{ + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + private Contact contact; + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + private List contributor = null; + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + private List cost = null; + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + @JsonPropertyDescription("") + private Date created; + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + private List dataset = null; + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + @JsonPropertyDescription("To provide any free-form text information on a DMP") + private String description; + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + @JsonPropertyDescription("Identifier for the DMP itself") + private DmpId dmpId; + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + @JsonPropertyDescription("To describe ethical issues directly in a DMP") + private String ethicalIssuesDescription; + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + @JsonPropertyDescription("To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown") + private Dmp.EthicalIssuesExist ethicalIssuesExist; + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + @JsonPropertyDescription("To indicate where a protocol from a meeting with an ethical commitee can be found") + private URI ethicalIssuesReport; + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the DMP expressed using ISO 639-3.") + private Dmp.Language language; + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + @JsonPropertyDescription("Must be set each time DMP is modified. Indicates DMP version.") + private Date modified; + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + @JsonPropertyDescription("Project related to a DMP") + private List project = null; + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title of a DMP") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4599713332472772292L; + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public Contact getContact() { + return contact; + } + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public void setContact(Contact contact) { + this.contact = contact; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public List getContributor() { + return contributor; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public void setContributor(List contributor) { + this.contributor = contributor; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public List getCost() { + return cost; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public void setCost(List cost) { + this.cost = cost; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public Date getCreated() { + return created; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public void setCreated(Date created) { + this.created = created; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public List getDataset() { + return dataset; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public void setDataset(List dataset) { + this.dataset = dataset; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public DmpId getDmpId() { + return dmpId; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public void setDmpId(DmpId dmpId) { + this.dmpId = dmpId; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public String getEthicalIssuesDescription() { + return ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public void setEthicalIssuesDescription(String ethicalIssuesDescription) { + this.ethicalIssuesDescription = ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public Dmp.EthicalIssuesExist getEthicalIssuesExist() { + return ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public void setEthicalIssuesExist(Dmp.EthicalIssuesExist ethicalIssuesExist) { + this.ethicalIssuesExist = ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public URI getEthicalIssuesReport() { + return ethicalIssuesReport; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public void setEthicalIssuesReport(URI ethicalIssuesReport) { + this.ethicalIssuesReport = ethicalIssuesReport; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Dmp.Language getLanguage() { + return language; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Dmp.Language language) { + this.language = language; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public Date getModified() { + return modified; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public void setModified(Date modified) { + this.modified = modified; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public List getProject() { + return project; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public void setProject(List project) { + this.project = project; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum EthicalIssuesExist { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.EthicalIssuesExist c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private EthicalIssuesExist(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.EthicalIssuesExist fromValue(String value) { + Dmp.EthicalIssuesExist constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.Language fromValue(String value) { + Dmp.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java new file mode 100644 index 000000000..7240efaa4 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DmpId implements Serializable +{ + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a DMP") + private String identifier; + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("The DMP Identifier Type. Allowed values: handle, doi, ark, url, other") + private DmpId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6059908070202476841L; + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DmpId.Type getType() { + return type; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DmpId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DmpId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DmpId.Type fromValue(String value) { + DmpId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java new file mode 100644 index 000000000..12b8bb8f7 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class FunderId implements Serializable +{ + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/") + private String identifier; + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: fundref, url, other") + private FunderId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1783349151334366078L; + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public FunderId.Type getType() { + return type; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(FunderId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + FUNDREF("fundref"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (FunderId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static FunderId.Type fromValue(String value) { + FunderId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java new file mode 100644 index 000000000..0cc378e7c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java @@ -0,0 +1,187 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Project Funding Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "funder_id", + "funding_status", + "grant_id" +}) +public class Funding implements Serializable +{ + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + @JsonPropertyDescription("Funder ID of the associated project") + private FunderId funderId; + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + @JsonPropertyDescription("To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected") + private Funding.FundingStatus fundingStatus; + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + @JsonPropertyDescription("Grant ID of the associated project") + private GrantId grantId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8962229321225336165L; + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public FunderId getFunderId() { + return funderId; + } + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public void setFunderId(FunderId funderId) { + this.funderId = funderId; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public Funding.FundingStatus getFundingStatus() { + return fundingStatus; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public void setFundingStatus(Funding.FundingStatus fundingStatus) { + this.fundingStatus = fundingStatus; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public GrantId getGrantId() { + return grantId; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public void setGrantId(GrantId grantId) { + this.grantId = grantId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum FundingStatus { + + PLANNED("planned"), + APPLIED("applied"), + GRANTED("granted"), + REJECTED("rejected"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Funding.FundingStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private FundingStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Funding.FundingStatus fromValue(String value) { + Funding.FundingStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java new file mode 100644 index 000000000..cb994a0ba --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class GrantId implements Serializable +{ + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Grant ID") + private String identifier; + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private GrantId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7738072672837592065L; + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public GrantId.Type getType() { + return type; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(GrantId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (GrantId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static GrantId.Type fromValue(String value) { + GrantId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java new file mode 100644 index 000000000..bfa6ec615 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java @@ -0,0 +1,775 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "availability", + "backup_frequency", + "backup_type", + "certified_with", + "description", + "geo_location", + "pid_system", + "storage_type", + "support_versioning", + "title", + "url" +}) +public class Host implements Serializable +{ + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + @JsonPropertyDescription("Availability") + private String availability; + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + @JsonPropertyDescription("Backup Frequency") + private String backupFrequency; + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + @JsonPropertyDescription("Backup Type") + private String backupType; + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + @JsonPropertyDescription("Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal") + private Host.CertifiedWith certifiedWith; + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + @JsonPropertyDescription("Physical location of the data expressed using ISO 3166-1 country code.") + private Host.GeoLocation geoLocation; + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + @JsonPropertyDescription("PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other") + private List pidSystem = null; + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + @JsonPropertyDescription("The type of storage required") + private String storageType; + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + @JsonPropertyDescription("If host supports versioning. Allowed values: yes, no, unknown") + private Host.SupportVersioning supportVersioning; + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + @JsonPropertyDescription("The URL of the system hosting a distribution of a dataset") + private URI url; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8564338806797654115L; + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public String getAvailability() { + return availability; + } + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public String getBackupFrequency() { + return backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public void setBackupFrequency(String backupFrequency) { + this.backupFrequency = backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public String getBackupType() { + return backupType; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public void setBackupType(String backupType) { + this.backupType = backupType; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public Host.CertifiedWith getCertifiedWith() { + return certifiedWith; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public void setCertifiedWith(Host.CertifiedWith certifiedWith) { + this.certifiedWith = certifiedWith; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public Host.GeoLocation getGeoLocation() { + return geoLocation; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public void setGeoLocation(Host.GeoLocation geoLocation) { + this.geoLocation = geoLocation; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public List getPidSystem() { + return pidSystem; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public void setPidSystem(List pidSystem) { + this.pidSystem = pidSystem; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public String getStorageType() { + return storageType; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public Host.SupportVersioning getSupportVersioning() { + return supportVersioning; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public void setSupportVersioning(Host.SupportVersioning supportVersioning) { + this.supportVersioning = supportVersioning; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public URI getUrl() { + return url; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public void setUrl(URI url) { + this.url = url; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CertifiedWith { + + DIN_31644("din31644"), + DINI_ZERTIFIKAT("dini-zertifikat"), + DSA("dsa"), + ISO_16363("iso16363"), + ISO_16919("iso16919"), + TRAC("trac"), + WDS("wds"), + CORETRUSTSEAL("coretrustseal"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.CertifiedWith c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CertifiedWith(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.CertifiedWith fromValue(String value) { + Host.CertifiedWith constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum GeoLocation { + + AD("AD"), + AE("AE"), + AF("AF"), + AG("AG"), + AI("AI"), + AL("AL"), + AM("AM"), + AO("AO"), + AQ("AQ"), + AR("AR"), + AS("AS"), + AT("AT"), + AU("AU"), + AW("AW"), + AX("AX"), + AZ("AZ"), + BA("BA"), + BB("BB"), + BD("BD"), + BE("BE"), + BF("BF"), + BG("BG"), + BH("BH"), + BI("BI"), + BJ("BJ"), + BL("BL"), + BM("BM"), + BN("BN"), + BO("BO"), + BQ("BQ"), + BR("BR"), + BS("BS"), + BT("BT"), + BV("BV"), + BW("BW"), + BY("BY"), + BZ("BZ"), + CA("CA"), + CC("CC"), + CD("CD"), + CF("CF"), + CG("CG"), + CH("CH"), + CI("CI"), + CK("CK"), + CL("CL"), + CM("CM"), + CN("CN"), + CO("CO"), + CR("CR"), + CU("CU"), + CV("CV"), + CW("CW"), + CX("CX"), + CY("CY"), + CZ("CZ"), + DE("DE"), + DJ("DJ"), + DK("DK"), + DM("DM"), + DO("DO"), + DZ("DZ"), + EC("EC"), + EE("EE"), + EG("EG"), + EH("EH"), + ER("ER"), + ES("ES"), + ET("ET"), + FI("FI"), + FJ("FJ"), + FK("FK"), + FM("FM"), + FO("FO"), + FR("FR"), + GA("GA"), + GB("GB"), + GD("GD"), + GE("GE"), + GF("GF"), + GG("GG"), + GH("GH"), + GI("GI"), + GL("GL"), + GM("GM"), + GN("GN"), + GP("GP"), + GQ("GQ"), + GR("GR"), + GS("GS"), + GT("GT"), + GU("GU"), + GW("GW"), + GY("GY"), + HK("HK"), + HM("HM"), + HN("HN"), + HR("HR"), + HT("HT"), + HU("HU"), + ID("ID"), + IE("IE"), + IL("IL"), + IM("IM"), + IN("IN"), + IO("IO"), + IQ("IQ"), + IR("IR"), + IS("IS"), + IT("IT"), + JE("JE"), + JM("JM"), + JO("JO"), + JP("JP"), + KE("KE"), + KG("KG"), + KH("KH"), + KI("KI"), + KM("KM"), + KN("KN"), + KP("KP"), + KR("KR"), + KW("KW"), + KY("KY"), + KZ("KZ"), + LA("LA"), + LB("LB"), + LC("LC"), + LI("LI"), + LK("LK"), + LR("LR"), + LS("LS"), + LT("LT"), + LU("LU"), + LV("LV"), + LY("LY"), + MA("MA"), + MC("MC"), + MD("MD"), + ME("ME"), + MF("MF"), + MG("MG"), + MH("MH"), + MK("MK"), + ML("ML"), + MM("MM"), + MN("MN"), + MO("MO"), + MP("MP"), + MQ("MQ"), + MR("MR"), + MS("MS"), + MT("MT"), + MU("MU"), + MV("MV"), + MW("MW"), + MX("MX"), + MY("MY"), + MZ("MZ"), + NA("NA"), + NC("NC"), + NE("NE"), + NF("NF"), + NG("NG"), + NI("NI"), + NL("NL"), + NO("NO"), + NP("NP"), + NR("NR"), + NU("NU"), + NZ("NZ"), + OM("OM"), + PA("PA"), + PE("PE"), + PF("PF"), + PG("PG"), + PH("PH"), + PK("PK"), + PL("PL"), + PM("PM"), + PN("PN"), + PR("PR"), + PS("PS"), + PT("PT"), + PW("PW"), + PY("PY"), + QA("QA"), + RE("RE"), + RO("RO"), + RS("RS"), + RU("RU"), + RW("RW"), + SA("SA"), + SB("SB"), + SC("SC"), + SD("SD"), + SE("SE"), + SG("SG"), + SH("SH"), + SI("SI"), + SJ("SJ"), + SK("SK"), + SL("SL"), + SM("SM"), + SN("SN"), + SO("SO"), + SR("SR"), + SS("SS"), + ST("ST"), + SV("SV"), + SX("SX"), + SY("SY"), + SZ("SZ"), + TC("TC"), + TD("TD"), + TF("TF"), + TG("TG"), + TH("TH"), + TJ("TJ"), + TK("TK"), + TL("TL"), + TM("TM"), + TN("TN"), + TO("TO"), + TR("TR"), + TT("TT"), + TV("TV"), + TW("TW"), + TZ("TZ"), + UA("UA"), + UG("UG"), + UM("UM"), + US("US"), + UY("UY"), + UZ("UZ"), + VA("VA"), + VC("VC"), + VE("VE"), + VG("VG"), + VI("VI"), + VN("VN"), + VU("VU"), + WF("WF"), + WS("WS"), + YE("YE"), + YT("YT"), + ZA("ZA"), + ZM("ZM"), + ZW("ZW"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.GeoLocation c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private GeoLocation(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.GeoLocation fromValue(String value) { + Host.GeoLocation constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SupportVersioning { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.SupportVersioning c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SupportVersioning(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.SupportVersioning fromValue(String value) { + Host.SupportVersioning constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java new file mode 100644 index 000000000..1527f5503 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java @@ -0,0 +1,113 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Distribution License Items + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "license_ref", + "start_date" +}) +public class License implements Serializable +{ + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + @JsonPropertyDescription("Link to license document.") + private URI licenseRef; + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + @JsonPropertyDescription("Starting date of license. If date is set in the future, it indicates embargo period.") + private String startDate; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4148207295817559010L; + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public URI getLicenseRef() { + return licenseRef; + } + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public void setLicenseRef(URI licenseRef) { + this.licenseRef = licenseRef; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public String getStartDate() { + return startDate; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java new file mode 100644 index 000000000..06b54a1f1 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Standard ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class MetadataStandardId implements Serializable +{ + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for the metadata standard used.") + private String identifier; + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private MetadataStandardId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7641042701935397947L; + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public MetadataStandardId.Type getType() { + return type; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(MetadataStandardId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (MetadataStandardId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static MetadataStandardId.Type fromValue(String value) { + MetadataStandardId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java new file mode 100644 index 000000000..d6057ca62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -0,0 +1,368 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "language", + "metadata_standard_id" +}) +public class Metadatum implements Serializable +{ + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the metadata expressed using ISO 639-3.") + private Metadatum.Language language; + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + private MetadataStandardId metadataStandardId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 6511312853153406190L; + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Metadatum.Language getLanguage() { + return language; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Metadatum.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public MetadataStandardId getMetadataStandardId() { + return metadataStandardId; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public void setMetadataStandardId(MetadataStandardId metadataStandardId) { + this.metadataStandardId = metadataStandardId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Metadatum.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Metadatum.Language fromValue(String value) { + Metadatum.Language constant = CONSTANTS.get(value); + if (constant == null) { + return null; +// throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java new file mode 100644 index 000000000..0e29d1153 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java @@ -0,0 +1,63 @@ + +package eu.eudat.models.rda; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PidSystem { + + ARK("ark"), + ARXIV("arxiv"), + BIBCODE("bibcode"), + DOI("doi"), + EAN_13("ean13"), + EISSN("eissn"), + HANDLE("handle"), + IGSN("igsn"), + ISBN("isbn"), + ISSN("issn"), + ISTC("istc"), + LISSN("lissn"), + LSID("lsid"), + PMID("pmid"), + PURL("purl"), + UPC("upc"), + URL("url"), + URN("urn"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (PidSystem c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PidSystem(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static PidSystem fromValue(String value) { + PidSystem constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java new file mode 100644 index 000000000..09c231ca3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java @@ -0,0 +1,212 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Project Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "end", + "funding", + "start", + "title" +}) +public class Project implements Serializable +{ + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Project description") + private String description; + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + @JsonPropertyDescription("Project end date") + private String end; + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + @JsonPropertyDescription("Funding related with a project") + private List funding = null; + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + @JsonPropertyDescription("Project start date") + private String start; + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Project title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1437619307195890472L; + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public String getEnd() { + return end; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public void setEnd(String end) { + this.end = end; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public List getFunding() { + return funding; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public void setFunding(List funding) { + this.funding = funding; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public String getStart() { + return start; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public void setStart(String start) { + this.start = start; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java new file mode 100644 index 000000000..61df61b32 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java @@ -0,0 +1,58 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * RDA DMP Common Standard Schema + *

+ * JSON Schema for the RDA DMP Common Standard + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "dmp" +}) +public class RDAModel implements Serializable +{ + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + private Dmp dmp; + private final static long serialVersionUID = 7331666133368350998L; + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public Dmp getDmp() { + return dmp; + } + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public void setDmp(Dmp dmp) { + this.dmp = dmp; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java new file mode 100644 index 000000000..0486df588 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Security & Policy Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "title" +}) +public class SecurityAndPrivacy implements Serializable +{ + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 7863747935827682977L; + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java new file mode 100644 index 000000000..eac85da72 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Technical Resource Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "name" +}) +public class TechnicalResource implements Serializable +{ + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description of the technical resource") + private String description; + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the technical resource") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7451757227129483110L; + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java new file mode 100644 index 000000000..48549d75a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -0,0 +1,15 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.ContactId; + +import java.util.UUID; + +public class ContactIdRDAMapper { + + public static ContactId toRDA(UUID id) { + ContactId rda = new ContactId(); + rda.setIdentifier(id.toString()); + rda.setType(ContactId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java new file mode 100644 index 000000000..69ea2310e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Contact; +import eu.eudat.models.rda.ContactId; + +public class ContactRDAMapper { + + public static Contact toRDA(UserInfo creator) { + Contact rda = new Contact(); + rda.setName(creator.getName()); + rda.setMbox(creator.getEmail()); + rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java new file mode 100644 index 000000000..107dfb996 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.Contributor; +import eu.eudat.models.rda.ContributorId; + +import java.util.UUID; + +public class ContributorIdRDAMapper { + + public static ContributorId toRDA(UUID id) { + ContributorId rda = new ContributorId(); + rda.setIdentifier(id.toString()); + rda.setType(ContributorId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java new file mode 100644 index 000000000..681d98940 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java @@ -0,0 +1,20 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserDMP; +import eu.eudat.models.rda.Contributor; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; + +public class ContributorRDAMapper { + + public static Contributor toRDA(UserDMP userDMP) { + Contributor rda = new Contributor(); + rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId())); + rda.setName(userDMP.getUser().getName()); + rda.setMbox(userDMP.getUser().getEmail()); + rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name()))); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java new file mode 100644 index 000000000..ab791e215 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java @@ -0,0 +1,17 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.DatasetId; + +import java.util.UUID; + +public class DatasetIdRDAMapper { + + public static DatasetId toRDA(UUID id) { + DatasetId rda = new DatasetId(); + rda.setIdentifier(id.toString()); + rda.setType(DatasetId.Type.OTHER); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java new file mode 100644 index 000000000..103ba72c6 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -0,0 +1,100 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.utilities.json.JsonSearcher; +import eu.eudat.models.data.datasetwizard.DatasetWizardModel; +import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; +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.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class DatasetRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); + + private DatasetManager datasetManager; + + @Autowired + public DatasetRDAMapper(DatasetManager datasetManager) { + this.datasetManager = datasetManager; + } + + @Transactional + public Dataset toRDA(eu.eudat.data.entities.Dataset dataset) { + Dataset rda = new Dataset(); + rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); + rda.setTitle(dataset.getLabel()); + rda.setDescription(dataset.getDescription()); + try { + + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); + ObjectMapper mapper = new ObjectMapper(); + JsonNode properties = mapper.readTree(dataset.getProperties()); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + } + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + } + List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); + if (!metadataNodes.isEmpty()) { + rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + } + List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); + if (!qaNodes.isEmpty()) { + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); + if (!distributionNodes.isEmpty()) { + rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + } + List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); + if (!keywordNodes.isEmpty()) { + rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + } + List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); + if (!securityAndPrivacyNodes.isEmpty()) { + rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + } + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + } + List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); + if (!technicalResourceNodes.isEmpty()) { + rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + } + + + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java new file mode 100644 index 000000000..513affd98 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -0,0 +1,39 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Distribution; + +import java.net.URI; +import java.util.Collections; + +public class DistributionRDAMapper { + + public static Distribution toRDA(JsonNode structure, JsonNode properties) { + Distribution rda = new Distribution(); + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("access_url")) { + rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("available_util")) { + rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("byte_size")) { + rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + } else if (rdaProperty.contains("data_access")) { + rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("download_url")) { + rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("format")) { + rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("host")) { + rda.setHost(HostRDAMapper.toRDA(structure, properties)); + } else if (rdaProperty.contains("license")) { + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java new file mode 100644 index 000000000..095c26e11 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.DmpId; + +import java.util.UUID; + +public class DmpIdRDAMapper { + + public static DmpId toRDA(Object id) { + DmpId rda = new DmpId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(DmpId.Type.OTHER); + } else { + rda.setType(DmpId.Type.DOI); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java new file mode 100644 index 000000000..620229a27 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -0,0 +1,51 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.UserDMP; +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Dmp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Collections; +import java.util.stream.Collectors; + +@Component +public class DmpRDAMapper { + + private DatasetRDAMapper datasetRDAMapper; + + @Autowired + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + this.datasetRDAMapper = datasetRDAMapper; + } + + @Transactional + public Dmp toRDA(DMP dmp) { + Dmp rda = new Dmp(); + if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getDoi())); + } else { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId())); + } + rda.setCreated(dmp.getCreated()); + rda.setDescription(dmp.getDescription()); + rda.setModified(dmp.getModified()); + rda.setTitle(dmp.getLabel()); + + UserInfo creator; + if (dmp.getCreator() != null) { + creator = dmp.getCreator(); + } else { + creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo()); + } + rda.setContact(ContactRDAMapper.toRDA(creator)); + rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); + rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); + rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java new file mode 100644 index 000000000..f0dc5ff4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.FunderId; + +import java.util.UUID; + +public class FunderIdRDAMapper { + + public static FunderId toRDA(Object id) { + FunderId rda = new FunderId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(FunderId.Type.OTHER); + } else { + rda.setType(FunderId.Type.FUNDREF); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java new file mode 100644 index 000000000..e0b8fbe65 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Funding; + +public class FundingRDAMapper { + + public static Funding toRDA(Grant grant) { + Funding rda = new Funding(); + String referencePrefix; + String shortReference; + if (grant.getFunder().getReference() != null) { + referencePrefix = grant.getFunder().getReference().split(":")[0]; + shortReference = grant.getFunder().getReference().substring(referencePrefix.length() + 1); + rda.setFunderId(FunderIdRDAMapper.toRDA(shortReference)); + } else { + rda.setFunderId(FunderIdRDAMapper.toRDA(grant.getFunder().getId())); + } + referencePrefix = grant.getReference().split(":")[0]; + shortReference = grant.getReference().substring(referencePrefix.length() + 1); + rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java new file mode 100644 index 000000000..d05ec5d02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.GrantId; + +public class GrantIdRDAMapper { + + public static GrantId toRDA(String id) { + GrantId rda = new GrantId(); + rda.setIdentifier(id); + rda.setType(GrantId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java new file mode 100644 index 000000000..9a32cc697 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -0,0 +1,41 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Host; +import eu.eudat.models.rda.PidSystem; + +import java.net.URI; +import java.util.Collections; + +public class HostRDAMapper { + + public static Host toRDA(JsonNode structure, JsonNode properties) { + Host rda = new Host(); + String rdaProperty = structure.get("rdaProperties").asText(); + if (rdaProperty.contains("availability")) { + rda.setAvailability(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_frequency")) { + rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_type")) { + rda.setBackupType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("certified_with")) { + rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("geo_location")) { + rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("pid_system")) { + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); + } else if (rdaProperty.contains("storage_type")) { + rda.setStorageType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("support_versioning")) { + rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("url")) { + rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java new file mode 100644 index 000000000..68817bd3d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -0,0 +1,23 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.License; + +import java.net.URI; + +public class LicenseRDAMapper { + + public static License toRDA(JsonNode structure, JsonNode properties) { + License rda = new License(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("license_ref")) { + rda.setLicenseRef(URI.create(value)); + } else if (rdaProperty.contains("start_date")) { + rda.setStartDate(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java new file mode 100644 index 000000000..fa638d3e3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -0,0 +1,44 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.Metadatum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Iterator; + +public class MetadataRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); + + public static Metadatum toRDA(JsonNode structure, JsonNode properties) { + Metadatum rda = new Metadatum(); + JsonNode dataNode = null; + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("metadata_standard_id")) { + try { + String jsonText = properties.get(structure.get("id").asText()).asText(); + if (jsonText != null && !jsonText.isEmpty()) { + dataNode = new ObjectMapper().readTree(jsonText); + for (Iterator it = dataNode.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + } + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("language")) { + String language = properties.get(structure.get("id").asText()).asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + rda.setLanguage(lang); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java new file mode 100644 index 000000000..586446e02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.MetadataStandardId; + +public class MetadataStandardIdRDAMapper { + + public static MetadataStandardId toRDA(String uri) { + MetadataStandardId rda = new MetadataStandardId(); + rda.setIdentifier(uri); + rda.setType(MetadataStandardId.Type.URL); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java new file mode 100644 index 000000000..d97eace4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Project; + +import java.util.Collections; + +public class ProjectRDAMapper { + + public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) { + Project rda = new Project(); + rda.setTitle(project.getLabel()); + rda.setDescription(project.getDescription()); + if (project.getStartdate() != null) { + rda.setStart(project.getStartdate().toString()); + } + if (project.getEnddate() != null) { + rda.setEnd(project.getEnddate().toString()); + } + rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant))); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java new file mode 100644 index 000000000..f7f95633f --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.SecurityAndPrivacy; + +public class SecurityAndPrivacyRDAMapper { + + public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + SecurityAndPrivacy rda = new SecurityAndPrivacy(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("title")) { + rda.setTitle(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java new file mode 100644 index 000000000..b2652901a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.TechnicalResource; + +public class TechnicalResourceRDAMapper { + + public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + TechnicalResource rda = new TechnicalResource(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("name")) { + rda.setName(value); + } + + return rda; + } +} From f1c405dae9383397cc3cd729e62865dd37f355b5 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 23 Mar 2020 18:09:31 +0200 Subject: [PATCH 120/160] Improved object coupling for various objects on the dataset form --- .../utilities/helpers/MyStringUtils.java | 21 ++++ .../logic/utilities/json/JsonSearcher.java | 1 + .../user/components/datasetprofile/Field.java | 6 +- .../components/datasetprofile/FieldSet.java | 9 +- .../models/rda/mapper/DatasetRDAMapper.java | 27 ++-- .../rda/mapper/DistributionRDAMapper.java | 107 ++++++++++++++-- .../models/rda/mapper/HostRDAMapper.java | 98 +++++++++++---- .../models/rda/mapper/LicenseRDAMapper.java | 6 +- .../models/rda/mapper/MetadataRDAMapper.java | 119 +++++++++++++++--- .../mapper/SecurityAndPrivacyRDAMapper.java | 57 ++++++++- .../mapper/TechnicalResourceRDAMapper.java | 58 ++++++++- .../dataset-description-form.model.ts | 2 +- 12 files changed, 424 insertions(+), 87 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java new file mode 100644 index 000000000..1a071e04c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java @@ -0,0 +1,21 @@ +package eu.eudat.logic.utilities.helpers; + +public class MyStringUtils { + + public static int getFirstDifference(String s1, String s2) { + char[] s1ar = s1.toCharArray(); + char[] s2ar = s2.toCharArray(); + + for(int i = 0; i < s1ar.length; i++) { + if (s2ar.length > i) { + if (s1ar[i] != s2ar[i]) { + return i; + } + } else { + return i; + } + } + + return -1; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java index ca2372b91..979053830 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -1,6 +1,7 @@ package eu.eudat.logic.utilities.json; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.ArrayList; import java.util.Iterator; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java index 4950261c4..1c735e1a9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java @@ -149,7 +149,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin this.rdaProperty = rdaProperty; } - Field cloneForMultiplicity(String key, Map properties) { + Field cloneForMultiplicity(String key, Map properties, int index) { Field newField = new Field(); newField.id = key; newField.ordinal = this.ordinal; @@ -161,6 +161,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin newField.data = this.data; newField.validations = this.validations; newField.rdaProperty = this.rdaProperty; + newField.numbering = "mult" + index + "_" + this.numbering; return newField; } @@ -204,8 +205,9 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } this.multiplicityItems = new LinkedList<>(); List compositeKeys = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList()); + int index = 1; for (String key : compositeKeys) { - this.multiplicityItems.add(this.cloneForMultiplicity(key, properties)); + this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java index 51663ddaf..277534d16 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java @@ -163,16 +163,18 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe }); List compositeKeysFather = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList()); List Ids=new ArrayList<>(); + int index = 1; for (String composite : compositeKeysFather) { String[] split = composite.split("_"); if (!Ids.contains(split[2])) { Ids.add(split[2]); - this.multiplicityItems.add(this.CloneForMultiplicity2(properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId() + "_" + split[2])).collect(Collectors.toList()), properties,split)); + this.multiplicityItems.add(this.CloneForMultiplicity2(properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId() + "_" + split[2])).collect(Collectors.toList()), properties,split, index)); + index++; } } } - private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids){ + private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids, int index){ FieldSet newFieldSet = new FieldSet(); newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2]; newFieldSet.description = this.description; @@ -181,8 +183,9 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe newFieldSet.title = this.title; newFieldSet.ordinal = this.ordinal; newFieldSet.fields = new LinkedList(); + for (Field field: this.fields) { - newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties)); + newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index)); } return newFieldSet; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 103ba72c6..5eb9cc685 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -1,21 +1,17 @@ package eu.eudat.models.rda.mapper; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; -import org.json.JSONObject; 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.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -41,52 +37,51 @@ public class DatasetRDAMapper { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); - JsonNode properties = mapper.readTree(dataset.getProperties()); String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); if (!typeNodes.isEmpty()) { - rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + rda.setType(typeNodes.get(0).get("value").asText()); } List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); if (!languageNodes.isEmpty()) { - rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + rda.setLanguage(Dataset.Language.fromValue(languageNodes.get(0).get("value").asText())); } List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); if (!metadataNodes.isEmpty()) { - rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + rda.setMetadata(MetadataRDAMapper.toRDAList(metadataNodes)); } List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { - rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { - rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes)); } List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { - rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { - rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get()); } List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); if (!securityAndPrivacyNodes.isEmpty()) { - rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + rda.setSecurityAndPrivacy(SecurityAndPrivacyRDAMapper.toRDAList(securityAndPrivacyNodes)); } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { - rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 513affd98..98cb6960b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,39 +1,120 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; import java.net.URI; -import java.util.Collections; +import java.util.*; public class DistributionRDAMapper { - public static Distribution toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + Distribution rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName : PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case ACCESS_URL: + rda.setAccessUrl(rdaValue); + break; + case AVAILABLE_UTIL: + rda.setAvailableUntil(rdaValue); + break; + case DOWNLOAD_URL: + rda.setDownloadUrl(URI.create(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case DATA_ACCESS: + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + break; + case BYTE_SIZE: + rda.setByteSize(Integer.parseInt(rdaValue)); + break; + case LICENSE: + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); + break; + case FORMAT: + rda.setFormat(Collections.singletonList(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case HOST: + rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); - String rdaProperty = structure.get("rdaProperty").asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); if (rdaProperty.contains("access_url")) { - rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + rda.setAccessUrl(rdaValue); } else if (rdaProperty.contains("available_util")) { - rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + rda.setAvailableUntil(rdaValue); } else if (rdaProperty.contains("byte_size")) { - rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + rda.setByteSize(Integer.parseInt(rdaValue)); } else if (rdaProperty.contains("data_access")) { - rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue); } else if (rdaProperty.contains("download_url")) { - rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + rda.setDownloadUrl(URI.create(rdaValue)); } else if (rdaProperty.contains("format")) { - rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + rda.setFormat(Collections.singletonList(rdaValue)); } else if (rdaProperty.contains("host")) { - rda.setHost(HostRDAMapper.toRDA(structure, properties)); +// rda.setHost(HostRDAMapper.toRDA(node)); } else if (rdaProperty.contains("license")) { - rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); + rda.setTitle(rdaValue); } return rda; } + + private static Distribution getRelative( Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); + } + + private enum PropertyName { + ACCESS_URL("access_url"), + AVAILABLE_UTIL("available_util"), + BYTE_SIZE("byte_size"), + DATA_ACCESS("data_access"), + DESCRIPTION("description"), + DOWNLOAD_URL("download_url"), + FORMAT("format"), + HOST("host"), + LICENSE("license"), + TITLE("title"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java index 9a32cc697..0983f3d3b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -1,41 +1,91 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; import java.net.URI; import java.util.Collections; +import java.util.List; public class HostRDAMapper { - public static Host toRDA(JsonNode structure, JsonNode properties) { + public static Host toRDA(List nodes, String numbering) { Host rda = new Host(); - String rdaProperty = structure.get("rdaProperties").asText(); - if (rdaProperty.contains("availability")) { - rda.setAvailability(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_frequency")) { - rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_type")) { - rda.setBackupType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("certified_with")) { - rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("geo_location")) { - rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("pid_system")) { - rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); - } else if (rdaProperty.contains("storage_type")) { - rda.setStorageType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("support_versioning")) { - rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("url")) { - rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperties").asText(); + if (rdaProperty.contains("host")) { + int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); + if (firstDiff == -1 || firstDiff > 2) { + String rdaValue = node.get("value").asText(); + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case AVAILABILITY: + rda.setAvailability(rdaValue); + break; + case BACKUP_FREQUENCY: + rda.setBackupFrequency(rdaValue); + break; + case BACKUP_TYPE: + rda.setBackupType(rdaValue); + break; + case CERTIFIED_WITH: + rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case GEO_LOCATION: + rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue)); + break; + case PID_SYSTEM: + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(rdaValue))); + break; + case STORAGE_TYPE: + rda.setStorageType(rdaValue); + break; + case SUPPORT_VERSIONING: + rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case URL: + rda.setUrl(URI.create(rdaValue)); + break; + } + } + } + } + } } return rda; } + + private enum PropertyName { + AVAILABILITY("availability"), + BACKUP_FREQUENCY("backup_frequency"), + BACKUP_TYPE("backup_type"), + CERTIFIED_WITH("certified_with"), + DESCRIPTION("description"), + GEO_LOCATION("geo_location"), + PID_SYSTEM("pid_system"), + STORAGE_TYPE("storage_type"), + SUPPORT_VERSIONING("support_versioning"), + TITLE("title"), + URL("url"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java index 68817bd3d..6f94a73c4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -7,10 +7,10 @@ import java.net.URI; public class LicenseRDAMapper { - public static License toRDA(JsonNode structure, JsonNode properties) { + public static License toRDA(JsonNode node) { License rda = new License(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("license_ref")) { rda.setLicenseRef(URI.create(value)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index fa638d3e3..c7e3ba35f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -2,43 +2,124 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.TextNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Metadatum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Iterator; +import java.util.*; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); - public static Metadatum toRDA(JsonNode structure, JsonNode properties) { - Metadatum rda = new Metadatum(); - JsonNode dataNode = null; - String rdaProperty = structure.get("rdaProperty").asText(); - if (rdaProperty.contains("metadata_standard_id")) { - try { - String jsonText = properties.get(structure.get("id").asText()).asText(); - if (jsonText != null && !jsonText.isEmpty()) { - dataNode = new ObjectMapper().readTree(jsonText); - for (Iterator it = dataNode.elements(); it.hasNext(); ) { - JsonNode data = it.next(); - if (data.get("uri") != null) { - rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); - } + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + List rdas = new ArrayList<>(); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case METADATA_STANDARD_ID: + if (rdaValue instanceof ArrayNode) { + try { + ObjectMapper mapper = new ObjectMapper(); + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = null; + data = mapper.readTree(it.next().asText()); + if (data.get("uri") != null) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); + } + break; + case DESCRIPTION: + if (!rdaValue.asText().isEmpty()) { + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setDescription(rdaValue.asText()); + } else { + rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); + } + } + break; + case LANGUAGE: + String language = rdaValue.asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setLanguage(lang); + } else { + rdas.forEach(rda1 -> rda1.setLanguage(lang)); + } + break; + } + } + } + + } + + return rdas; + } + + public static Metadatum toRDA(JsonNode node) { + Metadatum rda = new Metadatum(); + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + if (rdaProperty.contains("metadata_standard_id")) { + if (rdaValue instanceof ArrayNode) { + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); } } - } catch (IOException e) { - logger.error(e.getMessage(), e); } } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue.asText()); } else if (rdaProperty.contains("language")) { - String language = properties.get(structure.get("id").asText()).asText(); + String language = rdaValue.asText(); Metadatum.Language lang = Metadatum.Language.fromValue(language); rda.setLanguage(lang); } return rda; } + + private static Metadatum getRelative(List rdas, Map rdaMap, String numbering) { + String target = rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering))).map(Map.Entry::getKey).orElse(""); + return rdas.stream().filter(rda -> rda.getMetadataStandardId().getIdentifier().equals(target)).distinct().findFirst().orElse(null); + } + + private enum PropertyName { + METADATA_STANDARD_ID("metadata_standard_id"), + DESCRIPTION("description"), + LANGUAGE("language"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index f7f95633f..fc44cc182 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -1,14 +1,45 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import java.util.*; + public class SecurityAndPrivacyRDAMapper { - public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + SecurityAndPrivacy rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case TITLE: + rda.setTitle(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value =node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +49,24 @@ public class SecurityAndPrivacyRDAMapper { return rda; } + + private static SecurityAndPrivacy getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); + } + + private enum PropertyName { + TITLE("title"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index b2652901a..c48f93cae 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -1,14 +1,46 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; +import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import java.util.*; + public class TechnicalResourceRDAMapper { - public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + TechnicalResource rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case NAME: + rda.setName(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +50,24 @@ public class TechnicalResourceRDAMapper { return rda; } + + private static TechnicalResource getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); + } + + private enum PropertyName { + NAME("name"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts index c4b8153b8..fd8824ba3 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts @@ -338,4 +338,4 @@ export class DatasetDescriptionDefaultValueEditorModel extends BaseFormModel { }); return formGroup; } -} \ No newline at end of file +} From 926946018936104f9948e41eec93dbc6e9ae7dc4 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 24 Mar 2020 11:26:17 +0200 Subject: [PATCH 121/160] Minor bug fixes on the exporter --- .../src/main/java/eu/eudat/logic/managers/RDAManager.java | 2 +- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index eb10fd753..3a9f2f7a8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -29,7 +29,7 @@ public class RDAManager { Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); ObjectMapper mapper = new ObjectMapper(); - mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); result = mapper.writeValueAsString(rdaDmp); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 5eb9cc685..da04fe043 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -32,6 +32,7 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); +// rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); @@ -57,7 +58,7 @@ public class DatasetRDAMapper { } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); + rda.setPreservationStatement(preservationNodes.get(0).get("value").asText()); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { @@ -77,7 +78,7 @@ public class DatasetRDAMapper { } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); + rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { From d5c5c9743bb4f36a2af309067dc3d6381a8e9d72 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Tue, 24 Mar 2020 17:08:03 +0200 Subject: [PATCH 122/160] conf changes --- .../src/main/resources/config/application-staging.properties | 2 +- .../web/src/main/resources/config/application.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dmp-backend/web/src/main/resources/config/application-staging.properties b/dmp-backend/web/src/main/resources/config/application-staging.properties index 107c0f28c..93e304d2f 100644 --- a/dmp-backend/web/src/main/resources/config/application-staging.properties +++ b/dmp-backend/web/src/main/resources/config/application-staging.properties @@ -26,7 +26,7 @@ configuration.configurable_login_providers= ####################INVITATION MAIL CONFIGURATIONS############## ####################GENERIC MAIL CONFIGURATIONS################# mail.subject=Invitation to DMP Plan {dmpname} -mail.from=TheApp@dev.cite.gr +mail.from=opendmp-dev@cite.gr ####################SPRING MAIL CONFIGURATIONS################# spring.mail.default-encoding=UTF-8 diff --git a/dmp-backend/web/src/main/resources/config/application.properties b/dmp-backend/web/src/main/resources/config/application.properties index 99187392b..095672df1 100644 --- a/dmp-backend/web/src/main/resources/config/application.properties +++ b/dmp-backend/web/src/main/resources/config/application.properties @@ -8,7 +8,7 @@ eu.eudat.logic.proxy.allowed.host=https://eestore.paas2.uninett.no ####################INVITATION MAIL CONFIGURATIONS############## ####################GENERIC MAIL CONFIGURATIONS################# mail.subject=Invitation to DMP Plan {dmpname} -mail.from=TheApp@dev.cite.gr +mail.from=opendmp-dev@cite.gr ####################SPRING MAIL CONFIGURATIONS################# spring.mail.default-encoding=UTF-8 From a283bd47cfc3f7ab1aa737d469c4f9f3d61ad104 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 26 Mar 2020 18:39:25 +0200 Subject: [PATCH 123/160] Add RDA Import --- .../main/java/eu/eudat/controllers/DMPs.java | 11 +- .../managers/DataManagementPlanManager.java | 35 ++++++ .../eu/eudat/logic/managers/RDAManager.java | 9 ++ .../java/eu/eudat/models/rda/Dataset.java | 9 +- .../eu/eudat/models/rda/Distribution.java | 9 +- .../main/java/eu/eudat/models/rda/Dmp.java | 9 +- .../java/eu/eudat/models/rda/Metadatum.java | 9 +- .../eudat/models/rda/SecurityAndPrivacy.java | 9 +- .../eudat/models/rda/TechnicalResource.java | 9 +- .../models/rda/mapper/ContactIdRDAMapper.java | 4 + .../models/rda/mapper/ContactRDAMapper.java | 8 ++ .../models/rda/mapper/DatasetRDAMapper.java | 112 +++++++++++++++++- .../rda/mapper/DistributionRDAMapper.java | 97 ++++++++++++++- .../eudat/models/rda/mapper/DmpRDAMapper.java | 36 ++++-- .../models/rda/mapper/FundingRDAMapper.java | 9 +- .../models/rda/mapper/MetadataRDAMapper.java | 66 +++++++++++ .../models/rda/mapper/ProjectRDAMapper.java | 22 +++- .../mapper/SecurityAndPrivacyRDAMapper.java | 60 +++++++++- .../mapper/TechnicalResourceRDAMapper.java | 62 +++++++++- .../dmp-upload-dialogue.component.html | 2 +- 20 files changed, 531 insertions(+), 56 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index c87ce4590..0e25b98f6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -53,6 +53,9 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import static org.springframework.http.MediaType.APPLICATION_ATOM_XML; +import static org.springframework.http.MediaType.APPLICATION_JSON; + @RestController @CrossOrigin @@ -224,8 +227,12 @@ public class DMPs extends BaseController { } @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { - this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + public ResponseEntity dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { + if (files[0].getContentType().equals(APPLICATION_JSON.toString())) { + this.dataManagementPlanManager.createFromRDA(files, principal); + } else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString())) { + this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + } return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem() .status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 2710ec60c..c8dee4802 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -131,6 +131,13 @@ public class DataManagementPlanManager { if (fieldsGroup.equals("listing")) { itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)) .selectAsync(item -> { + if (item.getUsers().stream().noneMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) { + for (UserDMP userDMP: item.getUsers()) { + userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue()); + databaseRepository.getUserDmpDao().createOrUpdate(userDMP); + break; + } + } item.setDataset( item.getDataset().stream() .filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream() @@ -1329,6 +1336,34 @@ public class DataManagementPlanManager { return dataManagementPlans; } + public List createFromRDA(MultipartFile[] files, Principal principal) throws IOException { + if (principal.getId() == null) { + throw new UnauthorisedException("No user is logged in"); + } + List result = new ArrayList<>(); + for (MultipartFile file: files) { + DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8")); + UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); + dmp.setModified(new Date()); + dmp.setCreator(me); + dmp.setVersion(0); + dmp.setStatus((short)0); + dmp.setGroupId(UUID.randomUUID()); + databaseRepository.getDmpDao().createOrUpdate(dmp); + assignUser(dmp, me); + dmp.getDataset().forEach(dataset -> { + dataset.setStatus(Dataset.Status.SAVED.getValue()); + dataset.setCreated(new Date()); + dataset.setModified(new Date()); + dataset.setDmp(dmp); + databaseRepository.getDatasetDao().createOrUpdate(dataset); + }); + result.add(dmp); + } + + return result; + } + public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) { datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index 3a9f2f7a8..ff194455e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; +import java.io.IOException; import java.text.SimpleDateFormat; @Component @@ -35,4 +36,12 @@ public class RDAManager { return result; } + + public DMP convertToEntity(String json) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); + + Dmp rda = mapper.readValue(json, Dmp.class); + return dmpRDAMapper.toEntity(rda); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java index 43a7ac0cd..3c064965e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -38,7 +38,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "sensitive_data", "technical_resource", "title", - "type" + "type", + "additional_properties" }) public class Dataset implements Serializable { @@ -182,7 +183,7 @@ public class Dataset implements Serializable @JsonProperty("type") @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") private String type; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6931119120629009399L; @@ -524,12 +525,12 @@ public class Dataset implements Serializable this.type = type; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java index d005e7564..176931e9e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -34,7 +34,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "format", "host", "license", - "title" + "title", + "additional_properties" }) public class Distribution implements Serializable { @@ -131,7 +132,7 @@ public class Distribution implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6018365280419917902L; @@ -359,12 +360,12 @@ public class Distribution implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java index 7cac25d62..b53d26147 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "language", "modified", "project", - "title" + "title", + "additional_properties" }) public class Dmp implements Serializable { @@ -173,7 +174,7 @@ public class Dmp implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title of a DMP") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 4599713332472772292L; @@ -499,12 +500,12 @@ public class Dmp implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java index d6057ca62..56bee437d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.annotation.JsonValue; @JsonPropertyOrder({ "description", "language", - "metadata_standard_id" + "metadata_standard_id", + "additional_properties" }) public class Metadatum implements Serializable { @@ -58,7 +59,7 @@ public class Metadatum implements Serializable */ @JsonProperty("metadata_standard_id") private MetadataStandardId metadataStandardId; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 6511312853153406190L; @@ -132,12 +133,12 @@ public class Metadatum implements Serializable this.metadataStandardId = metadataStandardId; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java index 0486df588..245d202d0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "title" + "title", + "additional_properties" }) public class SecurityAndPrivacy implements Serializable { @@ -46,7 +47,7 @@ public class SecurityAndPrivacy implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 7863747935827682977L; @@ -96,12 +97,12 @@ public class SecurityAndPrivacy implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java index eac85da72..c7bd2b055 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "name" + "name", + "additional_properties" }) public class TechnicalResource implements Serializable { @@ -46,7 +47,7 @@ public class TechnicalResource implements Serializable @JsonProperty("name") @JsonPropertyDescription("Name of the technical resource") private String name; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -7451757227129483110L; @@ -96,12 +97,12 @@ public class TechnicalResource implements Serializable this.name = name; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java index 48549d75a..c9eac2009 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -12,4 +12,8 @@ public class ContactIdRDAMapper { rda.setType(ContactId.Type.OTHER); return rda; } + + public static UUID toEntity(ContactId rda) { + return UUID.fromString(rda.getIdentifier()); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java index 69ea2310e..957fef8d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -13,4 +13,12 @@ public class ContactRDAMapper { rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); return rda; } + + public static UserInfo toEntity(Contact rda) { + UserInfo entity = new UserInfo(); + entity.setId(ContactIdRDAMapper.toEntity(rda.getContactId())); + entity.setName(rda.getName()); + entity.setEmail(rda.getMbox()); + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index da04fe043..90aa4ec7c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -2,28 +2,34 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DatasetProfile; import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; 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.util.List; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Component public class DatasetRDAMapper { private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); private DatasetManager datasetManager; + private ApiContext apiContext; @Autowired - public DatasetRDAMapper(DatasetManager datasetManager) { + public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext) { this.datasetManager = datasetManager; + this.apiContext = apiContext; } @Transactional @@ -32,9 +38,10 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); -// rda.setAdditionalProperty("template", dataset.getProfile().getId()); + rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { - + JSONObject jObject = new JSONObject(dataset.getProperties()); + Map templateIdsToValues = jObject.toMap(); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); @@ -55,6 +62,9 @@ public class DatasetRDAMapper { List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < qaNodes.size(); i++) { + rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { @@ -67,6 +77,9 @@ public class DatasetRDAMapper { List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < keywordNodes.size(); i++) { + rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText()); + } } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { @@ -84,6 +97,14 @@ public class DatasetRDAMapper { if (!technicalResourceNodes.isEmpty()) { rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } + List foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes, + keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList()); + templateIdsToValues.entrySet().forEach(entry -> { + boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey())); + if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) { + rda.setAdditionalProperty(entry.getKey(), entry.getValue()); + } + }); } catch (Exception e) { @@ -93,4 +114,87 @@ public class DatasetRDAMapper { return rda; } + + + public eu.eudat.data.entities.Dataset toEntity(Dataset rda) { + eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset(); + entity.setLabel(rda.getTitle()); + entity.setDescription(rda.getDescription()); + try { + DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); + entity.setProfile(profile); + }catch(Exception e) { + logger.warn(e.getMessage(), e); + } + try { + Map properties = new HashMap<>(); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); + datasetWizardModel.setProfile(entity.getProfile().getId()); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity)); + ObjectMapper mapper = new ObjectMapper(); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + properties.put(typeNodes.get(0).get("id").asText(), rda.getType()); + } + + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value()); + } + + if (rda.getMetadata() != null) { + properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); + } + + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < qaIds.size(); i++) { + properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); + } + + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement()); + } + + if (rda.getDistribution() != null) { + properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution())); + } + + List keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < keywordIds.size(); i++) { + properties.put(keywordIds.get(i), rda.getKeyword().get(i)); + } + + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + properties.put(personalDataNodes.get(0).get("id").asText(), rda.getPersonalData().value()); + } + + if (rda.getSecurityAndPrivacy() != null) { + properties.putAll(SecurityAndPrivacyRDAMapper.toProperties(rda.getSecurityAndPrivacy())); + } + + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + properties.put(sensitiveDataNodes.get(0).get("id").asText(), rda.getSensitiveData().value()); + } + + if (rda.getTechnicalResource() != null) { + properties.putAll(TechnicalResourceRDAMapper.toProperties(rda.getTechnicalResource())); + } + + rda.getAdditionalProperties().entrySet().stream() + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); + entity.setProperties(new ObjectMapper().writeValueAsString(properties)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 98cb6960b..566288452 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,13 +1,17 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import com.lowagie.text.ExceptionConverter; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.*; public class DistributionRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,35 +23,43 @@ public class DistributionRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName : PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case ACCESS_URL: rda.setAccessUrl(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText()); break; case AVAILABLE_UTIL: rda.setAvailableUntil(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UTIL.getName(), node.get("id").asText()); break; case DOWNLOAD_URL: rda.setDownloadUrl(URI.create(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; case DATA_ACCESS: rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DATA_ACCESS.getName(), node.get("id").asText()); break; case BYTE_SIZE: rda.setByteSize(Integer.parseInt(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText()); break; case LICENSE: rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); break; case FORMAT: rda.setFormat(Collections.singletonList(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText()); break; case TITLE: rda.setTitle(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case HOST: rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); @@ -60,6 +72,49 @@ public class DistributionRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch (importPropertyName) { + case ACCESS_URL: + properties.put(entry.getValue().toString(), rda.getAccessUrl()); + break; + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case FORMAT: + properties.put(entry.getValue().toString(), rda.getFormat().get(0)); + break; + case BYTE_SIZE: + properties.put(entry.getValue().toString(), rda.getByteSize().toString()); + break; + case DATA_ACCESS: + properties.put(entry.getValue().toString(), rda.getDataAccess().value()); + break; + case DOWNLOAD_URL: + properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString()); + break; + case AVAILABLE_UTIL: + properties.put(entry.getValue().toString(), rda.getAvailableUntil()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + }); + }); + + return properties; + } + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); String rdaProperty = node.get("rdaProperty").asText(); @@ -95,7 +150,7 @@ public class DistributionRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); } - private enum PropertyName { + private enum ExportPropertyName { ACCESS_URL("access_url"), AVAILABLE_UTIL("available_util"), BYTE_SIZE("byte_size"), @@ -109,7 +164,7 @@ public class DistributionRDAMapper { private final String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -117,4 +172,36 @@ public class DistributionRDAMapper { return name; } } + + private enum ImportPropertyName { + ACCESS_URL("accessurlId"), + AVAILABLE_UTIL("availableUtilId"), + BYTE_SIZE("byteSizeId"), + DATA_ACCESS("dataAccessId"), + DESCRIPTION("descriptionId"), + DOWNLOAD_URL("downloadUrlId"), + FORMAT("formatId"), + /*HOST("host"), + LICENSE("license"),*/ + TITLE("titleId"); + + private final String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("No name available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java index 620229a27..7176f3b8d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -1,24 +1,26 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.DMP; -import eu.eudat.data.entities.UserDMP; -import eu.eudat.data.entities.UserInfo; +import eu.eudat.data.entities.*; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.DmpId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.Collections; +import java.util.*; import java.util.stream.Collectors; @Component public class DmpRDAMapper { private DatasetRDAMapper datasetRDAMapper; + private ApiContext apiContext; @Autowired - public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) { this.datasetRDAMapper = datasetRDAMapper; + this.apiContext = apiContext; } @Transactional @@ -44,8 +46,28 @@ public class DmpRDAMapper { rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); - - + rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray()); return rda; } + + public DMP toEntity(Dmp rda) { + DMP entity = new DMP(); + entity.setLabel(rda.getTitle()); + if (rda.getDmpId().getType() == DmpId.Type.DOI) { + entity.setDoi(rda.getDmpId().getIdentifier()); + } + entity.setCreated(rda.getCreated()); + entity.setModified(rda.getModified()); + entity.setDescription(rda.getDescription()); + entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1)).collect(Collectors.toSet())); + Map result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext); + entity.setProject((Project) result.get("project")); + result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue())); + entity.setAssociatedDmps(((List) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet())); + return entity; + } + + private DatasetProfile getProfile(String id) { + return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java index e0b8fbe65..2dd3f6cc2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -1,7 +1,8 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.Funder; +import eu.eudat.data.dao.criteria.GrantCriteria; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Funding; public class FundingRDAMapper { @@ -22,4 +23,10 @@ public class FundingRDAMapper { rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); return rda; } + + public static Grant toEntity(Funding rda, ApiContext apiContext) { + GrantCriteria criteria = new GrantCriteria(); + criteria.setReference(rda.getGrantId().getIdentifier()); + return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle(); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index c7e3ba35f..49bbbb527 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); @@ -36,6 +37,7 @@ public class MetadataRDAMapper { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdas.get(rdas.size() - 1).setAdditionalProperty("fieldId", node.get("id").asText()); rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); } } @@ -45,6 +47,7 @@ public class MetadataRDAMapper { } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdas.get(rdas.size() - 1).setAdditionalProperty("identifierId", node.get("id").asText()); rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); } break; @@ -53,6 +56,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setDescription(rdaValue.asText()); + rda.setAdditionalProperty("descriptionId", node.get("id").asText()); } else { rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); } @@ -64,6 +68,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setLanguage(lang); + rda.setAdditionalProperty("languageId", node.get("id").asText()); } else { rdas.forEach(rda1 -> rda1.setLanguage(lang)); } @@ -77,6 +82,40 @@ public class MetadataRDAMapper { return rdas; } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + List standardIds = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + switch (entry.getKey()) { + case "fieldId": + Map metadata = toMap(rda); + standardIds.add(metadata); + properties.put(entry.getValue().toString(), mapper.writeValueAsString(standardIds)); + break; + case "identifierId": + properties.put(entry.getValue().toString(), rda.getMetadataStandardId().getIdentifier()); + break; + case "descriptionId": + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case "languageId": + if (rda.getLanguage() != null) { + properties.put(entry.getValue().toString(), rda.getLanguage().value()); + } + break; + } + }catch (Exception e) { + logger.error(e.getMessage(), e); + } + }); + }); + + return properties; + } + public static Metadatum toRDA(JsonNode node) { Metadatum rda = new Metadatum(); String rdaProperty = node.get("rdaProperty").asText(); @@ -122,4 +161,31 @@ public class MetadataRDAMapper { return name; } } + + private static Map toMap(Metadatum rda) { + Map result = new HashMap<>(); + + ObjectMapper mapper = new ObjectMapper(); + + Map metadata = mapper.convertValue(rda, Map.class); + + Map metadataStandardId = mapper.convertValue(metadata.get("metadata_standard_id"), Map.class); + + String url = metadataStandardId.remove("identifier"); + metadataStandardId.remove("type"); + metadataStandardId.put("uri", url); + + metadata.remove("additional_properties"); + metadata.remove("metadata_standard_id"); + + Map newMetadata = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toString())); + + String label = newMetadata.remove("description"); + newMetadata.put("label", label); + + result.putAll(newMetadata); + result.putAll(metadataStandardId); + + return result; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java index d97eace4a..b21a9403c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -2,9 +2,10 @@ package eu.eudat.models.rda.mapper; import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Project; -import java.util.Collections; +import java.util.*; public class ProjectRDAMapper { @@ -22,4 +23,23 @@ public class ProjectRDAMapper { return rda; } + + public static Map toEntity(Project rda, ApiContext apiContext) { + Map entities = new HashMap<>(); + + entities.put("project", new eu.eudat.data.entities.Project()); + ((eu.eudat.data.entities.Project) entities.get("project")).setLabel(rda.getTitle()); + ((eu.eudat.data.entities.Project) entities.get("project")).setDescription(rda.getDescription()); + ((eu.eudat.data.entities.Project) entities.get("project")).setId(UUID.randomUUID()); + ((eu.eudat.data.entities.Project) entities.get("project")).setStatus((short)1); + ((eu.eudat.data.entities.Project) entities.get("project")).setCreated(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setModified(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setType(0); + apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(((eu.eudat.data.entities.Project) entities.get("project"))); + for (int i = 0; i < rda.getFunding().size(); i++) { + entities.put("grant" + (i + 1), FundingRDAMapper.toEntity(rda.getFunding().get(i), apiContext)); + } + + return entities; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index fc44cc182..3b5d28649 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -3,10 +3,13 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class SecurityAndPrivacyRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(SecurityAndPrivacyRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,14 +22,16 @@ public class SecurityAndPrivacyRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case TITLE: rda.setTitle(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -36,6 +41,27 @@ public class SecurityAndPrivacyRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); String rdaProperty = node.get("rdaProperty").asText(); @@ -55,13 +81,13 @@ public class SecurityAndPrivacyRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); } - private enum PropertyName { + private enum ExportPropertyName { TITLE("title"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -69,4 +95,28 @@ public class SecurityAndPrivacyRDAMapper { return name; } } + + private enum ImportPropertyName { + TITLE("titleId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property not available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index c48f93cae..cd764c302 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -2,12 +2,14 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; -import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class TechnicalResourceRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(TechnicalResourceRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -20,14 +22,16 @@ public class TechnicalResourceRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case NAME: rda.setName(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.NAME.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -37,6 +41,28 @@ public class TechnicalResourceRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case NAME: + properties.put(entry.getValue().toString(), rda.getName()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); String rdaProperty = node.get("rdaProperty").asText(); @@ -56,13 +82,13 @@ public class TechnicalResourceRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); } - private enum PropertyName { + private enum ExportPropertyName { NAME("name"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -70,4 +96,28 @@ public class TechnicalResourceRDAMapper { return name; } } + + private enum ImportPropertyName { + NAME("nameId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property name not available"); + } + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html index 81779fadc..f9669094e 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html @@ -7,7 +7,7 @@ - +
From 21fe5bb6215be2218daa486a4f92f6779c980b1f Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 26 Mar 2020 18:44:12 +0200 Subject: [PATCH 124/160] Replace the usage of environment.ts with config.json (not too stable) (ref #251) --- dmp-frontend/src/app/app.component.ts | 11 ++- dmp-frontend/src/app/app.module.ts | 13 +-- .../src/app/core/core-service.module.ts | 17 +++- .../help-service.model.ts | 20 ++++ .../configuration-models/logging.model.ts | 19 ++++ .../login-configuration.model.ts | 22 +++++ .../login-providers.model.ts | 57 +++++++++++ .../app/core/services/auth/auth.service.ts | 9 +- .../configuration/configuration.service.ts | 97 +++++++++++++++++++ .../contact-support.service.ts | 6 +- .../services/dashboard/dashboard.service.ts | 6 +- .../dataset-profile.service.ts | 5 +- .../dataset-wizard/dataset-wizard.service.ts | 5 +- .../dataset-external-autocomplete.service.ts | 8 +- .../core/services/dataset/dataset.service.ts | 9 +- .../services/dmp/dmp-invitation.service.ts | 5 +- .../core/services/dmp/dmp-profile.service.ts | 5 +- .../src/app/core/services/dmp/dmp.service.ts | 5 +- .../email-confirmation.service.ts | 5 +- .../extternal-data-repository.service.ts | 5 +- .../dataset/external-dataset.service.ts | 5 +- .../external-sources-configuration.service.ts | 5 +- .../external-sources.service.ts | 7 +- .../registry/external-registry.service.ts | 5 +- .../researcher/external-researcher.service.ts | 5 +- .../service/external-service.service.ts | 5 +- .../core/services/funder/funder.service.ts | 5 +- .../grant/grant-file-upload.service.ts | 5 +- .../app/core/services/grant/grant.service.ts | 5 +- .../help-content/help-content.service.ts | 6 +- .../services/language/language.service.ts | 10 +- .../core/services/language/server.loader.ts | 11 ++- .../app/core/services/lock/lock.service.ts | 5 +- .../core/services/logging/logging-service.ts | 7 +- .../organisation/organisation.service.ts | 5 +- .../core/services/project/project.service.ts | 5 +- .../quick-wizard/quick-wizard.service.ts | 5 +- .../services/search-bar/search-bar.service.ts | 5 +- .../services/user-guide/user-guide.service.ts | 12 ++- .../app/core/services/user/user.service.ts | 5 +- .../editor/dmp-profile-editor.component.ts | 7 +- .../b2access/b2access-login.component.ts | 14 +-- .../configurable-login.component.ts | 6 +- .../linkedin-login.component.ts | 16 +-- .../src/app/ui/auth/login/login.component.ts | 26 ++--- .../openaire-login.component.ts | 16 +-- .../orcid-login/orcid-login.component.ts | 12 ++- .../twitter-login/twitter-login.component.ts | 8 +- .../dataset-wizard.component.ts | 8 +- .../app/ui/dmp/editor/dmp-editor.component.ts | 8 +- .../ui/grant/editor/grant-editor.component.ts | 7 +- .../user-guide-editor.component.ts | 4 +- dmp-frontend/src/assets/config/config.json | 48 +++++++++ .../interceptors/auth-token.interceptor.ts | 4 +- .../http/interceptors/base.interceptor.ts | 5 +- .../http/interceptors/json.interceptor.ts | 4 +- .../http/interceptors/locale.interceptor.ts | 4 +- .../progress-indication.interceptor.ts | 4 +- .../request-timing.interceptor.ts | 4 +- .../response-payload.interceptor.ts | 6 +- .../interceptors/status-code.interceptor.ts | 4 +- .../unauthorized-response.interceptor.ts | 4 +- 62 files changed, 524 insertions(+), 147 deletions(-) create mode 100644 dmp-frontend/src/app/core/model/configuration-models/help-service.model.ts create mode 100644 dmp-frontend/src/app/core/model/configuration-models/logging.model.ts create mode 100644 dmp-frontend/src/app/core/model/configuration-models/login-configuration.model.ts create mode 100644 dmp-frontend/src/app/core/model/configuration-models/login-providers.model.ts create mode 100644 dmp-frontend/src/app/core/services/configuration/configuration.service.ts create mode 100644 dmp-frontend/src/assets/config/config.json diff --git a/dmp-frontend/src/app/app.component.ts b/dmp-frontend/src/app/app.component.ts index 3dceca965..898ec3cf4 100644 --- a/dmp-frontend/src/app/app.component.ts +++ b/dmp-frontend/src/app/app.component.ts @@ -13,6 +13,7 @@ import { Title } from '@angular/platform-browser'; import { NgcCookieConsentService, NgcStatusChangeEvent } from "ngx-cookieconsent"; import { CookieService } from "ngx-cookie-service"; import { LanguageService } from './core/services/language/language.service'; +import { ConfigurationService } from './core/services/configuration/configuration.service'; declare const gapi: any; @@ -27,7 +28,7 @@ export class AppComponent implements OnInit { hasBreadCrumb = observableOf(false); sideNavOpen = false; - helpContentEnabled = environment.HelpService.Enabled; + helpContentEnabled : boolean; private statusChangeSubscription: Subscription; constructor( @@ -40,9 +41,11 @@ export class AppComponent implements OnInit { private cultureService: CultureService, private cookieService: CookieService, private ccService: NgcCookieConsentService, - private language: LanguageService + private language: LanguageService, + private configurationService: ConfigurationService ) { this.initializeServices(); + this.helpContentEnabled = configurationService.helpService.enabled; } onActivate(event: any) { @@ -99,6 +102,8 @@ export class AppComponent implements OnInit { } }); + this.ccService.getConfig().content.href = this.configurationService.app + "terms-of-service"; + this.ccService.getConfig().cookie.domain = this.configurationService.app; this.translate .get(['COOKIE.MESSAGE', 'COOKIE.DISMISS', 'COOKIE.DENY', 'COOKIE.LINK', 'COOKIE.POLICY']) .subscribe(data => { @@ -146,7 +151,7 @@ export class AppComponent implements OnInit { initializeServices() { this.translate.setDefaultLang('en'); - this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(environment.defaultCulture); + this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(this.configurationService.defaultCulture); this.authentication.current() && this.authentication.current().language ? this.language.changeLanguage(this.authentication.current().language) : this.language.changeLanguage('en'); } } diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index 44eb869ba..fdb790e30 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -1,6 +1,6 @@ import { OverlayModule } from '@angular/cdk/overlay'; import { HttpClient, HttpClientModule } from '@angular/common/http'; -import { LOCALE_ID, NgModule } from '@angular/core'; +import { LOCALE_ID, NgModule, APP_INITIALIZER } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatMomentDateModule, MAT_MOMENT_DATE_FORMATS } from '@angular/material-moment-adapter'; import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core'; @@ -29,10 +29,11 @@ import { CookieService } from 'ngx-cookie-service'; import { NgcCookieConsentConfig, NgcCookieConsentModule } from 'ngx-cookieconsent'; import { TranslateServerLoader } from './core/services/language/server.loader'; import { BaseHttpService } from './core/services/http/base-http.service'; +import { ConfigurationService } from './core/services/configuration/configuration.service'; // AoT requires an exported function for factories -export function HttpLoaderFactory(http: HttpClient) { - return new TranslateServerLoader(http); +export function HttpLoaderFactory(http: HttpClient, appConfig: ConfigurationService) { + return new TranslateServerLoader(http, appConfig); //GK: In case we want the original translation provider uncomment the line below. //return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); } @@ -40,7 +41,7 @@ export function HttpLoaderFactory(http: HttpClient) { const cookieConfig: NgcCookieConsentConfig = { enabled: true, cookie: { - domain: environment.App // or 'your.domain.com' // it is mandatory to set a domain, for cookies to work properly (see https://goo.gl/S2Hy2A) + domain: ""//environment.App // or 'your.domain.com' // it is mandatory to set a domain, for cookies to work properly (see https://goo.gl/S2Hy2A) }, palette: { popup: { @@ -59,7 +60,7 @@ const cookieConfig: NgcCookieConsentConfig = { dismiss: "Got it!", deny: "Refuse cookies", link: "Learn more", - href: environment.App + "terms-of-service", + href: "",//environment.App + "terms-of-service", policy: "Cookie Policy" }, position: "bottom-right", @@ -78,7 +79,7 @@ const cookieConfig: NgcCookieConsentConfig = { loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, - deps: [HttpClient] + deps: [HttpClient, ConfigurationService] } }), HttpClientModule, diff --git a/dmp-frontend/src/app/core/core-service.module.ts b/dmp-frontend/src/app/core/core-service.module.ts index 0fbfbf240..0990f14c1 100644 --- a/dmp-frontend/src/app/core/core-service.module.ts +++ b/dmp-frontend/src/app/core/core-service.module.ts @@ -1,4 +1,4 @@ -import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core'; +import { ModuleWithProviders, NgModule, Optional, SkipSelf, APP_INITIALIZER } from '@angular/core'; import { CookieService } from 'ngx-cookie-service'; import { AuthGuard } from './auth-guard.service'; import { AuthService } from './services/auth/auth.service'; @@ -39,12 +39,18 @@ import { LanguageService } from './services/language/language.service'; import { AdminAuthGuard } from './admin-auth-guard.service'; import { LockService } from './services/lock/lock.service'; import { UserGuideService } from './services/user-guide/user-guide.service'; +import { ConfigurationService } from './services/configuration/configuration.service'; +import { HttpClient } from '@angular/common/http'; // // // This is shared module that provides all the services. Its imported only once on the AppModule. // // +export function ConfigurationFactory(appConfig: ConfigurationService) { + return () => appConfig.loadConfiguration(); +} + @NgModule({ }) export class CoreServiceModule { @@ -97,7 +103,14 @@ export class CoreServiceModule { ContactSupportService, LanguageService, LockService, - UserGuideService + UserGuideService, + ConfigurationService, + { + provide: APP_INITIALIZER, + useFactory: ConfigurationFactory, + deps: [ConfigurationService, HttpClient], + multi: true + }, ], }; } diff --git a/dmp-frontend/src/app/core/model/configuration-models/help-service.model.ts b/dmp-frontend/src/app/core/model/configuration-models/help-service.model.ts new file mode 100644 index 000000000..032d76e7f --- /dev/null +++ b/dmp-frontend/src/app/core/model/configuration-models/help-service.model.ts @@ -0,0 +1,20 @@ +export class HelpService { + + private _enabled: boolean; + get enabled(): boolean { + return this._enabled; + } + + private _url: string; + get url(): string { + return this._url; + } + + public static parseValue(value: any): HelpService { + const obj: HelpService = new HelpService(); + obj._enabled = value.Enabled; + obj._url = value.Url; + return obj; + } + +} diff --git a/dmp-frontend/src/app/core/model/configuration-models/logging.model.ts b/dmp-frontend/src/app/core/model/configuration-models/logging.model.ts new file mode 100644 index 000000000..2fb47ee7e --- /dev/null +++ b/dmp-frontend/src/app/core/model/configuration-models/logging.model.ts @@ -0,0 +1,19 @@ +export class Logging { + + private _enabled: boolean; + get enabled(): boolean { + return this._enabled; + } + + private _loglevels: string[] = []; + get loglevels(): string[] { + return this._loglevels; + } + + public static parseValue(value: any): Logging { + const obj: Logging = new Logging(); + obj._enabled = value.enabled; + obj._loglevels = value.logLevels; + return obj; + } +} diff --git a/dmp-frontend/src/app/core/model/configuration-models/login-configuration.model.ts b/dmp-frontend/src/app/core/model/configuration-models/login-configuration.model.ts new file mode 100644 index 000000000..18f467e99 --- /dev/null +++ b/dmp-frontend/src/app/core/model/configuration-models/login-configuration.model.ts @@ -0,0 +1,22 @@ +export class LoginConfiguration { + + private _clientId: string; + get clientId(): string { + return this._clientId; + } + + private _oauthUrl: string; + get oauthUrl(): string { + return this._oauthUrl; + } + + private _redirectUri: string; + get redirectUri(): string { + return this._redirectUri; + } + + private _state: string; + get state(): string { + return this._state; + } +} diff --git a/dmp-frontend/src/app/core/model/configuration-models/login-providers.model.ts b/dmp-frontend/src/app/core/model/configuration-models/login-providers.model.ts new file mode 100644 index 000000000..8c7751e2c --- /dev/null +++ b/dmp-frontend/src/app/core/model/configuration-models/login-providers.model.ts @@ -0,0 +1,57 @@ +import { LoginConfiguration } from './login-configuration.model'; + +export class LoginProviders { + + private _enabled: number[] = []; + get enabled(): number[] { + return this._enabled; + } + + private _facebookConfiguration: LoginConfiguration; + get facebookConfiguration(): LoginConfiguration { + return this._facebookConfiguration; + } + + private _googleConfiguration: LoginConfiguration; + get googleConfiguration(): LoginConfiguration { + return this._googleConfiguration; + } + + private _linkedInConfiguration: LoginConfiguration; + get linkedInConfiguration(): LoginConfiguration { + return this._linkedInConfiguration; + } + + private _twitterConfiguration: LoginConfiguration; + get twitterConfiguration(): LoginConfiguration { + return this._twitterConfiguration; + } + + private _b2accessConfiguration: LoginConfiguration; + get b2accessConfiguration(): LoginConfiguration { + return this._b2accessConfiguration; + } + + private _orcidConfiguration: LoginConfiguration; + get orcidConfiguration(): LoginConfiguration { + return this._orcidConfiguration; + } + + private _openAireConfiguration: LoginConfiguration; + get openAireConfiguration(): LoginConfiguration { + return this._openAireConfiguration; + } + + public static parseValue(value: any): LoginProviders { + const obj: LoginProviders = new LoginProviders(); + obj._enabled = value.enabled; + obj._facebookConfiguration = value.facebookConfiguration; + obj._googleConfiguration = value.googleConfiguration; + obj._linkedInConfiguration = value.linkedInConfiguration; + obj._twitterConfiguration = value.twitterConfiguration; + obj._b2accessConfiguration = value.b2accessConfiguration; + obj._orcidConfiguration = value.orcidConfiguration; + obj._openAireConfiguration = value.openAireConfiguration; + return obj; + } +} diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index bcb59345a..a48a2d478 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -13,6 +13,7 @@ import { TranslateService } from '@ngx-translate/core'; import { environment } from 'environments/environment'; import { Observable, of as observableOf, throwError as observableThrowError } from 'rxjs'; import { catchError, map, takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class AuthService extends BaseService { @@ -24,10 +25,11 @@ export class AuthService extends BaseService { private snackBar: MatSnackBar, private language: TranslateService, private router: Router, - private uiNotificationService: UiNotificationService + private uiNotificationService: UiNotificationService, + private configurationService: ConfigurationService ) { super(); - this.actionUrl = environment.Server + 'auth/'; + this.headers = new HttpHeaders(); this.headers = this.headers.set('Content-Type', 'application/json'); @@ -65,6 +67,7 @@ export class AuthService extends BaseService { //} public login(loginInfo: LoginInfo): Observable { + this.actionUrl = this.configurationService.server + 'auth/'; const url = this.actionUrl + 'externallogin'; return this.http.post(url, loginInfo, { headers: this.headers }).pipe( @@ -80,6 +83,7 @@ export class AuthService extends BaseService { } public nativeLogin(credentials: Credential): Observable { + this.actionUrl = this.configurationService.server + 'auth/'; const url = this.actionUrl + 'nativelogin'; return this.http.post(url, credentials, { headers: this.headers }).pipe( @@ -96,6 +100,7 @@ export class AuthService extends BaseService { public logout(): void { + this.actionUrl = this.configurationService.server + 'auth/'; const url = this.actionUrl + 'logout'; const principal = this.current(); this.clear(); diff --git a/dmp-frontend/src/app/core/services/configuration/configuration.service.ts b/dmp-frontend/src/app/core/services/configuration/configuration.service.ts new file mode 100644 index 000000000..e95d87773 --- /dev/null +++ b/dmp-frontend/src/app/core/services/configuration/configuration.service.ts @@ -0,0 +1,97 @@ +import { Injectable } from '@angular/core'; +import { BaseHttpParams } from '@common/http/base-http-params'; +import { InterceptorType } from '@common/http/interceptors/interceptor-type'; +import { BaseHttpService } from '@common/base/base-http.service'; +import { BaseComponent } from '@common/base/base.component'; +import { catchError, takeUntil } from 'rxjs/operators'; +import { Observable, throwError } from 'rxjs'; +import { HelpService } from '@app/core/model/configuration-models/help-service.model'; +import { LoginProviders } from '@app/core/model/configuration-models/login-providers.model'; +import { Logging } from '@app/core/model/configuration-models/logging.model'; +import { HttpClient } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root', + }) +export class ConfigurationService extends BaseComponent { + + constructor(private http: HttpClient) { super(); } + + private _server: string; + get server(): string { + return this._server; + } + + private _app: string; + get app(): string { + return this._app; + } + + private _helpService: HelpService; + get helpService(): HelpService { + return this._helpService; + } + + private _defaultCulture: string; + get defaultCulture(): string { + return this._defaultCulture; + } + + private _loginProviders: LoginProviders; + get loginProviders(): LoginProviders { + return this._loginProviders; + } + + private _logging: Logging; + get logging(): Logging { + return this._logging; + } + + private _lockInterval: number; + get lockInterval(): number { + return this._lockInterval; + } + + private _guideAssets: string; + get guideAssets():string { + return this._guideAssets; + } + + + public loadConfiguration(): Promise { + return new Promise((r, e) => { + + // We need to exclude all interceptors here, for the initial configuration request. + const params = new BaseHttpParams(); + params.interceptorContext = { + excludedInterceptors: [InterceptorType.AuthToken, + InterceptorType.JSONContentType, + InterceptorType.Locale, + InterceptorType.ProgressIndication, + InterceptorType.RequestTiming, + InterceptorType.UnauthorizedResponse] + }; + + this.http.get('./assets/config/config.json', { params: params }).pipe(catchError((err: any, caught: Observable) => throwError(err))) + .pipe(takeUntil(this._destroyed)) + .subscribe( + (content: ConfigurationService) => { + this.parseResponse(content); + r(this); + }, + reason => e(reason)); + }); + } + + private parseResponse(config: any) { + this._server = config.Server; + this._app = config.App; + this._helpService = HelpService.parseValue(config.HelpService); + this._defaultCulture = config.defaultCulture; + this._loginProviders = LoginProviders.parseValue(config.loginProviders); + this._logging = Logging.parseValue(config.logging); + this._lockInterval = config.lockInterval; + this._guideAssets = config.guideAssets; + } + +} diff --git a/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts b/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts index 1c1c3af08..3d2610eb5 100644 --- a/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts +++ b/dmp-frontend/src/app/core/services/contact-support/contact-support.service.ts @@ -4,14 +4,16 @@ import { environment } from "../../../../environments/environment"; import { Injectable } from "@angular/core"; import { ContactEmail } from "../../model/contact/contact-email-form-model"; import { Observable } from "rxjs"; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class ContactSupportService { private actionUrl: string; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'contactEmail/'; + constructor(private http: BaseHttpService, + private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'contactEmail/'; } postEmail(contentEmail: ContactEmail): Observable { diff --git a/dmp-frontend/src/app/core/services/dashboard/dashboard.service.ts b/dmp-frontend/src/app/core/services/dashboard/dashboard.service.ts index 156a5d596..2046a1b20 100644 --- a/dmp-frontend/src/app/core/services/dashboard/dashboard.service.ts +++ b/dmp-frontend/src/app/core/services/dashboard/dashboard.service.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs'; import { environment } from '../../../../environments/environment'; import { DashboardStatisticsModel } from '../../model/dashboard/dashboard-statistics-model'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class DashboardService { @@ -11,8 +12,9 @@ export class DashboardService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'dashboard/'; + constructor(private http: BaseHttpService, + private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'dashboard/'; } getStatistics(): Observable { diff --git a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts index 2d19bdea8..c368b2638 100644 --- a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts +++ b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts @@ -14,6 +14,7 @@ import { InterceptorType } from '@common/http/interceptors/interceptor-type'; import { environment } from 'environments/environment'; import { Observable } from 'rxjs'; import { takeUntil } from "rxjs/operators"; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class DatasetProfileService extends BaseService { @@ -24,9 +25,9 @@ export class DatasetProfileService extends BaseService { private actionUrl: string; private headers = new HttpHeaders(); - constructor(private http: BaseHttpService, private httpClient: HttpClient) { + constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { super(); - this.actionUrl = environment.Server + 'admin/'; + this.actionUrl = configurationService.server + 'admin/'; } createForm(data) { diff --git a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts b/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts index ef43731f6..3f1b65a33 100644 --- a/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts +++ b/dmp-frontend/src/app/core/services/dataset-wizard/dataset-wizard.service.ts @@ -10,6 +10,7 @@ import { DatasetWizardModel } from '../../model/dataset/dataset-wizard'; import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria'; import { RequestItem } from '../../query/request-item'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class DatasetWizardService { @@ -17,8 +18,8 @@ export class DatasetWizardService { private actionUrl: string; private headers = new HttpHeaders(); - constructor(private http: BaseHttpService, private httpClient: HttpClient) { - this.actionUrl = environment.Server + 'datasetwizard/'; + constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'datasetwizard/'; } // public userDmps(criteria: RequestItem): Observable { diff --git a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts index 571e73f94..21d3f814a 100644 --- a/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts +++ b/dmp-frontend/src/app/core/services/dataset/dataset-external-autocomplete.service.ts @@ -5,6 +5,7 @@ import { environment } from '../../../../environments/environment'; import { DatasetExternalAutocompleteCriteria } from '../../query/dataset/daatset-external-autocomplete-criteria'; import { RequestItem } from '../../query/request-item'; import { DatasetProfileService } from '../dataset-profile/dataset-profile.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class DatasetExternalAutocompleteService { @@ -13,8 +14,9 @@ export class DatasetExternalAutocompleteService { constructor( private httpClient: HttpClient, - private datasetProfileService: DatasetProfileService) { - this.actionUrl = environment.Server + 'datasetwizard/'; + private datasetProfileService: DatasetProfileService, + private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'datasetwizard/'; } getDatasetProfileById(datasetProfileID) { @@ -22,7 +24,7 @@ export class DatasetExternalAutocompleteService { } queryAutocomplete(lookUpItem: RequestItem): Observable { - return this.httpClient.post(environment.Server + 'search/autocomplete', lookUpItem); + return this.httpClient.post(this.configurationService.server + 'search/autocomplete', lookUpItem); } } diff --git a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset.service.ts index 70b806bed..7b157833a 100644 --- a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts +++ b/dmp-frontend/src/app/core/services/dataset/dataset.service.ts @@ -9,14 +9,17 @@ import { DatasetCriteria } from '../../query/dataset/dataset-criteria'; import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria'; import { BaseHttpService } from '../http/base-http.service'; import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class DatasetService { private actionUrl: string; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'datasets/'; + constructor( + private http: BaseHttpService, + private configurationSevice: ConfigurationService) { + this.actionUrl = configurationSevice.server + 'datasets/'; } getPaged(dataTableRequest: DataTableRequest): Observable> { @@ -32,7 +35,7 @@ export class DatasetService { } getDatasetProfiles(dataTableRequest: DataTableRequest): Observable { - return this.http.post(environment.Server + 'datasetprofiles/getAll', dataTableRequest); + return this.http.post(this.configurationSevice.server + 'datasetprofiles/getAll', dataTableRequest); } getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest) { diff --git a/dmp-frontend/src/app/core/services/dmp/dmp-invitation.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp-invitation.service.ts index 3f7dca82f..a19663de8 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp-invitation.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp-invitation.service.ts @@ -7,6 +7,7 @@ import { DmpInvitation } from '../../model/dmp/invitation/dmp-invitation'; import { DmpInvitationUser } from '../../model/dmp/invitation/dmp-invitation-user'; import { DmpInvitationUserCriteria } from '../../query/dmp/dmp-invitation-user-criteria'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class DmpInvitationService { @@ -14,8 +15,8 @@ export class DmpInvitationService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'invite/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'invite/'; } public inviteDmpInvitationUsers(invitation: DmpInvitation): Observable { diff --git a/dmp-frontend/src/app/core/services/dmp/dmp-profile.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp-profile.service.ts index a6679c832..9b9f16f39 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp-profile.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp-profile.service.ts @@ -13,6 +13,7 @@ import { DatasetListingModel } from '../../model/dataset/dataset-listing'; import { BaseHttpParams } from '../../../../common/http/base-http-params'; import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type'; import { DmpProfileExternalAutocompleteCriteria } from '../../query/dmp/dmp-profile-external-autocomplete-criteria'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class DmpProfileService { @@ -20,8 +21,8 @@ export class DmpProfileService { private actionUrl: string; private headers = new HttpHeaders(); - constructor(private http: BaseHttpService, private httpClient: HttpClient) { - this.actionUrl = environment.Server + 'dmpprofile/'; + constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'dmpprofile/'; } getPaged(dataTableRequest: DataTableRequest): Observable> { diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index 0edd621a9..edafe2ba3 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -18,6 +18,7 @@ import { DmpCriteria } from '../../query/dmp/dmp-criteria'; import { ExploreDmpCriteriaModel } from '../../query/explore-dmp/explore-dmp-criteria'; import { RequestItem } from '../../query/request-item'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class DmpService { @@ -25,8 +26,8 @@ export class DmpService { private actionUrl: string; private headers = new HttpHeaders(); - constructor(private http: BaseHttpService, private httpClient: HttpClient) { - this.actionUrl = environment.Server + 'dmps/'; + constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'dmps/'; } diff --git a/dmp-frontend/src/app/core/services/email-confirmation/email-confirmation.service.ts b/dmp-frontend/src/app/core/services/email-confirmation/email-confirmation.service.ts index 29433964f..bae593b87 100644 --- a/dmp-frontend/src/app/core/services/email-confirmation/email-confirmation.service.ts +++ b/dmp-frontend/src/app/core/services/email-confirmation/email-confirmation.service.ts @@ -2,14 +2,15 @@ import { HttpHeaders } from '@angular/common/http'; import { Injectable } from "@angular/core"; import { environment } from "../../../../environments/environment"; import { BaseHttpService } from "../http/base-http.service"; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class EmailConfirmationService { private actioUrl: string; private headers: HttpHeaders - constructor(private http: BaseHttpService) { - this.actioUrl = environment.Server + 'emailConfirmation/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actioUrl = configurationService.server + 'emailConfirmation/'; } public emailConfirmation(token: string) { diff --git a/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts b/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts index 43a8d6f3c..5fd29f12b 100644 --- a/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/data-repository/extternal-data-repository.service.ts @@ -3,13 +3,14 @@ import { Observable } from 'rxjs'; import { environment } from '../../../../../environments/environment'; import { DataRepositoryModel } from '../../../model/data-repository/data-repository'; import { BaseHttpService } from '../../http/base-http.service'; +import { ConfigurationService } from '../../configuration/configuration.service'; @Injectable() export class ExternalDataRepositoryService { private actionUrl: string; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'external/datarepos'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'external/datarepos'; } create(dataRepoModel: DataRepositoryModel): Observable { diff --git a/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts b/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts index 19ef67bd5..260bb989a 100644 --- a/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/dataset/external-dataset.service.ts @@ -7,13 +7,14 @@ import { DataTableRequest } from '../../../model/data-table/data-table-request'; import { ExternalDatasetModel } from '../../../model/external-dataset/external-dataset'; import { ExternalDatasetCriteria } from '../../../query/external-dataset/external-dataset-criteria'; import { BaseHttpService } from '../../http/base-http.service'; +import { ConfigurationService } from '../../configuration/configuration.service'; @Injectable() export class ExternalDatasetService { private actionUrl: string; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'externaldatasets/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'externaldatasets/'; } create(externalDatasetModel: ExternalDatasetModel): Observable { diff --git a/dmp-frontend/src/app/core/services/external-sources/external-sources-configuration.service.ts b/dmp-frontend/src/app/core/services/external-sources/external-sources-configuration.service.ts index ab6247a64..f443a4004 100644 --- a/dmp-frontend/src/app/core/services/external-sources/external-sources-configuration.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/external-sources-configuration.service.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs'; import { environment } from '../../../../environments/environment'; import { ExternalSourcesConfiguration } from '../../model/external-sources/external-sources-configuration'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class ExternalSourcesConfigurationService { @@ -11,8 +12,8 @@ export class ExternalSourcesConfigurationService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'common/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'common/'; } public getExternalSourcesConfiguration(): Observable { diff --git a/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts b/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts index d8b5b76a4..471b6f954 100644 --- a/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts @@ -11,6 +11,7 @@ import { ResearcherCriteria } from '../../query/researcher/researcher-criteria'; import { ServiceCriteria } from '../../query/service/service-criteria'; import { TagCriteria } from '../../query/tag/tag-criteria'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class ExternalSourcesService { @@ -18,9 +19,9 @@ export class ExternalSourcesService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = environment.Server + 'external/'; + this.actionUrl = configurationService.server + 'external/'; this.headers = new HttpHeaders(); this.headers = this.headers.set('Content-Type', 'application/json'); @@ -58,7 +59,7 @@ export class ExternalSourcesService { } public searchDMPResearchers(requestItem: RequestItem): Observable { - return this.http.post(environment.Server + 'researchers/getWithExternal', requestItem, { headers: this.headers }); + return this.http.post(this.configurationService.server + 'researchers/getWithExternal', requestItem, { headers: this.headers }); } public searchDMPOrganizations(like: string): Observable { diff --git a/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts b/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts index 163390444..3b4e1ef3a 100644 --- a/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/registry/external-registry.service.ts @@ -3,13 +3,14 @@ import { Observable } from 'rxjs'; import { environment } from '../../../../../environments/environment'; import { RegistryModel } from '../../../model/registry/registry'; import { BaseHttpService } from '../../http/base-http.service'; +import { ConfigurationService } from '../../configuration/configuration.service'; @Injectable() export class ExternalRegistryService { private actionUrl: string; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'registries/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'registries/'; } create(registerModel: RegistryModel): Observable { diff --git a/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts b/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts index f51c9cd78..3651c83e4 100644 --- a/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/researcher/external-researcher.service.ts @@ -2,14 +2,15 @@ import { Injectable } from '@angular/core'; import { environment } from '../../../../../environments/environment'; import { ResearcherModel } from '../../../model/researcher/researcher'; import { BaseHttpService } from '../../http/base-http.service'; +import { ConfigurationService } from '../../configuration/configuration.service'; @Injectable() export class ExternalResearcherService { private actionUrl: string; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'researchers/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'researchers/'; } public createResearcher(researcher: ResearcherModel) { diff --git a/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts b/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts index 45e7e9193..3a5fa623e 100644 --- a/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/service/external-service.service.ts @@ -3,13 +3,14 @@ import { Observable } from 'rxjs'; import { environment } from '../../../../../environments/environment'; import { ServiceModel } from '../../../model/service/service'; import { BaseHttpService } from '../../http/base-http.service'; +import { ConfigurationService } from '../../configuration/configuration.service'; @Injectable() export class ExternalServiceService { private actionUrl: string; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'services/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'services/'; } create(serviceModel: ServiceModel): Observable { diff --git a/dmp-frontend/src/app/core/services/funder/funder.service.ts b/dmp-frontend/src/app/core/services/funder/funder.service.ts index 9b19c05d0..86430d977 100644 --- a/dmp-frontend/src/app/core/services/funder/funder.service.ts +++ b/dmp-frontend/src/app/core/services/funder/funder.service.ts @@ -6,14 +6,15 @@ import { BaseHttpService } from "../http/base-http.service"; import { environment } from '../../../../environments/environment'; import { FunderCriteria } from "../../query/funder/funder-criteria"; import { FunderModel } from "../../model/funder/funder"; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class FunderService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'funders/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'funders/'; } getWithExternal(requestItem: RequestItem): Observable { diff --git a/dmp-frontend/src/app/core/services/grant/grant-file-upload.service.ts b/dmp-frontend/src/app/core/services/grant/grant-file-upload.service.ts index a4cd0a646..78aa904d3 100644 --- a/dmp-frontend/src/app/core/services/grant/grant-file-upload.service.ts +++ b/dmp-frontend/src/app/core/services/grant/grant-file-upload.service.ts @@ -6,14 +6,15 @@ import { ContentFile } from '../../model/grant/grant-listing'; import { BaseHttpService } from '../http/base-http.service'; import { BaseHttpParams } from '../../../../common/http/base-http-params'; import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class GrantFileUploadService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'files/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'files/'; } uploadFile(formData: FormData): Observable { diff --git a/dmp-frontend/src/app/core/services/grant/grant.service.ts b/dmp-frontend/src/app/core/services/grant/grant.service.ts index 4da0cd913..01d80993f 100644 --- a/dmp-frontend/src/app/core/services/grant/grant.service.ts +++ b/dmp-frontend/src/app/core/services/grant/grant.service.ts @@ -8,6 +8,7 @@ import { GrantListingModel } from '../../model/grant/grant-listing'; import { GrantCriteria } from '../../query/grant/grant-criteria'; import { RequestItem } from '../../query/request-item'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() @@ -16,8 +17,8 @@ export class GrantService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'grants/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'grants/'; } getPaged(dataTableRequest: DataTableRequest, fieldsGroup?: string): Observable> { diff --git a/dmp-frontend/src/app/core/services/help-content/help-content.service.ts b/dmp-frontend/src/app/core/services/help-content/help-content.service.ts index f0397b5b6..5682d934f 100644 --- a/dmp-frontend/src/app/core/services/help-content/help-content.service.ts +++ b/dmp-frontend/src/app/core/services/help-content/help-content.service.ts @@ -8,14 +8,16 @@ import { catchError, map } from 'rxjs/operators'; import { environment } from '../../../../environments/environment'; import { PageHelpContent } from '../../model/help-content/page-help-content'; import { CachedContentItem } from './cached-content-item'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class HelpContentService { - private _helpServiceUrl = environment.HelpService.Url; + private _helpServiceUrl: string; cache = new Map(); - constructor(private http: HttpClient) { + constructor(private http: HttpClient, private configurationService: ConfigurationService) { + this._helpServiceUrl = configurationService.helpService.url; } // getActivePageContent(route: string) { diff --git a/dmp-frontend/src/app/core/services/language/language.service.ts b/dmp-frontend/src/app/core/services/language/language.service.ts index 4999d6f8a..ad69aeebc 100644 --- a/dmp-frontend/src/app/core/services/language/language.service.ts +++ b/dmp-frontend/src/app/core/services/language/language.service.ts @@ -5,19 +5,23 @@ import { Observable } from 'rxjs'; import { HttpResponse, HttpClient } from '@angular/common/http'; import { BaseHttpService } from '../http/base-http.service'; import { Language } from '@app/models/language/Language'; +import { ConfigurationService } from '../configuration/configuration.service'; const availableLanguages: any[] = require('../../../../assets/resources/language.json'); @Injectable() export class LanguageService { private currentLanguage: string = 'en'; - private languageUrl = `${environment.Server}language`; + private languageUrl : string; constructor( private translate: TranslateService, private http: HttpClient, - private baseHttp: BaseHttpService - ) {} + private baseHttp: BaseHttpService, + private configurationService: ConfigurationService + ) { + this.languageUrl = `${configurationService.server}language`; + } public changeLanguage(lang: string) { this.currentLanguage = lang; diff --git a/dmp-frontend/src/app/core/services/language/server.loader.ts b/dmp-frontend/src/app/core/services/language/server.loader.ts index a9030e633..f97d19433 100644 --- a/dmp-frontend/src/app/core/services/language/server.loader.ts +++ b/dmp-frontend/src/app/core/services/language/server.loader.ts @@ -2,14 +2,19 @@ import { TranslateLoader } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { environment } from 'environments/environment'; import { HttpClient } from '@angular/common/http'; +import { ConfigurationService } from '../configuration/configuration.service'; export class TranslateServerLoader implements TranslateLoader{ - private languageUrl = `${environment.Server}language`; + private languageUrl: string; constructor( - private http: HttpClient - ) {} + private http: HttpClient, + private configurationService: ConfigurationService + ) { + + } getTranslation(lang: string): Observable { + this.languageUrl = `${this.configurationService.server}language`; return this.http.get(`${this.languageUrl}/${lang}`); } } diff --git a/dmp-frontend/src/app/core/services/lock/lock.service.ts b/dmp-frontend/src/app/core/services/lock/lock.service.ts index 0348386c4..a816163e5 100644 --- a/dmp-frontend/src/app/core/services/lock/lock.service.ts +++ b/dmp-frontend/src/app/core/services/lock/lock.service.ts @@ -4,6 +4,7 @@ import { BaseHttpService } from '../http/base-http.service'; import { environment } from 'environments/environment'; import { Observable } from 'rxjs'; import { LockModel } from '@app/core/model/lock/lock.model'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class LockService { @@ -11,8 +12,8 @@ export class LockService { private actionUrl: string; private headers = new HttpHeaders(); - constructor(private http: BaseHttpService, private httpClient: HttpClient) { - this.actionUrl = environment.Server + 'lock/'; + constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'lock/'; } checkLockStatus(id: string): Observable { diff --git a/dmp-frontend/src/app/core/services/logging/logging-service.ts b/dmp-frontend/src/app/core/services/logging/logging-service.ts index 1da0dc0cc..b8d8a2629 100644 --- a/dmp-frontend/src/app/core/services/logging/logging-service.ts +++ b/dmp-frontend/src/app/core/services/logging/logging-service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { environment } from '../../../../environments/environment'; +import { ConfigurationService } from '../configuration/configuration.service'; export enum LogLevel { Error = 'error', @@ -16,7 +17,7 @@ export class LoggingService { private loggingLevels: LogLevel[]; private loggingOutputs: LogOutput[] = []; - constructor() { + constructor(private configurationService: ConfigurationService) { } @@ -37,7 +38,7 @@ export class LoggingService { } init() { - this.loggingLevels = environment.logging.logLevels as LogLevel[]; + this.loggingLevels = this.configurationService.logging.loglevels as LogLevel[]; this.loggingOutputs.push((level: LogLevel, ...objects: any[]) => { switch (level) { @@ -62,7 +63,7 @@ export class LoggingService { private log(level: LogLevel, logs: any[]) { if (!this.loggingLevels) { this.init(); } - if (environment.logging.enabled && this.loggingLevels.includes(level)) { + if (this.configurationService.logging.enabled && this.loggingLevels.includes(level)) { this.loggingOutputs.forEach((output) => output.apply(output, [level, logs])); } } diff --git a/dmp-frontend/src/app/core/services/organisation/organisation.service.ts b/dmp-frontend/src/app/core/services/organisation/organisation.service.ts index a927bfcfa..274968b86 100644 --- a/dmp-frontend/src/app/core/services/organisation/organisation.service.ts +++ b/dmp-frontend/src/app/core/services/organisation/organisation.service.ts @@ -7,6 +7,7 @@ import { DataTableData } from "../../model/data-table/data-table-data"; import { OrganizationModel } from "../../model/organisation/organization"; import { OrganisationCriteria } from "../../query/organisation/organisation-criteria"; import { DataTableRequest } from "../../model/data-table/data-table-request"; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class OrganisationService { @@ -14,9 +15,9 @@ export class OrganisationService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = environment.Server; + this.actionUrl = configurationService.server; this.headers = new HttpHeaders(); this.headers = this.headers.set('Content-Type', 'application/json'); diff --git a/dmp-frontend/src/app/core/services/project/project.service.ts b/dmp-frontend/src/app/core/services/project/project.service.ts index 625be3581..0532f8c95 100644 --- a/dmp-frontend/src/app/core/services/project/project.service.ts +++ b/dmp-frontend/src/app/core/services/project/project.service.ts @@ -7,14 +7,15 @@ import { BaseHttpService } from "../http/base-http.service"; import { environment } from '../../../../environments/environment'; import { ProjectCriteria } from "../../query/project/project-criteria"; import { ProjectModel } from "../../model/project/project"; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class ProjectService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'projects/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'projects/'; } getWithExternal(requestItem: RequestItem): Observable { diff --git a/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts b/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts index 28174bb11..4a6d3579d 100644 --- a/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts +++ b/dmp-frontend/src/app/core/services/quick-wizard/quick-wizard.service.ts @@ -5,14 +5,15 @@ import { environment } from '../../../../environments/environment'; import { QuickWizardEditorWizardModel } from '../../../ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model'; import { BaseHttpService } from '../http/base-http.service'; import { DatasetCreateWizardModel } from '../../../ui/dataset-create-wizard/dataset-create-wizard.model'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class QuickWizardService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { - this.actionUrl = environment.Server + 'quick-wizard/'; + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { + this.actionUrl = configurationService.server + 'quick-wizard/'; } createQuickWizard(quickWizard: QuickWizardEditorWizardModel): Observable { diff --git a/dmp-frontend/src/app/core/services/search-bar/search-bar.service.ts b/dmp-frontend/src/app/core/services/search-bar/search-bar.service.ts index 3e2cd1876..db5d6341e 100644 --- a/dmp-frontend/src/app/core/services/search-bar/search-bar.service.ts +++ b/dmp-frontend/src/app/core/services/search-bar/search-bar.service.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs'; import { environment } from '../../../../environments/environment'; import { SearchBarItem } from '../../model/dashboard/search-bar-item'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class SearchBarService { @@ -11,9 +12,9 @@ export class SearchBarService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = environment.Server + 'dashboard/'; + this.actionUrl = configurationService.server + 'dashboard/'; } search(like: string): Observable { diff --git a/dmp-frontend/src/app/core/services/user-guide/user-guide.service.ts b/dmp-frontend/src/app/core/services/user-guide/user-guide.service.ts index 4a4133c10..abdf49738 100644 --- a/dmp-frontend/src/app/core/services/user-guide/user-guide.service.ts +++ b/dmp-frontend/src/app/core/services/user-guide/user-guide.service.ts @@ -4,21 +4,25 @@ import { environment } from 'environments/environment'; import { Observable } from 'rxjs'; import { HttpResponse, HttpClient } from '@angular/common/http'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class UserGuideService { - private userGuideUrl = `${environment.Server}userguide`; + private userGuideUrl : string; constructor( private translate: TranslateService, private http: HttpClient, - private baseHttp: BaseHttpService - ) {} + private baseHttp: BaseHttpService, + private configurationService: ConfigurationService + ) { + this.userGuideUrl = `${configurationService.server}userguide`; + } public getUserGuide(): Observable> { return this.http.get(`${this.userGuideUrl}/current`, { responseType: 'blob', observe: 'response', headers: {'Content-type': 'text/html', 'Accept': 'text/html', - 'Access-Control-Allow-Origin': environment.App, + 'Access-Control-Allow-Origin': this.configurationService.app, 'Access-Control-Allow-Credentials': 'true'} }); } diff --git a/dmp-frontend/src/app/core/services/user/user.service.ts b/dmp-frontend/src/app/core/services/user/user.service.ts index b4c8659a2..21f6381b2 100644 --- a/dmp-frontend/src/app/core/services/user/user.service.ts +++ b/dmp-frontend/src/app/core/services/user/user.service.ts @@ -7,6 +7,7 @@ import { DataTableRequest } from '../../model/data-table/data-table-request'; import { UserListingModel } from '../../model/user/user-listing'; import { UserCriteria } from '../../query/user/user-criteria'; import { BaseHttpService } from '../http/base-http.service'; +import { ConfigurationService } from '../configuration/configuration.service'; @Injectable() export class UserService { @@ -14,9 +15,9 @@ export class UserService { private actionUrl: string; private headers: HttpHeaders; - constructor(private http: BaseHttpService) { + constructor(private http: BaseHttpService, private configurationService: ConfigurationService) { - this.actionUrl = environment.Server + 'user/'; + this.actionUrl = configurationService.server + 'user/'; } getPaged(dataTableRequest: DataTableRequest): Observable> { diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts index b7cf3cdd0..6ee859cf1 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts @@ -20,6 +20,7 @@ import { environment } from 'environments/environment'; import * as FileSaver from 'file-saver'; import { Observable, of as observableOf } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ @@ -33,7 +34,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie viewOnly = false; dmpProfileModel: DmpProfileEditorModel; formGroup: FormGroup = null; - host = environment.Server; + host: string; dmpProfileId: string; breadCrumbs: Observable; @@ -44,9 +45,11 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie private language: TranslateService, private enumUtils: EnumUtils, private uiNotificationService: UiNotificationService, - private formService: FormService + private formService: FormService, + private configurationService: ConfigurationService ) { super(); + this.host = configurationService.server; } ngAfterViewInit() { diff --git a/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.ts b/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.ts index bdba62c6c..a5e2948f8 100644 --- a/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/b2access/b2access-login.component.ts @@ -7,6 +7,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { BaseComponent } from '@common/base/base.component'; import { environment } from 'environments/environment'; import { takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-b2access-login', @@ -20,7 +21,8 @@ export class B2AccessLoginComponent extends BaseComponent implements OnInit { private route: ActivatedRoute, private authService: AuthService, private loginService: LoginService, - private httpClient: HttpClient + private httpClient: HttpClient, + private configurationService: ConfigurationService ) { super(); } @@ -36,10 +38,10 @@ export class B2AccessLoginComponent extends BaseComponent implements OnInit { } public b2AccessGetAuthCode() { - window.location.href = environment.loginProviders.b2accessConfiguration.oauthUrl - + '?response_type=code&client_id=' + environment.loginProviders.b2accessConfiguration.clientId - + '&redirect_uri=' + environment.loginProviders.b2accessConfiguration.redirectUri - + '&state=' + environment.loginProviders.b2accessConfiguration.state + window.location.href = this.configurationService.loginProviders.b2accessConfiguration.oauthUrl + + '?response_type=code&client_id=' + this.configurationService.loginProviders.b2accessConfiguration.clientId + + '&redirect_uri=' + this.configurationService.loginProviders.b2accessConfiguration.redirectUri + + '&state=' + this.configurationService.loginProviders.b2accessConfiguration.state + '&scope=USER_PROFILE'; } @@ -47,7 +49,7 @@ export class B2AccessLoginComponent extends BaseComponent implements OnInit { let headers = new HttpHeaders(); headers = headers.set('Content-Type', 'application/json'); headers = headers.set('Accept', 'application/json'); - this.httpClient.post(environment.Server + 'auth/b2AccessRequestToken', { code: code }, { headers: headers }) + this.httpClient.post(this.configurationService.server + 'auth/b2AccessRequestToken', { code: code }, { headers: headers }) .pipe(takeUntil(this._destroyed)) .subscribe((data: any) => { this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.B2Access, data: null }) diff --git a/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.ts b/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.ts index 95f170f8d..69d35a0d4 100644 --- a/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/configurable-login/configurable-login.component.ts @@ -9,6 +9,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { BaseComponent } from '@common/base/base.component'; import { environment } from 'environments/environment'; import { takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-configurable-login', @@ -33,7 +34,8 @@ export class ConfigurableLoginComponent extends BaseComponent implements OnInit private authService: AuthService, private router: Router, private httpClient: HttpClient, - private providers: ConfigurableProvidersService + private providers: ConfigurableProvidersService, + private configurationService: ConfigurationService ) { super(); } @@ -80,7 +82,7 @@ export class ConfigurableLoginComponent extends BaseComponent implements OnInit if (state !== this.provider.state) { this.router.navigate(['/login']) } - this.httpClient.post(environment.Server + 'auth/configurableProviderRequestToken', { code: code, provider: AuthProvider.Configurable, configurableLoginId: this.providerId }) + this.httpClient.post(this.configurationService.server + 'auth/configurableProviderRequestToken', { code: code, provider: AuthProvider.Configurable, configurableLoginId: this.providerId }) .pipe(takeUntil(this._destroyed)) .subscribe((data: any) => { this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.Configurable, data: { configurableLoginId: this.provider.configurableLoginId } }) diff --git a/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.ts b/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.ts index 4d6acf28e..6b87652c8 100644 --- a/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/linkedin-login/linkedin-login.component.ts @@ -7,6 +7,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { BaseComponent } from '@common/base/base.component'; import { environment } from 'environments/environment'; import { takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-linkedin-login', @@ -21,7 +22,8 @@ export class LinkedInLoginComponent extends BaseComponent implements OnInit { private loginService: LoginService, private authService: AuthService, private router: Router, - private httpClient: HttpClient + private httpClient: HttpClient, + private configurationService: ConfigurationService ) { super(); } @@ -37,18 +39,18 @@ export class LinkedInLoginComponent extends BaseComponent implements OnInit { } public linkedinAuthorize() { - window.location.href = environment.loginProviders.linkedInConfiguration.oauthUrl - + '?response_type=code&client_id=' + environment.loginProviders.linkedInConfiguration.clientId - + '&redirect_uri=' + environment.loginProviders.linkedInConfiguration.redirectUri - + '&state=' + environment.loginProviders.linkedInConfiguration.state + window.location.href = this.configurationService.loginProviders.linkedInConfiguration.oauthUrl + + '?response_type=code&client_id=' + this.configurationService.loginProviders.linkedInConfiguration.clientId + + '&redirect_uri=' + this.configurationService.loginProviders.linkedInConfiguration.redirectUri + + '&state=' + this.configurationService.loginProviders.linkedInConfiguration.state + '&scope=r_emailaddress'; } public linkedInLoginUser(code: string, state: string) { - if (state !== environment.loginProviders.linkedInConfiguration.state) { + if (state !== this.configurationService.loginProviders.linkedInConfiguration.state) { this.router.navigate(['/login']); } - this.httpClient.post(environment.Server + 'auth/linkedInRequestToken', { code: code, provider: AuthProvider.LinkedIn }) + this.httpClient.post(this.configurationService.server + 'auth/linkedInRequestToken', { code: code, provider: AuthProvider.LinkedIn }) .pipe(takeUntil(this._destroyed)) .subscribe((data: any) => { this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.LinkedIn, data: null }) diff --git a/dmp-frontend/src/app/ui/auth/login/login.component.ts b/dmp-frontend/src/app/ui/auth/login/login.component.ts index 3f2662445..d439a234f 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.component.ts @@ -8,6 +8,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { BaseComponent } from '@common/base/base.component'; import { environment } from 'environments/environment'; import { takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; /// /// @@ -31,7 +32,8 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn private route: ActivatedRoute, private loginService: LoginService, private authService: AuthService, - public configurableProviderService: ConfigurableProvidersService + public configurableProviderService: ConfigurableProvidersService, + private configurationService: ConfigurationService ) { super(); } ngOnInit(): void { @@ -110,21 +112,21 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn } public hasProvider(provider: AuthProvider) { - for (let i = 0; i < environment.loginProviders.enabled.length; i++) { - if (provider === environment.loginProviders.enabled[i]) { return this.isProviderProperlyConfigured(provider); } + for (let i = 0; i < this.configurationService.loginProviders.enabled.length; i++) { + if (provider === this.configurationService.loginProviders.enabled[i]) { return this.isProviderProperlyConfigured(provider); } } return false; } private isProviderProperlyConfigured(provider: AuthProvider) { switch (provider) { - case AuthProvider.Facebook: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.facebookConfiguration); - case AuthProvider.Google: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.googleConfiguration); - case AuthProvider.LinkedIn: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.linkedInConfiguration); - case AuthProvider.Twitter: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.twitterConfiguration); - case AuthProvider.B2Access: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.b2accessConfiguration); - case AuthProvider.ORCID: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.orcidConfiguration); - case AuthProvider.OpenAire: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.openAireConfiguration); + case AuthProvider.Facebook: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.facebookConfiguration); + case AuthProvider.Google: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.googleConfiguration); + case AuthProvider.LinkedIn: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.linkedInConfiguration); + case AuthProvider.Twitter: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.twitterConfiguration); + case AuthProvider.B2Access: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.b2accessConfiguration); + case AuthProvider.ORCID: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.orcidConfiguration); + case AuthProvider.OpenAire: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.openAireConfiguration); default: throw new Error('Unsupported Provider Type'); } } @@ -140,7 +142,7 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn private initializeGoogleOauth(): void { gapi.load('auth2', () => { this.auth2 = gapi.auth2.init({ - client_id: environment.loginProviders.googleConfiguration.clientId, + client_id: this.configurationService.loginProviders.googleConfiguration.clientId, scope: 'profile email' }); this.attachGoogleSignΙn(document.getElementById('googleSignInButton')); @@ -169,7 +171,7 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn */ private initializeFacebookOauth(): void { FB.init({ - appId: environment.loginProviders.facebookConfiguration.clientId, + appId: this.configurationService.loginProviders.facebookConfiguration.clientId, cookie: false, xfbml: true, version: 'v2.8' diff --git a/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.ts b/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.ts index d621cd22a..f54db7cc6 100644 --- a/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/openaire-login/openaire-login.component.ts @@ -7,6 +7,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { BaseComponent } from '@common/base/base.component'; import { environment } from 'environments/environment'; import { takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-openaire-login', @@ -20,7 +21,8 @@ export class OpenAireLoginComponent extends BaseComponent implements OnInit { private loginService: LoginService, private authService: AuthService, private router: Router, - private httpClient: HttpClient + private httpClient: HttpClient, + private configurationService: ConfigurationService ) { super(); } @@ -36,18 +38,18 @@ export class OpenAireLoginComponent extends BaseComponent implements OnInit { } public openaireAuthorize() { - window.location.href = environment.loginProviders.openAireConfiguration.oauthUrl - + '?response_type=code&client_id=' + environment.loginProviders.openAireConfiguration.clientId - + '&redirect_uri=' + environment.loginProviders.openAireConfiguration.redirectUri - + '&state=' + environment.loginProviders.openAireConfiguration.state + window.location.href = this.configurationService.loginProviders.openAireConfiguration.oauthUrl + + '?response_type=code&client_id=' + this.configurationService.loginProviders.openAireConfiguration.clientId + + '&redirect_uri=' + this.configurationService.loginProviders.openAireConfiguration.redirectUri + + '&state=' + this.configurationService.loginProviders.openAireConfiguration.state + '&scope=openid profile email'; } public openaireLoginUser(code: string, state: string) { - if (state !== environment.loginProviders.openAireConfiguration.state) { + if (state !== this.configurationService.loginProviders.openAireConfiguration.state) { this.router.navigate(['/login']) } - this.httpClient.post(environment.Server + 'auth/openAireRequestToken', { code: code, provider: AuthProvider.OpenAire }) + this.httpClient.post(this.configurationService.server + 'auth/openAireRequestToken', { code: code, provider: AuthProvider.OpenAire }) .pipe(takeUntil(this._destroyed)) .subscribe((data: any) => { this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.OpenAire, data: null }) diff --git a/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.ts b/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.ts index ea7b24e93..bfa846180 100644 --- a/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/orcid-login/orcid-login.component.ts @@ -9,6 +9,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { BaseComponent } from '@common/base/base.component'; import { environment } from 'environments/environment'; import { takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-orcid-login', @@ -26,7 +27,8 @@ export class OrcidLoginComponent extends BaseComponent implements OnInit { private route: ActivatedRoute, private authService: AuthService, private loginService: LoginService, - private httpClient: HttpClient + private httpClient: HttpClient, + private configurationService: ConfigurationService ) { super(); this.orcidUser = new OrcidUser; @@ -43,18 +45,18 @@ export class OrcidLoginComponent extends BaseComponent implements OnInit { } public orcidAccessGetAuthCode() { - window.location.href = environment.loginProviders.orcidConfiguration.oauthUrl + window.location.href = this.configurationService.loginProviders.orcidConfiguration.oauthUrl + '?client_id=' - + environment.loginProviders.orcidConfiguration.clientId + + this.configurationService.loginProviders.orcidConfiguration.clientId + '&response_type=code&scope=/authenticate&redirect_uri=' - + environment.loginProviders.orcidConfiguration.redirectUri; + + this.configurationService.loginProviders.orcidConfiguration.redirectUri; } public orcidLogin(code: string) { let headers = new HttpHeaders(); headers = headers.set('Content-Type', 'application/json'); headers = headers.set('Accept', 'application/json'); - this.httpClient.post(environment.Server + 'auth/orcidRequestToken', { code: code }, { headers: headers }) + this.httpClient.post(this.configurationService.server + 'auth/orcidRequestToken', { code: code }, { headers: headers }) .pipe(takeUntil(this._destroyed)) .subscribe((responseData: any) => { this.orcidUser.orcidId = responseData.payload.orcidId diff --git a/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.ts b/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.ts index 66729e3c6..fdf7f7657 100644 --- a/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/twitter-login/twitter-login.component.ts @@ -8,6 +8,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service'; import { BaseComponent } from '@common/base/base.component'; import { environment } from 'environments/environment'; import { takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-twitter-login', @@ -21,7 +22,8 @@ export class TwitterLoginComponent extends BaseComponent implements OnInit { private route: ActivatedRoute, private authService: AuthService, private httpClient: BaseHttpService, - private loginService: LoginService + private loginService: LoginService, + private configurationService: ConfigurationService ) { super(); } @@ -40,10 +42,10 @@ export class TwitterLoginComponent extends BaseComponent implements OnInit { let headers = new HttpHeaders(); headers = headers.set('Content-Type', 'application/json'); headers = headers.set('Accept', 'application/json'); - this.httpClient.get(environment.Server + 'auth/twitterRequestToken', { headers: headers }) + this.httpClient.get(this.configurationService.server + 'auth/twitterRequestToken', { headers: headers }) .pipe(takeUntil(this._destroyed)) .subscribe((data: any) => { - window.location.href = environment.loginProviders.twitterConfiguration.oauthUrl + '?oauth_token=' + data.value; + window.location.href = this.configurationService.loginProviders.twitterConfiguration.oauthUrl + '?oauth_token=' + data.value; }); } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index 2e66c4bce..cbf4d22a8 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -40,6 +40,7 @@ import { Guid } from '@common/types/guid'; import { isNullOrUndefined } from 'util'; import { AuthService } from '@app/core/services/auth/auth.service'; import { environment } from 'environments/environment'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-dataset-wizard-component', @@ -85,7 +86,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr private formService: FormService, private lockService: LockService, private location: Location, - private authService: AuthService + private authService: AuthService, + private configurationService: ConfigurationService ) { super(); } @@ -152,7 +154,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { this.lock.id = Guid.parse(result); - interval(environment.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); }); } // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. @@ -259,7 +261,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { this.lock.id = Guid.parse(result); - interval(environment.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); }); } // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 2470b70e1..b74092256 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -42,6 +42,7 @@ import { LockModel } from '@app/core/model/lock/lock.model'; import { Guid } from '@common/types/guid'; import { isNullOrUndefined } from 'util'; import { environment } from 'environments/environment'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-dmp-editor-component', @@ -82,7 +83,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC private authentication: AuthService, private authService: AuthService, private formService: FormService, - private lockService: LockService + private lockService: LockService, + private configurationService: ConfigurationService ) { super(); } @@ -139,7 +141,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { this.lock.id = Guid.parse(result); - interval(environment.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); }); } // if (!this.isAuthenticated) { @@ -198,7 +200,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => { this.lock.id = Guid.parse(result); - interval(environment.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); + interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock()); }); } }) diff --git a/dmp-frontend/src/app/ui/grant/editor/grant-editor.component.ts b/dmp-frontend/src/app/ui/grant/editor/grant-editor.component.ts index 428cf5a1d..eb5325f52 100644 --- a/dmp-frontend/src/app/ui/grant/editor/grant-editor.component.ts +++ b/dmp-frontend/src/app/ui/grant/editor/grant-editor.component.ts @@ -20,6 +20,7 @@ import { TranslateService } from '@ngx-translate/core'; import { environment } from 'environments/environment'; import { Observable, of as observableOf } from 'rxjs'; import { map, takeUntil } from 'rxjs/operators'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ @@ -33,7 +34,7 @@ export class GrantEditorComponent extends BaseComponent implements OnInit, IBrea isNew = true; grant: GrantEditorModel; formGroup: FormGroup = null; - host = environment.Server; + host: string; editMode = false; sizeError = false; maxFileSize: number = 1048576; @@ -46,9 +47,11 @@ export class GrantEditorComponent extends BaseComponent implements OnInit, IBrea private dialog: MatDialog, private grantFileUploadService: GrantFileUploadService, private uiNotificationService: UiNotificationService, - private formService: FormService + private formService: FormService, + private configurationService: ConfigurationService ) { super(); + this.host = this.configurationService.server; } ngOnInit() { diff --git a/dmp-frontend/src/app/ui/user-guide-editor/user-guide-editor.component.ts b/dmp-frontend/src/app/ui/user-guide-editor/user-guide-editor.component.ts index 142dc7192..e4e1b1aa3 100644 --- a/dmp-frontend/src/app/ui/user-guide-editor/user-guide-editor.component.ts +++ b/dmp-frontend/src/app/ui/user-guide-editor/user-guide-editor.component.ts @@ -8,6 +8,7 @@ import { TranslateService } from '@ngx-translate/core'; import { Router } from '@angular/router'; import { isNullOrUndefined } from 'util'; import { environment } from 'environments/environment'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Component({ selector: 'app-user-guide-editor', @@ -22,6 +23,7 @@ export class UserGuideEditorComponent extends BaseComponent implements OnInit { private uiNotificationService: UiNotificationService, private translate: TranslateService, private router: Router, + private configurationService: ConfigurationService ) { super(); } ngOnInit() { @@ -40,7 +42,7 @@ export class UserGuideEditorComponent extends BaseComponent implements OnInit { } private parseText(source: string): string { - source = source.replace(/src="images/g, `src="${environment.guideAssets}`); + source = source.replace(/src="images/g, `src="${this.configurationService.guideAssets}`); source = source.replace(/\r\n +>/g, '>\n'); const brokenElements = Array.from(new Set(source.match(/<\/\w+\d* >/g))); if (!isNullOrUndefined(brokenElements)) { diff --git a/dmp-frontend/src/assets/config/config.json b/dmp-frontend/src/assets/config/config.json new file mode 100644 index 000000000..7298e06b8 --- /dev/null +++ b/dmp-frontend/src/assets/config/config.json @@ -0,0 +1,48 @@ +{ + "production": false, + "Server": "http://localhost:8080/api/", + "App": "http://localhost:4200/", + "HelpService": { + "Enabled": false, + "Url": "localhost:5000/" + }, + "defaultCulture": "en-US", + "loginProviders": { + "enabled": [1, 2, 3, 4, 5, 6, 7, 8], + "facebookConfiguration": { "clientId": "" }, + "googleConfiguration": { "clientId": "" }, + "linkedInConfiguration": { + "clientId": "", + "oauthUrl": "https://www.linkedin.com/oauth/v2/authorization", + "redirectUri": "http://localhost:4200/login/linkedin", + "state": "987654321" + }, + "twitterConfiguration": { + "clientId": "", + "oauthUrl": "https://api.twitter.com/oauth/authenticate" + }, + "b2accessConfiguration": { + "clientId": "", + "oauthUrl": "https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz", + "redirectUri": "http://localhost:4200/api/oauth/authorized/b2access", + "state": "" + }, + "orcidConfiguration": { + "clientId": "", + "oauthUrl": "https://orcid.org/oauth/authorize", + "redirectUri": "http://localhost:4200/login/external/orcid" + }, + "openAireConfiguration": { + "clientId": "", + "oauthUrl": "", + "redirectUri": "", + "state": "987654321" + } + }, + "logging": { + "enabled": true, + "logLevels": ["debug", "info", "warning", "error"] + }, + "lockInterval": 60000, + "guideAssets": "assets/images/guide" +} diff --git a/dmp-frontend/src/common/http/interceptors/auth-token.interceptor.ts b/dmp-frontend/src/common/http/interceptors/auth-token.interceptor.ts index 41b5443b9..7fc64d108 100644 --- a/dmp-frontend/src/common/http/interceptors/auth-token.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/auth-token.interceptor.ts @@ -4,12 +4,14 @@ import { Observable } from 'rxjs'; import { BaseInterceptor } from './base.interceptor'; import { InterceptorType } from './interceptor-type'; import { AuthService } from '../../../app/core/services/auth/auth.service'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Injectable() export class AuthTokenInterceptor extends BaseInterceptor { constructor( - private authService: AuthService) { super(); } + private authService: AuthService, + configurationService: ConfigurationService) { super(configurationService); } get type(): InterceptorType { return InterceptorType.AuthToken; } diff --git a/dmp-frontend/src/common/http/interceptors/base.interceptor.ts b/dmp-frontend/src/common/http/interceptors/base.interceptor.ts index 13374a21f..89e48679b 100644 --- a/dmp-frontend/src/common/http/interceptors/base.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/base.interceptor.ts @@ -3,10 +3,11 @@ import { Observable } from 'rxjs'; import { BaseHttpParams } from '../base-http-params'; import { InterceptorType } from './interceptor-type'; import { environment } from '../../../environments/environment'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; export abstract class BaseInterceptor implements HttpInterceptor { - constructor() { } + constructor(public configurationService: ConfigurationService) { } abstract type: InterceptorType; abstract interceptRequest(req: HttpRequest, next: HttpHandler): Observable>; @@ -25,6 +26,6 @@ export abstract class BaseInterceptor implements HttpInterceptor { } return (req.params instanceof BaseHttpParams && req.params.interceptorContext && Array.isArray(req.params.interceptorContext.interceptAllRequests) && req.params.interceptorContext.interceptAllRequests.includes(this.type)) - || req.url.startsWith(environment.Server); + || req.url.startsWith(this.configurationService.server); } } diff --git a/dmp-frontend/src/common/http/interceptors/json.interceptor.ts b/dmp-frontend/src/common/http/interceptors/json.interceptor.ts index c5bdfb4f0..d96718ee7 100644 --- a/dmp-frontend/src/common/http/interceptors/json.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/json.interceptor.ts @@ -3,12 +3,14 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { BaseInterceptor } from './base.interceptor'; import { InterceptorType } from './interceptor-type'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Injectable() export class JsonInterceptor extends BaseInterceptor { constructor( - ) { super(); } + configurationService: ConfigurationService + ) { super(configurationService); } get type(): InterceptorType { return InterceptorType.JSONContentType; } diff --git a/dmp-frontend/src/common/http/interceptors/locale.interceptor.ts b/dmp-frontend/src/common/http/interceptors/locale.interceptor.ts index 5df39499a..368333760 100644 --- a/dmp-frontend/src/common/http/interceptors/locale.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/locale.interceptor.ts @@ -4,12 +4,14 @@ import { TranslateService } from '@ngx-translate/core'; import { Observable } from 'rxjs'; import { BaseInterceptor } from './base.interceptor'; import { InterceptorType } from './interceptor-type'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Injectable() export class LocaleInterceptor extends BaseInterceptor { constructor( - private language: TranslateService) { super(); } + private language: TranslateService, + configurationService: ConfigurationService) { super(configurationService); } get type(): InterceptorType { return InterceptorType.Locale; } diff --git a/dmp-frontend/src/common/http/interceptors/progress-indication.interceptor.ts b/dmp-frontend/src/common/http/interceptors/progress-indication.interceptor.ts index 939d25f41..a86defa8a 100644 --- a/dmp-frontend/src/common/http/interceptors/progress-indication.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/progress-indication.interceptor.ts @@ -5,12 +5,14 @@ import { finalize } from 'rxjs/operators'; import { ProgressIndicationService } from '../../../app/core/services/progress-indication/progress-indication-service'; import { BaseInterceptor } from './base.interceptor'; import { InterceptorType } from './interceptor-type'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Injectable() export class ProgressIndicationInterceptor extends BaseInterceptor { constructor( - private progressIndicationService: ProgressIndicationService) { super(); } + private progressIndicationService: ProgressIndicationService, + configurationService: ConfigurationService) { super(configurationService); } get type(): InterceptorType { return InterceptorType.ProgressIndication; } diff --git a/dmp-frontend/src/common/http/interceptors/request-timing.interceptor.ts b/dmp-frontend/src/common/http/interceptors/request-timing.interceptor.ts index 295701614..5b3615152 100644 --- a/dmp-frontend/src/common/http/interceptors/request-timing.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/request-timing.interceptor.ts @@ -5,12 +5,14 @@ import { tap } from 'rxjs/operators'; import { LoggingService } from '../../../app/core/services/logging/logging-service'; import { BaseInterceptor } from './base.interceptor'; import { InterceptorType } from './interceptor-type'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Injectable() export class RequestTimingInterceptor extends BaseInterceptor { constructor( - private logger: LoggingService) { super(); } + private logger: LoggingService, + configurationService: ConfigurationService) { super(configurationService); } get type(): InterceptorType { return InterceptorType.RequestTiming; } diff --git a/dmp-frontend/src/common/http/interceptors/response-payload.interceptor.ts b/dmp-frontend/src/common/http/interceptors/response-payload.interceptor.ts index f34b273d4..dab8544f8 100644 --- a/dmp-frontend/src/common/http/interceptors/response-payload.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/response-payload.interceptor.ts @@ -5,13 +5,15 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { BaseInterceptor } from './base.interceptor'; import { InterceptorType } from './interceptor-type'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Injectable() export class ResponsePayloadInterceptor extends BaseInterceptor { constructor( - private snackBar: MatSnackBar - ) { super(); } + private snackBar: MatSnackBar, + configurationService: ConfigurationService + ) { super(configurationService); } get type(): InterceptorType { return InterceptorType.ResponsePayload; } diff --git a/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts b/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts index 867889a96..03ea053e2 100644 --- a/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts @@ -6,6 +6,7 @@ import { InterceptorType } from "./interceptor-type"; import { HttpHandler, HttpRequest, HttpEvent } from "@angular/common/http"; import { Observable } from "rxjs"; import { Router } from "@angular/router"; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Injectable() export class StatusCodeInterceptor extends BaseInterceptor { @@ -21,5 +22,6 @@ export class StatusCodeInterceptor extends BaseInterceptor { constructor( private router: Router, - ) { super(); } + configurationService: ConfigurationService + ) { super(configurationService); } } diff --git a/dmp-frontend/src/common/http/interceptors/unauthorized-response.interceptor.ts b/dmp-frontend/src/common/http/interceptors/unauthorized-response.interceptor.ts index 542df6dac..c33369a3b 100644 --- a/dmp-frontend/src/common/http/interceptors/unauthorized-response.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/unauthorized-response.interceptor.ts @@ -6,6 +6,7 @@ import { catchError, mergeMap, tap } from 'rxjs/operators'; import { AuthService } from '../../../app/core/services/auth/auth.service'; import { BaseInterceptor } from './base.interceptor'; import { InterceptorType } from './interceptor-type'; +import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @Injectable() export class UnauthorizedResponseInterceptor extends BaseInterceptor { @@ -13,7 +14,8 @@ export class UnauthorizedResponseInterceptor extends BaseInterceptor { constructor( public router: Router, private authService: AuthService, - ) { super(); } + configurationService: ConfigurationService + ) { super(configurationService); } get type(): InterceptorType { return InterceptorType.UnauthorizedResponse; } From c05fa8b768a4d88c09421281a3a634da0268ff43 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 20 Mar 2020 18:20:22 +0200 Subject: [PATCH 125/160] Add new RDA exporter --- .../managers/DataManagementPlanManager.java | 13 +- .../logic/managers/DatasetProfileManager.java | 4 +- .../eu/eudat/logic/managers/RDAManager.java | 38 + .../logic/utilities/json/JsonSearcher.java | 32 + .../commons/datafield/AutoCompleteData.java | 2 + .../commons/datafield/ComboBoxData.java | 11 + .../ExternalAutocompleteFieldModel.java | 12 +- .../data/rda/DatasetRDAExportModel.java | 3 +- .../java/eu/eudat/models/rda/Contact.java | 146 +++ .../java/eu/eudat/models/rda/ContactId.java | 154 ++++ .../java/eu/eudat/models/rda/Contributor.java | 181 ++++ .../eu/eudat/models/rda/ContributorId.java | 155 ++++ .../main/java/eu/eudat/models/rda/Cost.java | 374 ++++++++ .../java/eu/eudat/models/rda/Dataset.java | 839 ++++++++++++++++++ .../java/eu/eudat/models/rda/DatasetId.java | 156 ++++ .../eu/eudat/models/rda/Distribution.java | 412 +++++++++ .../main/java/eu/eudat/models/rda/Dmp.java | 774 ++++++++++++++++ .../main/java/eu/eudat/models/rda/DmpId.java | 156 ++++ .../java/eu/eudat/models/rda/FunderId.java | 154 ++++ .../java/eu/eudat/models/rda/Funding.java | 187 ++++ .../java/eu/eudat/models/rda/GrantId.java | 153 ++++ .../main/java/eu/eudat/models/rda/Host.java | 775 ++++++++++++++++ .../java/eu/eudat/models/rda/License.java | 113 +++ .../eudat/models/rda/MetadataStandardId.java | 153 ++++ .../java/eu/eudat/models/rda/Metadatum.java | 368 ++++++++ .../java/eu/eudat/models/rda/PidSystem.java | 63 ++ .../java/eu/eudat/models/rda/Project.java | 212 +++++ .../java/eu/eudat/models/rda/RDAModel.java | 58 ++ .../eudat/models/rda/SecurityAndPrivacy.java | 109 +++ .../eudat/models/rda/TechnicalResource.java | 109 +++ .../models/rda/mapper/ContactIdRDAMapper.java | 15 + .../models/rda/mapper/ContactRDAMapper.java | 16 + .../rda/mapper/ContributorIdRDAMapper.java | 16 + .../rda/mapper/ContributorRDAMapper.java | 20 + .../models/rda/mapper/DatasetIdRDAMapper.java | 17 + .../models/rda/mapper/DatasetRDAMapper.java | 100 +++ .../rda/mapper/DistributionRDAMapper.java | 39 + .../models/rda/mapper/DmpIdRDAMapper.java | 19 + .../eudat/models/rda/mapper/DmpRDAMapper.java | 51 ++ .../models/rda/mapper/FunderIdRDAMapper.java | 19 + .../models/rda/mapper/FundingRDAMapper.java | 25 + .../models/rda/mapper/GrantIdRDAMapper.java | 13 + .../models/rda/mapper/HostRDAMapper.java | 41 + .../models/rda/mapper/LicenseRDAMapper.java | 23 + .../models/rda/mapper/MetadataRDAMapper.java | 44 + .../mapper/MetadataStandardIdRDAMapper.java | 13 + .../models/rda/mapper/ProjectRDAMapper.java | 25 + .../mapper/SecurityAndPrivacyRDAMapper.java | 21 + .../mapper/TechnicalResourceRDAMapper.java | 21 + 49 files changed, 6447 insertions(+), 7 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index e88e48524..2710ec60c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -105,14 +105,16 @@ public class DataManagementPlanManager { private UtilitiesService utilitiesService; private DatabaseRepository databaseRepository; private Environment environment; + private RDAManager rdaManager; @Autowired - public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment) { + public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager) { this.apiContext = apiContext; this.datasetManager = datasetManager; this.utilitiesService = apiContext.getUtilitiesService(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.environment = environment; + this.rdaManager = rdaManager; } public DataTableData getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception { @@ -1129,15 +1131,20 @@ public class DataManagementPlanManager { eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id)); if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId())) throw new UnauthorisedException(); - RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); +// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); + String result = rdaManager.convertToRDA(dmp); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); File file = new File(fileName + ".json"); + OutputStream output = new FileOutputStream(file); try { - mapper.writeValue(file, rdaExportModel); +// mapper.writeValue(file, rdaExportModel); + output.write(result.getBytes()); + output.flush(); + output.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 079359827..81693e917 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -113,8 +113,8 @@ public class DatasetProfileManager { ResponseEntity response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class); DocumentContext jsonContext = JsonPath.parse(response.getBody()); - List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "']"); - jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource())))); + List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "','" + "uri" + "']"); + jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()), item.get("uri")))); return result; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java new file mode 100644 index 000000000..eb10fd753 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -0,0 +1,38 @@ +package eu.eudat.logic.managers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DMP; +import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.RDAModel; +import eu.eudat.models.rda.mapper.DmpRDAMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.text.SimpleDateFormat; + +@Component +public class RDAManager { + + private DmpRDAMapper dmpRDAMapper; + + @Autowired + public RDAManager(DmpRDAMapper dmpRDAMapper) { + this.dmpRDAMapper = dmpRDAMapper; + } + + @Transactional + public String convertToRDA(DMP dmp) throws JsonProcessingException { + String result = ""; + + Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + + result = mapper.writeValueAsString(rdaDmp); + + return result; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java new file mode 100644 index 000000000..ca2372b91 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -0,0 +1,32 @@ +package eu.eudat.logic.utilities.json; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class JsonSearcher { + + public static List findNodes(JsonNode root, String key, String value) { + List nodes = new ArrayList<>(); + for (Iterator it = root.elements(); it.hasNext(); ) { + JsonNode node = it.next(); + int found = 0; + for (Iterator iter = node.fieldNames(); iter.hasNext(); ) { + String fieldName = iter.next(); + if (fieldName.equals(key)) { + if (node.get(fieldName).asText().equals(value) || node.get(fieldName).asText().startsWith(value)) { + nodes.add(node); + found++; + } + } + + } + if (found == 0) { + nodes.addAll(findNodes(node, key, value)); + } + } + return nodes; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java index 8fbedc873..5b33f115d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java @@ -64,6 +64,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(optionElement.getAttribute("label")); this.autoCompleteOptions.setValue(optionElement.getAttribute("value")); this.autoCompleteOptions.setSource(optionElement.getAttribute("source")); + this.autoCompleteOptions.setUri(optionElement.getAttribute("uri")); } return this; } @@ -81,6 +82,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(options.get("label")); this.autoCompleteOptions.setValue(options.get("value")); this.autoCompleteOptions.setSource(options.get("source")); + this.autoCompleteOptions.setUri(options.get("uri")); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java index db67ea301..59bc6ea79 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java @@ -12,6 +12,7 @@ public abstract class ComboBoxData extends FieldData { private String label; private String value; private String source; + private String uri; public String getLabel() { return label; @@ -34,12 +35,21 @@ public abstract class ComboBoxData extends FieldData { this.source = source; } + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + @Override public Element toXml(Document doc) { Element option = doc.createElement("option"); option.setAttribute("label", this.label); option.setAttribute("value", this.value); option.setAttribute("source", this.source); + option.setAttribute("uri", this.uri); return option; } @@ -48,6 +58,7 @@ public abstract class ComboBoxData extends FieldData { this.label = item.getAttribute("label"); this.value = item.getAttribute("value"); this.source = item.getAttribute("source"); + this.uri = item.getAttribute("uri"); return this; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java index d57605a72..039c63acd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java @@ -4,11 +4,13 @@ public class ExternalAutocompleteFieldModel { private String id; private String label; private String source; + private String uri; - public ExternalAutocompleteFieldModel(String id, String label, String source) { + public ExternalAutocompleteFieldModel(String id, String label, String source, String uri) { this.id = id; this.label = label; this.source = source; + this.uri = uri; } public String getId() { @@ -31,4 +33,12 @@ public class ExternalAutocompleteFieldModel { public void setSource(String source) { this.source = source; } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index c9f509020..ccd79971f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -321,7 +321,8 @@ public class DatasetRDAExportModel { JSONObject jsonObject = jsonArray.getJSONObject(i); Map jsonObjectMap = jsonObject.toMap(); DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel(); - metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); +// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); + metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url")); metadataRDAExportModelList.add(metadataRda1); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java new file mode 100644 index 000000000..606a3ae2c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java @@ -0,0 +1,146 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Contact Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact_id", + "mbox", + "name" +}) +public class Contact implements Serializable +{ + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + private ContactId contactId; + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contact Person's E-mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contact person") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -2062619884605400321L; + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public ContactId getContactId() { + return contactId; + } + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public void setContactId(ContactId contactId) { + this.contactId = contactId; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java new file mode 100644 index 000000000..60454ea6c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contact ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContactId implements Serializable +{ + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + private String identifier; + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContactId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7066973565810615822L; + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContactId.Type getType() { + return type; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContactId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContactId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContactId.Type fromValue(String value) { + ContactId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java new file mode 100644 index 000000000..21dfe68c8 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java @@ -0,0 +1,181 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + + +/** + * The Contributor Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contributor_id", + "mbox", + "name", + "role" +}) +public class Contributor implements Serializable +{ + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + private ContributorId contributorId; + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contributor Mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contributor") + private String name; + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + @JsonDeserialize(as = java.util.LinkedHashSet.class) + @JsonPropertyDescription("Type of contributor") + private Set role = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3452606902359513114L; + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public ContributorId getContributorId() { + return contributorId; + } + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public void setContributorId(ContributorId contributorId) { + this.contributorId = contributorId; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public Set getRole() { + return role; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public void setRole(Set role) { + this.role = role; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java new file mode 100644 index 000000000..4045f5e0e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java @@ -0,0 +1,155 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contributor_id Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContributorId implements Serializable +{ + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a contact person") + private String identifier; + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContributorId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3089650417960767482L; + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContributorId.Type getType() { + return type; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContributorId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContributorId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContributorId.Type fromValue(String value) { + ContributorId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java new file mode 100644 index 000000000..db32ff641 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java @@ -0,0 +1,374 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Cost Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "currency_code", + "description", + "title", + "value" +}) +public class Cost implements Serializable +{ + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + @JsonPropertyDescription("Allowed values defined by ISO 4217") + private Cost.CurrencyCode currencyCode; + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Cost(s) Description") + private String description; + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Value") + private Double value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -322637784848035165L; + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public Cost.CurrencyCode getCurrencyCode() { + return currencyCode; + } + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public void setCurrencyCode(Cost.CurrencyCode currencyCode) { + this.currencyCode = currencyCode; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public Double getValue() { + return value; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public void setValue(Double value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CurrencyCode { + + AED("AED"), + AFN("AFN"), + ALL("ALL"), + AMD("AMD"), + ANG("ANG"), + AOA("AOA"), + ARS("ARS"), + AUD("AUD"), + AWG("AWG"), + AZN("AZN"), + BAM("BAM"), + BBD("BBD"), + BDT("BDT"), + BGN("BGN"), + BHD("BHD"), + BIF("BIF"), + BMD("BMD"), + BND("BND"), + BOB("BOB"), + BRL("BRL"), + BSD("BSD"), + BTN("BTN"), + BWP("BWP"), + BYN("BYN"), + BZD("BZD"), + CAD("CAD"), + CDF("CDF"), + CHF("CHF"), + CLP("CLP"), + CNY("CNY"), + COP("COP"), + CRC("CRC"), + CUC("CUC"), + CUP("CUP"), + CVE("CVE"), + CZK("CZK"), + DJF("DJF"), + DKK("DKK"), + DOP("DOP"), + DZD("DZD"), + EGP("EGP"), + ERN("ERN"), + ETB("ETB"), + EUR("EUR"), + FJD("FJD"), + FKP("FKP"), + GBP("GBP"), + GEL("GEL"), + GGP("GGP"), + GHS("GHS"), + GIP("GIP"), + GMD("GMD"), + GNF("GNF"), + GTQ("GTQ"), + GYD("GYD"), + HKD("HKD"), + HNL("HNL"), + HRK("HRK"), + HTG("HTG"), + HUF("HUF"), + IDR("IDR"), + ILS("ILS"), + IMP("IMP"), + INR("INR"), + IQD("IQD"), + IRR("IRR"), + ISK("ISK"), + JEP("JEP"), + JMD("JMD"), + JOD("JOD"), + JPY("JPY"), + KES("KES"), + KGS("KGS"), + KHR("KHR"), + KMF("KMF"), + KPW("KPW"), + KRW("KRW"), + KWD("KWD"), + KYD("KYD"), + KZT("KZT"), + LAK("LAK"), + LBP("LBP"), + LKR("LKR"), + LRD("LRD"), + LSL("LSL"), + LYD("LYD"), + MAD("MAD"), + MDL("MDL"), + MGA("MGA"), + MKD("MKD"), + MMK("MMK"), + MNT("MNT"), + MOP("MOP"), + MRU("MRU"), + MUR("MUR"), + MVR("MVR"), + MWK("MWK"), + MXN("MXN"), + MYR("MYR"), + MZN("MZN"), + NAD("NAD"), + NGN("NGN"), + NIO("NIO"), + NOK("NOK"), + NPR("NPR"), + NZD("NZD"), + OMR("OMR"), + PAB("PAB"), + PEN("PEN"), + PGK("PGK"), + PHP("PHP"), + PKR("PKR"), + PLN("PLN"), + PYG("PYG"), + QAR("QAR"), + RON("RON"), + RSD("RSD"), + RUB("RUB"), + RWF("RWF"), + SAR("SAR"), + SBD("SBD"), + SCR("SCR"), + SDG("SDG"), + SEK("SEK"), + SGD("SGD"), + SHP("SHP"), + SLL("SLL"), + SOS("SOS"), + SPL("SPL*"), + SRD("SRD"), + STN("STN"), + SVC("SVC"), + SYP("SYP"), + SZL("SZL"), + THB("THB"), + TJS("TJS"), + TMT("TMT"), + TND("TND"), + TOP("TOP"), + TRY("TRY"), + TTD("TTD"), + TVD("TVD"), + TWD("TWD"), + TZS("TZS"), + UAH("UAH"), + UGX("UGX"), + USD("USD"), + UYU("UYU"), + UZS("UZS"), + VEF("VEF"), + VND("VND"), + VUV("VUV"), + WST("WST"), + XAF("XAF"), + XCD("XCD"), + XDR("XDR"), + XOF("XOF"), + XPF("XPF"), + YER("YER"), + ZAR("ZAR"), + ZMW("ZMW"), + ZWD("ZWD"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Cost.CurrencyCode c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CurrencyCode(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Cost.CurrencyCode fromValue(String value) { + Cost.CurrencyCode constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java new file mode 100644 index 000000000..43a7ac0cd --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -0,0 +1,839 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "data_quality_assurance", + "dataset_id", + "description", + "distribution", + "issued", + "keyword", + "language", + "metadata", + "personal_data", + "preservation_statement", + "security_and_privacy", + "sensitive_data", + "technical_resource", + "title", + "type" +}) +public class Dataset implements Serializable +{ + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + @JsonPropertyDescription("Data Quality Assurance") + private List dataQualityAssurance = null; + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + @JsonPropertyDescription("Dataset ID") + private DatasetId datasetId; + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + @JsonPropertyDescription("To provide technical information on a specific instance of data.") + private List distribution = null; + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + @JsonPropertyDescription("Date of Issue") + private String issued; + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + @JsonPropertyDescription("Keywords") + private List keyword = null; + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the dataset expressed using ISO 639-3.") + private Dataset.Language language; + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + @JsonPropertyDescription("To describe metadata standards used.") + private List metadata = null; + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + @JsonPropertyDescription("If any personal data is contained. Allowed values: yes, no, unknown") + private Dataset.PersonalData personalData; + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + @JsonPropertyDescription("Preservation Statement") + private String preservationStatement; + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + @JsonPropertyDescription("To list all issues and requirements related to security and privacy") + private List securityAndPrivacy = null; + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + @JsonPropertyDescription("If any sensitive data is contained. Allowed values: yes, no, unknown") + private Dataset.SensitiveData sensitiveData; + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + @JsonPropertyDescription("To list all technical resources needed to implement a DMP") + private List technicalResource = null; + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") + private String type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6931119120629009399L; + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public List getDataQualityAssurance() { + return dataQualityAssurance; + } + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public void setDataQualityAssurance(List dataQualityAssurance) { + this.dataQualityAssurance = dataQualityAssurance; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public DatasetId getDatasetId() { + return datasetId; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public void setDatasetId(DatasetId datasetId) { + this.datasetId = datasetId; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public List getDistribution() { + return distribution; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public void setDistribution(List distribution) { + this.distribution = distribution; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public String getIssued() { + return issued; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public void setIssued(String issued) { + this.issued = issued; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public List getKeyword() { + return keyword; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public void setKeyword(List keyword) { + this.keyword = keyword; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public Dataset.Language getLanguage() { + return language; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public void setLanguage(Dataset.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public List getMetadata() { + return metadata; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public void setMetadata(List metadata) { + this.metadata = metadata; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public Dataset.PersonalData getPersonalData() { + return personalData; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public void setPersonalData(Dataset.PersonalData personalData) { + this.personalData = personalData; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public String getPreservationStatement() { + return preservationStatement; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public void setPreservationStatement(String preservationStatement) { + this.preservationStatement = preservationStatement; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public List getSecurityAndPrivacy() { + return securityAndPrivacy; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public void setSecurityAndPrivacy(List securityAndPrivacy) { + this.securityAndPrivacy = securityAndPrivacy; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public Dataset.SensitiveData getSensitiveData() { + return sensitiveData; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public void setSensitiveData(Dataset.SensitiveData sensitiveData) { + this.sensitiveData = sensitiveData; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public List getTechnicalResource() { + return technicalResource; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public void setTechnicalResource(List technicalResource) { + this.technicalResource = technicalResource; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.Language fromValue(String value) { + Dataset.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum PersonalData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.PersonalData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PersonalData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.PersonalData fromValue(String value) { + Dataset.PersonalData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SensitiveData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.SensitiveData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SensitiveData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.SensitiveData fromValue(String value) { + Dataset.SensitiveData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java new file mode 100644 index 000000000..c1cc1e57a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset ID Schema + *

+ * Dataset ID + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DatasetId implements Serializable +{ + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a dataset") + private String identifier; + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Dataset identifier type. Allowed values: handle, doi, ark, url, other") + private DatasetId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6295164005851378031L; + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DatasetId.Type getType() { + return type; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DatasetId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DatasetId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DatasetId.Type fromValue(String value) { + DatasetId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java new file mode 100644 index 000000000..d005e7564 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -0,0 +1,412 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "access_url", + "available_until", + "byte_size", + "data_access", + "description", + "download_url", + "format", + "host", + "license", + "title" +}) +public class Distribution implements Serializable +{ + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + @JsonPropertyDescription("A URL of the resource that gives access to a distribution of the dataset. e.g. landing page.") + private String accessUrl; + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + @JsonPropertyDescription("Indicates how long this distribution will be / should be available.") + private String availableUntil; + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + @JsonPropertyDescription("Size in bytes.") + private Integer byteSize; + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + @JsonPropertyDescription("Indicates access mode for data. Allowed values: open, shared, closed") + private Distribution.DataAccess dataAccess; + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + @JsonPropertyDescription("The URL of the downloadable file in a given format. E.g. CSV file or RDF file.") + private URI downloadUrl; + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + @JsonPropertyDescription("Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format.") + private List format = null; + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + @JsonPropertyDescription("To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored.") + private Host host; + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + @JsonPropertyDescription("To list all licenses applied to a specific distribution of data.") + private List license = null; + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6018365280419917902L; + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public String getAccessUrl() { + return accessUrl; + } + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public void setAccessUrl(String accessUrl) { + this.accessUrl = accessUrl; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public String getAvailableUntil() { + return availableUntil; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public void setAvailableUntil(String availableUntil) { + this.availableUntil = availableUntil; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public Integer getByteSize() { + return byteSize; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public void setByteSize(Integer byteSize) { + this.byteSize = byteSize; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public Distribution.DataAccess getDataAccess() { + return dataAccess; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public void setDataAccess(Distribution.DataAccess dataAccess) { + this.dataAccess = dataAccess; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public URI getDownloadUrl() { + return downloadUrl; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public void setDownloadUrl(URI downloadUrl) { + this.downloadUrl = downloadUrl; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public List getFormat() { + return format; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public void setFormat(List format) { + this.format = format; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public Host getHost() { + return host; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public void setHost(Host host) { + this.host = host; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public List getLicense() { + return license; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public void setLicense(List license) { + this.license = license; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum DataAccess { + + OPEN("open"), + SHARED("shared"), + CLOSED("closed"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Distribution.DataAccess c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private DataAccess(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Distribution.DataAccess fromValue(String value) { + Distribution.DataAccess constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java new file mode 100644 index 000000000..7cac25d62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -0,0 +1,774 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact", + "contributor", + "cost", + "created", + "dataset", + "description", + "dmp_id", + "ethical_issues_description", + "ethical_issues_exist", + "ethical_issues_report", + "language", + "modified", + "project", + "title" +}) +public class Dmp implements Serializable +{ + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + private Contact contact; + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + private List contributor = null; + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + private List cost = null; + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + @JsonPropertyDescription("") + private Date created; + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + private List dataset = null; + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + @JsonPropertyDescription("To provide any free-form text information on a DMP") + private String description; + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + @JsonPropertyDescription("Identifier for the DMP itself") + private DmpId dmpId; + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + @JsonPropertyDescription("To describe ethical issues directly in a DMP") + private String ethicalIssuesDescription; + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + @JsonPropertyDescription("To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown") + private Dmp.EthicalIssuesExist ethicalIssuesExist; + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + @JsonPropertyDescription("To indicate where a protocol from a meeting with an ethical commitee can be found") + private URI ethicalIssuesReport; + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the DMP expressed using ISO 639-3.") + private Dmp.Language language; + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + @JsonPropertyDescription("Must be set each time DMP is modified. Indicates DMP version.") + private Date modified; + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + @JsonPropertyDescription("Project related to a DMP") + private List project = null; + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title of a DMP") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4599713332472772292L; + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public Contact getContact() { + return contact; + } + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public void setContact(Contact contact) { + this.contact = contact; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public List getContributor() { + return contributor; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public void setContributor(List contributor) { + this.contributor = contributor; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public List getCost() { + return cost; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public void setCost(List cost) { + this.cost = cost; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public Date getCreated() { + return created; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public void setCreated(Date created) { + this.created = created; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public List getDataset() { + return dataset; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public void setDataset(List dataset) { + this.dataset = dataset; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public DmpId getDmpId() { + return dmpId; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public void setDmpId(DmpId dmpId) { + this.dmpId = dmpId; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public String getEthicalIssuesDescription() { + return ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public void setEthicalIssuesDescription(String ethicalIssuesDescription) { + this.ethicalIssuesDescription = ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public Dmp.EthicalIssuesExist getEthicalIssuesExist() { + return ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public void setEthicalIssuesExist(Dmp.EthicalIssuesExist ethicalIssuesExist) { + this.ethicalIssuesExist = ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public URI getEthicalIssuesReport() { + return ethicalIssuesReport; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public void setEthicalIssuesReport(URI ethicalIssuesReport) { + this.ethicalIssuesReport = ethicalIssuesReport; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Dmp.Language getLanguage() { + return language; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Dmp.Language language) { + this.language = language; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public Date getModified() { + return modified; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public void setModified(Date modified) { + this.modified = modified; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public List getProject() { + return project; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public void setProject(List project) { + this.project = project; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum EthicalIssuesExist { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.EthicalIssuesExist c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private EthicalIssuesExist(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.EthicalIssuesExist fromValue(String value) { + Dmp.EthicalIssuesExist constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.Language fromValue(String value) { + Dmp.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java new file mode 100644 index 000000000..7240efaa4 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DmpId implements Serializable +{ + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a DMP") + private String identifier; + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("The DMP Identifier Type. Allowed values: handle, doi, ark, url, other") + private DmpId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6059908070202476841L; + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DmpId.Type getType() { + return type; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DmpId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DmpId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DmpId.Type fromValue(String value) { + DmpId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java new file mode 100644 index 000000000..12b8bb8f7 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class FunderId implements Serializable +{ + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/") + private String identifier; + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: fundref, url, other") + private FunderId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1783349151334366078L; + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public FunderId.Type getType() { + return type; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(FunderId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + FUNDREF("fundref"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (FunderId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static FunderId.Type fromValue(String value) { + FunderId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java new file mode 100644 index 000000000..0cc378e7c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java @@ -0,0 +1,187 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Project Funding Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "funder_id", + "funding_status", + "grant_id" +}) +public class Funding implements Serializable +{ + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + @JsonPropertyDescription("Funder ID of the associated project") + private FunderId funderId; + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + @JsonPropertyDescription("To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected") + private Funding.FundingStatus fundingStatus; + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + @JsonPropertyDescription("Grant ID of the associated project") + private GrantId grantId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8962229321225336165L; + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public FunderId getFunderId() { + return funderId; + } + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public void setFunderId(FunderId funderId) { + this.funderId = funderId; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public Funding.FundingStatus getFundingStatus() { + return fundingStatus; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public void setFundingStatus(Funding.FundingStatus fundingStatus) { + this.fundingStatus = fundingStatus; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public GrantId getGrantId() { + return grantId; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public void setGrantId(GrantId grantId) { + this.grantId = grantId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum FundingStatus { + + PLANNED("planned"), + APPLIED("applied"), + GRANTED("granted"), + REJECTED("rejected"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Funding.FundingStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private FundingStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Funding.FundingStatus fromValue(String value) { + Funding.FundingStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java new file mode 100644 index 000000000..cb994a0ba --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class GrantId implements Serializable +{ + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Grant ID") + private String identifier; + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private GrantId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7738072672837592065L; + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public GrantId.Type getType() { + return type; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(GrantId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (GrantId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static GrantId.Type fromValue(String value) { + GrantId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java new file mode 100644 index 000000000..bfa6ec615 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java @@ -0,0 +1,775 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "availability", + "backup_frequency", + "backup_type", + "certified_with", + "description", + "geo_location", + "pid_system", + "storage_type", + "support_versioning", + "title", + "url" +}) +public class Host implements Serializable +{ + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + @JsonPropertyDescription("Availability") + private String availability; + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + @JsonPropertyDescription("Backup Frequency") + private String backupFrequency; + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + @JsonPropertyDescription("Backup Type") + private String backupType; + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + @JsonPropertyDescription("Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal") + private Host.CertifiedWith certifiedWith; + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + @JsonPropertyDescription("Physical location of the data expressed using ISO 3166-1 country code.") + private Host.GeoLocation geoLocation; + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + @JsonPropertyDescription("PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other") + private List pidSystem = null; + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + @JsonPropertyDescription("The type of storage required") + private String storageType; + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + @JsonPropertyDescription("If host supports versioning. Allowed values: yes, no, unknown") + private Host.SupportVersioning supportVersioning; + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + @JsonPropertyDescription("The URL of the system hosting a distribution of a dataset") + private URI url; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8564338806797654115L; + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public String getAvailability() { + return availability; + } + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public String getBackupFrequency() { + return backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public void setBackupFrequency(String backupFrequency) { + this.backupFrequency = backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public String getBackupType() { + return backupType; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public void setBackupType(String backupType) { + this.backupType = backupType; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public Host.CertifiedWith getCertifiedWith() { + return certifiedWith; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public void setCertifiedWith(Host.CertifiedWith certifiedWith) { + this.certifiedWith = certifiedWith; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public Host.GeoLocation getGeoLocation() { + return geoLocation; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public void setGeoLocation(Host.GeoLocation geoLocation) { + this.geoLocation = geoLocation; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public List getPidSystem() { + return pidSystem; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public void setPidSystem(List pidSystem) { + this.pidSystem = pidSystem; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public String getStorageType() { + return storageType; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public Host.SupportVersioning getSupportVersioning() { + return supportVersioning; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public void setSupportVersioning(Host.SupportVersioning supportVersioning) { + this.supportVersioning = supportVersioning; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public URI getUrl() { + return url; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public void setUrl(URI url) { + this.url = url; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CertifiedWith { + + DIN_31644("din31644"), + DINI_ZERTIFIKAT("dini-zertifikat"), + DSA("dsa"), + ISO_16363("iso16363"), + ISO_16919("iso16919"), + TRAC("trac"), + WDS("wds"), + CORETRUSTSEAL("coretrustseal"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.CertifiedWith c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CertifiedWith(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.CertifiedWith fromValue(String value) { + Host.CertifiedWith constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum GeoLocation { + + AD("AD"), + AE("AE"), + AF("AF"), + AG("AG"), + AI("AI"), + AL("AL"), + AM("AM"), + AO("AO"), + AQ("AQ"), + AR("AR"), + AS("AS"), + AT("AT"), + AU("AU"), + AW("AW"), + AX("AX"), + AZ("AZ"), + BA("BA"), + BB("BB"), + BD("BD"), + BE("BE"), + BF("BF"), + BG("BG"), + BH("BH"), + BI("BI"), + BJ("BJ"), + BL("BL"), + BM("BM"), + BN("BN"), + BO("BO"), + BQ("BQ"), + BR("BR"), + BS("BS"), + BT("BT"), + BV("BV"), + BW("BW"), + BY("BY"), + BZ("BZ"), + CA("CA"), + CC("CC"), + CD("CD"), + CF("CF"), + CG("CG"), + CH("CH"), + CI("CI"), + CK("CK"), + CL("CL"), + CM("CM"), + CN("CN"), + CO("CO"), + CR("CR"), + CU("CU"), + CV("CV"), + CW("CW"), + CX("CX"), + CY("CY"), + CZ("CZ"), + DE("DE"), + DJ("DJ"), + DK("DK"), + DM("DM"), + DO("DO"), + DZ("DZ"), + EC("EC"), + EE("EE"), + EG("EG"), + EH("EH"), + ER("ER"), + ES("ES"), + ET("ET"), + FI("FI"), + FJ("FJ"), + FK("FK"), + FM("FM"), + FO("FO"), + FR("FR"), + GA("GA"), + GB("GB"), + GD("GD"), + GE("GE"), + GF("GF"), + GG("GG"), + GH("GH"), + GI("GI"), + GL("GL"), + GM("GM"), + GN("GN"), + GP("GP"), + GQ("GQ"), + GR("GR"), + GS("GS"), + GT("GT"), + GU("GU"), + GW("GW"), + GY("GY"), + HK("HK"), + HM("HM"), + HN("HN"), + HR("HR"), + HT("HT"), + HU("HU"), + ID("ID"), + IE("IE"), + IL("IL"), + IM("IM"), + IN("IN"), + IO("IO"), + IQ("IQ"), + IR("IR"), + IS("IS"), + IT("IT"), + JE("JE"), + JM("JM"), + JO("JO"), + JP("JP"), + KE("KE"), + KG("KG"), + KH("KH"), + KI("KI"), + KM("KM"), + KN("KN"), + KP("KP"), + KR("KR"), + KW("KW"), + KY("KY"), + KZ("KZ"), + LA("LA"), + LB("LB"), + LC("LC"), + LI("LI"), + LK("LK"), + LR("LR"), + LS("LS"), + LT("LT"), + LU("LU"), + LV("LV"), + LY("LY"), + MA("MA"), + MC("MC"), + MD("MD"), + ME("ME"), + MF("MF"), + MG("MG"), + MH("MH"), + MK("MK"), + ML("ML"), + MM("MM"), + MN("MN"), + MO("MO"), + MP("MP"), + MQ("MQ"), + MR("MR"), + MS("MS"), + MT("MT"), + MU("MU"), + MV("MV"), + MW("MW"), + MX("MX"), + MY("MY"), + MZ("MZ"), + NA("NA"), + NC("NC"), + NE("NE"), + NF("NF"), + NG("NG"), + NI("NI"), + NL("NL"), + NO("NO"), + NP("NP"), + NR("NR"), + NU("NU"), + NZ("NZ"), + OM("OM"), + PA("PA"), + PE("PE"), + PF("PF"), + PG("PG"), + PH("PH"), + PK("PK"), + PL("PL"), + PM("PM"), + PN("PN"), + PR("PR"), + PS("PS"), + PT("PT"), + PW("PW"), + PY("PY"), + QA("QA"), + RE("RE"), + RO("RO"), + RS("RS"), + RU("RU"), + RW("RW"), + SA("SA"), + SB("SB"), + SC("SC"), + SD("SD"), + SE("SE"), + SG("SG"), + SH("SH"), + SI("SI"), + SJ("SJ"), + SK("SK"), + SL("SL"), + SM("SM"), + SN("SN"), + SO("SO"), + SR("SR"), + SS("SS"), + ST("ST"), + SV("SV"), + SX("SX"), + SY("SY"), + SZ("SZ"), + TC("TC"), + TD("TD"), + TF("TF"), + TG("TG"), + TH("TH"), + TJ("TJ"), + TK("TK"), + TL("TL"), + TM("TM"), + TN("TN"), + TO("TO"), + TR("TR"), + TT("TT"), + TV("TV"), + TW("TW"), + TZ("TZ"), + UA("UA"), + UG("UG"), + UM("UM"), + US("US"), + UY("UY"), + UZ("UZ"), + VA("VA"), + VC("VC"), + VE("VE"), + VG("VG"), + VI("VI"), + VN("VN"), + VU("VU"), + WF("WF"), + WS("WS"), + YE("YE"), + YT("YT"), + ZA("ZA"), + ZM("ZM"), + ZW("ZW"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.GeoLocation c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private GeoLocation(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.GeoLocation fromValue(String value) { + Host.GeoLocation constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SupportVersioning { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.SupportVersioning c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SupportVersioning(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.SupportVersioning fromValue(String value) { + Host.SupportVersioning constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java new file mode 100644 index 000000000..1527f5503 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java @@ -0,0 +1,113 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Distribution License Items + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "license_ref", + "start_date" +}) +public class License implements Serializable +{ + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + @JsonPropertyDescription("Link to license document.") + private URI licenseRef; + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + @JsonPropertyDescription("Starting date of license. If date is set in the future, it indicates embargo period.") + private String startDate; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4148207295817559010L; + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public URI getLicenseRef() { + return licenseRef; + } + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public void setLicenseRef(URI licenseRef) { + this.licenseRef = licenseRef; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public String getStartDate() { + return startDate; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java new file mode 100644 index 000000000..06b54a1f1 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Standard ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class MetadataStandardId implements Serializable +{ + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for the metadata standard used.") + private String identifier; + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private MetadataStandardId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7641042701935397947L; + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public MetadataStandardId.Type getType() { + return type; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(MetadataStandardId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (MetadataStandardId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static MetadataStandardId.Type fromValue(String value) { + MetadataStandardId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java new file mode 100644 index 000000000..d6057ca62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -0,0 +1,368 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "language", + "metadata_standard_id" +}) +public class Metadatum implements Serializable +{ + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the metadata expressed using ISO 639-3.") + private Metadatum.Language language; + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + private MetadataStandardId metadataStandardId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 6511312853153406190L; + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Metadatum.Language getLanguage() { + return language; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Metadatum.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public MetadataStandardId getMetadataStandardId() { + return metadataStandardId; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public void setMetadataStandardId(MetadataStandardId metadataStandardId) { + this.metadataStandardId = metadataStandardId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Metadatum.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Metadatum.Language fromValue(String value) { + Metadatum.Language constant = CONSTANTS.get(value); + if (constant == null) { + return null; +// throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java new file mode 100644 index 000000000..0e29d1153 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java @@ -0,0 +1,63 @@ + +package eu.eudat.models.rda; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PidSystem { + + ARK("ark"), + ARXIV("arxiv"), + BIBCODE("bibcode"), + DOI("doi"), + EAN_13("ean13"), + EISSN("eissn"), + HANDLE("handle"), + IGSN("igsn"), + ISBN("isbn"), + ISSN("issn"), + ISTC("istc"), + LISSN("lissn"), + LSID("lsid"), + PMID("pmid"), + PURL("purl"), + UPC("upc"), + URL("url"), + URN("urn"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (PidSystem c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PidSystem(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static PidSystem fromValue(String value) { + PidSystem constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java new file mode 100644 index 000000000..09c231ca3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java @@ -0,0 +1,212 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Project Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "end", + "funding", + "start", + "title" +}) +public class Project implements Serializable +{ + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Project description") + private String description; + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + @JsonPropertyDescription("Project end date") + private String end; + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + @JsonPropertyDescription("Funding related with a project") + private List funding = null; + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + @JsonPropertyDescription("Project start date") + private String start; + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Project title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1437619307195890472L; + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public String getEnd() { + return end; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public void setEnd(String end) { + this.end = end; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public List getFunding() { + return funding; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public void setFunding(List funding) { + this.funding = funding; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public String getStart() { + return start; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public void setStart(String start) { + this.start = start; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java new file mode 100644 index 000000000..61df61b32 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java @@ -0,0 +1,58 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * RDA DMP Common Standard Schema + *

+ * JSON Schema for the RDA DMP Common Standard + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "dmp" +}) +public class RDAModel implements Serializable +{ + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + private Dmp dmp; + private final static long serialVersionUID = 7331666133368350998L; + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public Dmp getDmp() { + return dmp; + } + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public void setDmp(Dmp dmp) { + this.dmp = dmp; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java new file mode 100644 index 000000000..0486df588 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Security & Policy Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "title" +}) +public class SecurityAndPrivacy implements Serializable +{ + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 7863747935827682977L; + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java new file mode 100644 index 000000000..eac85da72 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Technical Resource Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "name" +}) +public class TechnicalResource implements Serializable +{ + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description of the technical resource") + private String description; + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the technical resource") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7451757227129483110L; + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java new file mode 100644 index 000000000..48549d75a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -0,0 +1,15 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.ContactId; + +import java.util.UUID; + +public class ContactIdRDAMapper { + + public static ContactId toRDA(UUID id) { + ContactId rda = new ContactId(); + rda.setIdentifier(id.toString()); + rda.setType(ContactId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java new file mode 100644 index 000000000..69ea2310e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Contact; +import eu.eudat.models.rda.ContactId; + +public class ContactRDAMapper { + + public static Contact toRDA(UserInfo creator) { + Contact rda = new Contact(); + rda.setName(creator.getName()); + rda.setMbox(creator.getEmail()); + rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java new file mode 100644 index 000000000..107dfb996 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.Contributor; +import eu.eudat.models.rda.ContributorId; + +import java.util.UUID; + +public class ContributorIdRDAMapper { + + public static ContributorId toRDA(UUID id) { + ContributorId rda = new ContributorId(); + rda.setIdentifier(id.toString()); + rda.setType(ContributorId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java new file mode 100644 index 000000000..681d98940 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java @@ -0,0 +1,20 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserDMP; +import eu.eudat.models.rda.Contributor; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; + +public class ContributorRDAMapper { + + public static Contributor toRDA(UserDMP userDMP) { + Contributor rda = new Contributor(); + rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId())); + rda.setName(userDMP.getUser().getName()); + rda.setMbox(userDMP.getUser().getEmail()); + rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name()))); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java new file mode 100644 index 000000000..ab791e215 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java @@ -0,0 +1,17 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.DatasetId; + +import java.util.UUID; + +public class DatasetIdRDAMapper { + + public static DatasetId toRDA(UUID id) { + DatasetId rda = new DatasetId(); + rda.setIdentifier(id.toString()); + rda.setType(DatasetId.Type.OTHER); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java new file mode 100644 index 000000000..103ba72c6 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -0,0 +1,100 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.utilities.json.JsonSearcher; +import eu.eudat.models.data.datasetwizard.DatasetWizardModel; +import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; +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.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class DatasetRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); + + private DatasetManager datasetManager; + + @Autowired + public DatasetRDAMapper(DatasetManager datasetManager) { + this.datasetManager = datasetManager; + } + + @Transactional + public Dataset toRDA(eu.eudat.data.entities.Dataset dataset) { + Dataset rda = new Dataset(); + rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); + rda.setTitle(dataset.getLabel()); + rda.setDescription(dataset.getDescription()); + try { + + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); + ObjectMapper mapper = new ObjectMapper(); + JsonNode properties = mapper.readTree(dataset.getProperties()); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + } + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + } + List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); + if (!metadataNodes.isEmpty()) { + rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + } + List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); + if (!qaNodes.isEmpty()) { + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); + if (!distributionNodes.isEmpty()) { + rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + } + List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); + if (!keywordNodes.isEmpty()) { + rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + } + List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); + if (!securityAndPrivacyNodes.isEmpty()) { + rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + } + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + } + List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); + if (!technicalResourceNodes.isEmpty()) { + rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + } + + + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java new file mode 100644 index 000000000..513affd98 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -0,0 +1,39 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Distribution; + +import java.net.URI; +import java.util.Collections; + +public class DistributionRDAMapper { + + public static Distribution toRDA(JsonNode structure, JsonNode properties) { + Distribution rda = new Distribution(); + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("access_url")) { + rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("available_util")) { + rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("byte_size")) { + rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + } else if (rdaProperty.contains("data_access")) { + rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("download_url")) { + rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("format")) { + rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("host")) { + rda.setHost(HostRDAMapper.toRDA(structure, properties)); + } else if (rdaProperty.contains("license")) { + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java new file mode 100644 index 000000000..095c26e11 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.DmpId; + +import java.util.UUID; + +public class DmpIdRDAMapper { + + public static DmpId toRDA(Object id) { + DmpId rda = new DmpId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(DmpId.Type.OTHER); + } else { + rda.setType(DmpId.Type.DOI); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java new file mode 100644 index 000000000..620229a27 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -0,0 +1,51 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.UserDMP; +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Dmp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Collections; +import java.util.stream.Collectors; + +@Component +public class DmpRDAMapper { + + private DatasetRDAMapper datasetRDAMapper; + + @Autowired + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + this.datasetRDAMapper = datasetRDAMapper; + } + + @Transactional + public Dmp toRDA(DMP dmp) { + Dmp rda = new Dmp(); + if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getDoi())); + } else { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId())); + } + rda.setCreated(dmp.getCreated()); + rda.setDescription(dmp.getDescription()); + rda.setModified(dmp.getModified()); + rda.setTitle(dmp.getLabel()); + + UserInfo creator; + if (dmp.getCreator() != null) { + creator = dmp.getCreator(); + } else { + creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo()); + } + rda.setContact(ContactRDAMapper.toRDA(creator)); + rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); + rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); + rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java new file mode 100644 index 000000000..f0dc5ff4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.FunderId; + +import java.util.UUID; + +public class FunderIdRDAMapper { + + public static FunderId toRDA(Object id) { + FunderId rda = new FunderId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(FunderId.Type.OTHER); + } else { + rda.setType(FunderId.Type.FUNDREF); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java new file mode 100644 index 000000000..e0b8fbe65 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Funding; + +public class FundingRDAMapper { + + public static Funding toRDA(Grant grant) { + Funding rda = new Funding(); + String referencePrefix; + String shortReference; + if (grant.getFunder().getReference() != null) { + referencePrefix = grant.getFunder().getReference().split(":")[0]; + shortReference = grant.getFunder().getReference().substring(referencePrefix.length() + 1); + rda.setFunderId(FunderIdRDAMapper.toRDA(shortReference)); + } else { + rda.setFunderId(FunderIdRDAMapper.toRDA(grant.getFunder().getId())); + } + referencePrefix = grant.getReference().split(":")[0]; + shortReference = grant.getReference().substring(referencePrefix.length() + 1); + rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java new file mode 100644 index 000000000..d05ec5d02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.GrantId; + +public class GrantIdRDAMapper { + + public static GrantId toRDA(String id) { + GrantId rda = new GrantId(); + rda.setIdentifier(id); + rda.setType(GrantId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java new file mode 100644 index 000000000..9a32cc697 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -0,0 +1,41 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Host; +import eu.eudat.models.rda.PidSystem; + +import java.net.URI; +import java.util.Collections; + +public class HostRDAMapper { + + public static Host toRDA(JsonNode structure, JsonNode properties) { + Host rda = new Host(); + String rdaProperty = structure.get("rdaProperties").asText(); + if (rdaProperty.contains("availability")) { + rda.setAvailability(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_frequency")) { + rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_type")) { + rda.setBackupType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("certified_with")) { + rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("geo_location")) { + rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("pid_system")) { + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); + } else if (rdaProperty.contains("storage_type")) { + rda.setStorageType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("support_versioning")) { + rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("url")) { + rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java new file mode 100644 index 000000000..68817bd3d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -0,0 +1,23 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.License; + +import java.net.URI; + +public class LicenseRDAMapper { + + public static License toRDA(JsonNode structure, JsonNode properties) { + License rda = new License(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("license_ref")) { + rda.setLicenseRef(URI.create(value)); + } else if (rdaProperty.contains("start_date")) { + rda.setStartDate(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java new file mode 100644 index 000000000..fa638d3e3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -0,0 +1,44 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.Metadatum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Iterator; + +public class MetadataRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); + + public static Metadatum toRDA(JsonNode structure, JsonNode properties) { + Metadatum rda = new Metadatum(); + JsonNode dataNode = null; + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("metadata_standard_id")) { + try { + String jsonText = properties.get(structure.get("id").asText()).asText(); + if (jsonText != null && !jsonText.isEmpty()) { + dataNode = new ObjectMapper().readTree(jsonText); + for (Iterator it = dataNode.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + } + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("language")) { + String language = properties.get(structure.get("id").asText()).asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + rda.setLanguage(lang); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java new file mode 100644 index 000000000..586446e02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.MetadataStandardId; + +public class MetadataStandardIdRDAMapper { + + public static MetadataStandardId toRDA(String uri) { + MetadataStandardId rda = new MetadataStandardId(); + rda.setIdentifier(uri); + rda.setType(MetadataStandardId.Type.URL); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java new file mode 100644 index 000000000..d97eace4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Project; + +import java.util.Collections; + +public class ProjectRDAMapper { + + public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) { + Project rda = new Project(); + rda.setTitle(project.getLabel()); + rda.setDescription(project.getDescription()); + if (project.getStartdate() != null) { + rda.setStart(project.getStartdate().toString()); + } + if (project.getEnddate() != null) { + rda.setEnd(project.getEnddate().toString()); + } + rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant))); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java new file mode 100644 index 000000000..f7f95633f --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.SecurityAndPrivacy; + +public class SecurityAndPrivacyRDAMapper { + + public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + SecurityAndPrivacy rda = new SecurityAndPrivacy(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("title")) { + rda.setTitle(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java new file mode 100644 index 000000000..b2652901a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.TechnicalResource; + +public class TechnicalResourceRDAMapper { + + public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + TechnicalResource rda = new TechnicalResource(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("name")) { + rda.setName(value); + } + + return rda; + } +} From 72382529542a854e0baa69fa20c5318052962301 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 23 Mar 2020 18:09:31 +0200 Subject: [PATCH 126/160] Improved object coupling for various objects on the dataset form --- .../utilities/helpers/MyStringUtils.java | 21 ++++ .../logic/utilities/json/JsonSearcher.java | 1 + .../user/components/datasetprofile/Field.java | 6 +- .../components/datasetprofile/FieldSet.java | 9 +- .../models/rda/mapper/DatasetRDAMapper.java | 27 ++-- .../rda/mapper/DistributionRDAMapper.java | 107 ++++++++++++++-- .../models/rda/mapper/HostRDAMapper.java | 98 +++++++++++---- .../models/rda/mapper/LicenseRDAMapper.java | 6 +- .../models/rda/mapper/MetadataRDAMapper.java | 119 +++++++++++++++--- .../mapper/SecurityAndPrivacyRDAMapper.java | 57 ++++++++- .../mapper/TechnicalResourceRDAMapper.java | 58 ++++++++- .../dataset-description-form.model.ts | 2 +- 12 files changed, 424 insertions(+), 87 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java new file mode 100644 index 000000000..1a071e04c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java @@ -0,0 +1,21 @@ +package eu.eudat.logic.utilities.helpers; + +public class MyStringUtils { + + public static int getFirstDifference(String s1, String s2) { + char[] s1ar = s1.toCharArray(); + char[] s2ar = s2.toCharArray(); + + for(int i = 0; i < s1ar.length; i++) { + if (s2ar.length > i) { + if (s1ar[i] != s2ar[i]) { + return i; + } + } else { + return i; + } + } + + return -1; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java index ca2372b91..979053830 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -1,6 +1,7 @@ package eu.eudat.logic.utilities.json; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.ArrayList; import java.util.Iterator; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java index 4950261c4..1c735e1a9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java @@ -149,7 +149,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin this.rdaProperty = rdaProperty; } - Field cloneForMultiplicity(String key, Map properties) { + Field cloneForMultiplicity(String key, Map properties, int index) { Field newField = new Field(); newField.id = key; newField.ordinal = this.ordinal; @@ -161,6 +161,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin newField.data = this.data; newField.validations = this.validations; newField.rdaProperty = this.rdaProperty; + newField.numbering = "mult" + index + "_" + this.numbering; return newField; } @@ -204,8 +205,9 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } this.multiplicityItems = new LinkedList<>(); List compositeKeys = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList()); + int index = 1; for (String key : compositeKeys) { - this.multiplicityItems.add(this.cloneForMultiplicity(key, properties)); + this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java index 51663ddaf..277534d16 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java @@ -163,16 +163,18 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe }); List compositeKeysFather = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList()); List Ids=new ArrayList<>(); + int index = 1; for (String composite : compositeKeysFather) { String[] split = composite.split("_"); if (!Ids.contains(split[2])) { Ids.add(split[2]); - this.multiplicityItems.add(this.CloneForMultiplicity2(properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId() + "_" + split[2])).collect(Collectors.toList()), properties,split)); + this.multiplicityItems.add(this.CloneForMultiplicity2(properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId() + "_" + split[2])).collect(Collectors.toList()), properties,split, index)); + index++; } } } - private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids){ + private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids, int index){ FieldSet newFieldSet = new FieldSet(); newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2]; newFieldSet.description = this.description; @@ -181,8 +183,9 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe newFieldSet.title = this.title; newFieldSet.ordinal = this.ordinal; newFieldSet.fields = new LinkedList(); + for (Field field: this.fields) { - newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties)); + newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index)); } return newFieldSet; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 103ba72c6..5eb9cc685 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -1,21 +1,17 @@ package eu.eudat.models.rda.mapper; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; -import org.json.JSONObject; 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.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -41,52 +37,51 @@ public class DatasetRDAMapper { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); - JsonNode properties = mapper.readTree(dataset.getProperties()); String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); if (!typeNodes.isEmpty()) { - rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + rda.setType(typeNodes.get(0).get("value").asText()); } List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); if (!languageNodes.isEmpty()) { - rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + rda.setLanguage(Dataset.Language.fromValue(languageNodes.get(0).get("value").asText())); } List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); if (!metadataNodes.isEmpty()) { - rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + rda.setMetadata(MetadataRDAMapper.toRDAList(metadataNodes)); } List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { - rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { - rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes)); } List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { - rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { - rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get()); } List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); if (!securityAndPrivacyNodes.isEmpty()) { - rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + rda.setSecurityAndPrivacy(SecurityAndPrivacyRDAMapper.toRDAList(securityAndPrivacyNodes)); } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { - rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 513affd98..98cb6960b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,39 +1,120 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; import java.net.URI; -import java.util.Collections; +import java.util.*; public class DistributionRDAMapper { - public static Distribution toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + Distribution rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName : PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case ACCESS_URL: + rda.setAccessUrl(rdaValue); + break; + case AVAILABLE_UTIL: + rda.setAvailableUntil(rdaValue); + break; + case DOWNLOAD_URL: + rda.setDownloadUrl(URI.create(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case DATA_ACCESS: + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + break; + case BYTE_SIZE: + rda.setByteSize(Integer.parseInt(rdaValue)); + break; + case LICENSE: + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); + break; + case FORMAT: + rda.setFormat(Collections.singletonList(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case HOST: + rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); - String rdaProperty = structure.get("rdaProperty").asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); if (rdaProperty.contains("access_url")) { - rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + rda.setAccessUrl(rdaValue); } else if (rdaProperty.contains("available_util")) { - rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + rda.setAvailableUntil(rdaValue); } else if (rdaProperty.contains("byte_size")) { - rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + rda.setByteSize(Integer.parseInt(rdaValue)); } else if (rdaProperty.contains("data_access")) { - rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue); } else if (rdaProperty.contains("download_url")) { - rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + rda.setDownloadUrl(URI.create(rdaValue)); } else if (rdaProperty.contains("format")) { - rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + rda.setFormat(Collections.singletonList(rdaValue)); } else if (rdaProperty.contains("host")) { - rda.setHost(HostRDAMapper.toRDA(structure, properties)); +// rda.setHost(HostRDAMapper.toRDA(node)); } else if (rdaProperty.contains("license")) { - rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); + rda.setTitle(rdaValue); } return rda; } + + private static Distribution getRelative( Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); + } + + private enum PropertyName { + ACCESS_URL("access_url"), + AVAILABLE_UTIL("available_util"), + BYTE_SIZE("byte_size"), + DATA_ACCESS("data_access"), + DESCRIPTION("description"), + DOWNLOAD_URL("download_url"), + FORMAT("format"), + HOST("host"), + LICENSE("license"), + TITLE("title"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java index 9a32cc697..0983f3d3b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -1,41 +1,91 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; import java.net.URI; import java.util.Collections; +import java.util.List; public class HostRDAMapper { - public static Host toRDA(JsonNode structure, JsonNode properties) { + public static Host toRDA(List nodes, String numbering) { Host rda = new Host(); - String rdaProperty = structure.get("rdaProperties").asText(); - if (rdaProperty.contains("availability")) { - rda.setAvailability(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_frequency")) { - rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_type")) { - rda.setBackupType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("certified_with")) { - rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("geo_location")) { - rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("pid_system")) { - rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); - } else if (rdaProperty.contains("storage_type")) { - rda.setStorageType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("support_versioning")) { - rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("url")) { - rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperties").asText(); + if (rdaProperty.contains("host")) { + int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); + if (firstDiff == -1 || firstDiff > 2) { + String rdaValue = node.get("value").asText(); + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case AVAILABILITY: + rda.setAvailability(rdaValue); + break; + case BACKUP_FREQUENCY: + rda.setBackupFrequency(rdaValue); + break; + case BACKUP_TYPE: + rda.setBackupType(rdaValue); + break; + case CERTIFIED_WITH: + rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case GEO_LOCATION: + rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue)); + break; + case PID_SYSTEM: + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(rdaValue))); + break; + case STORAGE_TYPE: + rda.setStorageType(rdaValue); + break; + case SUPPORT_VERSIONING: + rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case URL: + rda.setUrl(URI.create(rdaValue)); + break; + } + } + } + } + } } return rda; } + + private enum PropertyName { + AVAILABILITY("availability"), + BACKUP_FREQUENCY("backup_frequency"), + BACKUP_TYPE("backup_type"), + CERTIFIED_WITH("certified_with"), + DESCRIPTION("description"), + GEO_LOCATION("geo_location"), + PID_SYSTEM("pid_system"), + STORAGE_TYPE("storage_type"), + SUPPORT_VERSIONING("support_versioning"), + TITLE("title"), + URL("url"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java index 68817bd3d..6f94a73c4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -7,10 +7,10 @@ import java.net.URI; public class LicenseRDAMapper { - public static License toRDA(JsonNode structure, JsonNode properties) { + public static License toRDA(JsonNode node) { License rda = new License(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("license_ref")) { rda.setLicenseRef(URI.create(value)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index fa638d3e3..c7e3ba35f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -2,43 +2,124 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.TextNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Metadatum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Iterator; +import java.util.*; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); - public static Metadatum toRDA(JsonNode structure, JsonNode properties) { - Metadatum rda = new Metadatum(); - JsonNode dataNode = null; - String rdaProperty = structure.get("rdaProperty").asText(); - if (rdaProperty.contains("metadata_standard_id")) { - try { - String jsonText = properties.get(structure.get("id").asText()).asText(); - if (jsonText != null && !jsonText.isEmpty()) { - dataNode = new ObjectMapper().readTree(jsonText); - for (Iterator it = dataNode.elements(); it.hasNext(); ) { - JsonNode data = it.next(); - if (data.get("uri") != null) { - rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); - } + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + List rdas = new ArrayList<>(); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case METADATA_STANDARD_ID: + if (rdaValue instanceof ArrayNode) { + try { + ObjectMapper mapper = new ObjectMapper(); + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = null; + data = mapper.readTree(it.next().asText()); + if (data.get("uri") != null) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); + } + break; + case DESCRIPTION: + if (!rdaValue.asText().isEmpty()) { + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setDescription(rdaValue.asText()); + } else { + rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); + } + } + break; + case LANGUAGE: + String language = rdaValue.asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setLanguage(lang); + } else { + rdas.forEach(rda1 -> rda1.setLanguage(lang)); + } + break; + } + } + } + + } + + return rdas; + } + + public static Metadatum toRDA(JsonNode node) { + Metadatum rda = new Metadatum(); + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + if (rdaProperty.contains("metadata_standard_id")) { + if (rdaValue instanceof ArrayNode) { + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); } } - } catch (IOException e) { - logger.error(e.getMessage(), e); } } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue.asText()); } else if (rdaProperty.contains("language")) { - String language = properties.get(structure.get("id").asText()).asText(); + String language = rdaValue.asText(); Metadatum.Language lang = Metadatum.Language.fromValue(language); rda.setLanguage(lang); } return rda; } + + private static Metadatum getRelative(List rdas, Map rdaMap, String numbering) { + String target = rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering))).map(Map.Entry::getKey).orElse(""); + return rdas.stream().filter(rda -> rda.getMetadataStandardId().getIdentifier().equals(target)).distinct().findFirst().orElse(null); + } + + private enum PropertyName { + METADATA_STANDARD_ID("metadata_standard_id"), + DESCRIPTION("description"), + LANGUAGE("language"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index f7f95633f..fc44cc182 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -1,14 +1,45 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import java.util.*; + public class SecurityAndPrivacyRDAMapper { - public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + SecurityAndPrivacy rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case TITLE: + rda.setTitle(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value =node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +49,24 @@ public class SecurityAndPrivacyRDAMapper { return rda; } + + private static SecurityAndPrivacy getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); + } + + private enum PropertyName { + TITLE("title"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index b2652901a..c48f93cae 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -1,14 +1,46 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; +import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import java.util.*; + public class TechnicalResourceRDAMapper { - public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + TechnicalResource rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case NAME: + rda.setName(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +50,24 @@ public class TechnicalResourceRDAMapper { return rda; } + + private static TechnicalResource getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); + } + + private enum PropertyName { + NAME("name"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts index c4b8153b8..fd8824ba3 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts @@ -338,4 +338,4 @@ export class DatasetDescriptionDefaultValueEditorModel extends BaseFormModel { }); return formGroup; } -} \ No newline at end of file +} From 357ad4ecda96adb6c5847f4ba5b74aba8d192693 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 24 Mar 2020 11:26:17 +0200 Subject: [PATCH 127/160] Minor bug fixes on the exporter --- .../src/main/java/eu/eudat/logic/managers/RDAManager.java | 2 +- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index eb10fd753..3a9f2f7a8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -29,7 +29,7 @@ public class RDAManager { Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); ObjectMapper mapper = new ObjectMapper(); - mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); result = mapper.writeValueAsString(rdaDmp); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 5eb9cc685..da04fe043 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -32,6 +32,7 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); +// rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); @@ -57,7 +58,7 @@ public class DatasetRDAMapper { } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); + rda.setPreservationStatement(preservationNodes.get(0).get("value").asText()); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { @@ -77,7 +78,7 @@ public class DatasetRDAMapper { } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); + rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { From 463277b399df3bd7fefc71bb4328aeff49068352 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 26 Mar 2020 18:39:25 +0200 Subject: [PATCH 128/160] Add RDA Import --- .../main/java/eu/eudat/controllers/DMPs.java | 11 +- .../managers/DataManagementPlanManager.java | 35 ++++++ .../eu/eudat/logic/managers/RDAManager.java | 9 ++ .../java/eu/eudat/models/rda/Dataset.java | 9 +- .../eu/eudat/models/rda/Distribution.java | 9 +- .../main/java/eu/eudat/models/rda/Dmp.java | 9 +- .../java/eu/eudat/models/rda/Metadatum.java | 9 +- .../eudat/models/rda/SecurityAndPrivacy.java | 9 +- .../eudat/models/rda/TechnicalResource.java | 9 +- .../models/rda/mapper/ContactIdRDAMapper.java | 4 + .../models/rda/mapper/ContactRDAMapper.java | 8 ++ .../models/rda/mapper/DatasetRDAMapper.java | 112 +++++++++++++++++- .../rda/mapper/DistributionRDAMapper.java | 97 ++++++++++++++- .../eudat/models/rda/mapper/DmpRDAMapper.java | 36 ++++-- .../models/rda/mapper/FundingRDAMapper.java | 9 +- .../models/rda/mapper/MetadataRDAMapper.java | 66 +++++++++++ .../models/rda/mapper/ProjectRDAMapper.java | 22 +++- .../mapper/SecurityAndPrivacyRDAMapper.java | 60 +++++++++- .../mapper/TechnicalResourceRDAMapper.java | 62 +++++++++- .../dmp-upload-dialogue.component.html | 2 +- 20 files changed, 531 insertions(+), 56 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index c87ce4590..0e25b98f6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -53,6 +53,9 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import static org.springframework.http.MediaType.APPLICATION_ATOM_XML; +import static org.springframework.http.MediaType.APPLICATION_JSON; + @RestController @CrossOrigin @@ -224,8 +227,12 @@ public class DMPs extends BaseController { } @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { - this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + public ResponseEntity dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { + if (files[0].getContentType().equals(APPLICATION_JSON.toString())) { + this.dataManagementPlanManager.createFromRDA(files, principal); + } else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString())) { + this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + } return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem() .status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 2710ec60c..c8dee4802 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -131,6 +131,13 @@ public class DataManagementPlanManager { if (fieldsGroup.equals("listing")) { itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)) .selectAsync(item -> { + if (item.getUsers().stream().noneMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) { + for (UserDMP userDMP: item.getUsers()) { + userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue()); + databaseRepository.getUserDmpDao().createOrUpdate(userDMP); + break; + } + } item.setDataset( item.getDataset().stream() .filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream() @@ -1329,6 +1336,34 @@ public class DataManagementPlanManager { return dataManagementPlans; } + public List createFromRDA(MultipartFile[] files, Principal principal) throws IOException { + if (principal.getId() == null) { + throw new UnauthorisedException("No user is logged in"); + } + List result = new ArrayList<>(); + for (MultipartFile file: files) { + DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8")); + UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); + dmp.setModified(new Date()); + dmp.setCreator(me); + dmp.setVersion(0); + dmp.setStatus((short)0); + dmp.setGroupId(UUID.randomUUID()); + databaseRepository.getDmpDao().createOrUpdate(dmp); + assignUser(dmp, me); + dmp.getDataset().forEach(dataset -> { + dataset.setStatus(Dataset.Status.SAVED.getValue()); + dataset.setCreated(new Date()); + dataset.setModified(new Date()); + dataset.setDmp(dmp); + databaseRepository.getDatasetDao().createOrUpdate(dataset); + }); + result.add(dmp); + } + + return result; + } + public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) { datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index 3a9f2f7a8..ff194455e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; +import java.io.IOException; import java.text.SimpleDateFormat; @Component @@ -35,4 +36,12 @@ public class RDAManager { return result; } + + public DMP convertToEntity(String json) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); + + Dmp rda = mapper.readValue(json, Dmp.class); + return dmpRDAMapper.toEntity(rda); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java index 43a7ac0cd..3c064965e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -38,7 +38,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "sensitive_data", "technical_resource", "title", - "type" + "type", + "additional_properties" }) public class Dataset implements Serializable { @@ -182,7 +183,7 @@ public class Dataset implements Serializable @JsonProperty("type") @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") private String type; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6931119120629009399L; @@ -524,12 +525,12 @@ public class Dataset implements Serializable this.type = type; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java index d005e7564..176931e9e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -34,7 +34,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "format", "host", "license", - "title" + "title", + "additional_properties" }) public class Distribution implements Serializable { @@ -131,7 +132,7 @@ public class Distribution implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6018365280419917902L; @@ -359,12 +360,12 @@ public class Distribution implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java index 7cac25d62..b53d26147 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "language", "modified", "project", - "title" + "title", + "additional_properties" }) public class Dmp implements Serializable { @@ -173,7 +174,7 @@ public class Dmp implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title of a DMP") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 4599713332472772292L; @@ -499,12 +500,12 @@ public class Dmp implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java index d6057ca62..56bee437d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.annotation.JsonValue; @JsonPropertyOrder({ "description", "language", - "metadata_standard_id" + "metadata_standard_id", + "additional_properties" }) public class Metadatum implements Serializable { @@ -58,7 +59,7 @@ public class Metadatum implements Serializable */ @JsonProperty("metadata_standard_id") private MetadataStandardId metadataStandardId; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 6511312853153406190L; @@ -132,12 +133,12 @@ public class Metadatum implements Serializable this.metadataStandardId = metadataStandardId; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java index 0486df588..245d202d0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "title" + "title", + "additional_properties" }) public class SecurityAndPrivacy implements Serializable { @@ -46,7 +47,7 @@ public class SecurityAndPrivacy implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 7863747935827682977L; @@ -96,12 +97,12 @@ public class SecurityAndPrivacy implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java index eac85da72..c7bd2b055 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "name" + "name", + "additional_properties" }) public class TechnicalResource implements Serializable { @@ -46,7 +47,7 @@ public class TechnicalResource implements Serializable @JsonProperty("name") @JsonPropertyDescription("Name of the technical resource") private String name; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -7451757227129483110L; @@ -96,12 +97,12 @@ public class TechnicalResource implements Serializable this.name = name; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java index 48549d75a..c9eac2009 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -12,4 +12,8 @@ public class ContactIdRDAMapper { rda.setType(ContactId.Type.OTHER); return rda; } + + public static UUID toEntity(ContactId rda) { + return UUID.fromString(rda.getIdentifier()); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java index 69ea2310e..957fef8d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -13,4 +13,12 @@ public class ContactRDAMapper { rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); return rda; } + + public static UserInfo toEntity(Contact rda) { + UserInfo entity = new UserInfo(); + entity.setId(ContactIdRDAMapper.toEntity(rda.getContactId())); + entity.setName(rda.getName()); + entity.setEmail(rda.getMbox()); + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index da04fe043..90aa4ec7c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -2,28 +2,34 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DatasetProfile; import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; 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.util.List; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Component public class DatasetRDAMapper { private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); private DatasetManager datasetManager; + private ApiContext apiContext; @Autowired - public DatasetRDAMapper(DatasetManager datasetManager) { + public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext) { this.datasetManager = datasetManager; + this.apiContext = apiContext; } @Transactional @@ -32,9 +38,10 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); -// rda.setAdditionalProperty("template", dataset.getProfile().getId()); + rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { - + JSONObject jObject = new JSONObject(dataset.getProperties()); + Map templateIdsToValues = jObject.toMap(); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); @@ -55,6 +62,9 @@ public class DatasetRDAMapper { List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < qaNodes.size(); i++) { + rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { @@ -67,6 +77,9 @@ public class DatasetRDAMapper { List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < keywordNodes.size(); i++) { + rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText()); + } } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { @@ -84,6 +97,14 @@ public class DatasetRDAMapper { if (!technicalResourceNodes.isEmpty()) { rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } + List foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes, + keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList()); + templateIdsToValues.entrySet().forEach(entry -> { + boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey())); + if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) { + rda.setAdditionalProperty(entry.getKey(), entry.getValue()); + } + }); } catch (Exception e) { @@ -93,4 +114,87 @@ public class DatasetRDAMapper { return rda; } + + + public eu.eudat.data.entities.Dataset toEntity(Dataset rda) { + eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset(); + entity.setLabel(rda.getTitle()); + entity.setDescription(rda.getDescription()); + try { + DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); + entity.setProfile(profile); + }catch(Exception e) { + logger.warn(e.getMessage(), e); + } + try { + Map properties = new HashMap<>(); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); + datasetWizardModel.setProfile(entity.getProfile().getId()); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity)); + ObjectMapper mapper = new ObjectMapper(); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + properties.put(typeNodes.get(0).get("id").asText(), rda.getType()); + } + + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value()); + } + + if (rda.getMetadata() != null) { + properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); + } + + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < qaIds.size(); i++) { + properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); + } + + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement()); + } + + if (rda.getDistribution() != null) { + properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution())); + } + + List keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < keywordIds.size(); i++) { + properties.put(keywordIds.get(i), rda.getKeyword().get(i)); + } + + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + properties.put(personalDataNodes.get(0).get("id").asText(), rda.getPersonalData().value()); + } + + if (rda.getSecurityAndPrivacy() != null) { + properties.putAll(SecurityAndPrivacyRDAMapper.toProperties(rda.getSecurityAndPrivacy())); + } + + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + properties.put(sensitiveDataNodes.get(0).get("id").asText(), rda.getSensitiveData().value()); + } + + if (rda.getTechnicalResource() != null) { + properties.putAll(TechnicalResourceRDAMapper.toProperties(rda.getTechnicalResource())); + } + + rda.getAdditionalProperties().entrySet().stream() + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); + entity.setProperties(new ObjectMapper().writeValueAsString(properties)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 98cb6960b..566288452 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,13 +1,17 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import com.lowagie.text.ExceptionConverter; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.*; public class DistributionRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,35 +23,43 @@ public class DistributionRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName : PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case ACCESS_URL: rda.setAccessUrl(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText()); break; case AVAILABLE_UTIL: rda.setAvailableUntil(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UTIL.getName(), node.get("id").asText()); break; case DOWNLOAD_URL: rda.setDownloadUrl(URI.create(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; case DATA_ACCESS: rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DATA_ACCESS.getName(), node.get("id").asText()); break; case BYTE_SIZE: rda.setByteSize(Integer.parseInt(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText()); break; case LICENSE: rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); break; case FORMAT: rda.setFormat(Collections.singletonList(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText()); break; case TITLE: rda.setTitle(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case HOST: rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); @@ -60,6 +72,49 @@ public class DistributionRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch (importPropertyName) { + case ACCESS_URL: + properties.put(entry.getValue().toString(), rda.getAccessUrl()); + break; + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case FORMAT: + properties.put(entry.getValue().toString(), rda.getFormat().get(0)); + break; + case BYTE_SIZE: + properties.put(entry.getValue().toString(), rda.getByteSize().toString()); + break; + case DATA_ACCESS: + properties.put(entry.getValue().toString(), rda.getDataAccess().value()); + break; + case DOWNLOAD_URL: + properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString()); + break; + case AVAILABLE_UTIL: + properties.put(entry.getValue().toString(), rda.getAvailableUntil()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + }); + }); + + return properties; + } + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); String rdaProperty = node.get("rdaProperty").asText(); @@ -95,7 +150,7 @@ public class DistributionRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); } - private enum PropertyName { + private enum ExportPropertyName { ACCESS_URL("access_url"), AVAILABLE_UTIL("available_util"), BYTE_SIZE("byte_size"), @@ -109,7 +164,7 @@ public class DistributionRDAMapper { private final String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -117,4 +172,36 @@ public class DistributionRDAMapper { return name; } } + + private enum ImportPropertyName { + ACCESS_URL("accessurlId"), + AVAILABLE_UTIL("availableUtilId"), + BYTE_SIZE("byteSizeId"), + DATA_ACCESS("dataAccessId"), + DESCRIPTION("descriptionId"), + DOWNLOAD_URL("downloadUrlId"), + FORMAT("formatId"), + /*HOST("host"), + LICENSE("license"),*/ + TITLE("titleId"); + + private final String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("No name available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java index 620229a27..7176f3b8d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -1,24 +1,26 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.DMP; -import eu.eudat.data.entities.UserDMP; -import eu.eudat.data.entities.UserInfo; +import eu.eudat.data.entities.*; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.DmpId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.Collections; +import java.util.*; import java.util.stream.Collectors; @Component public class DmpRDAMapper { private DatasetRDAMapper datasetRDAMapper; + private ApiContext apiContext; @Autowired - public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) { this.datasetRDAMapper = datasetRDAMapper; + this.apiContext = apiContext; } @Transactional @@ -44,8 +46,28 @@ public class DmpRDAMapper { rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); - - + rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray()); return rda; } + + public DMP toEntity(Dmp rda) { + DMP entity = new DMP(); + entity.setLabel(rda.getTitle()); + if (rda.getDmpId().getType() == DmpId.Type.DOI) { + entity.setDoi(rda.getDmpId().getIdentifier()); + } + entity.setCreated(rda.getCreated()); + entity.setModified(rda.getModified()); + entity.setDescription(rda.getDescription()); + entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1)).collect(Collectors.toSet())); + Map result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext); + entity.setProject((Project) result.get("project")); + result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue())); + entity.setAssociatedDmps(((List) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet())); + return entity; + } + + private DatasetProfile getProfile(String id) { + return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java index e0b8fbe65..2dd3f6cc2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -1,7 +1,8 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.Funder; +import eu.eudat.data.dao.criteria.GrantCriteria; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Funding; public class FundingRDAMapper { @@ -22,4 +23,10 @@ public class FundingRDAMapper { rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); return rda; } + + public static Grant toEntity(Funding rda, ApiContext apiContext) { + GrantCriteria criteria = new GrantCriteria(); + criteria.setReference(rda.getGrantId().getIdentifier()); + return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle(); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index c7e3ba35f..49bbbb527 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); @@ -36,6 +37,7 @@ public class MetadataRDAMapper { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdas.get(rdas.size() - 1).setAdditionalProperty("fieldId", node.get("id").asText()); rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); } } @@ -45,6 +47,7 @@ public class MetadataRDAMapper { } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdas.get(rdas.size() - 1).setAdditionalProperty("identifierId", node.get("id").asText()); rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); } break; @@ -53,6 +56,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setDescription(rdaValue.asText()); + rda.setAdditionalProperty("descriptionId", node.get("id").asText()); } else { rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); } @@ -64,6 +68,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setLanguage(lang); + rda.setAdditionalProperty("languageId", node.get("id").asText()); } else { rdas.forEach(rda1 -> rda1.setLanguage(lang)); } @@ -77,6 +82,40 @@ public class MetadataRDAMapper { return rdas; } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + List standardIds = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + switch (entry.getKey()) { + case "fieldId": + Map metadata = toMap(rda); + standardIds.add(metadata); + properties.put(entry.getValue().toString(), mapper.writeValueAsString(standardIds)); + break; + case "identifierId": + properties.put(entry.getValue().toString(), rda.getMetadataStandardId().getIdentifier()); + break; + case "descriptionId": + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case "languageId": + if (rda.getLanguage() != null) { + properties.put(entry.getValue().toString(), rda.getLanguage().value()); + } + break; + } + }catch (Exception e) { + logger.error(e.getMessage(), e); + } + }); + }); + + return properties; + } + public static Metadatum toRDA(JsonNode node) { Metadatum rda = new Metadatum(); String rdaProperty = node.get("rdaProperty").asText(); @@ -122,4 +161,31 @@ public class MetadataRDAMapper { return name; } } + + private static Map toMap(Metadatum rda) { + Map result = new HashMap<>(); + + ObjectMapper mapper = new ObjectMapper(); + + Map metadata = mapper.convertValue(rda, Map.class); + + Map metadataStandardId = mapper.convertValue(metadata.get("metadata_standard_id"), Map.class); + + String url = metadataStandardId.remove("identifier"); + metadataStandardId.remove("type"); + metadataStandardId.put("uri", url); + + metadata.remove("additional_properties"); + metadata.remove("metadata_standard_id"); + + Map newMetadata = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toString())); + + String label = newMetadata.remove("description"); + newMetadata.put("label", label); + + result.putAll(newMetadata); + result.putAll(metadataStandardId); + + return result; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java index d97eace4a..b21a9403c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -2,9 +2,10 @@ package eu.eudat.models.rda.mapper; import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Project; -import java.util.Collections; +import java.util.*; public class ProjectRDAMapper { @@ -22,4 +23,23 @@ public class ProjectRDAMapper { return rda; } + + public static Map toEntity(Project rda, ApiContext apiContext) { + Map entities = new HashMap<>(); + + entities.put("project", new eu.eudat.data.entities.Project()); + ((eu.eudat.data.entities.Project) entities.get("project")).setLabel(rda.getTitle()); + ((eu.eudat.data.entities.Project) entities.get("project")).setDescription(rda.getDescription()); + ((eu.eudat.data.entities.Project) entities.get("project")).setId(UUID.randomUUID()); + ((eu.eudat.data.entities.Project) entities.get("project")).setStatus((short)1); + ((eu.eudat.data.entities.Project) entities.get("project")).setCreated(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setModified(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setType(0); + apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(((eu.eudat.data.entities.Project) entities.get("project"))); + for (int i = 0; i < rda.getFunding().size(); i++) { + entities.put("grant" + (i + 1), FundingRDAMapper.toEntity(rda.getFunding().get(i), apiContext)); + } + + return entities; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index fc44cc182..3b5d28649 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -3,10 +3,13 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class SecurityAndPrivacyRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(SecurityAndPrivacyRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,14 +22,16 @@ public class SecurityAndPrivacyRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case TITLE: rda.setTitle(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -36,6 +41,27 @@ public class SecurityAndPrivacyRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); String rdaProperty = node.get("rdaProperty").asText(); @@ -55,13 +81,13 @@ public class SecurityAndPrivacyRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); } - private enum PropertyName { + private enum ExportPropertyName { TITLE("title"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -69,4 +95,28 @@ public class SecurityAndPrivacyRDAMapper { return name; } } + + private enum ImportPropertyName { + TITLE("titleId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property not available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index c48f93cae..cd764c302 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -2,12 +2,14 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; -import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class TechnicalResourceRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(TechnicalResourceRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -20,14 +22,16 @@ public class TechnicalResourceRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case NAME: rda.setName(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.NAME.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -37,6 +41,28 @@ public class TechnicalResourceRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case NAME: + properties.put(entry.getValue().toString(), rda.getName()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); String rdaProperty = node.get("rdaProperty").asText(); @@ -56,13 +82,13 @@ public class TechnicalResourceRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); } - private enum PropertyName { + private enum ExportPropertyName { NAME("name"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -70,4 +96,28 @@ public class TechnicalResourceRDAMapper { return name; } } + + private enum ImportPropertyName { + NAME("nameId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property name not available"); + } + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html index 81779fadc..f9669094e 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html @@ -7,7 +7,7 @@ - +
From db99cfe63dd205476132c889d88c4a1058cf9fed Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 27 Mar 2020 10:50:37 +0200 Subject: [PATCH 129/160] Small bugfix for RDA Import --- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 90aa4ec7c..eef6eb6ed 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -63,7 +63,7 @@ public class DatasetRDAMapper { if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); for (int i = 0; i < qaNodes.size(); i++) { - rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).get("id").asText()); } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); @@ -149,7 +149,7 @@ public class DatasetRDAMapper { properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); } - List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qaId")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); for (int i = 0; i < qaIds.size(); i++) { properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); } @@ -187,7 +187,7 @@ public class DatasetRDAMapper { } rda.getAdditionalProperties().entrySet().stream() - .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qaId") && !entry.getKey().startsWith("keyword")) .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); entity.setProperties(new ObjectMapper().writeValueAsString(properties)); } catch (Exception e) { From 4a4dd03b87c8fe4d40ee618ad04e1a40b2b2bb78 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 27 Mar 2020 10:51:49 +0200 Subject: [PATCH 130/160] Small fix for config.json --- dmp-frontend/src/app/core/services/auth/auth.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index a48a2d478..a50261ba0 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -150,6 +150,7 @@ export class AuthService extends BaseService { } public getConfigurableProviders(): Observable { + this.actionUrl = this.configurationService.server + 'auth/'; const url = this.actionUrl + 'configurableLogin'; return this.http.get(url, { headers: this.headers }).pipe( map((res: any) => { From e8dcb6bd0ff9402a3d7f18cdd061adaf09b7b0f2 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 20 Mar 2020 18:20:22 +0200 Subject: [PATCH 131/160] Add new RDA exporter --- .../managers/DataManagementPlanManager.java | 13 +- .../logic/managers/DatasetProfileManager.java | 4 +- .../eu/eudat/logic/managers/RDAManager.java | 38 + .../logic/utilities/json/JsonSearcher.java | 32 + .../commons/datafield/AutoCompleteData.java | 2 + .../commons/datafield/ComboBoxData.java | 11 + .../ExternalAutocompleteFieldModel.java | 12 +- .../data/rda/DatasetRDAExportModel.java | 3 +- .../java/eu/eudat/models/rda/Contact.java | 146 +++ .../java/eu/eudat/models/rda/ContactId.java | 154 ++++ .../java/eu/eudat/models/rda/Contributor.java | 181 ++++ .../eu/eudat/models/rda/ContributorId.java | 155 ++++ .../main/java/eu/eudat/models/rda/Cost.java | 374 ++++++++ .../java/eu/eudat/models/rda/Dataset.java | 839 ++++++++++++++++++ .../java/eu/eudat/models/rda/DatasetId.java | 156 ++++ .../eu/eudat/models/rda/Distribution.java | 412 +++++++++ .../main/java/eu/eudat/models/rda/Dmp.java | 774 ++++++++++++++++ .../main/java/eu/eudat/models/rda/DmpId.java | 156 ++++ .../java/eu/eudat/models/rda/FunderId.java | 154 ++++ .../java/eu/eudat/models/rda/Funding.java | 187 ++++ .../java/eu/eudat/models/rda/GrantId.java | 153 ++++ .../main/java/eu/eudat/models/rda/Host.java | 775 ++++++++++++++++ .../java/eu/eudat/models/rda/License.java | 113 +++ .../eudat/models/rda/MetadataStandardId.java | 153 ++++ .../java/eu/eudat/models/rda/Metadatum.java | 368 ++++++++ .../java/eu/eudat/models/rda/PidSystem.java | 63 ++ .../java/eu/eudat/models/rda/Project.java | 212 +++++ .../java/eu/eudat/models/rda/RDAModel.java | 58 ++ .../eudat/models/rda/SecurityAndPrivacy.java | 109 +++ .../eudat/models/rda/TechnicalResource.java | 109 +++ .../models/rda/mapper/ContactIdRDAMapper.java | 15 + .../models/rda/mapper/ContactRDAMapper.java | 16 + .../rda/mapper/ContributorIdRDAMapper.java | 16 + .../rda/mapper/ContributorRDAMapper.java | 20 + .../models/rda/mapper/DatasetIdRDAMapper.java | 17 + .../models/rda/mapper/DatasetRDAMapper.java | 100 +++ .../rda/mapper/DistributionRDAMapper.java | 39 + .../models/rda/mapper/DmpIdRDAMapper.java | 19 + .../eudat/models/rda/mapper/DmpRDAMapper.java | 51 ++ .../models/rda/mapper/FunderIdRDAMapper.java | 19 + .../models/rda/mapper/FundingRDAMapper.java | 25 + .../models/rda/mapper/GrantIdRDAMapper.java | 13 + .../models/rda/mapper/HostRDAMapper.java | 41 + .../models/rda/mapper/LicenseRDAMapper.java | 23 + .../models/rda/mapper/MetadataRDAMapper.java | 44 + .../mapper/MetadataStandardIdRDAMapper.java | 13 + .../models/rda/mapper/ProjectRDAMapper.java | 25 + .../mapper/SecurityAndPrivacyRDAMapper.java | 21 + .../mapper/TechnicalResourceRDAMapper.java | 21 + 49 files changed, 6447 insertions(+), 7 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index e88e48524..2710ec60c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -105,14 +105,16 @@ public class DataManagementPlanManager { private UtilitiesService utilitiesService; private DatabaseRepository databaseRepository; private Environment environment; + private RDAManager rdaManager; @Autowired - public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment) { + public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager) { this.apiContext = apiContext; this.datasetManager = datasetManager; this.utilitiesService = apiContext.getUtilitiesService(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.environment = environment; + this.rdaManager = rdaManager; } public DataTableData getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception { @@ -1129,15 +1131,20 @@ public class DataManagementPlanManager { eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id)); if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId())) throw new UnauthorisedException(); - RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); +// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal); + String result = rdaManager.convertToRDA(dmp); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); File file = new File(fileName + ".json"); + OutputStream output = new FileOutputStream(file); try { - mapper.writeValue(file, rdaExportModel); +// mapper.writeValue(file, rdaExportModel); + output.write(result.getBytes()); + output.flush(); + output.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 079359827..81693e917 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -113,8 +113,8 @@ public class DatasetProfileManager { ResponseEntity response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class); DocumentContext jsonContext = JsonPath.parse(response.getBody()); - List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "']"); - jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource())))); + List> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getAutoCompleteOptions().getLabel() + "','" + data.getAutoCompleteOptions().getValue() + "','" + data.getAutoCompleteOptions().getSource() + "','" + "uri" + "']"); + jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()), item.get(data.getAutoCompleteOptions().getSource()), item.get("uri")))); return result; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java new file mode 100644 index 000000000..eb10fd753 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -0,0 +1,38 @@ +package eu.eudat.logic.managers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DMP; +import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.RDAModel; +import eu.eudat.models.rda.mapper.DmpRDAMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.text.SimpleDateFormat; + +@Component +public class RDAManager { + + private DmpRDAMapper dmpRDAMapper; + + @Autowired + public RDAManager(DmpRDAMapper dmpRDAMapper) { + this.dmpRDAMapper = dmpRDAMapper; + } + + @Transactional + public String convertToRDA(DMP dmp) throws JsonProcessingException { + String result = ""; + + Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); + + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + + result = mapper.writeValueAsString(rdaDmp); + + return result; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java new file mode 100644 index 000000000..ca2372b91 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -0,0 +1,32 @@ +package eu.eudat.logic.utilities.json; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class JsonSearcher { + + public static List findNodes(JsonNode root, String key, String value) { + List nodes = new ArrayList<>(); + for (Iterator it = root.elements(); it.hasNext(); ) { + JsonNode node = it.next(); + int found = 0; + for (Iterator iter = node.fieldNames(); iter.hasNext(); ) { + String fieldName = iter.next(); + if (fieldName.equals(key)) { + if (node.get(fieldName).asText().equals(value) || node.get(fieldName).asText().startsWith(value)) { + nodes.add(node); + found++; + } + } + + } + if (found == 0) { + nodes.addAll(findNodes(node, key, value)); + } + } + return nodes; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java index 8fbedc873..5b33f115d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/AutoCompleteData.java @@ -64,6 +64,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(optionElement.getAttribute("label")); this.autoCompleteOptions.setValue(optionElement.getAttribute("value")); this.autoCompleteOptions.setSource(optionElement.getAttribute("source")); + this.autoCompleteOptions.setUri(optionElement.getAttribute("uri")); } return this; } @@ -81,6 +82,7 @@ public class AutoCompleteData extends ComboBoxData { this.autoCompleteOptions.setLabel(options.get("label")); this.autoCompleteOptions.setValue(options.get("value")); this.autoCompleteOptions.setSource(options.get("source")); + this.autoCompleteOptions.setUri(options.get("uri")); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java index db67ea301..59bc6ea79 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java @@ -12,6 +12,7 @@ public abstract class ComboBoxData extends FieldData { private String label; private String value; private String source; + private String uri; public String getLabel() { return label; @@ -34,12 +35,21 @@ public abstract class ComboBoxData extends FieldData { this.source = source; } + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + @Override public Element toXml(Document doc) { Element option = doc.createElement("option"); option.setAttribute("label", this.label); option.setAttribute("value", this.value); option.setAttribute("source", this.source); + option.setAttribute("uri", this.uri); return option; } @@ -48,6 +58,7 @@ public abstract class ComboBoxData extends FieldData { this.label = item.getAttribute("label"); this.value = item.getAttribute("value"); this.source = item.getAttribute("source"); + this.uri = item.getAttribute("uri"); return this; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java index d57605a72..039c63acd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/externaldataset/ExternalAutocompleteFieldModel.java @@ -4,11 +4,13 @@ public class ExternalAutocompleteFieldModel { private String id; private String label; private String source; + private String uri; - public ExternalAutocompleteFieldModel(String id, String label, String source) { + public ExternalAutocompleteFieldModel(String id, String label, String source, String uri) { this.id = id; this.label = label; this.source = source; + this.uri = uri; } public String getId() { @@ -31,4 +33,12 @@ public class ExternalAutocompleteFieldModel { public void setSource(String source) { this.source = source; } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index c9f509020..ccd79971f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -321,7 +321,8 @@ public class DatasetRDAExportModel { JSONObject jsonObject = jsonArray.getJSONObject(i); Map jsonObjectMap = jsonObject.toMap(); DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel(); - metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); +// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString())); + metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url")); metadataRDAExportModelList.add(metadataRda1); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java new file mode 100644 index 000000000..606a3ae2c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contact.java @@ -0,0 +1,146 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Contact Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact_id", + "mbox", + "name" +}) +public class Contact implements Serializable +{ + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + private ContactId contactId; + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contact Person's E-mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contact person") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -2062619884605400321L; + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public ContactId getContactId() { + return contactId; + } + + /** + * The Contact ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact_id") + public void setContactId(ContactId contactId) { + this.contactId = contactId; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Mailbox Schema + *

+ * Contact Person's E-mail address + * (Required) + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contact person + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java new file mode 100644 index 000000000..60454ea6c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContactId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contact ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContactId implements Serializable +{ + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + private String identifier; + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContactId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7066973565810615822L; + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Contact Identifier Schema + *

+ * + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContactId.Type getType() { + return type; + } + + /** + * The DMP Contact Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContactId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContactId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContactId.Type fromValue(String value) { + ContactId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java new file mode 100644 index 000000000..21dfe68c8 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Contributor.java @@ -0,0 +1,181 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + + +/** + * The Contributor Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contributor_id", + "mbox", + "name", + "role" +}) +public class Contributor implements Serializable +{ + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + private ContributorId contributorId; + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + @JsonPropertyDescription("Contributor Mail address") + private String mbox; + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the contributor") + private String name; + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + @JsonDeserialize(as = java.util.LinkedHashSet.class) + @JsonPropertyDescription("Type of contributor") + private Set role = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3452606902359513114L; + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public ContributorId getContributorId() { + return contributorId; + } + + /** + * The Contributor_id Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contributor_id") + public void setContributorId(ContributorId contributorId) { + this.contributorId = contributorId; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public String getMbox() { + return mbox; + } + + /** + * The Contributor Mailbox Schema + *

+ * Contributor Mail address + * + */ + @JsonProperty("mbox") + public void setMbox(String mbox) { + this.mbox = mbox; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Name Schema + *

+ * Name of the contributor + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public Set getRole() { + return role; + } + + /** + * The Role Schema + *

+ * Type of contributor + * (Required) + * + */ + @JsonProperty("role") + public void setRole(Set role) { + this.role = role; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java new file mode 100644 index 000000000..4045f5e0e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/ContributorId.java @@ -0,0 +1,155 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Contributor_id Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class ContributorId implements Serializable +{ + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a contact person") + private String identifier; + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other") + private ContributorId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 3089650417960767482L; + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Contributor Identifier Schema + *

+ * Identifier for a contact person + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public ContributorId.Type getType() { + return type; + } + + /** + * The Contributor Identifier Type Schema + *

+ * Identifier type. Allowed values: orcid, isni, openid, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(ContributorId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + ORCID("orcid"), + ISNI("isni"), + OPENID("openid"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ContributorId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ContributorId.Type fromValue(String value) { + ContributorId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java new file mode 100644 index 000000000..db32ff641 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Cost.java @@ -0,0 +1,374 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Cost Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "currency_code", + "description", + "title", + "value" +}) +public class Cost implements Serializable +{ + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + @JsonPropertyDescription("Allowed values defined by ISO 4217") + private Cost.CurrencyCode currencyCode; + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Cost(s) Description") + private String description; + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + @JsonPropertyDescription("Value") + private Double value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -322637784848035165L; + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public Cost.CurrencyCode getCurrencyCode() { + return currencyCode; + } + + /** + * The Cost Currency Code Schema + *

+ * Allowed values defined by ISO 4217 + * + */ + @JsonProperty("currency_code") + public void setCurrencyCode(Cost.CurrencyCode currencyCode) { + this.currencyCode = currencyCode; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Cost Description Schema + *

+ * Cost(s) Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Cost Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public Double getValue() { + return value; + } + + /** + * The Cost Value Schema + *

+ * Value + * + */ + @JsonProperty("value") + public void setValue(Double value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CurrencyCode { + + AED("AED"), + AFN("AFN"), + ALL("ALL"), + AMD("AMD"), + ANG("ANG"), + AOA("AOA"), + ARS("ARS"), + AUD("AUD"), + AWG("AWG"), + AZN("AZN"), + BAM("BAM"), + BBD("BBD"), + BDT("BDT"), + BGN("BGN"), + BHD("BHD"), + BIF("BIF"), + BMD("BMD"), + BND("BND"), + BOB("BOB"), + BRL("BRL"), + BSD("BSD"), + BTN("BTN"), + BWP("BWP"), + BYN("BYN"), + BZD("BZD"), + CAD("CAD"), + CDF("CDF"), + CHF("CHF"), + CLP("CLP"), + CNY("CNY"), + COP("COP"), + CRC("CRC"), + CUC("CUC"), + CUP("CUP"), + CVE("CVE"), + CZK("CZK"), + DJF("DJF"), + DKK("DKK"), + DOP("DOP"), + DZD("DZD"), + EGP("EGP"), + ERN("ERN"), + ETB("ETB"), + EUR("EUR"), + FJD("FJD"), + FKP("FKP"), + GBP("GBP"), + GEL("GEL"), + GGP("GGP"), + GHS("GHS"), + GIP("GIP"), + GMD("GMD"), + GNF("GNF"), + GTQ("GTQ"), + GYD("GYD"), + HKD("HKD"), + HNL("HNL"), + HRK("HRK"), + HTG("HTG"), + HUF("HUF"), + IDR("IDR"), + ILS("ILS"), + IMP("IMP"), + INR("INR"), + IQD("IQD"), + IRR("IRR"), + ISK("ISK"), + JEP("JEP"), + JMD("JMD"), + JOD("JOD"), + JPY("JPY"), + KES("KES"), + KGS("KGS"), + KHR("KHR"), + KMF("KMF"), + KPW("KPW"), + KRW("KRW"), + KWD("KWD"), + KYD("KYD"), + KZT("KZT"), + LAK("LAK"), + LBP("LBP"), + LKR("LKR"), + LRD("LRD"), + LSL("LSL"), + LYD("LYD"), + MAD("MAD"), + MDL("MDL"), + MGA("MGA"), + MKD("MKD"), + MMK("MMK"), + MNT("MNT"), + MOP("MOP"), + MRU("MRU"), + MUR("MUR"), + MVR("MVR"), + MWK("MWK"), + MXN("MXN"), + MYR("MYR"), + MZN("MZN"), + NAD("NAD"), + NGN("NGN"), + NIO("NIO"), + NOK("NOK"), + NPR("NPR"), + NZD("NZD"), + OMR("OMR"), + PAB("PAB"), + PEN("PEN"), + PGK("PGK"), + PHP("PHP"), + PKR("PKR"), + PLN("PLN"), + PYG("PYG"), + QAR("QAR"), + RON("RON"), + RSD("RSD"), + RUB("RUB"), + RWF("RWF"), + SAR("SAR"), + SBD("SBD"), + SCR("SCR"), + SDG("SDG"), + SEK("SEK"), + SGD("SGD"), + SHP("SHP"), + SLL("SLL"), + SOS("SOS"), + SPL("SPL*"), + SRD("SRD"), + STN("STN"), + SVC("SVC"), + SYP("SYP"), + SZL("SZL"), + THB("THB"), + TJS("TJS"), + TMT("TMT"), + TND("TND"), + TOP("TOP"), + TRY("TRY"), + TTD("TTD"), + TVD("TVD"), + TWD("TWD"), + TZS("TZS"), + UAH("UAH"), + UGX("UGX"), + USD("USD"), + UYU("UYU"), + UZS("UZS"), + VEF("VEF"), + VND("VND"), + VUV("VUV"), + WST("WST"), + XAF("XAF"), + XCD("XCD"), + XDR("XDR"), + XOF("XOF"), + XPF("XPF"), + YER("YER"), + ZAR("ZAR"), + ZMW("ZMW"), + ZWD("ZWD"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Cost.CurrencyCode c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CurrencyCode(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Cost.CurrencyCode fromValue(String value) { + Cost.CurrencyCode constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java new file mode 100644 index 000000000..43a7ac0cd --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -0,0 +1,839 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "data_quality_assurance", + "dataset_id", + "description", + "distribution", + "issued", + "keyword", + "language", + "metadata", + "personal_data", + "preservation_statement", + "security_and_privacy", + "sensitive_data", + "technical_resource", + "title", + "type" +}) +public class Dataset implements Serializable +{ + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + @JsonPropertyDescription("Data Quality Assurance") + private List dataQualityAssurance = null; + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + @JsonPropertyDescription("Dataset ID") + private DatasetId datasetId; + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + @JsonPropertyDescription("To provide technical information on a specific instance of data.") + private List distribution = null; + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + @JsonPropertyDescription("Date of Issue") + private String issued; + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + @JsonPropertyDescription("Keywords") + private List keyword = null; + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the dataset expressed using ISO 639-3.") + private Dataset.Language language; + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + @JsonPropertyDescription("To describe metadata standards used.") + private List metadata = null; + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + @JsonPropertyDescription("If any personal data is contained. Allowed values: yes, no, unknown") + private Dataset.PersonalData personalData; + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + @JsonPropertyDescription("Preservation Statement") + private String preservationStatement; + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + @JsonPropertyDescription("To list all issues and requirements related to security and privacy") + private List securityAndPrivacy = null; + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + @JsonPropertyDescription("If any sensitive data is contained. Allowed values: yes, no, unknown") + private Dataset.SensitiveData sensitiveData; + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + @JsonPropertyDescription("To list all technical resources needed to implement a DMP") + private List technicalResource = null; + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") + private String type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6931119120629009399L; + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public List getDataQualityAssurance() { + return dataQualityAssurance; + } + + /** + * The Data Quality Assurance Schema + *

+ * Data Quality Assurance + * + */ + @JsonProperty("data_quality_assurance") + public void setDataQualityAssurance(List dataQualityAssurance) { + this.dataQualityAssurance = dataQualityAssurance; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public DatasetId getDatasetId() { + return datasetId; + } + + /** + * The Dataset ID Schema + *

+ * Dataset ID + * (Required) + * + */ + @JsonProperty("dataset_id") + public void setDatasetId(DatasetId datasetId) { + this.datasetId = datasetId; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public List getDistribution() { + return distribution; + } + + /** + * The Dataset Distribution Schema + *

+ * To provide technical information on a specific instance of data. + * + */ + @JsonProperty("distribution") + public void setDistribution(List distribution) { + this.distribution = distribution; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public String getIssued() { + return issued; + } + + /** + * The Dataset Date of Issue Schema + *

+ * Date of Issue + * + */ + @JsonProperty("issued") + public void setIssued(String issued) { + this.issued = issued; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public List getKeyword() { + return keyword; + } + + /** + * The Dataset Keyword(s) Schema + *

+ * Keywords + * + */ + @JsonProperty("keyword") + public void setKeyword(List keyword) { + this.keyword = keyword; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public Dataset.Language getLanguage() { + return language; + } + + /** + * The Dataset Language Schema + *

+ * Language of the dataset expressed using ISO 639-3. + * + */ + @JsonProperty("language") + public void setLanguage(Dataset.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public List getMetadata() { + return metadata; + } + + /** + * The Dataset Metadata Schema + *

+ * To describe metadata standards used. + * + */ + @JsonProperty("metadata") + public void setMetadata(List metadata) { + this.metadata = metadata; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public Dataset.PersonalData getPersonalData() { + return personalData; + } + + /** + * The Dataset Personal Data Schema + *

+ * If any personal data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("personal_data") + public void setPersonalData(Dataset.PersonalData personalData) { + this.personalData = personalData; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public String getPreservationStatement() { + return preservationStatement; + } + + /** + * The Dataset Preservation Statement Schema + *

+ * Preservation Statement + * + */ + @JsonProperty("preservation_statement") + public void setPreservationStatement(String preservationStatement) { + this.preservationStatement = preservationStatement; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public List getSecurityAndPrivacy() { + return securityAndPrivacy; + } + + /** + * The Dataset Security and Policy Schema + *

+ * To list all issues and requirements related to security and privacy + * + */ + @JsonProperty("security_and_privacy") + public void setSecurityAndPrivacy(List securityAndPrivacy) { + this.securityAndPrivacy = securityAndPrivacy; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public Dataset.SensitiveData getSensitiveData() { + return sensitiveData; + } + + /** + * The Dataset Sensitive Data Schema + *

+ * If any sensitive data is contained. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("sensitive_data") + public void setSensitiveData(Dataset.SensitiveData sensitiveData) { + this.sensitiveData = sensitiveData; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public List getTechnicalResource() { + return technicalResource; + } + + /** + * The Dataset Technical Resource Schema + *

+ * To list all technical resources needed to implement a DMP + * + */ + @JsonProperty("technical_resource") + public void setTechnicalResource(List technicalResource) { + this.technicalResource = technicalResource; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * The Dataset Type Schema + *

+ * If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html + * + */ + @JsonProperty("type") + public void setType(String type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.Language fromValue(String value) { + Dataset.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum PersonalData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.PersonalData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PersonalData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.PersonalData fromValue(String value) { + Dataset.PersonalData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SensitiveData { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dataset.SensitiveData c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SensitiveData(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dataset.SensitiveData fromValue(String value) { + Dataset.SensitiveData constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java new file mode 100644 index 000000000..c1cc1e57a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DatasetId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset ID Schema + *

+ * Dataset ID + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DatasetId implements Serializable +{ + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a dataset") + private String identifier; + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Dataset identifier type. Allowed values: handle, doi, ark, url, other") + private DatasetId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6295164005851378031L; + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Identifier Schema + *

+ * Identifier for a dataset + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DatasetId.Type getType() { + return type; + } + + /** + * The Dataset Identifier Type Schema + *

+ * Dataset identifier type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DatasetId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DatasetId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DatasetId.Type fromValue(String value) { + DatasetId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java new file mode 100644 index 000000000..d005e7564 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -0,0 +1,412 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "access_url", + "available_until", + "byte_size", + "data_access", + "description", + "download_url", + "format", + "host", + "license", + "title" +}) +public class Distribution implements Serializable +{ + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + @JsonPropertyDescription("A URL of the resource that gives access to a distribution of the dataset. e.g. landing page.") + private String accessUrl; + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + @JsonPropertyDescription("Indicates how long this distribution will be / should be available.") + private String availableUntil; + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + @JsonPropertyDescription("Size in bytes.") + private Integer byteSize; + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + @JsonPropertyDescription("Indicates access mode for data. Allowed values: open, shared, closed") + private Distribution.DataAccess dataAccess; + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String description; + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + @JsonPropertyDescription("The URL of the downloadable file in a given format. E.g. CSV file or RDF file.") + private URI downloadUrl; + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + @JsonPropertyDescription("Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format.") + private List format = null; + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + @JsonPropertyDescription("To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored.") + private Host host; + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + @JsonPropertyDescription("To list all licenses applied to a specific distribution of data.") + private List license = null; + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6018365280419917902L; + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public String getAccessUrl() { + return accessUrl; + } + + /** + * The Dataset Distribution Access URL Schema + *

+ * A URL of the resource that gives access to a distribution of the dataset. e.g. landing page. + * + */ + @JsonProperty("access_url") + public void setAccessUrl(String accessUrl) { + this.accessUrl = accessUrl; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public String getAvailableUntil() { + return availableUntil; + } + + /** + * The Dataset Distribution Available Until Schema + *

+ * Indicates how long this distribution will be / should be available. + * + */ + @JsonProperty("available_until") + public void setAvailableUntil(String availableUntil) { + this.availableUntil = availableUntil; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public Integer getByteSize() { + return byteSize; + } + + /** + * The Dataset Distribution Byte Size Schema + *

+ * Size in bytes. + * + */ + @JsonProperty("byte_size") + public void setByteSize(Integer byteSize) { + this.byteSize = byteSize; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public Distribution.DataAccess getDataAccess() { + return dataAccess; + } + + /** + * The Dataset Distribution Data Access Schema + *

+ * Indicates access mode for data. Allowed values: open, shared, closed + * (Required) + * + */ + @JsonProperty("data_access") + public void setDataAccess(Distribution.DataAccess dataAccess) { + this.dataAccess = dataAccess; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Description Schema + *

+ * Description is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public URI getDownloadUrl() { + return downloadUrl; + } + + /** + * The Dataset Distribution Download URL Schema + *

+ * The URL of the downloadable file in a given format. E.g. CSV file or RDF file. + * + */ + @JsonProperty("download_url") + public void setDownloadUrl(URI downloadUrl) { + this.downloadUrl = downloadUrl; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public List getFormat() { + return format; + } + + /** + * The Dataset Distribution Format Schema + *

+ * Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format. + * + */ + @JsonProperty("format") + public void setFormat(List format) { + this.format = format; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public Host getHost() { + return host; + } + + /** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ + @JsonProperty("host") + public void setHost(Host host) { + this.host = host; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public List getLicense() { + return license; + } + + /** + * The Dataset Distribution License(s) Schema + *

+ * To list all licenses applied to a specific distribution of data. + * + */ + @JsonProperty("license") + public void setLicense(List license) { + this.license = license; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Title Schema + *

+ * Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file. + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum DataAccess { + + OPEN("open"), + SHARED("shared"), + CLOSED("closed"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Distribution.DataAccess c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private DataAccess(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Distribution.DataAccess fromValue(String value) { + Distribution.DataAccess constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java new file mode 100644 index 000000000..7cac25d62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -0,0 +1,774 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "contact", + "contributor", + "cost", + "created", + "dataset", + "description", + "dmp_id", + "ethical_issues_description", + "ethical_issues_exist", + "ethical_issues_report", + "language", + "modified", + "project", + "title" +}) +public class Dmp implements Serializable +{ + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + private Contact contact; + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + private List contributor = null; + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + private List cost = null; + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + @JsonPropertyDescription("") + private Date created; + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + private List dataset = null; + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + @JsonPropertyDescription("To provide any free-form text information on a DMP") + private String description; + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + @JsonPropertyDescription("Identifier for the DMP itself") + private DmpId dmpId; + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + @JsonPropertyDescription("To describe ethical issues directly in a DMP") + private String ethicalIssuesDescription; + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + @JsonPropertyDescription("To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown") + private Dmp.EthicalIssuesExist ethicalIssuesExist; + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + @JsonPropertyDescription("To indicate where a protocol from a meeting with an ethical commitee can be found") + private URI ethicalIssuesReport; + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the DMP expressed using ISO 639-3.") + private Dmp.Language language; + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + @JsonPropertyDescription("Must be set each time DMP is modified. Indicates DMP version.") + private Date modified; + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + @JsonPropertyDescription("Project related to a DMP") + private List project = null; + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title of a DMP") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4599713332472772292L; + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public Contact getContact() { + return contact; + } + + /** + * The DMP Contact Schema + *

+ * + * (Required) + * + */ + @JsonProperty("contact") + public void setContact(Contact contact) { + this.contact = contact; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public List getContributor() { + return contributor; + } + + /** + * The Contributor Schema + *

+ * + * + */ + @JsonProperty("contributor") + public void setContributor(List contributor) { + this.contributor = contributor; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public List getCost() { + return cost; + } + + /** + * The Cost Schema + *

+ * + * + */ + @JsonProperty("cost") + public void setCost(List cost) { + this.cost = cost; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public Date getCreated() { + return created; + } + + /** + * The DMP Creation Schema + *

+ * + * + */ + @JsonProperty("created") + public void setCreated(Date created) { + this.created = created; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public List getDataset() { + return dataset; + } + + /** + * The Dataset Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dataset") + public void setDataset(List dataset) { + this.dataset = dataset; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Description Schema + *

+ * To provide any free-form text information on a DMP + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public DmpId getDmpId() { + return dmpId; + } + + /** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * (Required) + * + */ + @JsonProperty("dmp_id") + public void setDmpId(DmpId dmpId) { + this.dmpId = dmpId; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public String getEthicalIssuesDescription() { + return ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Description Schema + *

+ * To describe ethical issues directly in a DMP + * + */ + @JsonProperty("ethical_issues_description") + public void setEthicalIssuesDescription(String ethicalIssuesDescription) { + this.ethicalIssuesDescription = ethicalIssuesDescription; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public Dmp.EthicalIssuesExist getEthicalIssuesExist() { + return ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Exist Schema + *

+ * To indicate whether there are ethical issues related to data that this DMP describes. Allowed values: yes, no, unknown + * (Required) + * + */ + @JsonProperty("ethical_issues_exist") + public void setEthicalIssuesExist(Dmp.EthicalIssuesExist ethicalIssuesExist) { + this.ethicalIssuesExist = ethicalIssuesExist; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public URI getEthicalIssuesReport() { + return ethicalIssuesReport; + } + + /** + * The DMP Ethical Issues Report Schema + *

+ * To indicate where a protocol from a meeting with an ethical commitee can be found + * + */ + @JsonProperty("ethical_issues_report") + public void setEthicalIssuesReport(URI ethicalIssuesReport) { + this.ethicalIssuesReport = ethicalIssuesReport; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Dmp.Language getLanguage() { + return language; + } + + /** + * The DMP Language Schema + *

+ * Language of the DMP expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Dmp.Language language) { + this.language = language; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public Date getModified() { + return modified; + } + + /** + * The DMP Modification Schema + *

+ * Must be set each time DMP is modified. Indicates DMP version. + * (Required) + * + */ + @JsonProperty("modified") + public void setModified(Date modified) { + this.modified = modified; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public List getProject() { + return project; + } + + /** + * The DMP Project Schema + *

+ * Project related to a DMP + * + */ + @JsonProperty("project") + public void setProject(List project) { + this.project = project; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Title Schema + *

+ * Title of a DMP + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum EthicalIssuesExist { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.EthicalIssuesExist c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private EthicalIssuesExist(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.EthicalIssuesExist fromValue(String value) { + Dmp.EthicalIssuesExist constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Dmp.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Dmp.Language fromValue(String value) { + Dmp.Language constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java new file mode 100644 index 000000000..7240efaa4 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/DmpId.java @@ -0,0 +1,156 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Identifier Schema + *

+ * Identifier for the DMP itself + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class DmpId implements Serializable +{ + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for a DMP") + private String identifier; + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("The DMP Identifier Type. Allowed values: handle, doi, ark, url, other") + private DmpId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -6059908070202476841L; + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The DMP Identifier Value Schema + *

+ * Identifier for a DMP + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public DmpId.Type getType() { + return type; + } + + /** + * The DMP Identifier Type Schema + *

+ * The DMP Identifier Type. Allowed values: handle, doi, ark, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(DmpId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + HANDLE("handle"), + DOI("doi"), + ARK("ark"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (DmpId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static DmpId.Type fromValue(String value) { + DmpId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java new file mode 100644 index 000000000..12b8bb8f7 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/FunderId.java @@ -0,0 +1,154 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class FunderId implements Serializable +{ + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/") + private String identifier; + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: fundref, url, other") + private FunderId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1783349151334366078L; + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funder ID Value Schema + *

+ * Funder ID, recommended to use CrossRef Funder Registry. See: https://www.crossref.org/services/funder-registry/ + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public FunderId.Type getType() { + return type; + } + + /** + * The Funder ID Type Schema + *

+ * Identifier type. Allowed values: fundref, url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(FunderId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + FUNDREF("fundref"), + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (FunderId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static FunderId.Type fromValue(String value) { + FunderId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java new file mode 100644 index 000000000..0cc378e7c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Funding.java @@ -0,0 +1,187 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The DMP Project Funding Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "funder_id", + "funding_status", + "grant_id" +}) +public class Funding implements Serializable +{ + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + @JsonPropertyDescription("Funder ID of the associated project") + private FunderId funderId; + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + @JsonPropertyDescription("To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected") + private Funding.FundingStatus fundingStatus; + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + @JsonPropertyDescription("Grant ID of the associated project") + private GrantId grantId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8962229321225336165L; + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public FunderId getFunderId() { + return funderId; + } + + /** + * The Funder ID Schema + *

+ * Funder ID of the associated project + * (Required) + * + */ + @JsonProperty("funder_id") + public void setFunderId(FunderId funderId) { + this.funderId = funderId; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public Funding.FundingStatus getFundingStatus() { + return fundingStatus; + } + + /** + * The Funding Status Schema + *

+ * To express different phases of project lifecycle. Allowed values: planned, applied, granted, rejected + * + */ + @JsonProperty("funding_status") + public void setFundingStatus(Funding.FundingStatus fundingStatus) { + this.fundingStatus = fundingStatus; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public GrantId getGrantId() { + return grantId; + } + + /** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * (Required) + * + */ + @JsonProperty("grant_id") + public void setGrantId(GrantId grantId) { + this.grantId = grantId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum FundingStatus { + + PLANNED("planned"), + APPLIED("applied"), + GRANTED("granted"), + REJECTED("rejected"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Funding.FundingStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private FundingStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Funding.FundingStatus fromValue(String value) { + Funding.FundingStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java new file mode 100644 index 000000000..cb994a0ba --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/GrantId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Funding Grant ID Schema + *

+ * Grant ID of the associated project + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class GrantId implements Serializable +{ + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Grant ID") + private String identifier; + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private GrantId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7738072672837592065L; + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Funding Grant ID Value Schema + *

+ * Grant ID + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public GrantId.Type getType() { + return type; + } + + /** + * The Funding Grant ID Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(GrantId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (GrantId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static GrantId.Type fromValue(String value) { + GrantId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java new file mode 100644 index 000000000..bfa6ec615 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Host.java @@ -0,0 +1,775 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Distribution Host Schema + *

+ * To provide information on quality of service provided by infrastructure (e.g. repository) where data is stored. + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "availability", + "backup_frequency", + "backup_type", + "certified_with", + "description", + "geo_location", + "pid_system", + "storage_type", + "support_versioning", + "title", + "url" +}) +public class Host implements Serializable +{ + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + @JsonPropertyDescription("Availability") + private String availability; + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + @JsonPropertyDescription("Backup Frequency") + private String backupFrequency; + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + @JsonPropertyDescription("Backup Type") + private String backupType; + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + @JsonPropertyDescription("Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal") + private Host.CertifiedWith certifiedWith; + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + @JsonPropertyDescription("Physical location of the data expressed using ISO 3166-1 country code.") + private Host.GeoLocation geoLocation; + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + @JsonPropertyDescription("PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other") + private List pidSystem = null; + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + @JsonPropertyDescription("The type of storage required") + private String storageType; + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + @JsonPropertyDescription("If host supports versioning. Allowed values: yes, no, unknown") + private Host.SupportVersioning supportVersioning; + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + @JsonPropertyDescription("The URL of the system hosting a distribution of a dataset") + private URI url; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 8564338806797654115L; + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public String getAvailability() { + return availability; + } + + /** + * The Dataset Distribution Host Availability Schema + *

+ * Availability + * + */ + @JsonProperty("availability") + public void setAvailability(String availability) { + this.availability = availability; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public String getBackupFrequency() { + return backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Frequency Schema + *

+ * Backup Frequency + * + */ + @JsonProperty("backup_frequency") + public void setBackupFrequency(String backupFrequency) { + this.backupFrequency = backupFrequency; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public String getBackupType() { + return backupType; + } + + /** + * The Dataset Distribution Host Backup Type Schema + *

+ * Backup Type + * + */ + @JsonProperty("backup_type") + public void setBackupType(String backupType) { + this.backupType = backupType; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public Host.CertifiedWith getCertifiedWith() { + return certifiedWith; + } + + /** + * The Dataset Distribution Host Certification Type Schema + *

+ * Repository certified to a recognised standard. Allowed values: din31644, dini-zertifikat, dsa, iso16363, iso16919, trac, wds, coretrustseal + * + */ + @JsonProperty("certified_with") + public void setCertifiedWith(Host.CertifiedWith certifiedWith) { + this.certifiedWith = certifiedWith; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Distribution Host Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public Host.GeoLocation getGeoLocation() { + return geoLocation; + } + + /** + * The Dataset Distribution Host Geographical Location Schema + *

+ * Physical location of the data expressed using ISO 3166-1 country code. + * + */ + @JsonProperty("geo_location") + public void setGeoLocation(Host.GeoLocation geoLocation) { + this.geoLocation = geoLocation; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public List getPidSystem() { + return pidSystem; + } + + /** + * The Dataset Distribution Host PID System Schema + *

+ * PID system(s). Allowed values: ark, arxiv, bibcode, doi, ean13, eissn, handle, igsn, isbn, issn, istc, lissn, lsid, pmid, purl, upc, url, urn, other + * + */ + @JsonProperty("pid_system") + public void setPidSystem(List pidSystem) { + this.pidSystem = pidSystem; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public String getStorageType() { + return storageType; + } + + /** + * The Dataset Distribution Host Storage Type Schema + *

+ * The type of storage required + * + */ + @JsonProperty("storage_type") + public void setStorageType(String storageType) { + this.storageType = storageType; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public Host.SupportVersioning getSupportVersioning() { + return supportVersioning; + } + + /** + * The Dataset Distribution Host Support Versioning Schema + *

+ * If host supports versioning. Allowed values: yes, no, unknown + * + */ + @JsonProperty("support_versioning") + public void setSupportVersioning(Host.SupportVersioning supportVersioning) { + this.supportVersioning = supportVersioning; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public URI getUrl() { + return url; + } + + /** + * The Dataset Distribution Host Title Schema + *

+ * The URL of the system hosting a distribution of a dataset + * (Required) + * + */ + @JsonProperty("url") + public void setUrl(URI url) { + this.url = url; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum CertifiedWith { + + DIN_31644("din31644"), + DINI_ZERTIFIKAT("dini-zertifikat"), + DSA("dsa"), + ISO_16363("iso16363"), + ISO_16919("iso16919"), + TRAC("trac"), + WDS("wds"), + CORETRUSTSEAL("coretrustseal"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.CertifiedWith c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private CertifiedWith(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.CertifiedWith fromValue(String value) { + Host.CertifiedWith constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum GeoLocation { + + AD("AD"), + AE("AE"), + AF("AF"), + AG("AG"), + AI("AI"), + AL("AL"), + AM("AM"), + AO("AO"), + AQ("AQ"), + AR("AR"), + AS("AS"), + AT("AT"), + AU("AU"), + AW("AW"), + AX("AX"), + AZ("AZ"), + BA("BA"), + BB("BB"), + BD("BD"), + BE("BE"), + BF("BF"), + BG("BG"), + BH("BH"), + BI("BI"), + BJ("BJ"), + BL("BL"), + BM("BM"), + BN("BN"), + BO("BO"), + BQ("BQ"), + BR("BR"), + BS("BS"), + BT("BT"), + BV("BV"), + BW("BW"), + BY("BY"), + BZ("BZ"), + CA("CA"), + CC("CC"), + CD("CD"), + CF("CF"), + CG("CG"), + CH("CH"), + CI("CI"), + CK("CK"), + CL("CL"), + CM("CM"), + CN("CN"), + CO("CO"), + CR("CR"), + CU("CU"), + CV("CV"), + CW("CW"), + CX("CX"), + CY("CY"), + CZ("CZ"), + DE("DE"), + DJ("DJ"), + DK("DK"), + DM("DM"), + DO("DO"), + DZ("DZ"), + EC("EC"), + EE("EE"), + EG("EG"), + EH("EH"), + ER("ER"), + ES("ES"), + ET("ET"), + FI("FI"), + FJ("FJ"), + FK("FK"), + FM("FM"), + FO("FO"), + FR("FR"), + GA("GA"), + GB("GB"), + GD("GD"), + GE("GE"), + GF("GF"), + GG("GG"), + GH("GH"), + GI("GI"), + GL("GL"), + GM("GM"), + GN("GN"), + GP("GP"), + GQ("GQ"), + GR("GR"), + GS("GS"), + GT("GT"), + GU("GU"), + GW("GW"), + GY("GY"), + HK("HK"), + HM("HM"), + HN("HN"), + HR("HR"), + HT("HT"), + HU("HU"), + ID("ID"), + IE("IE"), + IL("IL"), + IM("IM"), + IN("IN"), + IO("IO"), + IQ("IQ"), + IR("IR"), + IS("IS"), + IT("IT"), + JE("JE"), + JM("JM"), + JO("JO"), + JP("JP"), + KE("KE"), + KG("KG"), + KH("KH"), + KI("KI"), + KM("KM"), + KN("KN"), + KP("KP"), + KR("KR"), + KW("KW"), + KY("KY"), + KZ("KZ"), + LA("LA"), + LB("LB"), + LC("LC"), + LI("LI"), + LK("LK"), + LR("LR"), + LS("LS"), + LT("LT"), + LU("LU"), + LV("LV"), + LY("LY"), + MA("MA"), + MC("MC"), + MD("MD"), + ME("ME"), + MF("MF"), + MG("MG"), + MH("MH"), + MK("MK"), + ML("ML"), + MM("MM"), + MN("MN"), + MO("MO"), + MP("MP"), + MQ("MQ"), + MR("MR"), + MS("MS"), + MT("MT"), + MU("MU"), + MV("MV"), + MW("MW"), + MX("MX"), + MY("MY"), + MZ("MZ"), + NA("NA"), + NC("NC"), + NE("NE"), + NF("NF"), + NG("NG"), + NI("NI"), + NL("NL"), + NO("NO"), + NP("NP"), + NR("NR"), + NU("NU"), + NZ("NZ"), + OM("OM"), + PA("PA"), + PE("PE"), + PF("PF"), + PG("PG"), + PH("PH"), + PK("PK"), + PL("PL"), + PM("PM"), + PN("PN"), + PR("PR"), + PS("PS"), + PT("PT"), + PW("PW"), + PY("PY"), + QA("QA"), + RE("RE"), + RO("RO"), + RS("RS"), + RU("RU"), + RW("RW"), + SA("SA"), + SB("SB"), + SC("SC"), + SD("SD"), + SE("SE"), + SG("SG"), + SH("SH"), + SI("SI"), + SJ("SJ"), + SK("SK"), + SL("SL"), + SM("SM"), + SN("SN"), + SO("SO"), + SR("SR"), + SS("SS"), + ST("ST"), + SV("SV"), + SX("SX"), + SY("SY"), + SZ("SZ"), + TC("TC"), + TD("TD"), + TF("TF"), + TG("TG"), + TH("TH"), + TJ("TJ"), + TK("TK"), + TL("TL"), + TM("TM"), + TN("TN"), + TO("TO"), + TR("TR"), + TT("TT"), + TV("TV"), + TW("TW"), + TZ("TZ"), + UA("UA"), + UG("UG"), + UM("UM"), + US("US"), + UY("UY"), + UZ("UZ"), + VA("VA"), + VC("VC"), + VE("VE"), + VG("VG"), + VI("VI"), + VN("VN"), + VU("VU"), + WF("WF"), + WS("WS"), + YE("YE"), + YT("YT"), + ZA("ZA"), + ZM("ZM"), + ZW("ZW"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.GeoLocation c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private GeoLocation(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.GeoLocation fromValue(String value) { + Host.GeoLocation constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + + public enum SupportVersioning { + + YES("yes"), + NO("no"), + UNKNOWN("unknown"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Host.SupportVersioning c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private SupportVersioning(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Host.SupportVersioning fromValue(String value) { + Host.SupportVersioning constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java new file mode 100644 index 000000000..1527f5503 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/License.java @@ -0,0 +1,113 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Distribution License Items + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "license_ref", + "start_date" +}) +public class License implements Serializable +{ + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + @JsonPropertyDescription("Link to license document.") + private URI licenseRef; + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + @JsonPropertyDescription("Starting date of license. If date is set in the future, it indicates embargo period.") + private String startDate; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 4148207295817559010L; + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public URI getLicenseRef() { + return licenseRef; + } + + /** + * The Dataset Distribution License Reference Schema + *

+ * Link to license document. + * (Required) + * + */ + @JsonProperty("license_ref") + public void setLicenseRef(URI licenseRef) { + this.licenseRef = licenseRef; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public String getStartDate() { + return startDate; + } + + /** + * The Dataset Distribution License Start Date Schema + *

+ * Starting date of license. If date is set in the future, it indicates embargo period. + * (Required) + * + */ + @JsonProperty("start_date") + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java new file mode 100644 index 000000000..06b54a1f1 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/MetadataStandardId.java @@ -0,0 +1,153 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Standard ID Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "identifier", + "type" +}) +public class MetadataStandardId implements Serializable +{ + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + @JsonPropertyDescription("Identifier for the metadata standard used.") + private String identifier; + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("Identifier type. Allowed values: url, other") + private MetadataStandardId.Type type; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7641042701935397947L; + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public String getIdentifier() { + return identifier; + } + + /** + * The Dataset Metadata Standard Identifier Value Schema + *

+ * Identifier for the metadata standard used. + * (Required) + * + */ + @JsonProperty("identifier") + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public MetadataStandardId.Type getType() { + return type; + } + + /** + * The Dataset Metadata Standard Identifier Type Schema + *

+ * Identifier type. Allowed values: url, other + * (Required) + * + */ + @JsonProperty("type") + public void setType(MetadataStandardId.Type type) { + this.type = type; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Type { + + URL("url"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (MetadataStandardId.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static MetadataStandardId.Type fromValue(String value) { + MetadataStandardId.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java new file mode 100644 index 000000000..d6057ca62 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -0,0 +1,368 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * The Dataset Metadata Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "language", + "metadata_standard_id" +}) +public class Metadatum implements Serializable +{ + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + @JsonPropertyDescription("Language of the metadata expressed using ISO 639-3.") + private Metadatum.Language language; + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + private MetadataStandardId metadataStandardId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 6511312853153406190L; + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Metadata Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public Metadatum.Language getLanguage() { + return language; + } + + /** + * The Dataset Metadata Language Schema + *

+ * Language of the metadata expressed using ISO 639-3. + * (Required) + * + */ + @JsonProperty("language") + public void setLanguage(Metadatum.Language language) { + this.language = language; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public MetadataStandardId getMetadataStandardId() { + return metadataStandardId; + } + + /** + * The Dataset Metadata Standard ID Schema + *

+ * + * (Required) + * + */ + @JsonProperty("metadata_standard_id") + public void setMetadataStandardId(MetadataStandardId metadataStandardId) { + this.metadataStandardId = metadataStandardId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public enum Language { + + AAR("aar"), + ABK("abk"), + AFR("afr"), + AKA("aka"), + AMH("amh"), + ARA("ara"), + ARG("arg"), + ASM("asm"), + AVA("ava"), + AVE("ave"), + AYM("aym"), + AZE("aze"), + BAK("bak"), + BAM("bam"), + BEL("bel"), + BEN("ben"), + BIH("bih"), + BIS("bis"), + BOD("bod"), + BOS("bos"), + BRE("bre"), + BUL("bul"), + CAT("cat"), + CES("ces"), + CHA("cha"), + CHE("che"), + CHU("chu"), + CHV("chv"), + COR("cor"), + COS("cos"), + CRE("cre"), + CYM("cym"), + DAN("dan"), + DEU("deu"), + DIV("div"), + DZO("dzo"), + ELL("ell"), + ENG("eng"), + EPO("epo"), + EST("est"), + EUS("eus"), + EWE("ewe"), + FAO("fao"), + FAS("fas"), + FIJ("fij"), + FIN("fin"), + FRA("fra"), + FRY("fry"), + FUL("ful"), + GLA("gla"), + GLE("gle"), + GLG("glg"), + GLV("glv"), + GRN("grn"), + GUJ("guj"), + HAT("hat"), + HAU("hau"), + HBS("hbs"), + HEB("heb"), + HER("her"), + HIN("hin"), + HMO("hmo"), + HRV("hrv"), + HUN("hun"), + HYE("hye"), + IBO("ibo"), + IDO("ido"), + III("iii"), + IKU("iku"), + ILE("ile"), + INA("ina"), + IND("ind"), + IPK("ipk"), + ISL("isl"), + ITA("ita"), + JAV("jav"), + JPN("jpn"), + KAL("kal"), + KAN("kan"), + KAS("kas"), + KAT("kat"), + KAU("kau"), + KAZ("kaz"), + KHM("khm"), + KIK("kik"), + KIN("kin"), + KIR("kir"), + KOM("kom"), + KON("kon"), + KOR("kor"), + KUA("kua"), + KUR("kur"), + LAO("lao"), + LAT("lat"), + LAV("lav"), + LIM("lim"), + LIN("lin"), + LIT("lit"), + LTZ("ltz"), + LUB("lub"), + LUG("lug"), + MAH("mah"), + MAL("mal"), + MAR("mar"), + MKD("mkd"), + MLG("mlg"), + MLT("mlt"), + MON("mon"), + MRI("mri"), + MSA("msa"), + MYA("mya"), + NAU("nau"), + NAV("nav"), + NBL("nbl"), + NDE("nde"), + NDO("ndo"), + NEP("nep"), + NLD("nld"), + NNO("nno"), + NOB("nob"), + NOR("nor"), + NYA("nya"), + OCI("oci"), + OJI("oji"), + ORI("ori"), + ORM("orm"), + OSS("oss"), + PAN("pan"), + PLI("pli"), + POL("pol"), + POR("por"), + PUS("pus"), + QUE("que"), + ROH("roh"), + RON("ron"), + RUN("run"), + RUS("rus"), + SAG("sag"), + SAN("san"), + SIN("sin"), + SLK("slk"), + SLV("slv"), + SME("sme"), + SMO("smo"), + SNA("sna"), + SND("snd"), + SOM("som"), + SOT("sot"), + SPA("spa"), + SQI("sqi"), + SRD("srd"), + SRP("srp"), + SSW("ssw"), + SUN("sun"), + SWA("swa"), + SWE("swe"), + TAH("tah"), + TAM("tam"), + TAT("tat"), + TEL("tel"), + TGK("tgk"), + TGL("tgl"), + THA("tha"), + TIR("tir"), + TON("ton"), + TSN("tsn"), + TSO("tso"), + TUK("tuk"), + TUR("tur"), + TWI("twi"), + UIG("uig"), + UKR("ukr"), + URD("urd"), + UZB("uzb"), + VEN("ven"), + VIE("vie"), + VOL("vol"), + WLN("wln"), + WOL("wol"), + XHO("xho"), + YID("yid"), + YOR("yor"), + ZHA("zha"), + ZHO("zho"), + ZUL("zul"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (Metadatum.Language c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Language(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static Metadatum.Language fromValue(String value) { + Metadatum.Language constant = CONSTANTS.get(value); + if (constant == null) { + return null; +// throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java new file mode 100644 index 000000000..0e29d1153 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/PidSystem.java @@ -0,0 +1,63 @@ + +package eu.eudat.models.rda; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PidSystem { + + ARK("ark"), + ARXIV("arxiv"), + BIBCODE("bibcode"), + DOI("doi"), + EAN_13("ean13"), + EISSN("eissn"), + HANDLE("handle"), + IGSN("igsn"), + ISBN("isbn"), + ISSN("issn"), + ISTC("istc"), + LISSN("lissn"), + LSID("lsid"), + PMID("pmid"), + PURL("purl"), + UPC("upc"), + URL("url"), + URN("urn"), + OTHER("other"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (PidSystem c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private PidSystem(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static PidSystem fromValue(String value) { + PidSystem constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java new file mode 100644 index 000000000..09c231ca3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Project.java @@ -0,0 +1,212 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The DMP Project Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "end", + "funding", + "start", + "title" +}) +public class Project implements Serializable +{ + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Project description") + private String description; + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + @JsonPropertyDescription("Project end date") + private String end; + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + @JsonPropertyDescription("Funding related with a project") + private List funding = null; + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + @JsonPropertyDescription("Project start date") + private String start; + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Project title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1437619307195890472L; + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The DMP Project Description Schema + *

+ * Project description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public String getEnd() { + return end; + } + + /** + * The DMP Project End Date Schema + *

+ * Project end date + * (Required) + * + */ + @JsonProperty("end") + public void setEnd(String end) { + this.end = end; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public List getFunding() { + return funding; + } + + /** + * The DMP Project Funding Schema + *

+ * Funding related with a project + * + */ + @JsonProperty("funding") + public void setFunding(List funding) { + this.funding = funding; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public String getStart() { + return start; + } + + /** + * The DMP Project Start Date Schema + *

+ * Project start date + * (Required) + * + */ + @JsonProperty("start") + public void setStart(String start) { + this.start = start; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The DMP Project Title Schema + *

+ * Project title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java new file mode 100644 index 000000000..61df61b32 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/RDAModel.java @@ -0,0 +1,58 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * RDA DMP Common Standard Schema + *

+ * JSON Schema for the RDA DMP Common Standard + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "dmp" +}) +public class RDAModel implements Serializable +{ + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + private Dmp dmp; + private final static long serialVersionUID = 7331666133368350998L; + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public Dmp getDmp() { + return dmp; + } + + /** + * The DMP Schema + *

+ * + * (Required) + * + */ + @JsonProperty("dmp") + public void setDmp(Dmp dmp) { + this.dmp = dmp; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java new file mode 100644 index 000000000..0486df588 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Security & Policy Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "title" +}) +public class SecurityAndPrivacy implements Serializable +{ + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description") + private String description; + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + @JsonPropertyDescription("Title") + private String title; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 7863747935827682977L; + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Security & Policy Description Schema + *

+ * Description + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public String getTitle() { + return title; + } + + /** + * The Dataset Security & Policy Title Schema + *

+ * Title + * (Required) + * + */ + @JsonProperty("title") + public void setTitle(String title) { + this.title = title; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java new file mode 100644 index 000000000..eac85da72 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -0,0 +1,109 @@ + +package eu.eudat.models.rda; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * The Dataset Technical Resource Items Schema + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "description", + "name" +}) +public class TechnicalResource implements Serializable +{ + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + @JsonPropertyDescription("Description of the technical resource") + private String description; + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + @JsonPropertyDescription("Name of the technical resource") + private String name; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -7451757227129483110L; + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public String getDescription() { + return description; + } + + /** + * The Dataset Technical Resource Description Schema + *

+ * Description of the technical resource + * + */ + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * The Dataset Technical Resource Name Schema + *

+ * Name of the technical resource + * (Required) + * + */ + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java new file mode 100644 index 000000000..48549d75a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -0,0 +1,15 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.ContactId; + +import java.util.UUID; + +public class ContactIdRDAMapper { + + public static ContactId toRDA(UUID id) { + ContactId rda = new ContactId(); + rda.setIdentifier(id.toString()); + rda.setType(ContactId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java new file mode 100644 index 000000000..69ea2310e --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Contact; +import eu.eudat.models.rda.ContactId; + +public class ContactRDAMapper { + + public static Contact toRDA(UserInfo creator) { + Contact rda = new Contact(); + rda.setName(creator.getName()); + rda.setMbox(creator.getEmail()); + rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java new file mode 100644 index 000000000..107dfb996 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorIdRDAMapper.java @@ -0,0 +1,16 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.Contributor; +import eu.eudat.models.rda.ContributorId; + +import java.util.UUID; + +public class ContributorIdRDAMapper { + + public static ContributorId toRDA(UUID id) { + ContributorId rda = new ContributorId(); + rda.setIdentifier(id.toString()); + rda.setType(ContributorId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java new file mode 100644 index 000000000..681d98940 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContributorRDAMapper.java @@ -0,0 +1,20 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.UserDMP; +import eu.eudat.models.rda.Contributor; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; + +public class ContributorRDAMapper { + + public static Contributor toRDA(UserDMP userDMP) { + Contributor rda = new Contributor(); + rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId())); + rda.setName(userDMP.getUser().getName()); + rda.setMbox(userDMP.getUser().getEmail()); + rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name()))); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java new file mode 100644 index 000000000..ab791e215 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetIdRDAMapper.java @@ -0,0 +1,17 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.DatasetId; + +import java.util.UUID; + +public class DatasetIdRDAMapper { + + public static DatasetId toRDA(UUID id) { + DatasetId rda = new DatasetId(); + rda.setIdentifier(id.toString()); + rda.setType(DatasetId.Type.OTHER); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java new file mode 100644 index 000000000..103ba72c6 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -0,0 +1,100 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.utilities.json.JsonSearcher; +import eu.eudat.models.data.datasetwizard.DatasetWizardModel; +import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; +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.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +@Component +public class DatasetRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); + + private DatasetManager datasetManager; + + @Autowired + public DatasetRDAMapper(DatasetManager datasetManager) { + this.datasetManager = datasetManager; + } + + @Transactional + public Dataset toRDA(eu.eudat.data.entities.Dataset dataset) { + Dataset rda = new Dataset(); + rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); + rda.setTitle(dataset.getLabel()); + rda.setDescription(dataset.getDescription()); + try { + + DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); + ObjectMapper mapper = new ObjectMapper(); + JsonNode properties = mapper.readTree(dataset.getProperties()); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + } + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + } + List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); + if (!metadataNodes.isEmpty()) { + rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + } + List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); + if (!qaNodes.isEmpty()) { + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); + if (!distributionNodes.isEmpty()) { + rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + } + List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); + if (!keywordNodes.isEmpty()) { + rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + } + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + } + List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); + if (!securityAndPrivacyNodes.isEmpty()) { + rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + } + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + } + List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); + if (!technicalResourceNodes.isEmpty()) { + rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + } + + + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java new file mode 100644 index 000000000..513affd98 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -0,0 +1,39 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Distribution; + +import java.net.URI; +import java.util.Collections; + +public class DistributionRDAMapper { + + public static Distribution toRDA(JsonNode structure, JsonNode properties) { + Distribution rda = new Distribution(); + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("access_url")) { + rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("available_util")) { + rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("byte_size")) { + rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + } else if (rdaProperty.contains("data_access")) { + rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("download_url")) { + rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("format")) { + rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("host")) { + rda.setHost(HostRDAMapper.toRDA(structure, properties)); + } else if (rdaProperty.contains("license")) { + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java new file mode 100644 index 000000000..095c26e11 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.DmpId; + +import java.util.UUID; + +public class DmpIdRDAMapper { + + public static DmpId toRDA(Object id) { + DmpId rda = new DmpId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(DmpId.Type.OTHER); + } else { + rda.setType(DmpId.Type.DOI); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java new file mode 100644 index 000000000..620229a27 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -0,0 +1,51 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.DMP; +import eu.eudat.data.entities.UserDMP; +import eu.eudat.data.entities.UserInfo; +import eu.eudat.models.rda.Dmp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.transaction.Transactional; +import java.util.Collections; +import java.util.stream.Collectors; + +@Component +public class DmpRDAMapper { + + private DatasetRDAMapper datasetRDAMapper; + + @Autowired + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + this.datasetRDAMapper = datasetRDAMapper; + } + + @Transactional + public Dmp toRDA(DMP dmp) { + Dmp rda = new Dmp(); + if (dmp.getDoi() != null && !dmp.getDoi().isEmpty()) { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getDoi())); + } else { + rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId())); + } + rda.setCreated(dmp.getCreated()); + rda.setDescription(dmp.getDescription()); + rda.setModified(dmp.getModified()); + rda.setTitle(dmp.getLabel()); + + UserInfo creator; + if (dmp.getCreator() != null) { + creator = dmp.getCreator(); + } else { + creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo()); + } + rda.setContact(ContactRDAMapper.toRDA(creator)); + rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); + rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); + rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); + + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java new file mode 100644 index 000000000..f0dc5ff4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FunderIdRDAMapper.java @@ -0,0 +1,19 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.FunderId; + +import java.util.UUID; + +public class FunderIdRDAMapper { + + public static FunderId toRDA(Object id) { + FunderId rda = new FunderId(); + rda.setIdentifier(id.toString()); + if (id instanceof UUID) { + rda.setType(FunderId.Type.OTHER); + } else { + rda.setType(FunderId.Type.FUNDREF); + } + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java new file mode 100644 index 000000000..e0b8fbe65 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Funding; + +public class FundingRDAMapper { + + public static Funding toRDA(Grant grant) { + Funding rda = new Funding(); + String referencePrefix; + String shortReference; + if (grant.getFunder().getReference() != null) { + referencePrefix = grant.getFunder().getReference().split(":")[0]; + shortReference = grant.getFunder().getReference().substring(referencePrefix.length() + 1); + rda.setFunderId(FunderIdRDAMapper.toRDA(shortReference)); + } else { + rda.setFunderId(FunderIdRDAMapper.toRDA(grant.getFunder().getId())); + } + referencePrefix = grant.getReference().split(":")[0]; + shortReference = grant.getReference().substring(referencePrefix.length() + 1); + rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java new file mode 100644 index 000000000..d05ec5d02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/GrantIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.GrantId; + +public class GrantIdRDAMapper { + + public static GrantId toRDA(String id) { + GrantId rda = new GrantId(); + rda.setIdentifier(id); + rda.setType(GrantId.Type.OTHER); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java new file mode 100644 index 000000000..9a32cc697 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -0,0 +1,41 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.Host; +import eu.eudat.models.rda.PidSystem; + +import java.net.URI; +import java.util.Collections; + +public class HostRDAMapper { + + public static Host toRDA(JsonNode structure, JsonNode properties) { + Host rda = new Host(); + String rdaProperty = structure.get("rdaProperties").asText(); + if (rdaProperty.contains("availability")) { + rda.setAvailability(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_frequency")) { + rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("backup_type")) { + rda.setBackupType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("certified_with")) { + rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("geo_location")) { + rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("pid_system")) { + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); + } else if (rdaProperty.contains("storage_type")) { + rda.setStorageType(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("support_versioning")) { + rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); + } else if (rdaProperty.contains("title")) { + rda.setTitle(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("url")) { + rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java new file mode 100644 index 000000000..68817bd3d --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -0,0 +1,23 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.License; + +import java.net.URI; + +public class LicenseRDAMapper { + + public static License toRDA(JsonNode structure, JsonNode properties) { + License rda = new License(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("license_ref")) { + rda.setLicenseRef(URI.create(value)); + } else if (rdaProperty.contains("start_date")) { + rda.setStartDate(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java new file mode 100644 index 000000000..fa638d3e3 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -0,0 +1,44 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.models.rda.Metadatum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Iterator; + +public class MetadataRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); + + public static Metadatum toRDA(JsonNode structure, JsonNode properties) { + Metadatum rda = new Metadatum(); + JsonNode dataNode = null; + String rdaProperty = structure.get("rdaProperty").asText(); + if (rdaProperty.contains("metadata_standard_id")) { + try { + String jsonText = properties.get(structure.get("id").asText()).asText(); + if (jsonText != null && !jsonText.isEmpty()) { + dataNode = new ObjectMapper().readTree(jsonText); + for (Iterator it = dataNode.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + } + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaProperty.contains("description")) { + rda.setDescription(properties.get(structure.get("id").asText()).asText()); + } else if (rdaProperty.contains("language")) { + String language = properties.get(structure.get("id").asText()).asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + rda.setLanguage(lang); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java new file mode 100644 index 000000000..586446e02 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataStandardIdRDAMapper.java @@ -0,0 +1,13 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.models.rda.MetadataStandardId; + +public class MetadataStandardIdRDAMapper { + + public static MetadataStandardId toRDA(String uri) { + MetadataStandardId rda = new MetadataStandardId(); + rda.setIdentifier(uri); + rda.setType(MetadataStandardId.Type.URL); + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java new file mode 100644 index 000000000..d97eace4a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -0,0 +1,25 @@ +package eu.eudat.models.rda.mapper; + +import eu.eudat.data.entities.Funder; +import eu.eudat.data.entities.Grant; +import eu.eudat.models.rda.Project; + +import java.util.Collections; + +public class ProjectRDAMapper { + + public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) { + Project rda = new Project(); + rda.setTitle(project.getLabel()); + rda.setDescription(project.getDescription()); + if (project.getStartdate() != null) { + rda.setStart(project.getStartdate().toString()); + } + if (project.getEnddate() != null) { + rda.setEnd(project.getEnddate().toString()); + } + rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant))); + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java new file mode 100644 index 000000000..f7f95633f --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.SecurityAndPrivacy; + +public class SecurityAndPrivacyRDAMapper { + + public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + SecurityAndPrivacy rda = new SecurityAndPrivacy(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("title")) { + rda.setTitle(value); + } + + return rda; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java new file mode 100644 index 000000000..b2652901a --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -0,0 +1,21 @@ +package eu.eudat.models.rda.mapper; + +import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.models.rda.TechnicalResource; + +public class TechnicalResourceRDAMapper { + + public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + TechnicalResource rda = new TechnicalResource(); + String rdaProperty = structure.get("rdaProperty").asText(); + String value = properties.get(structure.get("id").asText()).asText(); + + if (rdaProperty.contains("description")) { + rda.setDescription(value); + } else if (rdaProperty.contains("name")) { + rda.setName(value); + } + + return rda; + } +} From dbf271047cb8b5971f132873b916f3f3884346e7 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 23 Mar 2020 18:09:31 +0200 Subject: [PATCH 132/160] Improved object coupling for various objects on the dataset form --- .../utilities/helpers/MyStringUtils.java | 21 ++++ .../logic/utilities/json/JsonSearcher.java | 1 + .../user/components/datasetprofile/Field.java | 6 +- .../components/datasetprofile/FieldSet.java | 9 +- .../models/rda/mapper/DatasetRDAMapper.java | 27 ++-- .../rda/mapper/DistributionRDAMapper.java | 107 ++++++++++++++-- .../models/rda/mapper/HostRDAMapper.java | 98 +++++++++++---- .../models/rda/mapper/LicenseRDAMapper.java | 6 +- .../models/rda/mapper/MetadataRDAMapper.java | 119 +++++++++++++++--- .../mapper/SecurityAndPrivacyRDAMapper.java | 57 ++++++++- .../mapper/TechnicalResourceRDAMapper.java | 58 ++++++++- .../dataset-description-form.model.ts | 2 +- 12 files changed, 424 insertions(+), 87 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java new file mode 100644 index 000000000..1a071e04c --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/helpers/MyStringUtils.java @@ -0,0 +1,21 @@ +package eu.eudat.logic.utilities.helpers; + +public class MyStringUtils { + + public static int getFirstDifference(String s1, String s2) { + char[] s1ar = s1.toCharArray(); + char[] s2ar = s2.toCharArray(); + + for(int i = 0; i < s1ar.length; i++) { + if (s2ar.length > i) { + if (s1ar[i] != s2ar[i]) { + return i; + } + } else { + return i; + } + } + + return -1; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java index ca2372b91..979053830 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/json/JsonSearcher.java @@ -1,6 +1,7 @@ package eu.eudat.logic.utilities.json; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import java.util.ArrayList; import java.util.Iterator; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java index 4950261c4..1c735e1a9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/Field.java @@ -149,7 +149,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin this.rdaProperty = rdaProperty; } - Field cloneForMultiplicity(String key, Map properties) { + Field cloneForMultiplicity(String key, Map properties, int index) { Field newField = new Field(); newField.id = key; newField.ordinal = this.ordinal; @@ -161,6 +161,7 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin newField.data = this.data; newField.validations = this.validations; newField.rdaProperty = this.rdaProperty; + newField.numbering = "mult" + index + "_" + this.numbering; return newField; } @@ -204,8 +205,9 @@ public class Field implements Comparable, PropertiesModelBuilder, ViewStyleDefin } this.multiplicityItems = new LinkedList<>(); List compositeKeys = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList()); + int index = 1; for (String key : compositeKeys) { - this.multiplicityItems.add(this.cloneForMultiplicity(key, properties)); + this.multiplicityItems.add(this.cloneForMultiplicity(key, properties, index)); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java index 51663ddaf..277534d16 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/user/components/datasetprofile/FieldSet.java @@ -163,16 +163,18 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe }); List compositeKeysFather = properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId())).collect(Collectors.toList()); List Ids=new ArrayList<>(); + int index = 1; for (String composite : compositeKeysFather) { String[] split = composite.split("_"); if (!Ids.contains(split[2])) { Ids.add(split[2]); - this.multiplicityItems.add(this.CloneForMultiplicity2(properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId() + "_" + split[2])).collect(Collectors.toList()), properties,split)); + this.multiplicityItems.add(this.CloneForMultiplicity2(properties.keySet().stream().filter(keys -> keys.startsWith("multiple_" + this.getId() + "_" + split[2])).collect(Collectors.toList()), properties,split, index)); + index++; } } } - private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids){ + private FieldSet CloneForMultiplicity2(List key, Map properties,String[] ids, int index){ FieldSet newFieldSet = new FieldSet(); newFieldSet.id = ids[0]+"_"+ids[1]+"_"+ids[2]; newFieldSet.description = this.description; @@ -181,8 +183,9 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe newFieldSet.title = this.title; newFieldSet.ordinal = this.ordinal; newFieldSet.fields = new LinkedList(); + for (Field field: this.fields) { - newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties)); + newFieldSet.fields.add(field.cloneForMultiplicity(newFieldSet.id + "_" + field.getId(), properties, index)); } return newFieldSet; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 103ba72c6..5eb9cc685 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -1,21 +1,17 @@ package eu.eudat.models.rda.mapper; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; -import org.json.JSONObject; 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.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -41,52 +37,51 @@ public class DatasetRDAMapper { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); - JsonNode properties = mapper.readTree(dataset.getProperties()); String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); if (!typeNodes.isEmpty()) { - rda.setType(properties.get(typeNodes.get(0).get("id").asText()).asText()); + rda.setType(typeNodes.get(0).get("value").asText()); } List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); if (!languageNodes.isEmpty()) { - rda.setLanguage(Dataset.Language.fromValue(properties.get(languageNodes.get(0).get("id").asText()).asText())); + rda.setLanguage(Dataset.Language.fromValue(languageNodes.get(0).get("value").asText())); } List metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.metadata"); if (!metadataNodes.isEmpty()) { - rda.setMetadata(metadataNodes.stream().map(node -> MetadataRDAMapper.toRDA(node, properties)).collect(Collectors.toList())); + rda.setMetadata(MetadataRDAMapper.toRDAList(metadataNodes)); } List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { - rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> properties.get(qaNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> properties.get(preservationNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { - rda.setDistribution(distributionNodes.stream().map(distributionNode -> DistributionRDAMapper.toRDA(distributionNode, properties)).collect(Collectors.toList())); + rda.setDistribution(DistributionRDAMapper.toRDAList(distributionNodes)); } List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { - rda.setKeyword(keywordNodes.stream().map(keywordNode -> properties.get(keywordNode.get("id").asText()).asText()).collect(Collectors.toList())); + rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { - rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(properties.get(personalDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setPersonalData(personalDataNodes.stream().map(personalDataNode -> Dataset.PersonalData.fromValue(personalDataNode.get("value").asText())).findFirst().get()); } List securityAndPrivacyNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.security_and_privacy"); if (!securityAndPrivacyNodes.isEmpty()) { - rda.setSecurityAndPrivacy(securityAndPrivacyNodes.stream().map(securityAndPrivacyNode -> SecurityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNode, properties)).collect(Collectors.toList())); + rda.setSecurityAndPrivacy(SecurityAndPrivacyRDAMapper.toRDAList(securityAndPrivacyNodes)); } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(properties.get(sensitiveDataNode.get("id").asText()).asText())).findFirst().get()); + rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { - rda.setTechnicalResource(technicalResourceNodes.stream().map(technicalResourceNode -> TechnicalResourceRDAMapper.toRDA(technicalResourceNode, properties)).collect(Collectors.toList())); + rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 513affd98..98cb6960b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,39 +1,120 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; import java.net.URI; -import java.util.Collections; +import java.util.*; public class DistributionRDAMapper { - public static Distribution toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + Distribution rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName : PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case ACCESS_URL: + rda.setAccessUrl(rdaValue); + break; + case AVAILABLE_UTIL: + rda.setAvailableUntil(rdaValue); + break; + case DOWNLOAD_URL: + rda.setDownloadUrl(URI.create(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case DATA_ACCESS: + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + break; + case BYTE_SIZE: + rda.setByteSize(Integer.parseInt(rdaValue)); + break; + case LICENSE: + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); + break; + case FORMAT: + rda.setFormat(Collections.singletonList(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case HOST: + rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); - String rdaProperty = structure.get("rdaProperty").asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); if (rdaProperty.contains("access_url")) { - rda.setAccessUrl(properties.get(structure.get("id").asText()).asText()); + rda.setAccessUrl(rdaValue); } else if (rdaProperty.contains("available_util")) { - rda.setAvailableUntil(properties.get(structure.get("id").asText()).asText()); + rda.setAvailableUntil(rdaValue); } else if (rdaProperty.contains("byte_size")) { - rda.setByteSize(properties.get(structure.get("id").asText()).asInt()); + rda.setByteSize(Integer.parseInt(rdaValue)); } else if (rdaProperty.contains("data_access")) { - rda.setDataAccess(Distribution.DataAccess.fromValue(properties.get(structure.get("id").asText()).asText())); + rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue); } else if (rdaProperty.contains("download_url")) { - rda.setDownloadUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + rda.setDownloadUrl(URI.create(rdaValue)); } else if (rdaProperty.contains("format")) { - rda.setFormat(Collections.singletonList(properties.get(structure.get("id").asText()).asText())); + rda.setFormat(Collections.singletonList(rdaValue)); } else if (rdaProperty.contains("host")) { - rda.setHost(HostRDAMapper.toRDA(structure, properties)); +// rda.setHost(HostRDAMapper.toRDA(node)); } else if (rdaProperty.contains("license")) { - rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(structure, properties))); + rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); + rda.setTitle(rdaValue); } return rda; } + + private static Distribution getRelative( Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); + } + + private enum PropertyName { + ACCESS_URL("access_url"), + AVAILABLE_UTIL("available_util"), + BYTE_SIZE("byte_size"), + DATA_ACCESS("data_access"), + DESCRIPTION("description"), + DOWNLOAD_URL("download_url"), + FORMAT("format"), + HOST("host"), + LICENSE("license"), + TITLE("title"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java index 9a32cc697..0983f3d3b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/HostRDAMapper.java @@ -1,41 +1,91 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Host; import eu.eudat.models.rda.PidSystem; import java.net.URI; import java.util.Collections; +import java.util.List; public class HostRDAMapper { - public static Host toRDA(JsonNode structure, JsonNode properties) { + public static Host toRDA(List nodes, String numbering) { Host rda = new Host(); - String rdaProperty = structure.get("rdaProperties").asText(); - if (rdaProperty.contains("availability")) { - rda.setAvailability(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_frequency")) { - rda.setBackupFrequency(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("backup_type")) { - rda.setBackupType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("certified_with")) { - rda.setCertifiedWith(Host.CertifiedWith.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("geo_location")) { - rda.setGeoLocation(Host.GeoLocation.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("pid_system")) { - rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(properties.get(structure.get("id").asText()).asText()))); - } else if (rdaProperty.contains("storage_type")) { - rda.setStorageType(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("support_versioning")) { - rda.setSupportVersioning(Host.SupportVersioning.fromValue(properties.get(structure.get("id").asText()).asText())); - } else if (rdaProperty.contains("title")) { - rda.setTitle(properties.get(structure.get("id").asText()).asText()); - } else if (rdaProperty.contains("url")) { - rda.setUrl(URI.create(properties.get(structure.get("id").asText()).asText())); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperties").asText(); + if (rdaProperty.contains("host")) { + int firstDiff = MyStringUtils.getFirstDifference(numbering, node.get("numbering").asText()); + if (firstDiff == -1 || firstDiff > 2) { + String rdaValue = node.get("value").asText(); + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case AVAILABILITY: + rda.setAvailability(rdaValue); + break; + case BACKUP_FREQUENCY: + rda.setBackupFrequency(rdaValue); + break; + case BACKUP_TYPE: + rda.setBackupType(rdaValue); + break; + case CERTIFIED_WITH: + rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue)); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + case GEO_LOCATION: + rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue)); + break; + case PID_SYSTEM: + rda.setPidSystem(Collections.singletonList(PidSystem.fromValue(rdaValue))); + break; + case STORAGE_TYPE: + rda.setStorageType(rdaValue); + break; + case SUPPORT_VERSIONING: + rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue)); + break; + case TITLE: + rda.setTitle(rdaValue); + break; + case URL: + rda.setUrl(URI.create(rdaValue)); + break; + } + } + } + } + } } return rda; } + + private enum PropertyName { + AVAILABILITY("availability"), + BACKUP_FREQUENCY("backup_frequency"), + BACKUP_TYPE("backup_type"), + CERTIFIED_WITH("certified_with"), + DESCRIPTION("description"), + GEO_LOCATION("geo_location"), + PID_SYSTEM("pid_system"), + STORAGE_TYPE("storage_type"), + SUPPORT_VERSIONING("support_versioning"), + TITLE("title"), + URL("url"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java index 68817bd3d..6f94a73c4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/LicenseRDAMapper.java @@ -7,10 +7,10 @@ import java.net.URI; public class LicenseRDAMapper { - public static License toRDA(JsonNode structure, JsonNode properties) { + public static License toRDA(JsonNode node) { License rda = new License(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("license_ref")) { rda.setLicenseRef(URI.create(value)); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index fa638d3e3..c7e3ba35f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -2,43 +2,124 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.TextNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Metadatum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Iterator; +import java.util.*; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); - public static Metadatum toRDA(JsonNode structure, JsonNode properties) { - Metadatum rda = new Metadatum(); - JsonNode dataNode = null; - String rdaProperty = structure.get("rdaProperty").asText(); - if (rdaProperty.contains("metadata_standard_id")) { - try { - String jsonText = properties.get(structure.get("id").asText()).asText(); - if (jsonText != null && !jsonText.isEmpty()) { - dataNode = new ObjectMapper().readTree(jsonText); - for (Iterator it = dataNode.elements(); it.hasNext(); ) { - JsonNode data = it.next(); - if (data.get("uri") != null) { - rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); - } + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + List rdas = new ArrayList<>(); + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case METADATA_STANDARD_ID: + if (rdaValue instanceof ArrayNode) { + try { + ObjectMapper mapper = new ObjectMapper(); + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = null; + data = mapper.readTree(it.next().asText()); + if (data.get("uri") != null) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); + rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); + } + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { + rdas.add(new Metadatum()); + rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); + } + break; + case DESCRIPTION: + if (!rdaValue.asText().isEmpty()) { + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setDescription(rdaValue.asText()); + } else { + rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); + } + } + break; + case LANGUAGE: + String language = rdaValue.asText(); + Metadatum.Language lang = Metadatum.Language.fromValue(language); + Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); + if (rda != null) { + rda.setLanguage(lang); + } else { + rdas.forEach(rda1 -> rda1.setLanguage(lang)); + } + break; + } + } + } + + } + + return rdas; + } + + public static Metadatum toRDA(JsonNode node) { + Metadatum rda = new Metadatum(); + String rdaProperty = node.get("rdaProperty").asText(); + JsonNode rdaValue = node.get("value"); + if (rdaProperty.contains("metadata_standard_id")) { + if (rdaValue instanceof ArrayNode) { + for (Iterator it = rdaValue.elements(); it.hasNext(); ) { + JsonNode data = it.next(); + if (data.get("uri") != null) { + rda.setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); } } - } catch (IOException e) { - logger.error(e.getMessage(), e); } } else if (rdaProperty.contains("description")) { - rda.setDescription(properties.get(structure.get("id").asText()).asText()); + rda.setDescription(rdaValue.asText()); } else if (rdaProperty.contains("language")) { - String language = properties.get(structure.get("id").asText()).asText(); + String language = rdaValue.asText(); Metadatum.Language lang = Metadatum.Language.fromValue(language); rda.setLanguage(lang); } return rda; } + + private static Metadatum getRelative(List rdas, Map rdaMap, String numbering) { + String target = rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering))).map(Map.Entry::getKey).orElse(""); + return rdas.stream().filter(rda -> rda.getMetadataStandardId().getIdentifier().equals(target)).distinct().findFirst().orElse(null); + } + + private enum PropertyName { + METADATA_STANDARD_ID("metadata_standard_id"), + DESCRIPTION("description"), + LANGUAGE("language"); + + private final String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index f7f95633f..fc44cc182 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -1,14 +1,45 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import java.util.*; + public class SecurityAndPrivacyRDAMapper { - public static SecurityAndPrivacy toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + SecurityAndPrivacy rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case TITLE: + rda.setTitle(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value =node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +49,24 @@ public class SecurityAndPrivacyRDAMapper { return rda; } + + private static SecurityAndPrivacy getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); + } + + private enum PropertyName { + TITLE("title"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index b2652901a..c48f93cae 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -1,14 +1,46 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import eu.eudat.logic.utilities.helpers.MyStringUtils; +import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import java.util.*; + public class TechnicalResourceRDAMapper { - public static TechnicalResource toRDA(JsonNode structure, JsonNode properties) { + public static List toRDAList(List nodes) { + Map rdaMap = new HashMap<>(); + + for (JsonNode node: nodes) { + String rdaProperty = node.get("rdaProperty").asText(); + String rdaValue = node.get("value").asText(); + + TechnicalResource rda = getRelative(rdaMap, node.get("numbering").asText()); + if (!rdaMap.containsValue(rda)) { + rdaMap.put(node.get("numbering").asText(), rda); + } + for (PropertyName propertyName: PropertyName.values()) { + if (rdaProperty.contains(propertyName.getName())) { + switch (propertyName) { + case NAME: + rda.setName(rdaValue); + break; + case DESCRIPTION: + rda.setDescription(rdaValue); + break; + } + } + } + } + + return new ArrayList<>(rdaMap.values()); + } + + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); - String rdaProperty = structure.get("rdaProperty").asText(); - String value = properties.get(structure.get("id").asText()).asText(); + String rdaProperty = node.get("rdaProperty").asText(); + String value = node.get("value").asText(); if (rdaProperty.contains("description")) { rda.setDescription(value); @@ -18,4 +50,24 @@ public class TechnicalResourceRDAMapper { return rda; } + + private static TechnicalResource getRelative(Map rdaMap, String numbering) { + return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0) + .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); + } + + private enum PropertyName { + NAME("name"), + DESCRIPTION("description"); + + private String name; + + PropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts index c4b8153b8..fd8824ba3 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description-form.model.ts @@ -338,4 +338,4 @@ export class DatasetDescriptionDefaultValueEditorModel extends BaseFormModel { }); return formGroup; } -} \ No newline at end of file +} From 646de5ccfb1c48496c4a4e357e32bdac065248a2 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Tue, 24 Mar 2020 11:26:17 +0200 Subject: [PATCH 133/160] Minor bug fixes on the exporter --- .../src/main/java/eu/eudat/logic/managers/RDAManager.java | 2 +- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index eb10fd753..3a9f2f7a8 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -29,7 +29,7 @@ public class RDAManager { Dmp rdaDmp = dmpRDAMapper.toRDA(dmp); ObjectMapper mapper = new ObjectMapper(); - mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); result = mapper.writeValueAsString(rdaDmp); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 5eb9cc685..da04fe043 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -32,6 +32,7 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); +// rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); @@ -57,7 +58,7 @@ public class DatasetRDAMapper { } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { - rda.setDataQualityAssurance(preservationNodes.stream().map(preservationNode -> preservationNode.get("value").asText()).collect(Collectors.toList())); + rda.setPreservationStatement(preservationNodes.get(0).get("value").asText()); } List distributionNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.distribution"); if (!distributionNodes.isEmpty()) { @@ -77,7 +78,7 @@ public class DatasetRDAMapper { } List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); if (!sensitiveDataNodes.isEmpty()) { - rda.setSensitiveData(securityAndPrivacyNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); + rda.setSensitiveData(sensitiveDataNodes.stream().map(sensitiveDataNode -> Dataset.SensitiveData.fromValue(sensitiveDataNode.get("value").asText())).findFirst().get()); } List technicalResourceNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.technical_resource"); if (!technicalResourceNodes.isEmpty()) { From 7a0e9132d0c449268e1eb577b15ca60c39513b12 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Thu, 26 Mar 2020 18:39:25 +0200 Subject: [PATCH 134/160] Add RDA Import --- .../main/java/eu/eudat/controllers/DMPs.java | 11 +- .../managers/DataManagementPlanManager.java | 35 ++++++ .../eu/eudat/logic/managers/RDAManager.java | 9 ++ .../java/eu/eudat/models/rda/Dataset.java | 9 +- .../eu/eudat/models/rda/Distribution.java | 9 +- .../main/java/eu/eudat/models/rda/Dmp.java | 9 +- .../java/eu/eudat/models/rda/Metadatum.java | 9 +- .../eudat/models/rda/SecurityAndPrivacy.java | 9 +- .../eudat/models/rda/TechnicalResource.java | 9 +- .../models/rda/mapper/ContactIdRDAMapper.java | 4 + .../models/rda/mapper/ContactRDAMapper.java | 8 ++ .../models/rda/mapper/DatasetRDAMapper.java | 112 +++++++++++++++++- .../rda/mapper/DistributionRDAMapper.java | 97 ++++++++++++++- .../eudat/models/rda/mapper/DmpRDAMapper.java | 36 ++++-- .../models/rda/mapper/FundingRDAMapper.java | 9 +- .../models/rda/mapper/MetadataRDAMapper.java | 66 +++++++++++ .../models/rda/mapper/ProjectRDAMapper.java | 22 +++- .../mapper/SecurityAndPrivacyRDAMapper.java | 60 +++++++++- .../mapper/TechnicalResourceRDAMapper.java | 62 +++++++++- .../dmp-upload-dialogue.component.html | 2 +- 20 files changed, 531 insertions(+), 56 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index c87ce4590..0e25b98f6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -53,6 +53,9 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import static org.springframework.http.MediaType.APPLICATION_ATOM_XML; +import static org.springframework.http.MediaType.APPLICATION_JSON; + @RestController @CrossOrigin @@ -224,8 +227,12 @@ public class DMPs extends BaseController { } @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) - public ResponseEntity dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { - this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + public ResponseEntity dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception { + if (files[0].getContentType().equals(APPLICATION_JSON.toString())) { + this.dataManagementPlanManager.createFromRDA(files, principal); + } else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString())) { + this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal); + } return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem() .status(ApiMessageCode.SUCCESS_MESSAGE)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 2710ec60c..c8dee4802 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -131,6 +131,13 @@ public class DataManagementPlanManager { if (fieldsGroup.equals("listing")) { itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)) .selectAsync(item -> { + if (item.getUsers().stream().noneMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue()))) { + for (UserDMP userDMP: item.getUsers()) { + userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue()); + databaseRepository.getUserDmpDao().createOrUpdate(userDMP); + break; + } + } item.setDataset( item.getDataset().stream() .filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).collect(Collectors.toList()).stream() @@ -1329,6 +1336,34 @@ public class DataManagementPlanManager { return dataManagementPlans; } + public List createFromRDA(MultipartFile[] files, Principal principal) throws IOException { + if (principal.getId() == null) { + throw new UnauthorisedException("No user is logged in"); + } + List result = new ArrayList<>(); + for (MultipartFile file: files) { + DMP dmp = rdaManager.convertToEntity(new String(file.getBytes(), "UTF-8")); + UserInfo me = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); + dmp.setModified(new Date()); + dmp.setCreator(me); + dmp.setVersion(0); + dmp.setStatus((short)0); + dmp.setGroupId(UUID.randomUUID()); + databaseRepository.getDmpDao().createOrUpdate(dmp); + assignUser(dmp, me); + dmp.getDataset().forEach(dataset -> { + dataset.setStatus(Dataset.Status.SAVED.getValue()); + dataset.setCreated(new Date()); + dataset.setModified(new Date()); + dataset.setDmp(dmp); + databaseRepository.getDatasetDao().createOrUpdate(dataset); + }); + result.add(dmp); + } + + return result; + } + public DataTableData getDatasetProfilesUsedByDMP(DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) { datasetProfileTableRequestItem.getCriteria().setFilter(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue()); datasetProfileTableRequestItem.getCriteria().setUserId(principal.getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java index 3a9f2f7a8..ff194455e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/RDAManager.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; +import java.io.IOException; import java.text.SimpleDateFormat; @Component @@ -35,4 +36,12 @@ public class RDAManager { return result; } + + public DMP convertToEntity(String json) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z")); + + Dmp rda = mapper.readValue(json, Dmp.class); + return dmpRDAMapper.toEntity(rda); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java index 43a7ac0cd..3c064965e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dataset.java @@ -38,7 +38,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "sensitive_data", "technical_resource", "title", - "type" + "type", + "additional_properties" }) public class Dataset implements Serializable { @@ -182,7 +183,7 @@ public class Dataset implements Serializable @JsonProperty("type") @JsonPropertyDescription("If appropriate, type according to: DataCite and/or COAR dictionary. Otherwise use the common name for the type, e.g. raw data, software, survey, etc. https://schema.datacite.org/meta/kernel-4.1/doc/DataCite-MetadataKernel_v4.1.pdf http://vocabularies.coar-repositories.org/pubby/resource_type.html") private String type; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6931119120629009399L; @@ -524,12 +525,12 @@ public class Dataset implements Serializable this.type = type; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java index d005e7564..176931e9e 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Distribution.java @@ -34,7 +34,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "format", "host", "license", - "title" + "title", + "additional_properties" }) public class Distribution implements Serializable { @@ -131,7 +132,7 @@ public class Distribution implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title is a property in both Dataset and Distribution, in compliance with W3C DCAT. In some cases these might be identical, but in most cases the Dataset represents a more abstract concept, while the distribution can point to a specific file.") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -6018365280419917902L; @@ -359,12 +360,12 @@ public class Distribution implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java index 7cac25d62..b53d26147 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Dmp.java @@ -39,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonValue; "language", "modified", "project", - "title" + "title", + "additional_properties" }) public class Dmp implements Serializable { @@ -173,7 +174,7 @@ public class Dmp implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title of a DMP") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 4599713332472772292L; @@ -499,12 +500,12 @@ public class Dmp implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java index d6057ca62..56bee437d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/Metadatum.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.annotation.JsonValue; @JsonPropertyOrder({ "description", "language", - "metadata_standard_id" + "metadata_standard_id", + "additional_properties" }) public class Metadatum implements Serializable { @@ -58,7 +59,7 @@ public class Metadatum implements Serializable */ @JsonProperty("metadata_standard_id") private MetadataStandardId metadataStandardId; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 6511312853153406190L; @@ -132,12 +133,12 @@ public class Metadatum implements Serializable this.metadataStandardId = metadataStandardId; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java index 0486df588..245d202d0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/SecurityAndPrivacy.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "title" + "title", + "additional_properties" }) public class SecurityAndPrivacy implements Serializable { @@ -46,7 +47,7 @@ public class SecurityAndPrivacy implements Serializable @JsonProperty("title") @JsonPropertyDescription("Title") private String title; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = 7863747935827682977L; @@ -96,12 +97,12 @@ public class SecurityAndPrivacy implements Serializable this.title = title; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java index eac85da72..c7bd2b055 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/TechnicalResource.java @@ -22,7 +22,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "description", - "name" + "name", + "additional_properties" }) public class TechnicalResource implements Serializable { @@ -46,7 +47,7 @@ public class TechnicalResource implements Serializable @JsonProperty("name") @JsonPropertyDescription("Name of the technical resource") private String name; - @JsonIgnore + @JsonProperty("additional_properties") private Map additionalProperties = new HashMap(); private final static long serialVersionUID = -7451757227129483110L; @@ -96,12 +97,12 @@ public class TechnicalResource implements Serializable this.name = name; } - @JsonAnyGetter + @JsonProperty("additional_properties") public Map getAdditionalProperties() { return this.additionalProperties; } - @JsonAnySetter + @JsonProperty("additional_properties") public void setAdditionalProperty(String name, Object value) { this.additionalProperties.put(name, value); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java index 48549d75a..c9eac2009 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactIdRDAMapper.java @@ -12,4 +12,8 @@ public class ContactIdRDAMapper { rda.setType(ContactId.Type.OTHER); return rda; } + + public static UUID toEntity(ContactId rda) { + return UUID.fromString(rda.getIdentifier()); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java index 69ea2310e..957fef8d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ContactRDAMapper.java @@ -13,4 +13,12 @@ public class ContactRDAMapper { rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId())); return rda; } + + public static UserInfo toEntity(Contact rda) { + UserInfo entity = new UserInfo(); + entity.setId(ContactIdRDAMapper.toEntity(rda.getContactId())); + entity.setName(rda.getName()); + entity.setEmail(rda.getMbox()); + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index da04fe043..90aa4ec7c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -2,28 +2,34 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.entities.DatasetProfile; import eu.eudat.logic.managers.DatasetManager; +import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.Dataset; +import org.json.JSONObject; 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.util.List; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Component public class DatasetRDAMapper { private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class); private DatasetManager datasetManager; + private ApiContext apiContext; @Autowired - public DatasetRDAMapper(DatasetManager datasetManager) { + public DatasetRDAMapper(DatasetManager datasetManager, ApiContext apiContext) { this.datasetManager = datasetManager; + this.apiContext = apiContext; } @Transactional @@ -32,9 +38,10 @@ public class DatasetRDAMapper { rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId())); rda.setTitle(dataset.getLabel()); rda.setDescription(dataset.getDescription()); -// rda.setAdditionalProperty("template", dataset.getProfile().getId()); + rda.setAdditionalProperty("template", dataset.getProfile().getId()); try { - + JSONObject jObject = new JSONObject(dataset.getProperties()); + Map templateIdsToValues = jObject.toMap(); DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset); datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset)); ObjectMapper mapper = new ObjectMapper(); @@ -55,6 +62,9 @@ public class DatasetRDAMapper { List qaNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.data_quality_assurance"); if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < qaNodes.size(); i++) { + rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); if (!preservationNodes.isEmpty()) { @@ -67,6 +77,9 @@ public class DatasetRDAMapper { List keywordNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.keyword"); if (!keywordNodes.isEmpty()) { rda.setKeyword(keywordNodes.stream().map(keywordNode -> keywordNode.get("value").asText()).collect(Collectors.toList())); + for (int i = 0; i < keywordNodes.size(); i++) { + rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText()); + } } List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); if (!personalDataNodes.isEmpty()) { @@ -84,6 +97,14 @@ public class DatasetRDAMapper { if (!technicalResourceNodes.isEmpty()) { rda.setTechnicalResource(TechnicalResourceRDAMapper.toRDAList(technicalResourceNodes)); } + List foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes, preservationNodes, distributionNodes, + keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).collect(Collectors.toList()); + templateIdsToValues.entrySet().forEach(entry -> { + boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey())); + if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) { + rda.setAdditionalProperty(entry.getKey(), entry.getValue()); + } + }); } catch (Exception e) { @@ -93,4 +114,87 @@ public class DatasetRDAMapper { return rda; } + + + public eu.eudat.data.entities.Dataset toEntity(Dataset rda) { + eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset(); + entity.setLabel(rda.getTitle()); + entity.setDescription(rda.getDescription()); + try { + DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); + entity.setProfile(profile); + }catch(Exception e) { + logger.warn(e.getMessage(), e); + } + try { + Map properties = new HashMap<>(); + DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); + datasetWizardModel.setProfile(entity.getProfile().getId()); + datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity)); + ObjectMapper mapper = new ObjectMapper(); + String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition()); + JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson); + + List typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.type"); + if (!typeNodes.isEmpty()) { + properties.put(typeNodes.get(0).get("id").asText(), rda.getType()); + } + + List languageNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.language"); + if (!languageNodes.isEmpty()) { + properties.put(languageNodes.get(0).get("id").asText(), rda.getLanguage().value()); + } + + if (rda.getMetadata() != null) { + properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); + } + + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < qaIds.size(); i++) { + properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); + } + + List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); + if (!preservationNodes.isEmpty()) { + properties.put(preservationNodes.get(0).get("id").asText(), rda.getPreservationStatement()); + } + + if (rda.getDistribution() != null) { + properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution())); + } + + List keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + for (int i = 0; i < keywordIds.size(); i++) { + properties.put(keywordIds.get(i), rda.getKeyword().get(i)); + } + + List personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.personal_data"); + if (!personalDataNodes.isEmpty()) { + properties.put(personalDataNodes.get(0).get("id").asText(), rda.getPersonalData().value()); + } + + if (rda.getSecurityAndPrivacy() != null) { + properties.putAll(SecurityAndPrivacyRDAMapper.toProperties(rda.getSecurityAndPrivacy())); + } + + List sensitiveDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.sensitive_data"); + if (!sensitiveDataNodes.isEmpty()) { + properties.put(sensitiveDataNodes.get(0).get("id").asText(), rda.getSensitiveData().value()); + } + + if (rda.getTechnicalResource() != null) { + properties.putAll(TechnicalResourceRDAMapper.toProperties(rda.getTechnicalResource())); + } + + rda.getAdditionalProperties().entrySet().stream() + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); + entity.setProperties(new ObjectMapper().writeValueAsString(properties)); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + + return entity; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java index 98cb6960b..566288452 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DistributionRDAMapper.java @@ -1,13 +1,17 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; +import com.lowagie.text.ExceptionConverter; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.Distribution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URI; import java.util.*; public class DistributionRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,35 +23,43 @@ public class DistributionRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName : PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case ACCESS_URL: rda.setAccessUrl(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.get("id").asText()); break; case AVAILABLE_UTIL: rda.setAvailableUntil(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UTIL.getName(), node.get("id").asText()); break; case DOWNLOAD_URL: rda.setDownloadUrl(URI.create(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; case DATA_ACCESS: rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.DATA_ACCESS.getName(), node.get("id").asText()); break; case BYTE_SIZE: rda.setByteSize(Integer.parseInt(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.get("id").asText()); break; case LICENSE: rda.setLicense(Collections.singletonList(LicenseRDAMapper.toRDA(node))); break; case FORMAT: rda.setFormat(Collections.singletonList(rdaValue)); + rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText()); break; case TITLE: rda.setTitle(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case HOST: rda.setHost(HostRDAMapper.toRDA(nodes, node.get("numbering").asText())); @@ -60,6 +72,49 @@ public class DistributionRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch (importPropertyName) { + case ACCESS_URL: + properties.put(entry.getValue().toString(), rda.getAccessUrl()); + break; + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case FORMAT: + properties.put(entry.getValue().toString(), rda.getFormat().get(0)); + break; + case BYTE_SIZE: + properties.put(entry.getValue().toString(), rda.getByteSize().toString()); + break; + case DATA_ACCESS: + properties.put(entry.getValue().toString(), rda.getDataAccess().value()); + break; + case DOWNLOAD_URL: + properties.put(entry.getValue().toString(), rda.getDownloadUrl().toString()); + break; + case AVAILABLE_UTIL: + properties.put(entry.getValue().toString(), rda.getAvailableUntil()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + }); + }); + + return properties; + } + public static Distribution toRDA(JsonNode node) { Distribution rda = new Distribution(); String rdaProperty = node.get("rdaProperty").asText(); @@ -95,7 +150,7 @@ public class DistributionRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new Distribution()); } - private enum PropertyName { + private enum ExportPropertyName { ACCESS_URL("access_url"), AVAILABLE_UTIL("available_util"), BYTE_SIZE("byte_size"), @@ -109,7 +164,7 @@ public class DistributionRDAMapper { private final String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -117,4 +172,36 @@ public class DistributionRDAMapper { return name; } } + + private enum ImportPropertyName { + ACCESS_URL("accessurlId"), + AVAILABLE_UTIL("availableUtilId"), + BYTE_SIZE("byteSizeId"), + DATA_ACCESS("dataAccessId"), + DESCRIPTION("descriptionId"), + DOWNLOAD_URL("downloadUrlId"), + FORMAT("formatId"), + /*HOST("host"), + LICENSE("license"),*/ + TITLE("titleId"); + + private final String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("No name available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java index 620229a27..7176f3b8d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -1,24 +1,26 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.DMP; -import eu.eudat.data.entities.UserDMP; -import eu.eudat.data.entities.UserInfo; +import eu.eudat.data.entities.*; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Dmp; +import eu.eudat.models.rda.DmpId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.transaction.Transactional; -import java.util.Collections; +import java.util.*; import java.util.stream.Collectors; @Component public class DmpRDAMapper { private DatasetRDAMapper datasetRDAMapper; + private ApiContext apiContext; @Autowired - public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper) { + public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) { this.datasetRDAMapper = datasetRDAMapper; + this.apiContext = apiContext; } @Transactional @@ -44,8 +46,28 @@ public class DmpRDAMapper { rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList())); rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList())); rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant()))); - - + rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray()); return rda; } + + public DMP toEntity(Dmp rda) { + DMP entity = new DMP(); + entity.setLabel(rda.getTitle()); + if (rda.getDmpId().getType() == DmpId.Type.DOI) { + entity.setDoi(rda.getDmpId().getIdentifier()); + } + entity.setCreated(rda.getCreated()); + entity.setModified(rda.getModified()); + entity.setDescription(rda.getDescription()); + entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1)).collect(Collectors.toSet())); + Map result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext); + entity.setProject((Project) result.get("project")); + result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue())); + entity.setAssociatedDmps(((List) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).collect(Collectors.toSet())); + return entity; + } + + private DatasetProfile getProfile(String id) { + return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java index e0b8fbe65..2dd3f6cc2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/FundingRDAMapper.java @@ -1,7 +1,8 @@ package eu.eudat.models.rda.mapper; -import eu.eudat.data.entities.Funder; +import eu.eudat.data.dao.criteria.GrantCriteria; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Funding; public class FundingRDAMapper { @@ -22,4 +23,10 @@ public class FundingRDAMapper { rda.setGrantId(GrantIdRDAMapper.toRDA(shortReference)); return rda; } + + public static Grant toEntity(Funding rda, ApiContext apiContext) { + GrantCriteria criteria = new GrantCriteria(); + criteria.setReference(rda.getGrantId().getIdentifier()); + return apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getWithCriteria(criteria).getSingle(); + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java index c7e3ba35f..49bbbb527 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/MetadataRDAMapper.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class MetadataRDAMapper { private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class); @@ -36,6 +37,7 @@ public class MetadataRDAMapper { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(data.get("uri").asText())); rdas.get(rdas.size() - 1).setDescription(data.get("label").asText()); + rdas.get(rdas.size() - 1).setAdditionalProperty("fieldId", node.get("id").asText()); rdaMap.put(data.get("uri").asText(), node.get("numbering").asText()); } } @@ -45,6 +47,7 @@ public class MetadataRDAMapper { } else if (rdaValue instanceof TextNode && rdaProperty.contains("identifier") && !rdaValue.asText().isEmpty()) { rdas.add(new Metadatum()); rdas.get(rdas.size() - 1).setMetadataStandardId(MetadataStandardIdRDAMapper.toRDA(rdaValue.asText())); + rdas.get(rdas.size() - 1).setAdditionalProperty("identifierId", node.get("id").asText()); rdaMap.put(rdaValue.asText(), node.get("numbering").asText()); } break; @@ -53,6 +56,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setDescription(rdaValue.asText()); + rda.setAdditionalProperty("descriptionId", node.get("id").asText()); } else { rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.asText())); } @@ -64,6 +68,7 @@ public class MetadataRDAMapper { Metadatum rda = getRelative(rdas, rdaMap, node.get("numbering").asText()); if (rda != null) { rda.setLanguage(lang); + rda.setAdditionalProperty("languageId", node.get("id").asText()); } else { rdas.forEach(rda1 -> rda1.setLanguage(lang)); } @@ -77,6 +82,40 @@ public class MetadataRDAMapper { return rdas; } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + List standardIds = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + rdas.forEach(rda -> { + rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + switch (entry.getKey()) { + case "fieldId": + Map metadata = toMap(rda); + standardIds.add(metadata); + properties.put(entry.getValue().toString(), mapper.writeValueAsString(standardIds)); + break; + case "identifierId": + properties.put(entry.getValue().toString(), rda.getMetadataStandardId().getIdentifier()); + break; + case "descriptionId": + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case "languageId": + if (rda.getLanguage() != null) { + properties.put(entry.getValue().toString(), rda.getLanguage().value()); + } + break; + } + }catch (Exception e) { + logger.error(e.getMessage(), e); + } + }); + }); + + return properties; + } + public static Metadatum toRDA(JsonNode node) { Metadatum rda = new Metadatum(); String rdaProperty = node.get("rdaProperty").asText(); @@ -122,4 +161,31 @@ public class MetadataRDAMapper { return name; } } + + private static Map toMap(Metadatum rda) { + Map result = new HashMap<>(); + + ObjectMapper mapper = new ObjectMapper(); + + Map metadata = mapper.convertValue(rda, Map.class); + + Map metadataStandardId = mapper.convertValue(metadata.get("metadata_standard_id"), Map.class); + + String url = metadataStandardId.remove("identifier"); + metadataStandardId.remove("type"); + metadataStandardId.put("uri", url); + + metadata.remove("additional_properties"); + metadata.remove("metadata_standard_id"); + + Map newMetadata = metadata.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toString())); + + String label = newMetadata.remove("description"); + newMetadata.put("label", label); + + result.putAll(newMetadata); + result.putAll(metadataStandardId); + + return result; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java index d97eace4a..b21a9403c 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/ProjectRDAMapper.java @@ -2,9 +2,10 @@ package eu.eudat.models.rda.mapper; import eu.eudat.data.entities.Funder; import eu.eudat.data.entities.Grant; +import eu.eudat.logic.services.ApiContext; import eu.eudat.models.rda.Project; -import java.util.Collections; +import java.util.*; public class ProjectRDAMapper { @@ -22,4 +23,23 @@ public class ProjectRDAMapper { return rda; } + + public static Map toEntity(Project rda, ApiContext apiContext) { + Map entities = new HashMap<>(); + + entities.put("project", new eu.eudat.data.entities.Project()); + ((eu.eudat.data.entities.Project) entities.get("project")).setLabel(rda.getTitle()); + ((eu.eudat.data.entities.Project) entities.get("project")).setDescription(rda.getDescription()); + ((eu.eudat.data.entities.Project) entities.get("project")).setId(UUID.randomUUID()); + ((eu.eudat.data.entities.Project) entities.get("project")).setStatus((short)1); + ((eu.eudat.data.entities.Project) entities.get("project")).setCreated(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setModified(new Date()); + ((eu.eudat.data.entities.Project) entities.get("project")).setType(0); + apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().createOrUpdate(((eu.eudat.data.entities.Project) entities.get("project"))); + for (int i = 0; i < rda.getFunding().size(); i++) { + entities.put("grant" + (i + 1), FundingRDAMapper.toEntity(rda.getFunding().get(i), apiContext)); + } + + return entities; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java index fc44cc182..3b5d28649 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/SecurityAndPrivacyRDAMapper.java @@ -3,10 +3,13 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; import eu.eudat.models.rda.SecurityAndPrivacy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class SecurityAndPrivacyRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(SecurityAndPrivacyRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -19,14 +22,16 @@ public class SecurityAndPrivacyRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case TITLE: rda.setTitle(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.TITLE.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.getAdditionalProperties().put(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -36,6 +41,27 @@ public class SecurityAndPrivacyRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case TITLE: + properties.put(entry.getValue().toString(), rda.getTitle()); + break; + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static SecurityAndPrivacy toRDA(JsonNode node) { SecurityAndPrivacy rda = new SecurityAndPrivacy(); String rdaProperty = node.get("rdaProperty").asText(); @@ -55,13 +81,13 @@ public class SecurityAndPrivacyRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy()); } - private enum PropertyName { + private enum ExportPropertyName { TITLE("title"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -69,4 +95,28 @@ public class SecurityAndPrivacyRDAMapper { return name; } } + + private enum ImportPropertyName { + TITLE("titleId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property not available"); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java index c48f93cae..cd764c302 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/TechnicalResourceRDAMapper.java @@ -2,12 +2,14 @@ package eu.eudat.models.rda.mapper; import com.fasterxml.jackson.databind.JsonNode; import eu.eudat.logic.utilities.helpers.MyStringUtils; -import eu.eudat.models.rda.SecurityAndPrivacy; import eu.eudat.models.rda.TechnicalResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class TechnicalResourceRDAMapper { + private static final Logger logger = LoggerFactory.getLogger(TechnicalResourceRDAMapper.class); public static List toRDAList(List nodes) { Map rdaMap = new HashMap<>(); @@ -20,14 +22,16 @@ public class TechnicalResourceRDAMapper { if (!rdaMap.containsValue(rda)) { rdaMap.put(node.get("numbering").asText(), rda); } - for (PropertyName propertyName: PropertyName.values()) { - if (rdaProperty.contains(propertyName.getName())) { - switch (propertyName) { + for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) { + if (rdaProperty.contains(exportPropertyName.getName())) { + switch (exportPropertyName) { case NAME: rda.setName(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.NAME.getName(), node.get("id").asText()); break; case DESCRIPTION: rda.setDescription(rdaValue); + rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.get("id").asText()); break; } } @@ -37,6 +41,28 @@ public class TechnicalResourceRDAMapper { return new ArrayList<>(rdaMap.values()); } + public static Map toProperties(List rdas) { + Map properties = new HashMap<>(); + + rdas.forEach(rda -> rda.getAdditionalProperties().entrySet().forEach(entry -> { + try { + ImportPropertyName importPropertyName = ImportPropertyName.fromString(entry.getKey()); + switch(importPropertyName) { + case DESCRIPTION: + properties.put(entry.getValue().toString(), rda.getDescription()); + break; + case NAME: + properties.put(entry.getValue().toString(), rda.getName()); + break; + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + })); + + return properties; + } + public static TechnicalResource toRDA(JsonNode node) { TechnicalResource rda = new TechnicalResource(); String rdaProperty = node.get("rdaProperty").asText(); @@ -56,13 +82,13 @@ public class TechnicalResourceRDAMapper { .max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource()); } - private enum PropertyName { + private enum ExportPropertyName { NAME("name"), DESCRIPTION("description"); private String name; - PropertyName(String name) { + ExportPropertyName(String name) { this.name = name; } @@ -70,4 +96,28 @@ public class TechnicalResourceRDAMapper { return name; } } + + private enum ImportPropertyName { + NAME("nameId"), + DESCRIPTION("descriptionId"); + + private String name; + + ImportPropertyName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static ImportPropertyName fromString(String name) throws Exception { + for (ImportPropertyName importPropertyName: ImportPropertyName.values()) { + if (importPropertyName.getName().equals(name)) { + return importPropertyName; + } + } + throw new Exception("Property name not available"); + } + } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html index 81779fadc..f9669094e 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/upload-dialogue/dmp-upload-dialogue.component.html @@ -7,7 +7,7 @@ - +
From 50d7bc6d28bafffb67e1c4002d13f2df5549c9dc Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 27 Mar 2020 10:50:37 +0200 Subject: [PATCH 135/160] Small bugfix for RDA Import --- .../java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index 90aa4ec7c..eef6eb6ed 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -63,7 +63,7 @@ public class DatasetRDAMapper { if (!qaNodes.isEmpty()) { rda.setDataQualityAssurance(qaNodes.stream().map(qaNode -> qaNode.get("value").asText()).collect(Collectors.toList())); for (int i = 0; i < qaNodes.size(); i++) { - rda.setAdditionalProperty("qa" + (i + 1), qaNodes.get(i).get("id").asText()); + rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).get("id").asText()); } } List preservationNodes = JsonSearcher.findNodes(datasetDescriptionObj, "rdaProperty", "dataset.preservation_statement"); @@ -149,7 +149,7 @@ public class DatasetRDAMapper { properties.putAll(MetadataRDAMapper.toProperties(rda.getMetadata())); } - List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qa")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); + List qaIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("qaId")).map(entry -> entry.getValue().toString()).collect(Collectors.toList()); for (int i = 0; i < qaIds.size(); i++) { properties.put(qaIds.get(i), rda.getDataQualityAssurance().get(i)); } @@ -187,7 +187,7 @@ public class DatasetRDAMapper { } rda.getAdditionalProperties().entrySet().stream() - .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qa") && !entry.getKey().startsWith("keyword")) + .filter(entry -> !entry.getKey().equals("template") && !entry.getKey().startsWith("qaId") && !entry.getKey().startsWith("keyword")) .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); entity.setProperties(new ObjectMapper().writeValueAsString(properties)); } catch (Exception e) { From 9cd7e243136a79c4f9db4769870282e2582ac75c Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Fri, 27 Mar 2020 14:34:11 +0200 Subject: [PATCH 136/160] Updated orcid external search (expanded Search) --- .../logic/proxy/fetching/RemoteFetcher.java | 52 +++++++++++++------ .../data/external/orcid/ExpandedResult.java | 44 ++++++++++++++++ .../data/external/orcid/ExpandedSearch.java | 18 +++++++ .../resources/externalUrls/ExternalUrls.xml | 21 +++++++- 4 files changed, 118 insertions(+), 17 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/data/external/orcid/ExpandedResult.java create mode 100644 dmp-backend/web/src/main/java/eu/eudat/models/data/external/orcid/ExpandedSearch.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java index 3e1488c6d..6bf756d0b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java @@ -321,23 +321,43 @@ public class RemoteFetcher { } ObjectMapper objectMapper = new ObjectMapper(); List> values = new ArrayList<>(); - Map map = objectMapper.convertValue( reader != null ? reader.invoke(data) : data, Map.class); - if (jsonDataPath.getMergedFields() != null && !jsonDataPath.getMergedFields().isEmpty() && jsonDataPath.getMergedFieldName() != null && !jsonDataPath.getMergedFieldName().isEmpty()) { - Map finalMap = new HashMap<>(); - for (Map.Entry entry : map.entrySet()) { - if (jsonDataPath.getMergedFields().contains(entry.getKey())) { - if (!finalMap.containsKey(jsonDataPath.getMergedFieldName())) { - finalMap.put(jsonDataPath.getMergedFieldName(), entry.getValue()); - } else { - finalMap.put(jsonDataPath.getMergedFieldName(), finalMap.get(jsonDataPath.getMergedFieldName())+ " " + entry.getValue()); - } - } else { - finalMap.put(entry.getKey(), entry.getValue()); - } + int max = 1; + if (reader != null) { + Object invokedField = reader.invoke(data); + if (invokedField instanceof Collection) { + max = ((Collection) invokedField).size(); + } + } + for (int i = 0; i< max; i++) { + Object value; + if (reader != null) { + Object invokedField = reader.invoke(data); + if (invokedField instanceof Collection) { + value = ((Collection) invokedField).toArray()[i]; + } else { + value = invokedField; + } + } else { + value = data; + } + Map map = objectMapper.convertValue(value, Map.class); + if (jsonDataPath.getMergedFields() != null && !jsonDataPath.getMergedFields().isEmpty() && jsonDataPath.getMergedFieldName() != null && !jsonDataPath.getMergedFieldName().isEmpty()) { + Map finalMap = new HashMap<>(); + for (Map.Entry entry : map.entrySet()) { + if (jsonDataPath.getMergedFields().contains(entry.getKey())) { + if (!finalMap.containsKey(jsonDataPath.getMergedFieldName())) { + finalMap.put(jsonDataPath.getMergedFieldName(), entry.getValue()); + } else { + finalMap.put(jsonDataPath.getMergedFieldName(), finalMap.get(jsonDataPath.getMergedFieldName()) + " " + entry.getValue()); + } + } else { + finalMap.put(entry.getKey(), entry.getValue()); + } + } + values.add(finalMap); + } else { + values.add(map); } - values.add(finalMap); - } else { - values.add(map); } results = new Results(values, new HashMap<>(1, 1)); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/external/orcid/ExpandedResult.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/external/orcid/ExpandedResult.java new file mode 100644 index 000000000..c247b5214 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/external/orcid/ExpandedResult.java @@ -0,0 +1,44 @@ +package eu.eudat.models.data.external.orcid; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "expanded-result", namespace = "http://www.orcid.org/ns/expanded-search") +public class ExpandedResult { + + private String pid; + private String givenNames; + private String familyName; + + public ExpandedResult(String givenNames, String familyName) { + this.givenNames = givenNames; + this.familyName = familyName; + } + + public ExpandedResult() { + } + + @XmlElement(name = "orcid-id", namespace = "http://www.orcid.org/ns/expanded-search") + public String getPid() { + return pid; + } + public void setPid(String pid) { + this.pid = pid; + } + + @XmlElement(name = "given-names", namespace = "http://www.orcid.org/ns/expanded-search") + public String getGivenNames() { + return givenNames; + } + public void setGivenNames(String givenNames) { + this.givenNames = givenNames; + } + @XmlElement(name = "family-names", namespace = "http://www.orcid.org/ns/expanded-search") + public String getFamilyName() { + return familyName; + } + public void setFamilyName(String familyName) { + this.familyName = familyName; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/external/orcid/ExpandedSearch.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/external/orcid/ExpandedSearch.java new file mode 100644 index 000000000..d3a2cf6c6 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/external/orcid/ExpandedSearch.java @@ -0,0 +1,18 @@ +package eu.eudat.models.data.external.orcid; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "expanded-search", namespace = "http://www.orcid.org/ns/expanded-search") +public class ExpandedSearch { + List expandedResults; + + @XmlElement(name = "expanded-result", namespace = "http://www.orcid.org/ns/expanded-search") + public List getExpandedResults() { + return expandedResults; + } + public void setExpandedResults(List expandedResults) { + this.expandedResults = expandedResults; + } +} diff --git a/dmp-backend/web/src/main/resources/externalUrls/ExternalUrls.xml b/dmp-backend/web/src/main/resources/externalUrls/ExternalUrls.xml index f7af0f9ae..de3d38152 100644 --- a/dmp-backend/web/src/main/resources/externalUrls/ExternalUrls.xml +++ b/dmp-backend/web/src/main/resources/externalUrls/ExternalUrls.xml @@ -642,7 +642,7 @@ $['meta']['pagination']['page','pages','count'] - + + + orcid + + 2 + External + https://pub.sandbox.orcid.org/v3.0/expanded-search/?q={like}&start={page}&rows={pageSize} + 0 + application/vnd.orcid+xml; qs=5;charset=UTF-8 + + eu.eudat.models.data.external.orcid.ExpandedSearch + expandedResults + + givenNames + familyName + + name + + $['num-found']