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;
@JsonProperty("repositoryRecordUrl")
private String repositoryRecordUrl;
@JsonProperty("server")
private String server;
@JsonProperty("parentDataverseAlias")
private String parentDataverseAlias;
public int getDepositType() {
return depositType;
@ -77,6 +81,20 @@ public class DataverseConfig {
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() {
RepositoryDepositConfiguration config = new RepositoryDepositConfiguration();
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 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 boolean isApiSet;
@ -62,7 +57,8 @@ public class DataverseDeposit implements RepositoryDeposit {
private void setDataverseApi() throws MalformedURLException {
if(!this.isApiSet) {
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);
this.isApiSet = true;
}
@ -86,7 +82,7 @@ public class DataverseDeposit implements RepositoryDeposit {
.build();
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);
@ -131,8 +127,8 @@ public class DataverseDeposit implements RepositoryDeposit {
private Map<String, Object> getDatasetIdentifier(String previousDOI) {
HttpHeaders headers = new HttpHeaders();
headers.set("X-Dataverse-key", API_TOKEN);
String serverUrl = SERVER + "/api/datasets/:persistentId?persistentId=doi:" + previousDOI;
headers.set("X-Dataverse-key", this.configLoader.getDataverseConfig().getApiToken());
String serverUrl = this.configLoader.getDataverseConfig().getServer() + "/api/datasets/:persistentId?persistentId=doi:" + previousDOI;
RestTemplate restTemplate = new RestTemplate();
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 {
HttpHeaders headers = new HttpHeaders();
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<>();
ContentDisposition contentDisposition = ContentDisposition
.builder("form-data")
@ -155,7 +151,7 @@ public class DataverseDeposit implements RepositoryDeposit {
HttpEntity<MultiValueMap<String, Object>> requestEntity
= 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();
ResponseEntity<Object> resp = restTemplate.postForEntity(serverUrl, requestEntity, Object.class);

View File

@ -2,6 +2,8 @@
"depositType": 0,
"repositoryId": "Dataverse",
"apiToken": "",
"repositoryUrl": "",
"repositoryRecordUrl": ""
"repositoryUrl": "https://demo.dataverse.org/api/",
"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.");
if (dmp.getStatus().equals(DMP.DMPStatus.ACTIVE.getValue()))
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());
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(dmp);
UUID dmpId = dmp.getId();

View File

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

View File

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

View File

@ -95,6 +95,7 @@ export interface DmpFinalizeDialogInput {
dmpLabel: string;
dmpDescription: string;
datasets: DmpFinalizeDialogDataset[];
accessRights: boolean;
}
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>
</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">
<mat-icon class="mat-mini-fab-icon">public</mat-icon>
</button>
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-LISTING.ACTIONS.MAKE-PUBLIC' | translate }}</p>
</div>
</div> -->
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item (click)="downloadPDF(dmp.id)">
<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 { DoiModel } from '@app/core/model/doi/doi';
import { MatSelect } from '@angular/material/select';
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
@Component({
selector: 'app-dmp-overview',
@ -519,41 +520,65 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
finalize(dmp: DmpOverviewModel) {
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 }
})
}
const extraProperties = new ExtraPropertiesFormModel();
this.dmpService.getSingle(this.dmp.id).pipe(map(data => data as DmpModel))
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
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) {

View File

@ -104,7 +104,8 @@ export class QuickWizardEditorComponent extends CheckDeactivateBaseComponent imp
dmpDescription: this.formGroup.get('dmp').get('description').value,
datasets: (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls.map(x => {
return { label: x.get('datasetLabel').value, status: DatasetStatus.Finalized };
})
}),
accessRights: false
}
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"
},
"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"
},
"DRAFTS": {