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

The following examples show how to use com.querydsl.core.types.dsl.StringExpression. 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: SuperBoot   Source File: UserDAO.java    License: MIT License 5 votes vote down vote up
/**
 * 增加对查询条件的模糊搜索支持
 *
 * @param bindings
 * @param user
 */
@Override
default void customize(QuerydslBindings bindings, QSuperbootUser user) {
    bindings.bind(user.userCode).first(StringExpression::containsIgnoreCase);
    bindings.bind(user.userEmail).first(StringExpression::containsIgnoreCase);
    bindings.bind(user.userPhone).first(StringExpression::containsIgnoreCase);
}
 
Example 2
Source Project: crnk-framework   Source File: QuerydslQueryBackend.java    License: Apache License 2.0 4 votes vote down vote up
private Predicate handle(Expression expression, FilterOperator operator, Object value) { // NOSONAR
	// checking multiple comparision implementations is a mess, created
	// https://github.com/querydsl/querydsl/issues/2028
	if (operator == FilterOperator.EQ || operator == FilterOperator.NEQ) {
		return handleEquals(expression, operator, value);
	}

	if (value instanceof Collection) {
		// map collection to OR statement (expect for EQUALS where a IN is used)
		List<Predicate> predicates = new ArrayList();
		for (Object element : (Collection) value) {
			predicates.add(handle(expression, operator, element));
		}
		return or(predicates);
	}

	if (operator == FilterOperator.LIKE) {
		return ((StringExpression) expression).lower().like(value.toString().toLowerCase());
	}
	else if (operator == FilterOperator.GT) {
		if (expression instanceof FetchableSubQueryBase) {
			return ((FetchableSubQueryBase) expression).gt(value);
		}
		else if (expression instanceof NumberExpression) {
			return ((NumberExpression) expression).gt((Number) value);
		}
		else {
			return ((ComparableExpression) expression).gt((Comparable) value);
		}
	}
	else if (operator == FilterOperator.LT) {
		if (expression instanceof FetchableSubQueryBase) {
			return ((FetchableSubQueryBase) expression).lt(value);
		}
		else if (expression instanceof NumberExpression) {
			return ((NumberExpression) expression).lt((Number) value);
		}
		else {
			return ((ComparableExpression) expression).lt((Comparable) value);
		}
	}
	else if (operator == FilterOperator.GE) {
		if (expression instanceof FetchableSubQueryBase) {
			return ((FetchableSubQueryBase) expression).goe(value);
		}
		else if (expression instanceof NumberExpression) {
			return ((NumberExpression) expression).goe((Number) value);
		}
		else {
			return ((ComparableExpression) expression).goe((Comparable) value);
		}
	}
	else if (operator == FilterOperator.LE) {
		if (expression instanceof FetchableSubQueryBase) {
			return ((FetchableSubQueryBase) expression).loe(value);
		}
		else if (expression instanceof NumberExpression) {
			return ((NumberExpression) expression).loe((Number) value);
		}
		else {
			return ((ComparableExpression) expression).loe((Comparable) value);
		}
	}
	else {
		throw new IllegalStateException("unexpected operator " + operator);
	}

}
 
Example 3
Source Project: SuperBoot   Source File: RoleDAO.java    License: MIT License 4 votes vote down vote up
/**
 * 增加对查询条件的模糊搜索支持
 * @param bindings
 * @param role
 */
@Override
default void customize(QuerydslBindings bindings, QSuperbootRole role) {
    bindings.bind(role.roleCode).first(StringExpression::containsIgnoreCase);
    bindings.bind(role.roleName).first(StringExpression::containsIgnoreCase);
}
 
Example 4
Source Project: katharsis-framework   Source File: QuerydslQueryBackend.java    License: Apache License 2.0 4 votes vote down vote up
private Predicate handle(Expression expression, FilterOperator operator, Object value) { // NOSONAR
	// checking multiple comparision implementations is a mess, created
	// https://github.com/querydsl/querydsl/issues/2028
	if (operator == FilterOperator.EQ || operator == FilterOperator.NEQ) {
		return handleEquals(expression, operator, value);
	}
	else if (operator == FilterOperator.LIKE) {
		return ((StringExpression) expression).lower().like(value.toString().toLowerCase());
	}
	else if (operator == FilterOperator.GT) {
		if (expression instanceof FetchableSubQueryBase) {
			return ((FetchableSubQueryBase) expression).gt((Number) value);
		}
		else if (expression instanceof NumberExpression) {
			return ((NumberExpression) expression).gt((Number) value);
		}
		else {
			return ((ComparableExpression) expression).gt((Comparable) value);
		}
	}
	else if (operator == FilterOperator.LT) {
		if (expression instanceof FetchableSubQueryBase) {
			return ((FetchableSubQueryBase) expression).lt((Number) value);
		}
		else if (expression instanceof NumberExpression) {
			return ((NumberExpression) expression).lt((Number) value);
		}
		else {
			return ((ComparableExpression) expression).lt((Comparable) value);
		}
	}
	else if (operator == FilterOperator.GE) {
		if (expression instanceof FetchableSubQueryBase) {
			return ((FetchableSubQueryBase) expression).goe((Number) value);
		}
		else if (expression instanceof NumberExpression) {
			return ((NumberExpression) expression).goe((Number) value);
		}
		else {
			return ((ComparableExpression) expression).goe((Comparable) value);
		}
	}
	else if (operator == FilterOperator.LE) {
		if (expression instanceof FetchableSubQueryBase) {
			return ((FetchableSubQueryBase) expression).loe((Number) value);
		}
		else if (expression instanceof NumberExpression) {
			return ((NumberExpression) expression).loe((Number) value);
		}
		else {
			return ((ComparableExpression) expression).loe((Comparable) value);
		}
	}
	else {
		throw new IllegalStateException("unexpected operator " + operator);
	}

}
 
Example 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 14
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 15
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 16
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 17
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 18
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 19
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);
}
 
Example 20
Source Project: SuperBoot   Source File: GroupDAO.java    License: MIT License 2 votes vote down vote up
/**
 * 增加对查询条件的模糊搜索支持
 *
 * @param bindings
 * @param group
 */
@Override
default void customize(QuerydslBindings bindings, QSuperbootGroup group) {
    bindings.bind(group.groupCode).first(StringExpression::containsIgnoreCase);
    bindings.bind(group.groupName).first(StringExpression::containsIgnoreCase);
}
 
Example 21
Source Project: SuperBoot   Source File: MenuDAO.java    License: MIT License 2 votes vote down vote up
/**
 * 增加对查询条件的模糊搜索支持
 *
 * @param bindings
 * @param menu
 */
@Override
default void customize(QuerydslBindings bindings, QSuperbootMenu menu) {
    bindings.bind(menu.menuCode).first(StringExpression::containsIgnoreCase);
    bindings.bind(menu.menuName).first(StringExpression::containsIgnoreCase);
}
 
Example 22
Source Project: SuperBoot   Source File: OrgDAO.java    License: MIT License 2 votes vote down vote up
/**
 * 增加对查询条件的模糊搜索支持
 *
 * @param bindings
 * @param org
 */
@Override
default void customize(QuerydslBindings bindings, QSuperbootOrg org) {
    bindings.bind(org.orgName).first(StringExpression::containsIgnoreCase);
}
 
Example 23
Source Project: SuperBoot   Source File: EmployeesDAO.java    License: MIT License 2 votes vote down vote up
/**
 * 增加对查询条件的模糊搜索支持
 *
 * @param bindings
 * @param emp
 */
@Override
default void customize(QuerydslBindings bindings, QSuperbootEmployees emp) {
    bindings.bind(emp.employeesCode).first(StringExpression::containsIgnoreCase);
    bindings.bind(emp.employeesName).first(StringExpression::containsIgnoreCase);
}
 
Example 24
Source Project: SuperBoot   Source File: DutiesDAO.java    License: MIT License 2 votes vote down vote up
/**
 * 增加对查询条件的模糊搜索支持
 *
 * @param bindings
 * @param duties
 */
@Override
default void customize(QuerydslBindings bindings, QSuperbootDuties duties) {
    bindings.bind(duties.dutiesCode).first(StringExpression::containsIgnoreCase);
    bindings.bind(duties.dutiesName).first(StringExpression::containsIgnoreCase);
}