Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
5e1cbc94a0
|
@ -195,10 +195,6 @@ public class DescriptionTemplatePersist {
|
||||||
.on(DescriptionTemplatePersist._definition)
|
.on(DescriptionTemplatePersist._definition)
|
||||||
.over(item.getDefinition())
|
.over(item.getDefinition())
|
||||||
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)),
|
.using(() -> this.validatorFactory.validator(DefinitionPersist.DefinitionPersistValidator.class)),
|
||||||
this.spec()
|
|
||||||
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
|
|
||||||
.must(() -> !this.isListNullOrEmpty(item.getUsers()))
|
|
||||||
.failOn(DescriptionTemplatePersist._users).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._users}, LocaleContextHolder.getLocale())),
|
|
||||||
this.navSpec()
|
this.navSpec()
|
||||||
.iff(() -> !this.isListNullOrEmpty(item.getUsers()))
|
.iff(() -> !this.isListNullOrEmpty(item.getUsers()))
|
||||||
.on(DescriptionTemplatePersist._users)
|
.on(DescriptionTemplatePersist._users)
|
||||||
|
|
|
@ -563,7 +563,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
public List<DmpUser> assignUsers(UUID dmpId, List<DmpUserPersist> model, FieldSet fieldSet, boolean disableDelete) throws InvalidApplicationException, IOException {
|
public List<DmpUser> assignUsers(UUID dmpId, List<DmpUserPersist> model, FieldSet fieldSet, boolean disableDelete) throws InvalidApplicationException, IOException {
|
||||||
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(dmpId)), Permission.AssignDmpUsers);
|
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(dmpId)), Permission.AssignDmpUsers);
|
||||||
|
|
||||||
if (model == null || model.stream().noneMatch(x-> x.getUser() != null && DmpUserRole.Owner.equals(x.getRole()))) throw new MyApplicationException("At least one owner required");
|
if (!disableDelete && (model == null || model.stream().noneMatch(x-> x.getUser() != null && DmpUserRole.Owner.equals(x.getRole())))) throw new MyApplicationException("At least one owner required");
|
||||||
|
|
||||||
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, dmpId);
|
DmpEntity dmpEntity = this.entityManager.find(DmpEntity.class, dmpId);
|
||||||
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpId, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpId, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
|
@ -25,5 +25,5 @@ public interface LockService {
|
||||||
|
|
||||||
void unlock(UUID target) throws InvalidApplicationException;
|
void unlock(UUID target) throws InvalidApplicationException;
|
||||||
|
|
||||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
void deleteAndSave(UUID id, UUID target) throws MyForbiddenException, InvalidApplicationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class LockServiceImpl implements LockService {
|
||||||
else {
|
else {
|
||||||
if (new Date().getTime() - Date.from(lock.getTouchedAt()).getTime() > lockProperties.getLockInterval()) {
|
if (new Date().getTime() - Date.from(lock.getTouchedAt()).getTime() > lockProperties.getLockInterval()) {
|
||||||
lockStatus.setStatus(false);
|
lockStatus.setStatus(false);
|
||||||
this.deleteAndSave(lock.getId());
|
this.deleteAndSave(lock.getId(), lock.getTarget());
|
||||||
} else lockStatus.setStatus(true);
|
} else lockStatus.setStatus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,14 +167,14 @@ public class LockServiceImpl implements LockService {
|
||||||
if (!lock.getLockedBy().equals(this.userScope.getUserId())) {
|
if (!lock.getLockedBy().equals(this.userScope.getUserId())) {
|
||||||
throw new InvalidApplicationException("Only the user who created that lock can delete it");
|
throw new InvalidApplicationException("Only the user who created that lock can delete it");
|
||||||
}
|
}
|
||||||
this.deleteAndSave(lock.getId());
|
this.deleteAndSave(lock.getId(), lock.getTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void deleteAndSave(UUID id, UUID target) throws MyForbiddenException, InvalidApplicationException {
|
||||||
logger.debug("deleting : {}", id);
|
logger.debug("deleting : {}", id);
|
||||||
|
|
||||||
AffiliatedResource affiliatedResourceDmp = this.authorizationContentResolver.dmpAffiliation(id);
|
AffiliatedResource affiliatedResourceDmp = this.authorizationContentResolver.dmpAffiliation(target);
|
||||||
AffiliatedResource affiliatedResourceDescription = this.authorizationContentResolver.descriptionAffiliation(id);
|
AffiliatedResource affiliatedResourceDescription = this.authorizationContentResolver.descriptionAffiliation(target);
|
||||||
this.authorizationService.authorizeAtLeastOneForce(List.of(affiliatedResourceDmp, affiliatedResourceDescription), Permission.DeleteLock);
|
this.authorizationService.authorizeAtLeastOneForce(List.of(affiliatedResourceDmp, affiliatedResourceDescription), Permission.DeleteLock);
|
||||||
|
|
||||||
this.deleterFactory.deleter(LockDeleter.class).deleteAndSaveByIds(List.of(id));
|
this.deleterFactory.deleter(LockDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||||
|
|
|
@ -212,12 +212,12 @@ public class LockController {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}/{target}")
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void delete(@PathVariable("id") UUID id, @PathVariable("id") UUID target) throws MyForbiddenException, InvalidApplicationException {
|
||||||
logger.debug(new MapLogEntry("retrieving" + Lock.class.getSimpleName()).And("id", id));
|
logger.debug(new MapLogEntry("retrieving" + Lock.class.getSimpleName()).And("id", id));
|
||||||
|
|
||||||
this.lockService.deleteAndSave(id);
|
this.lockService.deleteAndSave(id, target);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Lock_Delete, "id", id);
|
this.auditService.track(AuditableAction.Lock_Delete, "id", id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,16 +325,16 @@
|
||||||
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.UPDATE' |translate}}
|
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.UPDATE' |translate}}
|
||||||
<mat-icon (click)="$event.stopPropagation();" style="width: 14px;" [matMenuTriggerFor]="menuUpdate">expand_more</mat-icon>
|
<mat-icon (click)="$event.stopPropagation();" style="width: 14px;" [matMenuTriggerFor]="menuUpdate">expand_more</mat-icon>
|
||||||
</button> -->
|
</button> -->
|
||||||
<button *ngIf="formGroup.disabled || formGroup.get('status').value==1" [@finalize_btn] mat-raised-button class="template_action_btn save-btn" (click)="formSubmit()">
|
<!-- <button *ngIf="formGroup.disabled || formGroup.get('status').value==1" [@finalize_btn] mat-raised-button class="template_action_btn save-btn" (click)="formSubmit()">
|
||||||
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.UPDATE' | translate}}
|
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.UPDATE' | translate}}
|
||||||
<mat-icon (click)="$event.stopPropagation();" style="width: 14px;" [matMenuTriggerFor]="menuUpdate">expand_more</mat-icon>
|
<mat-icon (click)="$event.stopPropagation();" style="width: 14px;" [matMenuTriggerFor]="menuUpdate">expand_more</mat-icon>
|
||||||
</button>
|
</button> -->
|
||||||
<mat-menu #menuUpdate="matMenu">
|
<!-- <mat-menu #menuUpdate="matMenu">
|
||||||
<button [disabled]="!formGroup.valid" mat-menu-item (click)="updateAndFinalize(true)" type="button">{{ 'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.UPDATE-AND-CLOSE' | translate }}</button>
|
<button [disabled]="!formGroup.valid" mat-menu-item (click)="updateAndFinalize(true)" type="button">{{ 'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.UPDATE-AND-CLOSE' | translate }}</button>
|
||||||
<button [disabled]="!formGroup.valid" mat-menu-item (click)="updateAndFinalize()" type="button">{{ 'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.UPDATE-AND-CONTINUE' | translate }}</button>
|
<button [disabled]="!formGroup.valid" mat-menu-item (click)="updateAndFinalize()" type="button">{{ 'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.UPDATE-AND-CONTINUE' | translate }}</button>
|
||||||
</mat-menu>
|
</mat-menu> -->
|
||||||
|
|
||||||
<button *ngIf="!formGroup.disabled && formGroup.get('status').value!=1 && steps?.length-1 === stepper?.selectedIndex" [@finalize_btn] mat-button class="finalize-btn ml-3" [disabled]="!formGroup.valid" [class.invisible]="steps?.length-1 !== stepper?.selectedIndex" (click)="updateAndFinalize(true)">
|
<button *ngIf="!formGroup.disabled && formGroup.get('status').value!= finalized && steps?.length-1 === stepper?.selectedIndex" [@finalize_btn] mat-button class="finalize-btn ml-3" [disabled]="!formGroup.valid" [class.invisible]="steps?.length-1 !== stepper?.selectedIndex" (click)="finalize()">
|
||||||
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FINALIZE' | translate}}
|
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FINALIZE' | translate}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -60,6 +60,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
formGroup: UntypedFormGroup = null;
|
formGroup: UntypedFormGroup = null;
|
||||||
item: DescriptionTemplate;
|
item: DescriptionTemplate;
|
||||||
showInactiveDetails = false;
|
showInactiveDetails = false;
|
||||||
|
finalized: DescriptionTemplateStatus.Finalized;
|
||||||
|
|
||||||
availableLanguages: LanguageInfo[] = this.languageInfoService.getLanguageInfoValues();
|
availableLanguages: LanguageInfo[] = this.languageInfoService.getLanguageInfoValues();
|
||||||
|
|
||||||
|
@ -183,6 +184,10 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
if (this.editorModel.status == DescriptionTemplateStatus.Finalized || this.isDeleted) {
|
if (this.editorModel.status == DescriptionTemplateStatus.Finalized || this.isDeleted) {
|
||||||
this.formGroup.disable();
|
this.formGroup.disable();
|
||||||
}
|
}
|
||||||
|
const action = this.route.snapshot.data['action'];
|
||||||
|
if (action && action == 'new-version') {
|
||||||
|
this.formGroup.enable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshData(): void {
|
refreshData(): void {
|
||||||
|
@ -262,6 +267,25 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
this.formService.validateAllFormFields(this.formGroup);
|
this.formService.validateAllFormFields(this.formGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finalize() {
|
||||||
|
this.formService.removeAllBackEndErrors(this.formGroup);
|
||||||
|
this.formService.touchAllFormFields(this.formGroup);
|
||||||
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
|
restoreFocus: false,
|
||||||
|
data: {
|
||||||
|
message: this.language.instant('DESCRIPTION-OVERVIEW.FINALIZE-DIALOG.TITLE'),
|
||||||
|
confirmButton: this.language.instant('DESCRIPTION-OVERVIEW.FINALIZE-DIALOG.CONFIRM'),
|
||||||
|
cancelButton: this.language.instant('DESCRIPTION-OVERVIEW.FINALIZE-DIALOG.NEGATIVE'),
|
||||||
|
isDeleteConfirmation: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
this.formGroup.get('status').setValue(DescriptionTemplateStatus.Finalized);
|
||||||
|
this.persistEntity();
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Description Template User
|
// Description Template User
|
||||||
|
|
|
@ -352,7 +352,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
||||||
|
|
||||||
category: [{ value: this.category, disabled: disabled }, context.getValidation('category').validators],
|
category: [{ value: this.category, disabled: disabled }, context.getValidation('category').validators],
|
||||||
label: [{ value: this.label, disabled: disabled }, this.category === DmpBlueprintFieldCategory.System ? context.getValidation('label-system').validators : context.getValidation('label-extra').validators],
|
label: [{ value: this.label, disabled: disabled }, this.category === DmpBlueprintFieldCategory.System ? context.getValidation('label-system').validators : ( this.category === DmpBlueprintFieldCategory.Extra ? context.getValidation('label-extra').validators : context.getValidation('label-external-reference').validators)],
|
||||||
placeholder: [{ value: this.placeholder, disabled: disabled }, context.getValidation('placeholder').validators],
|
placeholder: [{ value: this.placeholder, disabled: disabled }, context.getValidation('placeholder').validators],
|
||||||
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
|
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
|
||||||
required: [{ value: this.required, disabled: disabled }, context.getValidation('required').validators],
|
required: [{ value: this.required, disabled: disabled }, context.getValidation('required').validators],
|
||||||
|
@ -377,6 +377,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
baseValidationArray.push({ key: 'category', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}category`)] });
|
baseValidationArray.push({ key: 'category', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}category`)] });
|
||||||
baseValidationArray.push({ key: 'label-system', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
baseValidationArray.push({ key: 'label-system', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||||
baseValidationArray.push({ key: 'label-extra', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
baseValidationArray.push({ key: 'label-extra', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||||
|
baseValidationArray.push({ key: 'label-external-reference', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
|
||||||
baseValidationArray.push({ key: 'placeholder', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}placeholder`)] });
|
baseValidationArray.push({ key: 'placeholder', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}placeholder`)] });
|
||||||
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
||||||
baseValidationArray.push({ key: 'semantics', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}semantics`)] });
|
baseValidationArray.push({ key: 'semantics', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}semantics`)] });
|
||||||
|
@ -406,7 +407,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
const control = formGroup?.get(keyField);
|
const control = formGroup?.get(keyField);
|
||||||
control?.clearValidators();
|
control?.clearValidators();
|
||||||
if (keyField == 'label') {
|
if (keyField == 'label') {
|
||||||
control?.addValidators(context.has('label-system') ? context.getValidation('label-system').validators : context.getValidation('label-extra').validators);
|
control?.addValidators(context.has('label-system') ? context.getValidation('label-system').validators : (context.has('label-extra') ? context.getValidation('label-extra').validators : context.getValidation('label-external-reference').validators));
|
||||||
} else if (keyField == 'referenceTypeId') {
|
} else if (keyField == 'referenceTypeId') {
|
||||||
if (formGroup.get('category').value == DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('referenceTypeId').validators]);
|
if (formGroup.get('category').value == DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('referenceTypeId').validators]);
|
||||||
else control?.addValidators([...context.getValidation('referenceTypeId').validators]);
|
else control?.addValidators([...context.getValidation('referenceTypeId').validators]);
|
||||||
|
|
Loading…
Reference in New Issue