Make DMP language Mandatory and set default language to English

This commit is contained in:
George Kalampokis 2021-10-29 15:08:58 +03:00
parent fd26e2a742
commit 5a66754cbd
4 changed files with 10 additions and 7 deletions

View File

@ -39,9 +39,9 @@ public class DmpRDAMapper {
throw new IllegalArgumentException("DMP is missing language and contact properties");
} else {
extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
if (extraProperties.get("language") == null) {
/*if (extraProperties.get("language") == null) {
throw new IllegalArgumentException("DMP must have it's language property defined");
}
}*/
if (extraProperties.get("contact") == null) {
throw new IllegalArgumentException("DMP must have it's contact property defined");
}
@ -72,7 +72,7 @@ public class DmpRDAMapper {
} else {
rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.UNKNOWN);
}
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString()));
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language") != null ? extraProperties.get("language").toString() : "en"));
if (extraProperties.get("costs") != null) {
rda.setCost(new ArrayList<>());
((List) extraProperties.get("costs")).forEach(costl -> {

View File

@ -55,11 +55,11 @@ export class ExtraPropertiesFormModel {
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'language', validators: [BackendErrorValidator(this.validationErrorModel, 'language')] });
baseContext.validation.push({ key: 'language', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'language')] });
baseContext.validation.push({ key: 'license', validators: [BackendErrorValidator(this.validationErrorModel, 'license')] });
baseContext.validation.push({ key: 'visible', validators: [BackendErrorValidator(this.validationErrorModel, 'visible')] });
baseContext.validation.push({ key: 'publicDate', validators: [BackendErrorValidator(this.validationErrorModel, 'publicDate')] });
baseContext.validation.push({ key: 'contact', validators: [BackendErrorValidator(this.validationErrorModel, 'contact')] });
baseContext.validation.push({ key: 'contact', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'contact')] });
baseContext.validation.push({ key: 'costs', validators: [BackendErrorValidator(this.validationErrorModel, 'costs')] });
return baseContext;
}

View File

@ -34,11 +34,11 @@
<!-- Language field -->
<div class="row">
<div class="col-12">
<div class="heading">1.3 {{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}</div>
<div class="heading">1.3 {{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}*</div>
<div class="hint">{{'DMP-EDITOR.FIELDS.LANGUAGE-HINT' | translate}}</div>
<div class="language-form">
<mat-form-field>
<mat-select [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}">
<mat-select [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.LANGUAGE' | translate}}" required>
<mat-option *ngFor="let lang of getLanguageInfos()" [value]="lang.code">
{{ lang.name }}
</mat-option>

View File

@ -111,6 +111,9 @@ export class MainInfoComponent extends BaseComponent implements OnInit {
if (isNullOrUndefined(this.formGroup.get('extraProperties').get('contact').value)) {
this.formGroup.get('extraProperties').get('contact').patchValue(associate.id);
}
if (isNullOrUndefined(this.formGroup.get('extraProperties').get('language').value)) {
this.formGroup.get('extraProperties').get('language').patchValue('en');
}
}
// Researchers