add remove backend validators, fix public dmp/descriptions

This commit is contained in:
amentis 2024-03-12 14:07:47 +02:00
parent 2cbb6297cb
commit b8f14e957e
25 changed files with 124 additions and 43 deletions

View File

@ -37,6 +37,15 @@ public class PublicDmp {
public static final String _publishedAt = "publishedAt";
private DmpStatus status;
public static final String _status = "status";
private UUID groupId;
public static final String _groupId = "groupId";
private DmpAccessType accessType;
public static final String _accessType = "accessType";
private List<PublicDmpUser> dmpUsers;
public static final String _dmpUsers = "dmpUsers";
@ -104,6 +113,30 @@ public class PublicDmp {
this.publishedAt = publishedAt;
}
public DmpStatus getStatus() {
return status;
}
public void setStatus(DmpStatus status) {
this.status = status;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public DmpAccessType getAccessType() {
return accessType;
}
public void setAccessType(DmpAccessType accessType) {
this.accessType = accessType;
}
public List<PublicDmpUser> getDmpUsers() {
return dmpUsers;
}

View File

@ -1,5 +1,7 @@
package eu.eudat.model;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant;
import java.util.UUID;
@ -14,6 +16,9 @@ public class PublicDmpReference {
private PublicReference reference;
public static final String _reference = "reference";
private IsActive isActive;
public static final String _isActive = "isActive";
public UUID getId() {
return id;
}
@ -37,4 +42,12 @@ public class PublicDmpReference {
public void setReference(PublicReference reference) {
this.reference = reference;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
}

View File

@ -74,6 +74,10 @@ public class PublicDmpBuilder extends BaseBuilder<PublicDmp, DmpEntity> {
if (fields.hasField(this.asIndexer(PublicDmp._description))) m.setDescription(d.getDescription());
if (fields.hasField(this.asIndexer(PublicDmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
if (fields.hasField(this.asIndexer(PublicDmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if (fields.hasField(this.asIndexer(PublicDmp._accessType))) m.setAccessType(d.getAccessType());
if (fields.hasField(this.asIndexer(PublicDmp._status))) m.setStatus(d.getStatus());
if (fields.hasField(this.asIndexer(PublicDmp._groupId))) m.setGroupId(d.getGroupId());
if (fields.hasField(this.asIndexer(PublicDmp._accessType))) m.setAccessType(d.getAccessType());
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
@ -109,7 +113,7 @@ public class PublicDmpBuilder extends BaseBuilder<PublicDmp, DmpEntity> {
this.logger.debug("checking related - {}", PublicDmpUser.class.getSimpleName());
Map<UUID, List<PublicDmpUser>> itemMap = null;
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpUser._user, PublicDmp._id));
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpUser._dmp, PublicDmp._id));
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(PublicDmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());

View File

@ -66,6 +66,7 @@ public class PublicDmpReferenceBuilder extends BaseBuilder<PublicDmpReference, D
for (DmpReferenceEntity d : data) {
PublicDmpReference m = new PublicDmpReference();
if (fields.hasField(this.asIndexer(PublicDmpReference._id))) m.setId(d.getId());
if (fields.hasField(this.asIndexer(PublicDmpReference._isActive))) m.setIsActive(d.getIsActive());
if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId()));
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
models.add(m);

View File

@ -52,7 +52,8 @@ public class QueryUtilsServiceImpl implements QueryUtilsService {
.filterFunc((subQueryRoot, cb) -> cb.or(
usePublic ? cb.and(
cb.equal(subQueryRoot.get(DescriptionEntity._status), DescriptionStatus.Finalized),
cb.equal(subQueryRoot.get(DescriptionEntity._isActive), IsActive.Active)
cb.equal(subQueryRoot.get(DescriptionEntity._isActive), IsActive.Active),
cb.in(subQueryRoot.get(DescriptionEntity._dmpId)).value(this.buildDmpAuthZSubQuery(query, criteriaBuilder, userId, usePublic))
): cb.or(), //Creates a false query
userId != null ? cb.equal(subQueryRoot.get(DescriptionEntity._createdById), userId) : cb.or() //Creates a false query
)

View File

@ -572,6 +572,7 @@ public class DmpServiceImpl implements DmpService {
}
data.setLabel(model.getLabel());
data.setLanguage(model.getLanguage());
data.setProperties(this.jsonHandlingService.toJson(this.buildDmpPropertiesEntity(model.getProperties())));
data.setDescription(model.getDescription());
data.setAccessType(model.getAccessType());

View File

@ -11,6 +11,7 @@ import { EntityDoi } from '../entity-doi/entity-doi';
import { ReferencePersist } from '../reference/reference';
import { DmpAssociatedUser, User } from "../user/user";
import { DmpReference } from './dmp-reference';
import { IsActive } from '@app/core/common/enum/is-active.enum';
export interface Dmp extends BaseEntity {
label?: string;
@ -157,6 +158,9 @@ export interface PublicDmp extends BaseEntity {
description?: string;
finalizedAt?: Date;
publishedAt?: Date;
status?: DmpStatus;
groupId?: String;
accessType: DmpAccessType;
dmpReferences: PublicDmpReference[];
dmpUsers: PublicDmpUser[];
descriptions: PublicDescription[];
@ -166,6 +170,7 @@ export interface PublicDmpReference {
id: Guid;
dmp: PublicDmp;
reference: PublicReference;
isActive?: IsActive;
}
export interface PublicReference {

View File

@ -7,6 +7,7 @@ import { Guid } from '@common/types/guid';
import * as FileSaver from 'file-saver';
import { MatomoService } from '../matomo/matomo-service';
import { FileUtils } from '../utilities/file-utils.service';
import { AuthService } from '../auth/auth.service';
@Injectable()
export class FileTransformerService extends BaseService {
@ -14,7 +15,8 @@ export class FileTransformerService extends BaseService {
constructor(
private fileTransformerHttpService: FileTransformerHttpService,
private matomoService: MatomoService,
private fileUtils: FileUtils
private fileUtils: FileUtils,
private authentication: AuthService,
) { super(); }
private _initialized: boolean = false;
@ -22,6 +24,9 @@ export class FileTransformerService extends BaseService {
private _availableFormats: FileFormat[] = [];
get availableFormats(): FileFormat[] {
if (!this.authentication.currentAccountIsAuthenticated()){
return;
}
// console.log('availableFormats');
if (!this._initialized && !this._loading) this.init();
return this._availableFormats;

View File

@ -4,12 +4,12 @@
<div class="col-12 d-flex" id="title-column">
<div style="padding-left: 2em;">
<h3 *ngIf="isNew && !isClone && !isNewVersion">{{'DESCRIPTION-TEMPLATE-EDITOR.TITLE.NEW-PROFILE' | translate}}</h3>
<h3 *ngIf="isNew && isClone">
<h3 *ngIf="isNew == true && isClone == false && isNewVersion == false">{{'DESCRIPTION-TEMPLATE-EDITOR.TITLE.NEW-PROFILE' | translate}}</h3>
<h3 *ngIf="isNew == false && isClone == true && isNewVersion == false">
<span *ngIf="isClone">{{'DESCRIPTION-TEMPLATE-EDITOR.TITLE.NEW-PROFILE-CLONE' | translate}}</span>
{{formGroup.get('label').value}}
</h3>
<h3 *ngIf="isNew && isNewVersion">
<h3 *ngIf="isNew == false && isClone == false && isNewVersion == true">
<span *ngIf="isNewVersion">{{'DESCRIPTION-TEMPLATE-EDITOR.TITLE.NEW-PROFILE-VERSION' | translate}}</span>
{{formGroup.get('label').value}}
</h3>
@ -119,7 +119,7 @@
<td>{{usersMap.get(user?.get('userId')?.value)?.name}}</td>
<td>{{enumUtils.toUserDescriptionTemplateRoleString(user?.get('role')?.value)}}</td>
<td>
<button mat-button class="delete-btn" (click)="verifyAndRemoveUser(user)" [matTooltip]="'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-REMOVE-USER'| translate"><mat-icon>person_remove</mat-icon></button>
<button mat-button class="delete-btn" (click)="verifyAndRemoveUser(i)" [matTooltip]="'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-REMOVE-USER'| translate"><mat-icon>person_remove</mat-icon></button>
</td>
</tr>
<tr *ngIf="formGroup.get('users')?.controls?.length === 0">

View File

@ -135,6 +135,22 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
ngOnInit(): void {
this.matomoService.trackPageView('Admin: DMP Blueprints');
super.ngOnInit();
this.initModelFlags(this.route.snapshot.data['action']);
}
private initModelFlags(action: string): void {
if (action == 'clone') {
this.isNew = false;
this.isClone = true;
this.isNewVersion = false;
} else if (action == 'new-version') {
this.isNew = false;
this.isClone = false;
this.isNewVersion = true;
} else {
this.isClone = false;
this.isNewVersion = false;
}
}
getItem(itemId: Guid, successFunction: (item: DescriptionTemplate) => void) {
@ -200,7 +216,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
}
persistEntity(onSuccess?: (response) => void): void {
if (!this.isClone && !this.isNewVersion){
if (this.isNewVersion == false){
const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist;
this.descriptionTemplateService.persist(formData)
@ -208,7 +224,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
error => this.onCallbackError(error)
);
} else if (this.isNewVersion && !this.isNew && !this.isClone) {
} else if (this.isNewVersion== true && this.isNew == false && this.isClone == false) {
const formData = this.formService.getValue(this.formGroup.value) as NewVersionDescriptionTemplatePersist;
this.descriptionTemplateService.newVersion(formData)

View File

@ -135,6 +135,7 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor<Descripti
}
formSubmit(): void {
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) {
return;

View File

@ -2,8 +2,8 @@
<div class="container-fluid dmp-blueprint-editor">
<div class="row align-items-center mb-4" *ngIf="formGroup">
<div class="col-auto">
<h3 *ngIf="!isFinalized && !isNewVersion">{{'DMP-BLUEPRINT-EDITOR.TITLE.NEW' | translate}}</h3>
<h3 *ngIf="isFinalized && !isNewVersion">{{formGroup.get('label').value}}</h3>
<h3 *ngIf="!isFinalized && !isNewVersion && isNew">{{'DMP-BLUEPRINT-EDITOR.TITLE.NEW' | translate}}</h3>
<h3 *ngIf="!isClone && !isNewVersion && !isNew">{{formGroup.get('label').value}}</h3>
<h3 *ngIf="isClone">
<span>{{'DMP-BLUEPRINT-EDITOR.TITLE.CLONE' | translate}}</span>
{{formGroup.get('label').value}}

View File

@ -153,7 +153,6 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
this.isClone = false;
this.isNewVersion = true;
} else {
this.isNew = true;
this.isClone = false;
this.isNewVersion = false;
}
@ -207,7 +206,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
}
persistEntity(onSuccess?: (response) => void): void {
if (this.isNew && !this.isClone && !this.isNewVersion) {
if ( this.isNewVersion == false) {
const formData = this.formService.getValue(this.formGroup.value) as DmpBlueprintPersist;
this.dmpBlueprintService.persist(formData)
@ -215,7 +214,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
error => this.onCallbackError(error)
);
} else if (this.isNewVersion && !this.isNew && !this.isClone) {
} else if (this.isNewVersion == true && this.isNew == false && this.isClone == false) {
const formData = this.formService.getValue(this.formGroup.value) as NewVersionDmpBlueprintPersist;
this.dmpBlueprintService.newVersion(formData)

View File

@ -155,6 +155,7 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
}
formSubmit(): void {
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) {
return;

View File

@ -189,11 +189,11 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
}
formSubmit(): void {
console.log(this.formGroup);
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.touchAllFormFields(this.formGroup);
// if (!this.isFormValid()) {
// return;
// }
if (!this.isFormValid()) {
return;
}
this.persistEntity();
}

View File

@ -141,16 +141,11 @@ export class PrefillingSourceEditorComponent extends BaseEditor<PrefillingSource
}
formSubmit(): void {
PrefillingSourceEditorModel.reApplyDefinitionValidators(
{
formGroup: this.formGroup,
validationErrorModel: this.editorModel.validationErrorModel
}
)
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.touchAllFormFields(this.formGroup);
// if (!this.isFormValid()) {
// return;
// }
if (!this.isFormValid()) {
return;
}
this.persistEntity();
}

View File

@ -154,10 +154,11 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
}
formSubmit(): void {
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.touchAllFormFields(this.formGroup);
// if (!this.isFormValid()) {
// return;
// }
if (!this.isFormValid()) {
return;
}
this.persistEntity();
}

View File

@ -151,10 +151,11 @@ export class TenantEditorComponent extends BaseEditor<TenantEditorModel, Tenant>
}
formSubmit(): void {
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.touchAllFormFields(this.formGroup);
// if (!this.isFormValid()) {
// return;
// }
if (!this.isFormValid()) {
return;
}
this.persistEntity();
}

View File

@ -4,10 +4,10 @@
<span class="d-flex align-items-center">{{'DMP-LISTING.SORT-BY' | translate}}:</span>
<mat-form-field appearance="outline" class="sort-form col-auto">
<mat-select placeholder="{{'CRITERIA.LIKE'| translate}}" [formControl]="formGroup.get('order')">
<mat-option *ngIf="!publicMode" [value]="order.MODIFIED">{{enumUtils.toRecentActivityOrderString(order.MODIFIED)}}</mat-option>
<mat-option *ngIf="publicMode" [value]="order.DATASETPUBLISHED">{{enumUtils.toRecentActivityOrderString(order.DATASETPUBLISHED)}}</mat-option>
<mat-option [value]="order.LABEL">{{enumUtils.toRecentActivityOrderString(order.LABEL)}}</mat-option>
<mat-option *ngIf="!publicMode" [value]="order.STATUS">{{enumUtils.toRecentActivityOrderString(order.STATUS)}}</mat-option>
<mat-option *ngIf="!publicMode" [value]="order.UpdatedAt">{{enumUtils.toRecentActivityOrderString(order.UpdatedAt)}}</mat-option>
<!-- <mat-option *ngIf="publicMode" [value]="order.DATASETPUBLISHED">{{enumUtils.toRecentActivityOrderString(order.DATASETPUBLISHED)}}</mat-option> -->
<mat-option [value]="order.LABEL">{{enumUtils.toRecentActivityOrderString(order.Label)}}</mat-option>
<mat-option *ngIf="!publicMode" [value]="order.Status">{{enumUtils.toRecentActivityOrderString(order.Status)}}</mat-option>
<!-- <mat-option [value]="order.CREATED">{{enumUtils.toRecentActivityOrderString(order.CREATED)}}</mat-option> -->
</mat-select>
</mat-form-field>

View File

@ -155,9 +155,9 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
const dmpSectionId = route.paramMap.get('dmpSectionId');
const copyDmpId = route.paramMap.get('copyDmpId');
// const cloneid = route.paramMap.get('cloneid');
if (id != null) {
if (id != null && copyDmpId == null && dmpSectionId == null) {
return this.descriptionService.getSingle(Guid.parse(id), fields)
} else if (dmpId != null && dmpSectionId != null) {
} else if (dmpId != null && dmpSectionId != null && copyDmpId == null) {
return this.dmpService.getSingle(Guid.parse(dmpId), DescriptionEditorResolver.dmpLookupFields()).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed), map(dmp => {
const description: Description = {};

View File

@ -24,7 +24,7 @@
</div>
</a>
<div class="description-card-actions">
<a class="col-auto border-right pointer" *ngIf="fileTransformerService.availableFormats.length > 0" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DESCRIPTION-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="fileTransformerService.availableFormats && fileTransformerService.availableFormats.length > 0" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DESCRIPTION-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isUserOwner" (click)="openShareDialog(description.dmp.id, description.dmp.label)"><span class="material-icons icon-align pr-2">group_add</span>{{'DESCRIPTION-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="copyToDmp(description)"><span class="material-icons icon-align pr-2">file_copy</span>{{'DESCRIPTION-LISTING.ACTIONS.COPY-DESCRIPTION' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isAuthenticated() && isUserDescriptionRelated()" (click)="deleteClicked(description.id)"><span class="material-icons icon-align pr-2">delete</span>{{ 'DESCRIPTION-LISTING.ACTIONS.DELETE' | translate }}</a>

View File

@ -91,7 +91,7 @@
</div>
</div>
<div class="col-md-4 col-lg-4 p-0">
<div class="frame mb-3 pt-4 pl-3 pr-5 pb-1">
<div class="frame mb-3 pt-4 pl-3 pr-5 pb-1" *ngIf="isAuthenticated()">
<div *ngIf="isDraftDescription(description) && !lockStatus">
<div class="row ml-0 mr-0 pl-4 d-flex align-items-center" (click)="finalize(description)">
<button mat-mini-fab class="finalize-btn">

View File

@ -132,7 +132,7 @@
</div>
</div>
</div>
<div class="frame mb-3 pt-4 pl-3 pr-5 pb-1">
<div class="frame mb-3 pt-4 pl-3 pr-5 pb-1" *ngIf="isAuthenticated()">
<div *ngIf="isDraftDmp() && canFinalizeDmp() && !lockStatus">
<div class="row ml-0 mr-0 pl-4 d-flex align-items-center" (click)="finalize(dmp)">
<button mat-mini-fab class="finalize-btn">

View File

@ -166,13 +166,15 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
});
}
});
this.depositRepositoriesService.getAvailableRepos()
if(this.isAuthenticated()){
this.depositRepositoriesService.getAvailableRepos()
.pipe(takeUntil(this._destroyed))
.subscribe(
repos => {
this.depositRepos = repos;
},
error => this.depositRepos = []);
}
}
onFetchingDeletedCallbackError(redirectRoot: string) {

View File

@ -675,6 +675,8 @@
"VALIDATE": "Validate",
"PREVIEW-AND-FINALIZE": "Preview & Finalize",
"BACK-TO-TOP": "Back to top",
"PREVIOUS": "Previous",
"NEXT": "Next",
"FIELD": {
"MAKE-IT-REQUIRED": "Make input required",
"ADD-VISIBILITY-RULE": "Make Conditional Question",