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());
}
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());
}
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());
}
}
}
}
}
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));
}
}
}
Aggregations