Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-05-15 13:56:35 +03:00
commit c4a757ba36
42 changed files with 198 additions and 136 deletions

View File

@ -1,7 +1,7 @@
package org.opencdmp.model.persist; package org.opencdmp.model.persist;
import org.opencdmp.commons.validation.BaseValidator;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import org.opencdmp.commons.validation.BaseValidator;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DmpEntity; import org.opencdmp.data.DmpEntity;
import org.opencdmp.errorcode.ErrorThesaurusProperties; import org.opencdmp.errorcode.ErrorThesaurusProperties;
@ -18,18 +18,18 @@ import java.util.UUID;
public class NewVersionDmpPersist { public class NewVersionDmpPersist {
private UUID id = null; private UUID id;
public static final String _id = "id"; public static final String _id = "id";
private String label = null; private String label;
public static final String _label = "label"; public static final String _label = "label";
private String description = null; private String description;
public static final String _description = "description"; public static final String _description = "description";
private UUID blueprintId = null; private UUID blueprintId;
public static final String _blueprintId = "blueprintId"; public static final String _blueprintId = "blueprintId";
@ -42,7 +42,7 @@ public class NewVersionDmpPersist {
public static final String _hash = "hash"; public static final String _hash = "hash";
public UUID getId() { public UUID getId() {
return id; return this.id;
} }
public void setId(UUID id) { public void setId(UUID id) {
@ -50,7 +50,7 @@ public class NewVersionDmpPersist {
} }
public String getLabel() { public String getLabel() {
return label; return this.label;
} }
public void setLabel(String label) { public void setLabel(String label) {
@ -58,7 +58,7 @@ public class NewVersionDmpPersist {
} }
public String getDescription() { public String getDescription() {
return description; return this.description;
} }
public void setDescription(String description) { public void setDescription(String description) {
@ -66,7 +66,7 @@ public class NewVersionDmpPersist {
} }
public UUID getBlueprintId() { public UUID getBlueprintId() {
return blueprintId; return this.blueprintId;
} }
public void setBlueprintId(UUID blueprintId) { public void setBlueprintId(UUID blueprintId) {
@ -74,7 +74,7 @@ public class NewVersionDmpPersist {
} }
public List<UUID> getDescriptions() { public List<UUID> getDescriptions() {
return descriptions; return this.descriptions;
} }
public void setDescriptions(List<UUID> descriptions) { public void setDescriptions(List<UUID> descriptions) {
@ -82,7 +82,7 @@ public class NewVersionDmpPersist {
} }
public String getHash() { public String getHash() {
return hash; return this.hash;
} }
public void setHash(String hash) { public void setHash(String hash) {
@ -113,23 +113,23 @@ public class NewVersionDmpPersist {
this.spec() this.spec()
.iff(() -> this.isValidGuid(item.getId())) .iff(() -> this.isValidGuid(item.getId()))
.must(() -> this.isValidHash(item.getHash())) .must(() -> this.isValidHash(item.getHash()))
.failOn(NewVersionDmpPersist._hash).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._hash}, LocaleContextHolder.getLocale())), .failOn(NewVersionDmpPersist._hash).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._hash}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getLabel())) .must(() -> !this.isEmpty(item.getLabel()))
.failOn(NewVersionDmpPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())), .failOn(NewVersionDmpPersist._label).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.iff(() -> !this.isEmpty(item.getLabel())) .iff(() -> !this.isEmpty(item.getLabel()))
.must(() -> this.lessEqualLength(item.getLabel(), DmpEntity._labelLength)) .must(() -> this.lessEqualLength(item.getLabel(), DmpEntity._labelLength))
.failOn(NewVersionDmpPersist._label).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())), .failOn(NewVersionDmpPersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{NewVersionDmpPersist._label}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getDescription())) .must(() -> !this.isEmpty(item.getDescription()))
.failOn(NewVersionDmpPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._description}, LocaleContextHolder.getLocale())), .failOn(NewVersionDmpPersist._description).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._description}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> this.isValidGuid(item.getBlueprintId())) .must(() -> this.isValidGuid(item.getBlueprintId()))
.failOn(NewVersionDmpPersist._blueprintId).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._blueprintId}, LocaleContextHolder.getLocale())), .failOn(NewVersionDmpPersist._blueprintId).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._blueprintId}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.must(() -> !this.isNull(item.getDescriptions())) .must(() -> !this.isNull(item.getDescriptions()))
.failOn(NewVersionDmpPersist._descriptions).failWith(messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._descriptions}, LocaleContextHolder.getLocale())) .failOn(NewVersionDmpPersist._descriptions).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{NewVersionDmpPersist._descriptions}, LocaleContextHolder.getLocale()))
); );
} }
} }

View File

@ -1,17 +1,17 @@
package org.opencdmp.service.description; package org.opencdmp.service.description;
import org.opencdmp.commons.types.description.importexport.DescriptionImportExport;
import org.opencdmp.data.StorageFileEntity;
import org.opencdmp.model.description.Description;
import org.opencdmp.model.DescriptionValidationResult;
import org.opencdmp.model.StorageFile;
import org.opencdmp.model.persist.*;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.exception.MyValidationException; import gr.cite.tools.exception.MyValidationException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import org.opencdmp.commons.types.description.importexport.DescriptionImportExport;
import org.opencdmp.data.StorageFileEntity;
import org.opencdmp.model.DescriptionValidationResult;
import org.opencdmp.model.StorageFile;
import org.opencdmp.model.description.Description;
import org.opencdmp.model.persist.*;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -40,8 +40,6 @@ public interface DescriptionService {
List<DescriptionValidationResult> validate(List<UUID> descriptionIds) throws InvalidApplicationException; List<DescriptionValidationResult> validate(List<UUID> descriptionIds) throws InvalidApplicationException;
void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException, IOException;
ResponseEntity<byte[]> export(UUID id, String exportType) throws InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException; ResponseEntity<byte[]> export(UUID id, String exportType) throws InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException;
StorageFile uploadFieldFile(DescriptionFieldFilePersist model, MultipartFile file, FieldSet fields) throws IOException; StorageFile uploadFieldFile(DescriptionFieldFilePersist model, MultipartFile file, FieldSet fields) throws IOException;

View File

@ -817,73 +817,6 @@ public class DescriptionServiceImpl implements DescriptionService {
//region clone //region clone
@Override
public void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException, IOException {
logger.debug("cloning description: {} with description: {}", descriptionId, dmpId);
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(descriptionId)), Permission.CloneDescription);
DescriptionEntity existing = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(descriptionId).isActive(IsActive.Active).first();
DescriptionEntity newDescription = new DescriptionEntity();
newDescription.setId(UUID.randomUUID());
newDescription.setLabel(existing.getLabel());
newDescription.setDescription(existing.getDescription());
newDescription.setStatus(DescriptionStatus.Draft);
newDescription.setProperties(existing.getProperties());
newDescription.setDmpId(dmpId);
newDescription.setDmpDescriptionTemplateId(existing.getDmpDescriptionTemplateId());
newDescription.setDescriptionTemplateId(existing.getDescriptionTemplateId());
newDescription.setCreatedById(this.userScope.getUserId());
newDescription.setCreatedAt(Instant.now());
newDescription.setUpdatedAt(Instant.now());
newDescription.setIsActive(IsActive.Active);
this.entityManager.persist(newDescription);
List<DescriptionReferenceEntity> descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class).disableTracking()
.descriptionIds(existing.getId())
.isActive(IsActive.Active)
.collect();
List<DescriptionTagEntity> descriptionTags = this.queryFactory.query(DescriptionTagQuery.class).disableTracking()
.descriptionIds(existing.getId())
.isActive(IsActive.Active)
.collect();
for (DescriptionReferenceEntity descriptionReference : descriptionReferences) {
DescriptionReferenceEntity newReference = new DescriptionReferenceEntity();
newReference.setId(UUID.randomUUID());
newReference.setDescriptionId(newDescription.getId());
newReference.setReferenceId(descriptionReference.getReferenceId());
newReference.setData(descriptionReference.getData());
newReference.setCreatedAt(Instant.now());
newReference.setUpdatedAt(Instant.now());
newReference.setIsActive(IsActive.Active);
this.entityManager.persist(newReference);
}
for(DescriptionTagEntity descriptionTag : descriptionTags) {
DescriptionTagEntity newTag = new DescriptionTagEntity();
newTag.setId(UUID.randomUUID());
newTag.setDescriptionId(newDescription.getId());
newTag.setTagId(descriptionTag.getTagId());
newTag.setCreatedAt(Instant.now());
newTag.setUpdatedAt(Instant.now());
newTag.setIsActive(IsActive.Active);
this.entityManager.persist(newTag);
}
this.entityManager.flush();
this.elasticService.persistDescription(newDescription);
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(newDescription.getId());
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(existing.getId());
}
//endregion //endregion
//region file export //region file export

View File

@ -444,6 +444,7 @@ public class DmpServiceImpl implements DmpService {
this.entityManager.persist(newReference); this.entityManager.persist(newReference);
} }
Map<UUID, UUID> dmpDescriptionTemplateRemap = new HashMap<>();
for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) { for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) {
DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity();
newTemplate.setId(UUID.randomUUID()); newTemplate.setId(UUID.randomUUID());
@ -453,12 +454,15 @@ public class DmpServiceImpl implements DmpService {
newTemplate.setCreatedAt(Instant.now()); newTemplate.setCreatedAt(Instant.now());
newTemplate.setUpdatedAt(Instant.now()); newTemplate.setUpdatedAt(Instant.now());
newTemplate.setIsActive(IsActive.Active); newTemplate.setIsActive(IsActive.Active);
dmpDescriptionTemplateRemap.put(dmpDescriptionTemplate.getId(), newTemplate.getId());
this.entityManager.persist(newTemplate); this.entityManager.persist(newTemplate);
} }
this.entityManager.flush();
for (UUID descriptionId : model.getDescriptions()) { for (UUID descriptionId : model.getDescriptions()) {
this.descriptionService.clone(newDmp.getId(), descriptionId); this.cloneDescription(newDmp.getId(), dmpDescriptionTemplateRemap, descriptionId);
} }
this.entityManager.flush(); this.entityManager.flush();
@ -476,6 +480,74 @@ public class DmpServiceImpl implements DmpService {
return this.builderFactory.builder(DmpBuilder.class).build(BaseFieldSet.build(fields, Dmp._id), newDmp); return this.builderFactory.builder(DmpBuilder.class).build(BaseFieldSet.build(fields, Dmp._id), newDmp);
} }
public void cloneDescription(UUID dmpId, Map<UUID, UUID> dmpDescriptionTemplateRemap, UUID descriptionId) throws InvalidApplicationException, IOException {
logger.debug("cloning description: {} with description: {}", descriptionId, dmpId);
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionAffiliation(descriptionId)), Permission.CloneDescription);
DescriptionEntity existing = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(descriptionId).isActive(IsActive.Active).first();
DescriptionEntity newDescription = new DescriptionEntity();
newDescription.setId(UUID.randomUUID());
newDescription.setLabel(existing.getLabel());
newDescription.setDescription(existing.getDescription());
newDescription.setStatus(DescriptionStatus.Draft);
newDescription.setProperties(existing.getProperties());
newDescription.setDmpId(dmpId);
newDescription.setDmpDescriptionTemplateId(dmpDescriptionTemplateRemap.get(existing.getDmpDescriptionTemplateId()));
newDescription.setDescriptionTemplateId(existing.getDescriptionTemplateId());
newDescription.setCreatedById(this.userScope.getUserId());
newDescription.setCreatedAt(Instant.now());
newDescription.setUpdatedAt(Instant.now());
newDescription.setIsActive(IsActive.Active);
this.entityManager.persist(newDescription);
List<DescriptionReferenceEntity> descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class).disableTracking()
.descriptionIds(existing.getId())
.isActive(IsActive.Active)
.collect();
List<DescriptionTagEntity> descriptionTags = this.queryFactory.query(DescriptionTagQuery.class).disableTracking()
.descriptionIds(existing.getId())
.isActive(IsActive.Active)
.collect();
for (DescriptionReferenceEntity descriptionReference : descriptionReferences) {
DescriptionReferenceEntity newReference = new DescriptionReferenceEntity();
newReference.setId(UUID.randomUUID());
newReference.setDescriptionId(newDescription.getId());
newReference.setReferenceId(descriptionReference.getReferenceId());
newReference.setData(descriptionReference.getData());
newReference.setCreatedAt(Instant.now());
newReference.setUpdatedAt(Instant.now());
newReference.setIsActive(IsActive.Active);
this.entityManager.persist(newReference);
}
for(DescriptionTagEntity descriptionTag : descriptionTags) {
DescriptionTagEntity newTag = new DescriptionTagEntity();
newTag.setId(UUID.randomUUID());
newTag.setDescriptionId(newDescription.getId());
newTag.setTagId(descriptionTag.getTagId());
newTag.setCreatedAt(Instant.now());
newTag.setUpdatedAt(Instant.now());
newTag.setIsActive(IsActive.Active);
this.entityManager.persist(newTag);
}
this.entityManager.flush();
this.elasticService.persistDescription(newDescription);
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(newDescription.getId());
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(existing.getId());
}
private void updateVersionStatusAndSave(DmpEntity data, DmpStatus previousStatus, DmpStatus newStatus) throws InvalidApplicationException { private void updateVersionStatusAndSave(DmpEntity data, DmpStatus previousStatus, DmpStatus newStatus) throws InvalidApplicationException {
if (previousStatus.equals(newStatus)) if (previousStatus.equals(newStatus))
return; return;
@ -578,6 +650,7 @@ public class DmpServiceImpl implements DmpService {
this.entityManager.persist(newReference); this.entityManager.persist(newReference);
} }
Map<UUID, UUID> dmpDescriptionTemplateRemap = new HashMap<>();
for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) { for (DmpDescriptionTemplateEntity dmpDescriptionTemplate : dmpDescriptionTemplates) {
DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity(); DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity();
newTemplate.setId(UUID.randomUUID()); newTemplate.setId(UUID.randomUUID());
@ -587,6 +660,7 @@ public class DmpServiceImpl implements DmpService {
newTemplate.setCreatedAt(Instant.now()); newTemplate.setCreatedAt(Instant.now());
newTemplate.setUpdatedAt(Instant.now()); newTemplate.setUpdatedAt(Instant.now());
newTemplate.setIsActive(IsActive.Active); newTemplate.setIsActive(IsActive.Active);
dmpDescriptionTemplateRemap.put(dmpDescriptionTemplate.getId(), newTemplate.getId());
this.entityManager.persist(newTemplate); this.entityManager.persist(newTemplate);
} }
@ -600,7 +674,7 @@ public class DmpServiceImpl implements DmpService {
DmpEntity resultingDmpEntity = this.queryFactory.query(DmpQuery.class).disableTracking().ids(newDmp.getId()).firstAs(fields); DmpEntity resultingDmpEntity = this.queryFactory.query(DmpQuery.class).disableTracking().ids(newDmp.getId()).firstAs(fields);
if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){ if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){
for (UUID description: model.getDescriptions()) { for (UUID description: model.getDescriptions()) {
this.descriptionService.clone(newDmp.getId(), description); this.cloneDescription(newDmp.getId(), dmpDescriptionTemplateRemap, description);
} }
} }
return this.builderFactory.builder(DmpBuilder.class).build(fields, resultingDmpEntity); return this.builderFactory.builder(DmpBuilder.class).build(fields, resultingDmpEntity);

View File

@ -1,15 +1,5 @@
storage: storage:
service: service:
defaultLanguage: en
storages:
- type: Temp
basePath: ${FILE_STORAGE}/temp
- type: Main
basePath: ${FILE_STORAGE}/main
- type: Transformer
basePath: ${FILE_STORAGE}/transformer
- type: Deposit
basePath: ${FILE_STORAGE}/deposit
static-files: static-files:
semantics: backend/web/src/main/resources/Semantics.json semantics: backend/web/src/main/resources/Semantics.json
material-files: material-files:

View File

@ -3,6 +3,16 @@ storage:
enable: true enable: true
intervalSeconds: 600 intervalSeconds: 600
service: service:
defaultLanguage: en
storages:
- type: Temp
basePath: ${FILE_STORAGE}/temp
- type: Main
basePath: ${FILE_STORAGE}/main
- type: Transformer
basePath: ${FILE_STORAGE}/transformer
- type: Deposit
basePath: ${FILE_STORAGE}/deposit
tempStoreLifetimeSeconds: 7200 tempStoreLifetimeSeconds: 7200
material-files: material-files:
localizedNameLanguageKey: "{lang}" localizedNameLanguageKey: "{lang}"

View File

@ -66,10 +66,9 @@
<button [disabled]="saving" mat-menu-item (click)="saveAndClose()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CLOSE' | translate }}</button> <button [disabled]="saving" mat-menu-item (click)="saveAndClose()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CLOSE' | translate }}</button>
<button [disabled]="saving" mat-menu-item (click)="saveAndContinue()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button> <button [disabled]="saving" mat-menu-item (click)="saveAndContinue()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button>
</mat-menu> </mat-menu>
<button [disabled]="saving" *ngIf="!isLocked && !viewOnly && hasReversableStatus() == false && canEdit" mat-raised-button class="description-save-btn mr-2" type="button" (click)="finalize()">{{ 'DESCRIPTION-EDITOR.ACTIONS.FINALIZE' | translate }}</button>
<button [disabled]="saving" *ngIf="!isLocked && !viewOnly && hasReversableStatus() == false" mat-raised-button class="description-save-btn mr-2" type="button" (click)="finalize()">{{ 'DESCRIPTION-EDITOR.ACTIONS.FINALIZE' | translate }}</button>
<button [disabled]="saving" *ngIf="isLocked" mat-raised-button disabled class="description-save-btn cursor-default" type="button">{{ 'DMP-OVERVIEW.LOCKED' | translate}}</button> <button [disabled]="saving" *ngIf="isLocked" mat-raised-button disabled class="description-save-btn cursor-default" type="button">{{ 'DMP-OVERVIEW.LOCKED' | translate}}</button>
<button [disabled]="saving" *ngIf="hasReversableStatus() && !isLocked" mat-raised-button class="description-save-btn mr-2" (click)="reverse()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.REVERSE' | translate }}</button> <button [disabled]="saving" *ngIf="hasReversableStatus() && !isLocked && canEdit" mat-raised-button class="description-save-btn mr-2" (click)="reverse()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.REVERSE' | translate }}</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -63,6 +63,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
isNew = true; isNew = true;
isDeleted = false; isDeleted = false;
isCopy = false; isCopy = false;
canEdit = false;
canReview = false; canReview = false;
item: Description; item: Description;
fieldsetIdWithFocus: string; fieldsetIdWithFocus: string;
@ -588,15 +589,15 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.descriptionService.getDescriptionSectionPermissions(descriptionSectionPermissionResolverModel) this.descriptionService.getDescriptionSectionPermissions(descriptionSectionPermissionResolverModel)
.pipe(takeUntil(this._destroyed)).subscribe( .pipe(takeUntil(this._destroyed)).subscribe(
permissionPerSection => { permissionPerSection => {
const canedit = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.EditDescription); this.canEdit = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.EditDescription);
this.canReview = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.ReviewDescription); this.canReview = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.ReviewDescription);
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !canedit); this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.canEdit);
if (this.item.descriptionTemplate?.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties')); if (this.item.descriptionTemplate?.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties'));
if (this.item.descriptionTemplate?.definition) this.pageToFieldSetMap = this.mapPageToFieldSet(this.item.descriptionTemplate);; if (this.item.descriptionTemplate?.definition) this.pageToFieldSetMap = this.mapPageToFieldSet(this.item.descriptionTemplate);;
// this.selectedSystemFields = this.selectedSystemFieldDisabled(); // this.selectedSystemFields = this.selectedSystemFieldDisabled();
this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel); this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted || !canedit) { if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted || !this.canEdit) {
this.viewOnly = true; this.viewOnly = true;
this.isFinalized = true; this.isFinalized = true;
this.formGroup.disable(); this.formGroup.disable();

View File

@ -104,8 +104,14 @@
</ol> </ol>
<ul *ngIf="item.id && section.hasTemplates && canEditSection(section.id) && !formGroup.disabled" class="add-description-option"> <ul *ngIf="item.id && section.hasTemplates && canEditSection(section.id) && !formGroup.disabled" class="add-description-option">
<li> <li>
<a class="add-description-action" [ngClass]="{'drag-handle-disabled': !canAddDescription(section)}" [routerLink]="canAddDescription(section) ? ['/descriptions/edit/' + item.id + '/' + section.id] : null"> <a class="add-description-action" [ngClass]="{'drag-handle-disabled': !hasDescriptionTemplates(section) || !hasValidMultiplicity(section)}" [routerLink]="hasDescriptionTemplates(section) && hasValidMultiplicity(section) ? ['/descriptions/edit/' + item.id + '/' + section.id] : null">
<mat-icon [matTooltipDisabled]="canAddDescription(section)" [matTooltip]="'DMP-EDITOR.DESCRIPTION-TEMPLATES-MAX-MULTIPLICITY' | translate">add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}} <ng-container *ngIf="!hasDescriptionTemplates(section)" >
<mat-icon [matTooltipDisabled]="hasDescriptionTemplates(section)" [matTooltip]="'DMP-EDITOR.DESCRIPTION-TEMPLATES.EMPTY' | translate">add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}}
</ng-container>
<ng-container *ngIf="hasDescriptionTemplates(section)">
<mat-icon [matTooltipDisabled]="hasValidMultiplicity(section)" [matTooltip]="'DMP-EDITOR.DESCRIPTION-TEMPLATES.MAX-MULTIPLICITY' | translate">add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}}
</ng-container>
</a> </a>
</li> </li>
</ul> </ul>

View File

@ -298,9 +298,11 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
//Transform descriptionTemplates //Transform descriptionTemplates
formData.descriptionTemplates = []; formData.descriptionTemplates = [];
for (const sectionId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) { for (const sectionId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) {
formData.descriptionTemplates.push( if (this.formGroup.get('descriptionTemplates').get(sectionId).value != undefined){
...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } }) formData.descriptionTemplates.push(
); ...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } })
);
}
} }
this.dmpService.persist(formData) this.dmpService.persist(formData)
@ -572,7 +574,12 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
}); });
} }
canAddDescription(section: DmpBlueprintDefinitionSection): boolean { hasDescriptionTemplates(section: DmpBlueprintDefinitionSection): boolean {
if (this.item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id).length > 0) return true;
return false;
}
hasValidMultiplicity(section: DmpBlueprintDefinitionSection): boolean {
if (section.hasTemplates) { if (section.hasTemplates) {
if (section.descriptionTemplates?.length > 0) { if (section.descriptionTemplates?.length > 0) {
const descriptions = this.descriptionsInSection(section.id) const descriptions = this.descriptionsInSection(section.id)

View File

@ -239,15 +239,15 @@
</ng-container> </ng-container>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="frame mb-3 pt-4 pl-4 pr-5 pb-3"> <div class="frame mb-3 pt-4 pl-3 pr-3 pb-3">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<p class="header">{{ 'DMP-OVERVIEW.DMP-AUTHORS' | translate }}</p> <p class="header">{{ 'DMP-OVERVIEW.DMP-AUTHORS' | translate }}</p>
</div> </div>
<div class="col-12"> <div class="col-12">
<div *ngFor="let dmpUser of dmp.dmpUsers" class="row authors"> <div *ngFor="let dmpUser of dmp.dmpUsers" class="row authors">
<div class="col-auto pr-0"> <div class="col-auto d-flex flex-row">
<button class="account_btn"> <button class="account_btn mr-3 pl-0">
<mat-icon class="account-icon">account_circle</mat-icon> <mat-icon class="account-icon">account_circle</mat-icon>
</button> </button>
</div> </div>
@ -257,7 +257,11 @@
<span *ngIf="isUserAuthor(dmpUser.user?.id)"> <span *ngIf="isUserAuthor(dmpUser.user?.id)">
({{ 'DMP-OVERVIEW.YOU' | translate }})</span> ({{ 'DMP-OVERVIEW.YOU' | translate }})</span>
</p> </p>
<p class="authors-role">{{ enumUtils.toDmpUserRoleString(dmpUser.role) }}</p> <p class="authors-role">
<span>{{ enumUtils.toDmpUserRoleString(dmpUser.role) }} - </span>
<span *ngIf="!dmpUser.sectionId">{{ 'DMP-OVERVIEW.ROLES.ALL-SECTIONS' | translate}}</span>
<span *ngIf="dmpUser.sectionId">{{ getSectionNameById(dmpUser.sectionId) }}</span>
</p>
</div> </div>
<div *ngIf="canAssignDmpUsers(dmp) && dmp.status === dmpStatusEnum.Draft && dmpUser.role != dmpUserRoleEnum.Owner" class="col-auto"> <div *ngIf="canAssignDmpUsers(dmp) && dmp.status === dmpStatusEnum.Draft && dmpUser.role != dmpUserRoleEnum.Owner" class="col-auto">
<button (click)="removeUserFromDmp(dmpUser)" mat-mini-fab matTooltip="{{ 'DMP-OVERVIEW.ACTIONS.REMOVE-AUTHOR' | translate}}" matTooltipPosition="above"> <button (click)="removeUserFromDmp(dmpUser)" mat-mini-fab matTooltip="{{ 'DMP-OVERVIEW.ACTIONS.REMOVE-AUTHOR' | translate}}" matTooltipPosition="above">

View File

@ -710,6 +710,14 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
return path + reference; return path + reference;
} }
getSectionNameById(sectionId: Guid): string {
if (sectionId == null) return '';
let sections: DmpBlueprintDefinitionSection[] = this.dmp?.blueprint?.definition?.sections?.filter((section:DmpBlueprintDefinitionSection) => sectionId===section.id);
return sections == null ? '' : sections[0].label;
}
checkLockStatus(id: Guid) { checkLockStatus(id: Guid) {
this.lockService.checkLockStatus(Guid.parse(id.toString())).pipe(takeUntil(this._destroyed)) this.lockService.checkLockStatus(Guid.parse(id.toString())).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => { .subscribe(lockStatus => {
@ -757,6 +765,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.status)].join('.'), [nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.status)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.isActive)].join('.'), [nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.isActive)].join('.'),
[nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.id)].join('.'), [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.sectionId)].join('.'),
[nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.id)].join('.'), [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.id)].join('.'),
[nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.name)].join('.'), [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.name)].join('.'),
[nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'), [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'),

View File

@ -249,21 +249,20 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
return; return;
} }
const formData = this.formService.getValue(this.formGroup.value) as UserPersist; const formData = this.formService.getValue(this.formGroup.value) as UserPersist;
formData.additionalInfo.organization.typeId = Guid.parse(this.referenceTypeService.getOrganizationReferenceType()); if (formData.additionalInfo.organization) formData.additionalInfo.organization.typeId = Guid.parse(this.referenceTypeService.getOrganizationReferenceType());
this.userService.persist(formData) this.userService.persist(formData)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
x => { x => {
this.editMode = false; this.editMode = false;
this.languageService.changeLanguage(this.formGroup.get('additionalInfo').get('language').value); this.languageService.changeLanguage(this.formGroup.get('additionalInfo').get('language').value);
this.getOrRefreshData();
this.authService.refresh() this.authService.refresh()
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(result => { .subscribe(result => {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/profile']); // this.router.navigate(['/profile']);
window.location.reload();
}); });
// .subscribe(result => window.location.reload());
}, },
error => this.onCallbackError(error)); error => this.onCallbackError(error));
} }

View File

@ -703,6 +703,9 @@
"MIN-DESCRIPTIONS-DIALOG": { "MIN-DESCRIPTIONS-DIALOG": {
"TITLE": "Min({{minMultiplicity}}) Descriptions needed using this template.", "TITLE": "Min({{minMultiplicity}}) Descriptions needed using this template.",
"MESSAGE": "Add Description." "MESSAGE": "Add Description."
},
"ROLES": {
"ALL-SECTIONS": "All Sections"
} }
}, },
"DESCRIPTION-OVERVIEW": { "DESCRIPTION-OVERVIEW": {
@ -1504,7 +1507,10 @@
"LOCKED": "Locked", "LOCKED": "Locked",
"DESCRIPTION": "Description", "DESCRIPTION": "Description",
"NO-TEMPLATE-MESSAGE": "If you can't find a template or if you want to create a personalized template for your institution, research community or training needs, please contact us.", "NO-TEMPLATE-MESSAGE": "If you can't find a template or if you want to create a personalized template for your institution, research community or training needs, please contact us.",
"DESCRIPTION-TEMPLATES-MAX-MULTIPLICITY": "Description Templates has reached the maximun multiplicity", "DESCRIPTION-TEMPLATES": {
"EMPTY": "Descriptiont templates not found",
"MAX-MULTIPLICITY": "Description Templates has reached the maximun multiplicity"
},
"UNSUCCESSFUL-REMOVE-TEMPLATE": "Cannot remove template, because it's already being used by one or more Descriptions.", "UNSUCCESSFUL-REMOVE-TEMPLATE": "Cannot remove template, because it's already being used by one or more Descriptions.",
"FIELDS": { "FIELDS": {
"TITLE": "Title of Plan", "TITLE": "Title of Plan",

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 3 sidebar_position: 3
description: What do we call 'blueprints'
--- ---
# Blueprints # Blueprints

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 5 sidebar_position: 5
description: Discover how collaboration works on descriptions
--- ---
# Collaborations # Collaborations

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 1 sidebar_position: 1
description: Discover how to create a new description
--- ---
# Create a Description # Create a Description

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 4 sidebar_position: 4
description: Discover the lifecycle of a description
--- ---
# Description Lifecycle # Description Lifecycle

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 2 sidebar_position: 2
description: Discover how to edit a description
--- ---
# Edit a Description # Edit a Description

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 8 sidebar_position: 8
description: Discover export options for a description
--- ---
# Exports # Exports

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 7 sidebar_position: 7
description: Discover import options for a description
--- ---
# Imports # Imports

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 3 sidebar_position: 3
description: Discover how to prefill a description to save time
--- ---
# Prefill a Description # Prefill a Description

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 6 sidebar_position: 6
description: Discover how to review a description
--- ---
# Reviewing # Reviewing

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 1 sidebar_position: 1
description: A brief introduction to the core entities of the platform
--- ---
# Introduction # Introduction

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 1 sidebar_position: 1
description: Discover how to create a new plan
--- ---
# Create a Plan # Create a Plan

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 9 sidebar_position: 9
description: Discover how to publich a plan and aquire a DOI
--- ---
# DOI Assignment # DOI Assignment

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 2 sidebar_position: 2
description: Discover how to edit a plan
--- ---
# Edit a Plan # Edit a Plan

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 8 sidebar_position: 8
description: Discover export options for a plan
--- ---
# Exports # Exports

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 7 sidebar_position: 7
description: Discover import options for a plan
--- ---
# Imports # Imports

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 4 sidebar_position: 4
description: Discover how you invite people to a plan
--- ---
# Invite collaborators # Invite collaborators

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 3 sidebar_position: 3
description: Discover the lifecycle of a plan
--- ---
# Plan lifecycle # Plan lifecycle

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 6 sidebar_position: 6
description: Discover how to review a plan
--- ---
# Reviewing # Reviewing

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 5 sidebar_position: 5
description: Discover plan versioning options
--- ---
# Versions # Versions

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 2 sidebar_position: 2
description: What do we call 'references'
--- ---
# References # References

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 4 sidebar_position: 4
description: What do we call 'templates'
--- ---
# Templates # Templates

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 1 sidebar_position: 1
description: A brief guide on the API documentation tool this platform uses
--- ---
# Swagger # Swagger

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 1 sidebar_position: 1
description: A guide on how Keycloak is configured as an auth provider for the platform
--- ---
# Keycloak # Keycloak

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 3 sidebar_position: 3
description: A guide for the platform architecture
--- ---
# Architecture # Architecture

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 2 sidebar_position: 2
description: A guide for the platform installation process
--- ---
# Installation # Installation

View File

@ -1,5 +1,6 @@
--- ---
sidebar_position: 1 sidebar_position: 1
description: A brief introduction to the platform features
--- ---
# Introduction # Introduction

View File

@ -5,4 +5,10 @@ description: Learn about the email notifications.
# Email # Email
These notifications are received by email, using the mail server configured during the platform installation. These notifications are received by email.
:::info
The mail server is configured during the notification service installation.
:::

View File

@ -23,19 +23,13 @@ import java.util.stream.Collectors;
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class UserBuilder extends BaseBuilder<User, UserEntity> { public class UserBuilder extends BaseBuilder<User, UserEntity> {
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired @Autowired
public UserBuilder( public UserBuilder(
ConventionService conventionService, ConventionService conventionService
BuilderFactory builderFactory,
QueryFactory queryFactory
) { ) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(UserBuilder.class))); super(conventionService, new LoggerService(LoggerFactory.getLogger(UserBuilder.class)));
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
} }
public UserBuilder authorize(EnumSet<AuthorizationFlags> values) { public UserBuilder authorize(EnumSet<AuthorizationFlags> values) {
@ -45,9 +39,9 @@ public class UserBuilder extends BaseBuilder<User, UserEntity> {
@Override @Override
public List<User> build(FieldSet fields, List<UserEntity> datas) throws MyApplicationException { public List<User> build(FieldSet fields, List<UserEntity> datas) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(datas).map(e -> e.size()).orElse(0), Optional.ofNullable(fields).map(e -> e.getFields()).map(e -> e.size()).orElse(0)); this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(datas).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields)); this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || fields.isEmpty()) return new ArrayList<>(); if (fields == null || fields.isEmpty() || datas == null) return new ArrayList<>();
List<User> models = new ArrayList<>(); List<User> models = new ArrayList<>();
@ -61,7 +55,7 @@ public class UserBuilder extends BaseBuilder<User, UserEntity> {
if (fields.hasField(this.asIndexer(User._isActive))) m.setIsActive(d.getIsActive()); if (fields.hasField(this.asIndexer(User._isActive))) m.setIsActive(d.getIsActive());
models.add(m); models.add(m);
} }
this.logger.debug("build {} items", Optional.ofNullable(models).map(e -> e.size()).orElse(0)); this.logger.debug("build {} items", models.size());
return models; return models;
} }
} }