use ilike

This commit is contained in:
Efstratios Giannopoulos 2024-04-05 12:43:33 +03:00
parent ff722b1d97
commit e61f06c192
18 changed files with 84 additions and 39 deletions

View File

@ -10,6 +10,7 @@ import eu.eudat.data.LockEntity;
import eu.eudat.data.TagEntity; import eu.eudat.data.TagEntity;
import eu.eudat.model.ActionConfirmation; import eu.eudat.model.ActionConfirmation;
import eu.eudat.model.Tag; import eu.eudat.model.Tag;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.data.query.QueryContext; import gr.cite.tools.data.query.QueryContext;
@ -46,7 +47,9 @@ public class ActionConfirmationQuery extends QueryBase<ActionConfirmationEntity>
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public ActionConfirmationQuery() { private final QueryUtilsService queryUtilsService;
public ActionConfirmationQuery(QueryUtilsService queryUtilsService) {
this.queryUtilsService = queryUtilsService;
} }
public ActionConfirmationQuery like(String value) { public ActionConfirmationQuery like(String value) {
@ -186,7 +189,7 @@ public class ActionConfirmationQuery extends QueryBase<ActionConfirmationEntity>
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) { protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(ActionConfirmationEntity._token), this.like)); predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ActionConfirmationEntity._token), this.like));
} }
if (this.ids != null) { if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ActionConfirmationEntity._id)); CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ActionConfirmationEntity._id));

View File

@ -242,8 +242,8 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.or( predicates.add(queryContext.CriteriaBuilder.or(
queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionEntity._description), this.like), queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._description), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionEntity._label), this.like) queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._label), this.like)
)); ));
} }
if (this.ids != null) { if (this.ids != null) {

View File

@ -274,8 +274,8 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
predicates.add(inClause); predicates.add(inClause);
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionTemplateEntity._label), this.like), predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionTemplateEntity._label), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionTemplateEntity._description), this.like) queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionTemplateEntity._description), this.like)
)); ));
} }
if (this.isActives != null) { if (this.isActives != null) {

View File

@ -8,6 +8,7 @@ import eu.eudat.data.DescriptionTemplateEntity;
import eu.eudat.data.DescriptionTemplateTypeEntity; import eu.eudat.data.DescriptionTemplateTypeEntity;
import eu.eudat.model.DescriptionTemplate; import eu.eudat.model.DescriptionTemplate;
import eu.eudat.model.DescriptionTemplateType; import eu.eudat.model.DescriptionTemplateType;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -108,8 +109,10 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
return this; return this;
} }
private final QueryUtilsService queryUtilsService;
public DescriptionTemplateTypeQuery( public DescriptionTemplateTypeQuery(
) { QueryUtilsService queryUtilsService) {
this.queryUtilsService = queryUtilsService;
} }
@Override @Override
@ -132,7 +135,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
predicates.add(inClause); predicates.add(inClause);
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionTemplateTypeEntity._name), this.like)); predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionTemplateTypeEntity._name), this.like));
} }
if (this.isActives != null) { if (this.isActives != null) {
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._isActive)); CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._isActive));

View File

@ -7,6 +7,7 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.model.DmpBlueprint; import eu.eudat.model.DmpBlueprint;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -158,10 +159,11 @@ public class DmpBlueprintQuery extends QueryBase<DmpBlueprintEntity> {
return this; return this;
} }
private final QueryUtilsService queryUtilsService;
public DmpBlueprintQuery( public DmpBlueprintQuery(
UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService
AuthorizationService authService
) { ) {
this.queryUtilsService = queryUtilsService;
} }
@Override @Override
@ -193,7 +195,7 @@ public class DmpBlueprintQuery extends QueryBase<DmpBlueprintEntity> {
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DmpBlueprintEntity._label), this.like)); predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpBlueprintEntity._label), this.like));
} }
if (this.isActives != null) { if (this.isActives != null) {

View File

@ -256,7 +256,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) { protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DmpEntity._label), this.like)); predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DmpEntity._label), this.like));
} }
if (this.ids != null) { if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)); CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id));

View File

@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.LanguageEntity; import eu.eudat.data.LanguageEntity;
import eu.eudat.model.Language; import eu.eudat.model.Language;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.data.query.QueryContext; import gr.cite.tools.data.query.QueryContext;
@ -103,8 +104,10 @@ public class LanguageQuery extends QueryBase<LanguageEntity> {
return this; return this;
} }
private final QueryUtilsService queryUtilsService;
public LanguageQuery( public LanguageQuery(
) { QueryUtilsService queryUtilsService) {
this.queryUtilsService = queryUtilsService;
} }
@Override @Override
@ -127,7 +130,7 @@ public class LanguageQuery extends QueryBase<LanguageEntity> {
predicates.add(inClause); predicates.add(inClause);
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(LanguageEntity._code), this.like)); predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(LanguageEntity._code), this.like));
} }
if (this.isActives != null) { if (this.isActives != null) {
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LanguageEntity._isActive)); CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LanguageEntity._isActive));

View File

@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.PrefillingSourceEntity; import eu.eudat.data.PrefillingSourceEntity;
import eu.eudat.model.PrefillingSource; import eu.eudat.model.PrefillingSource;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.data.query.QueryContext; import gr.cite.tools.data.query.QueryContext;
@ -87,8 +88,10 @@ public class PrefillingSourceQuery extends QueryBase<PrefillingSourceEntity> {
} }
private final QueryUtilsService queryUtilsService;
public PrefillingSourceQuery( public PrefillingSourceQuery(
) { QueryUtilsService queryUtilsService) {
this.queryUtilsService = queryUtilsService;
} }
@Override @Override
@ -111,7 +114,7 @@ public class PrefillingSourceQuery extends QueryBase<PrefillingSourceEntity> {
predicates.add(inClause); predicates.add(inClause);
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(PrefillingSourceEntity._label), this.like)); predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(PrefillingSourceEntity._label), this.like));
} }
if (this.isActives != null) { if (this.isActives != null) {
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PrefillingSourceEntity._isActive)); CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PrefillingSourceEntity._isActive));

View File

@ -236,9 +236,9 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
predicates.add(inClause); predicates.add(inClause);
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._label), this.like), predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._label), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._description), this.like), queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._description), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._source), this.like) queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._source), this.like)
)); ));
} }
if (this.isActives != null) { if (this.isActives != null) {

View File

@ -6,6 +6,7 @@ import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.ReferenceEntity; import eu.eudat.data.ReferenceEntity;
import eu.eudat.data.ReferenceTypeEntity; import eu.eudat.data.ReferenceTypeEntity;
import eu.eudat.model.ReferenceType; import eu.eudat.model.ReferenceType;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -107,8 +108,10 @@ public class ReferenceTypeQuery extends QueryBase<ReferenceTypeEntity> {
} }
private final QueryUtilsService queryUtilsService;
public ReferenceTypeQuery( public ReferenceTypeQuery(
) { QueryUtilsService queryUtilsService) {
this.queryUtilsService = queryUtilsService;
} }
@Override @Override
@ -131,8 +134,8 @@ public class ReferenceTypeQuery extends QueryBase<ReferenceTypeEntity> {
predicates.add(inClause); predicates.add(inClause);
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceTypeEntity._code), this.like), predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._code), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceTypeEntity._name), this.like) queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._name), this.like)
)); ));
} }
if (this.isActives != null) { if (this.isActives != null) {

View File

@ -6,6 +6,7 @@ import eu.eudat.commons.enums.StorageType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.StorageFileEntity; import eu.eudat.data.StorageFileEntity;
import eu.eudat.model.StorageFile; import eu.eudat.model.StorageFile;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -34,9 +35,11 @@ public class StorageFileQuery extends QueryBase<StorageFileEntity> {
private final UserScope userScope; private final UserScope userScope;
private final AuthorizationService authService; private final AuthorizationService authService;
public StorageFileQuery(UserScope userScope, AuthorizationService authService) { private final QueryUtilsService queryUtilsService;
public StorageFileQuery(UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService) {
this.userScope = userScope; this.userScope = userScope;
this.authService = authService; this.authService = authService;
this.queryUtilsService = queryUtilsService;
} }
public StorageFileQuery like(String value) { public StorageFileQuery like(String value) {
@ -146,7 +149,7 @@ public class StorageFileQuery extends QueryBase<StorageFileEntity> {
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) { protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add( queryContext.CriteriaBuilder.like(queryContext.Root.get(StorageFileEntity._name), this.like)); predicates.add( queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(StorageFileEntity._name), this.like));
} }
if (this.ids != null) { if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(StorageFileEntity._id)); CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(StorageFileEntity._id));

View File

@ -6,6 +6,7 @@ import eu.eudat.commons.enums.SupportiveMaterialFieldType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.SupportiveMaterialEntity; import eu.eudat.data.SupportiveMaterialEntity;
import eu.eudat.model.SupportiveMaterial; import eu.eudat.model.SupportiveMaterial;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -123,8 +124,10 @@ public class SupportiveMaterialQuery extends QueryBase<SupportiveMaterialEntity>
return this; return this;
} }
private final QueryUtilsService queryUtilsService;
public SupportiveMaterialQuery( public SupportiveMaterialQuery(
) { QueryUtilsService queryUtilsService) {
this.queryUtilsService = queryUtilsService;
} }
@Override @Override
@ -147,8 +150,8 @@ public class SupportiveMaterialQuery extends QueryBase<SupportiveMaterialEntity>
predicates.add(inClause); predicates.add(inClause);
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(SupportiveMaterialEntity._languageCode), this.like), predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._languageCode), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(SupportiveMaterialEntity._payload), this.like) queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._payload), this.like)
)); ));
} }
if (this.isActives != null) { if (this.isActives != null) {

View File

@ -204,7 +204,7 @@ public class TagQuery extends QueryBase<TagEntity> {
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) { protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(TagEntity._label), this.like)); predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TagEntity._label), this.like));
} }
if (this.ids != null) { if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id)); CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id));

View File

@ -6,12 +6,14 @@ import eu.eudat.commons.enums.IsActive;
import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.data.TenantEntity; import eu.eudat.data.TenantEntity;
import eu.eudat.model.Tenant; import eu.eudat.model.Tenant;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
import gr.cite.tools.data.query.QueryContext; import gr.cite.tools.data.query.QueryContext;
import jakarta.persistence.Tuple; import jakarta.persistence.Tuple;
import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -29,6 +31,13 @@ public class TenantQuery extends QueryBase<TenantEntity> {
private Collection<UUID> excludedIds; private Collection<UUID> excludedIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None); private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final QueryUtilsService queryUtilsService;
public TenantQuery(QueryUtilsService queryUtilsService) {
this.queryUtilsService = queryUtilsService;
}
public TenantQuery like(String value) { public TenantQuery like(String value) {
this.like = value; this.like = value;
return this; return this;
@ -104,8 +113,8 @@ public class TenantQuery extends QueryBase<TenantEntity> {
} }
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(TenantEntity._code), this.like), predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._code), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(TenantEntity._name), this.like) queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._name), this.like)
)); ));
} }

View File

@ -181,7 +181,7 @@ public class UserQuery extends QueryBase<UserEntity> {
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) { protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(UserEntity._name), this.like)); predicates.add(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserEntity._name), this.like));
} }
if (this.ids != null) { if (this.ids != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)); CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id));

View File

@ -6,6 +6,7 @@ import eu.eudat.commons.enums.UserSettingsType;
import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.data.UserSettingsEntity; import eu.eudat.data.UserSettingsEntity;
import eu.eudat.model.UserSettings; import eu.eudat.model.UserSettings;
import eu.eudat.query.utils.QueryUtilsService;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.FieldResolver;
import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryBase;
@ -35,13 +36,14 @@ public class UserSettingsQuery extends QueryBase<UserSettingsEntity> {
private final UserScope userScope; private final UserScope userScope;
private final AuthorizationService authService; private final AuthorizationService authService;
private final QueryUtilsService queryUtilsService;
public UserSettingsQuery( public UserSettingsQuery(
UserScope userScope, UserScope userScope,
AuthorizationService authService AuthorizationService authService, QueryUtilsService queryUtilsService
) { ) {
this.userScope = userScope; this.userScope = userScope;
this.authService = authService; this.authService = authService;
this.queryUtilsService = queryUtilsService;
} }
public UserSettingsQuery like(String like) { public UserSettingsQuery like(String like) {
@ -163,8 +165,8 @@ public class UserSettingsQuery extends QueryBase<UserSettingsEntity> {
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) { protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
if (this.like != null && !this.like.isEmpty()) { if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(UserSettingsEntity._key), this.like), predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._key), this.like),
queryContext.CriteriaBuilder.like(queryContext.Root.get(UserSettingsEntity._value), this.like) queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._value), this.like)
)); ));
} }
if (this.ids != null) { if (this.ids != null) {

View File

@ -1,8 +1,6 @@
package eu.eudat.query.utils; package eu.eudat.query.utils;
import jakarta.persistence.criteria.AbstractQuery; import jakarta.persistence.criteria.*;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Subquery;
import java.util.UUID; import java.util.UUID;
@ -20,4 +18,6 @@ public interface QueryUtilsService {
Subquery<UUID> buildDmpUserAuthZSubQuery(AbstractQuery<?> query, Subquery<UUID> buildDmpUserAuthZSubQuery(AbstractQuery<?> query,
CriteriaBuilder criteriaBuilder, CriteriaBuilder criteriaBuilder,
UUID userId); UUID userId);
Predicate ilike(CriteriaBuilder criteriaBuilder, Expression<String> path, String value);
} }

View File

@ -8,6 +8,7 @@ import eu.eudat.data.DescriptionEntity;
import eu.eudat.data.DmpEntity; import eu.eudat.data.DmpEntity;
import eu.eudat.data.DmpUserEntity; import eu.eudat.data.DmpUserEntity;
import jakarta.persistence.criteria.*; import jakarta.persistence.criteria.*;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -96,5 +97,15 @@ public class QueryUtilsServiceImpl implements QueryUtilsService {
) )
)); ));
} }
@Override
public Predicate ilike(CriteriaBuilder criteriaBuilder, Expression<String> path, String value){
if (criteriaBuilder instanceof HibernateCriteriaBuilder) {
return ((HibernateCriteriaBuilder) criteriaBuilder).ilike(path, value);
} else {
return criteriaBuilder.like(path, value);
}
}
} }