use ilike
This commit is contained in:
parent
ff722b1d97
commit
e61f06c192
|
@ -10,6 +10,7 @@ import eu.eudat.data.LockEntity;
|
|||
import eu.eudat.data.TagEntity;
|
||||
import eu.eudat.model.ActionConfirmation;
|
||||
import eu.eudat.model.Tag;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
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);
|
||||
|
||||
public ActionConfirmationQuery() {
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
public ActionConfirmationQuery(QueryUtilsService queryUtilsService) {
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
public ActionConfirmationQuery like(String value) {
|
||||
|
@ -186,7 +189,7 @@ public class ActionConfirmationQuery extends QueryBase<ActionConfirmationEntity>
|
|||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
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) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ActionConfirmationEntity._id));
|
||||
|
|
|
@ -242,8 +242,8 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
|||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.or(
|
||||
queryContext.CriteriaBuilder.like(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._description), this.like),
|
||||
queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionEntity._label), this.like)
|
||||
));
|
||||
}
|
||||
if (this.ids != null) {
|
||||
|
|
|
@ -274,8 +274,8 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
|||
predicates.add(inClause);
|
||||
}
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionTemplateEntity._label), this.like),
|
||||
queryContext.CriteriaBuilder.like(queryContext.Root.get(DescriptionTemplateEntity._description), this.like)
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionTemplateEntity._label), this.like),
|
||||
queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(DescriptionTemplateEntity._description), this.like)
|
||||
));
|
||||
}
|
||||
if (this.isActives != null) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.data.DescriptionTemplateEntity;
|
|||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||
import eu.eudat.model.DescriptionTemplate;
|
||||
import eu.eudat.model.DescriptionTemplateType;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
|
@ -108,8 +109,10 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
|||
return this;
|
||||
}
|
||||
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
public DescriptionTemplateTypeQuery(
|
||||
) {
|
||||
QueryUtilsService queryUtilsService) {
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,7 +135,7 @@ public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateT
|
|||
predicates.add(inClause);
|
||||
}
|
||||
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) {
|
||||
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._isActive));
|
||||
|
|
|
@ -7,6 +7,7 @@ import eu.eudat.commons.enums.IsActive;
|
|||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.DmpBlueprintEntity;
|
||||
import eu.eudat.model.DmpBlueprint;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
|
@ -158,10 +159,11 @@ public class DmpBlueprintQuery extends QueryBase<DmpBlueprintEntity> {
|
|||
return this;
|
||||
}
|
||||
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
public DmpBlueprintQuery(
|
||||
UserScope userScope,
|
||||
AuthorizationService authService
|
||||
AuthorizationService authService, QueryUtilsService queryUtilsService
|
||||
) {
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -193,7 +195,7 @@ public class DmpBlueprintQuery extends QueryBase<DmpBlueprintEntity> {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -256,7 +256,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
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) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id));
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.LanguageEntity;
|
||||
import eu.eudat.model.Language;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
|
@ -103,8 +104,10 @@ public class LanguageQuery extends QueryBase<LanguageEntity> {
|
|||
return this;
|
||||
}
|
||||
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
public LanguageQuery(
|
||||
) {
|
||||
QueryUtilsService queryUtilsService) {
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,7 +130,7 @@ public class LanguageQuery extends QueryBase<LanguageEntity> {
|
|||
predicates.add(inClause);
|
||||
}
|
||||
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) {
|
||||
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(LanguageEntity._isActive));
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.authorization.AuthorizationFlags;
|
|||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.PrefillingSourceEntity;
|
||||
import eu.eudat.model.PrefillingSource;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
|
@ -87,8 +88,10 @@ public class PrefillingSourceQuery extends QueryBase<PrefillingSourceEntity> {
|
|||
}
|
||||
|
||||
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
public PrefillingSourceQuery(
|
||||
) {
|
||||
QueryUtilsService queryUtilsService) {
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,7 +114,7 @@ public class PrefillingSourceQuery extends QueryBase<PrefillingSourceEntity> {
|
|||
predicates.add(inClause);
|
||||
}
|
||||
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) {
|
||||
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(PrefillingSourceEntity._isActive));
|
||||
|
|
|
@ -236,9 +236,9 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
|||
predicates.add(inClause);
|
||||
}
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._label), this.like),
|
||||
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._description), this.like),
|
||||
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._source), this.like)
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._label), this.like),
|
||||
queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._description), this.like),
|
||||
queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceEntity._source), this.like)
|
||||
));
|
||||
}
|
||||
if (this.isActives != null) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.commons.scope.user.UserScope;
|
|||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
|
@ -107,8 +108,10 @@ public class ReferenceTypeQuery extends QueryBase<ReferenceTypeEntity> {
|
|||
}
|
||||
|
||||
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
public ReferenceTypeQuery(
|
||||
) {
|
||||
QueryUtilsService queryUtilsService) {
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,8 +134,8 @@ public class ReferenceTypeQuery extends QueryBase<ReferenceTypeEntity> {
|
|||
predicates.add(inClause);
|
||||
}
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceTypeEntity._code), this.like),
|
||||
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceTypeEntity._name), this.like)
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._code), this.like),
|
||||
queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(ReferenceTypeEntity._name), this.like)
|
||||
));
|
||||
}
|
||||
if (this.isActives != null) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.commons.enums.StorageType;
|
|||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.StorageFileEntity;
|
||||
import eu.eudat.model.StorageFile;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
|
@ -34,9 +35,11 @@ public class StorageFileQuery extends QueryBase<StorageFileEntity> {
|
|||
|
||||
private final UserScope userScope;
|
||||
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.authService = authService;
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
public StorageFileQuery like(String value) {
|
||||
|
@ -146,7 +149,7 @@ public class StorageFileQuery extends QueryBase<StorageFileEntity> {
|
|||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
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) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(StorageFileEntity._id));
|
||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.commons.enums.SupportiveMaterialFieldType;
|
|||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.SupportiveMaterialEntity;
|
||||
import eu.eudat.model.SupportiveMaterial;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
|
@ -123,8 +124,10 @@ public class SupportiveMaterialQuery extends QueryBase<SupportiveMaterialEntity>
|
|||
return this;
|
||||
}
|
||||
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
public SupportiveMaterialQuery(
|
||||
) {
|
||||
QueryUtilsService queryUtilsService) {
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -147,8 +150,8 @@ public class SupportiveMaterialQuery extends QueryBase<SupportiveMaterialEntity>
|
|||
predicates.add(inClause);
|
||||
}
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(SupportiveMaterialEntity._languageCode), this.like),
|
||||
queryContext.CriteriaBuilder.like(queryContext.Root.get(SupportiveMaterialEntity._payload), this.like)
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._languageCode), this.like),
|
||||
queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(SupportiveMaterialEntity._payload), this.like)
|
||||
));
|
||||
}
|
||||
if (this.isActives != null) {
|
||||
|
|
|
@ -204,7 +204,7 @@ public class TagQuery extends QueryBase<TagEntity> {
|
|||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
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) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(TagEntity._id));
|
||||
|
|
|
@ -6,12 +6,14 @@ import eu.eudat.commons.enums.IsActive;
|
|||
import eu.eudat.data.DmpBlueprintEntity;
|
||||
import eu.eudat.data.TenantEntity;
|
||||
import eu.eudat.model.Tenant;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -29,7 +31,14 @@ public class TenantQuery extends QueryBase<TenantEntity> {
|
|||
private Collection<UUID> excludedIds;
|
||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||
|
||||
public TenantQuery like(String value) {
|
||||
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
|
||||
public TenantQuery(QueryUtilsService queryUtilsService) {
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
public TenantQuery like(String value) {
|
||||
this.like = value;
|
||||
return this;
|
||||
}
|
||||
|
@ -104,8 +113,8 @@ public class TenantQuery extends QueryBase<TenantEntity> {
|
|||
}
|
||||
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(TenantEntity._code), this.like),
|
||||
queryContext.CriteriaBuilder.like(queryContext.Root.get(TenantEntity._name), this.like)
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._code), this.like),
|
||||
queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(TenantEntity._name), this.like)
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ public class UserQuery extends QueryBase<UserEntity> {
|
|||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
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) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id));
|
||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.commons.enums.UserSettingsType;
|
|||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.UserSettingsEntity;
|
||||
import eu.eudat.model.UserSettings;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
|
@ -35,13 +36,14 @@ public class UserSettingsQuery extends QueryBase<UserSettingsEntity> {
|
|||
|
||||
private final UserScope userScope;
|
||||
private final AuthorizationService authService;
|
||||
|
||||
private final QueryUtilsService queryUtilsService;
|
||||
public UserSettingsQuery(
|
||||
UserScope userScope,
|
||||
AuthorizationService authService
|
||||
AuthorizationService authService, QueryUtilsService queryUtilsService
|
||||
) {
|
||||
this.userScope = userScope;
|
||||
this.authService = authService;
|
||||
this.queryUtilsService = queryUtilsService;
|
||||
}
|
||||
|
||||
public UserSettingsQuery like(String like) {
|
||||
|
@ -163,8 +165,8 @@ public class UserSettingsQuery extends QueryBase<UserSettingsEntity> {
|
|||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (this.like != null && !this.like.isEmpty()) {
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(UserSettingsEntity._key), this.like),
|
||||
queryContext.CriteriaBuilder.like(queryContext.Root.get(UserSettingsEntity._value), this.like)
|
||||
predicates.add(queryContext.CriteriaBuilder.or(queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._key), this.like),
|
||||
queryUtilsService.ilike(queryContext.CriteriaBuilder, queryContext.Root.get(UserSettingsEntity._value), this.like)
|
||||
));
|
||||
}
|
||||
if (this.ids != null) {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package eu.eudat.query.utils;
|
||||
|
||||
import jakarta.persistence.criteria.AbstractQuery;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Subquery;
|
||||
import jakarta.persistence.criteria.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -20,4 +18,6 @@ public interface QueryUtilsService {
|
|||
Subquery<UUID> buildDmpUserAuthZSubQuery(AbstractQuery<?> query,
|
||||
CriteriaBuilder criteriaBuilder,
|
||||
UUID userId);
|
||||
|
||||
Predicate ilike(CriteriaBuilder criteriaBuilder, Expression<String> path, String value);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.data.DescriptionEntity;
|
|||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.data.DmpUserEntity;
|
||||
import jakarta.persistence.criteria.*;
|
||||
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue