multiplicity on description template fix bug

This commit is contained in:
amentis 2024-04-05 13:16:22 +03:00
parent bf08b6abb7
commit b6138da7ab
4 changed files with 16 additions and 13 deletions

View File

@ -14,6 +14,7 @@ import eu.eudat.model.persist.descriptionproperties.PropertyDefinitionPersist;
import eu.eudat.query.DescriptionQuery; import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DmpDescriptionTemplateQuery; import eu.eudat.query.DmpDescriptionTemplateQuery;
import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification; import gr.cite.tools.validation.specification.Specification;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -25,7 +26,6 @@ import javax.management.InvalidApplicationException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
public class DescriptionPersist { public class DescriptionPersist {
@ -157,13 +157,16 @@ public class DescriptionPersist {
private final TenantEntityManager entityManager; private final TenantEntityManager entityManager;
private final XmlHandlingService xmlHandlingService; private final XmlHandlingService xmlHandlingService;
private final QueryFactory queryFactory; private final QueryFactory queryFactory;
private final ValidatorFactory validatorFactory;
protected DescriptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, TenantEntityManager entityManager, XmlHandlingService xmlHandlingService, QueryFactory queryFactory) {
protected DescriptionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, TenantEntityManager entityManager, XmlHandlingService xmlHandlingService, QueryFactory queryFactory, ValidatorFactory validatorFactory) {
super(conventionService, errors); super(conventionService, errors);
this.messageSource = messageSource; this.messageSource = messageSource;
this.entityManager = entityManager; this.entityManager = entityManager;
this.xmlHandlingService = xmlHandlingService; this.xmlHandlingService = xmlHandlingService;
this.queryFactory = queryFactory; this.queryFactory = queryFactory;
this.validatorFactory = validatorFactory;
} }
@Override @Override
@ -220,12 +223,12 @@ public class DescriptionPersist {
.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.spec() this.spec()
.must(() -> this.isDescriptionTemplateMaxMultiplicityValid(finalDmpBlueprintEntity, item.getDmpId(), item.getDmpDescriptionTemplateId(), this.isValidGuid(item.getId()))) .must(() -> this.isDescriptionTemplateMaxMultiplicityValid(finalDmpBlueprintEntity, item.getDmpId(), item.getDmpDescriptionTemplateId(), this.isValidGuid(item.getId())))
.failOn(DescriptionPersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicity", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())) .failOn(DescriptionPersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicity", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())),
// this.refSpec() this.refSpec()
// .iff(() -> !this.isNull(item.getProperties())) .iff(() -> item.getStatus() == DescriptionStatus.Finalized)
// .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

@ -813,7 +813,7 @@ public class DescriptionServiceImpl implements DescriptionService {
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{data.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
persist.setLabel(data.getLabel()); persist.setLabel(data.getLabel());
persist.setStatus(data.getStatus()); persist.setStatus(DescriptionStatus.Finalized);
persist.setDescription(data.getDescription()); persist.setDescription(data.getDescription());
persist.setDescriptionTemplateId(data.getDescriptionTemplateId()); persist.setDescriptionTemplateId(data.getDescriptionTemplateId());
persist.setDmpId(data.getDmpId()); persist.setDmpId(data.getDmpId());

View File

@ -333,14 +333,14 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
if (!this.conventionService.isListNullOrEmpty(persist.getFieldSets())) { if (!this.conventionService.isListNullOrEmpty(persist.getFieldSets())) {
data.setFieldSets(new ArrayList<>()); data.setFieldSets(new ArrayList<>());
for (FieldSetPersist fieldSetPersist : persist.getFieldSets()) { for (FieldSetPersist fieldSetPersist : persist.getFieldSets()) {
data.getFieldSets().add(this.buildFieldSetEntity(fieldSetPersist)); data.getFieldSets().add(this.buildFieldSetEntity(fieldSetPersist, persist.getMultiplicity()));
} }
} }
return data; return data;
} }
private @NotNull FieldSetEntity buildFieldSetEntity(FieldSetPersist persist) throws InvalidApplicationException { private @NotNull FieldSetEntity buildFieldSetEntity(FieldSetPersist persist, Boolean multiplicity) throws InvalidApplicationException {
FieldSetEntity data = new FieldSetEntity(); FieldSetEntity data = new FieldSetEntity();
if (persist == null) if (persist == null)
return data; return data;
@ -352,7 +352,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
data.setNumbering(persist.getNumbering()); data.setNumbering(persist.getNumbering());
data.setAdditionalInformation(persist.getAdditionalInformation()); data.setAdditionalInformation(persist.getAdditionalInformation());
data.setExtendedDescription(persist.getExtendedDescription()); data.setExtendedDescription(persist.getExtendedDescription());
if (persist.getMultiplicity() != null) if (persist.getMultiplicity() != null && multiplicity)
data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity())); data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
data.setHasCommentField(persist.getHasCommentField()); data.setHasCommentField(persist.getHasCommentField());

View File

@ -125,7 +125,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
this.dmp.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled); this.dmp.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled);
} }
} }
this.dmp.entityDois = data.entityDois.filter(x => x.isActive === IsActive.Active); if (data.entityDois && data.entityDois.length > 0) this.dmp.entityDois = data.entityDois.filter(x => x.isActive === IsActive.Active);
this.selectedBlueprint = data.blueprint; this.selectedBlueprint = data.blueprint;
this.researchers = this.referenceService.getReferencesForTypes(this.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]); this.researchers = this.referenceService.getReferencesForTypes(this.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]);
if (!this.hasDoi()) { if (!this.hasDoi()) {