Search in sources :

Example 21 with UserInfo

use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.

the class ExecuteReminderCommand method executedeadLine.

private Void executedeadLine(TaskContext ctx, TaskPersistenceContext persistenceContext, Task task, DeadlineSummary deadlineSummary, TaskData taskData) {
    Deadline deadline = persistenceContext.findDeadline(deadlineSummary.getDeadlineId());
    if (task == null || deadline == null) {
        return null;
    }
    if (taskData != null) {
        UserInfo userInfo = (UserInfo) ctx.get(EnvironmentName.TASK_USER_INFO);
        // check if task is still in valid status
        if (DeadlineType.START.isValidStatus(taskData.getStatus()) || DeadlineType.END.isValidStatus(taskData.getStatus())) {
            Map<String, Object> variables = getVariables(ctx, persistenceContext, task, taskData);
            if (deadline == null || deadline.getEscalations() == null) {
                return null;
            }
            TaskEventSupport taskEventSupport = ctx.getTaskEventSupport();
            taskEventSupport.fireBeforeTaskNotified(task, ctx);
            for (Escalation escalation : deadline.getEscalations()) {
                for (Notification notification : escalation.getNotifications()) {
                    if (notification.getNotificationType() == NotificationType.Email) {
                        logger.debug("Sending an Email");
                        NotificationListenerManager.get().broadcast(new NotificationEvent(notification, task, variables), userInfo);
                    }
                }
            }
            taskEventSupport.fireAfterTaskNotified(task, ctx);
        }
    }
    return null;
}
Also used : Deadline(org.kie.internal.task.api.model.Deadline) Escalation(org.kie.internal.task.api.model.Escalation) UserInfo(org.kie.internal.task.api.UserInfo) NotificationEvent(org.kie.internal.task.api.model.NotificationEvent) TaskEventSupport(org.jbpm.services.task.events.TaskEventSupport) Notification(org.kie.internal.task.api.model.Notification) EmailNotification(org.kie.internal.task.api.model.EmailNotification)

Example 22 with UserInfo

use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.

the class LDAPUserInfoImplTest method testGroupsSubtreeScopeBaseDnContext.

@Test
public void testGroupsSubtreeScopeBaseDnContext() {
    UserInfo ldapUserInfo = createLdapUserInfoWithGroupCtx(SUBTREE_SCOPE, "dc=jbpm,dc=org");
    assertGroups(ldapUserInfo, true, true, true, true);
}
Also used : UserInfo(org.kie.internal.task.api.UserInfo) Test(org.junit.Test)

Example 23 with UserInfo

use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.

the class LDAPUserInfoImplTest method testGetLanguageForEntity.

private void testGetLanguageForEntity(OrganizationalEntity entity, String language, boolean customAttribute) {
    Properties properties = createUserInfoProperties();
    if (customAttribute) {
        properties.setProperty(LDAPUserInfoImpl.LANG_ATTR_ID, "language");
    }
    if (entity.getId().startsWith("uid=") || entity.getId().startsWith("cn=")) {
        properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
    }
    UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
    Assertions.assertThat(ldapUserInfo.getLanguageForEntity(entity)).isEqualTo(language);
}
Also used : UserInfo(org.kie.internal.task.api.UserInfo) Properties(java.util.Properties)

Example 24 with UserInfo

use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.

the class LDAPUserInfoImplTest method testUsersOneLevelScopeBaseDnContext.

@Test
public void testUsersOneLevelScopeBaseDnContext() {
    UserInfo ldapUserInfo = createLdapUserInfoWithUserCtx(ONELEVEL_SCOPE, "dc=jbpm,dc=org");
    assertUsers(ldapUserInfo, false, false, false, false);
}
Also used : UserInfo(org.kie.internal.task.api.UserInfo) Test(org.junit.Test)

Example 25 with UserInfo

use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.

the class LDAPUserInfoImplTest method testGetMembersForGroup.

private void testGetMembersForGroup(boolean emptyGroup, boolean customAttribute, boolean distinguishedName) {
    Properties properties = createUserInfoProperties();
    if (customAttribute) {
        properties.setProperty(LDAPUserInfoImpl.MEMBER_ATTR_ID, "representative");
    }
    if (distinguishedName) {
        properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
    }
    UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
    Group group;
    if (distinguishedName) {
        group = emptyGroup ? USER_DN : MANAGER_DN;
    } else {
        group = emptyGroup ? USER : MANAGER;
    }
    Iterator<OrganizationalEntity> iterator = ldapUserInfo.getMembersForGroup(group);
    if (emptyGroup) {
        Assertions.assertThat(iterator.hasNext()).isFalse();
        return;
    }
    Assertions.assertThat(iterator.hasNext()).isTrue();
    User user = (User) iterator.next();
    if (customAttribute) {
        Assertions.assertThat(user.getId()).isEqualTo(MARY_DN.getId());
    } else {
        Assertions.assertThat(user.getId()).isEqualTo(JOHN_DN.getId());
    }
    Assertions.assertThat(iterator.hasNext()).isFalse();
}
Also used : Group(org.kie.api.task.model.Group) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) UserInfo(org.kie.internal.task.api.UserInfo) Properties(java.util.Properties)

Aggregations

UserInfo (org.kie.internal.task.api.UserInfo)38 Test (org.junit.Test)26 Properties (java.util.Properties)8 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)5 Task (org.kie.api.task.model.Task)5 ArrayList (java.util.ArrayList)4 Group (org.kie.api.task.model.Group)4 User (org.kie.api.task.model.User)4 InternalPeopleAssignments (org.kie.internal.task.api.model.InternalPeopleAssignments)4 Iterator (java.util.Iterator)3 List (java.util.List)3 Map (java.util.Map)3 TaskEventSupport (org.jbpm.services.task.events.TaskEventSupport)3 EnvironmentName (org.kie.api.runtime.EnvironmentName)3 TaskContext (org.kie.api.task.TaskContext)3 TaskPersistenceContext (org.kie.internal.task.api.TaskPersistenceContext)3 Assignment (org.kie.internal.task.api.assignment.Assignment)3 AssignmentStrategy (org.kie.internal.task.api.assignment.AssignmentStrategy)3 Notification (org.kie.internal.task.api.model.Notification)3 NotificationEvent (org.kie.internal.task.api.model.NotificationEvent)3