Package com.sparc.knappsack.forms

Examples of com.sparc.knappsack.forms.GroupForm


    private Errors errors;
    private GroupForm groupForm;

    @Before
    public void setup() {
        groupForm = new GroupForm();
        errors = new BeanPropertyBindingResult(groupForm, "groupForm");
    }
View Full Code Here


    @PreAuthorize("isOrganizationAdmin() or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/manager/addGroup", method = RequestMethod.GET)
    public String addGroup(Model model) {

        if (!model.containsAttribute("group")) {
            model.addAttribute("group", new GroupForm());
        }
        User user = userService.getUserFromSecurityContext();
        model.addAttribute("organizations", user.getActiveOrganization());

        return "manager/manageGroupTH";
View Full Code Here

        checkRequiredEntity(groupService, id);

        Group existingGroup = groupService.get(id);

        if (existingGroup != null) {
            GroupForm groupForm = new GroupForm();
            groupService.mapGroupToGroupForm(existingGroup, groupForm);
            model.addAttribute("group", groupForm);
            model.addAttribute("accessCode", existingGroup.getUuid());

            List<DomainUserRequest> requests = requestService.getAll(existingGroup.getId(), Status.PENDING);
View Full Code Here

    @PreAuthorize("isOrganizationAdminForActiveOrganization() or hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/manager/createGroup", method = RequestMethod.POST)
    public @ResponseBody Result createGroupAJAX(final HttpServletRequest request, @RequestParam(required = true) String name) {
        Result result = new Result();

        GroupForm groupForm = new GroupForm();
        groupForm.setName(StringUtils.trimTrailingWhitespace(name));

        boolean isValid = false;

        // Validate
        Errors errors = new BeanPropertyBindingResult(groupForm, "groupForm");
View Full Code Here

        return GroupForm.class.isAssignableFrom(aClass);
    }

    @Override
    public void validate(Object o, Errors errors) {
        GroupForm groupForm = (GroupForm) o;
        if (groupForm.getName() == null || "".equals(groupForm.getName())) {
            errors.rejectValue(NAME_FIELD, "groupValidator.emptyName");
        }

        if (!errors.hasFieldErrors(NAME_FIELD)) {
            User user = userService.getUserFromSecurityContext();
            if (user == null) {
                errors.reject("groupValidator.generic");
                return;
            }

            Organization organization = user.getActiveOrganization();
            if (organization == null) {
                errors.reject("groupValidator.generic");
            }

            Group group = groupService.get(groupForm.getName(), organization.getId());
            if (group != null) {
                errors.rejectValue(NAME_FIELD, "groupValidator.groupNameExistsInOrganization");
            }
        }
    }
View Full Code Here

    @Test
    public void createGroupTest() {
        Organization organization = getOrganization();
        setActiveOrganizationOnUserInSecurityContext(organization);
        GroupForm groupForm = getGroupForm();
        groupService.createGroup(groupForm);

        List<Group> groups = groupService.getAll();
        assertEquals(groups.size(), 1);
        assertEquals(groups.get(0).getName(), groupForm.getName());
        assertEquals(groups.get(0).getOrganization(), organization);
    }
View Full Code Here

        List<Group> groups = groupService.getAll();
        assertTrue(groups.size() == 1);
        assertEquals(group, groups.get(0));

        GroupForm groupForm = new GroupForm();
        groupService.mapGroupToGroupForm(group, groupForm);
        assertTrue(group.getId().equals(groupForm.getId()));
        assertTrue(group.getName().equals(groupForm.getName()));
        assertEquals(group.getOrganization(), getUserWithSecurityContext().getActiveOrganization());
    }
View Full Code Here

        List<Group> groups = groupService.getAll();
        assertTrue(groups.size() == 1);
        assertEquals(group, groups.get(0));

        GroupForm groupForm = new GroupForm();
        groupForm.setName("New Group");
        groupForm.setId(group.getId());
        groupService.editGroup(groupForm);
        group = groupService.get(group.getName(), group.getOrganization().getId());
        assertNotNull(group);
        assertTrue(group.getName().equals(groupForm.getName()));
    }
View Full Code Here

        Group ownedGroup = groupService.getOwnedGroup(application);
        assertTrue(group.equals(ownedGroup));
    }

    private GroupForm getGroupForm() {
        GroupForm groupForm = new GroupForm();
        groupForm.setName("Test Group");

        return groupForm;
    }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.forms.GroupForm

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.