dmp fixes

This commit is contained in:
amentis 2024-03-04 12:42:14 +02:00
parent b84cd93ce6
commit 5fc7241dc2
12 changed files with 27 additions and 10 deletions

View File

@ -10,7 +10,7 @@ public abstract class DatabaseEnumConverter<EnumType extends DatabaseEnum<T>, T>
@Override
public T convertToDatabaseColumn(EnumType value) {
if (value == null) throw new IllegalArgumentException("value");
if (value == null) throw new IllegalArgumentException("Value could not be null for: " + this.getClass().getSimpleName());
return value.getValue();
}

View File

@ -29,7 +29,7 @@ public interface DmpService {
Dmp createNewVersion(NewVersionDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, IOException, TransformerException;
Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException;
Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException;
List<DmpUser> assignUsers(UUID dmp, List<DmpUserPersist> model, FieldSet fields) throws InvalidApplicationException, IOException;
Dmp removeUser(DmpUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException;

View File

@ -291,6 +291,9 @@ public class DmpServiceImpl implements DmpService {
newDmp.setStatus(DmpStatus.Draft);
newDmp.setProperties(oldDmpEntity.getProperties());
newDmp.setBlueprintId(model.getBlueprintId());
newDmp.setCreatorId(this.userScope.getUserId());
this.entityManager.persist(newDmp);
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class)
.dmpIds(model.getId())
@ -348,8 +351,6 @@ public class DmpServiceImpl implements DmpService {
this.descriptionService.clone(newDmp.getId(), descriptionId);
}
this.entityManager.persist(newDmp);
oldDmpEntity.setVersionStatus(DmpVersionStatus.Previous);
this.entityManager.merge(oldDmpEntity);
@ -364,7 +365,7 @@ public class DmpServiceImpl implements DmpService {
}
@Override
public Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException {
public Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException {
this.authorizationService.authorizeForce(Permission.CloneDmp);
DmpEntity existingDmpEntity = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(model.getId()).firstAs(fields);
@ -378,12 +379,17 @@ public class DmpServiceImpl implements DmpService {
newDmp.setUpdatedAt(Instant.now());
newDmp.setGroupId(UUID.randomUUID());
newDmp.setVersion((short) 1);
newDmp.setVersionStatus(DmpVersionStatus.Current);
newDmp.setDescription(model.getDescription());
newDmp.setLabel(model.getLabel());
newDmp.setLanguage(existingDmpEntity.getLanguage());
newDmp.setStatus(DmpStatus.Draft);
newDmp.setProperties(existingDmpEntity.getProperties());
newDmp.setBlueprintId(existingDmpEntity.getBlueprintId());
newDmp.setAccessType(existingDmpEntity.getAccessType());
newDmp.setCreatorId(this.userScope.getUserId());
this.entityManager.persist(newDmp);
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class)
.dmpIds(model.getId())

View File

@ -152,7 +152,7 @@ public class DmpController {
@PostMapping("clone")
@Transactional
@ValidationFilterAnnotation(validator = CloneDmpPersist.CloneDmpPersistValidator.ValidatorName, argumentName = "model")
public Dmp buildClone(@RequestBody CloneDmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException {
public Dmp buildClone(@RequestBody CloneDmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException, InvalidApplicationException {
logger.debug(new MapLogEntry("clone" + Dmp.class.getSimpleName()).And("model", model).And("fields", fieldSet));
this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null);

View File

@ -385,7 +385,7 @@ permissions:
allowAuthenticated: false
InviteDmpUsers:
roles:
- User
- Admin
claims: [ ]
clients: [ ]
allowAnonymous: false

View File

@ -127,6 +127,7 @@ export interface NewVersionDmpPersist {
description: String;
blueprintId: Guid;
descriptions: Guid[];
hash?: string;
}
export interface DmpUserPersist {

View File

@ -36,6 +36,7 @@ export class DmpEditorResolver extends BaseEditorResolver {
nameof<Dmp>(x => x.version),
nameof<Dmp>(x => x.updatedAt),
nameof<Dmp>(x => x.publicAfter),
nameof<Dmp>(x => x.hash),
[nameof<Dmp>(x => x.properties), nameof<DmpProperties>(x => x.dmpBlueprintValues), nameof<DmpBlueprintValue>(x => x.fieldId)].join('.'),
[nameof<Dmp>(x => x.properties), nameof<DmpProperties>(x => x.dmpBlueprintValues), nameof<DmpBlueprintValue>(x => x.fieldValue)].join('.'),

View File

@ -167,6 +167,8 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr
nameof<Dmp>(x => x.version),
nameof<Dmp>(x => x.groupId),
nameof<Dmp>(x => x.updatedAt),
nameof<Dmp>(x => x.hash),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.label)].join('.'),

View File

@ -28,7 +28,7 @@
<a class="d-flex justify-content-center pb-3 show-more" *ngIf="dmp.descriptions?.length > 3" [routerLink]="isPublic ? ['/explore-plans/overview/public/' + dmp.id] : ['/plans/overview/' + dmp.id]"><u>{{'GENERAL.ACTIONS.SHOW-MORE' | translate}}</u></a>
</a>
<div class="dmp-card-actions">
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="canExportDmp(dmp)" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isDraftDmp(dmp)" [routerLink]="['/plans/edit/' + dmp.id]" target="_blank"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="canInviteDmpUsers(dmp)" (click)="inviteToDmp()"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="canCloneDmp(dmp)" (click)="cloneClicked()"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>

View File

@ -11,6 +11,7 @@ export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist {
description: String;
blueprintId: Guid;
descriptions: Guid[] = [];
hash?: string;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -24,6 +25,7 @@ export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist {
this.description = item.description;
this.blueprintId = item.blueprint.id;
if (item.descriptions) { this.descriptions = item.descriptions.map(x => x.id); }
this.hash= item.hash;
}
return this;
}
@ -37,6 +39,7 @@ export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist {
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
blueprintId: [{ value: this.blueprintId, disabled: disabled }, context.getValidation('blueprintId').validators],
descriptions: [{ value: this.descriptions, disabled: disabled }, context.getValidation('descriptions').validators],
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
});
}
@ -48,6 +51,8 @@ export class DmpNewVersionDialogEditorModel implements NewVersionDmpPersist {
baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
baseValidationArray.push({ key: 'blueprintId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'blueprintId')] });
baseValidationArray.push({ key: 'descriptions', validators: [BackendErrorValidator(this.validationErrorModel, 'descriptions')] });
baseValidationArray.push({ key: 'hash', validators: [] });
baseContext.validation = baseValidationArray;
return baseContext;
}

View File

@ -151,7 +151,7 @@
</button>
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-OVERVIEW.ACTIONS.REVERSE' | translate }}</p>
</div>
<div class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center">
<div *ngIf="canExportDmp()" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center">
<button mat-mini-fab class="frame-btn" [matMenuTriggerFor]="exportMenu">
<mat-icon class="mat-mini-fab-icon">open_in_new</mat-icon>
</button>
@ -193,7 +193,7 @@
<button *ngIf="isDmpOwner(dmp) && dmp.status === dmpStatusEnum.Draft && dmpUser.role != dmpUserRoleEnum.Owner" (click)="removeUserFromDmp(dmpUser)" class="remove-btn">{{ 'DMP-OVERVIEW.ACTIONS.REMOVE-AUTHOR' | translate}}</button>
</div>
</div>
<div *ngIf="isDmpOwner(dmp)" class="row mt-3 mb-3 d-flex align-items-center justify-content-center">
<div *ngIf="canInviteDmpUsers()" class="row mt-3 mb-3 d-flex align-items-center justify-content-center">
<button mat-raised-button class="invite-btn" (click)="openShareDialog(dmp.id,dmp.label)">
<mat-icon>group_add</mat-icon>
{{'DMP-OVERVIEW.ACTIONS.INVITE-SHORT' | translate}}

View File

@ -779,6 +779,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
[nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition)].join('.'),
[nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.blueprint), nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
nameof<Dmp>(x => x.hash),
]
}
}