Commits

Anonymous committed 4192b96

Change the names of parameters related to the old domain name secGroup
.

git-svn-id: http://svn.encuesta.me/trunk/encuestame@100639e2479b-dd58-4041-9f67-69c9b71f0610

Comments (0)

Files changed (11)

encuestame-business/src/main/java/org/encuestame/business/service/SecurityService.java

     public List<UnitGroupBean> loadGroups(final String currentUsername) throws EnMeDomainNotFoundException{
         final UserAccount userAccount = getUser(currentUsername);
         final List<UnitGroupBean> groupBeans = new ArrayList<UnitGroupBean>();
-        final List<Group> groups = getGroupDao().loadGroupsByUser(userAccount.getAccount());
-        for (Group secGroups : groups) {
-            groupBeans.add(ConvertDomainBean.convertGroupDomainToBean(secGroups));
+        final List<Group> groupsList = getGroupDao().loadGroupsByUser(userAccount.getAccount());
+        for (Group groups : groupsList) {
+            groupBeans.add(ConvertDomainBean.convertGroupDomainToBean(groups));
         }
         return groupBeans;
     }
      * @return
      * @throws EnMeDomainNotFoundException
      */
-    public Long getUserbyGroup(final Long secGroupId, final String username) throws EnMeDomainNotFoundException{
+    public Long getUserbyGroup(final Long groupId, final String username) throws EnMeDomainNotFoundException{
         Long counterUsers = 0L;
         try {
-             final Group group = getGroupDao().getGroupByIdandUser(secGroupId, getPrimaryUser(username));
+             final Group group = getGroupDao().getGroupByIdandUser(groupId, getPrimaryUser(username));
              if(group != null){
-             counterUsers = getGroupDao().getCountUserbyGroup(secGroupId);
+             counterUsers = getGroupDao().getCountUserbyGroup(groupId);
              }
         } catch (Exception e) {
             // TODO: handle exception Group no pertenece a usuario
             final String username) throws EnMeDomainNotFoundException {
         final UserAccount userAccount = getUser(userId); //TODO: I need confirm this user perhaps same group of logged user.
         //search group by group id and owner user id.
-        final Group secGroup = getGroupDao().getGroupById(groupId, getUser(username).getAccount());
-        if(secGroup == null){
+        final Group group = getGroupDao().getGroupById(groupId, getUser(username).getAccount());
+        if(group == null){
             throw new EnMeDomainNotFoundException("group not found");
         } else {
             //add new group.
-            userAccount.setSecGroup(secGroup);
+            userAccount.setGroup(group);
             getAccountDao().saveOrUpdate(userAccount);
         }
     }

encuestame-business/src/main/java/org/encuestame/business/service/imp/ISecurityService.java

      * @param username
      * @return
      */
-    Long getUserbyGroup(final Long secGroupId, final String username)throws EnMeDomainNotFoundException;
+    Long getUserbyGroup(final Long groupId, final String username)throws EnMeDomainNotFoundException;
 
     /**
      * Count Users by Groups

encuestame-business/src/test/java/org/encuestame/test/business/service/TestSecurityService.java

         createPermission(EnMePermission.ENCUESTAME_PUBLISHER.name());
         createPermission(EnMePermission.ENCUESTAME_ADMIN.name());
         this.secUserSecondary.getSecUserPermissions().add(this.secPermission);
-        getSecGroup().saveOrUpdate(this.secUserSecondary);
+        getGroup().saveOrUpdate(this.secUserSecondary);
     }
 
     /**
         final Long idGroup = groupDomain.getGroupId();
         final UnitGroupBean group = ConvertDomainBean.convertGroupDomainToBean(groupDomain);
         securityService.deleteGroup(group.getId());
-        final Group groupRetrieve = getSecGroup().getGroupById(idGroup);
+        final Group groupRetrieve = getGroup().getGroupById(idGroup);
         assertNull(groupRetrieve);
     }
 
       final Long idGroup = groupDomain.getGroupId();
       final UnitGroupBean group = ConvertDomainBean.convertGroupDomainToBean(groupDomain);
       securityService.deleteGroup(group.getId());
-      final Group groupRetrieve = getSecGroup().getGroupById(idGroup);
+      final Group groupRetrieve = getGroup().getGroupById(idGroup);
       assertNull(groupRetrieve);
 
     }
       UnitGroupBean groupBean = ConvertDomainBean.convertGroupDomainToBean(secgroups);
       groupBean.setGroupName("editors");
       securityService.updateGroup(groupBean);
-      Group groupUpdateRetrieve =  getSecGroup().getGroupById(idGroupUpdate);
+      Group groupUpdateRetrieve =  getGroup().getGroupById(idGroupUpdate);
       assertEquals("Should be","editors",groupUpdateRetrieve.getGroupName());
 
     }

encuestame-core/src/main/java/org/encuestame/core/util/ConvertDomainBean.java

             unitUserBean.setEmail(secUserSecondary.getUserEmail());
             unitUserBean.setUsername(secUserSecondary.getUsername());
             unitUserBean.setStatus(secUserSecondary.isUserStatus());
-            unitUserBean.setGroupBean(convertGroupDomainToBean(secUserSecondary.getSecGroup()));
-            unitUserBean.setGroupId(secUserSecondary.getSecGroup() == null ? null : secUserSecondary.getSecGroup().getGroupId());
+            unitUserBean.setGroupBean(convertGroupDomainToBean(secUserSecondary.getGroup()));
+            unitUserBean.setGroupId(secUserSecondary.getGroup() == null ? null : secUserSecondary.getGroup().getGroupId());
             unitUserBean.setListPermission(convertSetToUnitPermission(secUserSecondary.getSecUserPermissions()));
             unitUserBean.setFollowers(secUserSecondary.getFollowers());
             //System.out.println("Convert Enjoy Date "+secUserSecondary.getEnjoyDate());
      */
     public static final Collection<UnitGroupBean> convertSetToUnitGroupBean(final Set<Group> groups){
             final Collection<UnitGroupBean> loadListGroups = new LinkedList<UnitGroupBean>();
-            for (Group secGroups : groups) {
-                 loadListGroups.add(ConvertDomainBean.convertGroupDomainToBean(secGroups));
+            for (Group groupsList : groups) {
+                 loadListGroups.add(ConvertDomainBean.convertGroupDomainToBean(groupsList));
             }
         return loadListGroups;
     }

encuestame-persistence/src/main/java/org/encuestame/persistence/dao/imp/GroupDaoImp.java

      * @return
      */
     @SuppressWarnings("unchecked")
-    public Long getCountUserbyGroup(final Long secGroupId){
+    public Long getCountUserbyGroup(final Long groupId){
         List<Long> counter = getHibernateTemplate().findByNamedParam("select count(uid) "
-                  +" from UserAccount where secGroup.groupId = :secGroupId", "secGroupId", secGroupId);
+                  +" from UserAccount where group.groupId = :groupId", "groupId", groupId);
          return counter.get(0);
     }
 
     */
     @SuppressWarnings("unchecked")
     public List<Object[]> getUsersbyGroups(final Account user){
-         return getHibernateTemplate().findByNamedParam("SELECT sg.groupName, COUNT(scu.secGroup.groupId) "
+         return getHibernateTemplate().findByNamedParam("SELECT sg.groupName, COUNT(scu.group.groupId) "
                                                          + "FROM UserAccount as scu, Group as sg "
-                                                         + "WHERE scu.secGroup.groupId = sg.groupId AND "
+                                                         + "WHERE scu.group.groupId = sg.groupId AND "
                                                          + "scu.account = :account "
                                                          + "GROUP BY sg.groupName", "account", user);
     }
      */
     @SuppressWarnings("unchecked")
     public List<Object[]> countUsersbyGroups(final Long user){
-        return getHibernateTemplate().findByNamedParam("SELECT sg.groupName, COUNT(scu.secGroup.groupId) "
+        return getHibernateTemplate().findByNamedParam("SELECT sg.groupName, COUNT(scu.group.groupId) "
                                                         + "FROM UserAccount as scu, Group as sg "
-                                                        + "WHERE scu.secGroup.groupId = sg.groupId AND "
+                                                        + "WHERE scu.group.groupId = sg.groupId AND "
                                                         + "scu.account.uid = :account "
                                                         + "GROUP BY sg.groupName", "account", user);
    }

encuestame-persistence/src/main/java/org/encuestame/persistence/domain/security/Permission.java

     private Long idPermission;
     private EnMePermission permission;
     private String permissionDescription;
-    private Set<Group> secGroups = new HashSet<Group>();
+    private Set<Group> groups = new HashSet<Group>();
     private Set<UserAccount> secUserSecondaries = new HashSet<UserAccount>();
 
     /**
     @JoinTable(name="group_permission",
                joinColumns={@JoinColumn(name="sec_id_permission")},
                inverseJoinColumns={@JoinColumn(name="sec_id_group")})
-    public Set<Group> getSecGroups() {
-        return secGroups;
+    public Set<Group> getGroups() {
+        return groups;
     }
 
     /**
      * @param secGroups the secGroups to set
      */
-    public void setSecGroups(Set<Group> secGroups) {
-        this.secGroups = secGroups;
+    public void setGroups(Set<Group> groups) {
+        this.groups = groups;
     }
 }

encuestame-persistence/src/main/java/org/encuestame/persistence/domain/security/UserAccount.java

     /**
      * {@link Group}
      */
-    private Group secGroup;
+    private Group group;
 
     /**
      * @return uid
      */
     @ManyToOne()
     @JoinColumn(name = "groupId", nullable = true)
-    public Group getSecGroup() {
-        return secGroup;
+    public Group getGroup() {
+        return group;
     }
 
     /**
      * @param secGroup the secGroup to set
      */
-    public void setSecGroup(final Group secGroup) {
-        this.secGroup = secGroup;
+    public void setGroup(final Group group) {
+        this.group = group;
     }
 
     /**

encuestame-persistence/src/test/java/org/encuestame/test/config/AbstractBase.java

     /**
      * @return {@link IGroupDao}
      */
-    public IGroupDao getSecGroup(){
+    public IGroupDao getGroup(){
         return groupDaoImp;
     }
 
     /**
-     * @param secGroupDaoImp  {@link IGroupDao}
+     * @param GroupDaoImp  {@link IGroupDao}
      */
-    public void setgroupDao(final IGroupDao secGroupDaoImp){
-        this.groupDaoImp = secGroupDaoImp;
+    public void setgroupDao(final IGroupDao GroupDaoImp){
+        this.groupDaoImp = groupDaoImp;
     }
 
     /**
     }
 
     /**
-     * @return the secGroupDaoImp
+     * @return the groupDaoImp
      */
-    public IGroupDao getSecGroupDaoImp() {
+    public IGroupDao getGroupDaoImp() {
         return groupDaoImp;
     }
 
     /**
      * @param secGroupDaoImp the secGroupDaoImp to set
      */
-    public void setSecGroupDaoImp(final IGroupDao secGroupDaoImp) {
-        this.groupDaoImp = secGroupDaoImp;
+    public void setGroupDaoImp(final IGroupDao groupDaoImp) {
+        this.groupDaoImp = groupDaoImp;
     }
 
     /**
     public UserAccount createSecondaryUserGroup(
             final String name,
             final Account secUser,
-            final Group secGroup){
-        return createSecondaryUserGroup(name, name+"-"+RandomStringUtils.randomNumeric(6)+"@users.com", secUser, secGroup);
+            final Group group){
+        return createSecondaryUserGroup(name, name+"-"+RandomStringUtils.randomNumeric(6)+"@users.com", secUser, group);
     }
 
 
             final String name,
             final String email,
             final Account secUser,
-            final Group secGroup){
+            final Group group){
         final UserAccount user= new UserAccount();
         user.setCompleteName(name);
         user.setUsername(name);
         user.setInviteCode("xxxxxxx");
         user.setAccount(secUser);
         user.setUserStatus(true);
-        user.setSecGroup(secGroup);
+        user.setGroup(group);
         getSecUserDao().saveOrUpdate(user);
         return user;
     }
         group.setIdState(1L);
         group.setGroupType(Type.SECURITY);
         group.setGroupDescriptionInfo("First Group");
-        getSecGroup().saveOrUpdate(group);
+        getGroup().saveOrUpdate(group);
         return group;
     }
 

encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestSecGroupDaoImp.java

     @Test
    public void TestDeleteGroup(){
         final Group group = super.createGroups("second group");
-        getSecGroup().delete(group);
-        assertEquals("Should be equals",1, getSecGroup().findAllGroups().size());
+        getGroup().delete(group);
+        assertEquals("Should be equals",1, getGroup().findAllGroups().size());
     }
 
     /**Test Find All Groups*/
     {
         super.createGroups("group thirth");
         super.createGroups("group fourth");
-        assertEquals("Should be equals",3, getSecGroup().findAllGroups().size());
+        assertEquals("Should be equals",3, getGroup().findAllGroups().size());
 
     }
 
         final Group group = super.createGroups("fifth group");
         group.setGroupName(newName);
         group.setGroupDescriptionInfo(newDescription);
-        getSecGroup().saveOrUpdate(group);
-        final Group retrieveGroup = getSecGroupDaoImp().getGroupById(
+        getGroup().saveOrUpdate(group);
+        final Group retrieveGroup = getGroupDaoImp().getGroupById(
                 Long.valueOf(group.getGroupId()));
         /*sertEquals("New Name should be",newname,
             retrieveGroup.getName());
      */
     @Test
     public void testGetCountUserbyGroup(){
-        Assert.assertNotNull(this.secondary.getSecGroup());
-        Assert.assertNotNull(this.secondary.getSecGroup().getGroupId());
+        Assert.assertNotNull(this.secondary.getGroup());
+        Assert.assertNotNull(this.secondary.getGroup().getGroupId());
         final Long counterTest = 1L;
-        final Long counter = getSecGroupDaoImp().getCountUserbyGroup(this.secGroup.getGroupId());
+        final Long counter = getGroupDaoImp().getCountUserbyGroup(this.secGroup.getGroupId());
         assertEquals(counterTest, counter);
     }
 
      */
     @Test
     public void testGetUsersbyGroups(){
-        Assert.assertNotNull(this.secondary.getSecGroup());
-        Assert.assertNotNull(this.secondary.getSecGroup().getGroupId());
+        Assert.assertNotNull(this.secondary.getGroup());
+        Assert.assertNotNull(this.secondary.getGroup().getGroupId());
         Assert.assertNotNull(this.secUser);
-        final List<Object[]> usersGroups = getSecGroupDaoImp().getUsersbyGroups(this.secUser);
+        final List<Object[]> usersGroups = getGroupDaoImp().getUsersbyGroups(this.secUser);
         final String groupName = this.secGroup.getGroupName();
         final String group = (String) usersGroups.get(0)[0];
         assertEquals("Should be equals",groupName, group);
      */
     @Test
     public void testCountUsersbyGroups(){
-        Assert.assertNotNull(this.secondary.getSecGroup());
-        Assert.assertNotNull(this.secondary.getSecGroup().getGroupId());
+        Assert.assertNotNull(this.secondary.getGroup());
+        Assert.assertNotNull(this.secondary.getGroup().getGroupId());
         Assert.assertNotNull(this.secUser);
-        final List<Object[]> usersGroups = getSecGroupDaoImp().countUsersbyGroups(this.secUser.getUid());
+        final List<Object[]> usersGroups = getGroupDaoImp().countUsersbyGroups(this.secUser.getUid());
         final String groupName = this.secGroup.getGroupName();
         final String group = (String) usersGroups.get(0)[0];
         assertEquals("Should be equals",groupName, group);

encuestame-persistence/src/test/java/org/encuestame/test/persistence/dao/TestUserDao.java

         group.getSecPermissions().add(editor);
         group.getSecPermissions().add(admon);
         group.getSecPermissions().add(permission);
-        getSecGroup().saveOrUpdate(group);
+        getGroup().saveOrUpdate(group);
         assertEquals("Should be equals", 3, group.getSecPermissions().size());
     }
 

encuestame-persistence/src/test/java/org/encuestame/test/persistence/domain/TestHibernateDomains.java

         groups.setAccount(createUser());
         groups.getSecPermissions().add(createPermission("administrator"));
         groups.getProjects().add(createProject("TIC", "TIC", "TIC", createUser()));
-        getSecGroup().saveOrUpdate(groups);
+        getGroup().saveOrUpdate(groups);
         assertNotNull(groups.getGroupId());
     }
 
         final Permission permission = new Permission();
         permission.setPermission(EnMePermission.getPermissionString("ENCUESTAME_ADMIN"));
         permission.setPermissionDescription("Administrator of alls options");
-        permission.getSecGroups().add(createGroups("administrator"));
+        permission.getGroups().add(createGroups("administrator"));
         permission.getSecUserSecondaries().add(createSecondaryUser("juan carlos", createUser()));
         getSecPermissionDaoImp().saveOrUpdate(permission);
         assertNotNull(permission.getIdPermission());