Java Code Examples for com.querydsl.core.types.dsl.StringPath

The following examples show how to use com.querydsl.core.types.dsl.StringPath. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: springlets   Source File: QueryDslRepositorySupportExt.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Adds a global contains text filter on the provided attributes.
 * WARNING: this creates a very inefficient query. If you have many entity
 * instances to query, use instead an indexed text search solution for better
 * performance.
 * @param text the text to look for
 * @param query
 * @param globalSearchAttributes the list of attributes to perform the
 *        filter on
 * @return the updated query
 */
protected JPQLQuery<T> applyGlobalSearch(String text, JPQLQuery<T> query,
    Path<?>... globalSearchAttributes) {
  if (text != null && !StringUtils.isEmpty(text) && globalSearchAttributes.length > 0) {
    BooleanBuilder searchCondition = new BooleanBuilder();
    for (int i = 0; i < globalSearchAttributes.length; i++) {
      Path<?> path = globalSearchAttributes[i];
      if (path instanceof StringPath) {
        StringPath stringPath = (StringPath) path;
        searchCondition.or(stringPath.containsIgnoreCase(text));
      } else if (path instanceof NumberExpression) {
        searchCondition.or(((NumberExpression<?>) path).like("%".concat(text).concat("%")));
      }
    }
    return query.where(searchCondition);
  }
  return query;
}
 
Example 2
Source Project: SMSC   Source File: CustomerRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QCustomer root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::startsWithIgnoreCase);
    bindings.bind(Long.class).first((SingleValueBinding<NumberPath<Long>, Long>) NumberExpression::in);
}
 
Example 3
Source Project: SMSC   Source File: ContactRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QContact root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}
 
Example 4
Source Project: SMSC   Source File: UserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QUser root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
    bindings.excluding(root.password);
}
 
Example 5
Source Project: SMSC   Source File: GroupRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QGroup root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}
 
Example 6
Source Project: SMSC   Source File: RoleRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QRole root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}
 
Example 7
Source Project: SMSC   Source File: AuthorityRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QAuthority root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}
 
Example 8
Source Project: SMSC   Source File: UserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QUser root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
    bindings.excluding(root.password);
}
 
Example 9
Source Project: SMSC   Source File: DashboardBoxRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QDashboardBox root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}
 
Example 10
Source Project: SMSC   Source File: DashboardBoxTypeRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QDashboardBoxType root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}
 
Example 11
Source Project: SMSC   Source File: DashboardRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QDashboard root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}
 
Example 12
Source Project: spring-data-examples   Source File: UserRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
default public void customize(QuerydslBindings bindings, QUser root) {

	bindings.bind(String.class).first((StringPath path, String value) -> path.containsIgnoreCase(value));
	bindings.excluding(root.password);
}
 
Example 13
Source Project: tutorials   Source File: AddressRepository.java    License: MIT License 4 votes vote down vote up
@Override
default void customize(final QuerydslBindings bindings, final QAddress root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::eq);
}
 
Example 14
Source Project: tutorials   Source File: UserRepository.java    License: MIT License 4 votes vote down vote up
@Override
default void customize(final QuerydslBindings bindings, final QUser root) {
    bindings.bind(String.class).first((SingleValueBinding<StringPath, String>) StringExpression::eq);
}
 
Example 15
Source Project: tutorials   Source File: MyUserRepository.java    License: MIT License 4 votes vote down vote up
@Override
default public void customize(final QuerydslBindings bindings, final QMyUser root) {
    bindings.bind(String.class)
      .first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
    bindings.excluding(root.email);
}
 
Example 16
Source Project: spring-boot-jpa   Source File: PatientRepository.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Override default QueryDsl bindings.
 * TODO explain what and why?
 * This customizes QueryDsl to ignore case on queries involving String values
 *
 * @param bindings a QueryDslBindings to use
 * @param root     the QPatient root
 */
@Override
default void customize(QuerydslBindings bindings, QPatient root) {
    bindings.excluding(root.id);
    //bindings.excluding(root.patientId);
    bindings.bind(String.class)
            .first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}
 
Example 17
Source Project: spring-boot-jpa   Source File: MedicationRepository.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Override default QueryDsl bindings.
 * TODO explain what and why?
 *
 * @param bindings a QueryDslBindings to use
 * @param root     the QPatient root
 */
@Override
default void customize(QuerydslBindings bindings, QMedication root) {
	bindings.excluding(root.id);
	bindings.bind(String.class)
			.first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
}