prefiling service refactor

This commit is contained in:
Efstratios Giannopoulos 2024-01-05 18:32:24 +02:00
parent 043b43b9be
commit 658310d8ce
74 changed files with 1179 additions and 294 deletions

View File

@ -165,6 +165,10 @@ public final class Permission {
public static String EditTenantUser = "EditTenantUser"; public static String EditTenantUser = "EditTenantUser";
public static String DeleteTenantUser = "DeleteTenantUser"; public static String DeleteTenantUser = "DeleteTenantUser";
//Prefilling
public static String BrowsePrefilling = "BrowsePrefilling";
//Lock //Lock
public static String BrowseLock = "BrowseLock"; public static String BrowseLock = "BrowseLock";
public static String EditLock = "EditLock"; public static String EditLock = "EditLock";

View File

@ -77,15 +77,18 @@ public class DefinitionEntity implements XmlSerializable<DefinitionEntity> {
} }
return this; return this;
} }
public List<FieldEntity> getFieldById(String id){ public List<FieldEntity> getAllField(){
List<FieldEntity> fieldEntities = new ArrayList<>(); List<FieldEntity> fieldEntities = new ArrayList<>();
if (id == null || id.isBlank()) return fieldEntities;
if (this.getSections() != null){ if (this.getSections() != null){
for (SectionEntity sectionEntity: this.getSections()) { for (SectionEntity sectionEntity: this.getSections()) {
fieldEntities.addAll(sectionEntity.getFieldById(id)); fieldEntities.addAll(sectionEntity.getAllField());
} }
} }
return fieldEntities; return fieldEntities;
} }
public List<FieldEntity> getFieldById(String id) {
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
}
} }

View File

@ -191,10 +191,7 @@ public class FieldSetEntity implements DatabaseViewStyleDefinition, XmlSerializa
return this; return this;
} }
public List<FieldEntity> getAllField() {
public List<FieldEntity> getFieldById(String id){ return this.getFields() == null ? new ArrayList<>() : this.getFields();
if (this.getFields() == null || id == null || id.isBlank()) return new ArrayList<>();
return this.getFields().stream().filter(x-> id.equals(x.getId())).toList();
} }
} }

View File

@ -209,17 +209,16 @@ public class SectionEntity implements DatabaseViewStyleDefinition, XmlSerializab
return this; return this;
} }
public List<FieldEntity> getFieldById(String id){ public List<FieldEntity> getAllField(){
List<FieldEntity> fieldEntities = new ArrayList<>(); List<FieldEntity> fieldEntities = new ArrayList<>();
if (id == null || id.isBlank()) return fieldEntities;
if (this.getFieldSets() != null){ if (this.getFieldSets() != null){
for (FieldSetEntity fieldSetEntity: this.getFieldSets()) { for (FieldSetEntity fieldSetEntity: this.getFieldSets()) {
fieldEntities.addAll(fieldSetEntity.getFieldById(id)); fieldEntities.addAll(fieldSetEntity.getAllField());
} }
} }
if (this.getSections() != null){ if (this.getSections() != null){
for (SectionEntity sectionEntity: this.getSections()) { for (SectionEntity sectionEntity: this.getSections()) {
fieldEntities.addAll(sectionEntity.getFieldById(id)); fieldEntities.addAll(sectionEntity.getAllField());
} }
} }
return fieldEntities; return fieldEntities;

View File

@ -0,0 +1,65 @@
package eu.eudat.commons.types.prefilling;
import eu.eudat.commons.JsonHandlingService;
import java.util.Map;
public class PrefillingEntity {
private String pid;
private String name;
private Map<String, Object> data;
private String key;
private String tag;
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public static PrefillingEntity build(Map<String, String> fetchedData, JsonHandlingService jsonHandlingService){
PrefillingEntity m = new PrefillingEntity();
m.setPid(fetchedData.getOrDefault("pid", null));
m.setName(fetchedData.getOrDefault("name", null));
m.setKey(fetchedData.getOrDefault("key", null));
m.setTag(fetchedData.getOrDefault("tag", null));
m.setData(jsonHandlingService.fromJsonSafe(Map.class,fetchedData.getOrDefault("data", null)));
return m;
}
}

View File

@ -1,13 +1,19 @@
package eu.eudat.models.data.prefilling; package eu.eudat.model;
import java.util.Map; import java.util.Map;
public class Prefilling { public class Prefilling {
private String pid; private String pid;
public static final String _pid = "pid";
private String name; private String name;
public static final String _name = "name";
private Map<String, Object> data; private Map<String, Object> data;
public static final String _data = "data";
private String key; private String key;
public static final String _key = "key";
private String tag; private String tag;
public static final String _tag = "tag";
public String getPid() { public String getPid() {
return pid; return pid;

View File

@ -0,0 +1,23 @@
package eu.eudat.model;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.query.UserQuery;
import eu.eudat.query.lookup.UserRoleLookup;
import gr.cite.tools.data.query.Lookup;
import gr.cite.tools.data.query.QueryFactory;
import java.util.List;
import java.util.UUID;
public class PrefillingLookup extends Lookup {
private String like;
public String getLike() {
return like;
}
public void setLike(String like) {
this.like = like;
}
}

View File

@ -0,0 +1,94 @@
package eu.eudat.model.builder;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.ContactInfoType;
import eu.eudat.commons.types.prefilling.PrefillingEntity;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.UserEntity;
import eu.eudat.model.DmpAssociatedUser;
import eu.eudat.model.Prefilling;
import eu.eudat.model.User;
import eu.eudat.model.UserContactInfo;
import eu.eudat.query.UserContactInfoQuery;
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.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PrefillingBuilder extends BaseBuilder<Prefilling, PrefillingEntity> {
private final QueryFactory queryFactory;
private final BuilderFactory builderFactory;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
public PrefillingBuilder(ConventionService conventionService,
QueryFactory queryFactory,
BuilderFactory builderFactory) {
super(conventionService, new LoggerService(LoggerFactory.getLogger(PrefillingBuilder.class)));
this.queryFactory = queryFactory;
this.builderFactory = builderFactory;
}
public PrefillingBuilder authorize(EnumSet<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<Prefilling> build(FieldSet fields, List<PrefillingEntity> data) throws MyApplicationException {
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
this.logger.trace(new DataLogEntry("requested fields", fields));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
List<Prefilling> models = new ArrayList<>();
for (PrefillingEntity d : data) {
Prefilling m = new Prefilling();
if (fields.hasField(this.asIndexer(Prefilling._pid))) m.setPid(d.getPid());
if (fields.hasField(this.asIndexer(Prefilling._name))) m.setName(d.getName());
if (fields.hasField(this.asIndexer(Prefilling._key))) m.setKey(d.getKey());
if (fields.hasField(this.asIndexer(Prefilling._tag))) m.setTag(d.getTag());
if (fields.hasField(this.asIndexer(Prefilling._data))) m.setData(d.getData());
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
return models;
}
private Map<UUID, List<UserContactInfo>> collectUserContactInfos(FieldSet fields, List<UserEntity> data) throws MyApplicationException {
if (fields.isEmpty() || data.isEmpty()) return null;
this.logger.debug("checking related - {}", UserContactInfo.class.getSimpleName());
Map<UUID, List<UserContactInfo>> itemMap;
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(UserContactInfo._user, User._id));
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).authorize(this.authorize).userIds(data.stream().map(UserEntity::getId).distinct().collect(Collectors.toList()));
itemMap = this.builderFactory.builder(UserContactInfoBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getUser().getId());
if (!fields.hasField(this.asIndexer(UserContactInfo._user, User._id))) {
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getUser() != null).peek(x -> {
x.getUser().setId(null);
});
}
return itemMap;
}
}

View File

@ -0,0 +1,39 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.OwnedResource;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PrefillingCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PrefillingCensor.class));
protected final AuthorizationService authService;
public PrefillingCensor(ConventionService conventionService, AuthorizationService authService) {
super(conventionService);
this.authService = authService;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowsePrefilling);
}
}

View File

@ -0,0 +1,107 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.tools.fieldset.BaseFieldSet;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class DescriptionProfilingRequest {
private String prefillId;
public static final String _prefillId = "prefillId";
private String configId;
public static final String _configId = "configId";
private UUID descriptionTemplateId;
public static final String _descriptionTemplateId = "descriptionTemplateId";
private BaseFieldSet project;
public static final String _project = "project";
public String getPrefillId() {
return prefillId;
}
public void setPrefillId(String prefillId) {
this.prefillId = prefillId;
}
public String getConfigId() {
return configId;
}
public void setConfigId(String configId) {
this.configId = configId;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
}
public BaseFieldSet getProject() {
return project;
}
public void setProject(BaseFieldSet project) {
this.project = project;
}
@Component(DescriptionProfilingRequestValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionProfilingRequestValidator extends BaseValidator<DescriptionProfilingRequest> {
public static final String ValidatorName = "DescriptionProfilingRequestValidator";
private final MessageSource messageSource;
protected DescriptionProfilingRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<DescriptionProfilingRequest> modelClass() {
return DescriptionProfilingRequest.class;
}
@Override
protected List<Specification> specifications(DescriptionProfilingRequest item) {
return Arrays.asList(
this.spec()
.must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionProfilingRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getConfigId()))
.failOn(DescriptionProfilingRequest._configId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._configId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getPrefillId()))
.failOn(DescriptionProfilingRequest._prefillId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._prefillId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> item.getProject() != null)
.failOn(DescriptionProfilingRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingRequest._project}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -0,0 +1,106 @@
package eu.eudat.model.persist;
import eu.eudat.commons.validation.BaseValidator;
import eu.eudat.commons.validation.specification.Specification;
import eu.eudat.convention.ConventionService;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import gr.cite.tools.fieldset.BaseFieldSet;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class DescriptionProfilingWithDataRequest {
private Map<String, Object> data;
public static final String _data = "data";
private String configId;
public static final String _configId = "configId";
private UUID descriptionTemplateId;
public static final String _descriptionTemplateId = "descriptionTemplateId";
private BaseFieldSet project;
public static final String _project = "project";
public Map<String, Object> getData() {
return data;
}
public void setData(Map<String, Object> data) {
this.data = data;
}
public String getConfigId() {
return configId;
}
public void setConfigId(String configId) {
this.configId = configId;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
}
public BaseFieldSet getProject() {
return project;
}
public void setProject(BaseFieldSet project) {
this.project = project;
}
@Component(DescriptionProfilingWithDataRequestValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class DescriptionProfilingWithDataRequestValidator extends BaseValidator<DescriptionProfilingWithDataRequest> {
public static final String ValidatorName = "DescriptionProfilingWithDataRequestValidator";
private final MessageSource messageSource;
protected DescriptionProfilingWithDataRequestValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
super(conventionService, errors);
this.messageSource = messageSource;
}
@Override
protected Class<DescriptionProfilingWithDataRequest> modelClass() {
return DescriptionProfilingWithDataRequest.class;
}
@Override
protected List<Specification> specifications(DescriptionProfilingWithDataRequest item) {
return Arrays.asList(
this.spec()
.must(() -> this.isValidGuid(item.getDescriptionTemplateId()))
.failOn(DescriptionProfilingWithDataRequest._descriptionTemplateId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._descriptionTemplateId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getConfigId()))
.failOn(DescriptionProfilingWithDataRequest._configId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._configId}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> item.getData() != null)
.failOn(DescriptionProfilingWithDataRequest._data).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._data}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> item.getProject() != null)
.failOn(DescriptionProfilingWithDataRequest._project).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionProfilingWithDataRequest._project}, LocaleContextHolder.getLocale()))
);
}
}
}

View File

@ -0,0 +1,24 @@
package eu.eudat.service.prefilling;
import eu.eudat.model.Description;
import eu.eudat.model.Prefilling;
import eu.eudat.model.PrefillingLookup;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
import jakarta.xml.bind.JAXBException;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public interface PrefillingService {
List<Prefilling> getPrefillings(PrefillingLookup like);
Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException;
Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException;
}

View File

@ -0,0 +1,416 @@
package eu.eudat.service.prefilling;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.JsonHandlingService;
import eu.eudat.commons.XmlHandlingService;
import eu.eudat.commons.enums.FieldType;
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
import eu.eudat.commons.types.descriptiontemplate.fielddata.ComboBoxDataEntity;
import eu.eudat.commons.types.descriptiontemplate.fielddata.LicenseDataEntity;
import eu.eudat.commons.types.descriptiontemplate.fielddata.WordListDataEntity;
import eu.eudat.commons.types.prefilling.PrefillingEntity;
import eu.eudat.commons.validation.ValidatorFactory;
import eu.eudat.convention.ConventionService;
import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.ReferenceEntity;
import eu.eudat.file.transformer.utils.helpers.StreamDistinctBy;
import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionTemplateBuilder;
import eu.eudat.model.builder.PrefillingBuilder;
import eu.eudat.model.builder.ReferenceBuilder;
import eu.eudat.model.descriptionproperties.Field;
import eu.eudat.model.descriptionproperties.PropertyDefinition;
import eu.eudat.model.persist.DescriptionProfilingRequest;
import eu.eudat.model.persist.DescriptionProfilingWithDataRequest;
import eu.eudat.query.ReferenceQuery;
import eu.eudat.service.remotefetcher.ExternalUrlConfigProvider;
import eu.eudat.service.remotefetcher.RemoteFetcherService;
import eu.eudat.service.remotefetcher.config.entities.*;
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager;
import jakarta.xml.bind.JAXBException;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class PrefillingServiceImpl implements PrefillingService {
private final static String Zenodo = "zenodo";
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PrefillingServiceImpl.class));
private final EntityManager entityManager;
private final BuilderFactory builderFactory;
private final QueryFactory queryFactory;
private final ConventionService conventionService;
private final MessageSource messageSource;
private final RemoteFetcherService remoteFetcherService;
private final JsonHandlingService jsonHandlingService;
private final ExternalUrlConfigProvider externalUrlConfigProvider;
private final XmlHandlingService xmlHandlingService;
private final ValidatorFactory validatorFactory;
@Autowired
public PrefillingServiceImpl(
EntityManager entityManager,
BuilderFactory builderFactory,
QueryFactory queryFactory,
ConventionService conventionService,
MessageSource messageSource,
RemoteFetcherService remoteFetcherService,
JsonHandlingService jsonHandlingService,
ExternalUrlConfigProvider externalUrlConfigProvider,
XmlHandlingService xmlHandlingService,
ValidatorFactory validatorFactory) {
this.entityManager = entityManager;
this.builderFactory = builderFactory;
this.queryFactory = queryFactory;
this.conventionService = conventionService;
this.messageSource = messageSource;
this.remoteFetcherService = remoteFetcherService;
this.jsonHandlingService = jsonHandlingService;
this.externalUrlConfigProvider = externalUrlConfigProvider;
this.xmlHandlingService = xmlHandlingService;
this.validatorFactory = validatorFactory;
}
@Override
public List<Prefilling> getPrefillings(PrefillingLookup lookup) {
logger.debug(new MapLogEntry("persisting data").And("lookup", lookup));
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
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()) {
map = remoteFetcherService.getExternalGeneric(externalReferenceCriteria, prefillingConfig.getPrefillingSearch());
prefillings.addAll(map.stream().map(submap -> PrefillingEntity.build(submap, this.jsonHandlingService)).toList());
if (prefillingConfig.getPrefillingSearch().getUrlConfig().isDataInListing()) {
List<Map<String, Object>> mapData = remoteFetcherService.getExternalGenericWithData(externalReferenceCriteria, prefillingConfig.getPrefillingSearch());
for (int i = 0; i < mapData.size(); i++) {
prefillings.get(i).setData(mapData.get(i));
}
prefillings = prefillings.stream().filter(prefilling -> prefilling.getData() != null).collect(Collectors.toList());
}
}
return this.builderFactory.builder(PrefillingBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(lookup.getProject(), Prefilling._pid), prefillings);
}
@Override
public Description getPrefilledDescription(DescriptionProfilingRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(model.getConfigId());
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
Map<String, Object> prefillingEntity = getSinglePrefillingData(prefillingGet.getUrl(), model.getPrefillId());
DescriptionProfilingWithDataRequest descriptionProfilingWithDataRequest = new DescriptionProfilingWithDataRequest();
descriptionProfilingWithDataRequest.setConfigId(model.getConfigId());
descriptionProfilingWithDataRequest.setProject(model.getProject());
descriptionProfilingWithDataRequest.setDescriptionTemplateId(model.getDescriptionTemplateId());
descriptionProfilingWithDataRequest.setData(prefillingEntity);
validatorFactory.validator(DescriptionProfilingWithDataRequest.DescriptionProfilingWithDataRequestValidator.ValidatorName).validateForce(descriptionProfilingWithDataRequest);
return this.getPrefilledDescriptionUsingData(descriptionProfilingWithDataRequest);
}
private Map<String, Object> getSinglePrefillingData(String url, String id) {
RestTemplate restTemplate = new RestTemplate();
String parsedUrl = url.replace("{id}", id);
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
HttpEntity<String> entity = new HttpEntity("", headers);
return restTemplate.exchange(parsedUrl, HttpMethod.GET, entity, LinkedHashMap.class).getBody();
}
@Override
public Description getPrefilledDescriptionUsingData(DescriptionProfilingWithDataRequest model) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
PrefillingConfig prefillingConfig = this.externalUrlConfigProvider.getExternalUrls().getPrefillings().get(model.getConfigId());
PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet();
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
if (descriptionTemplateEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
Description description = new Description();
description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(model.getProject(), descriptionTemplateEntity));
return mapPrefilledEntityToDescription(description, model.getData(), prefillingGet, prefillingConfig.getType(), descriptionTemplateDefinition);
}
//region Description Mapping
private Object getValueFromPath(Map<String, Object> data, String path){
if (path == null || this.conventionService.isNullOrEmpty(path) || data == null) return null;
if (path.contains(".")){
String[] paths = path.split("\\.");
if (paths.length == 0) return null;
else {
Object value = data.getOrDefault(paths[0], null);
if (value instanceof Map) return this.getValueFromPath((Map) value, path.substring(paths[0].length() + 1));
else return null;
}
}else {
return data.getOrDefault(path, null);
}
}
private Description mapPrefilledEntityToDescription(Description description, Map<String, Object> prefilledData, PrefillingGet prefillingGet, String type, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition){
for (DefaultPrefillingMapping prefillingMapping: prefillingGet.getMappings()) {
Object sourceValue = this.getValueFromPath(prefilledData, prefillingMapping.getSource());
try {
setValueToDescription(description, prefillingMapping, sourceValue, descriptionTemplateDefinition, type);
}
catch (Exception e) {
logger.warn("Couldn't map " + (this.conventionService.isNullOrEmpty(prefillingMapping.getSemanticTarget()) ? prefillingMapping.getTarget() : prefillingMapping.getSemanticTarget()));
}
}
for (PrefillingFixedMapping fixedMapping: prefillingGet.getFixedMappings()) {
try {
setValueToDescription(description, fixedMapping, fixedMapping.getValue(), descriptionTemplateDefinition, type);
}
catch (Exception e) {
logger.warn("Couldn't map " + (this.conventionService.isNullOrEmpty(fixedMapping.getSemanticTarget()) ? fixedMapping.getTarget() : fixedMapping.getSemanticTarget()));
}
}
return description;
}
private void setValueToDescription(Description description, PrefillingMapping prefillingMapping, Object value, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition, String type) {
JsonNode valueNode = new ObjectMapper().valueToTree(value);
String parsedValue = this.getValueAsString(prefillingMapping, valueNode);
List<String> parsedValues = this.getValueAsStringArray(prefillingMapping, valueNode);
if (prefillingMapping.getTarget() != null) {
this.applyValueToDescriptionObject(description, prefillingMapping, parsedValue, parsedValues);
} else {
// zenodo prefilling customizations
if(type.equals(PrefillingServiceImpl.Zenodo)){
if(prefillingMapping.getSemanticTarget().equals("rda.dataset.distribution.data_access")){
if(parsedValue != null && parsedValue.equals("open")){
List<FieldEntity> issuedFieldEntities = definition.getAllField().stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.issued")).toList();
if(this.conventionService.isListNullOrEmpty(issuedFieldEntities)){
String issuedIdNode = issuedFieldEntities.getFirst().getId();
String issuedValue = description.getProperties().getFields().stream().filter(x-> x.getKey().equals(issuedIdNode)).map(Field::getValue).findFirst().orElse(null);//TODO
List<FieldEntity> licStartEntities = definition.getAllField().stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains("rda.dataset.distribution.license.start_date")).toList();
if(this.conventionService.isListNullOrEmpty(licStartEntities)) {
for (FieldEntity licStartDateNode : licStartEntities) {
String licStartDateId = licStartDateNode.getId();
Field field = new Field();
field.setKey(licStartDateId);
field.setValue(issuedValue);
description.getProperties().getFields().add(field);
}
}
}
}
}
if (prefillingMapping.getSemanticTarget().equals("rda.dataset.distribution.available_until") && parsedValue != null && !parsedValue.equals("null")) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
LocalDate date = LocalDate.parse(parsedValue, formatter);
date = date.plusYears(20);
parsedValue = date.toString();
}
}
List<FieldEntity> fieldEntities = definition.getAllField().stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains(prefillingMapping.getSemanticTarget())).toList();
for (FieldEntity fieldEntity: fieldEntities) {
if (description.getProperties() == null) description.setProperties(new PropertyDefinition());
if (description.getProperties().getFields() == null) description.getProperties().setFields(new ArrayList<>());
description.getProperties().getFields().add(buildFieldValue(fieldEntity, parsedValue, parsedValues, type));
}
}
}
private void applyValueToDescriptionObject(Description description, PrefillingMapping prefillingMapping, String parsedValue, List<String> parsedValues){
switch (prefillingMapping.getTarget()){
case Description._description:{
description.setDescription(parsedValue);
}
case Description._label:{
description.setLabel(parsedValue);
}
case Description._descriptionTags:{
if (!parsedValues.isEmpty()){
for (String tagString : parsedValues){
if (description.getDescriptionTags() == null) description.setDescriptionTags(new ArrayList<>());
if(description.getDescriptionTags().stream().anyMatch(x-> x.getTag() !=null && x.getTag().getLabel().equals(tagString))) continue;
DescriptionTag descriptionTag = new DescriptionTag();
Tag tag = new Tag();
tag.setLabel(tagString.trim());
descriptionTag.setTag(tag);
description.getDescriptionTags().add(descriptionTag);
}
}
}
}
}
private Field buildFieldValue(FieldEntity fieldEntity, String parsedValue, List<String> parsedValues, String type){
String id = fieldEntity.getId();
Field field = new Field();
field.setKey(id);
switch (fieldEntity.getData().getFieldType()) {
case COMBO_BOX:
case AUTO_COMPLETE:
case WORD_LIST: {
if (!parsedValues.stream().allMatch(Objects::isNull)) {
field.setValue(this.jsonHandlingService.toJsonSafe(parseComboBoxValues(fieldEntity, parsedValues)));
}
break;
}
case TAGS: {
if (!parsedValues.isEmpty()) {
field.setValue(jsonHandlingService.toJsonSafe(parseTags(String.join(", ", parsedValues))));
}
break;
}
case DATASET_IDENTIFIER: {
JSONObject datasetID = new JSONObject();
datasetID.put("identifier", parsedValue);
if (type.equals(PrefillingServiceImpl.Zenodo)) {
datasetID.put("type", "doi");
}
field.setValue(datasetID.toString());
break;
}
case LICENSES: {
List<ReferenceEntity> licenses = this.queryFactory.query(ReferenceQuery.class).references(parsedValues).collect();
LicenseDataEntity wordListDataEntity = (LicenseDataEntity) fieldEntity.getData();
if (licenses != null && !licenses.isEmpty() && wordListDataEntity != null) {
boolean isMultiAutocomplete = wordListDataEntity.getMultiAutoComplete();
List<Reference> licenseModels = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(new BaseFieldSet(), licenses);
if (isMultiAutocomplete) {
field.setValue(jsonHandlingService.toJsonSafe(licenseModels));
} else {
field.setValue(jsonHandlingService.toJsonSafe(licenseModels.getFirst()));
}
}
break;
}
default:
field.setValue(parsedValue);
break;
}
return field;
}
private List<String> getValueAsStringArray(PrefillingMapping prefillingMapping, Object value){
String trimRegex = !this.conventionService.isNullOrEmpty(prefillingMapping.getTrimRegex()) ? prefillingMapping.getTrimRegex() : "";
List<String> parsedValues = new ArrayList<>();
if (value instanceof String){
parsedValues.add(((String) value).replace(trimRegex, ""));
} else if (value.getClass().isArray()){
if (value instanceof String[]){
List<String> values = new LinkedList<>();
for (String val : (String[]) value) {
parsedValues.add(val.replace(trimRegex, ""));
}
} else {
if (prefillingMapping.getSubSource() == null || prefillingMapping.getSubSource().isEmpty()) {
throw new MyApplicationException("Source value is an array but no subSource field have been set");
}
for (Object obj : (Object[]) value) {
if (obj instanceof Map) {
Object property = ((Map)obj).getOrDefault(prefillingMapping.getSubSource(), null);
if (property instanceof String) {
parsedValues.add(((String) property).replaceAll(trimRegex, ""));
}
}
}
}
}
parsedValues = parsedValues.stream().distinct().collect(Collectors.toList());
return parsedValues;
}
private String getValueAsString(PrefillingMapping prefillingMapping, Object value){
List<String> parsedValues = this.getValueAsStringArray(prefillingMapping, value);
return parsedValues.isEmpty() ? null : String.join(", ", parsedValues);
}
private Object parseComboBoxValues(FieldEntity fieldEntity, List<String> parsedValues) {
List<String> normalizedValues = new ArrayList<>();
boolean isMultiSelect;
if(fieldEntity.getData().getFieldType().equals(FieldType.AUTO_COMPLETE)) {
AutoCompleteDataEntity autoCompleteData = (AutoCompleteDataEntity)fieldEntity.getData();
isMultiSelect = autoCompleteData.getMultiAutoComplete();
// for (String format : parsedValues) {
// List<ExternalAutocompleteFieldModel> result = new ArrayList<>();
// try {
// result = datasetProfileManager.getAutocomplete(autoCompleteData, format);
// }
// catch (Exception e) {
// logger.error(e.getMessage(), e);
// }
// result = result.stream().filter(StreamDistinctBy.distinctByKey(ExternalAutocompleteFieldModel::getId)).collect(Collectors.toList());
// if(!result.isEmpty()){
// List<String> tempValues = new LinkedList<>();
// for (ExternalAutocompleteFieldModel f : result) {
// if (format.equals(f.getId()) || f.getLabel().toUpperCase(Locale.ROOT).contains(format.toUpperCase(Locale.ROOT)))
// tempValues.add(mapper.valueToTree(f).toString());
// }
// if (isMultiSelect)
// normalizedValues.addAll(tempValues);
// else if (!tempValues.isEmpty())
// normalizedValues.add(tempValues.get(0));
// }
// }
return !normalizedValues.isEmpty() ? (isMultiSelect ? normalizedValues : normalizedValues.getFirst()) : null;
} else {
WordListDataEntity wordListDataEntity = (WordListDataEntity)fieldEntity.getData();
isMultiSelect = wordListDataEntity.getMultiList();
if (wordListDataEntity.getOptions() != null) {
for (ComboBoxDataEntity.Option option : wordListDataEntity.getOptions()) {
if (parsedValues.contains(option.getValue())) {
normalizedValues.add(option.getValue());
}
}
}
List<String> normalizedStringValues = normalizedValues.stream().map(Object::toString).collect(Collectors.toList());
return !normalizedValues.isEmpty() ? (isMultiSelect ? String.join(", ", normalizedStringValues) : normalizedValues.getFirst()) : null;
}
}
private static List<Tag> parseTags(String value) {
if (value == null || value.isEmpty())
return new LinkedList<>();
String[] rawTags = value.split(",");
List<Tag> parsedTags = new LinkedList<>();
for (String rawTag : rawTags) {
Tag tag = new Tag();
tag.setLabel(rawTag.trim());
parsedTags.add(tag);
}
return parsedTags;
}
//endregion aa
}

View File

@ -1,6 +1,6 @@
package eu.eudat.service.reference; package eu.eudat.service.reference;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import gr.cite.tools.cache.CacheService; import gr.cite.tools.cache.CacheService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -29,10 +29,10 @@ import eu.eudat.query.ReferenceQuery;
import eu.eudat.query.ReferenceTypeQuery; import eu.eudat.query.ReferenceTypeQuery;
import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup; import eu.eudat.query.lookup.ReferenceDefinitionSearchLookup;
import eu.eudat.query.lookup.ReferenceSearchLookup; import eu.eudat.query.lookup.ReferenceSearchLookup;
import eu.eudat.service.reference.external.RemoteFetcher; import eu.eudat.service.remotefetcher.RemoteFetcherService;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.models.ExternalRefernceResult; import eu.eudat.service.remotefetcher.models.ExternalRefernceResult;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
@ -74,7 +74,7 @@ import java.util.stream.Collectors;
public class ReferenceServiceImpl implements ReferenceService { public class ReferenceServiceImpl implements ReferenceService {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceServiceImpl.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceServiceImpl.class));
private final RemoteFetcher remoteFetcher; private final RemoteFetcherService remoteFetcherService;
private final EntityManager entityManager; private final EntityManager entityManager;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
private final DeleterFactory deleterFactory; private final DeleterFactory deleterFactory;
@ -86,7 +86,7 @@ public class ReferenceServiceImpl implements ReferenceService {
private final WebClient client; private final WebClient client;
public ReferenceServiceImpl(RemoteFetcher remoteFetcher, public ReferenceServiceImpl(RemoteFetcherService remoteFetcherService,
EntityManager entityManager, EntityManager entityManager,
AuthorizationService authorizationService, AuthorizationService authorizationService,
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
@ -95,7 +95,7 @@ public class ReferenceServiceImpl implements ReferenceService {
MessageSource messageSource, MessageSource messageSource,
QueryFactory queryFactory, QueryFactory queryFactory,
XmlHandlingService xmlHandlingService) { XmlHandlingService xmlHandlingService) {
this.remoteFetcher = remoteFetcher; this.remoteFetcherService = remoteFetcherService;
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory; this.deleterFactory = deleterFactory;
@ -205,7 +205,7 @@ public class ReferenceServiceImpl implements ReferenceService {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(lookup.getLike()); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(lookup.getLike());
List<Map<String, String>> remoteRepos = remoteFetcher.getReferences(lookup.getType(), externalReferenceCriteria, lookup.getKey()); List<Map<String, String>> remoteRepos = remoteFetcherService.getReferences(lookup.getType(), externalReferenceCriteria, lookup.getKey());
List<Reference> externalModels = this.builderFactory.builder(ReferenceSearchBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), remoteRepos); List<Reference> externalModels = this.builderFactory.builder(ReferenceSearchBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), remoteRepos);
List<Reference> models = this.fetchFromDb(lookup); List<Reference> models = this.fetchFromDb(lookup);

View File

@ -1,12 +0,0 @@
package eu.eudat.service.reference.external.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration;
import java.util.List;
public abstract class GenericUrls {
public abstract List<UrlConfiguration> getUrls();
public abstract FetchStrategy getFetchMode();
}

View File

@ -1,35 +0,0 @@
package eu.eudat.service.reference.external.config.entities;
import eu.eudat.service.reference.external.config.entities.GenericUrls;
import eu.eudat.service.reference.external.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class RepositoryUrls extends GenericUrls {
List<UrlConfiguration> urls;
FetchStrategy fetchMode;
public List<UrlConfiguration> getUrls() {
return urls;
}
@XmlElementWrapper
@XmlElement(name = "urlConfig")
public void setUrls(List<UrlConfiguration> urls) {
this.urls = urls;
}
public FetchStrategy getFetchMode() {
return fetchMode;
}
@XmlElement(name = "fetchMode")
public void setFetchMode(FetchStrategy fetchMode) {
this.fetchMode = fetchMode;
}
}

View File

@ -1,35 +0,0 @@
package eu.eudat.service.reference.external.config.entities;
import eu.eudat.service.reference.external.config.entities.GenericUrls;
import eu.eudat.service.reference.external.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class TaxonomiesUrls extends GenericUrls {
List<UrlConfiguration> urls;
FetchStrategy fetchMode;
public List<UrlConfiguration> getUrls() {
return urls;
}
@XmlElementWrapper
@XmlElement(name = "urlConfig")
public void setUrls(List<UrlConfiguration> urls) {
this.urls = urls;
}
public FetchStrategy getFetchMode() {
return fetchMode;
}
@XmlElement(name = "fetchMode")
public void setFetchMode(FetchStrategy fetchMode) {
this.fetchMode = fetchMode;
}
}

View File

@ -1,8 +0,0 @@
package eu.eudat.service.reference.external.criteria;
public enum FetchStrategy {
FIRST,
ALL
}

View File

@ -1,6 +1,6 @@
package eu.eudat.service.reference.external; package eu.eudat.service.remotefetcher;
import eu.eudat.service.reference.external.config.ExternalUrls; import eu.eudat.service.remotefetcher.config.ExternalUrls;
import eu.eudat.service.storage.StorageFileService; import eu.eudat.service.storage.StorageFileService;
import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;

View File

@ -0,0 +1,22 @@
package eu.eudat.service.remotefetcher;
import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.service.remotefetcher.config.entities.GenericUrls;
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import gr.cite.tools.exception.MyNotFoundException;
import java.util.List;
import java.util.Map;
public interface RemoteFetcherService {
List<Map<String, String>> getReferences(ReferenceType referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException;
GenericUrls getExternalUrls(ReferenceType referenceType);
Integer countEntries(ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException;
List<Map<String, String>> getExternalGeneric(ExternalReferenceCriteria externalReferenceCriteria, GenericUrls genericUrls);
List<Map<String, Object>> getExternalGenericWithData(ExternalReferenceCriteria externalReferenceCriteria, GenericUrls genericUrls);
}

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external; package eu.eudat.service.remotefetcher;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
@ -7,11 +7,14 @@ import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import eu.eudat.commons.enums.ReferenceType; import eu.eudat.commons.enums.ReferenceType;
import eu.eudat.commons.exceptions.HugeResultSetException; import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.service.reference.external.config.*; import eu.eudat.service.remotefetcher.config.AuthenticationConfiguration;
import eu.eudat.service.reference.external.config.entities.GenericUrls; import eu.eudat.service.remotefetcher.config.DataUrlConfiguration;
import eu.eudat.service.reference.external.models.ExternalRefernceResult; import eu.eudat.service.remotefetcher.config.QueryConfig;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.config.entities.GenericUrls;
import eu.eudat.service.remotefetcher.models.ExternalRefernceResult;
import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;
@ -35,13 +38,13 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class RemoteFetcher { public class RemoteFetcherServiceImpl implements RemoteFetcherService {
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class); private static final Logger logger = LoggerFactory.getLogger(RemoteFetcherServiceImpl.class);
private WebClient webClient; private WebClient webClient;
private final ExternalUrlConfigProvider externalUrlConfigProvider; private final ExternalUrlConfigProvider externalUrlConfigProvider;
@Autowired @Autowired
public RemoteFetcher(ExternalUrlConfigProvider externalUrlConfigProvider) { public RemoteFetcherServiceImpl(ExternalUrlConfigProvider externalUrlConfigProvider) {
this.externalUrlConfigProvider = externalUrlConfigProvider; this.externalUrlConfigProvider = externalUrlConfigProvider;
} }
@ -56,6 +59,7 @@ public class RemoteFetcher {
return webClient; return webClient;
} }
@Override
public List<Map<String, String>> getReferences(ReferenceType referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException { public List<Map<String, String>> getReferences(ReferenceType referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException {
FetchStrategy fetchStrategy = null; FetchStrategy fetchStrategy = null;
GenericUrls exGenericUrls = this.getExternalUrls(referenceType); GenericUrls exGenericUrls = this.getExternalUrls(referenceType);
@ -69,6 +73,7 @@ public class RemoteFetcher {
return results; return results;
} }
@Override
public GenericUrls getExternalUrls(ReferenceType referenceType) { public GenericUrls getExternalUrls(ReferenceType referenceType) {
return switch (referenceType) { return switch (referenceType) {
case Taxonomies -> this.externalUrlConfigProvider.getExternalUrls().getTaxonomies(); case Taxonomies -> this.externalUrlConfigProvider.getExternalUrls().getTaxonomies();
@ -89,6 +94,7 @@ public class RemoteFetcher {
}; };
} }
@Override
public Integer countEntries(ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException { public Integer countEntries(ExternalReferenceCriteria externalReferenceCriteria, String key) throws MyNotFoundException, HugeResultSetException {
List<UrlConfiguration> urlConfigs = List<UrlConfiguration> urlConfigs =
key != null && !key.isEmpty() ? this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList()) key != null && !key.isEmpty() ? this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
@ -98,12 +104,14 @@ public class RemoteFetcher {
return data.size(); return data.size();
} }
@Override
public List<Map<String, String>> getExternalGeneric(ExternalReferenceCriteria externalReferenceCriteria, GenericUrls genericUrls) { public List<Map<String, String>> getExternalGeneric(ExternalReferenceCriteria externalReferenceCriteria, GenericUrls genericUrls) {
List<UrlConfiguration> urlConfigurations = genericUrls.getUrls(); List<UrlConfiguration> urlConfigurations = genericUrls.getUrls();
FetchStrategy fetchStrategy = genericUrls.getFetchMode(); FetchStrategy fetchStrategy = genericUrls.getFetchMode();
return getAll(urlConfigurations, fetchStrategy, externalReferenceCriteria); return getAll(urlConfigurations, fetchStrategy, externalReferenceCriteria);
} }
@Override
public List<Map<String, Object>> getExternalGenericWithData(ExternalReferenceCriteria externalReferenceCriteria, GenericUrls genericUrls) { public List<Map<String, Object>> getExternalGenericWithData(ExternalReferenceCriteria externalReferenceCriteria, GenericUrls genericUrls) {
List<UrlConfiguration> urlConfigurations = genericUrls.getUrls(); List<UrlConfiguration> urlConfigurations = genericUrls.getUrls();
return getAllWithData(urlConfigurations, externalReferenceCriteria); return getAllWithData(urlConfigurations, externalReferenceCriteria);

View File

@ -1,10 +1,10 @@
package eu.eudat.service.reference.external; package eu.eudat.service.remotefetcher;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.DocumentContext;
import eu.eudat.service.reference.external.config.DataUrlConfiguration; import eu.eudat.service.remotefetcher.config.DataUrlConfiguration;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.service.reference.external.models.ExternalRefernceResult; import eu.eudat.service.remotefetcher.models.ExternalRefernceResult;
import net.minidev.json.JSONArray; import net.minidev.json.JSONArray;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -23,7 +23,7 @@ public class RemoteFetcherUtils {
new HashMap<>(1, 1)); new HashMap<>(1, 1));
} }
public static ExternalRefernceResult getFromJsonWithRecursiveFetching(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath, RemoteFetcher remoteFetcher, String requestBody, String requestType, String auth) { public static ExternalRefernceResult getFromJsonWithRecursiveFetching(DocumentContext jsonContext, DataUrlConfiguration jsonDataPath, RemoteFetcherServiceImpl remoteFetcherService, String requestBody, String requestType, String auth) {
ExternalRefernceResult externalRefernceResult = new ExternalRefernceResult(parseData(jsonContext, jsonDataPath), ExternalRefernceResult externalRefernceResult = new ExternalRefernceResult(parseData(jsonContext, jsonDataPath),
new HashMap<>(1, 1)); new HashMap<>(1, 1));
@ -31,8 +31,8 @@ public class RemoteFetcherUtils {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
externalReferenceCriteria.setPath(result.get("path")); externalReferenceCriteria.setPath(result.get("path"));
externalReferenceCriteria.setHost(result.get("host")); externalReferenceCriteria.setHost(result.get("host"));
String replacedPath = remoteFetcher.replaceCriteriaOnUrl(jsonDataPath.getUrlConfiguration().getUrl(), externalReferenceCriteria, jsonDataPath.getUrlConfiguration().getFirstpage(), jsonDataPath.getUrlConfiguration().getQueries()); String replacedPath = remoteFetcherService.replaceCriteriaOnUrl(jsonDataPath.getUrlConfiguration().getUrl(), externalReferenceCriteria, jsonDataPath.getUrlConfiguration().getFirstpage(), jsonDataPath.getUrlConfiguration().getQueries());
return remoteFetcher.getResultsFromUrl(replacedPath, jsonDataPath.getUrlConfiguration().getData(), jsonDataPath.getUrlConfiguration().getData().getPath(), jsonDataPath.getUrlConfiguration().getContentType(), requestBody, requestType, auth); return remoteFetcherService.getResultsFromUrl(replacedPath, jsonDataPath.getUrlConfiguration().getData(), jsonDataPath.getUrlConfiguration().getData().getPath(), jsonDataPath.getUrlConfiguration().getContentType(), requestBody, requestType, auth);
}).filter(Objects::nonNull).map(externalRefernceResult1 -> externalRefernceResult1.getResults().get(0)).collect(Collectors.toList()); }).filter(Objects::nonNull).map(externalRefernceResult1 -> externalRefernceResult1.getResults().get(0)).collect(Collectors.toList());
return new ExternalRefernceResult(multiResults, new HashMap<>(1, 1)); return new ExternalRefernceResult(multiResults, new HashMap<>(1, 1));
} }

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.config; package eu.eudat.service.remotefetcher.config;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.config; package eu.eudat.service.remotefetcher.config;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;

View File

@ -1,6 +1,5 @@
package eu.eudat.service.reference.external.config; package eu.eudat.service.remotefetcher.config;
import eu.eudat.service.reference.external.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List; import java.util.List;

View File

@ -1,9 +1,9 @@
package eu.eudat.service.reference.external.config; package eu.eudat.service.remotefetcher.config;
import eu.eudat.service.reference.external.config.prefilling.PrefillingConfigMapAdapter; import eu.eudat.service.remotefetcher.config.prefilling.PrefillingConfigMapAdapter;
import eu.eudat.service.reference.external.config.entities.*; import eu.eudat.service.remotefetcher.config.entities.*;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.config; package eu.eudat.service.remotefetcher.config;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.config; package eu.eudat.service.remotefetcher.config;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,8 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.config.entities.GenericUrls; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import eu.eudat.service.reference.external.config.UrlConfiguration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -0,0 +1,12 @@
package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import java.util.List;
public abstract class GenericUrls {
public abstract List<UrlConfiguration> getUrls();
public abstract FetchStrategy getFetchMode();
}

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,6 +1,5 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.config.entities.PrefillingSearch;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlRootElement;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,6 +1,4 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import jakarta.xml.bind.annotation.XmlAttribute;
public interface PrefillingMapping { public interface PrefillingMapping {
String getTarget(); String getTarget();

View File

@ -1,8 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.config.entities.GenericUrls; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import eu.eudat.service.reference.external.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -0,0 +1,34 @@
package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class RepositoryUrls extends GenericUrls {
List<UrlConfiguration> urls;
FetchStrategy fetchMode;
public List<UrlConfiguration> getUrls() {
return urls;
}
@XmlElementWrapper
@XmlElement(name = "urlConfig")
public void setUrls(List<UrlConfiguration> urls) {
this.urls = urls;
}
public FetchStrategy getFetchMode() {
return fetchMode;
}
@XmlElement(name = "fetchMode")
public void setFetchMode(FetchStrategy fetchMode) {
this.fetchMode = fetchMode;
}
}

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,7 +1,7 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -0,0 +1,34 @@
package eu.eudat.service.remotefetcher.config.entities;
import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class TaxonomiesUrls extends GenericUrls {
List<UrlConfiguration> urls;
FetchStrategy fetchMode;
public List<UrlConfiguration> getUrls() {
return urls;
}
@XmlElementWrapper
@XmlElement(name = "urlConfig")
public void setUrls(List<UrlConfiguration> urls) {
this.urls = urls;
}
public FetchStrategy getFetchMode() {
return fetchMode;
}
@XmlElement(name = "fetchMode")
public void setFetchMode(FetchStrategy fetchMode) {
this.fetchMode = fetchMode;
}
}

View File

@ -1,14 +1,12 @@
package eu.eudat.service.reference.external.config.entities; package eu.eudat.service.remotefetcher.config.entities;
import java.util.List; import java.util.List;
import eu.eudat.service.reference.external.config.entities.GenericUrls; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;
import eu.eudat.service.reference.external.criteria.FetchStrategy;
import eu.eudat.service.reference.external.config.UrlConfiguration;
public class ValidationUrls extends GenericUrls { public class ValidationUrls extends GenericUrls {
List<UrlConfiguration> urls; List<UrlConfiguration> urls;

View File

@ -1,6 +1,6 @@
package eu.eudat.service.reference.external.config.prefilling; package eu.eudat.service.remotefetcher.config.prefilling;
import eu.eudat.service.reference.external.config.entities.PrefillingConfig; import eu.eudat.service.remotefetcher.config.entities.PrefillingConfig;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBContext;

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.criteria; package eu.eudat.service.remotefetcher.criteria;
public class ExternalReferenceCriteria { public class ExternalReferenceCriteria {
private String like; private String like;

View File

@ -0,0 +1,8 @@
package eu.eudat.service.remotefetcher.criteria;
public enum FetchStrategy {
FIRST,
ALL
}

View File

@ -1,4 +1,4 @@
package eu.eudat.service.reference.external.models; package eu.eudat.service.remotefetcher.models;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,6 +1,6 @@
package eu.eudat.configurations.dynamicfunder.entities; package eu.eudat.configurations.dynamicfunder.entities;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,6 +1,6 @@
package eu.eudat.configurations.dynamicgrant.entities; package eu.eudat.configurations.dynamicgrant.entities;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,6 +1,6 @@
package eu.eudat.configurations.dynamicproject.entities; package eu.eudat.configurations.dynamicproject.entities;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper; import jakarta.xml.bind.annotation.XmlElementWrapper;

View File

@ -1,21 +1,16 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
import eu.eudat.configurations.dynamicgrant.entities.Language;
import eu.eudat.logic.managers.CommonsManager; import eu.eudat.logic.managers.CommonsManager;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration; import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.service.reference.external.ExternalUrlConfigProvider; import eu.eudat.service.remotefetcher.ExternalUrlConfigProvider;
import eu.eudat.service.storage.StorageFileService;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* Created by ikalyvas on 3/28/2018. * Created by ikalyvas on 3/28/2018.
*/ */

View File

@ -3,7 +3,7 @@ package eu.eudat.controllers;
import eu.eudat.logic.managers.PrefillingManager; import eu.eudat.logic.managers.PrefillingManager;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.prefilling.Prefilling; import eu.eudat.commons.types.prefilling.PrefillingEntity;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -27,9 +27,9 @@ public class Prefillings {
} }
@RequestMapping(method = RequestMethod.GET, value = {"/prefilling/list"}, produces = "application/json") @RequestMapping(method = RequestMethod.GET, value = {"/prefilling/list"}, produces = "application/json")
public ResponseEntity<ResponseItem<List<Prefilling>>> getPrefillingList(@RequestParam String like) { public ResponseEntity<ResponseItem<List<PrefillingEntity>>> getPrefillingList(@RequestParam String like) {
List<Prefilling> prefillingList = prefillingManager.getPrefillings(like); List<PrefillingEntity> prefillingList = prefillingManager.getPrefillings(like);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Prefilling>>().payload(prefillingList).status(ApiMessageCode.NO_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<PrefillingEntity>>().payload(prefillingList).status(ApiMessageCode.NO_MESSAGE));
} }
@RequestMapping(method = RequestMethod.GET, value = {"/prefilling/generate/{id}"}, produces = "application/json") @RequestMapping(method = RequestMethod.GET, value = {"/prefilling/generate/{id}"}, produces = "application/json")

View File

@ -33,7 +33,6 @@ public class DepositController extends BaseController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositController.class)); private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DepositController.class));
private final AuthorizationService authorizationService;
private final DepositService depositService; private final DepositService depositService;
@ -44,7 +43,6 @@ public class DepositController extends BaseController {
@Autowired @Autowired
public DepositController(ApiContext apiContext, AuthorizationService authorizationService, DepositService depositService, CensorFactory censorFactory, AuditService auditService) { public DepositController(ApiContext apiContext, AuthorizationService authorizationService, DepositService depositService, CensorFactory censorFactory, AuditService auditService) {
super(apiContext); super(apiContext);
this.authorizationService = authorizationService;
this.depositService = depositService; this.depositService = depositService;
this.censorFactory = censorFactory; this.censorFactory = censorFactory;
this.auditService = auditService; this.auditService = auditService;

View File

@ -2,15 +2,8 @@ package eu.eudat.logic.managers;
import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration; import eu.eudat.models.data.externalurl.ExternalSourcesConfiguration;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.service.reference.external.ExternalUrlConfigProvider; import eu.eudat.service.remotefetcher.ExternalUrlConfigProvider;
import eu.eudat.service.reference.external.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 java.io.ByteArrayInputStream;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**

View File

@ -5,17 +5,17 @@ import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEnti
import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.commons.types.xml.XmlBuilder;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.service.reference.external.config.entities.GeneralUrls; import eu.eudat.service.remotefetcher.config.entities.GeneralUrls;
import eu.eudat.service.reference.external.RemoteFetcher; import eu.eudat.service.remotefetcher.RemoteFetcherService;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel; import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
import eu.eudat.service.reference.external.config.AuthenticationConfiguration; import eu.eudat.service.remotefetcher.config.AuthenticationConfiguration;
import eu.eudat.service.reference.external.config.DataFieldsUrlConfiguration; import eu.eudat.service.remotefetcher.config.DataFieldsUrlConfiguration;
import eu.eudat.service.reference.external.config.DataUrlConfiguration; import eu.eudat.service.remotefetcher.config.DataUrlConfiguration;
import eu.eudat.service.reference.external.config.UrlConfiguration; import eu.eudat.service.remotefetcher.config.UrlConfiguration;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.remotefetcher.criteria.FetchStrategy;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -50,13 +50,13 @@ public class DatasetProfileManager {
private final DatabaseRepository databaseRepository; private final DatabaseRepository databaseRepository;
private final ConfigLoader configLoader; private final ConfigLoader configLoader;
private final RemoteFetcher remoteFetcher; private final RemoteFetcherService remoteFetcherService;
@Autowired @Autowired
public DatasetProfileManager(ApiContext apiContext, ConfigLoader configLoader, RemoteFetcher remoteFetcher) { public DatasetProfileManager(ApiContext apiContext, ConfigLoader configLoader, RemoteFetcherService remoteFetcherService) {
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.configLoader = configLoader; this.configLoader = configLoader;
this.remoteFetcher = remoteFetcher; this.remoteFetcherService = remoteFetcherService;
} }
public FieldEntity queryForField(String xml, String fieldId) throws XPathExpressionException { public FieldEntity queryForField(String xml, String fieldId) throws XPathExpressionException {
@ -189,7 +189,7 @@ public class DatasetProfileManager {
urlConfiguration.setAuth(authenticationConfiguration); urlConfiguration.setAuth(authenticationConfiguration);
} }
genericUrls.getUrls().add(urlConfiguration); genericUrls.getUrls().add(urlConfiguration);
List<Map<String, String>> singleResults = this.remoteFetcher.getExternalGeneric(urlCriteria, genericUrls); List<Map<String, String>> singleResults = this.remoteFetcherService.getExternalGeneric(urlCriteria, genericUrls);
if (!singleResults.isEmpty() && !singleResults.get(0).containsKey("source") && !singleData.getAutoCompleteOptions().getSource().isEmpty()) { if (!singleResults.isEmpty() && !singleResults.get(0).containsKey("source") && !singleData.getAutoCompleteOptions().getSource().isEmpty()) {
singleResults.forEach(singleResult -> singleResult.put("source", singleData.getAutoCompleteOptions().getSource())); singleResults.forEach(singleResult -> singleResult.put("source", singleData.getAutoCompleteOptions().getSource()));
} }

View File

@ -4,19 +4,13 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.DescriptionTemplateEntity; import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.logic.mapper.prefilling.PrefillingMapper; import eu.eudat.logic.mapper.prefilling.PrefillingMapper;
import eu.eudat.service.reference.external.ExternalUrlConfigProvider; import eu.eudat.service.remotefetcher.ExternalUrlConfigProvider;
import eu.eudat.service.reference.external.RemoteFetcher; import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.service.reference.external.config.ExternalUrls; import eu.eudat.service.remotefetcher.config.entities.PrefillingConfig;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.remotefetcher.config.entities.PrefillingGet;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.service.reference.external.config.entities.PrefillingConfig;
import eu.eudat.service.reference.external.config.entities.PrefillingGet;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.prefilling.Prefilling; import eu.eudat.commons.types.prefilling.PrefillingEntity;
import eu.eudat.service.storage.StorageFileService;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -24,7 +18,6 @@ import org.springframework.http.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.io.ByteArrayInputStream;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -49,15 +42,15 @@ public class PrefillingManager {
// this.licenseManager = licenseManager; // this.licenseManager = licenseManager;
} }
public List<Prefilling> getPrefillings(String like) { public List<PrefillingEntity> getPrefillings(String like) {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
externalReferenceCriteria.setLike(like); externalReferenceCriteria.setLike(like);
List<Prefilling> 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(); Map<String, PrefillingConfig> prefillingConfigs = this.externalUrlConfigProvider.getExternalUrls().getPrefillings();
for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) { for (PrefillingConfig prefillingConfig: prefillingConfigs.values()) {
map = apiContext.getOperationsContext().getRemoteFetcher().getExternalGeneric(externalReferenceCriteria, prefillingConfig.getPrefillingSearch()); map = apiContext.getOperationsContext().getRemoteFetcher().getExternalGeneric(externalReferenceCriteria, prefillingConfig.getPrefillingSearch());
prefillings.addAll(map.stream().map(submap -> objectMapper.convertValue(submap, Prefilling.class)).collect(Collectors.toList())); prefillings.addAll(map.stream().map(submap -> objectMapper.convertValue(submap, PrefillingEntity.class)).collect(Collectors.toList()));
if (prefillingConfig.getPrefillingSearch().getUrlConfig().isDataInListing()) { if (prefillingConfig.getPrefillingSearch().getUrlConfig().isDataInListing()) {
List<Map<String, Object>> mapData = apiContext.getOperationsContext().getRemoteFetcher().getExternalGenericWithData(externalReferenceCriteria, prefillingConfig.getPrefillingSearch()); List<Map<String, Object>> mapData = apiContext.getOperationsContext().getRemoteFetcher().getExternalGenericWithData(externalReferenceCriteria, prefillingConfig.getPrefillingSearch());
for (int i = 0; i < mapData.size(); i++) { for (int i = 0; i < mapData.size(); i++) {

View File

@ -5,26 +5,26 @@ import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.commons.exceptions.HugeResultSetException; import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.service.reference.external.RemoteFetcher; import eu.eudat.service.remotefetcher.RemoteFetcherService;
@Component @Component
public class ValidationManager { public class ValidationManager {
private RemoteFetcher remoteFetcher; private RemoteFetcherService remoteFetcherService;
private final UserScope userScope; private final UserScope userScope;
@Autowired @Autowired
public ValidationManager(RemoteFetcher remoteFetcher, UserScope userScope) { public ValidationManager(RemoteFetcherService remoteFetcherService, UserScope userScope) {
super(); super();
this.remoteFetcher = remoteFetcher; this.remoteFetcherService = remoteFetcherService;
this.userScope = userScope; this.userScope = userScope;
} }
public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException, HugeResultSetException { public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException, HugeResultSetException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier);
Integer count = this.remoteFetcher.countEntries(externalReferenceCriteria, type); Integer count = this.remoteFetcherService.countEntries(externalReferenceCriteria, type);
return this.userScope.isSet() && count > 0; return this.userScope.isSet() && count > 0;
} }

View File

@ -9,18 +9,16 @@ import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.TagEntity; import eu.eudat.data.TagEntity;
import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.managers.DatasetProfileManager; import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.service.reference.external.config.entities.DefaultPrefillingMapping; import eu.eudat.service.remotefetcher.config.entities.DefaultPrefillingMapping;
import eu.eudat.service.reference.external.config.entities.PrefillingFixedMapping; import eu.eudat.service.remotefetcher.config.entities.PrefillingFixedMapping;
import eu.eudat.service.reference.external.config.entities.PrefillingGet; import eu.eudat.service.remotefetcher.config.entities.PrefillingGet;
import eu.eudat.service.reference.external.config.entities.PrefillingMapping; import eu.eudat.service.remotefetcher.config.entities.PrefillingMapping;
import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy; import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.logic.utilities.json.JsonSearcher; import eu.eudat.logic.utilities.json.JsonSearcher;
import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity; import eu.eudat.commons.types.descriptiontemplate.fielddata.AutoCompleteDataEntity;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel; import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
import gr.cite.tools.exception.MyNotFoundException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -1,11 +1,8 @@
package eu.eudat.logic.proxy.config.configloaders; package eu.eudat.logic.proxy.config.configloaders;
import eu.eudat.service.descriptiontemplate.Semantic;
import eu.eudat.models.data.pid.PidLinks; import eu.eudat.models.data.pid.PidLinks;
import eu.eudat.service.reference.external.config.ExternalUrls;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface ConfigLoader { public interface ConfigLoader {

View File

@ -3,7 +3,6 @@ package eu.eudat.logic.proxy.config.configloaders;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.models.data.pid.PidLinks; import eu.eudat.models.data.pid.PidLinks;
import eu.eudat.service.reference.external.config.ExternalUrls;
import eu.eudat.service.storage.StorageFileService; import eu.eudat.service.storage.StorageFileService;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -15,8 +14,6 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;

View File

@ -1,9 +1,9 @@
package eu.eudat.logic.services; package eu.eudat.logic.services;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.remotefetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.commons.exceptions.HugeResultSetException; import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.service.reference.external.RemoteFetcher; import eu.eudat.service.remotefetcher.RemoteFetcherService;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -11,19 +11,19 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ExternalValidationService { public class ExternalValidationService {
private RemoteFetcher remoteFetcher; private RemoteFetcherService remoteFetcherService;
private final UserScope userScope; private final UserScope userScope;
@Autowired @Autowired
public ExternalValidationService(RemoteFetcher remoteFetcher, UserScope userScope) { public ExternalValidationService(RemoteFetcherService remoteFetcherService, UserScope userScope) {
super(); super();
this.remoteFetcher = remoteFetcher; this.remoteFetcherService = remoteFetcherService;
this.userScope = userScope; this.userScope = userScope;
} }
public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException, HugeResultSetException { public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException, HugeResultSetException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier);
Integer count = this.remoteFetcher.countEntries(externalReferenceCriteria, type); Integer count = this.remoteFetcherService.countEntries(externalReferenceCriteria, type);
return userScope.isSet() && count > 0; return userScope.isSet() && count > 0;
} }

View File

@ -1,7 +1,7 @@
package eu.eudat.logic.services.operations; package eu.eudat.logic.services.operations;
import eu.eudat.logic.builders.BuilderFactory; import eu.eudat.logic.builders.BuilderFactory;
import eu.eudat.service.reference.external.RemoteFetcher; import eu.eudat.service.remotefetcher.RemoteFetcherService;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
/** /**
@ -15,7 +15,7 @@ public interface OperationsContext {
BuilderFactory getBuilderFactory(); BuilderFactory getBuilderFactory();
RemoteFetcher getRemoteFetcher(); RemoteFetcherService getRemoteFetcher();
// FileStorageService getFileStorageService(); // FileStorageService getFileStorageService();

View File

@ -1,7 +1,7 @@
package eu.eudat.logic.services.operations; package eu.eudat.logic.services.operations;
import eu.eudat.logic.builders.BuilderFactory; import eu.eudat.logic.builders.BuilderFactory;
import eu.eudat.service.reference.external.RemoteFetcher; import eu.eudat.service.remotefetcher.RemoteFetcherService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -14,17 +14,17 @@ public class OperationsContextImpl implements OperationsContext {
private final DatabaseRepository databaseRepository; private final DatabaseRepository databaseRepository;
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
private final RemoteFetcher remoteFetcher; private final RemoteFetcherService remoteFetcherService;
private final BuilderFactory builderFactory; private final BuilderFactory builderFactory;
// private final FileStorageService fileStorageService; // private final FileStorageService fileStorageService;
// private final ElasticRepository elasticRepository; // private final ElasticRepository elasticRepository;
@Autowired @Autowired
public OperationsContextImpl(DatabaseRepository databaseRepository, ApplicationContext applicationContext, RemoteFetcher remoteFetcher public OperationsContextImpl(DatabaseRepository databaseRepository, ApplicationContext applicationContext, RemoteFetcherService remoteFetcherService
, BuilderFactory builderFactory/*FileStorageService fileStorageService, ElasticRepository elasticRepository*/) { , BuilderFactory builderFactory/*FileStorageService fileStorageService, ElasticRepository elasticRepository*/) {
this.databaseRepository = databaseRepository; this.databaseRepository = databaseRepository;
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
this.remoteFetcher = remoteFetcher; this.remoteFetcherService = remoteFetcherService;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
// this.fileStorageService = fileStorageService; // this.fileStorageService = fileStorageService;
// this.elasticRepository = elasticRepository; // this.elasticRepository = elasticRepository;
@ -41,8 +41,8 @@ public class OperationsContextImpl implements OperationsContext {
} }
@Override @Override
public RemoteFetcher getRemoteFetcher() { public RemoteFetcherService getRemoteFetcher() {
return remoteFetcher; return remoteFetcherService;
} }
@Override @Override

View File

@ -669,6 +669,17 @@ permissions:
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false
allowAuthenticated: false allowAuthenticated: false
# Prefilling
BrowsePrefilling:
roles:
- Admin
- DescriptionTemplateEditor
- Manager
- User
claims: [ ]
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
# Lock Permissions # Lock Permissions
BrowseLock: BrowseLock: