Add Zenodo file visibility field for DMP (ref #274)

This commit is contained in:
George Kalampokis 2020-06-29 12:23:53 +03:00
parent 346c731aae
commit 6e4e23e00d
7 changed files with 102 additions and 10 deletions

View File

@ -86,6 +86,7 @@ import javax.xml.bind.Unmarshaller;
import java.io.*;
import java.math.BigInteger;
import java.nio.file.Files;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@ -1654,11 +1655,15 @@ public class DataManagementPlanManager {
dataBuilder.append(" \"description\": \"").append((dmp.getDescription() != null && !dmp.getDescription().isEmpty() ? dmp.getDescription() : "<p></p>")).append("\",\n");
dataBuilder.append(" \"version\": \"").append(dmp.getVersion()).append("\",\n");
dataBuilder.append(" \"access_right\": \"");
if (dmp.isPublic()) {
dataBuilder.append("open\",\n");
dataBuilder.append(" \"related_identifiers\": [{\n");
dataBuilder.append(" \t\t\"identifier\": \"").append((this.environment.getProperty("dmp.domain") + "/external/zenodo/" + id.toString())).append("\",\n");
dataBuilder.append(" \t\t\"relation\": \"isIdenticalTo\"}],\n");
if (((Boolean)extraProperties.get("visible"))) {
Instant publicationDate = Instant.parse(extraProperties.get("publicDate").toString());
if (publicationDate.isBefore(Instant.now())) {
dataBuilder.append("open\",\n");
} else {
dataBuilder.append("embargoed\",\n");
dataBuilder.append(" \"embargo_date\": \"" + publicationDate + "\",\n");
}
if (extraProperties.get("license") != null) {
dataBuilder.append(" \"license\": \"").append(((Map)extraProperties.get("license")).get("pid")).append("\",\n");
}
@ -1666,6 +1671,11 @@ public class DataManagementPlanManager {
dataBuilder.append("restricted\",\n");
dataBuilder.append(" \"access_conditions\": \"\",\n");
}
if (dmp.isPublic()) {
dataBuilder.append(" \"related_identifiers\": [{\n");
dataBuilder.append(" \t\t\"identifier\": \"").append((this.environment.getProperty("dmp.domain") + "/external/zenodo/" + id.toString())).append("\",\n");
dataBuilder.append(" \t\t\"relation\": \"isIdenticalTo\"}],\n");
}
dataBuilder.append(" \"contributors\": [");
int i = 0;
for(UserDMP userDMP: dmp.getUsers()) {

View File

@ -5,10 +5,14 @@ import { BackendErrorValidator } from '@common/forms/validation/custom-validator
export class ExtraPropertiesFormModel {
public language: string;
public license: string;
public visible: boolean;
public publicDate: Date;
fromModel(item: any): ExtraPropertiesFormModel {
this.language = item.language;
this.license = item.license;
this.visible = item.visible;
this.publicDate = item.publicDate;
return this;
}
@ -17,7 +21,9 @@ export class ExtraPropertiesFormModel {
const formGroup = new FormBuilder().group({
language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators],
license: [{ value: this.license, disabled: disabled }, context.getValidation('license').validators]
license: [{ value: this.license, disabled: disabled }, context.getValidation('license').validators],
visible: [{ value: this.visible, disabled: disabled }, context.getValidation('visible').validators],
publicDate: [{ value: this.publicDate, disabled: disabled }, context.getValidation('publicDate').validators]
});
return formGroup;
}
@ -26,6 +32,8 @@ export class ExtraPropertiesFormModel {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'language', validators: [] });
baseContext.validation.push({ key: 'license', validators: [] });
baseContext.validation.push({ key: 'visible', validators: [] });
baseContext.validation.push({ key: 'publicDate', validators: [] });
return baseContext;
}

View File

@ -85,7 +85,7 @@
<mat-form-field class="col-sm-12 col-md-8">
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete> -->
<app-single-auto-complete [formControl]="formGroup.get('extraProperties').get('license')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="licenseAutoCompleteConfiguration">
<app-single-auto-complete [formControl]="formGroup.get('extraProperties').get('license')" placeholder="{{'DMP-EDITOR.FIELDS.LICENSE' | translate}}" [configuration]="licenseAutoCompleteConfiguration">
</app-single-auto-complete>
<mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('backendError')">
{{formGroup.get('extraProperties').get('language').getError('backendError').message}}</mat-error>
@ -94,6 +94,36 @@
</mat-form-field>
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
</div>
<div class="row pt-3">
<mat-form-field class="col-sm-12 col-md-8">
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete> -->
<mat-select [formControl]="formGroup.get('extraProperties').get('visible')" placeholder="{{'DMP-EDITOR.FIELDS.VISIBILITY' | translate}}">
<mat-option *ngFor="let vis of visibles" [value]="vis.value">
{{vis.name | translate}}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('extraProperties').get('visible').hasError('backendError')">
{{formGroup.get('extraProperties').get('visible').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('extraProperties').get('visible').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
</div>
<div class="row pt-3" *ngIf="formGroup.get('extraProperties').get('visible').value">
<mat-form-field class="col-sm-12 col-md-8">
<!-- <app-multiple-auto-complete [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete> -->
<input matInput [matDatepicker]="picker" [formControl]="formGroup.get('extraProperties').get('publicDate')" placeholder="{{'DMP-EDITOR.FIELDS.PUBLICATION' | translate}}">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
<mat-error *ngIf="formGroup.get('extraProperties').get('visible').hasError('backendError')">
{{formGroup.get('extraProperties').get('visible').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('extraProperties').get('visible').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
</div>
<div class="row pt-2">
<mat-form-field class="col-sm-12 col-md-8">
<app-single-auto-complete [required]="false" [formControl]="formGroup.get('profile')" placeholder="{{'DMP-EDITOR.FIELDS.TEMPLATE' | translate}}" [configuration]="dmpProfileAutoCompleteConfiguration">

View File

@ -27,6 +27,11 @@ import { LanguageInfoService } from '@app/core/services/culture/language-info-se
import { LanguageInfo } from '@app/core/model/language-info';
import { LicenseCriteria } from '@app/core/query/license/license-criteria';
interface Visible {
value: boolean;
name: string;
}
@Component({
selector: 'app-general-tab',
templateUrl: './general-tab.component.html',
@ -77,6 +82,11 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
selectedDmpProfileDefinition: DmpProfileDefinition;
visibles: Visible[] = [
{ value: true, name: 'DMP-EDITOR.VISIBILITY.PUBLIC' },
{ value: false, name: 'DMP-EDITOR.VISIBILITY.RESTRICTED' }
]
constructor(
private dmpProfileService: DmpProfileService,
private externalSourcesService: ExternalSourcesService,
@ -100,6 +110,9 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
if (!this.isUserOwner && !this.isClone) {
this.formGroup.disable();
}
if (isNullOrUndefined(this.formGroup.get('extraProperties').get('publicDate').value)) {
this.formGroup.get('extraProperties').get('publicDate').patchValue(new Date());
}
}
registerFormEventsForDmpProfile(definitionProperties?: DmpProfileDefinition): void {

View File

@ -708,7 +708,10 @@
"STATUS": "DMP Status",
"EXTERNAL-SOURCE-HINT": "List of values provided by external source(s)",
"COLLABORATORS": "Collaborators",
"LANGUAGE": "Language"
"LANGUAGE": "Language",
"LICENSE": "License",
"VISIBILITY": "Visibility",
"PUBLICATION": "Publication Date"
},
"ACTIONS": {
"GO-TO-GRANT": "Go To DMP Grant",
@ -730,6 +733,10 @@
"TITLE": "Available Dataset Templates",
"TEXT": "Dataset Profiles selected: ",
"OK": "OK"
},
"VISIBILITY": {
"PUBLIC": "Public",
"RESTRICTED": "Restricted"
}
},
"DMP-PROFILE-LISTING": {

View File

@ -89,6 +89,7 @@
"ABOUT": "Acerca de",
"PRIVACY": "Política de privacidad",
"TERMS": "Términos de servicio",
"COOKIES-POLICY": "Cookies Policy",
"PLANS": "Mis PGDs",
"EXPLORE-PLANS": "PGDs Publicados",
"QUICK-WIZARD": "(Asistente) Nuevo PGD",
@ -707,7 +708,10 @@
"STATUS": "Estado del PGD",
"EXTERNAL-SOURCE-HINT": "Lista de valores proporcioador por fuente(s) externa(s)",
"COLLABORATORS": "Collaborators",
"LANGUAGE": "Language"
"LANGUAGE": "Language",
"LICENSE": "License",
"VISIBILITY": "Visibility",
"PUBLICATION": "Publication Date"
},
"ACTIONS": {
"GO-TO-GRANT": "Ir a las subvención del PGD",
@ -729,6 +733,10 @@
"TITLE": "Plantilla del Dataset disponible",
"TEXT": "Perfil del Dataset seleccionado: ",
"OK": "OK"
},
"VISIBILITY": {
"PUBLIC": "Public",
"RESTRICTED": "Restricted"
}
},
"DMP-PROFILE-LISTING": {
@ -1042,6 +1050,7 @@
"GUIDE": "User Guide",
"GLOSSARY": "Glosario",
"TERMS-OF-SERVICE": "Términos del servicio",
"COOKIES-POLICY": "Cookies Policy",
"PRIVACY-POLICY": "Política de privacidad"
},
"GLOSSARY": {
@ -1067,6 +1076,9 @@
"TITLE": "-Términos del servicio-",
"MAIN-CONTENT": ""
},
"COOKIES-POLICY": {
"TITLE": "Cookies Policy"
},
"CONTACT": {
"SUPPORT": {
"TITLE": "Contacte con el soporte técnico",

View File

@ -89,6 +89,7 @@
"ABOUT": "Σχετικά",
"PRIVACY": "Πολιτική Απορρήτου και Προστασίας Προσωπικών Δεδομένων",
"TERMS": "Όροι χρήσης",
"COOKIES-POLICY": "Cookies Policy",
"PLANS": "Τα Σχέδια Διαχείρισης Δεδομένων Μου",
"EXPLORE-PLANS": "Δημοσιευμένα Σχέδια Διαχείρισης Δεδομένων",
"QUICK-WIZARD": "Νέο Σχέδιο Διαχείρισης Δεδομένων (Wizard)",
@ -707,7 +708,10 @@
"STATUS": "Κατάσταση Σχεδίου Διαχείρισης Δεδομένων",
"EXTERNAL-SOURCE-HINT": "Κατάλογος των τιμών που παρέχονται από εξωτερικές πηγές",
"COLLABORATORS": "Συνεργάτες",
"LANGUAGE": "Language"
"LANGUAGE": "Language",
"LICENSE": "License",
"VISIBILITY": "Visibility",
"PUBLICATION": "Publication Date"
},
"ACTIONS": {
"GO-TO-GRANT": "Μεταβείτε στην Επιχορήγηση Σχεδίου Διαχείρισης Δεδομένων",
@ -729,6 +733,10 @@
"TITLE": "Διαθέσιμα Templates Συνόλου Δεδομένων",
"TEXT": "Επιλογή Χαρακτηριστικών Συνόλου Δεδομένων:",
"OK": "OK"
},
"VISIBILITY": {
"PUBLIC": "Public",
"RESTRICTED": "Restricted"
}
},
"DMP-PROFILE-LISTING": {
@ -1042,6 +1050,7 @@
"GUIDE": "Οδηγός Χρήστη",
"GLOSSARY": "Γλωσσάριο",
"TERMS-OF-SERVICE": "Όροι Χρήσης",
"COOKIES-POLICY": "Cookies Policy",
"PRIVACY-POLICY": "Πολιτική Απορρήτου"
},
"GLOSSARY": {
@ -1067,6 +1076,9 @@
"TITLE": "-Όροι Χρήσης-",
"MAIN-CONTENT": ""
},
"COOKIES-POLICY": {
"TITLE": "Cookies Policy"
},
"CONTACT": {
"SUPPORT": {
"TITLE": "Επικοινωνία",