bug fixes

This commit is contained in:
Efstratios Giannopoulos 2024-05-09 12:38:55 +03:00
parent 40df26c560
commit 4b32d5f548
4 changed files with 15 additions and 11 deletions

View File

@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.net.URLConnection; import java.net.URLConnection;
@ -39,6 +40,7 @@ import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel, FieldEntity> { public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel, FieldEntity> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;

View File

@ -1,5 +1,8 @@
package org.opencdmp.model.builder.commonmodels.description; package org.opencdmp.model.builder.commonmodels.description;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.authorization.AuthorizationFlags;
import org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel; import org.opencdmp.commonmodels.models.description.PropertyDefinitionFieldSetItemModel;
import org.opencdmp.commons.types.description.PropertyDefinitionFieldSetItemEntity; import org.opencdmp.commons.types.description.PropertyDefinitionFieldSetItemEntity;
@ -8,9 +11,6 @@ import org.opencdmp.commons.types.descriptiontemplate.FieldSetEntity;
import org.opencdmp.convention.ConventionService; import org.opencdmp.convention.ConventionService;
import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder; import org.opencdmp.model.builder.commonmodels.BaseCommonModelBuilder;
import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse; import org.opencdmp.model.builder.commonmodels.CommonModelBuilderItemResponse;
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.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
import java.util.*; import java.util.*;
@Component @Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PropertyDefinitionFieldSetItemModelCommonModelBuilder extends BaseCommonModelBuilder<PropertyDefinitionFieldSetItemModel, PropertyDefinitionFieldSetItemEntity> { public class PropertyDefinitionFieldSetItemModelCommonModelBuilder extends BaseCommonModelBuilder<PropertyDefinitionFieldSetItemModel, PropertyDefinitionFieldSetItemEntity> {
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@ -66,8 +66,8 @@ public class PropertyDefinitionFieldSetItemModelCommonModelBuilder extends BaseC
if (d.getFields() != null && !d.getFields().isEmpty()) { if (d.getFields() != null && !d.getFields().isEmpty()) {
m.setFields(new HashMap<>()); m.setFields(new HashMap<>());
for (String key : d.getFields().keySet()){ for (String key : d.getFields().keySet()){
FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getFieldById(key).stream().findFirst().orElse(null) : null; FieldEntity fieldEntity = this.fieldSetEntity != null ? this.fieldSetEntity.getFieldById(key).stream().findFirst().orElse(null) : null;
m.getFields().put(key, this.builderFactory.builder(FieldCommonModelBuilder.class).useSharedStorage(useSharedStorage).authorize(this.authorize).withFieldEntity(fieldEntity).build(d.getFields().get(key))); m.getFields().put(key, this.builderFactory.builder(FieldCommonModelBuilder.class).useSharedStorage(this.useSharedStorage).authorize(this.authorize).withFieldEntity(fieldEntity).build(d.getFields().get(key)));
} }
} }
models.add(new CommonModelBuilderItemResponse<>(m, d)); models.add(new CommonModelBuilderItemResponse<>(m, d));

View File

@ -12,12 +12,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DefaultValueCommonModelBuilder extends BaseCommonModelBuilder<DefaultValueModel, DefaultValueEntity> { public class DefaultValueCommonModelBuilder extends BaseCommonModelBuilder<DefaultValueModel, DefaultValueEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);

View File

@ -20,31 +20,31 @@ public class FileTransformerRepository implements FileTransformerClient {
@Override @Override
public FileEnvelopeModel exportDmp(DmpModel dmpModel, String format) { public FileEnvelopeModel exportDmp(DmpModel dmpModel, String format) {
return transformerClient.post().uri("/export/dmp", uriBuilder -> uriBuilder.queryParam("format", format).build()).bodyValue(dmpModel) return this.transformerClient.post().uri("/export/dmp", uriBuilder -> uriBuilder.queryParam("format", format).build()).bodyValue(dmpModel)
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(FileEnvelopeModel.class)).block(); .exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(FileEnvelopeModel.class)).block();
} }
@Override @Override
public DmpModel importDmp(FileEnvelopeModel fileEnvelope) { public DmpModel importDmp(FileEnvelopeModel fileEnvelope) {
return transformerClient.post().uri("/import/dmp").bodyValue(fileEnvelope) return this.transformerClient.post().uri("/import/dmp").bodyValue(fileEnvelope)
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(DmpModel.class)).block(); .exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(DmpModel.class)).block();
} }
@Override @Override
public FileEnvelopeModel exportDescription(DescriptionModel descriptionModel, String format) { public FileEnvelopeModel exportDescription(DescriptionModel descriptionModel, String format) {
return transformerClient.post().uri("/export/description", uriBuilder -> uriBuilder.queryParam("format", format).build()).bodyValue(descriptionModel) return this.transformerClient.post().uri("/export/description", uriBuilder -> uriBuilder.queryParam("format", format).build()).bodyValue(descriptionModel)
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(FileEnvelopeModel.class)).block(); .exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(FileEnvelopeModel.class)).block();
} }
@Override @Override
public DescriptionModel importDescription(FileEnvelopeModel fileEnvelope) { public DescriptionModel importDescription(FileEnvelopeModel fileEnvelope) {
return transformerClient.post().uri("/import/description").bodyValue(fileEnvelope) return this.transformerClient.post().uri("/import/description").bodyValue(fileEnvelope)
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(DescriptionModel.class)).block(); .exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(DescriptionModel.class)).block();
} }
@Override @Override
public FileTransformerConfiguration getConfiguration() { public FileTransformerConfiguration getConfiguration() {
return transformerClient.get().uri("/formats") return this.transformerClient.get().uri("/formats")
.exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(new ParameterizedTypeReference<FileTransformerConfiguration>() {})).block(); .exchangeToMono(mono -> mono.statusCode().isError() ? mono.createException().flatMap(Mono::error) : mono.bodyToMono(new ParameterizedTypeReference<FileTransformerConfiguration>() {})).block();
} }