Merge branch 'dmp-refactoring-file-transformer-builder' into dmp-refactoring

This commit is contained in:
George Kalampokis 2024-01-18 10:11:29 +02:00
commit e39d8d25b6
33 changed files with 396 additions and 385 deletions

View File

@ -47,7 +47,7 @@
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>file-transformer-base</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>0.0.3</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>

View File

@ -8,7 +8,8 @@ import java.util.Map;
public enum StorageType implements DatabaseEnum<Short> {
Temp((short) 0),
Main((short) 1);
Main((short) 1),
Transformer((short)2);
private final Short value;

View File

@ -10,10 +10,7 @@ import eu.eudat.convention.ConventionService;
import eu.eudat.depositinterface.enums.FieldType;
import eu.eudat.depositinterface.models.DescriptionFieldDepositModel;
import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
import eu.eudat.file.transformer.models.descriptiontemplate.definition.FieldFileTransformerModel;
import eu.eudat.file.transformer.models.descriptiontemplate.definition.FieldSetFileTransformerModel;
import eu.eudat.file.transformer.models.descriptiontemplate.definition.PageFileTransformerModel;
import eu.eudat.file.transformer.models.descriptiontemplate.definition.SectionFileTransformerModel;
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;
@ -23,10 +20,7 @@ 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;
import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ -35,6 +29,7 @@ public class DescriptionFieldFileTransformerBuilder extends BaseFileTransformerB
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private DescriptionTemplateFileTransformerModel definition;
private final FieldDataHelperServiceProvider fieldDataHelperServiceProvider;
@Autowired
public DescriptionFieldFileTransformerBuilder(
ConventionService conventionService, FieldDataHelperServiceProvider fieldDataHelperServiceProvider
@ -110,6 +105,10 @@ public class DescriptionFieldFileTransformerBuilder extends BaseFileTransformerB
//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)));
@ -158,4 +157,112 @@ public class DescriptionFieldFileTransformerBuilder extends BaseFileTransformerB
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;
}
}

View File

@ -6,16 +6,24 @@ 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.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.*;
import eu.eudat.depositinterface.models.DescriptionDepositModel;
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.dmp.DmpReferenceFileTransformerModel;
import eu.eudat.file.transformer.models.reference.ReferenceFileTransformerModel;
import eu.eudat.file.transformer.models.tag.TagFileTransformerModel;
import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
import eu.eudat.model.DescriptionReference;
import eu.eudat.model.DescriptionTemplate;
import eu.eudat.query.DescriptionTemplateQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.model.DmpReference;
import eu.eudat.model.Tag;
import eu.eudat.model.builder.TagBuilder;
import eu.eudat.query.*;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
@ -65,8 +73,11 @@ public class DescriptionFileTransformerBuilder extends BaseFileTransformerBuilde
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());
DmpFileTransformerModel dmp = this.getDmp(data.get(0).getDmpId());
List<FileTransformerBuilderItemResponse<DescriptionFileTransformerModel, DescriptionEntity>> models = new ArrayList<>();
@ -84,6 +95,9 @@ public class DescriptionFileTransformerBuilder extends BaseFileTransformerBuilde
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));
}
@ -108,4 +122,49 @@ public class DescriptionFileTransformerBuilder extends BaseFileTransformerBuilde
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;
}
}

View File

@ -3,19 +3,13 @@ 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.DescriptionEntity;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.file.transformer.models.description.DescriptionFileTransformerModel;
import eu.eudat.file.transformer.models.descriptiontemplate.DescriptionTemplateFileTransformerModel;
import eu.eudat.model.DescriptionTemplate;
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.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,8 +17,10 @@ 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;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ -68,6 +64,8 @@ public class DescriptionTemplateFileTransformerBuilder extends BaseFileTransform
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));

View File

@ -92,6 +92,7 @@ public class DmpBlueprintFileTransformerBuilder extends BaseFileTransformerBuild
SectionFileTransformerModel m = new SectionFileTransformerModel();
m.setId(section.getId());
m.setLabel(section.getLabel());
m.setOrdinal(section.getOrdinal());
m.setDescription(section.getDescription());
m.setFields(mapFields(section.getFields()));
m.setHasTemplates(section.getHasTemplates());

View File

@ -12,9 +12,12 @@ 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;
@ -109,7 +112,15 @@ public class DmpFileTransformerBuilder extends BaseFileTransformerBuilder<DmpFil
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.getId())) m.setBlueprint(blueprintMap.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));
}
@ -126,11 +137,15 @@ public class DmpFileTransformerBuilder extends BaseFileTransformerBuilder<DmpFil
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, DmpReferenceFileTransformerModel> referenceDepositModelMap = this.builderFactory.builder(ReferenceFileTransformerBuilder.class).authorize(this.authorize).asForeignKey(query, ReferenceEntity::getId);
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 model =referenceDepositModelMap.getOrDefault(dmpReference.getReferenceId(), null);
if (model == null) continue;;
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);
@ -171,7 +186,7 @@ public class DmpFileTransformerBuilder extends BaseFileTransformerBuilder<DmpFil
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(entry -> entry.getKey(), entry -> entry.getValue()));
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
private Map<UUID, List<EntityDoiFileTransformerModel>> collectEntityDois(List<DmpEntity> data) {

View File

@ -7,6 +7,7 @@ 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;
@ -25,7 +26,7 @@ import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ReferenceFileTransformerBuilder extends BaseFileTransformerBuilder<DmpReferenceFileTransformerModel, ReferenceEntity> {
public class ReferenceFileTransformerBuilder extends BaseFileTransformerBuilder<ReferenceFileTransformerModel, ReferenceEntity> {
private final BuilderFactory builderFactory;
private final XmlHandlingService xmlHandlingService;
@ -46,11 +47,11 @@ public class ReferenceFileTransformerBuilder extends BaseFileTransformerBuilder<
}
@Override
protected List<FileTransformerBuilderItemResponse<DmpReferenceFileTransformerModel, ReferenceEntity>> buildInternal(List<ReferenceEntity> data) throws MyApplicationException {
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<DmpReferenceFileTransformerModel, ReferenceEntity>> models = new ArrayList<>();
List<FileTransformerBuilderItemResponse<ReferenceFileTransformerModel, ReferenceEntity>> models = new ArrayList<>();
for (ReferenceEntity d : data) {
ReferenceFileTransformerModel m = new ReferenceFileTransformerModel();
m.setId(d.getId());
@ -85,10 +86,7 @@ public class ReferenceFileTransformerBuilder extends BaseFileTransformerBuilder<
case Researcher -> m.setType(ReferenceType.Researcher);
default -> throw new MyApplicationException("unrecognized type " + d.getType().getValue());
}
DmpReferenceFileTransformerModel dmpReferenceFileTransformerModel = new DmpReferenceFileTransformerModel();
dmpReferenceFileTransformerModel.setReference(m);
models.add(new FileTransformerBuilderItemResponse<>(dmpReferenceFileTransformerModel, d));
models.add(new FileTransformerBuilderItemResponse<>(m, d));
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;

View File

@ -0,0 +1,59 @@
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;
}
}

View File

@ -20,8 +20,8 @@ public class TransformerRepository implements FileTransformerClient {
}
@Override
public FileEnvelope exportDmp(DmpFileTransformerModel dmpFileTransformerModel, String format) throws InvalidApplicationException, IOException {
return transformerClient.post().uri("/export/dmp", uriBuilder -> uriBuilder.queryParam("format", format).build()).bodyValue(dmpFileTransformerModel).exchangeToMono(mono -> mono.bodyToMono(FileEnvelope.class)).block();
public FileEnvelope exportDmp(DmpFileTransformerModel dmpFileTransformerModel) throws InvalidApplicationException, IOException {
return transformerClient.post().uri("/export/dmp").bodyValue(dmpFileTransformerModel).exchangeToMono(mono -> mono.bodyToMono(FileEnvelope.class)).block();
}
@Override

View File

@ -4,7 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission;
import eu.eudat.cache.transformer.FileTransformerConfigurationCache;
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.enums.DmpUserRole;
import eu.eudat.commons.enums.StorageType;
import eu.eudat.configurations.transformer.TransformerProperties;
import eu.eudat.convention.ConventionService;
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
@ -12,33 +12,21 @@ import eu.eudat.file.transformer.models.description.DescriptionFileTransformerMo
import eu.eudat.file.transformer.models.dmp.DmpFileTransformerModel;
import eu.eudat.file.transformer.models.misc.FileEnvelope;
import eu.eudat.file.transformer.models.misc.FileFormat;
import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionBuilder;
import eu.eudat.model.builder.DmpBuilder;
import eu.eudat.model.builder.filetransformer.DescriptionFileTransformerBuilder;
import eu.eudat.model.builder.filetransformer.DmpFileTransformerBuilder;
import eu.eudat.model.descriptionproperties.PropertyDefinition;
import eu.eudat.model.descriptiontemplatedefinition.*;
import eu.eudat.model.descriptiontemplatedefinition.fielddata.AutoCompleteData;
import eu.eudat.model.descriptiontemplatedefinition.fielddata.AutoCompleteSingleData;
import eu.eudat.model.descriptiontemplatedefinition.fielddata.BaseFieldData;
import eu.eudat.model.descriptiontemplatedefinition.fielddata.ComboBoxOption;
import eu.eudat.model.dmpblueprintdefinition.ExtraField;
import eu.eudat.model.dmpblueprintdefinition.SystemField;
import eu.eudat.model.file.TransformerCacheModel;
import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.EntityDoiQuery;
import eu.eudat.repository.TransformerRepository;
import eu.eudat.service.entitydoi.EntityDoiService;
import eu.eudat.service.storage.StorageFileService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import jakarta.persistence.EntityManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -55,7 +43,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.*;
@Service
@ -75,10 +62,11 @@ public class FileTransformerService {
private final JsonHandlingService jsonHandlingService;
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
private final StorageFileService storageFileService;
@Autowired
public FileTransformerService(TransformerProperties transformerProperties, TokenExchangeCacheService tokenExchangeCacheService, FileTransformerConfigurationCache fileTransformerConfigurationCache, WebClient.Builder builder, EntityManager entityManager, AuthorizationService authorizationService, ConventionService conventionService, Environment environment, DmpQuery dmpQuery, EntityDoiQuery doiQuery, EntityDoiService doiService, ApplicationContext applicationContext, JsonHandlingService jsonHandlingService, QueryFactory queryFactory, BuilderFactory builderFactory) {
public FileTransformerService(TransformerProperties transformerProperties, TokenExchangeCacheService tokenExchangeCacheService, FileTransformerConfigurationCache fileTransformerConfigurationCache, WebClient.Builder builder, EntityManager entityManager, AuthorizationService authorizationService, ConventionService conventionService, Environment environment, DmpQuery dmpQuery, EntityDoiQuery doiQuery, EntityDoiService doiService, ApplicationContext applicationContext, JsonHandlingService jsonHandlingService, QueryFactory queryFactory, BuilderFactory builderFactory, StorageFileService storageFileService) {
this.transformerProperties = transformerProperties;
this.tokenExchangeCacheService = tokenExchangeCacheService;
this.fileTransformerConfigurationCache = fileTransformerConfigurationCache;
@ -91,6 +79,7 @@ public class FileTransformerService {
this.jsonHandlingService = jsonHandlingService;
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
this.storageFileService = storageFileService;
this.clients = new HashMap<>();
}
@ -142,173 +131,15 @@ public class FileTransformerService {
//GK: First get the right client
TransformerRepository repository = getRepository(format);
//GK: Second get the Target Data Management Plan
/*FieldSet fieldSet = new BaseFieldSet(Dmp._id,
Dmp._accessType,
Dmp._dmpReferences,
Dmp._blueprint,
Dmp._dmpUsers,
Dmp._createdAt,
Dmp._creator,
Dmp._description,
Dmp._descriptions,
Dmp._entityDois,
Dmp._finalizedAt,
Dmp._groupId,
Dmp._isActive,
Dmp._label,
Dmp._properties,
Dmp._language,
Dmp._publicAfter,
Dmp._status,
Dmp._updatedAt,
Dmp._version,
Dmp._versionStatus,
Dmp._dmpReferences + "." + DmpReference._id,
Dmp._dmpReferences + "." + DmpReference._data,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._id,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._description,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._abbreviation,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._definition,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._label,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._source,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._sourceType,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._type,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._isActive,
Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._reference,
Dmp._creator + "." + User._id,
Dmp._creator + "." + User._additionalInfo + "." + UserAdditionalInfo._avatarUrl,
Dmp._creator + "." + User._additionalInfo + "." + UserAdditionalInfo._culture,
Dmp._creator + "." + User._additionalInfo + "." + UserAdditionalInfo._language,
Dmp._creator + "." + User._additionalInfo + "." + UserAdditionalInfo._timezone,
Dmp._creator + "." + User._additionalInfo + "." + UserAdditionalInfo._roleOrganization,
Dmp._creator + "." + User._additionalInfo + "." + UserAdditionalInfo._organization,
Dmp._creator + "." + User._createdAt,
Dmp._creator + "." + User._isActive,
Dmp._creator + "." + User._name,
Dmp._creator + "." + User._roles + "." + UserRole._id,
Dmp._creator + "." + User._roles + "." + UserRole._role,
Dmp._descriptions + "." + Description._id,
Dmp._descriptions + "." + Description._label,
Dmp._descriptions + "." + Description._properties,
Dmp._descriptions + "." + Description._description,
Dmp._descriptions + "." + Description._status,
Dmp._descriptions + "." + Description._descriptionTags,
Dmp._descriptions + "." + Description._descriptionTemplate,
Dmp._descriptions + "." + Description._descriptionReferences,
Dmp._descriptions + "." + Description._isActive,
Dmp._descriptions + "." + Description._properties + "." + PropertyDefinition._fields + "." + eu.eudat.model.descriptionproperties.Field._key,
Dmp._descriptions + "." + Description._properties + "." + PropertyDefinition._fields + "." + eu.eudat.model.descriptionproperties.Field._value,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._id,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._id,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._description,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._abbreviation,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._definition,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._label,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._source,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._sourceType,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._type,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._isActive,
Dmp._descriptions + "." + Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._reference,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._id,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._description,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._label,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._language,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._status,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._isActive,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._groupId,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._type,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._version,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._id,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._description,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._sections,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._title,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._page,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._ordinal,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._defaultVisibility,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._extendedDescription,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._multiplicity + "." + Multiplicity._max,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._multiplicity + "." + Multiplicity._min,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._multiplicity + "." + Multiplicity._placeholder,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._multiplicity + "." + Multiplicity._tableView,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._numbering,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._id,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._title,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._description,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._ordinal,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._numbering,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._multiplicity + "." + Multiplicity._max,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._multiplicity + "." + Multiplicity._min,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._multiplicity + "." + Multiplicity._tableView,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._multiplicity + "." + Multiplicity._placeholder,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._hasCommentField,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._additionalInformation,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._extendedDescription,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._id,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._ordinal,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._numbering,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + BaseFieldData._label,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + BaseFieldData._fieldType,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._multiAutoComplete,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._autoCompleteSingleDataList + "." + AutoCompleteSingleData._autoCompleteOptions + "." + ComboBoxOption._label,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._autoCompleteSingleDataList + "." + AutoCompleteSingleData._autoCompleteOptions + "." + ComboBoxOption._uri,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._autoCompleteSingleDataList + "." + AutoCompleteSingleData._autoCompleteOptions + "." + ComboBoxOption._source,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._autoCompleteSingleDataList + "." + AutoCompleteSingleData._autoCompleteOptions + "." + ComboBoxOption._value,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._defaultValue,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._includeInExport,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._schematics,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._validations,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._visibilityRules + "." + Rule._target,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._visibilityRules + "." + Rule._value,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._pages + "." + Page._id,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._pages + "." + Page._ordinal,
Dmp._descriptions + "." + Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._pages + "." + Page._title,
Dmp._descriptions + "." + Description._descriptionTags + "." + DescriptionTag._id,
Dmp._descriptions + "." + Description._descriptionTags + "." + DescriptionTag._tag + "." + Tag._id,
Dmp._descriptions + "." + Description._descriptionTags + "." + DescriptionTag._tag + "." + Tag._label,
Dmp._descriptions + "." + Description._dmpDescriptionTemplate + "." + DmpDescriptionTemplate._sectionId,
Dmp._blueprint + "." + DmpBlueprint._id,
Dmp._blueprint + "." + DmpBlueprint._label,
Dmp._blueprint + "." + DmpBlueprint._definition,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._id,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._description,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._label,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._ordinal,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + eu.eudat.model.dmpblueprintdefinition.Field._id,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + eu.eudat.model.dmpblueprintdefinition.Field._description,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + eu.eudat.model.dmpblueprintdefinition.Field._ordinal,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + eu.eudat.model.dmpblueprintdefinition.Field._label,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + eu.eudat.model.dmpblueprintdefinition.Field._placeholder,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + eu.eudat.model.dmpblueprintdefinition.Field._category,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + eu.eudat.model.dmpblueprintdefinition.Field._required,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + SystemField._systemFieldType,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._fields + "." + ExtraField._dataType,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._descriptionTemplates + "." + eu.eudat.model.dmpblueprintdefinition.DescriptionTemplate._id,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._descriptionTemplates + "." + eu.eudat.model.dmpblueprintdefinition.DescriptionTemplate._label,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._descriptionTemplates + "." + eu.eudat.model.dmpblueprintdefinition.DescriptionTemplate._descriptionTemplateId,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._descriptionTemplates + "." + eu.eudat.model.dmpblueprintdefinition.DescriptionTemplate._maxMultiplicity,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._descriptionTemplates + "." + eu.eudat.model.dmpblueprintdefinition.DescriptionTemplate._minMultiplicity,
Dmp._blueprint + "." + DmpBlueprint._definition + "." + eu.eudat.model.dmpblueprintdefinition.Definition._sections + "." + eu.eudat.model.dmpblueprintdefinition.Section._hasTemplates,
Dmp._entityDois + "." + EntityDoi._doi,
Dmp._entityDois + "." + EntityDoi._id,
Dmp._entityDois + "." + EntityDoi._entityType,
Dmp._dmpUsers + "." + DmpUser._id,
Dmp._dmpUsers + "." + DmpUser._user + "." + User._id,
Dmp._dmpUsers + "." + DmpUser._user + "." + User._additionalInfo,
Dmp._dmpUsers + "." + DmpUser._user + "." + User._createdAt,
Dmp._dmpUsers + "." + DmpUser._user + "." + User._isActive,
Dmp._dmpUsers + "." + DmpUser._user + "." + User._name,
Dmp._dmpUsers + "." + DmpUser._user + "." + User._roles + "." + UserRole._id,
Dmp._dmpUsers + "." + DmpUser._user + "." + User._roles + "." + UserRole._role,
Dmp._dmpUsers + "." + DmpUser._role
);*/
DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(dmpId);
DmpFileTransformerModel dmpFileTransformerModel = this.builderFactory.builder(DmpFileTransformerBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(query.first());
FileEnvelope fileEnvelope = repository.exportDmp(dmpFileTransformerModel, format);
dmpFileTransformerModel.setVariant(format);
FileEnvelope fileEnvelope = repository.exportDmp(dmpFileTransformerModel);
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
byte[] data = storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer);
File temp = new File(environment.getProperty("path.path") + UUID.randomUUID());
try (FileOutputStream fos = new FileOutputStream(temp)) {
fos.write(fileEnvelope.getFile());
fos.write(data);
}
result.setFile(temp);
result.setFilename(fileEnvelope.getFilename());
@ -322,125 +153,15 @@ public class FileTransformerService {
//GK: First get the right client
TransformerRepository repository = getRepository(format);
//GK: Second get the Target Data Management Plan
/*FieldSet fieldSet = new BaseFieldSet(
Description._dmp + "." + Dmp._id,
Description._dmp + "." + Dmp._createdAt,
Description._dmp + "." + Dmp._finalizedAt,
Description._dmp + "." + Dmp._groupId,
Description._dmp + "." + Dmp._isActive,
Description._dmp + "." + Dmp._label,
Description._dmp + "." + Dmp._language,
Description._dmp + "." + Dmp._publicAfter,
Description._dmp + "." + Dmp._status,
Description._dmp + "." + Dmp._updatedAt,
Description._dmp + "." + Dmp._version,
Description._dmp + "." + Dmp._properties,
Description._dmp + "." + Dmp._versionStatus,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._id,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._data,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._id,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._description,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._abbreviation,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._definition,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._label,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._source,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._sourceType,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._type,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._isActive,
Description._dmp + "." + Dmp._dmpReferences + "." + DmpReference._reference + "." + Reference._reference,
Description._id,
Description._label,
Description._properties,
Description._description,
Description._status,
Description._descriptionTags,
Description._descriptionTemplate,
Description._descriptionReferences,
Description._isActive,
Description._properties + "." + PropertyDefinition._fields + "." + eu.eudat.model.descriptionproperties.Field._key,
Description._properties + "." + PropertyDefinition._fields + "." + eu.eudat.model.descriptionproperties.Field._value,
Description._descriptionReferences + "." + DescriptionReference._id,
Description._descriptionReferences + "." + DescriptionReference._reference,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._id,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._description,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._abbreviation,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._definition,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._label,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._source,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._sourceType,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._type,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._isActive,
Description._descriptionReferences + "." + DescriptionReference._reference + "." + Reference._reference,
Description._descriptionTemplate + "." + DescriptionTemplate._id,
Description._descriptionTemplate + "." + DescriptionTemplate._description,
Description._descriptionTemplate + "." + DescriptionTemplate._label,
Description._descriptionTemplate + "." + DescriptionTemplate._language,
Description._descriptionTemplate + "." + DescriptionTemplate._status,
Description._descriptionTemplate + "." + DescriptionTemplate._isActive,
Description._descriptionTemplate + "." + DescriptionTemplate._groupId,
Description._descriptionTemplate + "." + DescriptionTemplate._type,
Description._descriptionTemplate + "." + DescriptionTemplate._version,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._pages,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._id,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._description,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._sections,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._title,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._page,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._ordinal,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._defaultVisibility,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._extendedDescription,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._multiplicity + "." + Multiplicity._max,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._multiplicity + "." + Multiplicity._min,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._multiplicity + "." + Multiplicity._placeholder,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._multiplicity + "." + Multiplicity._tableView,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._numbering,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._id,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._title,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._description,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._ordinal,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._numbering,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._multiplicity + "." + Multiplicity._max,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._multiplicity + "." + Multiplicity._min,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._multiplicity + "." + Multiplicity._tableView,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._multiplicity + "." + Multiplicity._placeholder,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._hasCommentField,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._additionalInformation,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._extendedDescription,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._id,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._ordinal,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._numbering,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + BaseFieldData._label,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + BaseFieldData._fieldType,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._multiAutoComplete,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._autoCompleteSingleDataList + "." + AutoCompleteSingleData._autoCompleteOptions + "." + ComboBoxOption._label,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._autoCompleteSingleDataList + "." + AutoCompleteSingleData._autoCompleteOptions + "." + ComboBoxOption._uri,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._autoCompleteSingleDataList + "." + AutoCompleteSingleData._autoCompleteOptions + "." + ComboBoxOption._source,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._data + "." + AutoCompleteData._autoCompleteSingleDataList + "." + AutoCompleteSingleData._autoCompleteOptions + "." + ComboBoxOption._value,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._defaultValue,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._includeInExport,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._schematics,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._validations,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._visibilityRules,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._visibilityRules + "." + Rule._target,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._sections + "." + Section._fieldSets + "." + eu.eudat.model.descriptiontemplatedefinition.FieldSet._fields + "." + Field._visibilityRules + "." + Rule._value,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._pages + "." + Page._id,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._pages + "." + Page._ordinal,
Description._descriptionTemplate + "." + DescriptionTemplate._definition + "." + Definition._pages + "." + Page._title,
Description._descriptionTags + "." + DescriptionTag._id,
Description._descriptionTags + "." + DescriptionTag._tag + "." + Tag._id,
Description._descriptionTags + "." + DescriptionTag._tag + "." + Tag._label,
Description._dmp + "." + Dmp._entityDois + "." + EntityDoi._doi,
Description._dmp + "." + Dmp._entityDois + "." + EntityDoi._id,
Description._dmp + "." + Dmp._entityDois + "." + EntityDoi._entityType
);*/
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(descriptionId);
DescriptionFileTransformerModel descriptionFileTransformerModel = this.builderFactory.builder(DescriptionFileTransformerBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(query.first());
descriptionFileTransformerModel.setCreatedBy(descriptionFileTransformerModel.getDmp().getCreator());
FileEnvelope fileEnvelope = repository.exportDescription(descriptionFileTransformerModel, format);
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
byte[] data = this.storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFile(), StorageType.Transformer);
File temp = new File(environment.getProperty("path.path") + UUID.randomUUID());
try (FileOutputStream fos = new FileOutputStream(temp)) {
fos.write(fileEnvelope.getFile());
fos.write(data);
}
result.setFile(temp);
result.setFilename(fileEnvelope.getFilename());

View File

@ -6,6 +6,8 @@ storage:
basePath: ./storage/temp
- type: Main
basePath: ./storage/main
- type: Transformer
basePath: ${TRANSFORMER_BASE_PATH}
static-files:
externalUrls: dmp-backend/web/src/main/resources/externalUrls/ExternalUrls.xml
semantics: Semantics.json

View File

@ -6,6 +6,18 @@ transformer:
client-id: ${IDP_APIKEY_CLIENT_ID:}
client-secret: ${IDP_APIKEY_CLIENT_SECRET:}
scope: ${IDP_APIKEY_SCOPE:}
- url: http://localhost:8086
codes: [ json ]
issuer-url: ${IDP_ISSUER_URI_TOKEN:}
client-id: ${IDP_APIKEY_CLIENT_ID:}
client-secret: ${IDP_APIKEY_CLIENT_SECRET:}
scope: ${IDP_APIKEY_SCOPE:}
- url: http://localhost:8087
codes: [ xml ]
issuer-url: ${IDP_ISSUER_URI_TOKEN:}
client-id: ${IDP_APIKEY_CLIENT_ID:}
client-secret: ${IDP_APIKEY_CLIENT_SECRET:}
scope: ${IDP_APIKEY_SCOPE:}
temp:
temp: ${TEMP_STORAGE}

View File

@ -1,5 +1,5 @@
export interface FileFormat {
format: string;
formatName: string;
hasLogo: boolean;
icon: string;
}

View File

@ -25,15 +25,15 @@ export class FileTransformerHttpService extends BaseService {
return this.http.get<FileFormat[]>(url).pipe(catchError((error: any) => throwError(error)));
}
exportDmp(dmpId: Guid): Observable<any> {
exportDmp(dmpId: Guid, format: string): Observable<any> {
//TODO: implement
const url = `${this.apiBase}/export-dmp`;
return this.http.post<any>(url, null).pipe(catchError((error: any) => throwError(error)));
return this.http.post<any>(url, {id: dmpId, format: format}, {responseType: 'blob', observe: 'response'}).pipe(catchError((error: any) => throwError(error)));
}
exportDescription(item: any): Observable<any> {
exportDescription(id: Guid, format: string): Observable<any> {
//TODO: implement
const url = `${this.apiBase}/export-description`;
return this.http.post<any>(url, item).pipe(catchError((error: any) => throwError(error)));
return this.http.post<any>(url, {id: id, format: format}, {responseType: 'blob', observe: 'response'}).pipe(catchError((error: any) => throwError(error)));
}
}

View File

@ -3,12 +3,18 @@ import { FileFormat } from '@app/core/model/file/file-format.model';
import { BaseService } from '@common/base/base.service';
import { catchError, takeUntil } from 'rxjs/operators';
import { FileTransformerHttpService } from './file-transformer.http.service';
import { Guid } from '@common/types/guid';
import * as FileSaver from 'file-saver';
import { MatomoService } from '../matomo/matomo-service';
import { FileUtils } from '../utilities/file-utils.service';
@Injectable()
export class FileTransformerService extends BaseService {
constructor(
private fileTransformerHttpService: FileTransformerHttpService
private fileTransformerHttpService: FileTransformerHttpService,
private matomoService: MatomoService,
private fileUtils: FileUtils
) { super(); }
private _initialized: boolean = false;
@ -34,4 +40,36 @@ export class FileTransformerService extends BaseService {
this._initialized = true;
});
}
exportDmp(id: Guid, format: string) {
this._loading = true;
this.fileTransformerHttpService.exportDmp(id, format).pipe(takeUntil(this._destroyed), catchError((error) => {
this._loading = false;
return null;
})).subscribe(result => {
if (result !== null) {
const blob = new Blob([result.body], { type: 'application/octet-stream' });
const filename = this.fileUtils.getFilenameFromContentDispositionHeader(result.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
this.matomoService.trackDownload('dmps', format, id.toString());
}
});
}
exportDescription(id: Guid, format: string) {
this._loading = true;
this.fileTransformerHttpService.exportDescription(id, format).pipe(takeUntil(this._destroyed), catchError((error) => {
this._loading = false;
return null;
})).subscribe(result => {
if (result !== null) {
const blob = new Blob([result.body], { type: 'application/octet-stream' });
const filename = this.fileUtils.getFilenameFromContentDispositionHeader(result.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
this.matomoService.trackDownload('descriptions', format, id.toString());
}
});
}
}

View File

@ -70,19 +70,19 @@
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item (click)="downloadPDF(activity.id)">
<i class="fa fa-file-pdf-o pr-2"></i>
<span>{{'GENERAL.FILE-TYPES.PDF' | translate}}</span>
<span>{{'GENERAL.FILE-TRANSFOMER.PDF' | translate}}</span>
</button>
<button mat-menu-item (click)="downloadDocx(activity.id)">
<i class="fa fa-file-word-o pr-2"></i>
<span>{{'GENERAL.FILE-TYPES.DOC' | translate}}</span>
<span>{{'GENERAL.FILE-TRANSFOMER.DOC' | translate}}</span>
</button>
<button mat-menu-item (click)="downloadXml(activity.id)">
<i class="fa fa-file-code-o pr-2"></i>
<span>{{'GENERAL.FILE-TYPES.XML' | translate}}</span>
<span>{{'GENERAL.FILE-TRANSFOMER.XML' | translate}}</span>
</button>
<button mat-menu-item (click)="downloadJson(activity.id)">
<i class="fa fa-file-o pr-2"></i>
<span>{{'GENERAL.FILE-TYPES.JSON' | translate}}</span>
<span>{{'GENERAL.FILE-TRANSFOMER.JSON' | translate}}</span>
</button>
</mat-menu>
<mat-menu #actionsMenu="matMenu" xPosition="before">

View File

@ -34,15 +34,15 @@
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item (click)="downloadPDF(formGroup.get('id').value)">
<i class="fa fa-file-pdf-o pr-2"></i>
<span>{{'GENERAL.FILE-TYPES.PDF' | translate}}</span>
<span>{{'GENERAL.FILE-TRANSFOMER.PDF' | translate}}</span>
</button>
<button mat-menu-item (click)="downloadDOCX(formGroup.get('id').value)">
<i class="fa fa-file-word-o pr-2"></i>
<span>{{'GENERAL.FILE-TYPES.DOC' | translate}}</span>
<span>{{'GENERAL.FILE-TRANSFOMER.DOC' | translate}}</span>
</button>
<button mat-menu-item (click)="downloadXML(formGroup.get('id').value)">
<i class="fa fa-file-code-o pr-2"></i>
<span>{{'GENERAL.FILE-TYPES.XML' | translate}}</span>
<span>{{'GENERAL.FILE-TRANSFOMER.XML' | translate}}</span>
</button>
</mat-menu>
</div>

View File

@ -716,7 +716,7 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
// this.filesToUpload = null;
// messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.LARGE-FILE-OR-UNACCEPTED-TYPE'));
// messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.MAX-FILE-SIZE', { 'maxfilesize': this.form.get("data").value.maxFileSizeInMB }));
// messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.ACCEPTED-FILE-TYPES') + this.form.get("data").value.types.map(type => type.value).join(", "));
// messages.push(this.language.instant('DATASET-WIZARD.MESSAGES.ACCEPTED-FILE-TRANSFOMER') + this.form.get("data").value.types.map(type => type.value).join(", "));
// }
// if (messages && messages.length > 0) {

View File

@ -38,9 +38,9 @@
</button>
</mat-menu>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(description.id)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format | translate}}</span>
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
</button>
</mat-menu>
</div>

View File

@ -117,9 +117,9 @@
{{ 'DESCRIPTION-OVERVIEW.ACTIONS.EXPORT' | translate }}</p>
</div>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(description.id)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format | translate}}</span>
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDescription(description.id, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
</button>
</mat-menu>
</div>

View File

@ -38,9 +38,9 @@
<a class="col-auto pointer" *ngIf="isAuthenticated()" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
</div>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDmp(dmp.id)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format | translate}}</span>
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.hasLogo ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format.toUpperCase() | translate}}</span>
</button>
</mat-menu>
<mat-menu #actionsMenu="matMenu" xPosition="before">

View File

@ -166,9 +166,9 @@
</p>
</div>
<mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDmp(dmp.id)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.format | translate}}</span>
<button mat-menu-item *ngFor='let fileTransformer of fileTransformerService.availableFormats' (click)="fileTransformerService.exportDmp(dmp.id, fileTransformer.format)">
<i class="fa pr-2" [ngClass]="fileTransformer.icon ? fileTransformer.icon : 'fa-file-o'"></i>
<span>{{'GENERAL.FILE-TRANSFORMER.' + fileTransformer.formatName.toUpperCase() | translate}}</span>
</button>
</mat-menu>
</div>

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Sprache",
"SIGN-IN": "Sign in to account"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "There is no selected file to upload",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "The file is too large or its type is not supported.",
"MAX-FILE-SIZE": "Uploaded files should be up to {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Supported media types are: "
"ACCEPTED-FILE-TRANSFOMER": "Supported media types are: "
},
"UPLOAD": {
"UPLOAD-XML": "Importieren",

View File

@ -176,7 +176,7 @@
"TENANTS": "Tenants",
"REFERENCES": "References"
},
"FILE-TYPES": {
"FILE-TRANSFORMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "RDA JSON",
@ -849,7 +849,7 @@
"NO-FILES-SELECTED": "There is no selected file to upload",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "The file is too large or its type is not supported.",
"MAX-FILE-SIZE": "Uploaded files should be up to {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Supported media types are: "
"ACCEPTED-FILE-TRANSFOMER": "Supported media types are: "
},
"UPLOAD": {
"UPLOAD-XML": "Import",

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Idioma",
"SIGN-IN": "Identificarse con su cuenta"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "RDA JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "There is no selected file to upload",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "The file is too large or its type is not supported.",
"MAX-FILE-SIZE": "Uploaded files should be up to {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Supported media types are: "
"ACCEPTED-FILE-TRANSFOMER": "Supported media types are: "
},
"UPLOAD": {
"UPLOAD-XML": "Importar",

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Γλώσσα",
"SIGN-IN": "Σύνδεση στο λογαριασμό"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "Δεν υπάρχουν επιλεγμένα αρχεία για μεταφόρτωση",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "Το αρχείο είναι πολύ μεγάλο ή ο τύπος του δεν υποστηρίζεται.",
"MAX-FILE-SIZE": "Τα αρχεία πρέπει να είναι έως {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Οι υποστηριζόμενοι τύποι πολυμέσων είναι: "
"ACCEPTED-FILE-TRANSFOMER": "Οι υποστηριζόμενοι τύποι πολυμέσων είναι: "
},
"UPLOAD": {
"UPLOAD-XML": "Εισαγωγή",

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Jezik",
"SIGN-IN": "Prijava"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "RDA JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "Nije izabrana niti jedna datoteka",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "Datoteka je prevelika ili format nije podržan.",
"MAX-FILE-SIZE": "Veličina odabranih datoteka ne smije biti veća od {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Podržani formati datoteka su: "
"ACCEPTED-FILE-TRANSFOMER": "Podržani formati datoteka su: "
},
"UPLOAD": {
"UPLOAD-XML": "Uvezi",

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Język",
"SIGN-IN": "Zaloguj się na konto"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "RDA JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "Nie zaznaczono pliku do przesłania",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "Plik jest za duży lub jego typ nie jest obsługiwany.",
"MAX-FILE-SIZE": "Przesyłane pliki powinny mieć do {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Obsługiwane typy nośników to: "
"ACCEPTED-FILE-TRANSFOMER": "Obsługiwane typy nośników to: "
},
"UPLOAD": {
"UPLOAD-XML": "Importuj",

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Idioma",
"SIGN-IN": "Entrar na conta"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "RDA JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "There is no selected file to upload",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "The file is too large or its type is not supported.",
"MAX-FILE-SIZE": "Uploaded files should be up to {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Supported media types are: "
"ACCEPTED-FILE-TRANSFOMER": "Supported media types are: "
},
"UPLOAD": {
"UPLOAD-XML": "Importar",

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Jazyk",
"SIGN-IN": "Prihlásiť sa do účtu"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "There is no selected file to upload",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "The file is too large or its type is not supported.",
"MAX-FILE-SIZE": "Uploaded files should be up to {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Supported media types are: "
"ACCEPTED-FILE-TRANSFOMER": "Supported media types are: "
},
"UPLOAD": {
"UPLOAD-XML": "Importovať",

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Jezik",
"SIGN-IN": "Prijavljivanje korisnika"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "RDA JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "There is no selected file to upload",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "The file is too large or its type is not supported.",
"MAX-FILE-SIZE": "Uploaded files should be up to {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Supported media types are: "
"ACCEPTED-FILE-TRANSFOMER": "Supported media types are: "
},
"UPLOAD": {
"UPLOAD-XML": "Uvezite",

View File

@ -175,7 +175,7 @@
"LANGUAGE": "Dil",
"SIGN-IN": "Oturum aç"
},
"FILE-TYPES": {
"FILE-TRANSFOMER": {
"PDF": "PDF",
"XML": "XML",
"JSON": "RDA JSON",
@ -776,7 +776,7 @@
"NO-FILES-SELECTED": "There is no selected file to upload",
"LARGE-FILE-OR-UNACCEPTED-TYPE": "The file is too large or its type is not supported.",
"MAX-FILE-SIZE": "Uploaded files should be up to {{maxfilesize}} MB.",
"ACCEPTED-FILE-TYPES": "Supported media types are: "
"ACCEPTED-FILE-TRANSFOMER": "Supported media types are: "
},
"UPLOAD": {
"UPLOAD-XML": "İçeri Aktar",