make description reference persist and ui fixes

This commit is contained in:
amentis 2024-03-26 18:44:59 +02:00
parent 8206602387
commit 7ec9c0b3c6
19 changed files with 106 additions and 26 deletions

View File

@ -134,4 +134,14 @@ public class ErrorThesaurusProperties {
public void setDmpBlueprintHasNoDescriptionTemplates(ErrorDescription dmpBlueprintHasNoDescriptionTemplates) { public void setDmpBlueprintHasNoDescriptionTemplates(ErrorDescription dmpBlueprintHasNoDescriptionTemplates) {
this.dmpBlueprintHasNoDescriptionTemplates = dmpBlueprintHasNoDescriptionTemplates; this.dmpBlueprintHasNoDescriptionTemplates = dmpBlueprintHasNoDescriptionTemplates;
} }
private ErrorDescription dmpDescriptionTemplateCanNotRemove;
public ErrorDescription getDmpDescriptionTemplateCanNotRemove() {
return dmpDescriptionTemplateCanNotRemove;
}
public void setDmpDescriptionTemplateCanNotRemove(ErrorDescription dmpDescriptionTemplateCanNotRemove) {
this.dmpDescriptionTemplateCanNotRemove = dmpDescriptionTemplateCanNotRemove;
}
} }

View File

@ -36,7 +36,7 @@ public class DescriptionReferenceDataCensor extends BaseCensor {
if (fields == null || fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorizeForce(Permission.BrowseDescriptionReference); this.authService.authorizeForce(Permission.BrowseDescriptionReference, Permission.DeferredAffiliation);
} }
} }

View File

@ -203,12 +203,12 @@ public class DescriptionPersist {
this.spec() this.spec()
.iff(() -> item.getStatus() == DescriptionStatus.Finalized) .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getProperties())) .must(() -> !this.isNull(item.getProperties()))
.failOn(DescriptionPersist._properties).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._properties}, LocaleContextHolder.getLocale())), .failOn(DescriptionPersist._properties).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._properties}, LocaleContextHolder.getLocale()))
this.refSpec() // this.refSpec()
.iff(() -> !this.isNull(item.getProperties())) // .iff(() -> !this.isNull(item.getProperties()))
.on(DescriptionPersist._properties) // .on(DescriptionPersist._properties)
.over(item.getProperties()) // .over(item.getProperties())
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition)) // .using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition))
// this.navSpec() // this.navSpec()
// .iff(() -> !this.isNull(item.getTags())) // .iff(() -> !this.isNull(item.getTags()))
// .on(DescriptionPersist._tags) // .on(DescriptionPersist._tags)

View File

@ -32,6 +32,9 @@ public class FieldPersist {
private List<ReferencePersist> references; private List<ReferencePersist> references;
public static final String _references = "references"; public static final String _references = "references";
private ReferencePersist reference;
public static final String _reference = "reference";
private ExternalIdentifierPersist externalIdentifier; private ExternalIdentifierPersist externalIdentifier;
public static final String _externalIdentifier = "externalIdentifier"; public static final String _externalIdentifier = "externalIdentifier";
@ -67,6 +70,14 @@ public class FieldPersist {
this.references = references; this.references = references;
} }
public ReferencePersist getReference() {
return reference;
}
public void setReference(ReferencePersist reference) {
this.reference = reference;
}
public ExternalIdentifierPersist getExternalIdentifier() { public ExternalIdentifierPersist getExternalIdentifier() {
return externalIdentifier; return externalIdentifier;
} }
@ -138,6 +149,11 @@ public class FieldPersist {
.on(FieldPersist._references) .on(FieldPersist._references)
.over(item.getReferences()) .over(item.getReferences())
.using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferencePersistValidator.class)), .using((itm) -> this.validatorFactory.validator(ReferencePersist.ReferencePersistValidator.class)),
this.refSpec()
.iff(() -> FieldType.isReferenceType(fieldType) && !this.isNull(item.getReference()))
.on(FieldPersist._reference)
.over(item.getReference())
.using(() -> this.validatorFactory.validator(ReferencePersist.ReferencePersistValidator.class)),
this.refSpec() this.refSpec()
.iff(() -> FieldType.isExternalIdentifierType(fieldType) && !this.isNull(item.getExternalIdentifier())) .iff(() -> FieldType.isExternalIdentifierType(fieldType) && !this.isNull(item.getExternalIdentifier()))
.on(FieldPersist._externalIdentifier) .on(FieldPersist._externalIdentifier)

View File

@ -218,6 +218,7 @@ public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEnt
else if (item.prefix(DescriptionReference._reference)) return DescriptionReferenceEntity._referenceId; else if (item.prefix(DescriptionReference._reference)) return DescriptionReferenceEntity._referenceId;
else if (item.match(DescriptionReference._createdAt)) return DescriptionReferenceEntity._createdAt; else if (item.match(DescriptionReference._createdAt)) return DescriptionReferenceEntity._createdAt;
else if (item.match(DescriptionReference._updatedAt)) return DescriptionReferenceEntity._updatedAt; else if (item.match(DescriptionReference._updatedAt)) return DescriptionReferenceEntity._updatedAt;
else if (item.prefix(DescriptionReference._data)) return DescriptionReferenceEntity._data;
else if (item.match(DescriptionReference._hash)) return DescriptionReferenceEntity._updatedAt; else if (item.match(DescriptionReference._hash)) return DescriptionReferenceEntity._updatedAt;
else if (item.match(DescriptionReference._isActive)) return DescriptionReferenceEntity._isActive; else if (item.match(DescriptionReference._isActive)) return DescriptionReferenceEntity._isActive;
else return null; else return null;
@ -231,6 +232,7 @@ public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEnt
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class)); item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class));
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class));
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._updatedAt, Instant.class)); item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._updatedAt, Instant.class));
item.setData(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._data, String.class));
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._isActive, IsActive.class)); item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._isActive, IsActive.class));
return item; return item;
} }

View File

@ -502,7 +502,7 @@ public class DescriptionServiceImpl implements DescriptionService {
List<DescriptionReferencePersist> descriptionReferencePersists = new ArrayList<>(); List<DescriptionReferencePersist> descriptionReferencePersists = new ArrayList<>();
if (persist.getFieldSets() != null && !persist.getFieldSets().isEmpty()){ if (persist.getFieldSets() != null && !persist.getFieldSets().isEmpty()){
for (PropertyDefinitionFieldSetPersist propertyDefinitionFieldSetPersist: persist.getFieldSets().values()) { for (PropertyDefinitionFieldSetPersist propertyDefinitionFieldSetPersist: persist.getFieldSets().values()) {
if (this.conventionService.isListNullOrEmpty( propertyDefinitionFieldSetPersist.getItems())) { if (!this.conventionService.isListNullOrEmpty( propertyDefinitionFieldSetPersist.getItems())) {
for (PropertyDefinitionFieldSetItemPersist definitionFieldSetItemPersist : propertyDefinitionFieldSetPersist.getItems()) { for (PropertyDefinitionFieldSetItemPersist definitionFieldSetItemPersist : propertyDefinitionFieldSetPersist.getItems()) {
if (definitionFieldSetItemPersist.getFields() != null && !definitionFieldSetItemPersist.getFields().isEmpty()) { if (definitionFieldSetItemPersist.getFields() != null && !definitionFieldSetItemPersist.getFields().isEmpty()) {
for (String key : definitionFieldSetItemPersist.getFields().keySet()) { for (String key : definitionFieldSetItemPersist.getFields().keySet()) {
@ -518,7 +518,8 @@ public class DescriptionServiceImpl implements DescriptionService {
} }
private void BuildDescriptionReferencePersist(String fieldId, FieldPersist fieldPersist, List<DescriptionReferencePersist> descriptionReferencePersists) { private void BuildDescriptionReferencePersist(String fieldId, FieldPersist fieldPersist, List<DescriptionReferencePersist> descriptionReferencePersists) {
if (this.conventionService.isListNullOrEmpty(fieldPersist.getReferences())) { if (fieldPersist.getReference() != null) fieldPersist.getReferences().add(fieldPersist.getReference());
if (!this.conventionService.isListNullOrEmpty(fieldPersist.getReferences())) {
for (ReferencePersist referencePersist : fieldPersist.getReferences()) { for (ReferencePersist referencePersist : fieldPersist.getReferences()) {
DescriptionReferencePersist descriptionReferencePersist = new DescriptionReferencePersist(); DescriptionReferencePersist descriptionReferencePersist = new DescriptionReferencePersist();
descriptionReferencePersist.setData(new DescriptionReferenceDataPersist()); descriptionReferencePersist.setData(new DescriptionReferenceDataPersist());

View File

@ -188,6 +188,8 @@ public class DmpServiceImpl implements DmpService {
this.patchAndSaveReferences(this.buildDmpReferencePersists(model.getProperties()), data.getId(), definition); this.patchAndSaveReferences(this.buildDmpReferencePersists(model.getProperties()), data.getId(), definition);
if (isUpdate) this.checkIfDescriptionTemplateIsUse(model.getDescriptionTemplates(), model.getId());
this.patchAndSaveTemplates(data.getId(), model.getDescriptionTemplates()); this.patchAndSaveTemplates(data.getId(), model.getDescriptionTemplates());
if (!isUpdate && userScope.isSet()) { if (!isUpdate && userScope.isSet()) {
@ -210,6 +212,17 @@ public class DmpServiceImpl implements DmpService {
return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data); return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data);
} }
private void checkIfDescriptionTemplateIsUse (List<DmpDescriptionTemplatePersist> descriptionTemplates, UUID id){
List<DmpDescriptionTemplateEntity> existingDmpDescriptionTemplates = this.queryFactory.query(DmpDescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(id).isActive(IsActive.Active).collect();
List<DmpDescriptionTemplateEntity> removedDescriptionTemplates = existingDmpDescriptionTemplates.stream().filter(x -> descriptionTemplates.stream().noneMatch(y -> y.getDescriptionTemplateGroupId().equals(x.getDescriptionTemplateGroupId()))).collect(Collectors.toList());
DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active).dmpIds(id).descriptionTemplateGroupIds(removedDescriptionTemplates.stream().map(x -> x.getDescriptionTemplateGroupId()).collect(Collectors.toList()));
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpDescriptionTemplateSubQuery(dmpDescriptionTemplateQuery).isActive(IsActive.Active);
if (query != null && query.count() > 0) throw new MyValidationException(this.errors.getDmpDescriptionTemplateCanNotRemove().getCode(), this.errors.getDmpDescriptionTemplateCanNotRemove().getMessage());
}
private DmpUserPersist createOwnerPersist() { private DmpUserPersist createOwnerPersist() {
DmpUserPersist persist = new DmpUserPersist(); DmpUserPersist persist = new DmpUserPersist();
persist.setRole(DmpUserRole.Owner); persist.setRole(DmpUserRole.Owner);

View File

@ -43,6 +43,7 @@ public class Field {
tempTextListValue = persist.getTextListValue(); tempTextListValue = persist.getTextListValue();
if (persist.getExternalIdentifier() != null) this.externalIdentifier = new ExternalIdentifier(persist.getExternalIdentifier()); if (persist.getExternalIdentifier() != null) this.externalIdentifier = new ExternalIdentifier(persist.getExternalIdentifier());
else this.externalIdentifier = null; else this.externalIdentifier = null;
if (persist.getReference() != null) persist.getReferences().add(persist.getReference());
if (persist.getReferences() != null && !persist.getReferences().isEmpty()){ if (persist.getReferences() != null && !persist.getReferences().isEmpty()){
tempTextListValue = persist.getReferences().stream().filter(x-> x.getId() != null).map(x-> x.getId().toString()).toList(); tempTextListValue = persist.getReferences().stream().filter(x-> x.getId() != null).map(x-> x.getId().toString()).toList();
} }

View File

@ -214,7 +214,7 @@ public class LockController {
@DeleteMapping("{id}/{target}") @DeleteMapping("{id}/{target}")
@Transactional @Transactional
public void delete(@PathVariable("id") UUID id, @PathVariable("id") UUID target) throws MyForbiddenException, InvalidApplicationException { public void delete(@PathVariable("id") UUID id, @PathVariable("target") 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, target); this.lockService.deleteAndSave(id, target);

View File

@ -53,3 +53,6 @@ error-thesaurus:
dmp-blueprint-new-version-conflict: dmp-blueprint-new-version-conflict:
code: 121 code: 121
message: version to update not the latest message: version to update not the latest
dmp-description-template-can-not-remove:
code: 122
message: Can not remove description template that is already in use.

View File

@ -43,8 +43,8 @@ export class LockService {
catchError((error: any) => throwError(error))); catchError((error: any) => throwError(error)));
} }
delete(id: Guid): Observable<Lock> { delete(id: Guid, target: Guid): Observable<Lock> {
const url = `${this.apiBase}/${id}`; const url = `${this.apiBase}/${id}/${target}`;
return this.http return this.http
.delete<Lock>(url).pipe( .delete<Lock>(url).pipe(

View File

@ -16,6 +16,7 @@ import { nameof } from 'ts-simple-nameof';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpV2Service } from '../http/base-http-v2.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
@Injectable() @Injectable()
export class ReferenceService { export class ReferenceService {
@ -150,6 +151,7 @@ export class ReferenceService {
nameof<Reference>(x => x.hash), nameof<Reference>(x => x.hash),
nameof<Reference>(x => x.label), nameof<Reference>(x => x.label),
nameof<Reference>(x => x.type), nameof<Reference>(x => x.type),
[nameof<Reference>(x => x.type), nameof<ReferenceType>(x => x.id)].join('.'),
nameof<Reference>(x => x.description), nameof<Reference>(x => x.description),
[nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.code)].join('.'), [nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.code)].join('.'),
[nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.dataType)].join('.'), [nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.dataType)].join('.'),

View File

@ -78,7 +78,7 @@
<mat-icon>more_horiz</mat-icon> <mat-icon>more_horiz</mat-icon>
</button> </button>
<mat-menu #actionsMenu="matMenu"> <mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="deleteType(row.id)"> <button mat-menu-item (click)="deleteType(row.id, row.target)">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
{{'LOCK-LISTING.ACTIONS.DELETE' | translate}} {{'LOCK-LISTING.ACTIONS.DELETE' | translate}}
</button> </button>

View File

@ -147,7 +147,7 @@ export class LockListingComponent extends BaseListingComponent<Lock, LockLookup>
return this.lockService.query(this.lookup); return this.lockService.query(this.lookup);
} }
public deleteType(id: Guid) { public deleteType(id: Guid, target: Guid) {
if (id) { if (id) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, { const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: { data: {
@ -159,7 +159,7 @@ export class LockListingComponent extends BaseListingComponent<Lock, LockLookup>
}); });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) { if (result) {
this.lockService.delete(id).pipe(takeUntil(this._destroyed)) this.lockService.delete(id, target).pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onCallbackSuccess(),
error => this.onCallbackError(error) error => this.onCallbackError(error)

View File

@ -1,5 +1,6 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms'; import { UntypedFormGroup } from '@angular/forms';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
import { Description } from '@app/core/model/description/description'; import { Description } from '@app/core/model/description/description';
import { DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
@ -26,10 +27,10 @@ export class DescriptionBaseFieldsEditorComponent extends BaseComponent {
) { super(); } ) { super(); }
ngOnInit() { ngOnInit() {
const dmpDescriptionTemplates: DmpDescriptionTemplate[] = this.description.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.description.dmpDescriptionTemplate.sectionId); const dmpDescriptionTemplates: DmpDescriptionTemplate[] = this.description.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.description.dmpDescriptionTemplate.sectionId && x.isActive == IsActive.Active);
const currentVersionsOfDescriptionTemplates = dmpDescriptionTemplates.map(x => x.currentDescriptionTemplate); const currentVersionsOfDescriptionTemplates = dmpDescriptionTemplates.map(x => x.currentDescriptionTemplate);
//Check if the used tempalte in included in the current list. If not add it. //Check if the used tempalte in included in the current list. If not add it.
if (currentVersionsOfDescriptionTemplates.find(x => x.id == this.description?.descriptionTemplate?.id) == null) { if (this.description.descriptionTemplate && currentVersionsOfDescriptionTemplates.find(x => x.id == this.description?.descriptionTemplate?.id) == null) {
this.availableDescriptionTemplates.push(this.description.descriptionTemplate) this.availableDescriptionTemplates.push(this.description.descriptionTemplate)
} }
this.availableDescriptionTemplates.push(...currentVersionsOfDescriptionTemplates); this.availableDescriptionTemplates.push(...currentVersionsOfDescriptionTemplates);

View File

@ -414,7 +414,7 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
textValue: string; textValue: string;
textListValue: string[]; textListValue: string[];
dateValue: Date; dateValue: Date;
references: ReferencePersist[]; references: ReferencePersist[] = [];
reference: ReferencePersist; reference: ReferencePersist;
externalIdentifier?: DescriptionExternalIdentifierEditorModel = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel); externalIdentifier?: DescriptionExternalIdentifierEditorModel = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel);
@ -429,9 +429,26 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
this.textValue = item.textValue; this.textValue = item.textValue;
this.textListValue = item.textListValue; this.textListValue = item.textListValue;
this.dateValue = item.dateValue; this.dateValue = item.dateValue;
//TODO: refactor reference type
// this.references = descriptionReferences?.filter(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => x.reference);
// this.reference = descriptionReferences?.find(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active)?.reference; // this.reference = descriptionReferences?.find(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active)?.reference;
if(descriptionReferences){
descriptionReferences.forEach(descriptionReference => {
if(descriptionReference.data.fieldId == descriptionTemplateField?.id && descriptionReference.isActive == IsActive.Active){
this.references.push({
id: descriptionReference.reference.id,
label: descriptionReference.reference.label,
reference: descriptionReference.reference.reference,
source: descriptionReference.reference.source,
typeId: null,
description: descriptionReference.reference.source,
definition: descriptionReference.reference.definition,
abbreviation: descriptionReference.reference.abbreviation,
sourceType: descriptionReference.reference.sourceType
})
}
})
}
this.externalIdentifier = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel).fromModel(item.externalIdentifier); this.externalIdentifier = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel).fromModel(item.externalIdentifier);
} }
return this; return this;

View File

@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AppPermission } from '@app/core/common/enum/permission.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum';
import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateExternalDatasetData, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateReferenceTypeData, DescriptionTemplateRule, DescriptionTemplateSection, DescriptionTemplateSelectData, DescriptionTemplateSelectOption, DescriptionTemplateUploadData, DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template'; import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateExternalDatasetData, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateReferenceTypeData, DescriptionTemplateRule, DescriptionTemplateSection, DescriptionTemplateSelectData, DescriptionTemplateSelectOption, DescriptionTemplateUploadData, DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template';
import { Description, DescriptionExternalIdentifier, DescriptionField, DescriptionPropertyDefinition, DescriptionPropertyDefinitionFieldSet, DescriptionPropertyDefinitionFieldSetItem, DescriptionReference, DescriptionTag } from '@app/core/model/description/description'; import { Description, DescriptionExternalIdentifier, DescriptionField, DescriptionPropertyDefinition, DescriptionPropertyDefinitionFieldSet, DescriptionPropertyDefinitionFieldSetItem, DescriptionReference, DescriptionReferenceData, DescriptionTag } from '@app/core/model/description/description';
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp'; import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp';
import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { ReferenceType } from '@app/core/model/reference-type/reference-type';
@ -57,6 +57,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
[nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'), [nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
[nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'), [nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
[nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.isActive)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.comment)].join('.'), [nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.comment)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.ordinal)].join('.'), [nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.ordinal)].join('.'),
@ -65,14 +66,24 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.dateValue)].join('.'), [nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.dateValue)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.externalIdentifier), nameof<DescriptionExternalIdentifier>(x => x.identifier)].join('.'), [nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.externalIdentifier), nameof<DescriptionExternalIdentifier>(x => x.identifier)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.externalIdentifier), nameof<DescriptionExternalIdentifier>(x => x.type)].join('.'), [nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.externalIdentifier), nameof<DescriptionExternalIdentifier>(x => x.type)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.references), nameof<Reference>(x => x.id)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.references), nameof<Reference>(x => x.label)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.references), nameof<Reference>(x => x.type), nameof<ReferenceType>(x => x.id)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.references), nameof<Reference>(x => x.reference)].join('.'),
[nameof<Description>(x => x.properties), nameof<DescriptionPropertyDefinition>(x => x.fieldSets), nameof<DescriptionPropertyDefinitionFieldSet>(x => x.items), nameof<DescriptionPropertyDefinitionFieldSetItem>(x => x.fields), nameof<DescriptionField>(x => x.references), nameof<Reference>(x => x.isActive)].join('.'),
[nameof<Description>(x => x.descriptionTags), nameof<DescriptionTag>(x => x.id),].join('.'), [nameof<Description>(x => x.descriptionTags), nameof<DescriptionTag>(x => x.id),].join('.'),
[nameof<Description>(x => x.descriptionTags), nameof<DescriptionTag>(x => x.tag), nameof<Tag>(x => x.label)].join('.'), [nameof<Description>(x => x.descriptionTags), nameof<DescriptionTag>(x => x.tag), nameof<Tag>(x => x.label)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.data), nameof<DescriptionReferenceData>(x => x.fieldId)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.id)].join('.'), [nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.id)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.label)].join('.'), [nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.label)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.type)].join('.'), [nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.type), nameof<ReferenceType>(x => x.id)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.reference)].join('.'), [nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.reference)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.source)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.sourceType)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.isActive)].join('.'),
nameof<Description>(x => x.createdAt), nameof<Description>(x => x.createdAt),
nameof<Description>(x => x.hash), nameof<Description>(x => x.hash),
nameof<Description>(x => x.isActive) nameof<Description>(x => x.isActive)
@ -85,6 +96,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.label)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.label)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.version)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.version)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.groupId)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.groupId)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.isActive)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.id)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.ordinal)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.ordinal)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.title)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.title)].join('.'),
@ -147,6 +159,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.isActive)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.currentDescriptionTemplate), nameof<DescriptionTemplate>(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.currentDescriptionTemplate), nameof<DescriptionTemplate>(x => x.id)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.currentDescriptionTemplate), nameof<DescriptionTemplate>(x => x.label)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.currentDescriptionTemplate), nameof<DescriptionTemplate>(x => x.label)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.currentDescriptionTemplate), nameof<DescriptionTemplate>(x => x.version)].join('.'), (prefix ? prefix + '.' : '') + [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.currentDescriptionTemplate), nameof<DescriptionTemplate>(x => x.version)].join('.'),

View File

@ -46,10 +46,10 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
item.blueprint.definition.sections.forEach(section => { item.blueprint.definition.sections.forEach(section => {
if (section.hasTemplates) { if (section.hasTemplates) {
const sectionTempaltesFromDmp = item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id) || []; const sectionTempaltesFromDmp = item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id && x.isActive == IsActive.Active) || [];
if (sectionTempaltesFromDmp.length > 0) { if (sectionTempaltesFromDmp.length > 0) {
item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id).forEach(dmpDescriptionTemplate => { sectionTempaltesFromDmp?.filter(x => x.sectionId == section.id).forEach(dmpDescriptionTemplate => {
this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel(this.validationErrorModel).fromModel( this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel(this.validationErrorModel).fromModel(
{ {
sectionId: section.id, sectionId: section.id,
@ -57,7 +57,7 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
})); }));
}); });
} else if (section.descriptionTemplates?.length > 0) { } else if (section.descriptionTemplates?.length > 0) {
section.descriptionTemplates.forEach(blueprintDefinedDescriptionTemplate => { sectionTempaltesFromDmp.forEach(blueprintDefinedDescriptionTemplate => {
this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel(this.validationErrorModel).fromModel( this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel(this.validationErrorModel).fromModel(
{ {
sectionId: section.id, sectionId: section.id,
@ -297,7 +297,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
// TODO check typeId field // TODO check typeId field
if(dmpReferences){ if(dmpReferences){
dmpReferences.forEach(dmpReference => { dmpReferences.forEach(dmpReference => {
if(dmpReference.data.blueprintFieldId == this.fieldId){ if(dmpReference.data.blueprintFieldId == this.fieldId && dmpReference.isActive == IsActive.Active){
this.references.push({ this.references.push({
data: dmpReference.data, data: dmpReference.data,
reference: { reference: {

View File

@ -82,6 +82,7 @@ export class DmpEditorResolver extends BaseEditorResolver {
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'), [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'), [nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'),
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.isActive)].join('.'),
// nameof<Dmp>(x => x.id), // nameof<Dmp>(x => x.id),