From ae6db14ac6636b2639f8d466b7e973e9e254fb8f Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Tue, 15 Oct 2019 13:38:51 +0300 Subject: [PATCH] Adds "RDA Common Standard" as a property of Dataset Template's Field. --- .../main/java/eu/eudat/controllers/Admin.java | 10 +- .../logic/managers/DatasetProfileManager.java | 23 +++- .../components/datasetprofile/FieldSet.java | 33 ++--- .../datasetprofiledefinition/FieldSet.java | 40 +++--- .../src/main/resources/RDACommonStandards.txt | 31 +++++ .../admin/dataset-profile/dataset-profile.ts | 1 + .../dataset-profile.service.ts | 4 + .../admin/field-set-editor-model.ts | 5 +- ...file-editor-composite-field.component.html | 8 ++ ...rofile-editor-composite-field.component.ts | 1 + ...aset-profile-editor-section.component.html | 2 +- ...ataset-profile-editor-section.component.ts | 1 + .../dataset-profile-editor.component.html | 2 +- .../dataset-profile-editor.component.ts | 129 +++++++++--------- dmp-frontend/src/assets/i18n/en.json | 3 +- 15 files changed, 190 insertions(+), 103 deletions(-) create mode 100644 dmp-backend/web/src/main/resources/RDACommonStandards.txt diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java index 9b36da4b6..e0fd216fa 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java @@ -13,6 +13,7 @@ import eu.eudat.models.data.admin.composite.DatasetProfile; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.responses.ResponseItem; +import org.springframework.core.env.Environment; import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.types.ApiMessageCode; @@ -37,12 +38,14 @@ public class Admin extends BaseController { private DatasetProfileManager datasetProfileManager; private UserManager userManager; + private Environment environment; @Autowired - public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, UserManager userManager, Logger logger) { + public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, UserManager userManager, Logger logger, Environment environment) { super(apiContext); this.datasetProfileManager = datasetProfileManager; this.userManager = userManager; + this.environment = environment; } @Transactional @@ -149,4 +152,9 @@ public class Admin extends BaseController { .status(ApiMessageCode.SUCCESS_MESSAGE).message("")); } + @RequestMapping(method = RequestMethod.GET, value = {"/getRDACommonStandards"}, produces = "application/json") + public ResponseEntity getRDACommonStandards(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) { + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(this.datasetProfileManager.getRDACommonStandards(environment))); + } + } 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 4d79f00c5..362b90bd3 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 @@ -19,11 +19,11 @@ import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field; import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel; -import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpers.common.DataTableData; -import eu.eudat.models.data.security.Principal; import eu.eudat.queryable.QueryableList; + import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.http.*; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @@ -190,4 +190,23 @@ public class DatasetProfileManager { throw new DatasetProfileNewVersionException("Version to update not the latest."); } } + + public List getRDACommonStandards(Environment environment) { + String filePath = environment.getProperty("configuration.resources.path") + "RDACommonStandards.txt"; + BufferedReader reader; + List rdaList = new LinkedList<>(); + try { + reader = new BufferedReader(new FileReader(filePath)); + String line = reader.readLine(); + while (line != null) { + rdaList.add(line); + line = reader.readLine(); + } + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + return rdaList; + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/admin/components/datasetprofile/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/admin/components/datasetprofile/FieldSet.java index de1623765..7b3e8a29a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/admin/components/datasetprofile/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/admin/components/datasetprofile/FieldSet.java @@ -11,6 +11,7 @@ import java.util.List; public class FieldSet implements Comparable, ViewStyleDefinition { private String id; private Integer ordinal; + private String rdaCommonStandard; private Multiplicity multiplicity; private String title; private String description; @@ -22,7 +23,6 @@ public class FieldSet implements Comparable, ViewStyleDefinition getFields() { return fields; } - public void setFields(List fields) { this.fields = fields; } @@ -30,7 +30,6 @@ public class FieldSet implements Comparable, ViewStyleDefinition viewStylefields = new ModelBuilder().toViewStyleDefinition(this.fields, eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field.class); - item.setFields(viewStylefields); + List viewStyleFields = new ModelBuilder().toViewStyleDefinition(this.fields, eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field.class); + item.setFields(viewStyleFields); item.setId(this.id); item.setDescription(this.description); item.setTitle(this.title); @@ -108,6 +106,7 @@ public class FieldSet implements Comparable, ViewStyleDefinition fieldToShort = this.fields; Collections.sort(fieldToShort); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/datasetprofiledefinition/FieldSet.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/datasetprofiledefinition/FieldSet.java index 86f7728a3..b852fa09d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/datasetprofiledefinition/FieldSet.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/datasetprofiledefinition/FieldSet.java @@ -14,6 +14,7 @@ import java.util.List; public class FieldSet implements DatabaseViewStyleDefinition, XmlSerializable
{ private String id; private int ordinal; + private String rdaCommonStandard; private List fields; private String numbering; private String title; @@ -27,7 +28,6 @@ public class FieldSet implements DatabaseViewStyleDefinition, XmlSerializable getFields() { return fields; } - public void setFields(List fields) { this.fields = fields; } @@ -35,7 +35,6 @@ public class FieldSet implements DatabaseViewStyleDefinition, XmlSerializable { + return this.http.get(this.actionUrl + "getRDACommonStandards"); + } } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts index 37e9f1fe4..f381d0537 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/admin/field-set-editor-model.ts @@ -16,6 +16,7 @@ export class FieldSetEditorModel extends BaseFormModel { public extendedDescription: string; public additionalInformation: string; public hasCommentField: boolean; + public rdaCommonStandard: string; fromModel(item: FieldSet): FieldSetEditorModel { @@ -28,6 +29,7 @@ export class FieldSetEditorModel extends BaseFormModel { this.extendedDescription = item.extendedDescription; this.additionalInformation = item.additionalInformation; this.hasCommentField = item.hasCommentField; + this.rdaCommonStandard = item.rdaCommonStandard; return this; } @@ -39,7 +41,8 @@ export class FieldSetEditorModel extends BaseFormModel { description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.description')) }], extendedDescription: [{ value: this.extendedDescription, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.extendedDescription')) }], additionalInformation: [{ value: this.additionalInformation, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.additionalInformation')) }], - hasCommentField: [{ value: this.hasCommentField, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.hasCommentField')) }] + hasCommentField: [{ value: this.hasCommentField, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.hasCommentField')) }], + rdaCommonStandard: [{value: this.rdaCommonStandard, disabled: (disabled && !skipDisable.includes('FieldSetEditorModel.rdaCommonStandard')) }] }); const fieldsFormArray = new Array(); this.fields.forEach(item => { diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html index 5e3d64c3e..2dfe882f7 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html @@ -36,6 +36,14 @@ + + {{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.RDA-COMMON-STANDARDS' | translate}} + + + {{property}} + + +
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts index 256a522fc..f5c1d29c5 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.ts @@ -13,6 +13,7 @@ export class DatasetProfileEditorCompositeFieldComponent implements OnInit { @Input() form: FormGroup; @Input() indexPath: string; @Input() viewOnly: boolean; + @Input() rdaCommonStandards: String[]; isComposite = false; isMultiplicityEnabled = false; diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html index f34dc1eee..99dbc473b 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.html @@ -42,7 +42,7 @@ - +
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts index 98b885051..c4e937bc8 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/section/dataset-profile-editor-section.component.ts @@ -18,6 +18,7 @@ export class DatasetProfileEditorSectionComponent extends BaseComponent implemen @Input() dataModel: SectionEditorModel; @Input() indexPath: string; @Input() viewOnly: boolean; + @Input() rdaCommonStandards: String[]; constructor() { super(); } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html index 65945f77d..56283b3cc 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html @@ -46,7 +46,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts index 2683c5384..16094a2f2 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts @@ -1,5 +1,5 @@ -import {of as observableOf, Observable } from 'rxjs'; +import { of as observableOf, Observable } from 'rxjs'; import { HttpErrorResponse } from '@angular/common/http'; import { Component, OnInit, ViewChild } from '@angular/core'; import { FormArray, FormControl, FormGroup } from '@angular/forms'; @@ -46,6 +46,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn breadCrumbs: Observable; @ViewChild('stepper', { static: false }) stepper: MatHorizontalStepper; viewOnly = false; + rdaCommonStandards: String[]; constructor( private datasetProfileService: DatasetProfileService, @@ -72,67 +73,67 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn this.datasetProfileService.getDatasetProfileById(this.datasetProfileId) .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { - this.form = this.dataModel.buildForm(true, skipDisable); - this.viewOnly = true; - } else { - this.form = this.dataModel.buildForm(); + data => { + try { + this.dataModel = new DatasetProfileEditorModel().fromModel(data); + // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; + if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { + this.form = this.dataModel.buildForm(true, skipDisable); + this.viewOnly = true; + } else { + this.form = this.dataModel.buildForm(); + } + this.prepareForm(); + } catch { + this.logger.error('Could not parse MasterItem: ' + data); + this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); } - this.prepareForm(); - } catch { - this.logger.error('Could not parse MasterItem: ' + data); - this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) + }, + error => this.onCallbackError(error) ); - this.breadCrumbs = observableOf([{ - parentComponentName: 'DatasetProfileListingComponent', - label: this.language.instant('NAV-BAR.TEMPLATE'), - url: '/dataset-profiles/' + this.datasetProfileId - }]); + this.breadCrumbs = observableOf([{ + parentComponentName: 'DatasetProfileListingComponent', + label: this.language.instant('NAV-BAR.TEMPLATE'), + url: '/dataset-profiles/' + this.datasetProfileId + }]); } else if (cloneId != null) { this.isClone = true; this.datasetProfileService.clone(cloneId) .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - this.dataModel.status = DatasetProfileEnum.SAVED; - this.form = this.dataModel.buildForm(); - this.prepareForm(); - } catch { - this.logger.error('Could not parse MasterItem: ' + data); - this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) + data => { + try { + this.dataModel = new DatasetProfileEditorModel().fromModel(data); + // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; + this.dataModel.status = DatasetProfileEnum.SAVED; + this.form = this.dataModel.buildForm(); + this.prepareForm(); + } catch { + this.logger.error('Could not parse MasterItem: ' + data); + this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); + } + }, + error => this.onCallbackError(error) ); } else if (this.newVersionId != null) { this.isNewVersion = true; this.datasetProfileService.getDatasetProfileById(this.newVersionId) .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - this.form = this.dataModel.buildForm(); - this.form.get('version').setValue(this.form.get('version').value + 1); - this.form.controls['label'].disable(); - this.prepareForm(); - } catch { - this.logger.error('Could not parse MasterItem: ' + data); - this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) + data => { + try { + this.dataModel = new DatasetProfileEditorModel().fromModel(data); + // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; + this.form = this.dataModel.buildForm(); + this.form.get('version').setValue(this.form.get('version').value + 1); + this.form.controls['label'].disable(); + this.prepareForm(); + } catch { + this.logger.error('Could not parse MasterItem: ' + data); + this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); + } + }, + error => this.onCallbackError(error) ); } else { this.dataModel = new DatasetProfileEditorModel(); @@ -145,6 +146,12 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn this.addPage(); } }); + this.datasetProfileService.getRDACommonStandards() + .subscribe( + data => { + this.rdaCommonStandards = data; + } + ); } prepareForm() { @@ -201,7 +208,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn .subscribe(() => { this.router.navigate(['/dataset-profiles']); }, - error => this.onCallbackErrorNewVersion(error) + error => this.onCallbackErrorNewVersion(error) ); } else { this.form.get('status').setValue(DatasetStatus.Draft); @@ -262,18 +269,18 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn this.datasetProfileService.delete(this.datasetProfileId, this.form.value) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/dataset-profiles']); - }, - error => { - this.onCallbackError(error); - if (error.error.statusCode == 674) { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error); - } else { - this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); + complete => { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); + this.router.navigate(['/dataset-profiles']); + }, + error => { + this.onCallbackError(error); + if (error.error.statusCode == 674) { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error); + } else { + this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); + } } - } ); } }); diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index a1becbb90..ce63395dd 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -239,7 +239,8 @@ "MULTIPLICITY-ADD-ONE-FIELD": "Add one more fieldset", "ORDER": "Order", "COMMENT-PLACEHOLDER": "Please Specify", - "COMMENT-HINT": "Provide additional information or justification about your selection" + "COMMENT-HINT": "Provide additional information or justification about your selection", + "RDA-COMMON-STANDARDS": "RDA Common Standards" }, "ACTIONS": { "ADD-CHILD-FIELD": "Add Child Field +"