Package org.apache.syncope.common.to

Examples of org.apache.syncope.common.to.WorkflowFormTO


        } catch (ActivitiException e) {
            LOG.debug("No form found for task {}", task.getId(), e);
            formData = null;
        }

        WorkflowFormTO result = null;
        if (formData != null && !formData.getFormProperties().isEmpty()) {
            result = getFormTO(task, formData);
        }

        return result;
View Full Code Here


        assertEquals(1, userTO.getMemberships().size());
        assertEquals(9, userTO.getMemberships().get(0).getRoleId());
        assertEquals("createApproval", userTO.getStatus());

        // 2. request if there is any pending task for user just created
        WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getId());
        assertNotNull(form);
        assertNotNull(form.getUserId());
        assertEquals(userTO.getId(), form.getUserId());
        assertNotNull(form.getTaskId());
        assertNull(form.getOwner());

        // 3. claim task from rossini, not in role 7 (designated for approval in workflow definition): fail
        UserWorkflowService userService2 = setupCredentials(
                userWorkflowService, UserWorkflowService.class, "rossini", ADMIN_PWD);

        try {
            userService2.claimForm(form.getTaskId());
            fail();
        } catch (SyncopeClientCompositeErrorException scce) {
            assertNotNull(scce.getException(SyncopeClientExceptionType.Workflow));
        }

        // 4. claim task from bellini, in role 7
        UserWorkflowService userService3 = setupCredentials(userWorkflowService, UserWorkflowService.class, "bellini",
                ADMIN_PWD);

        form = userService3.claimForm(form.getTaskId());
        assertNotNull(form);
        assertNotNull(form.getTaskId());
        assertNotNull(form.getOwner());

        // 5. reject user
        Map<String, WorkflowFormPropertyTO> props = form.getPropertyMap();
        props.get("approve").setValue(Boolean.FALSE.toString());
        props.get("rejectReason").setValue("I don't like him.");
        form.setProperties(props.values());
        userTO = userService3.submitForm(form);
        assertNotNull(userTO);
        assertEquals("rejected", userTO.getStatus());

        // 6. check that rejected user was not propagated to external resource (SYNCOPE-364)
View Full Code Here

        // 2. request if there is any pending form for user just created
        List<WorkflowFormTO> forms = userWorkflowService.getForms();
        assertNotNull(forms);
        assertEquals(1, forms.size());

        WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getId());
        assertNotNull(form);
        assertNotNull(form.getTaskId());
        assertNull(form.getOwner());

        // 4. claim task (from admin)
        form = userWorkflowService.claimForm(form.getTaskId());
        assertNotNull(form);
        assertNotNull(form.getTaskId());
        assertNotNull(form.getOwner());

        // 5. approve user (and verify that propagation occurred)
        Map<String, WorkflowFormPropertyTO> props = form.getPropertyMap();
        props.get("approve").setValue(Boolean.TRUE.toString());
        form.setProperties(props.values());
        userTO = userWorkflowService.submitForm(form);
        assertNotNull(userTO);
        assertEquals("active", userTO.getStatus());
        assertEquals(Collections.singleton(RESOURCE_NAME_TESTDB), userTO.getResources());
View Full Code Here

    @PreAuthorize("hasRole('WORKFLOW_FORM_READ') and hasRole('USER_READ')")
    @RequestMapping(method = RequestMethod.GET, value = "/workflow/form/{userId}")
    @Transactional(rollbackFor = {Throwable.class})
    public WorkflowFormTO getFormForUser(@PathVariable("userId") final Long userId) {
        SyncopeUser user = binder.getUserFromId(userId);
        WorkflowFormTO result = uwfAdapter.getForm(user.getWorkflowId());

        auditManager.audit(Category.user, UserSubCategory.getFormForUser, Result.success,
                "Successfully read workflow form for user: " + user.getUsername());

        return result;
View Full Code Here

    @PreAuthorize("hasRole('WORKFLOW_FORM_CLAIM')")
    @RequestMapping(method = RequestMethod.GET, value = "/workflow/form/claim/{taskId}")
    @Transactional(rollbackFor = {Throwable.class})
    public WorkflowFormTO claimForm(@PathVariable("taskId") final String taskId) {
        WorkflowFormTO result = uwfAdapter.claimForm(taskId,
                SecurityContextHolder.getContext().getAuthentication().getName());

        auditManager.audit(Category.user, UserSubCategory.claimForm, Result.success,
                "Successfully claimed workflow form: " + taskId);
View Full Code Here

        return result;
    }

    @SuppressWarnings("unchecked")
    private WorkflowFormTO getFormTO(final Task task, final TaskFormData formData) {
        WorkflowFormTO formTO = new WorkflowFormTO();

        SyncopeUser user = userDAO.findByWorkflowId(task.getProcessInstanceId());
        if (user == null) {
            throw new NotFoundException("User with workflow id " + task.getProcessInstanceId());
        }
        formTO.setUserId(user.getId());

        formTO.setTaskId(task.getId());
        formTO.setKey(formData.getFormKey());

        BeanUtils.copyProperties(task, formTO);

        for (FormProperty fProp : formData.getFormProperties()) {
            WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
            BeanUtils.copyProperties(fProp, propertyTO, PROPERTY_IGNORE_PROPS);
            propertyTO.setType(fromActivitiFormType(fProp.getType()));

            if (propertyTO.getType() == WorkflowFormPropertyType.Date) {
                propertyTO.setDatePattern((String) fProp.getType().getInformation("datePattern"));
            }
            if (propertyTO.getType() == WorkflowFormPropertyType.Enum) {
                propertyTO.setEnumValues((Map<String, String>) fProp.getType().getInformation("values"));
            }

            formTO.addProperty(propertyTO);
        }

        return formTO;
    }
View Full Code Here

        } catch (ActivitiException e) {
            LOG.debug("No form found for task {}", task.getId(), e);
            formData = null;
        }

        WorkflowFormTO result = null;
        if (formData != null && !formData.getFormProperties().isEmpty()) {
            result = getFormTO(task, formData);
        }

        return result;
View Full Code Here

        return result;
    }

    @SuppressWarnings("unchecked")
    private WorkflowFormTO getFormTO(final Task task, final TaskFormData formData) {
        WorkflowFormTO formTO = new WorkflowFormTO();

        SyncopeUser user = userDAO.findByWorkflowId(task.getProcessInstanceId());
        if (user == null) {
            throw new NotFoundException("User with workflow id " + task.getProcessInstanceId());
        }
        formTO.setUserId(user.getId());

        formTO.setTaskId(task.getId());
        formTO.setKey(formData.getFormKey());

        BeanUtils.copyProperties(task, formTO);

        for (FormProperty fProp : formData.getFormProperties()) {
            WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
            BeanUtils.copyProperties(fProp, propertyTO, PROPERTY_IGNORE_PROPS);
            propertyTO.setType(fromActivitiFormType(fProp.getType()));

            if (propertyTO.getType() == WorkflowFormPropertyType.Date) {
                propertyTO.setDatePattern((String) fProp.getType().getInformation("datePattern"));
            }
            if (propertyTO.getType() == WorkflowFormPropertyType.Enum) {
                propertyTO.setEnumValues((Map<String, String>) fProp.getType().getInformation("values"));
            }

            formTO.addProperty(propertyTO);
        }

        return formTO;
    }
View Full Code Here

        } catch (ActivitiException e) {
            LOG.debug("No form found for task {}", task.getId(), e);
            formData = null;
        }

        WorkflowFormTO result = null;
        if (formData != null && !formData.getFormProperties().isEmpty()) {
            result = getFormTO(task, formData);
        }

        return result;
View Full Code Here

        return result;
    }

    @SuppressWarnings("unchecked")
    private WorkflowFormTO getFormTO(final Task task, final TaskFormData formData) {
        WorkflowFormTO formTO = new WorkflowFormTO();

        SyncopeUser user = userDAO.findByWorkflowId(task.getProcessInstanceId());
        if (user == null) {
            throw new NotFoundException("User with workflow id " + task.getProcessInstanceId());
        }
        formTO.setUserId(user.getId());

        formTO.setTaskId(task.getId());
        formTO.setKey(formData.getFormKey());

        BeanUtils.copyProperties(task, formTO);

        for (FormProperty fProp : formData.getFormProperties()) {
            WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
            BeanUtils.copyProperties(fProp, propertyTO, PROPERTY_IGNORE_PROPS);
            propertyTO.setType(fromActivitiFormType(fProp.getType()));

            if (propertyTO.getType() == WorkflowFormPropertyType.Date) {
                propertyTO.setDatePattern((String) fProp.getType().getInformation("datePattern"));
            }
            if (propertyTO.getType() == WorkflowFormPropertyType.Enum) {
                propertyTO.setEnumValues((Map<String, String>) fProp.getType().getInformation("values"));
            }

            formTO.addProperty(propertyTO);
        }

        return formTO;
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.to.WorkflowFormTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.