description properties changes

This commit is contained in:
Efstratios Giannopoulos 2024-02-07 13:53:01 +02:00
parent 176d13d443
commit 2b436be2cd
7 changed files with 36 additions and 16 deletions

View File

@ -12,7 +12,7 @@ public enum FieldType implements DatabaseEnum<String> {
RADIO_BOX(Names.RadioBox),
INTERNAL_DMP_ENTRIES_RESEARCHERS(Names.InternalDmpResearchers),
INTERNAL_DMP_ENTRIES_DMPS(Names.InternalDmpDmps),
INTERNAL_DMP_ENTRIES_DATASETS(Names.InternalDmpDatasets),
INTERNAL_ENTRIES_DESCRIPTIONS(Names.InternalDmpDescriptions),
CHECK_BOX(Names.CheckBox),
FREE_TEXT(Names.FreeText),
TEXT_AREA(Names.TextArea),
@ -43,7 +43,7 @@ public enum FieldType implements DatabaseEnum<String> {
public static final String RadioBox = "radiobox";
public static final String InternalDmpResearchers = "internalDmpResearchers";
public static final String InternalDmpDmps = "internalDmpDmps";
public static final String InternalDmpDatasets = "internalDmpDatasets";
public static final String InternalDmpDescriptions = "internalDmpDescriptions";
public static final String CheckBox = "checkBox";
public static final String FreeText = "freetext";
public static final String TextArea = "textarea";
@ -83,8 +83,7 @@ public enum FieldType implements DatabaseEnum<String> {
}
public static boolean isNotImplemented(FieldType fieldType){
return fieldType.equals(FieldType.EXTERNAL_SELECT) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DMPS) ||
fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
return fieldType.equals(FieldType.EXTERNAL_SELECT);
}
public static boolean isReferenceType(FieldType fieldType){
@ -101,7 +100,8 @@ public enum FieldType implements DatabaseEnum<String> {
}
public static boolean isTextListType(FieldType fieldType){
return fieldType.equals(FieldType.SELECT) || fieldType.equals(FieldType.TAGS);
return fieldType.equals(FieldType.SELECT) || fieldType.equals(FieldType.TAGS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DMPS) ||
fieldType.equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS);
}
public static boolean isDateType(FieldType fieldType){

View File

@ -86,7 +86,7 @@ public class DescriptionFieldDepositBuilder extends BaseDepositBuilder<Descripti
case RADIO_BOX -> m.setFieldType(FieldType.RADIO_BOX);
case INTERNAL_DMP_ENTRIES_RESEARCHERS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS);
case INTERNAL_DMP_ENTRIES_DMPS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DMPS);
case INTERNAL_DMP_ENTRIES_DATASETS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
case INTERNAL_ENTRIES_DESCRIPTIONS -> m.setFieldType(FieldType.INTERNAL_DMP_ENTRIES_DATASETS);
case CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX);
case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT);
case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA);

View File

@ -3,7 +3,6 @@ package eu.eudat.model.persist.descriptionproperties;
import eu.eudat.commons.enums.FieldType;
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.model.descriptionproperties.Field;
import eu.eudat.model.persist.ReferencePersist;
import gr.cite.tools.validation.ValidatorFactory;
import gr.cite.tools.validation.specification.Specification;
@ -16,7 +15,6 @@ import org.springframework.stereotype.Component;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class FieldPersist {
@ -132,7 +130,7 @@ public class FieldPersist {
.must(() -> this.isUUID(item.getTextValue()))
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
this.spec()
.iff(()-> !this.isNull(item.getTextListValue()) && fieldType.equals(FieldType.TAGS))
.iff(()-> !this.isNull(item.getTextListValue()) && (fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_DMPS) || fieldType.equals(FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS) || fieldType.equals(FieldType.INTERNAL_ENTRIES_DESCRIPTIONS)))
.must(() -> item.getTextListValue().stream().allMatch(this::isUUID))
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
this.navSpec()

View File

@ -22,7 +22,7 @@ import java.util.List;
@JsonSubTypes({
@JsonSubTypes.Type(value = ExternalSelectDataPersist.class, name = FieldType.Names.ExternalSelect),
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.BooleanDecision),
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.InternalDmpDatasets),
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.InternalDmpDescriptions),
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.InternalDmpDmps),
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.CheckBox),
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.DatePicker),

View File

@ -5,6 +5,7 @@ import eu.eudat.authorization.Permission;
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.*;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.enums.notification.NotificationContactType;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.commons.types.description.*;
@ -23,7 +24,6 @@ import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionBuilder;
import eu.eudat.model.builder.StorageFileBuilder;
import eu.eudat.model.deleter.DescriptionDeleter;
import eu.eudat.model.deleter.DescriptionReferenceDeleter;
import eu.eudat.model.deleter.DescriptionTagDeleter;
@ -408,13 +408,35 @@ public class DescriptionServiceImpl implements DescriptionService {
data.setTextValue(persist.getTextValue());
}
}
else if (FieldType.isDateType(fieldType)) data.setDateValue(persist.getDateValue());
else if (FieldType.isTextListType(fieldType)) data.setTextListValue(persist.getTextListValue());
else if (FieldType.isExternalIdentifierType(fieldType) && persist.getExternalIdentifier() != null) data.setExternalIdentifier(this.buildExternalIdentifierEntity(persist.getExternalIdentifier()));
else if (FieldType.isTextListType(fieldType)) {
if (FieldType.INTERNAL_DMP_ENTRIES_DMPS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){
List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
Set<UUID> existingIds = this.queryFactory.query(DmpQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Dmp._id)).stream().map(DmpEntity::getId).collect(Collectors.toSet());
for (UUID id : ids){
if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
}
} if (FieldType.INTERNAL_ENTRIES_DESCRIPTIONS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){
List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
Set<UUID> existingIds = this.queryFactory.query(DescriptionQuery.class).ids(ids).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Description._id)).stream().map(DescriptionEntity::getId).collect(Collectors.toSet());
for (UUID id : ids){
if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
}
} if (FieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS.equals(fieldType) && !this.conventionService.isListNullOrEmpty(persist.getTextListValue())){
List<UUID> ids = persist.getTextListValue().stream().map(UUID::fromString).toList();
Set<UUID> existingIds = this.queryFactory.query(ReferenceQuery.class).ids(ids).types(ReferenceType.Researcher).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(Reference._id)).stream().map(ReferenceEntity::getId).collect(Collectors.toSet());
for (UUID id : ids){
if (!existingIds.contains(id)) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
}
}
data.setTextListValue(persist.getTextListValue());
}
else if (FieldType.isReferenceType(fieldType) && fieldEntity != null ) {
List<UUID> referenceIds = fieldToReferenceMap.getOrDefault(fieldEntity.getId(), null);
if (referenceIds != null) data.setTextListValue(referenceIds.stream().map(UUID::toString).toList());
}
else if (FieldType.isDateType(fieldType)) data.setDateValue(persist.getDateValue());
else if (FieldType.isExternalIdentifierType(fieldType) && persist.getExternalIdentifier() != null) data.setExternalIdentifier(this.buildExternalIdentifierEntity(persist.getExternalIdentifier()));
return data;
}

View File

@ -24,7 +24,7 @@ public class FieldDataHelperServiceProvider {
case REGISTRIES:
case SERVICES:
case RESEARCHERS:
case INTERNAL_DMP_ENTRIES_DATASETS:
case INTERNAL_ENTRIES_DESCRIPTIONS:
case INTERNAL_DMP_ENTRIES_DMPS:
case INTERNAL_DMP_ENTRIES_RESEARCHERS:
case ORGANIZATIONS: {

View File

@ -290,7 +290,7 @@ public class ExportXmlBuilderDatasetProfile {
dataOut.setAttribute("label", baseFieldDataObject.getLabel());
break;
case INTERNAL_DMP_ENTRIES_RESEARCHERS:
case INTERNAL_DMP_ENTRIES_DATASETS:
case INTERNAL_ENTRIES_DESCRIPTIONS:
case INTERNAL_DMP_ENTRIES_DMPS:
// InternalDmpBaseDataEntity internalDmpEntitiesData = (InternalDmpBaseDataEntity) field.getData();
// dataOut.setAttribute("label", internalDmpEntitiesData.getLabel());