remove ExternalUrlConfigProvider

This commit is contained in:
amentis 2024-02-28 17:37:56 +02:00
parent 067e81207f
commit fd77a44039
6 changed files with 3 additions and 88 deletions

View File

@ -1,37 +0,0 @@
package eu.eudat.service.externalfetcher;
import eu.eudat.service.externalfetcher.config.ExternalUrls;
import eu.eudat.service.storage.StorageFileService;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
@Service
public class ExternalUrlConfigProvider {
private static final Logger logger = LoggerFactory.getLogger(ExternalUrlConfigProvider.class);
private ExternalUrls externalUrls;
private final StorageFileService storageFileService;
public ExternalUrlConfigProvider(StorageFileService storageFileService) {
this.storageFileService = storageFileService;
}
public ExternalUrls getExternalUrls() {
if (externalUrls == null) {
byte[] bytes = this.storageFileService.getExternalUrlsFile();
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(bytes));
} catch (Exception ex) {
logger.error("Cannot find resource", ex);
}
}
return externalUrls;
}
}

View File

@ -1,31 +0,0 @@
package eu.eudat.service.externalfetcher.config;
import eu.eudat.service.externalfetcher.config.prefilling.PrefillingConfigMapAdapter;
import eu.eudat.service.externalfetcher.config.entities.*;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.io.Serializable;
import java.util.Map;
@XmlRootElement
public class ExternalUrls implements Serializable {
private static final long serialVersionUID = -5076364662014107275L;
Map<String, PrefillingConfig> prefillings;
public Map<String, PrefillingConfig> getPrefillings() {
return prefillings;
}
@XmlJavaTypeAdapter(PrefillingConfigMapAdapter.class)
@XmlElement(name = "prefillings")
public void setPrefillings(Map<String, PrefillingConfig> prefillings) {
this.prefillings = prefillings;
}
}

View File

@ -18,7 +18,6 @@ import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet;
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
import eu.eudat.service.externalfetcher.ExternalUrlConfigProvider;
import eu.eudat.service.externalfetcher.config.entities.*;
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
import gr.cite.tools.data.builder.BuilderFactory;
@ -59,7 +58,6 @@ public class PrefillingServiceImpl implements PrefillingService {
private final BuilderFactory builderFactory;
private final ConventionService conventionService;
private final MessageSource messageSource;
private final ExternalUrlConfigProvider externalUrlConfigProvider;
private final XmlHandlingService xmlHandlingService;
private final ValidatorFactory validatorFactory;
@Autowired
@ -68,14 +66,12 @@ public class PrefillingServiceImpl implements PrefillingService {
BuilderFactory builderFactory,
ConventionService conventionService,
MessageSource messageSource,
ExternalUrlConfigProvider externalUrlConfigProvider,
XmlHandlingService xmlHandlingService,
ValidatorFactory validatorFactory) {
this.entityManager = entityManager;
this.builderFactory = builderFactory;
this.conventionService = conventionService;
this.messageSource = messageSource;
this.externalUrlConfigProvider = externalUrlConfigProvider;
this.xmlHandlingService = xmlHandlingService;
this.validatorFactory = validatorFactory;
}
@ -88,7 +84,6 @@ public class PrefillingServiceImpl implements PrefillingService {
externalReferenceCriteria.setLike(lookup.getLike());
List<PrefillingEntity> prefillings = new ArrayList<>();
List<Map<String, String>> map;
Map<String, PrefillingConfig> prefillingConfigs = this.externalUrlConfigProvider.getExternalUrls().getPrefillings();
// for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {//TODO new reference logic
// map = remoteFetcherService.getExternalData(prefillingConfig.getPrefillingSearch().getUrls(), externalReferenceCriteria, prefillingConfig.getPrefillingSearch().getFetchMode());
// prefillings.addAll(map.stream().map(submap -> PrefillingEntity.build(submap, this.jsonHandlingService)).toList());
@ -105,7 +100,7 @@ public class PrefillingServiceImpl implements PrefillingService {
@Override
public Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(model.getConfigId());
PrefillingConfig prefillingConfig = null;
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
Map<String, Object> prefillingEntity = getSinglePrefillingData(prefillingGet.getUrl(), model.getPrefillId());
DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest();
@ -129,7 +124,7 @@ public class PrefillingServiceImpl implements PrefillingService {
@Override
public Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(model.getConfigId());
PrefillingConfig prefillingConfig = null;
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());

View File

@ -33,8 +33,6 @@ public interface StorageFileService extends ApplicationListener<ApplicationReady
byte[] getSemanticsFile();
byte[] getExternalUrlsFile();
byte[] getPidLinksFile();
byte[] getH2020TemplateFile();

View File

@ -333,16 +333,6 @@ public class StorageFileServiceImpl implements StorageFileService {
}
}
@Override
public byte[] getExternalUrlsFile() {
try {
return this.readFileBytes(this.config.getStaticFiles().getExternalUrls());
}
catch (Exception ex) {
logger.warn("problem reading ExternalUrls file", ex);
return null;
}
}
@Override
public byte[] getPidLinksFile() {

View File

@ -1,5 +1,5 @@
export enum PrefillingSourceSystemTargetType {
Label = "label",
Description = "description",
Tags= "tags"
Tags= "descriptionTags"
}