Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-05-22 13:44:24 +03:00
commit 435efb3330
13 changed files with 157 additions and 80 deletions

View File

@ -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<NestedTagElasticEntity> getTags() {
return tags;
return this.tags;
}
public void setTags(List<NestedTagElasticEntity> 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<NestedReferenceElasticEntity> getReferences() {
return references;
return this.references;
}
public void setReferences(List<NestedReferenceElasticEntity> references) {
@ -141,7 +142,7 @@ public class DescriptionElasticEntity {
}
public Date getCreatedAt() {
return createdAt;
return this.createdAt;
}
public void setCreatedAt(Date createdAt) {

View File

@ -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<NestedTagElasticEntity> getTags() {
return tags;
return this.tags;
}
public void setTags(List<NestedTagElasticEntity> tags) {
@ -108,7 +109,7 @@ public class NestedDescriptionElasticEntity {
}
public List<NestedReferenceElasticEntity> getReferences() {
return references;
return this.references;
}
public void setReferences(List<NestedReferenceElasticEntity> references) {
@ -116,7 +117,7 @@ public class NestedDescriptionElasticEntity {
}
public NestedDescriptionTemplateElasticEntity getDescriptionTemplate() {
return descriptionTemplate;
return this.descriptionTemplate;
}
public void setDescriptionTemplate(NestedDescriptionTemplateElasticEntity descriptionTemplate) {

View File

@ -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) {

View File

@ -64,6 +64,7 @@ public class NestedDescriptionElasticBuilder extends BaseElasticBuilder<NestedDe
}
if (referenceElasticEntityMap != null) m.setReferences(referenceElasticEntityMap.getOrDefault(d.getId(), null));
if (tagElasticEntityMap != null) m.setTags(tagElasticEntityMap.getOrDefault(d.getId(), null));
if (descriptionTemplateElasticEntityMap != null) m.setDescriptionTemplate(descriptionTemplateElasticEntityMap.getOrDefault(d.getDescriptionTemplateId(), null));
models.add(m);
}
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));

View File

@ -1,11 +1,11 @@
package org.opencdmp.elastic.elasticbuilder.nested;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
import org.opencdmp.convention.ConventionService;
import org.opencdmp.data.DescriptionTemplateEntity;
import org.opencdmp.elastic.data.nested.NestedDescriptionTemplateElasticEntity;
import org.opencdmp.elastic.elasticbuilder.BaseElasticBuilder;
import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -17,7 +17,7 @@ import java.util.List;
import java.util.Optional;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NestedDescriptionTemplateElasticBuilder extends BaseElasticBuilder<NestedDescriptionTemplateElasticEntity, DescriptionTemplateEntity> {
@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));

View File

@ -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<DmpElasticEntity, UUID> {
private Collection<Integer> versions;
private Collection<UUID> groupIds;
private NestedCollaboratorElasticQuery dmpUserSubQuery;
private NestedDescriptionElasticQuery descriptionSubQuery;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@ -58,6 +58,11 @@ public class DmpElasticQuery extends ElasticQuery<DmpElasticEntity, UUID> {
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<DmpElasticEntity, UUID> {
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);

View File

@ -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<InnerObjectDescriptionTemplateElasticQuery, NestedDescriptionTemplateElasticEntity, UUID> {
private Collection<UUID> 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<UUID> 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,14 +69,24 @@ public class InnerObjectDescriptionTemplateElasticQuery extends ElasticInnerObje
@Override
protected Query applyFilters() {
List<Query> 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
public NestedDescriptionTemplateElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {
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;
}

View File

@ -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<NestedDescriptionElasticQuery, NestedDescriptionElasticEntity, UUID> {
private String nestedPath;
private InnerObjectDescriptionTemplateElasticQuery descriptionTemplateSubQuery;
public NestedDescriptionElasticQuery descriptionTemplateSubQuery(InnerObjectDescriptionTemplateElasticQuery subQuery) {
this.descriptionTemplateSubQuery = subQuery;
return this;
}
@Override
public NestedDescriptionElasticQuery nestedPath(String value) {
@ -61,8 +65,18 @@ public class NestedDescriptionElasticQuery extends ElasticNestedQuery<NestedDesc
@Override
protected Query applyFilters() {
List<Query> 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
public NestedDescriptionElasticEntity convert(Map<String, Object> rawData, Set<String> columns) {

View File

@ -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<NestedDescriptionTemplateElasticQuery, NestedDescriptionTemplateElasticEntity, UUID> {
private String nestedPath;
@ -62,6 +62,7 @@ public class NestedDescriptionTemplateElasticQuery extends ElasticNestedQuery<Ne
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.setId(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;
}
@ -70,6 +71,7 @@ public class NestedDescriptionTemplateElasticQuery extends ElasticNestedQuery<Ne
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;
}

View File

@ -1,11 +1,11 @@
package org.opencdmp.query.lookup;
import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.query.DescriptionQuery;
import org.opencdmp.query.DmpDescriptionTemplateQuery;
import gr.cite.tools.data.query.Lookup;
import gr.cite.tools.data.query.QueryFactory;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.elastic.query.InnerObjectDescriptionTemplateElasticQuery;
import org.opencdmp.elastic.query.NestedDescriptionElasticQuery;
import org.opencdmp.query.DmpDescriptionTemplateQuery;
import java.util.List;
import java.util.UUID;
@ -22,7 +22,7 @@ public class DmpDescriptionTemplateLookup extends Lookup {
private List<IsActive> isActive;
public List<UUID> getIds() {
return ids;
return this.ids;
}
public void setIds(List<UUID> ids) {
@ -30,7 +30,7 @@ public class DmpDescriptionTemplateLookup extends Lookup {
}
public List<UUID> getExcludedIds() {
return excludedIds;
return this.excludedIds;
}
public void setExcludedIds(List<UUID> excludedIds) {
@ -38,7 +38,7 @@ public class DmpDescriptionTemplateLookup extends Lookup {
}
public List<IsActive> getIsActive() {
return isActive;
return this.isActive;
}
public void setIsActive(List<IsActive> isActive) {
@ -46,7 +46,7 @@ public class DmpDescriptionTemplateLookup extends Lookup {
}
public List<UUID> getDmpIds() {
return dmpIds;
return this.dmpIds;
}
public void setDmpIds(List<UUID> dmpIds) {
@ -54,11 +54,11 @@ public class DmpDescriptionTemplateLookup extends Lookup {
}
public List<UUID> getDescriptionTemplateGroupIds() {
return descriptionTemplateGroupIds;
return this.descriptionTemplateGroupIds;
}
public List<UUID> getSectionIds() {
return sectionIds;
return this.sectionIds;
}
public void setSectionIds(List<UUID> 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;
}
}

View File

@ -151,7 +151,7 @@ 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.dmpDescriptionTemplateSubQuery != null) query.descriptionSubQuery(this.dmpDescriptionTemplateSubQuery.enrichElasticInner(queryFactory));
if (this.dmpUserSubQuery != null) query.dmpSubQuery(this.dmpUserSubQuery.enrichElasticInner(queryFactory));
this.enrichCommon(query);

View File

@ -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;
}

View File

@ -16,5 +16,4 @@
</mat-autocomplete>
<mat-error *ngIf="form.hasError('backendError')">{{ form.getError('backendError')?.message}}</mat-error>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>