From 0135f80e89c5f9b118d0ef4e8034145bf93f7f56 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Thu, 20 Jun 2024 14:17:58 +0300 Subject: [PATCH 1/2] elastic fixes --- .../data/DescriptionElasticEntity.java | 20 ++++++++++++---- .../elastic/data/DmpElasticEntity.java | 24 +++++++++++++++++++ .../DescriptionElasticBuilder.java | 1 + .../elasticbuilder/DmpElasticBuilder.java | 3 +++ .../query/DescriptionElasticQuery.java | 4 +++- .../elastic/query/DmpElasticQuery.java | 4 ++++ .../service/elastic/ElasticServiceImpl.java | 3 +++ 7 files changed, 54 insertions(+), 5 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 a5bcbf6eb..773166327 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 @@ -41,10 +41,6 @@ public class DescriptionElasticEntity { private Date finalizedAt; public final static String _finalizedAt = "finalizedAt"; - @Field(value = DescriptionElasticEntity._createdAt, type = FieldType.Date) - private Date createdAt; - public final static String _createdAt = "createdAt"; - @Field(value = DescriptionElasticEntity._tags, type = FieldType.Nested) private List tags; public final static String _tags = "tags"; @@ -61,6 +57,14 @@ public class DescriptionElasticEntity { private List references; public final static String _references = "references"; + @Field(value = DescriptionElasticEntity._updatedAt, type = FieldType.Date) + private Date updatedAt; + public final static String _updatedAt = "updatedAt"; + + @Field(value = DescriptionElasticEntity._createdAt, type = FieldType.Date) + private Date createdAt; + public final static String _createdAt = "createdAt"; + public UUID getId() { return this.id; } @@ -148,4 +152,12 @@ public class DescriptionElasticEntity { public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } + + public Date getUpdatedAt() { + return this.updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/data/DmpElasticEntity.java b/backend/core/src/main/java/org/opencdmp/elastic/data/DmpElasticEntity.java index 46fa1be9a..72c13cae1 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/data/DmpElasticEntity.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/data/DmpElasticEntity.java @@ -82,6 +82,14 @@ public class DmpElasticEntity { private List dois; public final static String _dois = "dois"; + @Field(value = DmpElasticEntity._updatedAt, type = FieldType.Date) + private Date updatedAt; + public final static String _updatedAt = "updatedAt"; + + @Field(value = DmpElasticEntity._createdAt, type = FieldType.Date) + private Date createdAt; + public final static String _createdAt = "createdAt"; + public UUID getId() { return this.id; } @@ -217,4 +225,20 @@ public class DmpElasticEntity { public void setDmpDescriptionTemplates(List dmpDescriptionTemplates) { this.dmpDescriptionTemplates = dmpDescriptionTemplates; } + + public Date getCreatedAt() { + return this.createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return this.updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } } diff --git a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java index cf09ccb5d..80528860f 100644 --- a/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/elastic/elasticbuilder/DescriptionElasticBuilder.java @@ -65,6 +65,7 @@ public class DescriptionElasticBuilder extends BaseElasticBuilder { if (columns.contains(DmpElasticEntity._groupId)) mocDoc.setGroupId(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._groupId), UUID.class)); if (columns.contains(DmpElasticEntity._accessType)) mocDoc.setAccessType(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._accessType), DmpAccessType.class)); if (columns.contains(DmpElasticEntity._finalizedAt)) mocDoc.setFinalizedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._finalizedAt), Date.class)); + if (columns.contains(DmpElasticEntity._createdAt)) mocDoc.setCreatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._createdAt), Date.class)); + if (columns.contains(DmpElasticEntity._updatedAt)) mocDoc.setUpdatedAt(FieldBasedMapper.shallowSafeConversion(rawData.get(DmpElasticEntity._updatedAt), Date.class)); mocDoc.setCollaborators(this.convertNested(rawData, columns, this.queryFactory.query(NestedCollaboratorElasticQuery.class), DmpElasticEntity._collaborators, null)); mocDoc.setReferences(this.convertNested(rawData, columns, this.queryFactory.query(NestedReferenceElasticQuery.class), DmpElasticEntity._references, null)); mocDoc.setDescriptions(this.convertNested(rawData, columns, this.queryFactory.query(NestedDescriptionElasticQuery.class), DmpElasticEntity._descriptions, null)); @@ -358,6 +360,8 @@ public class DmpElasticQuery extends ElasticQuery { else if (item.match(DmpElasticEntity._versionStatus)) return this.elasticFieldOf(DmpElasticEntity._versionStatus); else if (item.match(DmpElasticEntity._groupId)) return this.elasticFieldOf(DmpElasticEntity._groupId); else if (item.match(DmpElasticEntity._finalizedAt)) return this.elasticFieldOf(DmpElasticEntity._finalizedAt); + else if (item.match(DmpElasticEntity._updatedAt)) return this.elasticFieldOf(DmpElasticEntity._updatedAt); + else if (item.match(DmpElasticEntity._createdAt)) return this.elasticFieldOf(DmpElasticEntity._createdAt); else if (item.match(DmpElasticEntity._accessType)) return this.elasticFieldOf(DmpElasticEntity._accessType); else if (item.prefix(DmpElasticEntity._collaborators)) return this.queryFactory.query(NestedCollaboratorElasticQuery.class).nestedPath(DmpElasticEntity._collaborators).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._collaborators)); else if (item.prefix(DmpElasticEntity._references)) return this.queryFactory.query(NestedReferenceElasticQuery.class).nestedPath(DmpElasticEntity._references).fieldNameOf(this.extractPrefixed(item, DmpElasticEntity._references)); 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 7d0cf369f..73684f3ad 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 @@ -139,6 +139,7 @@ public class ElasticServiceImpl implements ElasticService { propertyMap.put(DescriptionElasticEntity._status, this.createElastic(FieldType.Short, false)); propertyMap.put(DescriptionElasticEntity._finalizedAt, this.createElastic(FieldType.Date, false)); propertyMap.put(DescriptionElasticEntity._createdAt, this.createElastic(FieldType.Date, false)); + propertyMap.put(DescriptionElasticEntity._updatedAt, this.createElastic(FieldType.Date, false)); propertyMap.put(DescriptionElasticEntity._tags, new Property.Builder().nested(x -> x.properties(this.createNestedTagsTemplatePropertyMap())).build()); propertyMap.put(DescriptionElasticEntity._references, new Property.Builder().nested(x -> x.properties(this.createNestedReferencesTemplatePropertyMap())).build()); @@ -160,6 +161,8 @@ public class ElasticServiceImpl implements ElasticService { propertyMap.put(DmpElasticEntity._accessType, this.createElastic(FieldType.Short, false)); propertyMap.put(DmpElasticEntity._groupId, this.createElastic(FieldType.Keyword, false)); propertyMap.put(DmpElasticEntity._finalizedAt, this.createElastic(FieldType.Date, false)); + propertyMap.put(DmpElasticEntity._updatedAt, this.createElastic(FieldType.Date, false)); + propertyMap.put(DmpElasticEntity._createdAt, this.createElastic(FieldType.Date, false)); propertyMap.put(DmpElasticEntity._versionStatus, this.createElastic(FieldType.Short, false)); propertyMap.put(DmpElasticEntity._descriptions, new Property.Builder().nested(x -> x.properties(this.createNestedDescriptionTemplatePropertyMap())).build()); From c890b8ec399af66a974242b3c90166f1e71d1fcb Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Thu, 20 Jun 2024 14:27:48 +0300 Subject: [PATCH 2/2] change to isblank like filters check --- .../main/java/org/opencdmp/query/ActionConfirmationQuery.java | 2 +- .../core/src/main/java/org/opencdmp/query/DescriptionQuery.java | 2 +- .../main/java/org/opencdmp/query/DescriptionTemplateQuery.java | 2 +- .../java/org/opencdmp/query/DescriptionTemplateTypeQuery.java | 2 +- .../src/main/java/org/opencdmp/query/DmpBlueprintQuery.java | 2 +- backend/core/src/main/java/org/opencdmp/query/DmpQuery.java | 2 +- .../core/src/main/java/org/opencdmp/query/LanguageQuery.java | 2 +- .../src/main/java/org/opencdmp/query/PrefillingSourceQuery.java | 2 +- .../core/src/main/java/org/opencdmp/query/ReferenceQuery.java | 2 +- .../src/main/java/org/opencdmp/query/ReferenceTypeQuery.java | 2 +- .../core/src/main/java/org/opencdmp/query/StorageFileQuery.java | 2 +- .../main/java/org/opencdmp/query/SupportiveMaterialQuery.java | 2 +- backend/core/src/main/java/org/opencdmp/query/TagQuery.java | 2 +- backend/core/src/main/java/org/opencdmp/query/TenantQuery.java | 2 +- backend/core/src/main/java/org/opencdmp/query/UserQuery.java | 2 +- .../src/main/java/org/opencdmp/query/UserSettingsQuery.java | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/query/ActionConfirmationQuery.java b/backend/core/src/main/java/org/opencdmp/query/ActionConfirmationQuery.java index 12cda1aa8..f7f06de8e 100644 --- a/backend/core/src/main/java/org/opencdmp/query/ActionConfirmationQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/ActionConfirmationQuery.java @@ -203,7 +203,7 @@ public class ActionConfirmationQuery extends QueryBase @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ActionConfirmationEntity._token), this.like)); } if (this.ids != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java index e69754815..731fb3018 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionQuery.java @@ -272,7 +272,7 @@ public class DescriptionQuery extends QueryBase { @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(queryContext.CriteriaBuilder.or( this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._description), this.like), this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._label), this.like) diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java index df790e8b5..b732aa76e 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionTemplateQuery.java @@ -310,7 +310,7 @@ public class DescriptionTemplateQuery extends QueryBase { predicates.add(notInClause.not()); } - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpBlueprintEntity._label), this.like)); } diff --git a/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java b/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java index 89024508d..959beb2bd 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DmpQuery.java @@ -302,7 +302,7 @@ public class DmpQuery extends QueryBase { @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpEntity._label), this.like)); } if (this.ids != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/LanguageQuery.java b/backend/core/src/main/java/org/opencdmp/query/LanguageQuery.java index c9b7ac9c2..dc28f7a8a 100644 --- a/backend/core/src/main/java/org/opencdmp/query/LanguageQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/LanguageQuery.java @@ -148,7 +148,7 @@ public class LanguageQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(LanguageEntity._code), this.like)); } if (this.isActives != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/PrefillingSourceQuery.java b/backend/core/src/main/java/org/opencdmp/query/PrefillingSourceQuery.java index 3d73e7449..1db07cd5f 100644 --- a/backend/core/src/main/java/org/opencdmp/query/PrefillingSourceQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PrefillingSourceQuery.java @@ -149,7 +149,7 @@ public class PrefillingSourceQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PrefillingSourceEntity._code), this.like), this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PrefillingSourceEntity._label), this.like) )); diff --git a/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java b/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java index 42be7a255..6589e6ca9 100644 --- a/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/ReferenceQuery.java @@ -269,7 +269,7 @@ public class ReferenceQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._label), this.like), this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._description), this.like), this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._reference), this.like) diff --git a/backend/core/src/main/java/org/opencdmp/query/ReferenceTypeQuery.java b/backend/core/src/main/java/org/opencdmp/query/ReferenceTypeQuery.java index 8500a37f0..7f23df2fd 100644 --- a/backend/core/src/main/java/org/opencdmp/query/ReferenceTypeQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/ReferenceTypeQuery.java @@ -150,7 +150,7 @@ public class ReferenceTypeQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._code), this.like), this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._name), this.like) )); diff --git a/backend/core/src/main/java/org/opencdmp/query/StorageFileQuery.java b/backend/core/src/main/java/org/opencdmp/query/StorageFileQuery.java index 44221b782..6419bca73 100644 --- a/backend/core/src/main/java/org/opencdmp/query/StorageFileQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/StorageFileQuery.java @@ -167,7 +167,7 @@ public class StorageFileQuery extends QueryBase { @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(StorageFileEntity._name), this.like)); } if (this.ids != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/SupportiveMaterialQuery.java b/backend/core/src/main/java/org/opencdmp/query/SupportiveMaterialQuery.java index 3f2b6dd4e..3b21565a9 100644 --- a/backend/core/src/main/java/org/opencdmp/query/SupportiveMaterialQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/SupportiveMaterialQuery.java @@ -166,7 +166,7 @@ public class SupportiveMaterialQuery extends QueryBase inClause.value(item); predicates.add(inClause); } - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._languageCode), this.like), this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._payload), this.like) )); diff --git a/backend/core/src/main/java/org/opencdmp/query/TagQuery.java b/backend/core/src/main/java/org/opencdmp/query/TagQuery.java index d519ff765..f0b591cd2 100644 --- a/backend/core/src/main/java/org/opencdmp/query/TagQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/TagQuery.java @@ -228,7 +228,7 @@ public class TagQuery extends QueryBase { @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TagEntity._label), this.like)); } if (this.ids != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/TenantQuery.java b/backend/core/src/main/java/org/opencdmp/query/TenantQuery.java index 47d539ad5..c28793d26 100644 --- a/backend/core/src/main/java/org/opencdmp/query/TenantQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/TenantQuery.java @@ -151,7 +151,7 @@ public class TenantQuery extends QueryBase { predicates.add(inClause); } - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._code), this.like), this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._name), this.like) )); diff --git a/backend/core/src/main/java/org/opencdmp/query/UserQuery.java b/backend/core/src/main/java/org/opencdmp/query/UserQuery.java index 70ce987a9..a6d5fe73d 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserQuery.java @@ -196,7 +196,7 @@ public class UserQuery extends QueryBase { @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserEntity._name), this.like)); } if (this.ids != null) { diff --git a/backend/core/src/main/java/org/opencdmp/query/UserSettingsQuery.java b/backend/core/src/main/java/org/opencdmp/query/UserSettingsQuery.java index 4f7875228..48fb51427 100644 --- a/backend/core/src/main/java/org/opencdmp/query/UserSettingsQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/UserSettingsQuery.java @@ -183,7 +183,7 @@ public class UserSettingsQuery extends QueryBase { @Override protected Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); - if (this.like != null && !this.like.isEmpty()) { + if (this.like != null && !this.like.isBlank()) { predicates.add(queryContext.CriteriaBuilder.or(this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._key), this.like), this.queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._value), this.like) ));