add Description template hasMultiplicity

This commit is contained in:
Efstratios Giannopoulos 2024-04-24 14:07:51 +03:00
parent cd8545590e
commit e5e1f23811
23 changed files with 132 additions and 85 deletions

View File

@ -27,6 +27,8 @@ public class FieldSetEntity {
private String additionalInformation;
@XmlElement(name="multiplicity")
private MultiplicityEntity multiplicity;
@XmlAttribute(name="hasMultiplicity")
private boolean hasMultiplicity;
@XmlAttribute(name="hasCommentField")
private boolean hasCommentField;
@ -108,4 +110,12 @@ public class FieldSetEntity {
public List<FieldEntity> getFieldById(String id) {
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
}
public boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
}

View File

@ -27,6 +27,9 @@ public class FieldSetImportExport {
private String additionalInformation;
@XmlElement(name="multiplicity")
private MultiplicityImportExport multiplicity;
@XmlAttribute(name="hasMultiplicity")
private boolean hasMultiplicity;
@XmlAttribute(name="hasCommentField")
private Boolean hasCommentField;
@ -109,4 +112,11 @@ public class FieldSetImportExport {
this.title = title;
}
public boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
}

View File

@ -56,6 +56,7 @@ public class FieldSetCommonModelBuilder extends BaseCommonModelBuilder<FieldSetM
m.setExtendedDescription(d.getExtendedDescription());
m.setAdditionalInformation(d.getAdditionalInformation());
if (d.getMultiplicity() != null) m.setMultiplicity(this.builderFactory.builder(MultiplicityCommonModelBuilder.class).authorize(this.authorize).build(d.getMultiplicity()));
// if (d.getHasMultiplicity() != null) m.se(this.builderFactory.builder(MultiplicityCommonModelBuilder.class).authorize(this.authorize).build(d.getMultiplicity())); //TODO: HasMultiplicity
if (d.getFields() != null) m.setFields(this.builderFactory.builder(FieldCommonModelBuilder.class).authorize(this.authorize).build(d.getFields()));
models.add(new CommonModelBuilderItemResponse<>(m, d));
}

View File

@ -57,6 +57,7 @@ public class FieldSetBuilder extends BaseBuilder<eu.eudat.model.descriptiontempl
if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._extendedDescription))) m.setExtendedDescription(d.getExtendedDescription());
if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._additionalInformation))) m.setAdditionalInformation(d.getAdditionalInformation());
if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._hasCommentField))) m.setHasCommentField(d.getHasCommentField());
if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._hasMultiplicity))) m.setHasMultiplicity(d.getHasMultiplicity());
if (!multiplicityFields.isEmpty() && d.getMultiplicity() != null) m.setMultiplicity(this.builderFactory.builder(MultiplicityBuilder.class).authorize(this.authorize).build(multiplicityFields, d.getMultiplicity()));
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
models.add(m);

View File

@ -28,6 +28,9 @@ public class FieldSet {
public final static String _multiplicity = "multiplicity";
private Multiplicity multiplicity;
private Boolean hasMultiplicity;
public static final String _hasMultiplicity = "hasMultiplicity";
public final static String _hasCommentField = "hasCommentField";
private Boolean hasCommentField;
@ -98,6 +101,14 @@ public class FieldSet {
this.multiplicity = multiplicity;
}
public Boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(Boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
public Boolean getHasCommentField() {
return hasCommentField;
}

View File

@ -22,7 +22,7 @@ public class DescriptionFieldSetToDatasetFieldSetMapper {
model.setTitle(fieldSet.getTitle());
model.setAdditionalInformation(fieldSet.getAdditionalInformation());
model.setExtendedDescription(fieldSet.getExtendedDescription());
if (fieldSet.getMultiplicity() != null) {
if (fieldSet.getMultiplicity() != null && fieldSet.getHasMultiplicity()) {
MultiplicityEntity multiplicityEntity = new MultiplicityEntity();
multiplicityEntity.setMin(fieldSet.getMultiplicity().getMin());
multiplicityEntity.setMax(fieldSet.getMultiplicity().getMax());

View File

@ -48,10 +48,8 @@ public class PropertyDefinitionFieldSetPersist {
@Override
protected List<Specification> specifications(PropertyDefinitionFieldSetPersist item) {
Integer min = fieldSetEntity != null && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMin() : null;
Integer max = fieldSetEntity != null && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMax() : null;
if(min == 0 && max == 0) max = null;
Integer finalMax = max;
int min = fieldSetEntity != null && fieldSetEntity.getHasMultiplicity() && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMin() : 0;
int max = fieldSetEntity != null && fieldSetEntity.getHasMultiplicity() && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMax() : Integer.MAX_VALUE;
return Arrays.asList(
this.navSpec()
@ -60,13 +58,13 @@ public class PropertyDefinitionFieldSetPersist {
.over(item.getItems())
.using((itm) -> this.validatorFactory.validator(PropertyDefinitionFieldSetItemPersist.PersistValidator.class).withFieldSetEntity(this.fieldSetEntity).setStatus(this.status)),
this.spec()
.iff(() -> DescriptionStatus.Finalized.equals(this.status) && min != null)
.iff(() -> DescriptionStatus.Finalized.equals(this.status) && fieldSetEntity.getHasMultiplicity())
.must(() -> !this.isListNullOrEmpty(item.getItems()) && min <= item.getItems().size())
.failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LargerThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, min}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> DescriptionStatus.Finalized.equals(this.status) && finalMax != null)
.must(() -> !this.isListNullOrEmpty(item.getItems()) && finalMax >= item.getItems().size())
.failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LessThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, finalMax}, LocaleContextHolder.getLocale()))
.iff(() -> DescriptionStatus.Finalized.equals(this.status) && fieldSetEntity.getHasMultiplicity())
.must(() -> !this.isListNullOrEmpty(item.getItems()) && max >= item.getItems().size())
.failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LessThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, max}, LocaleContextHolder.getLocale()))
);
}

View File

@ -100,10 +100,10 @@ public class PropertyDefinitionPersist {
if (definition == null || definition.getAllFieldSets() == null) return missingMultipleFieldSets;
for (FieldSetEntity fieldSet: definition.getAllFieldSets()) {
boolean requiredAtLeastOneFieldSet = fieldSet.getMultiplicity() != null && fieldSet.getMultiplicity().getMin() > 0;
boolean requiredAtLeastOneFieldSet = fieldSet.getMultiplicity() != null && fieldSet.getHasMultiplicity() && fieldSet.getMultiplicity().getMin() > 0;
if (requiredAtLeastOneFieldSet) {
if (item == null || item.getFieldSets() == null) missingMultipleFieldSets.add(fieldSet);
if (item.getFieldSets() != null) {
if (item != null && item.getFieldSets() != null) {
PropertyDefinitionFieldSetPersist fieldSetPersist = item.getFieldSets().getOrDefault(fieldSet.getId(), null);
if (fieldSetPersist == null) missingMultipleFieldSets.add(fieldSet);
}

View File

@ -45,6 +45,10 @@ public class FieldSetPersist {
private MultiplicityPersist multiplicity = null;
public static final String _multiplicity = "multiplicity";
private Boolean hasMultiplicity;
public static final String _hasMultiplicity = "hasMultiplicity";
private Boolean hasCommentField = null;
private List<FieldPersist> fields = null;
@ -131,6 +135,14 @@ public class FieldSetPersist {
this.fields = fields;
}
public Boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(Boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
@Component(FieldSetPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class FieldSetPersistValidator extends BaseValidator<FieldSetPersist> {
@ -164,6 +176,9 @@ public class FieldSetPersist {
this.spec()
.must(() -> !this.isEmpty(item.getNumbering()))
.failOn(FieldSetPersist._numbering).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._numbering}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getHasMultiplicity()))
.failOn(FieldSetPersist._hasMultiplicity).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._hasMultiplicity}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getTitle()))
.failOn(FieldSetPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._title}, LocaleContextHolder.getLocale())),

View File

@ -349,14 +349,16 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
data.setDescription(persist.getDescription());
data.setOrdinal(persist.getOrdinal());
data.setTitle(persist.getTitle());
data.setHasMultiplicity(persist.getHasMultiplicity());
data.setNumbering(persist.getNumbering());
data.setAdditionalInformation(persist.getAdditionalInformation());
data.setExtendedDescription(persist.getExtendedDescription());
if (persist.getMultiplicity() != null && (
if (persist.getMultiplicity() != null && persist.getHasMultiplicity() && (
(persist.getMultiplicity().getMin() != null && persist.getMultiplicity().getMin() != 0)
|| (persist.getMultiplicity().getMax() != null && persist.getMultiplicity().getMax() != 0)
))
)) {
data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
}
data.setHasCommentField(persist.getHasCommentField());
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
@ -833,6 +835,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
fieldSet1Entity.setOrdinal(importExport.getOrdinal());
fieldSet1Entity.setHasCommentField(importExport.getHasCommentField() != null ? importExport.getHasCommentField() : false);
fieldSet1Entity.setMultiplicity(importExport.getMultiplicity() != null ? this.xmlMultiplicityToPersist(importExport.getMultiplicity()) : null);
fieldSet1Entity.setHasMultiplicity(importExport.getHasMultiplicity());
fieldSet1Entity.setTitle(importExport.getTitle());
fieldSet1Entity.setDescription(importExport.getDescription());
fieldSet1Entity.setExtendedDescription(importExport.getExtendedDescription());
@ -970,6 +973,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
fieldSet1Entity.setId(entity.getId());
fieldSet1Entity.setOrdinal(entity.getOrdinal());
fieldSet1Entity.setHasCommentField(entity.getHasCommentField());
fieldSet1Entity.setHasMultiplicity(entity.getHasMultiplicity());
fieldSet1Entity.setMultiplicity(entity.getMultiplicity() != null ? this.multiplicityXmlToExport(entity.getMultiplicity()) : null);
fieldSet1Entity.setTitle(entity.getTitle());
fieldSet1Entity.setDescription(entity.getDescription());

View File

@ -174,6 +174,7 @@ public class PublicDatasetsDescriptionDocumentation {
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._extendedDescription),
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._ordinal),
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._additionalInformation),
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._hasMultiplicity),
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._multiplicity, Multiplicity._min),
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._multiplicity, Multiplicity._max),
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._multiplicity, Multiplicity._placeholder),

View File

@ -49,7 +49,6 @@ export interface DescriptionTemplateSectionPersist {
id: string;
ordinal: number;
defaultVisibility: boolean;
multiplicity: boolean;
title: string;
description: string;
@ -66,6 +65,7 @@ export interface DescriptionTemplateFieldSetPersist {
extendedDescription: string;
additionalInformation: string;
multiplicity: DescriptionTemplateMultiplicityPersist;
hasMultiplicity: boolean;
hasCommentField: boolean;
fields: DescriptionTemplateFieldPersist[];
}

View File

@ -47,7 +47,6 @@ export interface DescriptionTemplateSection {
id?: string;
ordinal?: number;
defaultVisibility?: boolean;
multiplicity?: boolean;
title?: string;
description?: string;
sections?: DescriptionTemplateSection[];
@ -63,6 +62,7 @@ export interface DescriptionTemplateFieldSet {
extendedDescription: string;
additionalInformation: string;
multiplicity: DescriptionTemplateMultiplicity
hasMultiplicity: boolean;
hasCommentField: boolean;
fields: DescriptionTemplateField[];
}

View File

@ -33,25 +33,25 @@
</div>
<div class="row">
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field">
<mat-form-field *ngIf="this.form.get('hasMultiplicity')?.value" class="col pl-0 underline-line-field">
<input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MIN' | translate}}" type="number" [formControl]="form.get('multiplicity').get('min')">
<mat-error *ngIf="form.get('multiplicity').get('min').hasError('backendError')">{{form.get('multiplicity').get('min').getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.get('multiplicity').get('min').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pr-0 underline-line-field">
<mat-form-field *ngIf="this.form.get('hasMultiplicity')?.value" class="col pr-0 underline-line-field">
<input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MAX' | translate}}" type="number" [formControl]="this.form.get('multiplicity').get('max')">
<mat-error *ngIf="form.get('multiplicity').get('max').hasError('backendError')">{{form.get('multiplicity').get('max').getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.get('multiplicity').get('max').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="row">
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field">
<mat-form-field *ngIf="this.form.get('hasMultiplicity')?.value" class="col pl-0 underline-line-field">
<input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-PLACEHOLDER' | translate}}" type="text" [formControl]="form.get('multiplicity').get('placeholder')">
<mat-error *ngIf="form.get('multiplicity').get('placeholder').hasError('backendError')">{{form.get('placeholder').get('multiplicity').getError('backendError').message}}</mat-error>
</mat-form-field>
</div>
<div class="row">
<mat-checkbox *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field fieldset-checkbox-action-description-template-editor" [formControl]="form.get('multiplicity').get('tableView')">
<mat-checkbox *ngIf="this.form.get('hasMultiplicity')?.value" class="col pl-0 underline-line-field fieldset-checkbox-action-description-template-editor" [formControl]="form.get('multiplicity').get('tableView')">
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-TABLEVIEW' | translate}}
<mat-error *ngIf="form.get('multiplicity').get('tableView').hasError('backendError')">{{form.get('multiplicity').get('tableView').getError('backendError').message}}</mat-error>
</mat-checkbox>
@ -110,7 +110,7 @@
</div>
</div>
</div>
<div class="w-100" *ngIf="!firstField?.get('data')?.get('fieldType')?.value">
<em>
@ -240,7 +240,7 @@
<mat-error *ngIf="form.get('hasCommentField').hasError('backendError')">{{form.get('hasCommentField').getError('backendError').message}}</mat-error>
</li>
<li class="list-inline-item">
<mat-checkbox class="fieldset-checkbox-action-description-template-editor" [(checked)]="isMultiplicityEnabled" (change)="onIsMultiplicityEnabledChange($event)" [matTooltip]="'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.ENABLE-MULTIPLICITY' | translate" [disabled]="viewOnly">
<mat-checkbox class="fieldset-checkbox-action-description-template-editor" [formControl]="this.form.get('hasMultiplicity')" (change)="onIsMultiplicityEnabledChange($event)" [matTooltip]="'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.ENABLE-MULTIPLICITY' | translate" [disabled]="viewOnly">
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.MULTIPLICITY' | translate}}
</mat-checkbox>
</li>
@ -257,4 +257,4 @@
</div>
</div>
</ng-container>
</div>
</div>

View File

@ -72,7 +72,6 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
private myCustomValidators: EditorCustomValidators = new EditorCustomValidators();
isMultiplicityEnabled = false;
constructor(
private dialog: MatDialog,
private language: TranslateService,
@ -89,16 +88,6 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
// this.showExtendedDescription = !!this.form.get('extendedDescription').value;
// this.showAdditionalInfo = !!this.form.get('additionalInformation').value;
// console.log(this.form.get('fields')['controls'])
if (changes['form']) {
try {
const multiplicity = this.form.get('multiplicity').value;
this.isMultiplicityEnabled = multiplicity.min > 0 || multiplicity.max > 0;
} catch {
this.isMultiplicityEnabled = false;
}
}
}
get firstField() {
@ -264,9 +253,11 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
description: formValue.description,
extendedDescription: formValue.extendedDescription,
additionalInformation: formValue.additionalInformation,
hasMultiplicity: formValue.hasMultiplicity,
multiplicity: {
max: formValue.multiplicity.max, min: formValue.multiplicity.min,
placeholder: formValue.multiplicity.placeholder, tableView: formValue.multiplicity.tableView
max: formValue.multiplicity?.max,
min: formValue.multiplicity?.min,
placeholder: formValue.multiplicity?.placeholder, tableView: formValue.multiplicity?.tableView
},
hasCommentField: formValue.hasCommentField,
fields: fields
@ -342,13 +333,12 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
placeholder.setValue('');
tableView.setValue(false);
} else {
minControl.setValue(0);
maxControl.setValue(0);
minControl.setValue(null);
maxControl.setValue(null);
placeholder.setValue(null);
tableView.setValue(null);
}
this.isMultiplicityEnabled = isMultiplicityEnabled.checked;
minControl.updateValueAndValidity();
maxControl.updateValueAndValidity();

View File

@ -20,7 +20,7 @@ export class FinalPreviewComponent implements OnInit {
@Input() descriptionTemplatePersist: DescriptionTemplatePersist;
descriptionTemplate: DescriptionTemplate;
previewPropertiesFormGroup: UntypedFormGroup;
constructor(public visibilityRulesService: VisibilityRulesService) {
@ -45,7 +45,7 @@ export class FinalPreviewComponent implements OnInit {
}
const descriptionEditorModel = new DescriptionEditorModel().fromModel(mockDescription, mockDescription.descriptionTemplate);
this.previewPropertiesFormGroup = descriptionEditorModel.properties.buildForm() as UntypedFormGroup;
this.visibilityRulesService.setContext(this.descriptionTemplate.definition, this.previewPropertiesFormGroup);
}
@ -64,14 +64,14 @@ export class FinalPreviewComponent implements OnInit {
status: persist.status,
definition: this.buildDescriptionTemplateDefinition(persist.definition),
users: persist.users
}
}
}
private buildDescriptionTemplateDefinition(persist: DescriptionTemplateDefinitionPersist) : DescriptionTemplateDefinition{
if (persist == null) return null;
return {
pages: persist.pages.map(x => this.buildDescriptionTemplatePage(x))
}
}
}
private buildDescriptionTemplatePage(persist: DescriptionTemplatePagePersist) : DescriptionTemplatePage{
@ -81,7 +81,7 @@ export class FinalPreviewComponent implements OnInit {
ordinal: persist.ordinal,
title: persist.title,
sections: persist.sections.map(x => this.buildDescriptionTemplateSection(x)),
}
}
}
private buildDescriptionTemplateSection(persist: DescriptionTemplateSectionPersist) : DescriptionTemplateSection{
@ -90,12 +90,11 @@ export class FinalPreviewComponent implements OnInit {
id: persist.id,
ordinal: persist.ordinal,
defaultVisibility: persist.defaultVisibility,
multiplicity: persist.multiplicity,
title: persist.title,
description: persist.description,
sections: persist.sections.map(x => this.buildDescriptionTemplateSection(x)),
fieldSets: persist.fieldSets.map(x => this.buildDescriptionTemplateFieldSet(x)),
}
}
}
private buildDescriptionTemplateFieldSet(persist: DescriptionTemplateFieldSetPersist) : DescriptionTemplateFieldSet{
@ -108,13 +107,16 @@ export class FinalPreviewComponent implements OnInit {
description: persist.description,
extendedDescription: persist.extendedDescription,
additionalInformation: persist.additionalInformation,
hasMultiplicity: persist.hasMultiplicity,
multiplicity: {
max: persist.multiplicity.max, min: persist.multiplicity.min,
placeholder: persist.multiplicity.placeholder, tableView: persist.multiplicity.tableView
max: persist.multiplicity?.max,
min: persist.multiplicity?.min,
placeholder: persist.multiplicity?.placeholder,
tableView: persist.multiplicity?.tableView
},
hasCommentField: persist.hasCommentField,
fields: persist.fields.map(x => this.buildDescriptionTemplateField(x)),
}
}
}
private buildDescriptionTemplateField (persist: DescriptionTemplateFieldPersist) : DescriptionTemplateField{
@ -128,7 +130,7 @@ export class FinalPreviewComponent implements OnInit {
validations: persist.validations,
includeInExport: persist.includeInExport,
data: persist.data,
}
}
if (persist.data.fieldType === DescriptionTemplateFieldType.REFERENCE_TYPES) {
convertedField.data = persist.data;

View File

@ -361,7 +361,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
id: string;
ordinal: number;
defaultVisibility: boolean = false; // TODO: check if used and remove
multiplicity: boolean = false;
title: string;
description: string;
sections: DescriptionTemplateSectionEditorModel[] = [];
@ -378,7 +377,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
this.id = item.id;
this.ordinal = item.ordinal;
this.defaultVisibility = item.defaultVisibility;
this.multiplicity = item.multiplicity;
this.title = item.title;
this.description = item.description;
if (item.sections) { item.sections.map(x => this.sections.push(new DescriptionTemplateSectionEditorModel(this.validationErrorModel).fromModel(x))); }
@ -404,7 +402,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
defaultVisibility: [{ value: this.defaultVisibility, disabled: disabled }, context.getValidation('defaultVisibility').validators],
multiplicity: [{ value: this.multiplicity, disabled: disabled }, context.getValidation('multiplicity').validators],
title: [{ value: this.title, disabled: disabled }, context.getValidation('title').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
sections: this.formBuilder.array(
@ -439,7 +436,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
baseValidationArray.push({ key: 'defaultVisibility', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}defaultVisibility`)] });
baseValidationArray.push({ key: 'multiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}multiplicity`)] });
baseValidationArray.push({ key: 'title', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}title`)] });
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
baseValidationArray.push({ key: 'sections', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sections`)] });
@ -461,7 +457,7 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
validationErrorModel
});
['id', 'ordinal', 'defaultVisibility', 'multiplicity', 'page', 'title', 'description'].forEach(keyField => {
['id', 'ordinal', 'defaultVisibility', 'page', 'title', 'description'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
@ -495,6 +491,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
extendedDescription: string;
additionalInformation: string;
multiplicity: DescriptionTemplateMultiplicityEditorModel = new DescriptionTemplateMultiplicityEditorModel(this.validationErrorModel);
hasMultiplicity: boolean = false;
hasCommentField: boolean = false;
fields: DescriptionTemplateFieldEditorModel[] = [];
@ -514,6 +511,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
this.extendedDescription = item.extendedDescription;
this.additionalInformation = item.additionalInformation;
this.hasCommentField = item.hasCommentField;
this.hasMultiplicity = item.hasMultiplicity;
this.multiplicity = new DescriptionTemplateMultiplicityEditorModel(this.validationErrorModel).fromModel(item.multiplicity);
if (item.fields) { item.fields.map(x => this.fields.push(new DescriptionTemplateFieldEditorModel(this.validationErrorModel).fromModel(x))); }
@ -543,6 +541,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
extendedDescription: [{ value: this.extendedDescription, disabled: disabled }, context.getValidation('extendedDescription').validators],
additionalInformation: [{ value: this.additionalInformation, disabled: disabled }, context.getValidation('additionalInformation').validators],
hasCommentField: [{ value: this.hasCommentField, disabled: disabled }, context.getValidation('hasCommentField').validators],
hasMultiplicity: [{ value: this.hasMultiplicity, disabled: disabled }, context.getValidation('hasMultiplicity').validators],
multiplicity: this.multiplicity.buildForm({
rootPath: `${rootPath}multiplicity.`
}),
@ -572,6 +571,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
baseValidationArray.push({ key: 'extendedDescription', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}extendedDescription`)] });
baseValidationArray.push({ key: 'additionalInformation', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}additionalInformation`)] });
baseValidationArray.push({ key: 'hasCommentField', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasCommentField`)] });
baseValidationArray.push({ key: 'hasMultiplicity', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}hasMultiplicity`)] });
baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
baseContext.validation = baseValidationArray;
@ -590,7 +590,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
validationErrorModel
});
['id', 'ordinal', 'numbering', 'title', 'description', 'extendedDescription', 'additionalInformation', 'hasCommentField'].forEach(keyField => {
['id', 'ordinal', 'numbering', 'title', 'description', 'extendedDescription', 'additionalInformation', 'hasCommentField', 'hasMultiplicity'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);

View File

@ -39,7 +39,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.id)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.ordinal)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.defaultVisibility)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.multiplicity)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.title)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.description)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.ordinal)].join('.'),
@ -53,6 +52,7 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.extendedDescription)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.additionalInformation)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasCommentField)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasMultiplicity)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.min)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.max)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.placeholder)].join('.'),

View File

@ -113,6 +113,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.extendedDescription)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.additionalInformation)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasCommentField)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasMultiplicity)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.min)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.max)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.placeholder)].join('.'),

View File

@ -32,7 +32,7 @@
</button>
</div>
</div>
<div *ngIf="(fieldSet?.multiplicity?.max - 1) > (propertiesFormGroup.get('items').length)" class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
<div *ngIf="fieldSet.hasMultiplicity && (fieldSet?.multiplicity?.max - 1) > (propertiesFormGroup.get('items').length)" class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
<span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()">
<button mat-icon-button color="primary" [disabled]="propertiesFormGroup.disabled">
<mat-icon>add_circle</mat-icon>
@ -42,7 +42,7 @@
</span>
</div>
</div>
<div *ngIf="fieldSet?.multiplicity?.tableView" class="col-12">
<div *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.tableView" class="col-12">
<table class="table table-bordered" style="table-layout: fixed">
<tr>
<th *ngFor="let field of fieldSet.fields; let i = index;" class="text-wrap">{{field.data?.label}}</th>
@ -66,7 +66,7 @@
</tr>
</ng-container>
<tr *ngIf="(fieldSet.multiplicity.max - 1) > propertiesFormGroup?.get('items')?.controls.length">
<tr *ngIf="fieldSet.hasMultiplicity && (fieldSet.multiplicity.max - 1) > propertiesFormGroup?.get('items')?.controls.length">
<td [colSpan]="fieldSet.fields.length + 1" class="text-center">
<span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()">
<button mat-icon-button color="primary" [disabled]="propertiesFormGroup.disabled">

View File

@ -29,7 +29,7 @@ export class DescriptionFormFieldSetComponent extends BaseComponent {
@Input() descriptionId: Guid;
get isMultiplicityEnabled() {
return this.fieldSet.multiplicity != null && this.fieldSet.multiplicity.min != 0 && this.fieldSet.multiplicity.max != 0;
return this.fieldSet.hasMultiplicity && this.fieldSet.multiplicity != null;
}

View File

@ -14,6 +14,7 @@ import eu.eudat.data.ReferenceTypeEntity;
import eu.eudat.data.converters.enums.DatabaseEnum;
import eu.eudat.model.DescriptionTemplate;
import eu.eudat.query.DescriptionTemplateQuery;
import eu.old.eudat.logic.services.helpers.HelpersService;
import eu.old.eudat.logic.utilities.builders.XmlBuilder;
import eu.old.eudat.models.data.components.commons.Multiplicity;
import eu.old.eudat.models.data.components.commons.Rule;
@ -172,7 +173,9 @@ public class DescriptionTemplateXmlMigrationService {
data.setExtendedDescription(persist.getExtendedDescription());
data.setAdditionalInformation(persist.getAdditionalInformation());
data.setHasCommentField(persist.getHasCommentField());
if (persist.getMultiplicity() != null) data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
data.setHasMultiplicity(persist.getMultiplicity() != null && (persist.getMultiplicity().getMin() != 0 || persist.getMultiplicity().getMax() != 0));
if (persist.getMultiplicity() != null && data.getHasMultiplicity()) data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
data.setFields(new ArrayList<>());

View File

@ -90,36 +90,36 @@ public class MigrationController {
@GetMapping("all")
@Transactional
public boolean migrateAll() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException {
//Reference
this.dataRepositoryMigrationService.migrate();
this.externalDatasetMigrationService.migrate();
this.funderMigrationService.migrate();
this.grantMigrationService.migrate();
this.organizationMigrationService.migrate();
this.projectMigrationService.migrate();
this.registryMigrationService.migrate();
this.researcherMigrationService.migrate();
this.serviceMigrationService.migrate();
//User
this.userContactInfoMigrationService.migrate();
this.userMigrationService.migrate();
//XML recreate
this.dmpBlueprintXmlMigrationService.migrate();
this.descriptionTemplateXmlMigrationService.migrate();
// //Reference
// this.dataRepositoryMigrationService.migrate();
// this.externalDatasetMigrationService.migrate();
// this.funderMigrationService.migrate();
// this.grantMigrationService.migrate();
// this.organizationMigrationService.migrate();
// this.projectMigrationService.migrate();
// this.registryMigrationService.migrate();
// this.researcherMigrationService.migrate();
// this.serviceMigrationService.migrate();
//
// //User
// this.userContactInfoMigrationService.migrate();
// this.userMigrationService.migrate();
// //XML recreate
// this.dmpBlueprintXmlMigrationService.migrate();
// this.descriptionTemplateXmlMigrationService.migrate();
//
//Dmp
this.dmpMigrationService.migrate();
this.dmpDatasetProfileMigrationService.migrate();
this.dmpUserMigrationService.migrate();
//Description
this.datasetMigrationService.migrate();
this.datasetReferenceMigrationService.migrateDatasetReferences();
this.tagMigrationService.migrate();
this.storageFileMigrationService.migrate();
// //Description
// this.datasetMigrationService.migrate();
// this.datasetReferenceMigrationService.migrateDatasetReferences();
// this.tagMigrationService.migrate();
//
// this.storageFileMigrationService.migrate();
//throw new RuntimeException("");
return true;