Search in sources :

Example 6 with UserQuery

use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.

the class UserQueryTest method testQueryByInvalidLastName.

public void testQueryByInvalidLastName() {
    UserQuery query = identityService.createUserQuery().userLastName("invalid");
    verifyQueryResults(query, 0);
    try {
        identityService.createUserQuery().userLastName(null).singleResult();
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) UserQuery(org.activiti.engine.identity.UserQuery)

Example 7 with UserQuery

use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.

the class UserQueryTest method testQuerySorting.

public void testQuerySorting() {
    // asc
    assertEquals(3, identityService.createUserQuery().orderByUserId().asc().count());
    assertEquals(3, identityService.createUserQuery().orderByUserEmail().asc().count());
    assertEquals(3, identityService.createUserQuery().orderByUserFirstName().asc().count());
    assertEquals(3, identityService.createUserQuery().orderByUserLastName().asc().count());
    // desc
    assertEquals(3, identityService.createUserQuery().orderByUserId().desc().count());
    assertEquals(3, identityService.createUserQuery().orderByUserEmail().desc().count());
    assertEquals(3, identityService.createUserQuery().orderByUserFirstName().desc().count());
    assertEquals(3, identityService.createUserQuery().orderByUserLastName().desc().count());
    // Combined with criteria
    UserQuery query = identityService.createUserQuery().userLastNameLike("%ea%").orderByUserFirstName().asc();
    List<User> users = query.list();
    assertEquals(2, users.size());
    assertEquals("Fozzie", users.get(0).getFirstName());
    assertEquals("Gonzo", users.get(1).getFirstName());
}
Also used : User(org.activiti.engine.identity.User) UserQuery(org.activiti.engine.identity.UserQuery)

Example 8 with UserQuery

use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.

the class UserQueryTest method testQueryByFullNameLike.

public void testQueryByFullNameLike() {
    UserQuery query = identityService.createUserQuery().userFullNameLike("%erm%");
    verifyQueryResults(query, 1);
    query = identityService.createUserQuery().userFullNameLike("%ea%");
    verifyQueryResults(query, 2);
    query = identityService.createUserQuery().userFullNameLike("%e%");
    verifyQueryResults(query, 3);
}
Also used : UserQuery(org.activiti.engine.identity.UserQuery)

Example 9 with UserQuery

use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.

the class GroupMembersQuery method loadItems.

public List<Item> loadItems(int start, int count) {
    UserQuery query = identityService.createUserQuery().memberOfGroup(groupId);
    if (sortby == null || "id".equals(sortby)) {
        // default
        query.orderByUserId();
    } else if ("firstName".equals(sortby)) {
        query.orderByUserFirstName();
    } else if ("lastName".equals(sortby)) {
        query.orderByUserLastName();
    } else if ("email".equals(sortby)) {
        query.orderByUserEmail();
    }
    if (sortby == null || ascending) {
        query.asc();
    } else {
        query.desc();
    }
    List<User> users = query.listPage(start, count);
    List<Item> items = new ArrayList<Item>();
    for (User user : users) {
        items.add(new GroupMemberItem(user));
    }
    return items;
}
Also used : PropertysetItem(com.vaadin.data.util.PropertysetItem) Item(com.vaadin.data.Item) User(org.activiti.engine.identity.User) UserQuery(org.activiti.engine.identity.UserQuery) ArrayList(java.util.ArrayList)

Example 10 with UserQuery

use of org.activiti.engine.identity.UserQuery in project Activiti by Activiti.

the class UserQueryEscapeClauseTest method testQueryByLastNameLike.

public void testQueryByLastNameLike() {
    UserQuery query = identityService.createUserQuery().userLastNameLike("%\\%%");
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
    assertEquals("kermit", query.singleResult().getId());
    query = identityService.createUserQuery().userLastNameLike("%\\_%");
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
    assertEquals("fozzie", query.singleResult().getId());
}
Also used : UserQuery(org.activiti.engine.identity.UserQuery)

Aggregations

UserQuery (org.activiti.engine.identity.UserQuery)24 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)8 User (org.activiti.engine.identity.User)5 Item (com.vaadin.data.Item)1 PropertysetItem (com.vaadin.data.util.PropertysetItem)1 ArrayList (java.util.ArrayList)1