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

View File

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

View File

@ -85,7 +85,7 @@
<mat-form-field class="col-sm-12 col-md-8"> <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 [formControl]="formGroup.get('extraProperties').get('language')" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}" [configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete> --> </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> </app-single-auto-complete>
<mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('backendError')"> <mat-error *ngIf="formGroup.get('extraProperties').get('license').hasError('backendError')">
{{formGroup.get('extraProperties').get('language').getError('backendError').message}}</mat-error> {{formGroup.get('extraProperties').get('language').getError('backendError').message}}</mat-error>
@ -94,6 +94,36 @@
</mat-form-field> </mat-form-field>
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> --> <!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
</div> </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"> <div class="row pt-2">
<mat-form-field class="col-sm-12 col-md-8"> <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"> <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 { LanguageInfo } from '@app/core/model/language-info';
import { LicenseCriteria } from '@app/core/query/license/license-criteria'; import { LicenseCriteria } from '@app/core/query/license/license-criteria';
interface Visible {
value: boolean;
name: string;
}
@Component({ @Component({
selector: 'app-general-tab', selector: 'app-general-tab',
templateUrl: './general-tab.component.html', templateUrl: './general-tab.component.html',
@ -77,6 +82,11 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
selectedDmpProfileDefinition: DmpProfileDefinition; selectedDmpProfileDefinition: DmpProfileDefinition;
visibles: Visible[] = [
{ value: true, name: 'DMP-EDITOR.VISIBILITY.PUBLIC' },
{ value: false, name: 'DMP-EDITOR.VISIBILITY.RESTRICTED' }
]
constructor( constructor(
private dmpProfileService: DmpProfileService, private dmpProfileService: DmpProfileService,
private externalSourcesService: ExternalSourcesService, private externalSourcesService: ExternalSourcesService,
@ -100,6 +110,9 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
if (!this.isUserOwner && !this.isClone) { if (!this.isUserOwner && !this.isClone) {
this.formGroup.disable(); 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 { registerFormEventsForDmpProfile(definitionProperties?: DmpProfileDefinition): void {

View File

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

View File

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

View File

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