Search in sources :

Example 91 with User

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

the class TaskServiceTest method testUnClaimTask.

public void testUnClaimTask() {
    Task task = taskService.newTask();
    taskService.saveTask(task);
    User user = identityService.newUser("user");
    identityService.saveUser(user);
    // Claim task the first time
    taskService.claim(task.getId(), user.getId());
    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    assertEquals(user.getId(), task.getAssignee());
    // Unclaim the task
    taskService.unclaim(task.getId());
    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    assertNull(task.getAssignee());
    taskService.deleteTask(task.getId(), true);
    identityService.deleteUser(user.getId());
}
Also used : Task(org.activiti.engine.task.Task) User(org.activiti.engine.identity.User)

Example 92 with User

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

the class TaskServiceTest method testClaimAlreadyClaimedTaskBySameUser.

public void testClaimAlreadyClaimedTaskBySameUser() {
    Task task = taskService.newTask();
    taskService.saveTask(task);
    User user = identityService.newUser("user");
    identityService.saveUser(user);
    // Claim task the first time
    taskService.claim(task.getId(), user.getId());
    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    // Claim the task again with the same user. No exception should be thrown
    taskService.claim(task.getId(), user.getId());
    taskService.deleteTask(task.getId(), true);
    identityService.deleteUser(user.getId());
}
Also used : Task(org.activiti.engine.task.Task) User(org.activiti.engine.identity.User)

Example 93 with User

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

the class SelectUsersPopupWindow method searchPeople.

protected void searchPeople(String searchText) {
    if (searchText.length() >= 2) {
        matchingUsersTable.removeAllItems();
        List<User> results = ProcessEngines.getDefaultProcessEngine().getIdentityService().createUserQuery().userFullNameLike("%" + searchText + "%").list();
        for (User user : results) {
            if (!multiSelect || !selectedUsersTable.containsId(user.getId())) {
                if (ignoredUserIds == null || !ignoredUserIds.contains(user.getId())) {
                    addMatchingUser(user.getId(), user.getFirstName() + " " + user.getLastName());
                }
            }
        }
    }
}
Also used : User(org.activiti.engine.identity.User) LoggedInUser(org.activiti.explorer.identity.LoggedInUser)

Example 94 with User

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

the class DemoDataGenerator method createUser.

protected void createUser(String userId, String firstName, String lastName, String password, String email, String imageResource, List<String> groups, List<String> userInfo) {
    if (identityService.createUserQuery().userId(userId).count() == 0) {
        // Following data can already be set by demo setup script
        User user = identityService.newUser(userId);
        user.setFirstName(firstName);
        user.setLastName(lastName);
        user.setPassword(password);
        user.setEmail(email);
        identityService.saveUser(user);
        if (groups != null) {
            for (String group : groups) {
                identityService.createMembership(userId, group);
            }
        }
    }
    // image
    if (imageResource != null) {
        byte[] pictureBytes = IoUtil.readInputStream(this.getClass().getClassLoader().getResourceAsStream(imageResource), null);
        Picture picture = new Picture(pictureBytes, "image/jpeg");
        identityService.setUserPicture(userId, picture);
    }
    // user info
    if (userInfo != null) {
        for (int i = 0; i < userInfo.size(); i += 2) {
            identityService.setUserInfo(userId, userInfo.get(i), userInfo.get(i + 1));
        }
    }
}
Also used : User(org.activiti.engine.identity.User) Picture(org.activiti.engine.identity.Picture)

Aggregations

User (org.activiti.engine.identity.User)94 Group (org.activiti.engine.identity.Group)22 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 Task (org.activiti.engine.task.Task)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)9 Picture (org.activiti.engine.identity.Picture)9 StringEntity (org.apache.http.entity.StringEntity)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ArrayList (java.util.ArrayList)7 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)7 HttpPut (org.apache.http.client.methods.HttpPut)7 HttpGet (org.apache.http.client.methods.HttpGet)6 UserQuery (org.activiti.engine.identity.UserQuery)5 HttpDelete (org.apache.http.client.methods.HttpDelete)5 HttpPost (org.apache.http.client.methods.HttpPost)4 Item (com.vaadin.data.Item)3 ActivitiException (org.activiti.engine.ActivitiException)3 IdentityService (org.activiti.engine.IdentityService)3