use of com.querydsl.core.types.dsl.BooleanExpression in project Settler by EmhyrVarEmreis.
the class PermissionManagerImplementation method isAuthorized.
@Override
public boolean isAuthorized(PrivilegeObject source, PrivilegeObject target, OperationType operationType) {
BooleanExpression expression = jTBObjectHierarchy.objectFrom.id.eq(jTBObjectPrivilege.objectTo.id).and(jTBObjectHierarchy.objectTo.id.eq(target.getId()));
expression = expression.or(jTBObjectPrivilege.objectTo.id.eq(target.getId()));
expression = expression.or(jTBObjectPrivilege.objectTo.isNull());
return new JPAQuery<Void>(entityManager).select(Expressions.ONE).from(jTBObjectPrivilege, jTBObjectHierarchy).where(jTBObjectPrivilege.objectFrom.id.eq(source.getId()), (jTBObjectPrivilege.operationType.eq(operationType)), expression).fetchFirst() != null;
}
use of com.querydsl.core.types.dsl.BooleanExpression in project JavaForFun by gumartinm.
the class AdDescriptionServiceImpl method queryDslExample.
// Extending CrudServiceImpl when we need some business logic. Otherwise we would be using
// the JPA repositories and nothing else :)
// In this case there is any business logic, but this is just an example.
/**
* Using Querydsl. Giving some business logic to this service :)
*
* Querydsl: fluent interface done easy. There is no effort because it is already implemented.
*
* Criteria using Specifications requires some effort.
*
* See: de.spring.example.services.impl.AdServiceImpl
*/
@Override
public Page<AdDescription> queryDslExample(Pageable pageRequest) {
final QAdDescription adDescription = QAdDescription.adDescription1;
final BooleanExpression adDescriptionHasAdLink = adDescription.adLink.contains("gumartinm");
final BooleanExpression adDescriptionHasDescription = adDescription.adDescription.contains("babucha");
/**
* https://github.com/spring-projects/spring-data-envers/pull/45
* return repository.findAll(adDescriptionHasAdLink.and(adDescriptionHasDescription), pageRequest);
*/
return null;
}
use of com.querydsl.core.types.dsl.BooleanExpression in project tutorials by eugenp.
the class UserController method findAllByQuerydsl.
@RequestMapping(method = RequestMethod.GET, value = "/myusers")
@ResponseBody
public Iterable<MyUser> findAllByQuerydsl(@RequestParam(value = "search") String search) {
MyUserPredicatesBuilder builder = new MyUserPredicatesBuilder();
if (search != null) {
Pattern pattern = Pattern.compile("(\\w+?)(:|<|>)(\\w+?),");
Matcher matcher = pattern.matcher(search + ",");
while (matcher.find()) {
builder.with(matcher.group(1), matcher.group(2), matcher.group(3));
}
}
BooleanExpression exp = builder.build();
return myUserRepository.findAll(exp);
}
use of com.querydsl.core.types.dsl.BooleanExpression in project modesti by jlsalmon.
the class Predicate method getStringPredicate.
private BooleanExpression getStringPredicate(PathBuilder<T> entityPath, String argument) {
StringPath path = entityPath.getString(criteria.getKey());
BooleanExpression expression;
if (argument.startsWith("*") && argument.endsWith("*")) {
expression = path.containsIgnoreCase(argument.substring(1, argument.length() - 1));
} else if (argument.startsWith("*")) {
expression = path.endsWithIgnoreCase(argument.substring(1, argument.length()));
} else if (argument.endsWith("*")) {
expression = path.startsWithIgnoreCase(argument.substring(0, argument.length() - 1));
} else {
expression = path.equalsIgnoreCase(argument);
}
if (RSQLOperators.EQUAL.equals(criteria.getOperation())) {
return expression;
} else {
return expression.not();
}
}
use of com.querydsl.core.types.dsl.BooleanExpression in project querydsl by querydsl.
the class JPABase method subquery_uniqueResult.
@Test
// isn't a valid JPQL query
@Ignore
public void subquery_uniqueResult() {
QCat cat2 = new QCat("cat2");
BooleanExpression exists = selectOne().from(cat2).where(cat2.eyecolor.isNotNull()).exists();
assertNotNull(query().from(cat).where(cat.breed.eq(0).not()).select(new QCatSummary(cat.breed.count(), exists)).fetchOne());
}
Aggregations