/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") void loadFrame() { groupList = dbOps.getUserGroups(); for (UserGroup g : groupList) { ddGroup.addItem(g.getGroupID()); ddGroup1.addItem(g.getGroupID()); ddGroup2.addItem(g.getGroupID()); } }
public void postObject( HttpServletResponse response, HttpServletRequest request, Message message) { List<User> users = new ArrayList<User>(message.getUsers()); message.getUsers().clear(); for (OrganisationUnit ou : message.getOrganisationUnits()) { OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(ou.getUid()); if (organisationUnit == null) { ContextUtils.conflictResponse(response, "Organisation Unit does not exist: " + ou.getUid()); return; } message.getUsers().addAll(organisationUnit.getUsers()); } for (User u : users) { User user = userService.getUser(u.getUid()); if (user == null) { ContextUtils.conflictResponse(response, "User does not exist: " + u.getUid()); return; } message.getUsers().add(user); } for (UserGroup ug : message.getUserGroups()) { UserGroup userGroup = userGroupService.getUserGroup(ug.getUid()); if (userGroup == null) { ContextUtils.conflictResponse(response, "User Group does not exist: " + ug.getUid()); return; } message.getUsers().addAll(userGroup.getMembers()); } if (message.getUsers().isEmpty()) { ContextUtils.conflictResponse(response, "No recipients selected."); return; } String metaData = MessageService.META_USER_AGENT + request.getHeader(ContextUtils.HEADER_USER_AGENT); int id = messageService.sendMessage( message.getSubject(), message.getText(), metaData, message.getUsers()); MessageConversation conversation = messageService.getMessageConversation(id); ContextUtils.createdResponse( response, "Message conversation created", MessageConversationController.RESOURCE_PATH + "/" + conversation.getUid()); }
@Override public void deleteUser(User user) { Iterator<UserGroup> iterator = user.getGroups().iterator(); while (iterator.hasNext()) { UserGroup group = iterator.next(); group.getMembers().remove(user); userGroupService.updateUserGroup(group); } }
private void add(User parentResource, Map<String, Object> propertyMap) { String qualifiedName = (String) propertyMap.get("qualifiedName"); Class<UserGroup> baseTumlClass = UmlgSchemaFactory.getUmlgSchemaMap().get(qualifiedName); try { Object id = propertyMap.get("id"); UserGroup childResource = UMLG.get().getEntity(id); parentResource.addToUsergroup(childResource); childResource.fromJson(propertyMap); } catch (Exception e) { throw new RuntimeException(e); } }
private void setupUserGroup() throws NonUniqueBusinessKeyException, ObjectNotFoundException { org = Organizations.createOrganization(mgr, OrganizationRoleType.PLATFORM_OPERATOR); assertNotNull("organization expected", org); userGroup = new UserGroup(); userGroup.setName("group1"); userGroup.setDescription("group1 description"); userGroup.setReferenceId("group1 reference Id"); userGroup.setIsDefault(true); userGroup.setOrganization(org); mgr.persist(userGroup); }
private void doTestDeleteByUserGroup() { userGroup = mgr.find(UserGroup.class, userGroup.getKey()); assertNotNull("UserGroup expected", userGroup); List<UserGroupToInvisibleProduct> list = userGroup.getUserGroupToInvisibleProducts(); assertNotNull(list); Assert.assertEquals(1, list.size()); oldUserGroupToInvisibleProduct = mgr.find(UserGroupToInvisibleProduct.class, list.get(0).getKey()); assertNotNull(oldUserGroupToInvisibleProduct); mgr.remove(userGroup); }
@Test public void testUserGroupManagement() { // Try to get non-existent UserGroup userGroup = _userManager.getUserGroup("nonexistentusergroup"); assertNull(userGroup); // Clear DB as necessary userGroup = _userManager.getUserGroup("testusergroup"); if (userGroup != null) { _userManager.deleteUserGroup(userGroup); } // Add userGroup = new UserGroup(); userGroup.setName("testusergroup"); Authority authority = _userManager.getAuthority("testauthority"); if (authority == null) { authority = new Authority("testauthority"); _userManager.addAuthority(authority); } userGroup.getAuthorities().add(authority); User user = _userManager.getUser("testuser"); if (user == null) { user = getTestUser(); _userManager.addUser(user); } _userManager.addUserGroup(userGroup); // Update Authority additionalAuthority = _userManager.getAuthority("additionalauthority"); if (additionalAuthority == null) { additionalAuthority = new Authority("additionalauthority"); _userManager.addAuthority(additionalAuthority); } userGroup.getAuthorities().add(additionalAuthority); _userManager.updateUserGroup(userGroup); userGroup = _userManager.getUserGroup("testusergroup"); assertNotNull(userGroup); assertTrue(userGroup.getAuthorities().contains(additionalAuthority)); // Delete _userManager.deleteUserGroup(userGroup); userGroup = _userManager.getUserGroup("testusergroup"); assertNull(userGroup); }
public static void changeGroup(User user, int groupTypeId, int groupId) { UserGroup to = null; // try { // to = getUserGroup(groupTypeId, groupId); // } catch (Exception e) { // to = getUserGroup(groupTypeId).getGroupByExp(user.getExp()); // } to = getUserGroup(groupTypeId).getGroupByExp(user.getExp()); if (to == null) { throw new RuntimeException("无法根据用户经验值匹配正确的用户组,请选择!"); } user.setGroupTypeId(to.getTypeId()); user.setGroupId(to.getId()); }
@Override public String allowDeleteUserGroup(UserGroup group) { int count = jdbcTemplate.queryForObject( "select count(*) from usergroupaccess where usergroupid=" + group.getId(), Integer.class); return count == 0 ? null : ""; }
private void doTestDeleteCheckByUserGroup() { // UserGroup must be deleted UserGroup ug = mgr.find(UserGroup.class, userGroup.getKey()); Assert.assertNull("UserGroup still available", ug); // UserGroupToInvisibleProduct must be deleted UserGroupToInvisibleProduct userGroupToInvisibleProduct = mgr.find(UserGroupToInvisibleProduct.class, oldUserGroupToInvisibleProduct.getKey()); Assert.assertNull("UserGroupToInvisibleProduct still available", userGroupToInvisibleProduct); }
private void doTestAdd() throws Exception { userGroup = mgr.find(UserGroup.class, userGroup.getKey()); p = mgr.find(Product.class, p.getKey()); UserGroupToInvisibleProduct uip = new UserGroupToInvisibleProduct(); uip.setUserGroup(userGroup); uip.setProduct(p); mgr.persist(uip); }
@Test public void testUserManagement() { // Try to get non-existent User user = _userManager.getUser("nonexistentuser"); assertNull(user); // Clear DB as necessary user = _userManager.getUser("testuser"); if (user != null) { _userManager.deleteUser(user); } // Add user = getTestUser(); Set<UserGroup> userGroups = new HashSet<UserGroup>(); UserGroup userGroup = _userManager.getUserGroup("testusergroup"); if (userGroup == null) { userGroup = new UserGroup(); userGroup.setName("testusergroup"); userGroup.getAuthorities().add(new Authority("testauthority")); } userGroup.getUsers().add(user); user.setUserGroups(userGroups); _userManager.addUser(user); // Update user.setPassword("modifiedtestpw"); _userManager.updateUser(user); user = _userManager.getUser("testuser"); assertNotNull(user); assertTrue(user.checkPassword("modifiedtestpw")); // Delete _userManager.deleteUser(user); user = _userManager.getUser("testuser"); assertNull(user); }
public void remove(Long id) { VDCUser user = (VDCUser) em.find(VDCUser.class, id); if (user != null) { // Need to remove this user from other collections it may belong to. for (Iterator it = user.getUserGroups().iterator(); it.hasNext(); ) { UserGroup group = (UserGroup) it.next(); group.getUsers().remove(user); } for (Iterator it2 = user.getStudies().iterator(); it2.hasNext(); ) { Study study = (Study) it2.next(); study.getAllowedUsers().remove(user); } for (Iterator it2 = user.getStudyFiles().iterator(); it2.hasNext(); ) { StudyFile studyFile = (StudyFile) it2.next(); studyFile.getAllowedUsers().remove(user); } for (Iterator it = user.getAllowedFileVdcs().iterator(); it.hasNext(); ) { VDC elem = (VDC) it.next(); elem.getAllowedFileUsers().remove(user); } em.remove(user); } }
public void addAllowedGroup(Long groupId) { UserGroup group = em.find(UserGroup.class, groupId); vdc.getAllowedGroups().add(group); group.getVdcs().add(vdc); }
private void put(Map<String, Object> propertyMap) { Object id = propertyMap.get("id"); UserGroup childResource = UMLG.get().getEntity(id); childResource.fromJson(propertyMap); Class<? extends UserGroup> baseTumlClass = childResource.getClass(); }
public void removeAllowedGroup(Long groupId) { UserGroup group = em.find(UserGroup.class, groupId); vdc.getAllowedGroups().remove(group); group.getVdcs().remove(vdc); }
@Override public String toString() { return userGroup == null ? name : userGroup.getName() + "-" + name; }