reference refactor

This commit is contained in:
Efstratios Giannopoulos 2024-01-04 11:23:13 +02:00
parent 659c213360
commit ccd7d069cb
18 changed files with 97 additions and 95 deletions

View File

@ -50,6 +50,7 @@ public class AuditableAction {
public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup"); public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup");
public static final EventId Reference_Persist = new EventId(7002, "Reference_Persist"); public static final EventId Reference_Persist = new EventId(7002, "Reference_Persist");
public static final EventId Reference_Delete = new EventId(7003, "Reference_Delete"); public static final EventId Reference_Delete = new EventId(7003, "Reference_Delete");
public static final EventId Reference_Search = new EventId(7004, "Reference_Search");
public static final EventId DescriptionTemplate_Query = new EventId(8000, "DescriptionTemplate_Query"); public static final EventId DescriptionTemplate_Query = new EventId(8000, "DescriptionTemplate_Query");
public static final EventId DescriptionTemplate_Lookup = new EventId(8001, "DescriptionTemplate_Lookup"); public static final EventId DescriptionTemplate_Lookup = new EventId(8001, "DescriptionTemplate_Lookup");

View File

@ -197,9 +197,15 @@ public class ReferenceServiceImpl implements ReferenceService {
@Override @Override
public List<Reference> searchReference(ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { public List<Reference> searchReference(ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
int initialOffset = 0;
if (lookup.getPage() != null && !lookup.getPage().isEmpty()){
initialOffset = lookup.getPage().getOffset();
lookup.getPage().setOffset(0);
}
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(lookup.getLike()); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(lookup.getLike());
List<Map<String, String>> remoteRepos = remoteFetcher.get(lookup.getType(), externalReferenceCriteria, lookup.getKey()); List<Map<String, String>> remoteRepos = remoteFetcher.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);
@ -208,16 +214,15 @@ public class ReferenceServiceImpl implements ReferenceService {
models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(lookup.getLike().toLowerCase())).collect(Collectors.toList()); models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(lookup.getLike().toLowerCase())).collect(Collectors.toList());
models.sort(Comparator.comparing(Reference::getLabel)); models.sort(Comparator.comparing(Reference::getLabel));
if (lookup.getPage() != null && !lookup.getPage().isEmpty()){
models = models.stream().skip(initialOffset).limit(lookup.getPage().getSize()).toList();
}
return models; return models;
} }
private List<Reference> fetchFromDb(ReferenceSearchLookup lookup){ private List<Reference> fetchFromDb(ReferenceSearchLookup lookup){
List<String> fields = Arrays.asList(Reference._id, Reference._label, Reference._description, Reference._abbreviation, Reference._source,
Reference._isActive, Reference._createdAt, Reference._updatedAt, Reference._type, Reference._definition, Reference._reference, Reference._sourceType );
lookup.setProject(new BaseFieldSet(fields));
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic); ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
List<ReferenceEntity> data = query.collectAs(lookup.getProject()); List<ReferenceEntity> data = query.collectAs(lookup.getProject());
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data); return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);

View File

@ -12,14 +12,12 @@ import eu.eudat.service.reference.external.config.entities.GenericUrls;
import eu.eudat.service.reference.external.models.ExternalRefernceResult; import eu.eudat.service.reference.external.models.ExternalRefernceResult;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria; import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
import eu.eudat.service.reference.external.criteria.FetchStrategy; import eu.eudat.service.reference.external.criteria.FetchStrategy;
import eu.eudat.service.storage.StorageFileService;
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;
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;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.http.client.reactive.ReactorClientHttpConnector;
@ -29,7 +27,6 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient; import reactor.netty.http.client.HttpClient;
import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.StringReader; import java.io.StringReader;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -41,19 +38,25 @@ import java.util.stream.Collectors;
public class RemoteFetcher { public class RemoteFetcher {
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class); private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
private final WebClient client; private WebClient webClient;
private final ExternalUrlConfigProvider externalUrlConfigProvider; private final ExternalUrlConfigProvider externalUrlConfigProvider;
@Autowired @Autowired
public RemoteFetcher(ExternalUrlConfigProvider externalUrlConfigProvider) { public RemoteFetcher(ExternalUrlConfigProvider externalUrlConfigProvider) {
this.externalUrlConfigProvider = externalUrlConfigProvider; this.externalUrlConfigProvider = externalUrlConfigProvider;
this.client = WebClient.builder().codecs(clientCodecConfigurer -> { }
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here??? private WebClient getWebClient(){
} if (this.webClient == null) {
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build(); this.webClient = WebClient.builder().codecs(clientCodecConfigurer -> {
clientCodecConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON));
clientCodecConfigurer.defaultCodecs().maxInMemorySize(2 * ((int) Math.pow(1024, 3))); //GK: Why here???
}
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
}
return webClient;
} }
public List<Map<String, String>> get(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);
List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList()) List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
@ -67,26 +70,26 @@ public class RemoteFetcher {
} }
public GenericUrls getExternalUrls(ReferenceType referenceType) { public GenericUrls getExternalUrls(ReferenceType referenceType) {
switch (referenceType){ return switch (referenceType) {
case Taxonomies: return this.externalUrlConfigProvider.getExternalUrls().getTaxonomies(); case Taxonomies -> this.externalUrlConfigProvider.getExternalUrls().getTaxonomies();
case Licenses: return this.externalUrlConfigProvider.getExternalUrls().getLicenses(); case Licenses -> this.externalUrlConfigProvider.getExternalUrls().getLicenses();
case Publications: return this.externalUrlConfigProvider.getExternalUrls().getPublications(); case Publications -> this.externalUrlConfigProvider.getExternalUrls().getPublications();
case Journals: return this.externalUrlConfigProvider.getExternalUrls().getJournals(); case Journals -> this.externalUrlConfigProvider.getExternalUrls().getJournals();
case PubRepositories: return this.externalUrlConfigProvider.getExternalUrls().getPubRepositories(); case PubRepositories -> this.externalUrlConfigProvider.getExternalUrls().getPubRepositories();
case DataRepositories: return this.externalUrlConfigProvider.getExternalUrls().getRepositories(); case DataRepositories -> this.externalUrlConfigProvider.getExternalUrls().getRepositories();
case Registries: return this.externalUrlConfigProvider.getExternalUrls().getRegistries(); case Registries -> this.externalUrlConfigProvider.getExternalUrls().getRegistries();
case Services: return this.externalUrlConfigProvider.getExternalUrls().getServices(); case Services -> this.externalUrlConfigProvider.getExternalUrls().getServices();
case Grants: return this.externalUrlConfigProvider.getExternalUrls().getGrants(); case Grants -> this.externalUrlConfigProvider.getExternalUrls().getGrants();
case Organizations: return this.externalUrlConfigProvider.getExternalUrls().getOrganisations(); case Organizations -> this.externalUrlConfigProvider.getExternalUrls().getOrganisations();
case Datasets: return this.externalUrlConfigProvider.getExternalUrls().getDatasets(); case Datasets -> this.externalUrlConfigProvider.getExternalUrls().getDatasets();
case Funder: return this.externalUrlConfigProvider.getExternalUrls().getFunders(); case Funder -> this.externalUrlConfigProvider.getExternalUrls().getFunders();
case Project: return this.externalUrlConfigProvider.getExternalUrls().getProjects(); case Project -> this.externalUrlConfigProvider.getExternalUrls().getProjects();
case Researcher: return this.externalUrlConfigProvider.getExternalUrls().getResearchers(); case Researcher -> this.externalUrlConfigProvider.getExternalUrls().getResearchers();
default: throw new IllegalArgumentException("Type not found" + referenceType); default -> throw new IllegalArgumentException("Type not found" + referenceType);
} };
} }
public Integer findEntries(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())
: this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls(); : this.externalUrlConfigProvider.getExternalUrls().getValidations().getUrls();
@ -116,22 +119,22 @@ public class RemoteFetcher {
// throw new MyNotFoundException("No Repository urls found in configuration"); // throw new MyNotFoundException("No Repository urls found in configuration");
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal)); urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
urlConfigs.forEach(urlConfiguration -> { for (UrlConfiguration urlConfiguration : urlConfigs) {
ifFunderQueryExist(urlConfiguration, externalReferenceCriteria); applyFunderQuery(urlConfiguration, externalReferenceCriteria);
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) { if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
try { try {
String auth = null; String auth = null;
if (urlConfiguration.getAuth() != null) { if (urlConfiguration.getAuth() != null) {
auth = this.getAuthentication(urlConfiguration.getAuth()); auth = this.getAuthentication(urlConfiguration.getAuth());
} }
results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalReferenceCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries(), auth)); results.addAll(getAllResultsFromUrl(urlConfiguration.getUrl(), fetchStrategy, urlConfiguration.getData(), urlConfiguration.getPaginationPath(), externalReferenceCriteria, urlConfiguration.getLabel(), urlConfiguration.getKey(), urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getFilterType(), urlConfiguration.getQueries(), auth));
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage(), e); logger.error(e.getLocalizedMessage(), e);
} }
} else if (urlConfiguration.getType() != null && urlConfiguration.getType().equals("Internal")) { } else if (urlConfiguration.getType() != null && urlConfiguration.getType().equals("Internal")) {
results.addAll(getAllResultsFromMockUpJson(urlConfiguration.getUrl(), externalReferenceCriteria.getLike())); results.addAll(getAllResultsFromMockUpJson(urlConfiguration.getUrl(), externalReferenceCriteria.getLike()));
} }
}); }
/* for (UrlConfiguration urlConfig : urlConfigs) { /* for (UrlConfiguration urlConfig : urlConfigs) {
ifFunderQueryExist(urlConfig, externalUrlCriteria); ifFunderQueryExist(urlConfig, externalUrlCriteria);
if (urlConfig.getType() == null || urlConfig.getType().equals("External")) { if (urlConfig.getType() == null || urlConfig.getType().equals("External")) {
@ -145,7 +148,7 @@ public class RemoteFetcher {
private String getAuthentication(AuthenticationConfiguration authenticationConfiguration) { private String getAuthentication(AuthenticationConfiguration authenticationConfiguration) {
HttpMethod method = HttpMethod.valueOf(authenticationConfiguration.getAuthMethod()); HttpMethod method = HttpMethod.valueOf(authenticationConfiguration.getAuthMethod());
Map<String, Object> reponse = this.client.method(method).uri(authenticationConfiguration.getAuthUrl()) Map<String, Object> response = this.getWebClient().method(method).uri(authenticationConfiguration.getAuthUrl())
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.bodyValue(this.parseBodyString(authenticationConfiguration.getAuthRequestBody())) .bodyValue(this.parseBodyString(authenticationConfiguration.getAuthRequestBody()))
.exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() { .exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {
@ -153,7 +156,7 @@ public class RemoteFetcher {
return authenticationConfiguration.getType() + " " + reponse.get(authenticationConfiguration.getAuthTokenPath()); return authenticationConfiguration.getType() + " " + response.get(authenticationConfiguration.getAuthTokenPath());
} }
private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalReferenceCriteria externalReferenceCriteria) { private List<Map<String, Object>> getAllWithData(List<UrlConfiguration> urlConfigs, ExternalReferenceCriteria externalReferenceCriteria) {
@ -166,7 +169,7 @@ public class RemoteFetcher {
urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal)); urlConfigs.sort(Comparator.comparing(UrlConfiguration::getOrdinal));
urlConfigs.forEach(urlConfiguration -> { urlConfigs.forEach(urlConfiguration -> {
ifFunderQueryExist(urlConfiguration, externalReferenceCriteria); applyFunderQuery(urlConfiguration, externalReferenceCriteria);
if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) { if (urlConfiguration.getType() == null || urlConfiguration.getType().equals("External")) {
try { try {
results.addAll(getAllResultsFromUrlWithData(urlConfiguration.getUrl(), urlConfiguration.getData(), externalReferenceCriteria, urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getQueries())); results.addAll(getAllResultsFromUrlWithData(urlConfiguration.getUrl(), urlConfiguration.getData(), externalReferenceCriteria, urlConfiguration.getContentType(), urlConfiguration.getFirstpage(), urlConfiguration.getRequestBody(), urlConfiguration.getRequestType(), urlConfiguration.getQueries()));
@ -179,7 +182,7 @@ public class RemoteFetcher {
} }
private void ifFunderQueryExist(UrlConfiguration urlConfiguration, ExternalReferenceCriteria externalReferenceCriteria) { private void applyFunderQuery(UrlConfiguration urlConfiguration, ExternalReferenceCriteria externalReferenceCriteria) {
if (urlConfiguration.getFunderQuery() != null) { if (urlConfiguration.getFunderQuery() != null) {
if (externalReferenceCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) { if (externalReferenceCriteria.getFunderId() != null && !urlConfiguration.getFunderQuery().startsWith("dmp:")) {
urlConfiguration.setUrl(urlConfiguration.getUrl().replace("{funderQuery}", urlConfiguration.getFunderQuery())); urlConfiguration.setUrl(urlConfiguration.getUrl().replace("{funderQuery}", urlConfiguration.getFunderQuery()));
@ -366,7 +369,7 @@ public class RemoteFetcher {
// entity = new HttpEntity<>(jsonBody, headers); // entity = new HttpEntity<>(jsonBody, headers);
response = this.client.method(HttpMethod.valueOf(requestType)).uri(urlString).headers(httpHeaders -> { response = this.getWebClient().method(HttpMethod.valueOf(requestType)).uri(urlString).headers(httpHeaders -> {
if (contentType != null && !contentType.isEmpty()) { if (contentType != null && !contentType.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.valueOf(contentType))); httpHeaders.setAccept(Collections.singletonList(MediaType.valueOf(contentType)));
httpHeaders.setContentType(MediaType.valueOf(contentType)); httpHeaders.setContentType(MediaType.valueOf(contentType));

View File

@ -106,23 +106,28 @@ public class ReferenceController extends BaseController {
} }
@PostMapping("search") @PostMapping("search")
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReference(@RequestBody ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { public List<Reference> searchReference(@RequestBody ReferenceSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); logger.debug("search {}", Reference.class.getSimpleName());
// ReferenceType referenceType = ReferenceType.of((short) externalType);
if (lookup.getType() != null) { this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null);
List<Reference> references = this.referenceService.searchReference(lookup); List<Reference> references = this.referenceService.searchReference(lookup);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Reference>>().status(ApiMessageCode.NO_MESSAGE).payload(references));
} this.auditService.track(AuditableAction.Reference_Search, "lookup", lookup);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Reference>>().status(ApiMessageCode.NO_MESSAGE));
return references;
} }
@PostMapping("search-with-db-definition") @PostMapping("search-with-db-definition")
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReferenceWithDefinition(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { public List<Reference> searchReferenceWithDefinition(@RequestBody ReferenceDefinitionSearchLookup lookup) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); logger.debug("search with db definition {}", Reference.class.getSimpleName());
this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null);
List<Reference> references = this.referenceService.searchReferenceWithDefinition(lookup); List<Reference> references = this.referenceService.searchReferenceWithDefinition(lookup);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Reference>>().status(ApiMessageCode.NO_MESSAGE).payload(references));
this.auditService.track(AuditableAction.Reference_Search, "lookup", lookup);
return references;
} }
@GetMapping("{id}") @GetMapping("{id}")
@ -161,18 +166,6 @@ public class ReferenceController extends BaseController {
return persisted; return persisted;
} }
// @GetMapping(path = {"search/{externalType}"}, produces = "application/json")
// public @ResponseBody ResponseEntity<ResponseItem<List<FetcherReference>>> searchReference(@PathVariable(value = "externalType") int externalType,
// @RequestParam(value = "query", required = false) String query,
// @RequestParam(value = "type", required = false) String type
// ) throws HugeResultSet, MyNotFoundException, InvalidApplicationException {
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
// ReferenceType referenceType = ReferenceType.of((short) externalType);
//
// List<FetcherReference> fetcherReferences = this.referenceService.searchReference(referenceType, query, type);
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<FetcherReference>>().status(ApiMessageCode.NO_MESSAGE).payload(fetcherReferences));
// }
@DeleteMapping("{id}") @DeleteMapping("{id}")
@Transactional @Transactional
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException { public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {

View File

@ -42,7 +42,7 @@ public class DataRepositoryManager {
public List<DataRepositoryModel> getDataRepositories(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { public List<DataRepositoryModel> getDataRepositories(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.DataRepositories, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.DataRepositories, externalReferenceCriteria, type);
DataRepositoryCriteria criteria = new DataRepositoryCriteria(); DataRepositoryCriteria criteria = new DataRepositoryCriteria();
if (!query.isEmpty()) criteria.setLike(query); if (!query.isEmpty()) criteria.setLike(query);
@ -61,7 +61,7 @@ public class DataRepositoryManager {
} }
public List<DataRepositoryModel> getPubRepositories(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { public List<DataRepositoryModel> getPubRepositories(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.PubRepositories, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.PubRepositories, externalReferenceCriteria, type);
DataRepositoryCriteria criteria = new DataRepositoryCriteria(); DataRepositoryCriteria criteria = new DataRepositoryCriteria();
if (!query.isEmpty()) criteria.setLike(query); if (!query.isEmpty()) criteria.setLike(query);
@ -80,7 +80,7 @@ public class DataRepositoryManager {
} }
public List<DataRepositoryModel> getJournals(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { public List<DataRepositoryModel> getJournals(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Journals, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Journals, externalReferenceCriteria, type);
DataRepositoryCriteria criteria = new DataRepositoryCriteria(); DataRepositoryCriteria criteria = new DataRepositoryCriteria();
if (!query.isEmpty()) criteria.setLike(query); if (!query.isEmpty()) criteria.setLike(query);

View File

@ -58,7 +58,7 @@ public class ExternalDatasetManager {
// Fetch external Datasets from external sources. // Fetch external Datasets from external sources.
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Datasets, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Datasets, externalReferenceCriteria, type);
// Parse items from external sources to listing models. // Parse items from external sources to listing models.
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

View File

@ -46,7 +46,7 @@ public class FunderManager {
QueryableList<eu.eudat.data.old.Funder> authItems = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getAuthenticated(items, userInfo); QueryableList<eu.eudat.data.old.Funder> authItems = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getAuthenticated(items, userInfo);
List<Funder> funders = authItems.select(item -> new eu.eudat.models.data.funder.Funder().fromDataModel(item)); List<Funder> funders = authItems.select(item -> new eu.eudat.models.data.funder.Funder().fromDataModel(item));
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(funderCriteria.getCriteria().getLike()); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(funderCriteria.getCriteria().getLike());
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Funder, externalReferenceCriteria, null); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Funder, externalReferenceCriteria, null);
FundersExternalSourcesModel fundersExternalSourcesModel = new FundersExternalSourcesModel().fromExternalItem(remoteRepos); FundersExternalSourcesModel fundersExternalSourcesModel = new FundersExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : fundersExternalSourcesModel) { for (ExternalSourcesItemModel externalListingItem : fundersExternalSourcesModel) {
eu.eudat.models.data.funder.Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class) eu.eudat.models.data.funder.Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class)

View File

@ -127,7 +127,7 @@ public class GrantManager {
QueryableList<eu.eudat.data.old.Grant> authItems = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getAuthenticated(items, userInfo); QueryableList<eu.eudat.data.old.Grant> authItems = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().getAuthenticated(items, userInfo);
List<eu.eudat.models.data.grant.Grant> grants = authItems.select(item -> new Grant().fromDataModel(item)); List<eu.eudat.models.data.grant.Grant> grants = authItems.select(item -> new Grant().fromDataModel(item));
List<Map<String, String>> remoteRepos = remoteFetcher.get(ReferenceType.Grants, externalReferenceCriteria, null); List<Map<String, String>> remoteRepos = remoteFetcher.getReferences(ReferenceType.Grants, externalReferenceCriteria, null);
GrantsExternalSourcesModel grantsExternalSourcesModel = new GrantsExternalSourcesModel().fromExternalItem(remoteRepos); GrantsExternalSourcesModel grantsExternalSourcesModel = new GrantsExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : grantsExternalSourcesModel) { for (ExternalSourcesItemModel externalListingItem : grantsExternalSourcesModel) {

View File

@ -31,7 +31,7 @@ public class LicenseManager {
public List<LicenseModel> getLicenses(String query, String type) throws HugeResultSetException, MyNotFoundException { public List<LicenseModel> getLicenses(String query, String type) throws HugeResultSetException, MyNotFoundException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Licenses, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Licenses, externalReferenceCriteria, type);
DataRepositoryCriteria criteria = new DataRepositoryCriteria(); DataRepositoryCriteria criteria = new DataRepositoryCriteria();
if (!query.isEmpty()) criteria.setLike(query); if (!query.isEmpty()) criteria.setLike(query);

View File

@ -82,7 +82,7 @@ public class OrganisationsManager {
List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()); List<Organisation> org = pagedItems.toList().stream().distinct().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(organisationsTableRequest.getCriteria().getLabelLike()); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(organisationsTableRequest.getCriteria().getLabelLike());
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Organizations, externalReferenceCriteria, null); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Organizations, externalReferenceCriteria, null);
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos); OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) { for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {
Organisation organisation = apiContext.getOperationsContext().getBuilderFactory().getBuilder(OrganisationBuilder.class) Organisation organisation = apiContext.getOperationsContext().getBuilderFactory().getBuilder(OrganisationBuilder.class)
@ -98,7 +98,7 @@ public class OrganisationsManager {
public List<Organisation> getCriteriaWithExternal(String query, String type) throws HugeResultSetException, MyNotFoundException { public List<Organisation> getCriteriaWithExternal(String query, String type) throws HugeResultSetException, MyNotFoundException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Organizations, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Organizations, externalReferenceCriteria, type);
OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos); OrganisationsExternalSourcesModel organisationsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
List<Organisation> organisations = new LinkedList<>(); List<Organisation> organisations = new LinkedList<>();
for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) { for (ExternalSourcesItemModel externalListingItem : organisationsExternalSourcesModel) {

View File

@ -46,7 +46,7 @@ public class ProjectManager {
QueryableList<eu.eudat.data.old.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo); QueryableList<eu.eudat.data.old.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo);
List<Project> projects = authItems.select(item -> new Project().fromDataModel(item)); List<Project> projects = authItems.select(item -> new Project().fromDataModel(item));
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(projectCriteria.getCriteria().getLike()); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(projectCriteria.getCriteria().getLike());
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.DataRepositories, externalReferenceCriteria, null); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.DataRepositories, externalReferenceCriteria, null);
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos); ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) { for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) {
eu.eudat.models.data.project.Project project = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ProjectBuilder.class) eu.eudat.models.data.project.Project project = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ProjectBuilder.class)

View File

@ -28,7 +28,7 @@ public class PublicationManager {
public List<PublicationModel> getPublications(String query, String type) throws HugeResultSetException, MyNotFoundException { public List<PublicationModel> getPublications(String query, String type) throws HugeResultSetException, MyNotFoundException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Publications, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Publications, externalReferenceCriteria, type);
DataRepositoryCriteria criteria = new DataRepositoryCriteria(); DataRepositoryCriteria criteria = new DataRepositoryCriteria();
if (!query.isEmpty()) criteria.setLike(query); if (!query.isEmpty()) criteria.setLike(query);

View File

@ -43,7 +43,7 @@ public class RegistryManager {
public List<RegistryModel> getRegistries(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException { public List<RegistryModel> getRegistries(String query, String type) throws HugeResultSetException, MyNotFoundException, InvalidApplicationException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Registries, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Registries, externalReferenceCriteria, type);
RegistryCriteria criteria = new RegistryCriteria(); RegistryCriteria criteria = new RegistryCriteria();
if (!query.isEmpty()) criteria.setLike(query); if (!query.isEmpty()) criteria.setLike(query);

View File

@ -65,7 +65,7 @@ public class ResearcherManager {
item.setTag(keyToSourceMap.get(item.getKey())); item.setTag(keyToSourceMap.get(item.getKey()));
} }
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(researcherCriteriaRequest.getCriteria().getName()); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(researcherCriteriaRequest.getCriteria().getName());
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Researcher, externalReferenceCriteria, null); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Researcher, externalReferenceCriteria, null);
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos); ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) { for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) {
eu.eudat.models.data.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class) eu.eudat.models.data.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class)

View File

@ -48,7 +48,7 @@ public class ServiceManager {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Services, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Services, externalReferenceCriteria, type);
ServiceCriteria criteria = new ServiceCriteria(); ServiceCriteria criteria = new ServiceCriteria();
if (!query.isEmpty()) criteria.setLike(query); if (!query.isEmpty()) criteria.setLike(query);

View File

@ -29,7 +29,7 @@ public class TaxonomyManager {
public List<TaxonomyModel> getTaxonomies(String query, String type) throws HugeResultSetException, MyNotFoundException { public List<TaxonomyModel> getTaxonomies(String query, String type) throws HugeResultSetException, MyNotFoundException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(query);
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(ReferenceType.Taxonomies, externalReferenceCriteria, type); List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().getReferences(ReferenceType.Taxonomies, externalReferenceCriteria, type);
DataRepositoryCriteria criteria = new DataRepositoryCriteria(); DataRepositoryCriteria criteria = new DataRepositoryCriteria();
if (!query.isEmpty()) criteria.setLike(query); if (!query.isEmpty()) criteria.setLike(query);

View File

@ -24,7 +24,7 @@ public class ValidationManager {
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.findEntries(externalReferenceCriteria, type); Integer count = this.remoteFetcher.countEntries(externalReferenceCriteria, type);
return this.userScope.isSet() && count > 0; return this.userScope.isSet() && count > 0;
} }

View File

@ -23,7 +23,7 @@ public class ExternalValidationService {
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.findEntries(externalReferenceCriteria, type); Integer count = this.remoteFetcher.countEntries(externalReferenceCriteria, type);
return userScope.isSet() && count > 0; return userScope.isSet() && count > 0;
} }