From f72a50f9af8724e112c84d18dcff6c362b4c4248 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 22 May 2024 13:25:38 +0300 Subject: [PATCH] elastic dmp query support group ids --- .../data/DescriptionElasticEntity.java | 33 +++++++-------- .../NestedDescriptionElasticEntity.java | 29 ++++++------- ...estedDescriptionTemplateElasticEntity.java | 29 +++++++++---- .../NestedDescriptionElasticBuilder.java | 1 + ...stedDescriptionTemplateElasticBuilder.java | 7 ++-- .../elastic/query/DmpElasticQuery.java | 16 ++++++-- ...ObjectDescriptionTemplateElasticQuery.java | 41 +++++++++++++++---- .../query/NestedDescriptionElasticQuery.java | 34 ++++++++++----- ...NestedDescriptionTemplateElasticQuery.java | 8 ++-- .../lookup/DmpDescriptionTemplateLookup.java | 33 ++++++++++----- .../org/opencdmp/query/lookup/DmpLookup.java | 4 +- .../service/elastic/ElasticServiceImpl.java | 1 + .../tag/tags-field/tags-field.component.html | 1 - 13 files changed, 157 insertions(+), 80 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java index 9c190127e..a5bcbf6eb 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/DescriptionElasticEntity.java @@ -1,8 +1,11 @@ package org.opencdmp.elastic.data; -import org.opencdmp.commons.enums.DescriptionStatus; -import org.opencdmp.elastic.data.nested.*; import gr.cite.tools.elastic.ElasticConstants; +import org.opencdmp.commons.enums.DescriptionStatus; +import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; +import org.opencdmp.elastic.data.nested.NestedDmpElasticEntity; +import org.opencdmp.elastic.data.nested.NestedReferenceElasticEntity; +import org.opencdmp.elastic.data.nested.NestedTagElasticEntity; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.*; @@ -22,9 +25,7 @@ public class DescriptionElasticEntity { private UUID tenantId; public final static String _tenantId = "tenantId"; - @MultiField(mainField = @Field(value = DescriptionElasticEntity._label, type = FieldType.Text), otherFields = { - @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword) - }) + @MultiField(mainField = @Field(value = DescriptionElasticEntity._label, type = FieldType.Text), otherFields = @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)) private String label; public final static String _label = "label"; @@ -61,7 +62,7 @@ public class DescriptionElasticEntity { public final static String _references = "references"; public UUID getId() { - return id; + return this.id; } public void setId(UUID id) { @@ -69,7 +70,7 @@ public class DescriptionElasticEntity { } public UUID getTenantId() { - return tenantId; + return this.tenantId; } public void setTenantId(UUID tenantId) { @@ -77,7 +78,7 @@ public class DescriptionElasticEntity { } public String getLabel() { - return label; + return this.label; } public void setLabel(String label) { @@ -85,7 +86,7 @@ public class DescriptionElasticEntity { } public String getDescription() { - return description; + return this.description; } public void setDescription(String description) { @@ -93,7 +94,7 @@ public class DescriptionElasticEntity { } public DescriptionStatus getStatus() { - return status; + return this.status; } public void setStatus(DescriptionStatus status) { @@ -101,7 +102,7 @@ public class DescriptionElasticEntity { } public Date getFinalizedAt() { - return finalizedAt; + return this.finalizedAt; } public void setFinalizedAt(Date finalizedAt) { @@ -109,7 +110,7 @@ public class DescriptionElasticEntity { } public List getTags() { - return tags; + return this.tags; } public void setTags(List tags) { @@ -117,7 +118,7 @@ public class DescriptionElasticEntity { } public NestedDescriptionTemplateElasticEntity getDescriptionTemplate() { - return descriptionTemplate; + return this.descriptionTemplate; } public void setDescriptionTemplate(NestedDescriptionTemplateElasticEntity descriptionTemplate) { @@ -125,7 +126,7 @@ public class DescriptionElasticEntity { } public NestedDmpElasticEntity getDmp() { - return dmp; + return this.dmp; } public void setDmp(NestedDmpElasticEntity dmp) { @@ -133,7 +134,7 @@ public class DescriptionElasticEntity { } public List getReferences() { - return references; + return this.references; } public void setReferences(List references) { @@ -141,7 +142,7 @@ public class DescriptionElasticEntity { } public Date getCreatedAt() { - return createdAt; + return this.createdAt; } public void setCreatedAt(Date createdAt) { diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionElasticEntity.java index 114826abd..2b42887b9 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionElasticEntity.java @@ -1,10 +1,13 @@ package org.opencdmp.elastic.data.nested; +import gr.cite.tools.elastic.ElasticConstants; import org.opencdmp.commons.enums.DescriptionStatus; import org.opencdmp.elastic.data.DescriptionElasticEntity; -import gr.cite.tools.elastic.ElasticConstants; import org.springframework.data.annotation.Id; -import org.springframework.data.elasticsearch.annotations.*; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; +import org.springframework.data.elasticsearch.annotations.InnerField; +import org.springframework.data.elasticsearch.annotations.MultiField; import java.util.Date; import java.util.List; @@ -21,9 +24,7 @@ public class NestedDescriptionElasticEntity { private UUID dmpId; public final static String _dmpId = "dmpId"; - @MultiField(mainField = @Field(value = NestedDescriptionElasticEntity._label, type = FieldType.Text), otherFields = { - @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword) - }) + @MultiField(mainField = @Field(value = NestedDescriptionElasticEntity._label, type = FieldType.Text), otherFields = @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)) private String label; public final static String _label = "label"; @@ -52,7 +53,7 @@ public class NestedDescriptionElasticEntity { public final static String _descriptionTemplate = "descriptionTemplate"; public UUID getId() { - return id; + return this.id; } public void setId(UUID id) { @@ -60,7 +61,7 @@ public class NestedDescriptionElasticEntity { } public UUID getDmpId() { - return dmpId; + return this.dmpId; } public void setDmpId(UUID dmpId) { @@ -68,7 +69,7 @@ public class NestedDescriptionElasticEntity { } public String getLabel() { - return label; + return this.label; } public void setLabel(String label) { @@ -76,7 +77,7 @@ public class NestedDescriptionElasticEntity { } public String getDescription() { - return description; + return this.description; } public void setDescription(String description) { @@ -84,7 +85,7 @@ public class NestedDescriptionElasticEntity { } public DescriptionStatus getStatus() { - return status; + return this.status; } public void setStatus(DescriptionStatus status) { @@ -92,7 +93,7 @@ public class NestedDescriptionElasticEntity { } public Date getFinalizedAt() { - return finalizedAt; + return this.finalizedAt; } public void setFinalizedAt(Date finalizedAt) { @@ -100,7 +101,7 @@ public class NestedDescriptionElasticEntity { } public List getTags() { - return tags; + return this.tags; } public void setTags(List tags) { @@ -108,7 +109,7 @@ public class NestedDescriptionElasticEntity { } public List getReferences() { - return references; + return this.references; } public void setReferences(List references) { @@ -116,7 +117,7 @@ public class NestedDescriptionElasticEntity { } public NestedDescriptionTemplateElasticEntity getDescriptionTemplate() { - return descriptionTemplate; + return this.descriptionTemplate; } public void setDescriptionTemplate(NestedDescriptionTemplateElasticEntity descriptionTemplate) { diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionTemplateElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionTemplateElasticEntity.java index e653c9519..44f6b28d1 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionTemplateElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/nested/NestedDescriptionTemplateElasticEntity.java @@ -1,10 +1,12 @@ package org.opencdmp.elastic.data.nested; -import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus; -import org.opencdmp.elastic.data.DescriptionElasticEntity; import gr.cite.tools.elastic.ElasticConstants; +import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus; import org.springframework.data.annotation.Id; -import org.springframework.data.elasticsearch.annotations.*; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; +import org.springframework.data.elasticsearch.annotations.InnerField; +import org.springframework.data.elasticsearch.annotations.MultiField; import java.util.UUID; @@ -15,19 +17,20 @@ public class NestedDescriptionTemplateElasticEntity { private UUID id; public final static String _id = "id"; - @MultiField(mainField = @Field(value = NestedDescriptionTemplateElasticEntity._label, type = FieldType.Text), otherFields = { - @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword) - }) + @MultiField(mainField = @Field(value = NestedDescriptionTemplateElasticEntity._label, type = FieldType.Text), otherFields = @InnerField(suffix = ElasticConstants.SubFields.keyword, type = FieldType.Keyword)) private String label; public final static String _label = "label"; + @Field(value = NestedDescriptionTemplateElasticEntity._groupId, type = FieldType.Keyword) + private UUID groupId; + public final static String _groupId = "groupId"; @Field(value = NestedDescriptionTemplateElasticEntity._versionStatus, type = FieldType.Short) private DescriptionTemplateVersionStatus versionStatus; public final static String _versionStatus = "versionStatus"; public UUID getId() { - return id; + return this.id; } public void setId(UUID id) { @@ -35,15 +38,23 @@ public class NestedDescriptionTemplateElasticEntity { } public String getLabel() { - return label; + return this.label; } public void setLabel(String label) { this.label = label; } + public UUID getGroupId() { + return this.groupId; + } + + public void setGroupId(UUID groupId) { + this.groupId = groupId; + } + public DescriptionTemplateVersionStatus getVersionStatus() { - return versionStatus; + return this.versionStatus; } public void setVersionStatus(DescriptionTemplateVersionStatus versionStatus) { diff --git a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDescriptionElasticBuilder.java b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDescriptionElasticBuilder.java index d3f971383..97f3f0af5 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDescriptionElasticBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/nested/NestedDescriptionElasticBuilder.java @@ -64,6 +64,7 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder { @Autowired @@ -37,6 +37,7 @@ public class NestedDescriptionTemplateElasticBuilder extends BaseElasticBuilder< m.setId(d.getId()); m.setVersionStatus(d.getVersionStatus()); m.setLabel(d.getLabel()); + m.setGroupId(d.getGroupId()); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/backend/core/src/main/java/org/opencdmp/elastic/query/DmpElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/DmpElasticQuery.java index 8e9633bff..f83391659 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/query/DmpElasticQuery.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/DmpElasticQuery.java @@ -34,7 +34,6 @@ import org.springframework.stereotype.Component; import javax.management.InvalidApplicationException; import java.io.IOException; import java.util.*; -import java.util.stream.Collectors; @Component //Like in C# make it Transient @@ -50,6 +49,7 @@ public class DmpElasticQuery extends ElasticQuery { private Collection versions; private Collection groupIds; private NestedCollaboratorElasticQuery dmpUserSubQuery; + private NestedDescriptionElasticQuery descriptionSubQuery; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -58,6 +58,11 @@ public class DmpElasticQuery extends ElasticQuery { return this; } + public DmpElasticQuery descriptionSubQuery(NestedDescriptionElasticQuery subQuery) { + this.descriptionSubQuery = subQuery; + return this; + } + public DmpElasticQuery like(String value) { this.like = value; return this; @@ -294,17 +299,20 @@ public class DmpElasticQuery extends ElasticQuery { predicates.add(this.not(this.containsUUID(this.elasticFieldOf(DmpElasticEntity._id), this.excludedIds)._toQuery())._toQuery()); } if (this.statuses != null) { - predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._status), this.statuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.statuses.size()]))._toQuery()); + predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._status), this.statuses.stream().map(DmpStatus::getValue).toList().toArray(new Short[this.statuses.size()]))._toQuery()); } if (this.versionStatuses != null) { - predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._versionStatus), this.versionStatuses.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.versionStatuses.size()]))._toQuery()); + predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._versionStatus), this.versionStatuses.stream().map(DmpVersionStatus::getValue).toList().toArray(new Short[this.versionStatuses.size()]))._toQuery()); } if (this.accessTypes != null) { - predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._accessType), this.accessTypes.stream().map(x-> x.getValue()).collect(Collectors.toList()).toArray(new Short[this.accessTypes.size()]))._toQuery()); + predicates.add(this.contains(this.elasticFieldOf(DmpElasticEntity._accessType), this.accessTypes.stream().map(DmpAccessType::getValue).toList().toArray(new Short[this.accessTypes.size()]))._toQuery()); } if (this.dmpUserSubQuery != null) { predicates.add(this.nestedQuery( this.dmpUserSubQuery.nestedPath(DmpElasticEntity._collaborators)).build()._toQuery()); } + if (this.descriptionSubQuery != null) { + predicates.add(this.nestedQuery( this.descriptionSubQuery.nestedPath(DmpElasticEntity._descriptions)).build()._toQuery()); + } if (!predicates.isEmpty()) { return this.and(predicates); diff --git a/backend/core/src/main/java/org/opencdmp/elastic/query/InnerObjectDescriptionTemplateElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/InnerObjectDescriptionTemplateElasticQuery.java index 05d71f485..65c53c1f2 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/query/InnerObjectDescriptionTemplateElasticQuery.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/InnerObjectDescriptionTemplateElasticQuery.java @@ -1,26 +1,25 @@ package org.opencdmp.elastic.query; import co.elastic.clients.elasticsearch._types.query_dsl.Query; -import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus; -import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.elastic.configuration.ElasticProperties; import gr.cite.tools.elastic.mapper.FieldBasedMapper; import gr.cite.tools.elastic.query.ElasticField; import gr.cite.tools.elastic.query.ElasticInnerObjectQuery; import gr.cite.tools.elastic.query.ElasticNestedQuery; +import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus; +import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; import org.springframework.stereotype.Component; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObjectQuery { + private Collection groupIds; private String innerPath; @@ -30,6 +29,21 @@ public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObje return this; } + public InnerObjectDescriptionTemplateElasticQuery groupIds(UUID value) { + this.groupIds = List.of(value); + return this; + } + + public InnerObjectDescriptionTemplateElasticQuery groupIds(UUID... value) { + this.groupIds = Arrays.asList(value); + return this; + } + + public InnerObjectDescriptionTemplateElasticQuery groupIds(Collection values) { + this.groupIds = values; + return this; + } + public InnerObjectDescriptionTemplateElasticQuery( ElasticsearchTemplate elasticsearchRestTemplate, @@ -45,7 +59,7 @@ public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObje @Override protected Boolean isFalseQuery() { - return false; + return this.isEmpty(this.groupIds); } @Override @@ -55,7 +69,16 @@ public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObje @Override protected Query applyFilters() { - return null; + List predicates = new ArrayList<>(); + if (this.groupIds != null) { + predicates.add(this.containsUUID(this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._groupId).disableInfer(true), this.groupIds)._toQuery()); + } + + if (!predicates.isEmpty()) { + return this.and(predicates); + } else { + return null; + } } @Override @@ -63,6 +86,7 @@ public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObje NestedDescriptionTemplateElasticEntity mocDoc = new NestedDescriptionTemplateElasticEntity(); if (columns.contains(NestedDescriptionTemplateElasticEntity._id)) mocDoc.setId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._id), UUID.class)); if (columns.contains(NestedDescriptionTemplateElasticEntity._label)) mocDoc.setLabel(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._label), String.class)); + if (columns.contains(NestedDescriptionTemplateElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._groupId), UUID.class)); if (columns.contains(NestedDescriptionTemplateElasticEntity._versionStatus)) mocDoc.setVersionStatus(FieldBasedMapper.shallowSafeConversion(rawData.get(NestedDescriptionTemplateElasticEntity._versionStatus), DescriptionTemplateVersionStatus.class)); return mocDoc; } @@ -71,6 +95,7 @@ public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObje protected ElasticField fieldNameOf(FieldResolver item) { if (item.match(NestedDescriptionTemplateElasticEntity._id)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._id).disableInfer(true); else if (item.match(NestedDescriptionTemplateElasticEntity._label)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._label).disableInfer(true); + else if (item.match(NestedDescriptionTemplateElasticEntity._groupId)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._groupId).disableInfer(true); else if (item.match(NestedDescriptionTemplateElasticEntity._versionStatus)) return this.elasticFieldOf(NestedDescriptionTemplateElasticEntity._versionStatus).disableInfer(true); else return null; } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/query/NestedDescriptionElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/NestedDescriptionElasticQuery.java index fa97b3f34..b9bad0e34 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/query/NestedDescriptionElasticQuery.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/NestedDescriptionElasticQuery.java @@ -1,31 +1,35 @@ package org.opencdmp.elastic.query; import co.elastic.clients.elasticsearch._types.query_dsl.Query; -import org.opencdmp.commons.enums.DescriptionStatus; -import org.opencdmp.convention.ConventionService; -import org.opencdmp.elastic.data.DescriptionElasticEntity; -import org.opencdmp.elastic.data.nested.NestedDescriptionElasticEntity; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.elastic.configuration.ElasticProperties; import gr.cite.tools.elastic.mapper.FieldBasedMapper; import gr.cite.tools.elastic.query.ElasticField; import gr.cite.tools.elastic.query.ElasticNestedQuery; +import org.opencdmp.commons.enums.DescriptionStatus; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.elastic.data.nested.NestedDescriptionElasticEntity; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; import org.springframework.stereotype.Component; -import java.util.Date; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class NestedDescriptionElasticQuery extends ElasticNestedQuery { private String nestedPath; + private InnerObjectDescriptionTemplateElasticQuery descriptionTemplateSubQuery; + + + + public NestedDescriptionElasticQuery descriptionTemplateSubQuery(InnerObjectDescriptionTemplateElasticQuery subQuery) { + this.descriptionTemplateSubQuery = subQuery; + return this; + } @Override public NestedDescriptionElasticQuery nestedPath(String value) { @@ -61,7 +65,17 @@ public class NestedDescriptionElasticQuery extends ElasticNestedQuery predicates = new ArrayList<>(); + + if (this.descriptionTemplateSubQuery != null) { + predicates.add(this.descriptionTemplateSubQuery.innerPath(this.conventionService.asIndexer(this.getNestedPath(), NestedDescriptionElasticEntity._descriptionTemplate)).applyFilters()); + } + + if (!predicates.isEmpty()) { + return this.and(predicates); + } else { + return null; + } } @Override diff --git a/backend/core/src/main/java/org/opencdmp/elastic/query/NestedDescriptionTemplateElasticQuery.java b/backend/core/src/main/java/org/opencdmp/elastic/query/NestedDescriptionTemplateElasticQuery.java index 7c8b1f648..fb3b1be6f 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/query/NestedDescriptionTemplateElasticQuery.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/query/NestedDescriptionTemplateElasticQuery.java @@ -1,13 +1,13 @@ package org.opencdmp.elastic.query; import co.elastic.clients.elasticsearch._types.query_dsl.Query; -import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus; -import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.elastic.configuration.ElasticProperties; import gr.cite.tools.elastic.mapper.FieldBasedMapper; import gr.cite.tools.elastic.query.ElasticField; import gr.cite.tools.elastic.query.ElasticNestedQuery; +import org.opencdmp.commons.enums.DescriptionTemplateVersionStatus; +import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; @@ -18,7 +18,7 @@ import java.util.Set; import java.util.UUID; @Component -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class NestedDescriptionTemplateElasticQuery extends ElasticNestedQuery { private String nestedPath; @@ -62,6 +62,7 @@ public class NestedDescriptionTemplateElasticQuery extends ElasticNestedQuery isActive; public List getIds() { - return ids; + return this.ids; } public void setIds(List ids) { @@ -30,7 +30,7 @@ public class DmpDescriptionTemplateLookup extends Lookup { } public List getExcludedIds() { - return excludedIds; + return this.excludedIds; } public void setExcludedIds(List excludedIds) { @@ -38,7 +38,7 @@ public class DmpDescriptionTemplateLookup extends Lookup { } public List getIsActive() { - return isActive; + return this.isActive; } public void setIsActive(List isActive) { @@ -46,7 +46,7 @@ public class DmpDescriptionTemplateLookup extends Lookup { } public List getDmpIds() { - return dmpIds; + return this.dmpIds; } public void setDmpIds(List dmpIds) { @@ -54,11 +54,11 @@ public class DmpDescriptionTemplateLookup extends Lookup { } public List getDescriptionTemplateGroupIds() { - return descriptionTemplateGroupIds; + return this.descriptionTemplateGroupIds; } public List getSectionIds() { - return sectionIds; + return this.sectionIds; } public void setSectionIds(List sectionIds) { @@ -83,4 +83,17 @@ public class DmpDescriptionTemplateLookup extends Lookup { return query; } + public NestedDescriptionElasticQuery enrichElasticInner(QueryFactory queryFactory) { + NestedDescriptionElasticQuery query = queryFactory.query(NestedDescriptionElasticQuery.class); + if (this.ids != null) throw new UnsupportedOperationException(""); + if (this.dmpIds != null) throw new UnsupportedOperationException(""); + if (this.descriptionTemplateGroupIds != null) query.descriptionTemplateSubQuery(queryFactory.query(InnerObjectDescriptionTemplateElasticQuery.class).groupIds(this.descriptionTemplateGroupIds)); + if (this.sectionIds != null) throw new UnsupportedOperationException(""); + if (this.excludedIds != null) throw new UnsupportedOperationException(""); + + this.enrichCommon(query); + + return query; + } + } diff --git a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpLookup.java b/backend/core/src/main/java/org/opencdmp/query/lookup/DmpLookup.java index 204344c28..bedc6fdc0 100644 --- a/backend/core/src/main/java/org/opencdmp/query/lookup/DmpLookup.java +++ b/backend/core/src/main/java/org/opencdmp/query/lookup/DmpLookup.java @@ -151,8 +151,8 @@ public class DmpLookup extends Lookup { if (this.statuses != null) query.statuses(this.statuses); if (this.versions != null) query.versions(this.versions); if (this.versionStatuses != null) query.versionStatuses(this.versionStatuses); - if (this.dmpDescriptionTemplateSubQuery != null) throw new UnsupportedOperationException(""); - if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory)); + if (this.dmpDescriptionTemplateSubQuery != null) query.descriptionSubQuery(this.dmpDescriptionTemplateSubQuery.enrichElasticInner(queryFactory)); + if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory)); this.enrichCommon(query); diff --git a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java index 6724fdd65..5813a3c48 100644 --- a/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/elastic/ElasticServiceImpl.java @@ -206,6 +206,7 @@ public class ElasticServiceImpl implements ElasticService { propertyMap.put(NestedDescriptionTemplateElasticEntity._id, this.createElastic(FieldType.Keyword, false)); propertyMap.put(NestedDescriptionTemplateElasticEntity._label, this.createElastic(FieldType.Text, true)); propertyMap.put(NestedDescriptionTemplateElasticEntity._versionStatus, this.createElastic(FieldType.Short, true)); + propertyMap.put(NestedDescriptionTemplateElasticEntity._groupId, this.createElastic(FieldType.Keyword, true)); return propertyMap; } diff --git a/dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.html b/dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.html index 52411a4f4..616a3746e 100644 --- a/dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.html +++ b/dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.html @@ -16,5 +16,4 @@ {{ form.getError('backendError')?.message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} -