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

The following examples show how to use com.querydsl.core.types.dsl.StringExpression. 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 File: UserDAO.java    From SuperBoot with 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 File: MyUserRepository.java    From tutorials with 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 #3
Source File: QuerydslQueryBackend.java    From crnk-framework with 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 #4
Source File: UserRepository.java    From tutorials with 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 #5
Source File: AddressRepository.java    From tutorials with 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 #6
Source File: DashboardRepository.java    From SMSC with 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 #7
Source File: DashboardBoxTypeRepository.java    From SMSC with 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 #8
Source File: DashboardBoxRepository.java    From SMSC with 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 #9
Source File: UserRepository.java    From SMSC with 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 #10
Source File: AuthorityRepository.java    From SMSC with 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 File: RoleRepository.java    From SMSC with 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 #12
Source File: GroupRepository.java    From SMSC with 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 #13
Source File: UserRepository.java    From SMSC with 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 #14
Source File: ContactRepository.java    From SMSC with 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 #15
Source File: CustomerRepository.java    From SMSC with 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 #16
Source File: QuerydslQueryBackend.java    From katharsis-framework with 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 #17
Source File: RoleDAO.java    From SuperBoot with 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 #18
Source File: MedicationRepository.java    From spring-boot-jpa with 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 #19
Source File: PatientRepository.java    From spring-boot-jpa with 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 #20
Source File: DutiesDAO.java    From SuperBoot with 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);
}
 
Example #21
Source File: EmployeesDAO.java    From SuperBoot with 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 #22
Source File: OrgDAO.java    From SuperBoot with 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 File: MenuDAO.java    From SuperBoot with 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 #24
Source File: GroupDAO.java    From SuperBoot with 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);
}