Package org.fao.geonet.domain

Examples of org.fao.geonet.domain.UserGroup


        User user2 = UserRepositoryTest.newUser(inc);
        user2.setProfile(Profile.RegisteredUser);
        user2 = _userRepo.save(user2);

        _userGroupRepo.save(new UserGroup().setGroup(group).setUser(user1).setProfile(Profile.Editor));
        _userGroupRepo.save(new UserGroup().setGroup(group).setUser(user2).setProfile(Profile.RegisteredUser));

        final ServiceContext serviceContext = createServiceContext();
        UserSession userSession = new UserSession();
        userSession.loginAs(user1);
View Full Code Here


    @Autowired
    GroupRepository _groupRepo;

    @Test
    public void testHasGroupId() throws Exception {
        UserGroup ug1 = _repo.save(newUserGroup());
        _repo.save(newUserGroup());
        _repo.save(newUserGroup());
        _repo.save(newUserGroup());

        UserGroup found = _repo.findOne(hasGroupId(ug1.getId().getGroupId()));
        assertEquals(ug1.getId(), found.getId());
    }
View Full Code Here

        assertEquals(ug1.getId(), found.getId());
    }

    @Test
    public void testHasUserId() throws Exception {
        UserGroup ug1 = _repo.save(newUserGroup());
        _repo.save(newUserGroup());
        _repo.save(newUserGroup());
        _repo.save(newUserGroup());

        UserGroup found = _repo.findOne(hasUserId(ug1.getId().getUserId()));
        assertEquals(ug1.getId(), found.getId());
    }
View Full Code Here

        assertEquals(ug1.getId(), found.getId());
    }

    @Test
    public void testHasProfile() throws Exception {
        UserGroup ug1 = _repo.save(newUserGroup());
        _repo.save(newUserGroup());
        _repo.save(newUserGroup());
        _repo.save(newUserGroup());

        List<UserGroup> found = _repo.findAll(hasProfile(ug1.getProfile()));

        for (UserGroup userGroup : found) {
            assertEquals(ug1.getProfile(), userGroup.getProfile());
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testIsReservedGroup() throws Exception {
        UserGroup ug1 = _repo.save(newUserGroup());
        UserGroup ug2 = _repo.save(newUserGroup());
        UserGroup ug3 = _repo.save(newUserGroup());
        UserGroup ug4 = _repo.save(newUserGroup());

        Map<ReservedGroup, Integer> normalIds = new HashMap<ReservedGroup, Integer>();
        // Set all reserveGroup ids so that they are not the the same as those in the other groups
        for (ReservedGroup reservedGroup : ReservedGroup.values()) {
            normalIds.put(reservedGroup, reservedGroup.getId());
            setReservedGroupId(ug1.getId().getGroupId() - 10 + reservedGroup.getId(), reservedGroup);
        }

        try {
            final int groupId = ug3.getId().getGroupId();
            final ReservedGroup group = ReservedGroup.intranet;
            setReservedGroupId(groupId, group);

            setReservedGroupId(groupId, group);
            setReservedGroupId(groupId, group);
            setReservedGroupId(groupId, group);

            List<Integer> found = _repo.findGroupIds(isReservedGroup(true));
            assertFalse(found.contains(ug1.getId().getGroupId()));
            assertFalse(found.contains(ug2.getId().getGroupId()));
            assertTrue(found.contains(groupId));
            assertFalse(found.contains(ug4.getId().getGroupId()));

            found = _repo.findGroupIds(isReservedGroup(false));
            assertTrue(found.contains(ug1.getId().getGroupId()));
            assertTrue(found.contains(ug2.getId().getGroupId()));
            assertFalse(found.contains(groupId));
            assertTrue(found.contains(ug4.getId().getGroupId()));
        } finally {
            for (ReservedGroup reservedGroup : ReservedGroup.values()) {
                setReservedGroupId(normalIds.get(reservedGroup), reservedGroup);
            }
View Full Code Here

            UserGroupRepository userGroupRepo = context.getBean(UserGroupRepository.class);

            long count = userGroupRepo.count(where(hasGroupId(groupId)).and(hasUserId(userId)));

            if (count == 0) {
                UserGroup userGroup = new UserGroup();
                userGroup.getId().setGroupId(groupId).setUserId(userId);
                userGroupRepo.save(userGroup);
            }
        }

        return user;
View Full Code Here

        userRepository.save(user);

        // The user is created as registereduser on the GUEST group, and not mapped on the specific optional
        // profile. Then the catalogue administrator could manage the created user.
        UserGroup userGroup = new UserGroup().setUser(user).setGroup(group).setProfile(Profile.RegisteredUser);
        context.getBean(UserGroupRepository.class).save(userGroup);
    // Send email to user confirming registration

    SettingInfo si = context.getBean(SettingInfo.class);
    String siteURL = si.getSiteUrl() + context.getBaseUrl();
View Full Code Here

TOP

Related Classes of org.fao.geonet.domain.UserGroup

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.