From 94cc0b87cded189949362ec8a4ea84b308aff160 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Thu, 11 Apr 2024 18:09:47 +0300 Subject: [PATCH] bug fixes --- .../NestedCollaboratorElasticBuilder.java | 21 +- .../BaseFileTransformerBuilder.java | 77 ----- ...escriptionFieldFileTransformerBuilder.java | 265 ------------------ .../DescriptionFileTransformerBuilder.java | 167 ----------- ...plateDefinitionFileTransformerBuilder.java | 243 ---------------- ...riptionTemplateFileTransformerBuilder.java | 83 ------ .../DmpBlueprintFileTransformerBuilder.java | 129 --------- .../DmpFileTransformerBuilder.java | 200 ------------- .../DmpUserFileTransformerBuilder.java | 85 ------ .../EntityDoiFileTransformerBuilder.java | 34 --- .../FileTransformerBuilderItemResponse.java | 19 -- ...renceDefinitionFileTransformerBuilder.java | 54 ---- .../ReferenceFieldFileTransformerBuilder.java | 53 ---- .../ReferenceFileTransformerBuilder.java | 80 ------ .../TagFileTransformerBuilder.java | 59 ---- .../UserFileTransformerBuilder.java | 75 ----- .../description/DescriptionServiceImpl.java | 6 +- 17 files changed, 20 insertions(+), 1630 deletions(-) delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/BaseFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionFieldFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionTemplateDefinitionFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionTemplateFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpBlueprintFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpUserFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/EntityDoiFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/FileTransformerBuilderItemResponse.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceDefinitionFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceFieldFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/TagFileTransformerBuilder.java delete mode 100644 dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/UserFileTransformerBuilder.java diff --git a/dmp-backend/core/src/main/java/eu/eudat/elastic/elasticbuilder/nested/NestedCollaboratorElasticBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/elastic/elasticbuilder/nested/NestedCollaboratorElasticBuilder.java index 889a86067..fd2bf6623 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/elastic/elasticbuilder/nested/NestedCollaboratorElasticBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/elastic/elasticbuilder/nested/NestedCollaboratorElasticBuilder.java @@ -1,10 +1,18 @@ package eu.eudat.elastic.elasticbuilder.nested; +import eu.eudat.commons.enums.IsActive; import eu.eudat.convention.ConventionService; +import eu.eudat.data.DescriptionEntity; import eu.eudat.data.DmpUserEntity; +import eu.eudat.data.UserEntity; import eu.eudat.elastic.data.nested.NestedCollaboratorElasticEntity; import eu.eudat.elastic.elasticbuilder.BaseElasticBuilder; +import eu.eudat.model.User; +import eu.eudat.query.DescriptionTemplateQuery; +import eu.eudat.query.UserQuery; +import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.BaseFieldSet; import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -12,18 +20,19 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; +import java.util.*; +import java.util.stream.Collectors; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder { + private final QueryFactory queryFactory; @Autowired public NestedCollaboratorElasticBuilder( - ConventionService conventionService) { + ConventionService conventionService, QueryFactory queryFactory) { super(conventionService, new LoggerService(LoggerFactory.getLogger(NestedCollaboratorElasticBuilder.class))); + this.queryFactory = queryFactory; } @Override @@ -32,11 +41,13 @@ public class NestedCollaboratorElasticBuilder extends BaseElasticBuilder(); List models = new ArrayList<>(); + Map userNameMap = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(User._id).ensure(User._name)) + .stream().collect(Collectors.toMap(UserEntity::getId, UserEntity::getName)); for (DmpUserEntity d : data) { NestedCollaboratorElasticEntity m = new NestedCollaboratorElasticEntity(); m.setId(d.getId()); m.setRole(d.getRole()); - m.setName(d.getUserId().toString()); //TODO: Get UserName + m.setName(userNameMap.getOrDefault(d.getUserId(), d.getUserId().toString())); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/BaseFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/BaseFileTransformerBuilder.java deleted file mode 100644 index 1728b5756..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/BaseFileTransformerBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.convention.ConventionService; -//import gr.cite.tools.data.builder.Builder; -//import gr.cite.tools.data.query.QueryBase; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -// -//import java.util.*; -//import java.util.function.Function; -//import java.util.stream.Collectors; -// -//public abstract class BaseFileTransformerBuilder implements Builder { -// protected final LoggerService logger; -// protected final ConventionService conventionService; -// -// public BaseFileTransformerBuilder( -// ConventionService conventionService, -// LoggerService logger -// ) { -// this.conventionService = conventionService; -// this.logger = logger; -// } -// -// public M build(D data) throws MyApplicationException { -// if (data == null) { -// //this.logger.Debug(new MapLogEntry("requested build for null item requesting fields").And("fields", directives)); -//// return default(M); -// M model = null; -// return null; //TODO -// } -// List> models = this.buildInternal(List.of(data)); -// return models.stream().map(FileTransformerBuilderItemResponse::getModel).findFirst().orElse(null); //TODO -// } -// -// public List build(List data) throws MyApplicationException{ -// List> models = this.buildInternal(data); -// return models == null ? null : models.stream().map(FileTransformerBuilderItemResponse::getModel).collect(Collectors.toList()); -// } -// -// protected abstract List> buildInternal(List data) throws MyApplicationException; -// -// public Map asForeignKey(QueryBase query, Function keySelector) throws MyApplicationException { -// this.logger.trace("Building references from query"); -// List data = query.collect(); -// this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0)); -// return this.asForeignKey(data, keySelector); -// } -// -// public Map asForeignKey(List data, Function keySelector) throws MyApplicationException { -// this.logger.trace("building references"); -// List> models = this.buildInternal(data); -// this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0)); -// return models == null ? new HashMap<>() : models.stream().collect(Collectors.toMap(x-> keySelector.apply(x.getData()), FileTransformerBuilderItemResponse::getModel)); -// } -// public Map> asMasterKey(QueryBase query,Function keySelector) throws MyApplicationException { -// this.logger.trace("Building details from query"); -// List data = query.collect(); -// this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0)); -// return this.asMasterKey(data, keySelector); -// } -// -// public Map> asMasterKey(List data, Function keySelector) throws MyApplicationException { -// this.logger.trace("building details"); -// List> models = this.buildInternal(data); -// this.logger.debug("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0)); -// Map> map = new HashMap<>(); -// if (models == null) return map; -// for (FileTransformerBuilderItemResponse model : models) { -// K key = keySelector.apply(model.getData()); -// if (!map.containsKey(key)) map.put(key, new ArrayList()); -// map.get(key).add(model.getModel()); -// } -// return map; -// } -//} -// diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionFieldFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionFieldFileTransformerBuilder.java deleted file mode 100644 index 14e5f351c..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionFieldFileTransformerBuilder.java +++ /dev/null @@ -1,265 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import com.fasterxml.jackson.databind.ObjectMapper; -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.types.description.FieldEntity; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel; -//import eu.eudat.file.transformer.models.descriptiontemplate.definition.*; -//import eu.eudat.service.fielddatahelper.FieldDataHelperServiceProvider; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.*; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class DescriptionFieldFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// private DescriptionTemplateFileTransformerModel definition; -// private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider; -// -// @Autowired -// public DescriptionFieldFileTransformerBuilder( -// ConventionService conventionService, FieldDataHelperServiceProvider fieldDataHelperServiceProvider -// ) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFieldFileTransformerBuilder.class))); -// this.fieldDataHelperServiceProvider = fieldDataHelperServiceProvider; -// } -// -// public DescriptionFieldFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// public DescriptionFieldFileTransformerBuilder setDefinition(DescriptionTemplateFileTransformerModel definition) { -// this.definition = definition; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// // List> models = new ArrayList<>(); -// ObjectMapper objectMapper = new ObjectMapper(); -// for (FieldEntity d : data) { -// // DescriptionFieldDepositModel m = new DescriptionFieldDepositModel(); -// if (definition != null){ -// //TODO Update with the new logic of property definition -//// FieldFileTransformerModel fieldEntity = findFieldById(d.getKey()); -// FieldFileTransformerModel fieldEntity = new FieldFileTransformerModel(); -// if (fieldEntity != null){ -// //m.setSchematics(fieldEntity.getSchematics()); -// if (fieldEntity.getData() != null) { -// /*boolean isMultiValue = fieldDataHelperServiceProvider.get(eu.eudat.commons.enums.FieldType.of(fieldEntity.getData().getFieldType().getValue())).isMultiValue(fieldEntity.getData()); -// if (!isMultiValue) fieldEntity.getData().setValue(List.of(d.getValue()); -// else { -// fieldEntity.getData().setValue(d.getValue()); -// } -// */ -// /*switch (field.getData().getFieldType()) { -// case AUTO_COMPLETE -> m.setFieldType(FieldType.AUTO_COMPLETE); -// case WORD_LIST -> m.setFieldType(FieldType.WORD_LIST); -// case BOOLEAN_DECISION -> m.setFieldType(FieldType.BOOLEAN_DECISION); -// 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 CHECK_BOX -> m.setFieldType(FieldType.CHECK_BOX); -// case FREE_TEXT -> m.setFieldType(FieldType.FREE_TEXT); -// case TEXT_AREA -> m.setFieldType(FieldType.TEXT_AREA); -// case RICH_TEXT_AREA -> m.setFieldType(FieldType.RICH_TEXT_AREA); -// case UPLOAD -> m.setFieldType(FieldType.UPLOAD); -// case DATE_PICKER -> m.setFieldType(FieldType.DATE_PICKER); -// case EXTERNAL_DATASETS -> m.setFieldType(FieldType.EXTERNAL_DATASETS); -// case DATA_REPOSITORIES -> m.setFieldType(FieldType.DATA_REPOSITORIES); -// case JOURNAL_REPOSITORIES -> m.setFieldType(FieldType.JOURNAL_REPOSITORIES); -// case PUB_REPOSITORIES -> m.setFieldType(FieldType.PUB_REPOSITORIES); -// case LICENSES -> m.setFieldType(FieldType.LICENSES); -// case PUBLICATIONS -> m.setFieldType(FieldType.PUBLICATIONS); -// case REGISTRIES -> m.setFieldType(FieldType.REGISTRIES); -// case SERVICES -> m.setFieldType(FieldType.SERVICES); -// case TAGS -> m.setFieldType(FieldType.TAGS); -// case RESEARCHERS -> m.setFieldType(FieldType.RESEARCHERS); -// case ORGANIZATIONS -> m.setFieldType(FieldType.ORGANIZATIONS); -// case DATASET_IDENTIFIER -> m.setFieldType(FieldType.DATASET_IDENTIFIER); -// case CURRENCY -> m.setFieldType(FieldType.CURRENCY); -// case VALIDATION -> m.setFieldType(FieldType.VALIDATION); -// case TAXONOMIES -> m.setFieldType(FieldType.TAXONOMIES); -// default -> throw new MyApplicationException("unrecognized type " + field.getData().getFieldType()); -// }*/ -// } -// } -// } -// //models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// -// for (PageFileTransformerModel page : definition.getDefinition().getPages()) { -// page.setSections(calculateSectionVisibility(page.getSections())); -// } -// -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// -// return List.of(new FileTransformerBuilderItemResponse<>(definition, data.get(0))); -// } -// -// private FieldFileTransformerModel findFieldById(String id) { -// FieldFileTransformerModel result = null; -// List pages = definition.getDefinition().getPages(); -// for (PageFileTransformerModel page: pages) { -// if (page.getSections() != null && !page.getSections().isEmpty()) { -// result = findSectionFieldById(id, page.getSections()); -// if (result != null) { -// break; -// } -// } -// } -// return result; -// } -// -// private FieldFileTransformerModel findSectionFieldById(String id, List sections) { -// FieldFileTransformerModel result = null; -// for (SectionFileTransformerModel section: sections) { -// if (section.getSections() != null && !section.getSections().isEmpty()) { -// result = findSectionFieldById(id, section.getSections()); -// } -// if (result == null) { -// List fieldSets = section.getFieldSets(); -// if (fieldSets != null && !fieldSets.isEmpty()) { -// for (FieldSetFileTransformerModel fieldSet : fieldSets) { -// List fields = fieldSet.getFields(); -// if (fields != null && !fields.isEmpty()) { -// for (FieldFileTransformerModel field : fields) { -// if (field.getId().equals(id)) { -// result = field; -// break; -// } -// } -// } -// if (result != null) { -// break; -// } -// } -// } -// } -// } -// return result; -// } -// -// private List calculateSectionVisibility(List sections) { -// List result = new ArrayList<>(); -// -// for (SectionFileTransformerModel section : sections) { -// if (section.getSections() != null && !section.getSections().isEmpty()) { -// section.setSections(calculateSectionVisibility(section.getSections())); -// } -// -// if (section.getFieldSets() != null && !section.getFieldSets().isEmpty()) { -// section.setFieldSets(calculateFieldSetVisibility(section.getFieldSets())); -// } -// -// if ((section.getSections() != null && !section.getSections().isEmpty()) || (section.getFieldSets() != null && !section.getFieldSets().isEmpty())) { -// result.add(section); -// } -// } -// -// return result; -// } -// -// private List calculateFieldSetVisibility(List fieldSets) { -// List result = new ArrayList<>(); -// for (FieldSetFileTransformerModel fieldSet : fieldSets) { -// if (fieldSet.getFields() != null && !fieldSet.getFields().isEmpty()) { -// fieldSet.setFields(calculateFieldVisibility(fieldSet.getFields())); -// if (fieldSet.getFields() != null && !fieldSet.getFields().isEmpty()) { -// result.add(fieldSet); -// } -// } -// } -// return result; -// } -// -// private List calculateFieldVisibility(List fields) { -// List result = new ArrayList<>(); -// for (FieldFileTransformerModel field : fields) { -// if (field.getVisibilityRules() != null && !field.getVisibilityRules().isEmpty()) { -// Integer maxChecks = field.getVisibilityRules().size(); -// Integer successfulChecks = 0; -// for (RuleFileTransformerModel rule : field.getVisibilityRules()) { -// FieldFileTransformerModel targetField = findFieldByPages(definition.getDefinition().getPages(), rule.getTarget()); -// if (targetField.getData() != null ) { -// successfulChecks = targetField.getData().getValue().equals(rule.getValue()) ? successfulChecks + 1 : successfulChecks; -// } -// } -// if (successfulChecks.equals(maxChecks)) { -// result.add(field); -// } -// } else { -// result.add(field); -// } -// } -// return result; -// } -// -// private FieldFileTransformerModel findFieldByPages(List pages, String fieldId) { -// FieldFileTransformerModel result = null; -// for (PageFileTransformerModel page : pages) { -// result = findFieldBySections(page.getSections(), fieldId); -// if (result != null) { -// break; -// } -// } -// return result; -// } -// -// private FieldFileTransformerModel findFieldBySections(List sections, String fieldId) { -// FieldFileTransformerModel result = null; -// for (SectionFileTransformerModel section : sections) { -// if (section.getSections() != null && !section.getSections().isEmpty()) { -// result = findFieldBySections(section.getSections(), fieldId); -// if (result != null) { -// break; -// } -// } -// -// if (section.getFieldSets() != null && !section.getFieldSets().isEmpty()) { -// result = findFieldByFieldSets(section.getFieldSets(), fieldId); -// if (result != null) { -// break; -// } -// } -// } -// return result; -// } -// -// private FieldFileTransformerModel findFieldByFieldSets(List fieldSets, String fieldId) { -// FieldFileTransformerModel result = null; -// for (FieldSetFileTransformerModel fieldSet: fieldSets) { -// result = findField(fieldSet.getFields(), fieldId); -// if (result != null) { -// break; -// } -// } -// return result; -// } -// -// private FieldFileTransformerModel findField(List fields, String fieldId) { -// FieldFileTransformerModel result = null; -// for (FieldFileTransformerModel field: fields) { -// if (field.getId().equals(fieldId)) { -// result = field; -// break; -// } -// } -// return result; -// } -// -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionFileTransformerBuilder.java deleted file mode 100644 index 95b62c927..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionFileTransformerBuilder.java +++ /dev/null @@ -1,167 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.JsonHandlingService; -//import eu.eudat.commons.XmlHandlingService; -//import eu.eudat.commons.enums.IsActive; -//import eu.eudat.commons.types.description.PropertyDefinitionEntity; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.*; -//import eu.eudat.file.transformer.enums.DescriptionStatus; -//import eu.eudat.file.transformer.models.description.DescriptionFileTransformerModel; -//import eu.eudat.file.transformer.models.description.DescriptionReferenceFileTransformerModel; -//import eu.eudat.file.transformer.models.description.DescriptionTagFileTransformerModel; -//import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel; -//import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel; -//import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel; -//import eu.eudat.file.transformer.models.tag.TagFileTransformerModel; -//import eu.eudat.model.DescriptionReference; -//import eu.eudat.model.DescriptionTemplate; -//import eu.eudat.model.DmpReference; -//import eu.eudat.query.*; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.data.query.QueryFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.fieldset.BaseFieldSet; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.*; -//import java.util.stream.Collectors; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class DescriptionFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final QueryFactory queryFactory; -// -// private final BuilderFactory builderFactory; -// private final JsonHandlingService jsonHandlingService; -// -// private final XmlHandlingService xmlHandlingService; -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public DescriptionFileTransformerBuilder( -// ConventionService conventionService, -// QueryFactory queryFactory, -// BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionFileTransformerBuilder.class))); -// this.queryFactory = queryFactory; -// this.builderFactory = builderFactory; -// this.jsonHandlingService = jsonHandlingService; -// this.xmlHandlingService = xmlHandlingService; -// } -// -// public DescriptionFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// List definitionMap = this.collectDescriptionTemplates(data); -// Map> referenceMap = collectReferences(data); -// Map> tagMap = collectTags(data); -// -// -// DmpFileTransformerModel dmp = this.getDmp(data.get(0).getDmpId()); -// -// -// List> models = new ArrayList<>(); -// for (DescriptionEntity d : data) { -// DescriptionFileTransformerModel m = new DescriptionFileTransformerModel(); -// m.setId(d.getId()); -// m.setLabel(d.getLabel()); -// m.setLabel(d.getLabel()); -// m.setDescription(d.getDescription()); -// m.setCreatedAt(d.getCreatedAt()); -// m.setFinalizedAt(d.getFinalizedAt()); -// m.setUpdatedAt(d.getUpdatedAt()); -// m.setStatus(DescriptionStatus.of(d.getStatus().getValue())); -// if (d.getProperties() != null){ -// PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties()); -// -// //TODO Update with the new logic of property definition -//// if (definitionMap != null && definitionMap.stream().anyMatch(dt -> dt.getId().equals(d.getDescriptionTemplateId())) && propertyDefinition != null && !this.conventionService.isListNullOrEmpty(propertyDefinition.getFields())) m.setDescriptionTemplate(this.builderFactory.builder(DescriptionFieldFileTransformerBuilder.class).authorize(this.authorize).setDefinition(definitionMap.stream().filter(dm -> dm.getId().equals(d.getDescriptionTemplateId())).findFirst().get()).build(propertyDefinition.getFields()).get(0)); -// } -// if (referenceMap != null && !referenceMap.isEmpty() && referenceMap.containsKey(d.getId())) m.setDescriptionReferenceFileTransformerModels(referenceMap.get(d.getId())); -// if (tagMap != null && !tagMap.isEmpty() && tagMap.containsKey(d.getId())) m.setDescriptionTagFileTransformerModels(tagMap.get(d.getId())); -// -// m.setDmp(dmp); -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// -// return models; -// } -// -// private DmpFileTransformerModel getDmp(UUID id) { -// DmpQuery query = queryFactory.query(DmpQuery.class).authorize(authorize).isActive(IsActive.Active).ids(id); -// return builderFactory.builder(DmpFileTransformerBuilder.class).ignoreDescriptions(true).authorize(authorize).build(query.first()); -// } -// -// private List collectDescriptionTemplates(List data) throws MyApplicationException { -// if (data.isEmpty()) -// return null; -// this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName()); -// -// List descriptionTemplateEntities = this.queryFactory.query(DescriptionTemplateQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDescriptionTemplateId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionTemplate._id).ensure(DescriptionTemplate._definition)); -// -// return this.builderFactory.builder(DescriptionTemplateFileTransformerBuilder.class).authorize(authorize).build(descriptionTemplateEntities); -// } -// -// private Map> collectReferences(List data) throws MyApplicationException { -// if (data.isEmpty()) return null; -// this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); -// -// List descriptionReferences = this.queryFactory.query(DescriptionReferenceQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DescriptionReference._description).ensure(DescriptionReference._reference)); -// -// Map> itemMap = new HashMap<>(); -// ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(descriptionReferences.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); -// Map referenceDepositModelMap = this.builderFactory.builder(ReferenceFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId); -// if (referenceDepositModelMap == null) return null; -// for (DescriptionReferenceEntity descriptionReference : descriptionReferences) { -// DescriptionReferenceFileTransformerModel descriptionReferenceFileTransformerModel = new DescriptionReferenceFileTransformerModel(); -// descriptionReferenceFileTransformerModel.setId(descriptionReference.getId()); -// descriptionReferenceFileTransformerModel.setReference(referenceDepositModelMap.getOrDefault(descriptionReference.getReferenceId(), null)); -// DescriptionReferenceFileTransformerModel model = descriptionReferenceFileTransformerModel; -// if (model == null) continue; -// UUID key = descriptionReference.getDescriptionId(); -// if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>()); -// itemMap.get(key).add(model); -// } -// return itemMap; -// } -// -// private Map> collectTags(List data) { -// if (data.isEmpty()) return null; -// -// List descriptionTags = this.queryFactory.query(DescriptionTagQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().toList()).collect(); -// -// Map> itemMap = new HashMap<>(); -// TagQuery query = this.queryFactory.query(TagQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(descriptionTags.stream().map(DescriptionTagEntity::getTagId).distinct().toList()); -// Map tagMap = this.builderFactory.builder(TagFileTransformerBuilder.class).asForeignKey(query, TagEntity::getId); -// for (DescriptionTagEntity descriptionTag : descriptionTags) { -// DescriptionTagFileTransformerModel descriptionTagFileTransformerModel = new DescriptionTagFileTransformerModel(); -// descriptionTagFileTransformerModel.setId(descriptionTag.getId()); -// descriptionTagFileTransformerModel.setTagFileTransformerModel(tagMap.getOrDefault(descriptionTag.getTagId(), null)); -// DescriptionTagFileTransformerModel model = descriptionTagFileTransformerModel; -// if (model == null) continue; -// UUID key = descriptionTag.getDescriptionId(); -// if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>()); -// itemMap.get(key).add(model); -// } -// -// return itemMap; -// } -// -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionTemplateDefinitionFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionTemplateDefinitionFileTransformerBuilder.java deleted file mode 100644 index 737c68302..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionTemplateDefinitionFileTransformerBuilder.java +++ /dev/null @@ -1,243 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.JsonHandlingService; -//import eu.eudat.commons.XmlHandlingService; -//import eu.eudat.commons.types.descriptiontemplate.*; -//import eu.eudat.commons.types.descriptiontemplate.fielddata.*; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.file.transformer.enums.FieldDataExternalDatasetType; -//import eu.eudat.file.transformer.enums.FieldType; -//import eu.eudat.file.transformer.enums.FieldValidationType; -//import eu.eudat.file.transformer.models.descriptiontemplate.definition.*; -//import eu.eudat.file.transformer.models.descriptiontemplate.definition.fielddata.*; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.data.query.QueryFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.ArrayList; -//import java.util.EnumSet; -//import java.util.List; -//import java.util.Optional; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class DescriptionTemplateDefinitionFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final QueryFactory queryFactory; -// -// private final BuilderFactory builderFactory; -// private final JsonHandlingService jsonHandlingService; -// -// private final XmlHandlingService xmlHandlingService; -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public DescriptionTemplateDefinitionFileTransformerBuilder( -// ConventionService conventionService, -// QueryFactory queryFactory, -// BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateDefinitionFileTransformerBuilder.class))); -// this.queryFactory = queryFactory; -// this.builderFactory = builderFactory; -// this.jsonHandlingService = jsonHandlingService; -// this.xmlHandlingService = xmlHandlingService; -// } -// -// public DescriptionTemplateDefinitionFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// List> models = new ArrayList<>(); -// for (DefinitionEntity d : data) { -// DefinitionFileTransformerModel m = new DefinitionFileTransformerModel(); -// m.setPages(collectPages(d.getPages())); -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// -// return models; -// } -// -// private List collectPages(List data) { -// List result = new ArrayList<>(); -// for (PageEntity d: data) { -// PageFileTransformerModel m = new PageFileTransformerModel(); -// m.setId(d.getId()); -// m.setOrdinal(d.getOrdinal()); -// m.setTitle(d.getTitle()); -// if (d.getSections() != null) m.setSections(collectSections(d.getSections())); -// result.add(m); -// } -// -// return result; -// } -// -// private List collectSections(List data) { -// List result = new ArrayList<>(); -// for (SectionEntity d : data) { -// SectionFileTransformerModel m = new SectionFileTransformerModel(); -// m.setId(d.getId()); -// m.setDescription(d.getDescription()); -// m.setTitle(d.getTitle()); -// m.setOrdinal(d.getOrdinal()); -// m.setDefaultVisibility(d.isDefaultVisibility()); -// m.setExtendedDescription(d.getExtendedDescription()); -// m.setMultiplicity(d.getMultiplicity()); -// m.setNumbering(d.getNumbering()); -// if (d.getSections() != null && !d.getSections().isEmpty()) { -// m.setSections(collectSections(d.getSections())); -// } -// if (d.getFieldSets() != null && !d.getFieldSets().isEmpty()) { -// m.setFieldSets(collectFieldSet(d.getFieldSets())); -// } -// result.add(m); -// } -// return result; -// } -// -// private List collectFieldSet(List data) { -// List result = new ArrayList<>(); -// for (FieldSetEntity d : data) { -// FieldSetFileTransformerModel m = new FieldSetFileTransformerModel(); -// m.setId(d.getId()); -// m.setDescription(d.getDescription()); -// m.setExtendedDescription(d.getExtendedDescription()); -// m.setAdditionalInformation(d.getAdditionalInformation()); -// m.setHasCommentField(d.getHasCommentField()); -// m.setNumbering(d.getNumbering()); -// m.setOrdinal(d.getOrdinal()); -// m.setTitle(d.getTitle()); -// //m.setMultiplicity(); //TODO: No multiplicity in this code (yet) -// m.setFields(convertFields(d.getFields())); -// result.add(m); -// } -// return result; -// } -// -// private List convertFields(List data) { -// List result = new ArrayList<>(); -// for (FieldEntity d : data) { -// FieldFileTransformerModel m = new FieldFileTransformerModel(); -// m.setId(d.getId()); -// m.setSchematics(d.getSchematics()); -// m.setNumbering(d.getNumbering()); -// m.setOrdinal(d.getOrdinal()); -// m.setDefaultValue(d.getDefaultValue()); -// m.setIncludeInExport(d.getIncludeInExport()); -// m.setValidations(d.getValidations().stream().map(fieldValidationType -> FieldValidationType.of(fieldValidationType.getValue())).toList()); -// if (d.getVisibilityRules() != null && !d.getVisibilityRules().isEmpty()) { -// m.setVisibilityRules(convertVisibilityRules(d.getVisibilityRules())); -// } -// m.setData(convertData(d.getData())); -// result.add(m); -// } -// return result; -// } -// -// public List convertVisibilityRules(List data) { -// List result = new ArrayList<>(); -// for (RuleEntity d : data) { -// RuleFileTransformerModel m = new RuleFileTransformerModel(); -// m.setTarget(d.getTarget()); -// m.setValue(d.getValue()); -// result.add(m); -// } -// return result; -// } -// -// public BaseFieldDataFileTransformerModel convertData (BaseFieldDataEntity data) { -// BaseFieldDataFileTransformerModel m; -// switch (data) { //TODO new reference logic -//// case ExternalSelectDataEntity d -> { -//// m = new ExternalSelectDataFileTransformerModel(); -//// m.setLabel(d.getLabel()); -//// m.setFieldType(FieldType.of(d.getFieldType().getValue())); -//// ((ExternalSelectDataFileTransformerModel)m).setMultipleSelect(d.getMultipleSelect()); -//// ((ExternalSelectDataFileTransformerModel) m).setSources(convertAutoCompleteSingleData(d.getSources())); -//// } -//// case ExternalDatasetDataEntity d -> { -//// m = new ExternalDatasetDataFileTransformerModel(); -//// m.setLabel(d.getLabel()); -//// m.setFieldType(FieldType.of(d.getFieldType().getValue())); -//// ((ExternalDatasetDataFileTransformerModel)m).setType(FieldDataExternalDatasetType.of(d.getType().getValue())); -//// } -// case RadioBoxDataEntity d -> { -// m = new RadioBoxDataFileTransformerModel(); -// m.setLabel(d.getLabel()); -// m.setFieldType(FieldType.of(d.getFieldType().getValue())); -// ((RadioBoxDataFileTransformerModel) m).setOptions(convertRadioBoxOptions(d.getOptions())); -// } -// case UploadDataEntity d -> { -// m = new UploadDataFileTransformerModel(); -// m.setLabel(d.getLabel()); -// m.setFieldType(FieldType.of(d.getFieldType().getValue())); -// ((UploadDataFileTransformerModel) m).setMaxFileSizeInMB(d.getMaxFileSizeInMB()); -// ((UploadDataFileTransformerModel) m).setTypes(convertUploadDataOptions(d.getTypes())); -// } -// case SelectDataEntity d -> { -// m = new SelectDataFileTransformerModel(); -// m.setLabel(d.getLabel()); -// m.setFieldType(FieldType.of(d.getFieldType().getValue())); -// ((SelectDataFileTransformerModel) m).setMultipleSelect(d.getMultipleSelect()); -// ((SelectDataFileTransformerModel) m).setOptions(d.getOptions().stream().map(this::convertComboBoxOption).toList()); -// } -// case LabelAndMultiplicityDataEntity d -> { -// m = new LabelAndMultiplicityDataFileTransformerModel(); -// m.setLabel(d.getLabel()); -// m.setFieldType(FieldType.of(d.getFieldType().getValue())); -// ((LabelAndMultiplicityDataFileTransformerModel)m).setMultipleSelect(d.getMultipleSelect()); -// } -// default -> { -// m = new LabelDataFileTransformerModel(); -// m.setLabel(data.getLabel()); -// m.setFieldType(FieldType.of(data.getFieldType().getValue())); -// } -// } -// return m; -// } -// -// private List convertRadioBoxOptions(List data) { -// List result = new ArrayList<>(); -// for (RadioBoxDataEntity.RadioBoxDataOptionEntity d : data) { -// RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel m = new RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel(); -// m.setLabel(d.getLabel()); -// m.setValue(d.getValue()); -// result.add(m); -// } -// return result; -// } -// -// private SelectDataFileTransformerModel.OptionFileTransformerModel convertComboBoxOption(SelectDataEntity.OptionEntity data) { -// SelectDataFileTransformerModel.OptionFileTransformerModel m = new SelectDataFileTransformerModel.OptionFileTransformerModel(); -// m.setLabel(data.getLabel()); -// m.setValue(data.getValue()); -// return m; -// } -// -// private List convertUploadDataOptions(List data) { -// List result = new ArrayList<>(); -// for (UploadDataEntity.UploadDataOptionEntity d : data) { -// UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel m = new UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel(); -// m.setLabel(d.getLabel()); -// m.setValue(d.getValue()); -// result.add(m); -// } -// return result; -// } -// -// -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionTemplateFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionTemplateFileTransformerBuilder.java deleted file mode 100644 index d6038f986..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DescriptionTemplateFileTransformerBuilder.java +++ /dev/null @@ -1,83 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.JsonHandlingService; -//import eu.eudat.commons.XmlHandlingService; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.DescriptionTemplateEntity; -//import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel; -//import eu.eudat.query.DescriptionTemplateQuery; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.data.query.QueryFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.ArrayList; -//import java.util.EnumSet; -//import java.util.List; -//import java.util.Optional; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class DescriptionTemplateFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final QueryFactory queryFactory; -// -// private final BuilderFactory builderFactory; -// private final JsonHandlingService jsonHandlingService; -// -// private final XmlHandlingService xmlHandlingService; -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public DescriptionTemplateFileTransformerBuilder( -// ConventionService conventionService, -// QueryFactory queryFactory, -// BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateFileTransformerBuilder.class))); -// this.queryFactory = queryFactory; -// this.builderFactory = builderFactory; -// this.jsonHandlingService = jsonHandlingService; -// this.xmlHandlingService = xmlHandlingService; -// } -// -// public DescriptionTemplateFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// data = queryFactory.query(DescriptionTemplateQuery.class).ids(data.stream().map(DescriptionTemplateEntity::getId).toList()).collect(); -// List> models = new ArrayList<>(); -// for (DescriptionTemplateEntity d : data) { -// -// DescriptionTemplateFileTransformerModel m = new DescriptionTemplateFileTransformerModel(); -// m.setId(d.getId()); -// m.setLabel(d.getLabel()); -// m.setDescription(d.getDescription()); -// m.setLanguage(d.getLanguage()); -// m.setVersion(d.getVersion()); -// m.setDefinition(this.builderFactory.builder(DescriptionTemplateDefinitionFileTransformerBuilder.class).authorize(authorize).build(collectDescriptionTemplates(d))); -// -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// -// return models; -// } -// -// private eu.eudat.commons.types.descriptiontemplate.DefinitionEntity collectDescriptionTemplates(DescriptionTemplateEntity data) throws MyApplicationException { -// return this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, data.getDefinition()); -// } -// -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpBlueprintFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpBlueprintFileTransformerBuilder.java deleted file mode 100644 index 590cf07df..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpBlueprintFileTransformerBuilder.java +++ /dev/null @@ -1,129 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import com.fasterxml.jackson.core.JsonProcessingException; -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.JsonHandlingService; -//import eu.eudat.commons.XmlHandlingService; -//import eu.eudat.commons.types.dmpblueprint.*; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.DmpBlueprintEntity; -//import eu.eudat.file.transformer.enums.DmpBlueprintExtraFieldDataType; -//import eu.eudat.file.transformer.enums.DmpBlueprintSystemFieldType; -//import eu.eudat.file.transformer.models.dmpblueprint.DmpBlueprintFileTransformerModel; -//import eu.eudat.file.transformer.models.dmpblueprint.definition.*; -//import eu.eudat.query.DmpBlueprintQuery; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.data.query.QueryFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.apache.commons.lang3.NotImplementedException; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.*; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class DmpBlueprintFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final QueryFactory queryFactory; -// -// private final BuilderFactory builderFactory; -// private final JsonHandlingService jsonHandlingService; -// -// private final XmlHandlingService xmlHandlingService; -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public DmpBlueprintFileTransformerBuilder( -// ConventionService conventionService, -// QueryFactory queryFactory, -// BuilderFactory builderFactory, JsonHandlingService jsonHandlingService, XmlHandlingService xmlHandlingService) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintFileTransformerBuilder.class))); -// this.queryFactory = queryFactory; -// this.builderFactory = builderFactory; -// this.jsonHandlingService = jsonHandlingService; -// this.xmlHandlingService = xmlHandlingService; -// } -// -// public DmpBlueprintFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// data = queryFactory.query(DmpBlueprintQuery.class).ids(data.stream().map(DmpBlueprintEntity::getId).toList()).collect(); -// List> models = new ArrayList<>(); -// for (DmpBlueprintEntity d : data) { -// -// DmpBlueprintFileTransformerModel m = new DmpBlueprintFileTransformerModel(); -// m.setId(d.getId()); -// m.setLabel(d.getLabel()); -// try { -// m.setDefinitionFileTransformerModel(getDefinition(d.getDefinition())); -// } catch (JsonProcessingException e) { -// logger.error(e.getMessage(), e); -// } -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// -// return models; -// } -// -// private DefinitionFileTransformerModel getDefinition(String source) throws JsonProcessingException { -// DefinitionFileTransformerModel result = new DefinitionFileTransformerModel(); -// result.setSections(new ArrayList<>()); -// DefinitionEntity parsedDefinition = xmlHandlingService.fromXmlSafe(DefinitionEntity.class, source); -// List sections = parsedDefinition.getSections(); -// sections.forEach(section -> { -// SectionFileTransformerModel m = new SectionFileTransformerModel(); -// m.setId(section.getId()); -// m.setLabel(section.getLabel()); -// m.setOrdinal(section.getOrdinal()); -// m.setDescription(section.getDescription()); -// if (section.getFields() != null && !section.getFields().isEmpty()) { -// m.setFields(mapFields(section.getFields())); -// } -// m.setHasTemplates(section.getHasTemplates()); -// result.getSections().add(m); -// }); -// -// return result; -// } -// -// private List mapFields(List fieldEntities) { -// List result = new ArrayList<>(); -// fieldEntities.forEach(fieldEntity -> { -// FieldFileTransformerModel m = switch (fieldEntity.getCategory()) { -// case System -> new SystemFieldFileTransformerModel(); -// case Extra -> new ExtraFieldFileTransformerModelFileTransformerModel(); -// case ReferenceType -> throw new NotImplementedException("ReferenceFieldFileTransformerModel"); -// default -> throw new MyApplicationException("unrecognized type " + fieldEntity.getCategory()); -// }; -// m.setId(fieldEntity.getId()); -// m.setLabel(fieldEntity.getLabel()); -// m.setDescription(fieldEntity.getDescription()); -// m.setOrdinal(fieldEntity.getOrdinal()); -// m.setPlaceholder(fieldEntity.getPlaceholder()); -// m.setRequired(fieldEntity.isRequired()); -// switch (m) { -// case SystemFieldFileTransformerModel sm -> sm.setSystemFieldType(DmpBlueprintSystemFieldType.of(((SystemFieldEntity)fieldEntity).getType().getValue())); -// case ExtraFieldFileTransformerModelFileTransformerModel sm -> sm.setDataType(DmpBlueprintExtraFieldDataType.of(((ExtraFieldEntity)fieldEntity).getType().getValue())); -//// case ReferenceFieldFileTransformerModelFileTransformerModel sm -> sm.setReferenceTypeId(((ReferenceFieldEntity)fieldEntity).getReferenceTypeId()); -// default -> throw new MyApplicationException("unrecognized type " + fieldEntity.getCategory()); -// } -// result.add(m); -// }); -// return result; -// } -// -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpFileTransformerBuilder.java deleted file mode 100644 index e7e97dc20..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpFileTransformerBuilder.java +++ /dev/null @@ -1,200 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.enums.IsActive; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.*; -//import eu.eudat.file.transformer.enums.DmpAccessType; -//import eu.eudat.file.transformer.enums.DmpStatus; -//import eu.eudat.file.transformer.enums.DmpVersionStatus; -//import eu.eudat.file.transformer.models.description.DescriptionFileTransformerModel; -//import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel; -//import eu.eudat.file.transformer.models.dmp.DmpReferenceFileTransformerModel; -//import eu.eudat.file.transformer.models.dmp.DmpUserFileTransformerModel; -//import eu.eudat.file.transformer.models.dmpblueprint.DmpBlueprintFileTransformerModel; -//import eu.eudat.file.transformer.models.dmpblueprint.definition.SectionFileTransformerModel; -//import eu.eudat.file.transformer.models.entitydoi.EntityDoiFileTransformerModel; -//import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel; -//import eu.eudat.file.transformer.models.user.UserFileTransformerModel; -//import eu.eudat.model.*; -//import eu.eudat.model.builder.DmpReferenceBuilder; -//import eu.eudat.query.*; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.data.query.Ordering; -//import gr.cite.tools.data.query.QueryFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.fieldset.BaseFieldSet; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.time.Instant; -//import java.util.*; -//import java.util.stream.Collectors; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class DmpFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final QueryFactory queryFactory; -// private final BuilderFactory builderFactory; -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// private Boolean ignoreDescriptions = false; -// -// @Autowired -// public DmpFileTransformerBuilder(ConventionService conventionService, -// QueryFactory queryFactory, -// BuilderFactory builderFactory) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpFileTransformerBuilder.class))); -// this.queryFactory = queryFactory; -// this.builderFactory = builderFactory; -// } -// -// public DmpFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// public DmpFileTransformerBuilder ignoreDescriptions(Boolean ignoreDescriptions) { -// this.ignoreDescriptions = ignoreDescriptions; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// List> models = new ArrayList<>(); -// -// Map> dmpReferencesMap = this.collectReferences(data); -// -// Map> dmpUsersMap = this.collectDmpUsers(data); -// -// Map> descriptionsMap = null; -// if (!ignoreDescriptions) { -// descriptionsMap = this.collectDmpDescriptions(data); -// } -// -// Map> doiMap = this.collectEntityDois(data); -// Map creatorMap = this.collectCreators(data); -// Map blueprintMap = this.collectBlueprints(data); -// -// for (DmpEntity d : data) { -// DmpFileTransformerModel m = new DmpFileTransformerModel(); -// m.setId(d.getId()); -// m.setLabel(d.getLabel()); -// m.setVersion(d.getVersion()); -// m.setDescription(d.getDescription()); -// m.setFinalizedAt(d.getFinalizedAt()); -// m.setCreatedAt(d.getCreatedAt()); -// if (d.getPublicAfter() != null && d.getPublicAfter().isAfter(Instant.now())) { -// m.setPublishedAt(d.getPublicAfter()); -// } -// switch (d.getAccessType()){ -// case Public -> m.setAccessType(DmpAccessType.Public); -// case Restricted -> m.setAccessType(DmpAccessType.Restricted); -// case null -> m.setAccessType(null); -// default -> throw new MyApplicationException("unrecognized type " + d.getAccessType().getValue()); -// } -// -// m.setProperties(d.getProperties()); -// m.setUpdatedAt(d.getUpdatedAt()); -// m.setLanguage(d.getLanguage()); -// m.setStatus(DmpStatus.of(d.getStatus().getValue())); -// m.setVersionStatus(DmpVersionStatus.of(d.getVersionStatus().getValue())); -// if (dmpReferencesMap != null && !dmpReferencesMap.isEmpty() && dmpReferencesMap.containsKey(d.getId())) m.setDmpReferences(dmpReferencesMap.get(d.getId())); -// if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId())); -// if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId())); -// if (doiMap != null && !doiMap.isEmpty() && doiMap.containsKey(d.getId())) m.setEntityDois(doiMap.get(d.getId())); -// if (creatorMap != null && !creatorMap.isEmpty() && creatorMap.containsKey(d.getId())) m.setCreator(creatorMap.get(d.getId())); -// if (blueprintMap != null && !blueprintMap.isEmpty() && blueprintMap.containsKey(d.getBlueprintId())) m.setBlueprint(blueprintMap.get(d.getBlueprintId())); -// -// SectionFileTransformerModel templateSection = m.getBlueprint().getDefinitionFileTransformerModel().getSections().stream().filter(SectionFileTransformerModel::getHasTemplates).findFirst().orElse(null); -// if (templateSection != null && m.getDescriptions() != null && !m.getDescriptions().isEmpty()) { -// m.getDescriptions().forEach(description -> { -// description.setSectionId(templateSection.getId()); -// description.setCreatedBy(m.getCreator()); -// }); -// } -// -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// -// return models; -// } -// -// private Map> collectReferences(List data) throws MyApplicationException { -// if (data.isEmpty()) return null; -// this.logger.debug("checking related - {}", DmpReference.class.getSimpleName()); -// -// List dmpReferences = this.queryFactory.query(DmpReferenceQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())).collectAs(new BaseFieldSet().ensure(DmpReference._dmp).ensure(DmpReference._reference)); -// -// Map> itemMap = new HashMap<>(); -// ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).isActive(IsActive.Active).ids(dmpReferences.stream().map(DmpReferenceEntity::getReferenceId).distinct().collect(Collectors.toList())); -// Map referenceDepositModelMap = this.builderFactory.builder(ReferenceFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId); -// if (referenceDepositModelMap == null) return null; -// for (DmpReferenceEntity dmpReference : dmpReferences) { -// DmpReferenceFileTransformerModel dmpReferenceFileTransformerModel = new DmpReferenceFileTransformerModel(); -// dmpReferenceFileTransformerModel.setId(dmpReference.getId()); -// dmpReferenceFileTransformerModel.setData(dmpReference.getData()); -// dmpReferenceFileTransformerModel.setReference(referenceDepositModelMap.getOrDefault(dmpReference.getReferenceId(), null)); -// DmpReferenceFileTransformerModel model = dmpReferenceFileTransformerModel; -// if (model == null) continue; -// UUID key = dmpReference.getDmpId(); -// if (!itemMap.containsKey(key)) itemMap.put(key, new ArrayList<>()); -// itemMap.get(key).add(model); -// } -// return itemMap; -// } -// -// -// private Map> collectDmpUsers(List data) throws MyApplicationException { -// this.logger.debug("checking related - {}", DmpUser.class.getSimpleName()); -// -// Map> itemMap; -// DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); -// itemMap = this.builderFactory.builder(DmpUserFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId); -// -// return itemMap; -// } -// -// private Map> collectDmpDescriptions(List data) throws MyApplicationException { -// if (data.isEmpty()) return null; -// this.logger.debug("checking related - {}", Description.class.getSimpleName()); -// -// Map> itemMap; -// DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); -// itemMap = this.builderFactory.builder(DescriptionFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId); -// -// return itemMap; -// } -// -// private Map collectCreators(List data) { -// DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).isActives(IsActive.Active).authorize(this.authorize).userIds(data.stream().map(DmpEntity::getCreatorId).toList()); -// return this.builderFactory.builder(DmpUserFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpUserEntity::getDmpId) -// .entrySet().stream().map(uuidListEntry -> Map.entry(uuidListEntry.getKey(), uuidListEntry.getValue().get(0).getUser())) -// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); -// } -// -// private Map collectBlueprints(List data) { -// DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpEntity::getBlueprintId).toList()); -// return this.builderFactory.builder(DmpBlueprintFileTransformerBuilder.class).authorize(this.authorize).asMasterKey(query, DmpBlueprintEntity::getId) -// .entrySet().stream().map(uuidListEntry -> Map.entry(uuidListEntry.getKey(), uuidListEntry.getValue().get(0))) -// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); -// } -// -// private Map> collectEntityDois(List data) { -// if (data.isEmpty()) return null; -// Map> result; -// EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).isActive(IsActive.Active).authorize(authorize).entityIds(data.stream().map(DmpEntity::getId).distinct().toList()); -// result = builderFactory.builder(EntityDoiFileTransformerBuilder.class).asMasterKey(query, EntityDoiEntity::getEntityId); -// return result; -// } -// -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpUserFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpUserFileTransformerBuilder.java deleted file mode 100644 index 355a12bfd..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/DmpUserFileTransformerBuilder.java +++ /dev/null @@ -1,85 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.enums.IsActive; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.DmpUserEntity; -//import eu.eudat.data.UserEntity; -//import eu.eudat.file.transformer.enums.DmpUserRole; -//import eu.eudat.file.transformer.models.dmp.DmpUserFileTransformerModel; -//import eu.eudat.file.transformer.models.user.UserFileTransformerModel; -//import eu.eudat.query.UserQuery; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.data.query.QueryFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.*; -//import java.util.stream.Collectors; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class DmpUserFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final BuilderFactory builderFactory; -// -// private final QueryFactory queryFactory; -// -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public DmpUserFileTransformerBuilder( -// ConventionService conventionService, -// BuilderFactory builderFactory, QueryFactory queryFactory) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpUserFileTransformerBuilder.class))); -// this.builderFactory = builderFactory; -// this.queryFactory = queryFactory; -// } -// -// public DmpUserFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null) -// return new ArrayList<>(); -// -// -// Map userItemsMap = this.collectUsers(data); -// -// List> models = new ArrayList<>(); -// for (DmpUserEntity d : data) { -// DmpUserFileTransformerModel m = new DmpUserFileTransformerModel(); -// m.setId(d.getId()); -// switch (d.getRole()){ -// case User -> m.setRole(DmpUserRole.User); -// case Owner -> m.setRole(DmpUserRole.Owner); -// default -> throw new MyApplicationException("unrecognized type " + d.getRole().getValue()); -// } -// if (userItemsMap != null && userItemsMap.containsKey(d.getUserId())) m.setUser(userItemsMap.get(d.getUserId())); -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// return models; -// } -// -// private Map collectUsers(List data) throws MyApplicationException { -// if (data.isEmpty()) -// return null; -// this.logger.debug("checking related - {}", UserFileTransformerModel.class.getSimpleName()); -// -// Map itemMap; -// UserQuery q = this.queryFactory.query(UserQuery.class).isActive(IsActive.Active).authorize(this.authorize).ids(data.stream().map(DmpUserEntity::getUserId).distinct().collect(Collectors.toList())); -// itemMap = this.builderFactory.builder(UserFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(q, UserEntity::getId); -// return itemMap; -// } -// -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/EntityDoiFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/EntityDoiFileTransformerBuilder.java deleted file mode 100644 index b24a728fe..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/EntityDoiFileTransformerBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.EntityDoiEntity; -//import eu.eudat.file.transformer.models.entitydoi.EntityDoiFileTransformerModel; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Component; -// -//import java.util.ArrayList; -//import java.util.List; -// -//@Component -//public class EntityDoiFileTransformerBuilder extends BaseFileTransformerBuilder{ -// @Autowired -// public EntityDoiFileTransformerBuilder(ConventionService conventionService) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpFileTransformerBuilder.class))); -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// List> result = new ArrayList<>(); -// for (EntityDoiEntity d : data) { -// EntityDoiFileTransformerModel m = new EntityDoiFileTransformerModel(); -// m.setId(d.getId()); -// m.setDoi(d.getDoi()); -// m.setRepositoryId(d.getRepositoryId()); -// result.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// return result; -// } -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/FileTransformerBuilderItemResponse.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/FileTransformerBuilderItemResponse.java deleted file mode 100644 index 5236852d0..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/FileTransformerBuilderItemResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//public class FileTransformerBuilderItemResponse{ -// private final M model; -// private final D data; -// -// public FileTransformerBuilderItemResponse(M model, D data) { -// this.model = model; -// this.data = data; -// } -// -// public D getData() { -// return data; -// } -// -// public M getModel() { -// return model; -// } -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceDefinitionFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceDefinitionFileTransformerBuilder.java deleted file mode 100644 index 651371389..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceDefinitionFileTransformerBuilder.java +++ /dev/null @@ -1,54 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.types.reference.DefinitionEntity; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.file.transformer.models.reference.DefinitionFileTransformerModel; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.ArrayList; -//import java.util.EnumSet; -//import java.util.List; -//import java.util.Optional; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class ReferenceDefinitionFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final BuilderFactory builderFactory; -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public ReferenceDefinitionFileTransformerBuilder( -// ConventionService conventionService, BuilderFactory builderFactory) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceDefinitionFileTransformerBuilder.class))); -// this.builderFactory = builderFactory; -// } -// -// public ReferenceDefinitionFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// List> models = new ArrayList<>(); -// for (DefinitionEntity d : data) { -// DefinitionFileTransformerModel m = new DefinitionFileTransformerModel(); -// if (d.getFields() != null) m.setFields(this.builderFactory.builder(ReferenceFieldFileTransformerBuilder.class).authorize(this.authorize).build(d.getFields())); -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// return models; -// } -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceFieldFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceFieldFileTransformerBuilder.java deleted file mode 100644 index 77623cee6..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceFieldFileTransformerBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.types.reference.FieldEntity; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.file.transformer.models.reference.FieldFileTransformerModel; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.ArrayList; -//import java.util.EnumSet; -//import java.util.List; -//import java.util.Optional; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class ReferenceFieldFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public ReferenceFieldFileTransformerBuilder( -// ConventionService conventionService) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldFileTransformerBuilder.class))); -// } -// -// public ReferenceFieldFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// List> models = new ArrayList<>(); -// for (FieldEntity d : data) { -// FieldFileTransformerModel m = new FieldFileTransformerModel(); -// m.setCode(d.getCode()); -// m.setValue(d.getValue()); -// -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// return models; -// } -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceFileTransformerBuilder.java deleted file mode 100644 index da5e0e178..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/ReferenceFileTransformerBuilder.java +++ /dev/null @@ -1,80 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.XmlHandlingService; -//import eu.eudat.commons.types.reference.DefinitionEntity; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.ReferenceEntity; -//import eu.eudat.file.transformer.enums.ReferenceSourceType; -//import eu.eudat.file.transformer.enums.ReferenceType; -//import eu.eudat.file.transformer.models.description.DescriptionReferenceFileTransformerModel; -//import eu.eudat.file.transformer.models.dmp.DmpReferenceFileTransformerModel; -//import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.ArrayList; -//import java.util.EnumSet; -//import java.util.List; -//import java.util.Optional; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class ReferenceFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final BuilderFactory builderFactory; -// private final XmlHandlingService xmlHandlingService; -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public ReferenceFileTransformerBuilder( -// ConventionService conventionService, -// BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFileTransformerBuilder.class))); -// this.builderFactory = builderFactory; -// this.xmlHandlingService = xmlHandlingService; -// } -// -// public ReferenceFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// List> models = new ArrayList<>(); -// for (ReferenceEntity d : data) { -// ReferenceFileTransformerModel m = new ReferenceFileTransformerModel(); -// m.setId(d.getId()); -// m.setLabel(d.getLabel()); -// if (d.getDefinition() != null){ -// DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition()); -// m.setDefinition(this.builderFactory.builder(ReferenceDefinitionFileTransformerBuilder.class).authorize(this.authorize).build(definition)); -// } -// m.setReference(d.getReference()); -// m.setAbbreviation(d.getAbbreviation()); -// m.setDescription(d.getDescription()); -// m.setSource(d.getSource()); -// switch (d.getSourceType()){ -// case Internal -> m.setSourceType(ReferenceSourceType.Internal); -// case External -> m.setSourceType(ReferenceSourceType.External); -// default -> throw new MyApplicationException("unrecognized type " + d.getSourceType().getValue()); -// } -// -// //m.setType(d.getTypeId()); //TODO new reference logic -// -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// return models; -// } -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/TagFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/TagFileTransformerBuilder.java deleted file mode 100644 index 0a4ce8a38..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/TagFileTransformerBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.commons.XmlHandlingService; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.TagEntity; -//import eu.eudat.file.transformer.models.tag.TagFileTransformerModel; -//import gr.cite.tools.data.builder.BuilderFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.ArrayList; -//import java.util.EnumSet; -//import java.util.List; -//import java.util.Optional; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class TagFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private final BuilderFactory builderFactory; -// private final XmlHandlingService xmlHandlingService; -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// -// @Autowired -// public TagFileTransformerBuilder( -// ConventionService conventionService, -// BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(TagFileTransformerBuilder.class))); -// this.builderFactory = builderFactory; -// this.xmlHandlingService = xmlHandlingService; -// } -// -// public TagFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null || data.isEmpty()) return new ArrayList<>(); -// -// List> models = new ArrayList<>(); -// for (TagEntity d : data) { -// TagFileTransformerModel m = new TagFileTransformerModel(); -// m.setId(d.getId()); -// m.setLabel(d.getLabel()); -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// return models; -// } -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/UserFileTransformerBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/UserFileTransformerBuilder.java deleted file mode 100644 index 3196b7581..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/filetransformer/UserFileTransformerBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -//package eu.eudat.model.builder.filetransformer; -// -//import eu.eudat.authorization.AuthorizationFlags; -//import eu.eudat.convention.ConventionService; -//import eu.eudat.data.UserContactInfoEntity; -//import eu.eudat.data.UserEntity; -//import eu.eudat.file.transformer.enums.ContactInfoType; -//import eu.eudat.file.transformer.models.user.UserContactInfoFileTransformerModel; -//import eu.eudat.file.transformer.models.user.UserFileTransformerModel; -//import eu.eudat.query.UserContactInfoQuery; -//import gr.cite.tools.data.query.QueryFactory; -//import gr.cite.tools.exception.MyApplicationException; -//import gr.cite.tools.logging.LoggerService; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.config.ConfigurableBeanFactory; -//import org.springframework.context.annotation.Scope; -//import org.springframework.stereotype.Component; -// -//import java.util.*; -// -//@Component -//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -//public class UserFileTransformerBuilder extends BaseFileTransformerBuilder { -// -// private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); -// private final QueryFactory queryFactory; -// -// @Autowired -// public UserFileTransformerBuilder(ConventionService conventionService, QueryFactory queryFactory) { -// super(conventionService, new LoggerService(LoggerFactory.getLogger(UserFileTransformerBuilder.class))); -// this.queryFactory = queryFactory; -// } -// -// public UserFileTransformerBuilder authorize(EnumSet values) { -// this.authorize = values; -// return this; -// } -// -// @Override -// protected List> buildInternal(List data) throws MyApplicationException { -// this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0)); -// if (data == null) -// return new ArrayList<>(); -// -// List> models = new ArrayList<>(); -// -// for (UserEntity d : data) { -// UserFileTransformerModel m = new UserFileTransformerModel(); -// m.setId(d.getId()); -// m.setName(d.getName()); -// m.setContacts(mapContactInfo(d.getId())); -// models.add(new FileTransformerBuilderItemResponse<>(m, d)); -// } -// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); -// -// return models; -// } -// -// private List mapContactInfo(UUID userId) { -// List result = new ArrayList<>(); -// UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(userId); -// List contactInfos = query.collect(); -// contactInfos.forEach(contactInfo -> { -// UserContactInfoFileTransformerModel m = new UserContactInfoFileTransformerModel(); -// m.setId(contactInfo.getId()); -// m.setOrdinal(contactInfo.getOrdinal()); -// m.setType(ContactInfoType.of(contactInfo.getType().getValue())); -// m.setValue(contactInfo.getValue()); -// result.add(m); -// }); -// return result; -// } -// -//} diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index 31d6c6dbf..f0890cedf 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -499,7 +499,8 @@ public class DescriptionServiceImpl implements DescriptionService { StorageFile storageFile = this.storageFileService.copyToStorage(newFileId, StorageType.Main, true, new BaseFieldSet().ensure(StorageFile._id)); this.storageFileService.updatePurgeAt(storageFile.getId(), null); if (existingFileId != null){ - this.storageFileService.updatePurgeAt(existingFileId, Instant.now().minusSeconds(60)); + //DO NOT Remove we can not be sure uf the description is copied + //this.storageFileService.updatePurgeAt(existingFileId, Instant.now().minusSeconds(60)); } data.setTextValue(storageFile.getId().toString()); } else { @@ -507,7 +508,8 @@ public class DescriptionServiceImpl implements DescriptionService { } } else { if (existingFileId != null){ - this.storageFileService.updatePurgeAt(existingFileId, Instant.now().minusSeconds(60)); + //DO NOT Remove we can not be sure uf the description is copied + //this.storageFileService.updatePurgeAt(existingFileId, Instant.now().minusSeconds(60)); } data.setTextValue(null); }