when finalizing a dmp and its access rights are open, make it publicly available in Argos

This commit is contained in:
Bernaldo Mihasi 2022-11-24 16:29:11 +02:00
parent 573aab059b
commit 7a0e1c89f2
11 changed files with 106 additions and 54 deletions

View File

@ -41,6 +41,10 @@ public class DataverseConfig {
private String repositoryUrl; private String repositoryUrl;
@JsonProperty("repositoryRecordUrl") @JsonProperty("repositoryRecordUrl")
private String repositoryRecordUrl; private String repositoryRecordUrl;
@JsonProperty("server")
private String server;
@JsonProperty("parentDataverseAlias")
private String parentDataverseAlias;
public int getDepositType() { public int getDepositType() {
return depositType; return depositType;
@ -77,6 +81,20 @@ public class DataverseConfig {
this.repositoryRecordUrl = repositoryRecordUrl; this.repositoryRecordUrl = repositoryRecordUrl;
} }
public String getServer() {
return server;
}
public void setServer(String server) {
this.server = server;
}
public String getParentDataverseAlias() {
return parentDataverseAlias;
}
public void setParentDataverseAlias(String parentDataverseAlias) {
this.parentDataverseAlias = parentDataverseAlias;
}
public RepositoryDepositConfiguration toRepoConfig() { public RepositoryDepositConfiguration toRepoConfig() {
RepositoryDepositConfiguration config = new RepositoryDepositConfiguration(); RepositoryDepositConfiguration config = new RepositoryDepositConfiguration();
config.setDepositType(this.depositType); config.setDepositType(this.depositType);

View File

@ -41,11 +41,6 @@ public class DataverseDeposit implements RepositoryDeposit {
private static final Logger logger = LoggerFactory.getLogger(DataverseDeposit.class); private static final Logger logger = LoggerFactory.getLogger(DataverseDeposit.class);
private static final ObjectMapper objectMapper = new ObjectMapper(); private static final ObjectMapper objectMapper = new ObjectMapper();
private static final String API_TOKEN = "";
private static final String SYSTEM_PARENT_DATAVERSE_ALIAS = "";
private static final String SERVER = "";
private static final String SYSTEM_EMAIL = "";
private DataverseAPI api; private DataverseAPI api;
private boolean isApiSet; private boolean isApiSet;
@ -62,7 +57,8 @@ public class DataverseDeposit implements RepositoryDeposit {
private void setDataverseApi() throws MalformedURLException { private void setDataverseApi() throws MalformedURLException {
if(!this.isApiSet) { if(!this.isApiSet) {
this.api = new DataverseAPIImpl(); this.api = new DataverseAPIImpl();
DataverseConfig config = new DataverseConfig(new URL(SERVER), API_TOKEN, SYSTEM_PARENT_DATAVERSE_ALIAS); eu.eudat.depositinterface.dataverserepository.config.DataverseConfig jsonConfig = this.configLoader.getDataverseConfig();
DataverseConfig config = new DataverseConfig(new URL(jsonConfig.getServer()), jsonConfig.getApiToken(), jsonConfig.getParentDataverseAlias());
api.configure(config); api.configure(config);
this.isApiSet = true; this.isApiSet = true;
} }
@ -86,7 +82,7 @@ public class DataverseDeposit implements RepositoryDeposit {
.build(); .build();
if(dmpDepositModel.getPreviousDOI() == null || dmpDepositModel.getPreviousDOI().isEmpty()){ if(dmpDepositModel.getPreviousDOI() == null || dmpDepositModel.getPreviousDOI().isEmpty()){
Identifier id = this.api.getDataverseOperations().createDataset(dataset, SYSTEM_PARENT_DATAVERSE_ALIAS); Identifier id = this.api.getDataverseOperations().createDataset(dataset, this.configLoader.getDataverseConfig().getParentDataverseAlias());
doi = this.api.getDatasetOperations().getDataset(id).getDoiId().orElse(null); doi = this.api.getDatasetOperations().getDataset(id).getDoiId().orElse(null);
@ -131,8 +127,8 @@ public class DataverseDeposit implements RepositoryDeposit {
private Map<String, Object> getDatasetIdentifier(String previousDOI) { private Map<String, Object> getDatasetIdentifier(String previousDOI) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("X-Dataverse-key", API_TOKEN); headers.set("X-Dataverse-key", this.configLoader.getDataverseConfig().getApiToken());
String serverUrl = SERVER + "/api/datasets/:persistentId?persistentId=doi:" + previousDOI; String serverUrl = this.configLoader.getDataverseConfig().getServer() + "/api/datasets/:persistentId?persistentId=doi:" + previousDOI;
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
return (Map<String, Object>) restTemplate.exchange(serverUrl, HttpMethod.GET, new HttpEntity<>(headers), Map.class).getBody().get("data"); return (Map<String, Object>) restTemplate.exchange(serverUrl, HttpMethod.GET, new HttpEntity<>(headers), Map.class).getBody().get("data");
} }
@ -140,7 +136,7 @@ public class DataverseDeposit implements RepositoryDeposit {
private void uploadFile(String filename, File file, String doi) throws IOException { private void uploadFile(String filename, File file, String doi) throws IOException {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA); headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.set("X-Dataverse-key", API_TOKEN); headers.set("X-Dataverse-key", this.configLoader.getDataverseConfig().getApiToken());
MultiValueMap<String, String> fileMap = new LinkedMultiValueMap<>(); MultiValueMap<String, String> fileMap = new LinkedMultiValueMap<>();
ContentDisposition contentDisposition = ContentDisposition ContentDisposition contentDisposition = ContentDisposition
.builder("form-data") .builder("form-data")
@ -155,7 +151,7 @@ public class DataverseDeposit implements RepositoryDeposit {
HttpEntity<MultiValueMap<String, Object>> requestEntity HttpEntity<MultiValueMap<String, Object>> requestEntity
= new HttpEntity<>(body, headers); = new HttpEntity<>(body, headers);
String serverUrl = SERVER + "/api/datasets/:persistentId/add?persistentId=doi:" + doi; String serverUrl = this.configLoader.getDataverseConfig().getServer() + "/api/datasets/:persistentId/add?persistentId=doi:" + doi;
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Object> resp = restTemplate.postForEntity(serverUrl, requestEntity, Object.class); ResponseEntity<Object> resp = restTemplate.postForEntity(serverUrl, requestEntity, Object.class);

View File

@ -2,6 +2,8 @@
"depositType": 0, "depositType": 0,
"repositoryId": "Dataverse", "repositoryId": "Dataverse",
"apiToken": "", "apiToken": "",
"repositoryUrl": "", "repositoryUrl": "https://demo.dataverse.org/api/",
"repositoryRecordUrl": "" "repositoryRecordUrl": "https://demo.dataverse.org/dataset.xhtml?persistentId=doi:",
"server": "https://demo.dataverse.org",
"parentDataverseAlias": ""
} }

View File

@ -1156,6 +1156,10 @@ public class DataManagementPlanManager {
throw new Exception("User does not have the privilege to do this action."); throw new Exception("User does not have the privilege to do this action.");
if (dmp.getStatus().equals(DMP.DMPStatus.ACTIVE.getValue())) if (dmp.getStatus().equals(DMP.DMPStatus.ACTIVE.getValue()))
throw new Exception("DMP is already Active"); throw new Exception("DMP is already Active");
if (dmp.isPublic())
throw new Exception("DMP is publicly available");
if (!dmp.getDois().isEmpty())
throw new Exception("DMP is deposited");
dmp.setStatus(DMP.DMPStatus.ACTIVE.getValue()); dmp.setStatus(DMP.DMPStatus.ACTIVE.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp); apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
UUID dmpId = dmp.getId(); UUID dmpId = dmp.getId();

View File

@ -980,7 +980,8 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
dmpDescription: this.formGroup.get('description').value, dmpDescription: this.formGroup.get('description').value,
datasets: this.formGroup.get('datasets').value.map(x => { datasets: this.formGroup.get('datasets').value.map(x => {
return { label: x.label, id: x.id, status: x.status }; return { label: x.label, id: x.id, status: x.status };
}) }),
accessRights: false
} }
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {

View File

@ -64,8 +64,11 @@
<div class="row pt-2 pb-2 pl-4 pr-4"> <div class="row pt-2 pb-2 pl-4 pr-4">
{{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }} {{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }}
</div> </div>
<div class="row pl-4 pr-4"> <div *ngIf="inputModel.accessRights" class="row pl-4 pr-4">
{{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION' | translate }} {{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION-PUBLISH' | translate }}
</div>
<div *ngIf="!inputModel.accessRights" class="row pl-4 pr-4">
{{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION-RESTRICT-ACCESS' | translate }}
</div> </div>
</div> </div>

View File

@ -95,6 +95,7 @@ export interface DmpFinalizeDialogInput {
dmpLabel: string; dmpLabel: string;
dmpDescription: string; dmpDescription: string;
datasets: DmpFinalizeDialogDataset[]; datasets: DmpFinalizeDialogDataset[];
accessRights: boolean;
} }
export interface DmpFinalizeDialogDataset { export interface DmpFinalizeDialogDataset {

View File

@ -187,12 +187,12 @@
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-LISTING.ACTIONS.START-NEW-VERSION' | translate }} <p class="mb-0 pl-2 frame-txt">{{ 'DMP-LISTING.ACTIONS.START-NEW-VERSION' | translate }}
</p> </p>
</div> </div>
<div *ngIf="!dmp.isPublic && showPublishButton(dmp) && isUserOwner" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center" (click)="publish(dmp.id)"> <!-- <div *ngIf="!dmp.isPublic && showPublishButton(dmp) && isUserOwner" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center" (click)="publish(dmp.id)">
<button mat-mini-fab class="frame-btn"> <button mat-mini-fab class="frame-btn">
<mat-icon class="mat-mini-fab-icon">public</mat-icon> <mat-icon class="mat-mini-fab-icon">public</mat-icon>
</button> </button>
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-LISTING.ACTIONS.MAKE-PUBLIC' | translate }}</p> <p class="mb-0 pl-2 frame-txt">{{ 'DMP-LISTING.ACTIONS.MAKE-PUBLIC' | translate }}</p>
</div> </div> -->
<mat-menu #exportMenu="matMenu" xPosition="before"> <mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item (click)="downloadPDF(dmp.id)"> <button mat-menu-item (click)="downloadPDF(dmp.id)">
<i class="fa fa-file-pdf-o pr-2"></i> <i class="fa fa-file-pdf-o pr-2"></i>

View File

@ -45,6 +45,7 @@ import { DmpDepositDialogComponent } from '../editor/dmp-deposit-dialog/dmp-depo
import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration'; import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration';
import { DoiModel } from '@app/core/model/doi/doi'; import { DoiModel } from '@app/core/model/doi/doi';
import { MatSelect } from '@angular/material/select'; import { MatSelect } from '@angular/material/select';
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
@Component({ @Component({
selector: 'app-dmp-overview', selector: 'app-dmp-overview',
@ -519,41 +520,65 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
finalize(dmp: DmpOverviewModel) { finalize(dmp: DmpOverviewModel) {
const dialogInputModel: DmpFinalizeDialogInput = { const extraProperties = new ExtraPropertiesFormModel();
dmpLabel: this.dmp.label, this.dmpService.getSingle(this.dmp.id).pipe(map(data => data as DmpModel))
dmpDescription: this.dmp.description, .pipe(takeUntil(this._destroyed))
datasets: this.dmp.datasets.map(x => { .subscribe(data => {
return { label: x.label, id: x.id, status: x.status }
}) if (!isNullOrUndefined(data.extraProperties)) {
} extraProperties.fromModel(data.extraProperties);
}
const dialogInputModel: DmpFinalizeDialogInput = {
dmpLabel: this.dmp.label,
dmpDescription: this.dmp.description,
datasets: this.dmp.datasets.map(x => {
return { label: x.label, id: x.id, status: x.status }
}),
accessRights: extraProperties.visible
}
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {
maxWidth: '500px',
restoreFocus: false,
autoFocus: false,
data: {
dialogInputModel: dialogInputModel,
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => {
if (result && !result.cancelled) {
var datasetsToBeFinalized: DatasetsToBeFinalized = {
uuids: result.datasetsToBeFinalized
};
this.dmpService.finalize(datasetsToBeFinalized, this.dmp.id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => {
if(extraProperties.visible){
//this.publish(this.dmp.id);
this.dmpService.publish(this.dmp.id)
.pipe(takeUntil(this._destroyed))
.subscribe(() => {
//this.hasPublishButton = false;
this.dmp.status = DmpStatus.Finalized;
this.onUpdateCallbackSuccess();
});
}
else{
this.dmp.status = DmpStatus.Finalized;
this.onUpdateCallbackSuccess();
}
},
error => this.onUpdateCallbackError(error)
);
}
});
});
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {
maxWidth: '500px',
restoreFocus: false,
autoFocus: false,
data: {
dialogInputModel: dialogInputModel,
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => {
if (result && !result.cancelled) {
var datasetsToBeFinalized: DatasetsToBeFinalized = {
uuids: result.datasetsToBeFinalized
};
this.dmpService.finalize(datasetsToBeFinalized, this.dmp.id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => {
this.dmp.status = DmpStatus.Finalized;
this.onUpdateCallbackSuccess();
},
error => this.onUpdateCallbackError(error)
);
}
});
} }
// newVersion(id: String, label: String) { // newVersion(id: String, label: String) {

View File

@ -104,7 +104,8 @@ export class QuickWizardEditorComponent extends CheckDeactivateBaseComponent imp
dmpDescription: this.formGroup.get('dmp').get('description').value, dmpDescription: this.formGroup.get('dmp').get('description').value,
datasets: (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls.map(x => { datasets: (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls.map(x => {
return { label: x.get('datasetLabel').value, status: DatasetStatus.Finalized }; return { label: x.get('datasetLabel').value, status: DatasetStatus.Finalized };
}) }),
accessRights: false
} }
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {

View File

@ -1792,7 +1792,8 @@
"AT-LEAST-ONE-DATASET-FINALISED": "You need to have at least one Dataset Finalized" "AT-LEAST-ONE-DATASET-FINALISED": "You need to have at least one Dataset Finalized"
}, },
"IMPACT": "This action will finalize your DMP, and you won't be able to edit it again.", "IMPACT": "This action will finalize your DMP, and you won't be able to edit it again.",
"AFTER-FINALIZATION": "After finalizing your DMP you can Publish it, and it'll be publicly available to the ARGOS tool.", "AFTER-FINALIZATION-PUBLISH": "After finalizing your DMP, it'll be published and be publicly available to the ARGOS tool.",
"AFTER-FINALIZATION-RESTRICT-ACCESS": "Your DMP can be published and be publicly available to the ARGOS tool after finalization when its access rights are opened. Current access rights: restricted",
"INVALID": "Invalid" "INVALID": "Invalid"
}, },
"DRAFTS": { "DRAFTS": {