when new version is deposited, create dataset in existing dataverse
This commit is contained in:
parent
b4490cb0f3
commit
6c13d3b68f
|
@ -3,10 +3,7 @@ package eu.eudat.depositinterface.dataverserepository.interfaces;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.researchspace.dataverse.api.v1.DataverseAPI;
|
||||
import com.researchspace.dataverse.api.v1.DataverseConfig;
|
||||
import com.researchspace.dataverse.entities.DataverseContacts;
|
||||
import com.researchspace.dataverse.entities.DataversePost;
|
||||
import com.researchspace.dataverse.entities.DataverseResponse;
|
||||
import com.researchspace.dataverse.entities.Identifier;
|
||||
import com.researchspace.dataverse.entities.*;
|
||||
import com.researchspace.dataverse.entities.facade.DatasetAuthor;
|
||||
import com.researchspace.dataverse.entities.facade.DatasetContact;
|
||||
import com.researchspace.dataverse.entities.facade.DatasetDescription;
|
||||
|
@ -76,13 +73,17 @@ public class DataverseDeposit implements RepositoryDeposit {
|
|||
if(!this.isApiSet)
|
||||
this.setDataverseApi();
|
||||
|
||||
String alias = dmpDepositModel.getLabel().replace(" ", "_");
|
||||
DataverseGet dataverse = this.api.getDataverseOperations().getDataverseById(alias);
|
||||
if(dataverse == null) {
|
||||
DataversePost entity = new DataversePost();
|
||||
entity.setName(dmpDepositModel.getLabel());
|
||||
entity.setAlias(dmpDepositModel.getLabel().replace(" ", "_"));
|
||||
entity.setAlias(alias);
|
||||
entity.setDescription(dmpDepositModel.getDescription());
|
||||
entity.setCreationDate(new Date());
|
||||
entity.setDataverseContacts(Collections.singletonList(new DataverseContacts(SYSTEM_EMAIL)));
|
||||
DataverseResponse<DataversePost> response = this.api.getDataverseOperations().createNewDataverse(SYSTEM_PARENT_DATAVERSE_ALIAS, entity);
|
||||
}
|
||||
|
||||
DatasetFacade dataset = DatasetFacade.builder()
|
||||
.title(dmpDepositModel.getLabel())
|
||||
|
@ -93,7 +94,7 @@ public class DataverseDeposit implements RepositoryDeposit {
|
|||
.languages(new ArrayList<>())
|
||||
.depositor("")
|
||||
.build();
|
||||
Identifier id = this.api.getDataverseOperations().createDataset(dataset, entity.getAlias());
|
||||
Identifier id = this.api.getDataverseOperations().createDataset(dataset, alias);
|
||||
|
||||
String doi = this.api.getDatasetOperations().getDataset(id).getDoiId().orElse(null);
|
||||
|
||||
|
@ -148,7 +149,7 @@ public class DataverseDeposit implements RepositoryDeposit {
|
|||
conf.setDepositAccountStatus(SystemDeposit.getValue());
|
||||
conf.setAccessToken(API_TOKEN);
|
||||
conf.setRepositoryUrl(SERVER + "/api/");
|
||||
conf.setRepositoryRecordUrl(SERVER + "/dataverse/");
|
||||
conf.setRepositoryRecordUrl(SERVER + "/dataset.xhtml?persistentId=doi:");
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,13 +114,13 @@
|
|||
<div *ngIf="!hasDoi(dmp)" class="row d-flex flex-column ml-0 mr-0 mb-3">
|
||||
<p class="doi-label">{{'DMP-EDITOR.TITLE.SUBTITLE' | translate}}</p>
|
||||
<div class="doi-panel">
|
||||
<mat-select class="mb-0 ml-3" placeholder="{{ dmp.dois[0].doi }}">
|
||||
<mat-option *ngFor="let doi of dmp.dois">
|
||||
<mat-select #select class="mb-0 ml-3" placeholder="{{ dmp.dois[0].doi }}">
|
||||
<mat-option *ngFor="let doi of dmp.dois" (click)="selectDoi(select, doi)">
|
||||
{{doi.repositoryId}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<div class="d-flex justify-content-end ml-3">
|
||||
<button (click)="copyDoi(doi)" mat-mini-fab class="mr-2 d-flex justify-content-center align-items-center" matTooltip="{{'DMP-LISTING.ACTIONS.COPY' | translate}}" matTooltipPosition="above">
|
||||
<button (click)="copyDoi(dmp.dois[0].doi)" mat-mini-fab class="mr-2 d-flex justify-content-center align-items-center" matTooltip="{{'DMP-LISTING.ACTIONS.COPY' | translate}}" matTooltipPosition="above">
|
||||
<mat-icon class="mat-mini-fab-icon">content_copy</mat-icon>
|
||||
</button>
|
||||
<button mat-mini-fab class="mr-2 d-flex justify-content-center align-items-center" matTooltip="{{'GRANT-EDITOR.ACTIONS.VISIT-WEBSITE' | translate}}" matTooltipPosition="above">
|
||||
|
|
|
@ -44,6 +44,7 @@ import { DepositRepositoriesService } from '@app/core/services/deposit-repositor
|
|||
import { DmpDepositDialogComponent } from '../editor/dmp-deposit-dialog/dmp-deposit-dialog.component';
|
||||
import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration';
|
||||
import { DoiModel } from '@app/core/model/doi/doi';
|
||||
import { MatSelect } from '@angular/material/select';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-overview',
|
||||
|
@ -615,11 +616,23 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
this.router.navigate(['/datasets', 'new', this.dmp.id]);
|
||||
}
|
||||
|
||||
selectDoi(s: MatSelect, doiModel: DoiModel){
|
||||
s.placeholder = doiModel.doi;
|
||||
const foundIdx = this.dmp.dois.findIndex(el => el == doiModel);
|
||||
this.dmp.dois.splice(foundIdx, 1);
|
||||
this.dmp.dois.unshift(doiModel);
|
||||
}
|
||||
|
||||
createDoiLink(doiModel: DoiModel): string {
|
||||
if(doiModel.repositoryId == "Zenodo"){
|
||||
const doiarr = doiModel.doi.split('.');
|
||||
const id = doiarr[doiarr.length - 1];
|
||||
return this.depositRepos.find(r => r.repositoryId == doiModel.repositoryId).repositoryRecordUrl + id;
|
||||
}
|
||||
else{
|
||||
return this.depositRepos.find(r => r.repositoryId == doiModel.repositoryId).repositoryRecordUrl + doiModel.doi;
|
||||
}
|
||||
}
|
||||
|
||||
reverse() {
|
||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||
|
@ -688,10 +701,15 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
}
|
||||
|
||||
copyDoi(doi) {
|
||||
let domElement = doi.nativeElement as HTMLInputElement;
|
||||
domElement.select();
|
||||
const el = document.createElement('textarea');
|
||||
el.value = doi;
|
||||
el.setAttribute('readonly', '');
|
||||
el.style.position = 'absolute';
|
||||
el.style.left = '-9999px';
|
||||
document.body.appendChild(el);
|
||||
el.select();
|
||||
document.execCommand('copy');
|
||||
domElement.setSelectionRange(0, 0);
|
||||
document.body.removeChild(el);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-COPY-TO-CLIPBOARD'), SnackBarNotificationLevel.Success);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue