add reference search builders, lookup
This commit is contained in:
parent
557c444bc1
commit
f744573f02
|
@ -19,7 +19,7 @@ public class ReferenceTypeProperties {
|
|||
private Map<String, List<ReferenceTypeField>> project;
|
||||
private Map<String, List<ReferenceTypeField>> organisation;
|
||||
private Map<String, List<ReferenceTypeField>> dataset;
|
||||
private Map<String, List<Field>> dataRepository;
|
||||
private Map<String, List<ReferenceTypeField>> dataRepository;
|
||||
private Map<String, List<ReferenceTypeField>> pubRepository;
|
||||
private Map<String, List<ReferenceTypeField>> journal;
|
||||
private Map<String, List<ReferenceTypeField>> publication;
|
||||
|
@ -31,7 +31,7 @@ public class ReferenceTypeProperties {
|
|||
Map<String, List<ReferenceTypeField>> researcher, Map<String, List<ReferenceTypeField>> service,
|
||||
Map<String, List<ReferenceTypeField>> registry, Map<String, List<ReferenceTypeField>> project,
|
||||
Map<String, List<ReferenceTypeField>> organisation, Map<String, List<ReferenceTypeField>> dataset,
|
||||
Map<String, List<Field>> dataRepository, Map<String, List<ReferenceTypeField>> pubRepository,
|
||||
Map<String, List<ReferenceTypeField>> dataRepository, Map<String, List<ReferenceTypeField>> pubRepository,
|
||||
Map<String, List<ReferenceTypeField>> journal, Map<String, List<ReferenceTypeField>> publication,
|
||||
Map<String, List<ReferenceTypeField>> licence, Map<String, List<ReferenceTypeField>> taxonomy) {
|
||||
this.grant = grant;
|
||||
|
@ -114,11 +114,11 @@ public class ReferenceTypeProperties {
|
|||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
public Map<String, List<Field>> getDataRepository() {
|
||||
public Map<String, List<ReferenceTypeField>> getDataRepository() {
|
||||
return dataRepository;
|
||||
}
|
||||
|
||||
public void setDataRepository(Map<String, List<Field>> dataRepository) {
|
||||
public void setDataRepository(Map<String, List<ReferenceTypeField>> dataRepository) {
|
||||
this.dataRepository = dataRepository;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package eu.eudat.model.builder.referencesearch;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.configurations.referencetype.ReferenceTypeProperties;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencedefinition.Definition;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
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.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class DefinitionSearchBuilder extends BaseBuilder<Definition, Map<String, String>> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private final ReferenceTypeProperties properties;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public DefinitionSearchBuilder(
|
||||
ConventionService conventionService, BuilderFactory builderFactory, ReferenceTypeProperties properties) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DefinitionSearchBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public DefinitionSearchBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Definition> build(FieldSet fields, List<Map<String, String>> 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 (data == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
List<Definition> models = new ArrayList<>();
|
||||
//for (Map<String, String> d : data) {
|
||||
Definition m = new Definition();
|
||||
m.setFields(this.builderFactory.builder(FieldSearchBuilder.class).authorize(this.authorize).build(null, data));
|
||||
models.add(m);
|
||||
//}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package eu.eudat.model.builder.referencesearch;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.configurations.referencetype.ReferenceTypeField;
|
||||
import eu.eudat.configurations.referencetype.ReferenceTypeProperties;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
import eu.eudat.model.referencedefinition.Field;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
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.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class FieldSearchBuilder extends BaseBuilder<Field, Map<String, String>> {
|
||||
|
||||
private final ReferenceTypeProperties properties;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public FieldSearchBuilder(
|
||||
ConventionService conventionService, ReferenceTypeProperties properties) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldSearchBuilder.class)));
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public FieldSearchBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Field> build(FieldSet fields, List< Map<String, String>> 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 (data == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
List<Field> models = new ArrayList<>();
|
||||
for (Map<String, String> d : data) {
|
||||
|
||||
ReferenceType referenceType = ReferenceType.valueOf(d.getOrDefault("referenceType", null));
|
||||
List<ReferenceTypeField> typeFields = this.getPropertiesFields(referenceType);
|
||||
if (typeFields.isEmpty()){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
for (ReferenceTypeField typeField: typeFields){
|
||||
Field m = new Field();
|
||||
m.setCode(typeField.getCode());
|
||||
m.setDataType(ReferenceFieldDataType.valueOf(typeField.getDataType()));
|
||||
m.setValue(d.getOrDefault(typeField.getCode(), null));
|
||||
models.add(m);
|
||||
}
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
|
||||
private List<ReferenceTypeField> getPropertiesFields(ReferenceType referenceType){
|
||||
switch (referenceType){
|
||||
case Taxonomies: return properties.getTaxonomy().get("fields");
|
||||
case Licenses: return properties.getLicence().get("fields");
|
||||
case Publications: return properties.getPublication().get("fields");
|
||||
case Journals: return properties.getJournal().get("fields");
|
||||
case PubRepositories: return properties.getPubRepository().get("fields");
|
||||
case DataRepositories: return properties.getDataRepository().get("fields");
|
||||
case Registries: return properties.getRegistry().get("fields");
|
||||
case Services: return properties.getService().get("fields");
|
||||
case Organizations: return properties.getOrganisation().get("fields");
|
||||
case Datasets: return properties.getDataset().get("fields");
|
||||
case Funder: return properties.getFunder().get("fields");
|
||||
case Project: return properties.getProject().get("fields");
|
||||
case Researcher: return properties.getResearcher().get("fields");
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package eu.eudat.model.builder.referencesearch;
|
||||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.model.Reference;
|
||||
import eu.eudat.model.builder.BaseBuilder;
|
||||
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.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.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class ReferenceSearchBuilder extends BaseBuilder<Reference, Map<String, String>> {
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
private final QueryFactory queryFactory;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
@Autowired
|
||||
public ReferenceSearchBuilder(
|
||||
ConventionService conventionService,
|
||||
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceSearchBuilder.class)));
|
||||
this.builderFactory = builderFactory;
|
||||
this.queryFactory = queryFactory;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
}
|
||||
|
||||
public ReferenceSearchBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||
this.authorize = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Reference> build(FieldSet fields, List<Map<String, String>> 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 (data == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
List<Reference> models = new ArrayList<>();
|
||||
for (Map<String, String> d : data) {
|
||||
Reference m = new Reference();
|
||||
if (d.containsKey("id")) m.setId(UUID.fromString(d.getOrDefault("id", null)));
|
||||
m.setLabel(d.getOrDefault("name", null));
|
||||
m.setDescription(d.getOrDefault("description", null));
|
||||
m.setAbbreviation(d.getOrDefault("abbreviation", null));
|
||||
m.setSource(d.getOrDefault("source", null));
|
||||
m.setReference(d.getOrDefault("reference", null));
|
||||
|
||||
String sourceType = d.getOrDefault("type", null);
|
||||
if (sourceType != null) m.setSourceType(ReferenceSourceType.valueOf(sourceType));
|
||||
String type = d.getOrDefault("referenceType", null);
|
||||
if (type != null) m.setType(ReferenceType.valueOf(type));
|
||||
|
||||
m.setDefinition(this.builderFactory.builder(DefinitionSearchBuilder.class).authorize(this.authorize).build(null, d));
|
||||
models.add(m);
|
||||
|
||||
}
|
||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||
return models;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import gr.cite.tools.data.query.Lookup;
|
||||
|
||||
public class ReferenceSearchLookup extends Lookup {
|
||||
|
||||
private String like;
|
||||
|
||||
private ReferenceType type;
|
||||
|
||||
private String key;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(String like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public ReferenceType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ReferenceType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import eu.eudat.audit.AuditableAction;
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.authorization.Permission;
|
||||
import eu.eudat.commons.enums.ReferenceType;
|
||||
import eu.eudat.controllers.BaseController;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||
|
@ -20,6 +19,7 @@ import eu.eudat.models.data.FetcherReference;
|
|||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.query.ReferenceQuery;
|
||||
import eu.eudat.query.lookup.ReferenceLookup;
|
||||
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.auditing.AuditService;
|
||||
|
@ -99,6 +99,18 @@ public class ReferenceController extends BaseController {
|
|||
return new QueryResult(models, count);
|
||||
}
|
||||
|
||||
@PostMapping("search")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<Reference>>> searchReference(@RequestBody ReferenceSearchLookup lookup) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||
// ReferenceType referenceType = ReferenceType.of((short) externalType);
|
||||
|
||||
if (lookup.getType() != null){
|
||||
List<Reference> references = this.referenceService.searchReference(lookup);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Reference>>().status(ApiMessageCode.NO_MESSAGE).payload(references));
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public Reference get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||
logger.debug(new MapLogEntry("retrieving" + Reference.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||
|
@ -134,17 +146,17 @@ public class ReferenceController extends BaseController {
|
|||
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, NoURLFound, 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));
|
||||
}
|
||||
// @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, NoURLFound, 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}")
|
||||
@Transactional
|
||||
|
@ -156,15 +168,4 @@ public class ReferenceController extends BaseController {
|
|||
this.auditService.track(AuditableAction.Reference_Delete, "id", id);
|
||||
}
|
||||
|
||||
|
||||
// @Transactional
|
||||
// @PostMapping(path = {"persist"}, consumes = "application/json", produces = "application/json")
|
||||
// public @ResponseBody
|
||||
// ResponseEntity<ResponseItem<ExternalReference>> createExternalReferecnes(@RequestBody ExternalReference externalReference) throws Exception {
|
||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||
//
|
||||
// ExternalReference newExternalReference = this.externalReferencesService.createDataRepo(externalReference);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -25,11 +25,13 @@ import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.model.Reference;
|
||||
import eu.eudat.model.builder.ReferenceBuilder;
|
||||
import eu.eudat.model.builder.referencesearch.ReferenceSearchBuilder;
|
||||
import eu.eudat.model.deleter.ReferenceDeleter;
|
||||
import eu.eudat.model.persist.ReferencePersist;
|
||||
import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
|
||||
import eu.eudat.model.persist.referencedefinition.FieldPersist;
|
||||
import eu.eudat.models.data.FetcherReference;
|
||||
import eu.eudat.query.lookup.ReferenceSearchLookup;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
|
@ -169,17 +171,35 @@ public class ReferenceService {
|
|||
this.deleterFactory.deleter(ReferenceDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||
}
|
||||
|
||||
public List<FetcherReference> searchReference(ReferenceType externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
||||
// public List<FetcherReference> searchReference(ReferenceType externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||
// ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
||||
//
|
||||
// List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType, externalUrlCriteria, type);
|
||||
//
|
||||
// List<FetcherReference> list = this.fetchFromDb(externalType, query, type, remoteRepos);
|
||||
//
|
||||
// list.addAll(remoteRepos.stream().map(FetcherReference::fromRemoteModel).toList());
|
||||
// list = list.stream().filter(x -> x.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
|
||||
// list.sort(Comparator.comparing(FetcherReference::getName));
|
||||
// return list;
|
||||
// }
|
||||
|
||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType, externalUrlCriteria, type);
|
||||
public List<Reference> searchReference(ReferenceSearchLookup lookup) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(lookup.getLike());
|
||||
|
||||
List<FetcherReference> list = this.fetchFromDb(externalType, query, type, remoteRepos);
|
||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(lookup.getType(), externalUrlCriteria, lookup.getKey());
|
||||
for (Map<String, String> repo: remoteRepos) {
|
||||
repo.put("referenceType", lookup.getType().name());
|
||||
}
|
||||
|
||||
list.addAll(remoteRepos.stream().map(FetcherReference::fromRemoteModel).toList());
|
||||
list = list.stream().filter(x -> x.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
|
||||
list.sort(Comparator.comparing(FetcherReference::getName));
|
||||
return list;
|
||||
// List<FetcherReference> list = this.fetchFromDb(externalType, query, type, remoteRepos);
|
||||
|
||||
List<Reference> models = this.builderFactory.builder(ReferenceSearchBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(lookup.getProject(), remoteRepos);
|
||||
//List<Reference> models = null;
|
||||
models = models.stream().filter(x -> x.getLabel().toLowerCase().contains(lookup.getLike().toLowerCase())).collect(Collectors.toList());
|
||||
models.sort(Comparator.comparing(Reference::getLabel));
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
private List<FetcherReference> fetchFromDb(ReferenceType externalType, String query, String type, List<Map<String, String>> remoteRepos) throws InvalidApplicationException {
|
||||
|
|
|
@ -2,63 +2,81 @@ reference-type:
|
|||
grant:
|
||||
fields:
|
||||
- code: startDate
|
||||
dataType: date
|
||||
dataType: Date
|
||||
- code: endDate
|
||||
dataType: date
|
||||
dataType: Date
|
||||
funder:
|
||||
fields:
|
||||
- code: uri
|
||||
dataType: text
|
||||
dataType: Text
|
||||
researcher:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
- code: firstName
|
||||
dataType: text
|
||||
dataType: Text
|
||||
- code: lastName
|
||||
dataType: text
|
||||
dataType: Text
|
||||
- code: uri
|
||||
dataType: text
|
||||
dataType: Text
|
||||
service:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
- code: uri
|
||||
dataType: text
|
||||
dataType: Text
|
||||
registry:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
- code: uri
|
||||
dataType: text
|
||||
dataType: Text
|
||||
project:
|
||||
fields:
|
||||
- code: startDate
|
||||
dataType: date
|
||||
dataType: Date
|
||||
- code: endDate
|
||||
dataType: date
|
||||
dataType: Date
|
||||
organisation:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
- code: pid
|
||||
dataType: text
|
||||
dataType: Text
|
||||
- code: uri
|
||||
dataType: text
|
||||
dataType: Text
|
||||
- code: pidTypeField
|
||||
dataType: text
|
||||
dataType: Text
|
||||
dataset:
|
||||
fields:
|
||||
- code: pid
|
||||
dataType: text
|
||||
dataType: Text
|
||||
- code: pidTypeField
|
||||
dataType: text
|
||||
dataType: Text
|
||||
dataRepository:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
pubRepository:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
journal:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
publication:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
- code: pid
|
||||
dataType: text
|
||||
dataType: Text
|
||||
- code: pidTypeField
|
||||
dataType: text
|
||||
dataType: Text
|
||||
licence:
|
||||
fields:
|
||||
- code: tag
|
||||
dataType: Text
|
||||
- code: uri
|
||||
dataType: text
|
||||
taxonomy:
|
||||
|
|
|
@ -14,6 +14,7 @@ import { nameof } from 'ts-simple-nameof';
|
|||
import { ConfigurationService } from '../configuration/configuration.service';
|
||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||
import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type';
|
||||
import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup';
|
||||
|
||||
@Injectable()
|
||||
export class ReferenceService {
|
||||
|
@ -32,6 +33,11 @@ export class ReferenceService {
|
|||
return this.http.post<QueryResult<Reference>>(url, q).pipe(catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
search(q: ReferenceSearchLookup): Observable<Reference[]> {
|
||||
const url = `${this.apiBase}/search`;
|
||||
return this.http.post<Reference[]>(url, q).pipe(catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
getSingle(id: Guid, reqFields: string[] = []): Observable<Reference> {
|
||||
const url = `${this.apiBase}/${id}`;
|
||||
const options = { params: { f: reqFields } };
|
||||
|
|
|
@ -48,9 +48,12 @@ import {MatDialog} from "@angular/material/dialog";
|
|||
import {HttpError} from "@common/modules/errors/error-handling/http-error-handling.service";
|
||||
import {HttpErrorResponse} from "@angular/common/http";
|
||||
import * as FileSaver from "file-saver";
|
||||
import { FetcherReference } from '@app/core/model/reference/reference';
|
||||
import { FetcherReference, Reference } from '@app/core/model/reference/reference';
|
||||
import { ReferenceType } from '@app/core/common/enum/reference-type';
|
||||
import { FileUtils } from '@app/core/services/utilities/file-utils.service';
|
||||
import { ReferenceSearchLookup } from '@app/core/query/reference-search.lookup';
|
||||
import { lookup } from 'dns';
|
||||
import { ReferenceService } from '@app/core/services/reference/reference.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form-field',
|
||||
|
@ -131,7 +134,8 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
private cdr: ChangeDetectorRef,
|
||||
private uiNotificationService: UiNotificationService,
|
||||
public dialog: MatDialog,
|
||||
private fileUtils: FileUtils
|
||||
private fileUtils: FileUtils,
|
||||
private referenceService: ReferenceService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -466,35 +470,55 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
searchDatasetExternalDatasets(query: string): Observable<FetcherReference[]> {
|
||||
const requestItem: RequestItem<ExternalDatasetCriteria> = new RequestItem();
|
||||
requestItem.criteria = new ExternalDatasetCriteria();
|
||||
requestItem.criteria.like = query;
|
||||
requestItem.criteria.type = '';
|
||||
//return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem);
|
||||
return this.externalSourcesService.listExternal(ReferenceType.Datasets, requestItem.criteria.like, requestItem.criteria.type);
|
||||
searchDatasetExternalDatasets(query: string): Observable<Reference[]> {
|
||||
// const requestItem: RequestItem<ExternalDatasetCriteria> = new RequestItem();
|
||||
// requestItem.criteria = new ExternalDatasetCriteria();
|
||||
// requestItem.criteria.like = query;
|
||||
// requestItem.criteria.type = '';
|
||||
// //return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem);
|
||||
// return this.externalSourcesService.listExternal(ReferenceType.Datasets, requestItem.criteria.like, requestItem.criteria.type);
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = query;
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.Datasets;
|
||||
return this.referenceService.search(lookup);
|
||||
}
|
||||
|
||||
searchDatasetExternalDataRepositories(query: string): Observable<FetcherReference[]> {
|
||||
const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
||||
requestItem.criteria = new DataRepositoryCriteria();
|
||||
requestItem.criteria.like = query;
|
||||
requestItem.criteria.type = '';
|
||||
return this.externalSourcesService.listExternal(ReferenceType.DataRepositories, requestItem.criteria.like, requestItem.criteria.type);
|
||||
searchDatasetExternalDataRepositories(query: string): Observable<Reference[]> {
|
||||
// const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
||||
// requestItem.criteria = new DataRepositoryCriteria();
|
||||
// requestItem.criteria.like = query;
|
||||
// requestItem.criteria.type = '';
|
||||
// return this.externalSourcesService.listExternal(ReferenceType.DataRepositories, requestItem.criteria.like, requestItem.criteria.type);
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = query;
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.DataRepositories;
|
||||
return this.referenceService.search(lookup);
|
||||
}
|
||||
searchDatasetExternalPubRepositories(query: string): Observable<FetcherReference[]> {
|
||||
const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
||||
requestItem.criteria = new DataRepositoryCriteria();
|
||||
requestItem.criteria.like = query;
|
||||
requestItem.criteria.type = '';
|
||||
return this.externalSourcesService.listExternal(ReferenceType.PubRepositories, requestItem.criteria.like, requestItem.criteria.type);
|
||||
searchDatasetExternalPubRepositories(query: string): Observable<Reference[]> {
|
||||
// const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
||||
// requestItem.criteria = new DataRepositoryCriteria();
|
||||
// requestItem.criteria.like = query;
|
||||
// requestItem.criteria.type = '';
|
||||
// return this.externalSourcesService.listExternal(ReferenceType.PubRepositories, requestItem.criteria.like, requestItem.criteria.type);
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = query;
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.PubRepositories;
|
||||
return this.referenceService.search(lookup);
|
||||
}
|
||||
searchDatasetExternalJournalRepositories(query: string): Observable<FetcherReference[]> {
|
||||
const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
||||
requestItem.criteria = new DataRepositoryCriteria();
|
||||
requestItem.criteria.like = query;
|
||||
requestItem.criteria.type = '';
|
||||
return this.externalSourcesService.listExternal(ReferenceType.Journals, requestItem.criteria.like, requestItem.criteria.type);
|
||||
searchDatasetExternalJournalRepositories(query: string): Observable<Reference[]> {
|
||||
// const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
||||
// requestItem.criteria = new DataRepositoryCriteria();
|
||||
// requestItem.criteria.like = query;
|
||||
// requestItem.criteria.type = '';
|
||||
// return this.externalSourcesService.listExternal(ReferenceType.Journals, requestItem.criteria.like, requestItem.criteria.type);
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = query;
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.Journals;
|
||||
return this.referenceService.search(lookup);
|
||||
}
|
||||
searchDatasetExternalTaxonomies(query: string): Observable<FetcherReference[]> {
|
||||
const requestItem: RequestItem<TaxonomyCriteria> = new RequestItem();
|
||||
|
@ -503,19 +527,30 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
requestItem.criteria.type = '';
|
||||
return this.externalSourcesService.listExternal(ReferenceType.Taxonomies, requestItem.criteria.like, requestItem.criteria.type);
|
||||
}
|
||||
searchDatasetExternalLicences(query: string): Observable<FetcherReference[]> {
|
||||
const requestItem: RequestItem<LicenseCriteria> = new RequestItem();
|
||||
requestItem.criteria = new LicenseCriteria();
|
||||
requestItem.criteria.like = query;
|
||||
requestItem.criteria.type = '';
|
||||
return this.externalSourcesService.listExternal(ReferenceType.Licenses, requestItem.criteria.like, requestItem.criteria.type);
|
||||
searchDatasetExternalLicences(query: string): Observable<Reference[]> {
|
||||
// const requestItem: RequestItem<LicenseCriteria> = new RequestItem();
|
||||
// requestItem.criteria = new LicenseCriteria();
|
||||
// requestItem.criteria.like = query;
|
||||
// requestItem.criteria.type = '';
|
||||
// return this.externalSourcesService.listExternal(ReferenceType.Licenses, requestItem.criteria.like, requestItem.criteria.type);
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = query;
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.Licenses;
|
||||
return this.referenceService.search(lookup);
|
||||
}
|
||||
searchDatasetExternalPublications(query: string): Observable<FetcherReference[]> {
|
||||
const requestItem: RequestItem<PublicationCriteria> = new RequestItem();
|
||||
requestItem.criteria = new PublicationCriteria();
|
||||
requestItem.criteria.like = query;
|
||||
requestItem.criteria.type = '';
|
||||
return this.externalSourcesService.listExternal(ReferenceType.Publications, requestItem.criteria.like, requestItem.criteria.type);
|
||||
searchDatasetExternalPublications(query: string): Observable<Reference[]> {
|
||||
// const requestItem: RequestItem<PublicationCriteria> = new RequestItem();
|
||||
// requestItem.criteria = new PublicationCriteria();
|
||||
// requestItem.criteria.like = query;
|
||||
// requestItem.criteria.type = '';
|
||||
//return this.externalSourcesService.listExternal(ReferenceType.Publications, requestItem.criteria.like, requestItem.criteria.type);
|
||||
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = query;
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.Publications;
|
||||
return this.referenceService.search(lookup);
|
||||
}
|
||||
|
||||
searchDatasetExternalRegistries(query: string): Observable<FetcherReference[]> {
|
||||
|
@ -593,14 +628,24 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
filterOrganisations(value: string): Observable<FetcherReference[]> {
|
||||
filterOrganisations(value: string): Observable<Reference[]> {
|
||||
//return this.externalSourcesService.searchDMPOrganizations(value);
|
||||
return this.externalSourcesService.listExternal(ReferenceType.Organizations, value, '');
|
||||
//return this.externalSourcesService.listExternal(ReferenceType.Organizations, value, '');
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = value;
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.Organizations;
|
||||
return this.referenceService.search(lookup);
|
||||
}
|
||||
|
||||
filterResearchers(value: string): Observable<FetcherReference[]> {
|
||||
filterResearchers(value: string): Observable<Reference[]> {
|
||||
//return this.externalSourcesService.searchDMPResearchers({ criteria: { name: value, like: null } });
|
||||
return this.externalSourcesService.listExternal(ReferenceType.Researcher, value, '');
|
||||
//return this.externalSourcesService.listExternal(ReferenceType.Researcher, value, '');
|
||||
const lookup = new ReferenceSearchLookup();
|
||||
lookup.like = value;
|
||||
lookup.key = '';
|
||||
lookup.type = ReferenceType.Researcher;
|
||||
return this.referenceService.search(lookup);
|
||||
}
|
||||
|
||||
getDatasetIdControl(name: string): UntypedFormControl {
|
||||
|
|
Loading…
Reference in New Issue