Search in sources :

Example 6 with Group

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

the class CreateUserAndMembershipTestDelegate method execute.

@Override
public void execute(DelegateExecution execution) throws Exception {
    IdentityService identityService = execution.getEngineServices().getIdentityService();
    String username = "Kermit";
    User user = identityService.newUser(username);
    user.setPassword("123");
    user.setFirstName("Manually");
    user.setLastName("created");
    identityService.saveUser(user);
    // Add admin group
    Group group = identityService.newGroup("admin");
    identityService.saveGroup(group);
    identityService.createMembership(username, "admin");
}
Also used : IdentityService(org.activiti.engine.IdentityService) Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User)

Example 7 with Group

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

the class TaskTable method addTaskRow.

protected Object addTaskRow(Object previousTaskItemId, String taskName, String taskAssignee, String taskGroups, String taskDescription, Boolean startWithPrevious) {
    Object newItemId = null;
    if (previousTaskItemId == null) {
        // add at the end of list
        newItemId = addItem();
    } else {
        newItemId = addItemAfter(previousTaskItemId);
    }
    Item newItem = getItem(newItemId);
    // name
    newItem.getItemProperty(ID_NAME).setValue(taskName == null ? "my task" : taskName);
    // assignee
    ComboBox assigneeComboBox = new ComboBox();
    assigneeComboBox.setNullSelectionAllowed(true);
    try {
        for (User user : ProcessEngines.getDefaultProcessEngine().getIdentityService().createUserQuery().orderByUserFirstName().asc().list()) {
            assigneeComboBox.addItem(user.getId());
            assigneeComboBox.setItemCaption(user.getId(), user.getFirstName() + " " + user.getLastName());
        }
    } catch (Exception e) {
    // Don't do anything. Will be an empty dropdown.
    }
    if (taskAssignee != null) {
        assigneeComboBox.select(taskAssignee);
    }
    newItem.getItemProperty(ID_ASSIGNEE).setValue(assigneeComboBox);
    // groups
    ComboBox groupComboBox = new ComboBox();
    groupComboBox.setNullSelectionAllowed(true);
    try {
        for (Group group : ProcessEngines.getDefaultProcessEngine().getIdentityService().createGroupQuery().orderByGroupName().asc().list()) {
            groupComboBox.addItem(group.getId());
            groupComboBox.setItemCaption(group.getId(), group.getName());
        }
    } catch (Exception e) {
    // Don't do anything. Will be an empty dropdown.
    }
    if (taskGroups != null) {
        groupComboBox.select(taskGroups);
    }
    newItem.getItemProperty(ID_GROUPS).setValue(groupComboBox);
    // description
    TextField descriptionTextField = new TextField();
    descriptionTextField.setColumns(16);
    descriptionTextField.setRows(1);
    if (taskDescription != null) {
        descriptionTextField.setValue(taskDescription);
    }
    newItem.getItemProperty(ID_DESCRIPTION).setValue(descriptionTextField);
    // concurrency
    CheckBox startWithPreviousCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_EDITOR_TASK_START_WITH_PREVIOUS));
    startWithPreviousCheckBox.setValue(startWithPrevious == null ? false : startWithPrevious);
    newItem.getItemProperty(ID_START_WITH_PREVIOUS).setValue(startWithPreviousCheckBox);
    // actions
    newItem.getItemProperty(ID_ACTIONS).setValue(generateActionButtons(newItemId));
    return newItemId;
}
Also used : Item(com.vaadin.data.Item) Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User) ComboBox(com.vaadin.ui.ComboBox) CheckBox(com.vaadin.ui.CheckBox) TextField(com.vaadin.ui.TextField)

Example 8 with Group

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

the class DemoDataConfiguration method createGroup.

protected void createGroup(String groupId, String type) {
    if (identityService.createGroupQuery().groupId(groupId).count() == 0) {
        Group newGroup = identityService.newGroup(groupId);
        newGroup.setName(groupId.substring(0, 1).toUpperCase() + groupId.substring(1));
        newGroup.setType(type);
        identityService.saveGroup(newGroup);
    }
}
Also used : Group(org.activiti.engine.identity.Group)

Example 9 with Group

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

the class DemoDataGenerator method createGroup.

protected void createGroup(String groupId, String type) {
    if (identityService.createGroupQuery().groupId(groupId).count() == 0) {
        Group newGroup = identityService.newGroup(groupId);
        newGroup.setName(groupId.substring(0, 1).toUpperCase() + groupId.substring(1));
        newGroup.setType(type);
        identityService.saveGroup(newGroup);
    }
}
Also used : Group(org.activiti.engine.identity.Group)

Example 10 with Group

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

the class TaskNavigator method getGroupIds.

protected List<String> getGroupIds(String userId) {
    List<String> groupIds = new ArrayList<String>();
    List<Group> groups = identityService.createGroupQuery().groupMember(userId).list();
    for (Group group : groups) {
        groupIds.add(group.getId());
    }
    return groupIds;
}
Also used : Group(org.activiti.engine.identity.Group) ArrayList(java.util.ArrayList)

Aggregations

Group (org.activiti.engine.identity.Group)61 User (org.activiti.engine.identity.User)22 ArrayList (java.util.ArrayList)12 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 StringEntity (org.apache.http.entity.StringEntity)5 Item (com.vaadin.data.Item)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 PropertysetItem (com.vaadin.data.util.PropertysetItem)3 Deployment (org.activiti.engine.test.Deployment)3 HttpDelete (org.apache.http.client.methods.HttpDelete)3 HttpPut (org.apache.http.client.methods.HttpPut)3 HashSet (java.util.HashSet)2 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)2 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)2 IdentityService (org.activiti.engine.IdentityService)2 GroupQuery (org.activiti.engine.identity.GroupQuery)2 LoggedInUser (org.activiti.explorer.identity.LoggedInUser)2 ActivitiConflictException (org.activiti.rest.exception.ActivitiConflictException)2