Example usage for javax.persistence.criteria CriteriaBuilder upper

List of usage examples for javax.persistence.criteria CriteriaBuilder upper

Introduction

In this page you can find the example usage for javax.persistence.criteria CriteriaBuilder upper.

Prototype

Expression<String> upper(Expression<String> x);

Source Link

Document

Create expression for converting a string to uppercase.

Usage

From source file:com.alliander.osgp.adapter.ws.infra.specifications.JpaDeviceSpecifications.java

@Override
public Specification<Device> hasAlias(final String alias) throws ArgumentNullOrEmptyException {
    if (StringUtils.isEmpty(alias)) {
        throw new ArgumentNullOrEmptyException("alias");
    }/*  www .  j a va2 s .  c  o m*/

    return new Specification<Device>() {
        @Override
        public Predicate toPredicate(final Root<Device> deviceRoot, final CriteriaQuery<?> query,
                final CriteriaBuilder cb) {

            return cb.like(cb.upper(deviceRoot.<String>get("alias")), alias.toUpperCase());
        }
    };
}

From source file:com.alliander.osgp.adapter.ws.infra.specifications.JpaDeviceSpecifications.java

@Override
public Specification<Device> forDeviceType(final String deviceType) throws ArgumentNullOrEmptyException {
    if (deviceType == null) {
        throw new ArgumentNullOrEmptyException("deviceType");
    }// ww w  .  ja v  a 2 s .c  o m

    return new Specification<Device>() {
        @Override
        public Predicate toPredicate(final Root<Device> deviceRoot, final CriteriaQuery<?> query,
                final CriteriaBuilder cb) {

            return cb.like(cb.upper(deviceRoot.<String>get("deviceType")), deviceType.toUpperCase());
        }
    };
}

From source file:com.alliander.osgp.adapter.ws.infra.specifications.JpaDeviceSpecifications.java

@Override
public Specification<Device> hasMunicipality(final String municipality) throws ArgumentNullOrEmptyException {
    if (StringUtils.isEmpty(municipality)) {
        throw new ArgumentNullOrEmptyException("municipality");
    }//from w  w  w  .  j av  a 2s  .  c o m

    return new Specification<Device>() {
        @Override
        public Predicate toPredicate(final Root<Device> deviceRoot, final CriteriaQuery<?> query,
                final CriteriaBuilder cb) {

            return cb.like(cb.upper(deviceRoot.<String>get("containerMunicipality")),
                    municipality.toUpperCase());
        }
    };
}

From source file:com.expressui.sample.view.contact.ContactQuery.java

@Override
public List<Predicate> buildCriteria(CriteriaBuilder builder, Root<Contact> rootEntity) {
    List<Predicate> criteria = new ArrayList<Predicate>();

    if (!isEmpty(lastName)) {
        ParameterExpression<String> p = builder.parameter(String.class, "lastName");
        criteria.add(builder.like(builder.upper(rootEntity.<String>get("lastName")), p));
    }/*from  w w w.  j av  a2 s  .co m*/
    if (!isEmpty(states)) {
        ParameterExpression<Set> p = builder.parameter(Set.class, "states");
        criteria.add(builder.in(rootEntity.get("mailingAddress").get("state")).value(p));
    }
    if (!isEmpty(country)) {
        ParameterExpression<Country> p = builder.parameter(Country.class, "country");
        criteria.add(builder.equal(rootEntity.get("mailingAddress").get("country"), p));
    }

    return criteria;
}

From source file:com.expressui.core.dao.security.query.RoleQuery.java

@Override
public List<Predicate> buildCriteria(CriteriaBuilder builder, CriteriaQuery<Role> query, Root<Role> role) {
    List<Predicate> predicates = new ArrayList<Predicate>();

    if (hasValue(name)) {
        ParameterExpression<String> nameExp = builder.parameter(String.class, "name");
        predicates.add(builder.like(builder.upper(role.<String>get("name")), nameExp));
    }//from  w w w. ja v a 2s  .  c  o m

    if (hasValue(doesNotBelongToUser)) {
        Subquery<Role> subquery = query.subquery(Role.class);
        Root<UserRole> userRole = subquery.from(UserRole.class);
        ParameterExpression<User> userExp = builder.parameter(User.class, "doesNotBelongToUser");
        subquery.select(userRole.<Role>get("role")).where(builder.equal(userRole.get("user"), userExp));
        predicates.add(builder.not(role.in(subquery)));
    }

    return predicates;
}

From source file:com.expressui.sample.dao.query.ProfileQuery.java

@Override
public List<Predicate> buildCriteria(CriteriaBuilder builder, CriteriaQuery<Profile> query,
        Root<Profile> profile) {//from w w w .j av  a2 s  .com
    List<Predicate> predicates = new ArrayList<Predicate>();

    if (hasValue(loginName)) {
        ParameterExpression<String> loginNameExp = builder.parameter(String.class, "loginName");
        predicates.add(
                builder.like(builder.upper(profile.<User>get("user").<String>get("loginName")), loginNameExp));
    }

    return predicates;
}

From source file:com.expressui.sample.dao.query.ContactQuery.java

@Override
public List<Predicate> buildCriteria(CriteriaBuilder builder, CriteriaQuery<Contact> query,
        Root<Contact> contact) {//from  w w  w .  j a  va2 s  . c  om
    List<Predicate> predicates = new ArrayList<Predicate>();

    if (hasValue(lastName)) {
        ParameterExpression<String> lastNameExp = builder.parameter(String.class, "lastName");
        predicates.add(builder.like(builder.upper(contact.<String>get("lastName")), lastNameExp));
    }
    if (hasValue(account)) {
        ParameterExpression<Account> accountExp = builder.parameter(Account.class, "account");
        predicates.add(builder.equal(contact.get("account"), accountExp));
    }

    return predicates;
}

From source file:com.expressui.sample.dao.query.AccountQuery.java

@Override
public List<Predicate> buildCriteria(CriteriaBuilder builder, CriteriaQuery<Account> query,
        Root<Account> account) {/*from   w  w  w  .  jav a 2 s  . co  m*/
    List<Predicate> predicates = new ArrayList<Predicate>();

    if (hasValue(name)) {
        ParameterExpression<String> nameExp = builder.parameter(String.class, "name");
        predicates.add(builder.like(builder.upper(account.<String>get("name")), nameExp));
    }
    if (hasValue(states)) {
        ParameterExpression<Set> statesExp = builder.parameter(Set.class, "states");
        predicates.add(builder.in(account.get("billingAddress").get("state")).value(statesExp));
    }
    if (hasValue(country)) {
        ParameterExpression<Country> countryExp = builder.parameter(Country.class, "country");
        predicates.add(builder.equal(account.get("billingAddress").get("country"), countryExp));
    }

    return predicates;
}

From source file:com.expressui.core.dao.security.query.UserQuery.java

@Override
public List<Predicate> buildCriteria(CriteriaBuilder builder, CriteriaQuery<User> query, Root<User> user) {
    List<Predicate> predicates = new ArrayList<Predicate>();

    if (hasValue(loginName)) {
        ParameterExpression<String> loginNameExp = builder.parameter(String.class, "loginName");
        predicates.add(builder.like(builder.upper(user.<String>get("loginName")), loginNameExp));
    }/* w w w. j  a v  a  2  s. c o  m*/

    if (hasValue(doesNotBelongToRole)) {
        Subquery<User> subquery = query.subquery(User.class);
        Root userRole = subquery.from(UserRole.class);
        ParameterExpression<Role> role = builder.parameter(Role.class, "doesNotBelongToRole");
        subquery.select(userRole.get("user")).where(builder.equal(userRole.get("role"), role));
        predicates.add(builder.not(user.in(subquery)));
    }

    return predicates;
}

From source file:com.alliander.osgp.adapter.ws.infra.specifications.JpaDeviceSpecifications.java

@Override
public Specification<Device> hasDeviceIdentification(final String deviceIdentification,
        final boolean exactMatch) throws ArgumentNullOrEmptyException {
    if (StringUtils.isEmpty(deviceIdentification)) {
        throw new ArgumentNullOrEmptyException("deviceIdentification");
    }/*from ww  w . ja v a  2s. co m*/

    return new Specification<Device>() {
        @Override
        public Predicate toPredicate(final Root<Device> deviceRoot, final CriteriaQuery<?> query,
                final CriteriaBuilder cb) {
            if (exactMatch) {
                return cb.equal(cb.upper(deviceRoot.<String>get("deviceIdentification")), deviceIdentification);
            } else {
                return cb.like(cb.upper(deviceRoot.<String>get("deviceIdentification")),
                        deviceIdentification.toUpperCase());
            }
        }
    };
}