bug fixes
This commit is contained in:
parent
928babb9d5
commit
94cc0b87cd
|
@ -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<NestedCollaboratorElasticEntity, DmpUserEntity> {
|
||||
|
||||
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<NestedC
|
|||
return new ArrayList<>();
|
||||
|
||||
List<NestedCollaboratorElasticEntity> models = new ArrayList<>();
|
||||
Map<UUID, String> 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));
|
||||
|
|
|
@ -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<M, D> 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<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(List.of(data));
|
||||
// return models.stream().map(FileTransformerBuilderItemResponse::getModel).findFirst().orElse(null); //TODO
|
||||
// }
|
||||
//
|
||||
// public List<M> build(List<D> data) throws MyApplicationException{
|
||||
// List<FileTransformerBuilderItemResponse<M, D>> models = this.buildInternal(data);
|
||||
// return models == null ? null : models.stream().map(FileTransformerBuilderItemResponse::getModel).collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// protected abstract List<FileTransformerBuilderItemResponse<M, D>> buildInternal(List<D> data) throws MyApplicationException;
|
||||
//
|
||||
// public <K> Map<K, M> asForeignKey(QueryBase<D> query, Function<D, K> keySelector) throws MyApplicationException {
|
||||
// this.logger.trace("Building references from query");
|
||||
// List<D> data = query.collect();
|
||||
// this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
// return this.asForeignKey(data, keySelector);
|
||||
// }
|
||||
//
|
||||
// public <K> Map<K, M> asForeignKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
||||
// this.logger.trace("building references");
|
||||
// List<FileTransformerBuilderItemResponse<M, D>> 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 <K> Map<K, List<M>> asMasterKey(QueryBase<D> query,Function<D, K> keySelector) throws MyApplicationException {
|
||||
// this.logger.trace("Building details from query");
|
||||
// List<D> data = query.collect();
|
||||
// this.logger.debug("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
// return this.asMasterKey(data, keySelector);
|
||||
// }
|
||||
//
|
||||
// public <K> Map<K, List<M>> asMasterKey(List<D> data, Function<D, K> keySelector) throws MyApplicationException {
|
||||
// this.logger.trace("building details");
|
||||
// List<FileTransformerBuilderItemResponse<M, D>> 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<K, List<M>> map = new HashMap<>();
|
||||
// if (models == null) return map;
|
||||
// for (FileTransformerBuilderItemResponse<M, D> model : models) {
|
||||
// K key = keySelector.apply(model.getData());
|
||||
// if (!map.containsKey(key)) map.put(key, new ArrayList<M>());
|
||||
// map.get(key).add(model.getModel());
|
||||
// }
|
||||
// return map;
|
||||
// }
|
||||
//}
|
||||
//
|
|
@ -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<DescriptionTemplateFileTransformerModel, FieldEntity> {
|
||||
//
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public DescriptionFieldFileTransformerBuilder setDefinition(DescriptionTemplateFileTransformerModel definition) {
|
||||
// this.definition = definition;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, FieldEntity>> buildInternal(List<FieldEntity> 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<FileTransformerBuilderItemResponse<DescriptionFieldDepositModel, FieldEntity>> 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<PageFileTransformerModel> 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<SectionFileTransformerModel> sections) {
|
||||
// FieldFileTransformerModel result = null;
|
||||
// for (SectionFileTransformerModel section: sections) {
|
||||
// if (section.getSections() != null && !section.getSections().isEmpty()) {
|
||||
// result = findSectionFieldById(id, section.getSections());
|
||||
// }
|
||||
// if (result == null) {
|
||||
// List<FieldSetFileTransformerModel> fieldSets = section.getFieldSets();
|
||||
// if (fieldSets != null && !fieldSets.isEmpty()) {
|
||||
// for (FieldSetFileTransformerModel fieldSet : fieldSets) {
|
||||
// List<FieldFileTransformerModel> 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<SectionFileTransformerModel> calculateSectionVisibility(List<SectionFileTransformerModel> sections) {
|
||||
// List<SectionFileTransformerModel> 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<FieldSetFileTransformerModel> calculateFieldSetVisibility(List<FieldSetFileTransformerModel> fieldSets) {
|
||||
// List<FieldSetFileTransformerModel> 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<FieldFileTransformerModel> calculateFieldVisibility(List<FieldFileTransformerModel> fields) {
|
||||
// List<FieldFileTransformerModel> 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<PageFileTransformerModel> 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<SectionFileTransformerModel> 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<FieldSetFileTransformerModel> 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<FieldFileTransformerModel> fields, String fieldId) {
|
||||
// FieldFileTransformerModel result = null;
|
||||
// for (FieldFileTransformerModel field: fields) {
|
||||
// if (field.getId().equals(fieldId)) {
|
||||
// result = field;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -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<DescriptionFileTransformerModel, DescriptionEntity> {
|
||||
//
|
||||
// private final QueryFactory queryFactory;
|
||||
//
|
||||
// private final BuilderFactory builderFactory;
|
||||
// private final JsonHandlingService jsonHandlingService;
|
||||
//
|
||||
// private final XmlHandlingService xmlHandlingService;
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<DescriptionFileTransformerModel, DescriptionEntity>> buildInternal(List<DescriptionEntity> 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<DescriptionTemplateFileTransformerModel> definitionMap = this.collectDescriptionTemplates(data);
|
||||
// Map<UUID, List<DescriptionReferenceFileTransformerModel>> referenceMap = collectReferences(data);
|
||||
// Map<UUID, List<DescriptionTagFileTransformerModel>> tagMap = collectTags(data);
|
||||
//
|
||||
//
|
||||
// DmpFileTransformerModel dmp = this.getDmp(data.get(0).getDmpId());
|
||||
//
|
||||
//
|
||||
// List<FileTransformerBuilderItemResponse<DescriptionFileTransformerModel, DescriptionEntity>> 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<DescriptionTemplateFileTransformerModel> collectDescriptionTemplates(List<DescriptionEntity> data) throws MyApplicationException {
|
||||
// if (data.isEmpty())
|
||||
// return null;
|
||||
// this.logger.debug("checking related - {}", DescriptionTemplate.class.getSimpleName());
|
||||
//
|
||||
// List<DescriptionTemplateEntity> 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<UUID, List<DescriptionReferenceFileTransformerModel>> collectReferences(List<DescriptionEntity> data) throws MyApplicationException {
|
||||
// if (data.isEmpty()) return null;
|
||||
// this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||
//
|
||||
// List<DescriptionReferenceEntity> 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<UUID, List<DescriptionReferenceFileTransformerModel>> 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<UUID, ReferenceFileTransformerModel> 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<UUID, List<DescriptionTagFileTransformerModel>> collectTags(List<DescriptionEntity> data) {
|
||||
// if (data.isEmpty()) return null;
|
||||
//
|
||||
// List<DescriptionTagEntity> descriptionTags = this.queryFactory.query(DescriptionTagQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().toList()).collect();
|
||||
//
|
||||
// Map<UUID, List<DescriptionTagFileTransformerModel>> 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<UUID, TagFileTransformerModel> 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;
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -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<DefinitionFileTransformerModel, DefinitionEntity> {
|
||||
//
|
||||
// private final QueryFactory queryFactory;
|
||||
//
|
||||
// private final BuilderFactory builderFactory;
|
||||
// private final JsonHandlingService jsonHandlingService;
|
||||
//
|
||||
// private final XmlHandlingService xmlHandlingService;
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> 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<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> 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<PageFileTransformerModel> collectPages(List<PageEntity> data) {
|
||||
// List<PageFileTransformerModel> 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<SectionFileTransformerModel> collectSections(List<SectionEntity> data) {
|
||||
// List<SectionFileTransformerModel> 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<FieldSetFileTransformerModel> collectFieldSet(List<FieldSetEntity> data) {
|
||||
// List<FieldSetFileTransformerModel> 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<FieldFileTransformerModel> convertFields(List<FieldEntity> data) {
|
||||
// List<FieldFileTransformerModel> 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<RuleFileTransformerModel> convertVisibilityRules(List<RuleEntity> data) {
|
||||
// List<RuleFileTransformerModel> 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<RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel> convertRadioBoxOptions(List<RadioBoxDataEntity.RadioBoxDataOptionEntity> data) {
|
||||
// List<RadioBoxDataFileTransformerModel.RadioBoxDataOptionFileTransformerModel> 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<UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel> convertUploadDataOptions(List<UploadDataEntity.UploadDataOptionEntity> data) {
|
||||
// List<UploadDataFileTransformerModel.UploadDataOptionFileTransformerModel> 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;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
|
@ -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<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity> {
|
||||
//
|
||||
// private final QueryFactory queryFactory;
|
||||
//
|
||||
// private final BuilderFactory builderFactory;
|
||||
// private final JsonHandlingService jsonHandlingService;
|
||||
//
|
||||
// private final XmlHandlingService xmlHandlingService;
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity>> buildInternal(List<DescriptionTemplateEntity> 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<FileTransformerBuilderItemResponse<DescriptionTemplateFileTransformerModel, DescriptionTemplateEntity>> 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());
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -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<DmpBlueprintFileTransformerModel, DmpBlueprintEntity> {
|
||||
//
|
||||
// private final QueryFactory queryFactory;
|
||||
//
|
||||
// private final BuilderFactory builderFactory;
|
||||
// private final JsonHandlingService jsonHandlingService;
|
||||
//
|
||||
// private final XmlHandlingService xmlHandlingService;
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<DmpBlueprintFileTransformerModel, DmpBlueprintEntity>> buildInternal(List<DmpBlueprintEntity> 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<FileTransformerBuilderItemResponse<DmpBlueprintFileTransformerModel, DmpBlueprintEntity>> 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<SectionEntity> 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<FieldFileTransformerModel> mapFields(List<FieldEntity> fieldEntities) {
|
||||
// List<FieldFileTransformerModel> 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;
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -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<DmpFileTransformerModel, DmpEntity> {
|
||||
//
|
||||
// private final QueryFactory queryFactory;
|
||||
// private final BuilderFactory builderFactory;
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public DmpFileTransformerBuilder ignoreDescriptions(Boolean ignoreDescriptions) {
|
||||
// this.ignoreDescriptions = ignoreDescriptions;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<DmpFileTransformerModel, DmpEntity>> buildInternal(List<DmpEntity> 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<FileTransformerBuilderItemResponse<DmpFileTransformerModel, DmpEntity>> models = new ArrayList<>();
|
||||
//
|
||||
// Map<UUID, List<DmpReferenceFileTransformerModel>> dmpReferencesMap = this.collectReferences(data);
|
||||
//
|
||||
// Map<UUID, List<DmpUserFileTransformerModel>> dmpUsersMap = this.collectDmpUsers(data);
|
||||
//
|
||||
// Map<UUID, List<DescriptionFileTransformerModel>> descriptionsMap = null;
|
||||
// if (!ignoreDescriptions) {
|
||||
// descriptionsMap = this.collectDmpDescriptions(data);
|
||||
// }
|
||||
//
|
||||
// Map<UUID, List<EntityDoiFileTransformerModel>> doiMap = this.collectEntityDois(data);
|
||||
// Map<UUID, UserFileTransformerModel> creatorMap = this.collectCreators(data);
|
||||
// Map<UUID, DmpBlueprintFileTransformerModel> 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<UUID, List<DmpReferenceFileTransformerModel>> collectReferences(List<DmpEntity> data) throws MyApplicationException {
|
||||
// if (data.isEmpty()) return null;
|
||||
// this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||
//
|
||||
// List<DmpReferenceEntity> 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<UUID, List<DmpReferenceFileTransformerModel>> 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<UUID, ReferenceFileTransformerModel> 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<UUID, List<DmpUserFileTransformerModel>> collectDmpUsers(List<DmpEntity> data) throws MyApplicationException {
|
||||
// this.logger.debug("checking related - {}", DmpUser.class.getSimpleName());
|
||||
//
|
||||
// Map<UUID, List<DmpUserFileTransformerModel>> 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<UUID, List<DescriptionFileTransformerModel>> collectDmpDescriptions(List<DmpEntity> data) throws MyApplicationException {
|
||||
// if (data.isEmpty()) return null;
|
||||
// this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
||||
//
|
||||
// Map<UUID, List<DescriptionFileTransformerModel>> 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<UUID, UserFileTransformerModel> collectCreators(List<DmpEntity> 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<UUID, DmpBlueprintFileTransformerModel> collectBlueprints(List<DmpEntity> 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<UUID, List<EntityDoiFileTransformerModel>> collectEntityDois(List<DmpEntity> data) {
|
||||
// if (data.isEmpty()) return null;
|
||||
// Map<UUID, List<EntityDoiFileTransformerModel>> 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;
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -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<DmpUserFileTransformerModel, DmpUserEntity> {
|
||||
//
|
||||
// private final BuilderFactory builderFactory;
|
||||
//
|
||||
// private final QueryFactory queryFactory;
|
||||
//
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<DmpUserFileTransformerModel, DmpUserEntity>> buildInternal(List<DmpUserEntity> data) throws MyApplicationException {
|
||||
// this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
// if (data == null)
|
||||
// return new ArrayList<>();
|
||||
//
|
||||
//
|
||||
// Map<UUID, UserFileTransformerModel> userItemsMap = this.collectUsers(data);
|
||||
//
|
||||
// List<FileTransformerBuilderItemResponse<DmpUserFileTransformerModel, DmpUserEntity>> 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<UUID, UserFileTransformerModel> collectUsers(List<DmpUserEntity> data) throws MyApplicationException {
|
||||
// if (data.isEmpty())
|
||||
// return null;
|
||||
// this.logger.debug("checking related - {}", UserFileTransformerModel.class.getSimpleName());
|
||||
//
|
||||
// Map<UUID, UserFileTransformerModel> 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;
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -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<EntityDoiFileTransformerModel, EntityDoiEntity>{
|
||||
// @Autowired
|
||||
// public EntityDoiFileTransformerBuilder(ConventionService conventionService) {
|
||||
// super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpFileTransformerBuilder.class)));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<EntityDoiFileTransformerModel, EntityDoiEntity>> buildInternal(List<EntityDoiEntity> data) throws MyApplicationException {
|
||||
// List<FileTransformerBuilderItemResponse<EntityDoiFileTransformerModel, EntityDoiEntity>> 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;
|
||||
// }
|
||||
//}
|
|
@ -1,19 +0,0 @@
|
|||
//package eu.eudat.model.builder.filetransformer;
|
||||
//
|
||||
//public class FileTransformerBuilderItemResponse<M, D>{
|
||||
// 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;
|
||||
// }
|
||||
//}
|
|
@ -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<DefinitionFileTransformerModel, DefinitionEntity> {
|
||||
//
|
||||
// private final BuilderFactory builderFactory;
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> buildInternal(List<DefinitionEntity> 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<FileTransformerBuilderItemResponse<DefinitionFileTransformerModel, DefinitionEntity>> 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;
|
||||
// }
|
||||
//}
|
|
@ -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<FieldFileTransformerModel, FieldEntity> {
|
||||
//
|
||||
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
//
|
||||
// @Autowired
|
||||
// public ReferenceFieldFileTransformerBuilder(
|
||||
// ConventionService conventionService) {
|
||||
// super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceFieldFileTransformerBuilder.class)));
|
||||
// }
|
||||
//
|
||||
// public ReferenceFieldFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<FieldFileTransformerModel, FieldEntity>> buildInternal(List<FieldEntity> 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<FileTransformerBuilderItemResponse<FieldFileTransformerModel, FieldEntity>> 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;
|
||||
// }
|
||||
//}
|
|
@ -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<ReferenceFileTransformerModel, ReferenceEntity> {
|
||||
//
|
||||
// private final BuilderFactory builderFactory;
|
||||
// private final XmlHandlingService xmlHandlingService;
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<ReferenceFileTransformerModel, ReferenceEntity>> buildInternal(List<ReferenceEntity> 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<FileTransformerBuilderItemResponse<ReferenceFileTransformerModel, ReferenceEntity>> 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;
|
||||
// }
|
||||
//}
|
|
@ -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<TagFileTransformerModel, TagEntity> {
|
||||
//
|
||||
// private final BuilderFactory builderFactory;
|
||||
// private final XmlHandlingService xmlHandlingService;
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<TagFileTransformerModel, TagEntity>> buildInternal(List<TagEntity> 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<FileTransformerBuilderItemResponse<TagFileTransformerModel, TagEntity>> 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;
|
||||
// }
|
||||
//}
|
|
@ -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<UserFileTransformerModel, UserEntity> {
|
||||
//
|
||||
// private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
|
||||
// this.authorize = values;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected List<FileTransformerBuilderItemResponse<UserFileTransformerModel, UserEntity>> buildInternal(List<UserEntity> data) throws MyApplicationException {
|
||||
// this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
// if (data == null)
|
||||
// return new ArrayList<>();
|
||||
//
|
||||
// List<FileTransformerBuilderItemResponse<UserFileTransformerModel, UserEntity>> 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<UserContactInfoFileTransformerModel> mapContactInfo(UUID userId) {
|
||||
// List<UserContactInfoFileTransformerModel> result = new ArrayList<>();
|
||||
// UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(userId);
|
||||
// List<UserContactInfoEntity> 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;
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue