From 41fc3407eb6c912142af011c5519056ff26828bf Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Thu, 9 Nov 2023 11:29:42 +0200 Subject: [PATCH] description refactor --- .../eu/eudat/authorization/Permission.java | 5 +++ .../java/eu/eudat/data/DescriptionEntity.java | 14 +++++++- .../main/java/eu/eudat/model/Description.java | 12 +++++++ .../model/builder/DescriptionBuilder.java | 34 +++++++++++++++++++ .../model/censorship/DescriptionCensor.java | 3 ++ .../censorship/DescriptionTagCensor.java | 2 +- .../java/eu/eudat/query/DescriptionQuery.java | 24 ++++++++----- .../query/DescriptionReferenceQuery.java | 12 ++----- .../eu/eudat/query/DescriptionTagQuery.java | 11 ++---- .../eu/eudat/query/DmpReferenceQuery.java | 33 ++++++++++++++++-- .../eudat/query/lookup/DescriptionLookup.java | 10 ++++++ .../elastic/repository/DatasetRepository.java | 4 +-- .../elastic/repository/DmpRepository.java | 3 +- .../elastic/repository/ElasticRepository.java | 11 +++--- .../resources/config/elasticsearch-devel.yml | 2 ++ 15 files changed, 140 insertions(+), 40 deletions(-) create mode 100644 dmp-backend/web/src/main/resources/config/elasticsearch-devel.yml diff --git a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java index b46db02e1..9ecc4948a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java +++ b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java @@ -75,6 +75,11 @@ public final class Permission { public static String EditDescription = "EditDescription"; public static String DeleteDescription = "DeleteDescription"; + //DescriptionTag + public static String BrowseDescriptionTag = "BrowseDescriptionTag"; + public static String EditDescriptionTag = "EditDescriptionTag"; + public static String DeleteDescriptionTag = "DeleteDescriptionTag"; + //DescriptionTemplateType public static String BrowseEntityDoi = "BrowseEntityDoi"; public static String EditEntityDoi = "EditEntityDoi"; diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java index d9af6478a..b0885e040 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java @@ -77,8 +77,12 @@ public class DescriptionEntity implements DataEntity { @Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false) private UUID dmpDescriptionTemplateId; - public static final String _dmpDescriptionTemplateId = "dmpDescriptionTemplateId"; + + @Column(name = "dmp", columnDefinition = "uuid", nullable = false) + private UUID dmpId; + + public static final String _dmpId = "dmpId"; public UUID getId() { return id; @@ -168,6 +172,14 @@ public class DescriptionEntity implements DataEntity { this.dmpDescriptionTemplateId = dmpDescriptionTemplateId; } + public UUID getDmpId() { + return dmpId; + } + + public void setDmpId(UUID dmpId) { + this.dmpId = dmpId; + } + @Override public void update(DescriptionEntity entity) { // this.setUri(entity.getUri()); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/Description.java b/dmp-backend/core/src/main/java/eu/eudat/model/Description.java index aafc827c3..589a05df4 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/Description.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/Description.java @@ -67,6 +67,10 @@ public class Description { public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate"; + private Dmp dmp; + + public static final String _dmp = "dmp"; + public UUID getId() { return id; } @@ -179,4 +183,12 @@ public class Description { public void setDescriptionTags(List descriptionTags) { this.descriptionTags = descriptionTags; } + + public Dmp getDmp() { + return dmp; + } + + public void setDmp(Dmp dmp) { + this.dmp = dmp; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java index 698a66720..5f2fe8611 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java @@ -62,6 +62,9 @@ public class DescriptionBuilder extends BaseBuilder dmpDescriptionTemplateItemsMap = this.collectDmpDescriptionTemplates(dmpDescriptionTemplateFields, data); + FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(Description._dmpDescriptionTemplate)); + Map dmpItemsMap = this.collectDmps(dmpFields, data); + FieldSet descriptionReferencesFields = fields.extractPrefixed(this.asPrefix(Description._descriptionReferences)); Map> descriptionReferencesMap = this.collectDescriptionReferences(descriptionReferencesFields, data); @@ -82,6 +85,7 @@ public class DescriptionBuilder extends BaseBuilder collectDmps(FieldSet fields, List data) throws MyApplicationException { + if (fields.isEmpty() || data.isEmpty()) + return null; + this.logger.debug("checking related - {}", Dmp.class.getSimpleName()); + + Map itemMap; + if (!fields.hasOtherField(this.asIndexer(Dmp._id))) { + itemMap = this.asEmpty( + data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()), + x -> { + Dmp item = new Dmp(); + item.setId(x); + return item; + }, + Dmp::getId); + } else { + FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id); + DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList())); + itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId); + } + if (!fields.hasField(Dmp._id)) { + itemMap.forEach((id, item) -> { + if (item != null) + item.setId(null); + }); + } + + return itemMap; + } + private Map> collectDescriptionReferences(FieldSet fields, List data) throws MyApplicationException { if (fields.isEmpty() || data.isEmpty()) return null; this.logger.debug("checking related - {}", DescriptionReference.class.getSimpleName()); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionCensor.java index 36c550e23..6e3f5136b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionCensor.java @@ -48,6 +48,9 @@ public class DescriptionCensor extends BaseCensor { FieldSet dmpDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmpDescriptionTemplate)); this.censorFactory.censor(DmpDescriptionTemplateCensor.class).censor(dmpDescriptionTemplateFields, userId); + FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmp)); + this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId); + FieldSet propertiesFields = fields.extractPrefixed(this.asIndexerPrefix(Description._properties)); this.censorFactory.censor(PropertyDefinitionCensor.class).censor(propertiesFields, userId); diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionTagCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionTagCensor.java index 5babfb353..8160aceb5 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionTagCensor.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DescriptionTagCensor.java @@ -41,7 +41,7 @@ public class DescriptionTagCensor extends BaseCensor { if (fields == null || fields.isEmpty()) return; - this.authService.authorizeForce(Permission.BrowseDescriptionReference); + this.authService.authorizeForce(Permission.BrowseDescriptionTag); FieldSet descriptionFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionTag._description)); this.censorFactory.censor(DescriptionCensor.class).censor(descriptionFields, userId); FieldSet tagFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionTag._tag)); diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java index 33ca55684..86ad808bf 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java @@ -33,6 +33,7 @@ public class DescriptionQuery extends QueryBase { private String like; private Collection ids; private DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery; + private DmpQuery dmpQuery; private Collection excludedIds; private Collection isActives; @@ -74,6 +75,11 @@ public class DescriptionQuery extends QueryBase { this.dmpDescriptionTemplateQuery = subQuery; return this; } + + public DescriptionQuery dmpSubQuery(DmpQuery subQuery) { + this.dmpQuery = subQuery; + return this; + } public DescriptionQuery excludedIds(Collection values) { this.excludedIds = values; @@ -130,7 +136,7 @@ public class DescriptionQuery extends QueryBase { return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || - this.isEmpty(this.excludedIds) || + this.isEmpty(this.excludedIds) || this.isFalseQuery(this.dmpQuery) || this.isEmpty(this.statuses) || this.isFalseQuery(this.dmpDescriptionTemplateQuery); } @@ -150,14 +156,7 @@ public class DescriptionQuery extends QueryBase { List predicates = new ArrayList<>(); if (userId != null || usePublic ) { - Subquery dmpDescriptionTemplateSubquery = queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( - new BuildSubQueryInput.Builder<>(DmpDescriptionTemplateEntity.class, UUID.class, queryContext) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpDescriptionTemplateEntity._id)) - .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DmpDescriptionTemplateEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) - ) - )); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)).value(dmpDescriptionTemplateSubquery)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); } if (predicates.size() > 0) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); @@ -205,6 +204,11 @@ public class DescriptionQuery extends QueryBase { this.applySubQuery(this.dmpDescriptionTemplateQuery, queryContext.CriteriaBuilder, subQuery); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)).value(subQuery)); } + if (this.dmpQuery != null) { + Subquery subQuery = queryContext.Query.subquery(this.dmpQuery.entityClass()); + this.applySubQuery(this.dmpQuery, queryContext.CriteriaBuilder, subQuery); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId)).value(subQuery)); + } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); return queryContext.CriteriaBuilder.and(predicatesArray); @@ -226,6 +230,7 @@ public class DescriptionQuery extends QueryBase { else if (item.match(Description._isActive)) return DescriptionEntity._isActive; else if (item.match(Description._finalizedAt)) return DescriptionEntity._finalizedAt; else if (item.match(Description._dmpDescriptionTemplate)) return DescriptionEntity._dmpDescriptionTemplateId; + else if (item.prefix(Description._dmp)) return DescriptionEntity._dmpId; else return null; } @@ -242,6 +247,7 @@ public class DescriptionQuery extends QueryBase { item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionEntity._isActive, IsActive.class)); item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._finalizedAt, Instant.class)); item.setDmpDescriptionTemplateId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpDescriptionTemplateId, UUID.class)); + item.setDmpId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpId, UUID.class)); return item; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java index 8d0286c14..aa14a630d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java @@ -1,6 +1,7 @@ package eu.eudat.query; import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.authorization.Permission; import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.data.DescriptionEntity; @@ -148,7 +149,7 @@ public class DescriptionReferenceQuery extends QueryBase Predicate applyAuthZ(QueryContext queryContext) { if (this.authorize.contains(AuthorizationFlags.None)) return null; - //if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDescription)) return null; + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDescriptionReference)) return null; UUID userId; boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe(); @@ -156,18 +157,11 @@ public class DescriptionReferenceQuery extends QueryBase predicates = new ArrayList<>(); if (userId != null || usePublic ) { - Subquery dmpDescriptionTemplateSubquery = queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( - new BuildSubQueryInput.Builder<>(DmpDescriptionTemplateEntity.class, UUID.class, queryContext) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpDescriptionTemplateEntity._id)) - .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DmpDescriptionTemplateEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) - ) - )); Subquery descriptionSubquery = queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( new BuildSubQueryInput.Builder<>(DescriptionEntity.class, UUID.class, queryContext) .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DescriptionEntity._id)) .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DescriptionEntity._dmpDescriptionTemplateId)).value(dmpDescriptionTemplateSubquery) + cb.in(subQueryRoot.get(DescriptionEntity._dmpDescriptionTemplateId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) ) )); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._descriptionId)).value(descriptionSubquery)); diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTagQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTagQuery.java index 2d904e4aa..527f60c77 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTagQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTagQuery.java @@ -147,7 +147,7 @@ public class DescriptionTagQuery extends QueryBase { @Override protected Predicate applyAuthZ(QueryContext queryContext) { if (this.authorize.contains(AuthorizationFlags.None)) return null; - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDescription)) return null; + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDescriptionTag)) return null; UUID userId; boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe(); @@ -155,18 +155,11 @@ public class DescriptionTagQuery extends QueryBase { List predicates = new ArrayList<>(); if (userId != null || usePublic ) { - Subquery dmpDescriptionTemplateSubquery = queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( - new BuildSubQueryInput.Builder<>(DmpDescriptionTemplateEntity.class, UUID.class, queryContext) - .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpDescriptionTemplateEntity._id)) - .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DmpDescriptionTemplateEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) - ) - )); Subquery descriptionSubquery = queryUtilsService.buildSubQuery(new BuildSubQueryInput<>( new BuildSubQueryInput.Builder<>(DescriptionEntity.class, UUID.class, queryContext) .keyPathFunc((subQueryRoot) -> subQueryRoot.get(DescriptionEntity._id)) .filterFunc((subQueryRoot, cb) -> - cb.in(subQueryRoot.get(DescriptionEntity._dmpDescriptionTemplateId)).value(dmpDescriptionTemplateSubquery) + cb.in(subQueryRoot.get(DescriptionEntity._dmpDescriptionTemplateId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)) ) )); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTagEntity._descriptionId)).value(descriptionSubquery)); diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java index 7747eda97..dee7dd50a 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java @@ -1,10 +1,15 @@ package eu.eudat.query; import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.authorization.Permission; import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.scope.user.UserScope; +import eu.eudat.data.DescriptionEntity; +import eu.eudat.data.DescriptionReferenceEntity; import eu.eudat.data.DmpReferenceEntity; import eu.eudat.model.DmpReference; +import eu.eudat.query.utils.BuildSubQueryInput; +import eu.eudat.query.utils.QueryUtilsService; import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; @@ -12,6 +17,7 @@ import gr.cite.tools.data.query.QueryContext; import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Subquery; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -102,13 +108,15 @@ public class DmpReferenceQuery extends QueryBase { private final UserScope userScope; private final AuthorizationService authService; + private final QueryUtilsService queryUtilsService; public DmpReferenceQuery( UserScope userScope, - AuthorizationService authService - ) { + AuthorizationService authService, + QueryUtilsService queryUtilsService) { this.userScope = userScope; this.authService = authService; + this.queryUtilsService = queryUtilsService; } @Override @@ -121,6 +129,27 @@ public class DmpReferenceQuery extends QueryBase { return this.isEmpty(this.ids) || this.isEmpty(this.dmpIds) || this.isEmpty(this.referenceIds); } + @Override + protected Predicate applyAuthZ(QueryContext queryContext) { + if (this.authorize.contains(AuthorizationFlags.None)) return null; + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseDmpReference)) return null; + UUID userId; + boolean usePublic = this.authorize.contains(AuthorizationFlags.Public); + if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe(); + else userId = null; + + List predicates = new ArrayList<>(); + if (userId != null || usePublic ) { + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))); + } + if (predicates.size() > 0) { + Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); + return queryContext.CriteriaBuilder.and(predicatesArray); + } else { + return queryContext.CriteriaBuilder.or(); //Creates a false query + } + } + @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionLookup.java b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionLookup.java index faea05646..95037acf1 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionLookup.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionLookup.java @@ -18,6 +18,7 @@ public class DescriptionLookup extends Lookup { private List excludedIds; private DmpDescriptionTemplateLookup dmpDescriptionTemplateSubQuery; + private DmpLookup dmpSubQuery; private List isActive; @@ -71,12 +72,21 @@ public class DescriptionLookup extends Lookup { this.dmpDescriptionTemplateSubQuery = dmpDescriptionTemplateSubQuery; } + public DmpLookup getDmpSubQuery() { + return dmpSubQuery; + } + + public void setDmpSubQuery(DmpLookup dmpSubQuery) { + this.dmpSubQuery = dmpSubQuery; + } + public DescriptionQuery enrich(QueryFactory queryFactory) { DescriptionQuery query = queryFactory.query(DescriptionQuery.class); if (this.like != null) query.like(this.like); if (this.ids != null) query.ids(this.ids); if (this.excludedIds != null) query.excludedIds(this.excludedIds); if (this.dmpDescriptionTemplateSubQuery != null) query.dmpDescriptionTemplateSubQuery(this.dmpDescriptionTemplateSubQuery.enrich(queryFactory)); + if (this.dmpSubQuery != null) query.dmpSubQuery(this.dmpSubQuery.enrich(queryFactory)); if (this.isActive != null) query.isActive(this.isActive); if (this.statuses != null) query.statuses(this.statuses); diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java index 8364d6c57..5c50ac732 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/DatasetRepository.java @@ -28,8 +28,6 @@ import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import org.elasticsearch.search.sort.SortBuilder; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; @@ -45,7 +43,7 @@ public class DatasetRepository extends ElasticRepository { @Autowired public DmpRepository(RestHighLevelClient client, Environment environment) { - super(client); + super(client, environment); this.environment = environment; } diff --git a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/ElasticRepository.java b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/ElasticRepository.java index 68e329396..6f1ba9da8 100644 --- a/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/ElasticRepository.java +++ b/dmp-backend/elastic/src/main/java/eu/eudat/elastic/repository/ElasticRepository.java @@ -3,12 +3,11 @@ package eu.eudat.elastic.repository; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.elastic.criteria.Criteria; import eu.eudat.elastic.entities.ElasticEntity; -import org.elasticsearch.client.Client; import org.elasticsearch.client.RequestOptions; -import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestHighLevelClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.env.Environment; import java.io.IOException; @@ -22,9 +21,13 @@ public abstract class ElasticRepository