@Override public List<Map<String, Object>> classpageUserJoin( String code, List<String> mailIds, User apiCaller) throws Exception { List<Map<String, Object>> classpageMember = new ArrayList<Map<String, Object>>(); UserGroup userGroup = this.getUserGroupService().findUserGroupByGroupCode(code); Classpage classpage = this.getCollectionRepository().getClasspageByCode(code); if (userGroup != null && classpage != null) { for (String mailId : mailIds) { Identity identity = this.getUserRepository().findByEmailIdOrUserName(mailId, true, false); if (identity != null) { InviteUser inviteUser = this.getInviteRepository().findInviteUserById(mailId, classpage.getGooruOid()); if (inviteUser != null) { inviteUser.setStatus( this.getCustomTableRepository().getCustomTableValue(INVITE_USER_STATUS, ACTIVE)); inviteUser.setJoinedDate(new Date(System.currentTimeMillis())); this.getInviteRepository().save(inviteUser); } if (this.getUserRepository() .getUserGroupMemebrByGroupUid( userGroup.getPartyUid(), identity.getUser().getPartyUid()) == null) { UserGroupAssociation groupAssociation = new UserGroupAssociation(); groupAssociation.setIsGroupOwner(0); groupAssociation.setUser(identity.getUser()); groupAssociation.setUserGroup(userGroup); this.getUserRepository().save(groupAssociation); classpageMember.add(setMemberResponse(groupAssociation, ACTIVE)); } } } } return classpageMember; }
private Map<String, Object> setMemberResponse( UserGroupAssociation userGroupAssociation, String status) { Map<String, Object> member = new HashMap<String, Object>(); member.put( EMAIL_ID, userGroupAssociation.getUser().getIdentities() != null ? userGroupAssociation.getUser().getIdentities().iterator().next().getExternalId() : null); member.put(_GOORU_UID, userGroupAssociation.getUser().getPartyUid()); member.put(USER_NAME, userGroupAssociation.getUser().getUsername()); member.put( PROFILE_IMG_URL, this.getUserManagementService().buildUserProfileImageUrl(userGroupAssociation.getUser())); member.put(STATUS, status); return member; }
private List<Map<String, Object>> getActiveMemberList(String code) { List<Map<String, Object>> activeList = new ArrayList<Map<String, Object>>(); Classpage classpage = this.getCollectionRepository().getClasspageByCode(code); if (classpage == null) { throw new NotFoundException("Class not found!!!"); } UserGroup userGroup = this.getUserGroupService().findUserGroupByGroupCode(code); List<UserGroupAssociation> userGroupAssociations = this.getUserGroupRepository().getUserGroupAssociationByGroup(userGroup.getPartyUid()); for (UserGroupAssociation userGroupAssociation : userGroupAssociations) { if (userGroupAssociation.getIsGroupOwner() != 1) { activeList.add(this.setMemberResponse(userGroupAssociation, ACTIVE)); } } return activeList; }