remove ExternalUrlConfigProvider
This commit is contained in:
parent
067e81207f
commit
fd77a44039
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSet;
|
||||||
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
|
import eu.eudat.model.descriptionproperties.PropertyDefinitionFieldSetItem;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
import eu.eudat.model.persist.DescriptionProfilingRequest;
|
||||||
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
|
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
|
||||||
import eu.eudat.service.externalfetcher.ExternalUrlConfigProvider;
|
|
||||||
import eu.eudat.service.externalfetcher.config.entities.*;
|
import eu.eudat.service.externalfetcher.config.entities.*;
|
||||||
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
import eu.eudat.service.externalfetcher.criteria.ExternalReferenceCriteria;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
@ -59,7 +58,6 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private final ConventionService conventionService;
|
private final ConventionService conventionService;
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
|
||||||
private final XmlHandlingService xmlHandlingService;
|
private final XmlHandlingService xmlHandlingService;
|
||||||
private final ValidatorFactory validatorFactory;
|
private final ValidatorFactory validatorFactory;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -68,14 +66,12 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
BuilderFactory builderFactory,
|
BuilderFactory builderFactory,
|
||||||
ConventionService conventionService,
|
ConventionService conventionService,
|
||||||
MessageSource messageSource,
|
MessageSource messageSource,
|
||||||
ExternalUrlConfigProvider externalUrlConfigProvider,
|
|
||||||
XmlHandlingService xmlHandlingService,
|
XmlHandlingService xmlHandlingService,
|
||||||
ValidatorFactory validatorFactory) {
|
ValidatorFactory validatorFactory) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
this.conventionService = conventionService;
|
this.conventionService = conventionService;
|
||||||
this.messageSource = messageSource;
|
this.messageSource = messageSource;
|
||||||
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
this.validatorFactory = validatorFactory;
|
this.validatorFactory = validatorFactory;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +84,6 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
externalReferenceCriteria.setLike(lookup.getLike());
|
externalReferenceCriteria.setLike(lookup.getLike());
|
||||||
List<PrefillingEntity> prefillings = new ArrayList<>();
|
List<PrefillingEntity> prefillings = new ArrayList<>();
|
||||||
List<Map<String, String>> map;
|
List<Map<String, String>> map;
|
||||||
Map<String, PrefillingConfig> prefillingConfigs = this.externalUrlConfigProvider.getExternalUrls().getPrefillings();
|
|
||||||
// for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {//TODO new reference logic
|
// for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {//TODO new reference logic
|
||||||
// map = remoteFetcherService.getExternalData(prefillingConfig.getPrefillingSearch().getUrls(), externalReferenceCriteria, prefillingConfig.getPrefillingSearch().getFetchMode());
|
// map = remoteFetcherService.getExternalData(prefillingConfig.getPrefillingSearch().getUrls(), externalReferenceCriteria, prefillingConfig.getPrefillingSearch().getFetchMode());
|
||||||
// prefillings.addAll(map.stream().map(submap -> PrefillingEntity.build(submap, this.jsonHandlingService)).toList());
|
// prefillings.addAll(map.stream().map(submap -> PrefillingEntity.build(submap, this.jsonHandlingService)).toList());
|
||||||
|
@ -105,7 +100,7 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
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();
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
Map<String, Object> prefillingEntity = getSinglePrefillingData(prefillingGet.getUrl(), model.getPrefillId());
|
Map<String, Object> prefillingEntity = getSinglePrefillingData(prefillingGet.getUrl(), model.getPrefillId());
|
||||||
DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest();
|
DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest();
|
||||||
|
@ -129,7 +124,7 @@ public class PrefillingServiceImpl implements PrefillingService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
|
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();
|
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
|
||||||
|
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
|
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
|
||||||
|
|
|
@ -33,8 +33,6 @@ public interface StorageFileService extends ApplicationListener<ApplicationReady
|
||||||
|
|
||||||
byte[] getSemanticsFile();
|
byte[] getSemanticsFile();
|
||||||
|
|
||||||
byte[] getExternalUrlsFile();
|
|
||||||
|
|
||||||
byte[] getPidLinksFile();
|
byte[] getPidLinksFile();
|
||||||
|
|
||||||
byte[] getH2020TemplateFile();
|
byte[] getH2020TemplateFile();
|
||||||
|
|
|
@ -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
|
@Override
|
||||||
public byte[] getPidLinksFile() {
|
public byte[] getPidLinksFile() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export enum PrefillingSourceSystemTargetType {
|
export enum PrefillingSourceSystemTargetType {
|
||||||
Label = "label",
|
Label = "label",
|
||||||
Description = "description",
|
Description = "description",
|
||||||
Tags= "tags"
|
Tags= "descriptionTags"
|
||||||
}
|
}
|
Loading…
Reference in New Issue