Author: solomax
Date: Thu Sep 22 17:03:47 2016
New Revision: 1761979

URL: http://svn.apache.org/viewvc?rev=1761979&view=rev
Log:
[OPENMEETINGS-1472] user is deleted as expected

Modified:
    
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
    
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
    
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
    
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
    
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
    
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
    
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
    
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
    
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
 Thu Sep 22 17:03:47 2016
@@ -112,16 +112,14 @@ public class GroupDao implements IDataPr
        }
 
        @Override
-       public void delete(Group entity, Long userId) {
-               em.createNamedQuery("deleteUsersFromGroup")
-                       .setParameter("id", entity.getId())
-                       .executeUpdate();
+       public void delete(Group g, Long userId) {
+               
em.createNamedQuery("deleteGroupUsersByGroup").setParameter("id", 
g.getId()).executeUpdate();
 
-               entity.setDeleted(true);
+               g.setDeleted(true);
                if (userId != null) {
-                       entity.setUpdatedby(userId);
+                       g.setUpdatedby(userId);
                }
 
-               em.merge(entity);
+               em.merge(g);
        }
 }

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 Thu Sep 22 17:03:47 2016
@@ -24,6 +24,7 @@ import static org.apache.openmeetings.ut
 
 import java.io.UnsupportedEncodingException;
 import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
@@ -287,10 +288,7 @@ public class UserDao implements IDataPro
        @Override
        public void delete(User u, Long userId) {
                if (u != null && u.getId() != null) {
-                       for (GroupUser ou : u.getGroupUsers()){
-                               em.remove(ou);
-                       }
-                       u.setGroupUsers(null);
+                       u.setGroupUsers(new ArrayList<>());
                        u.setDeleted(true);
                        u.setUpdated(new Date());
                        u.setSipUser(null);
@@ -298,7 +296,6 @@ public class UserDao implements IDataPro
                        if (adr != null) {
                                adr.setDeleted(true);
                        }
-
                        update(u, userId);
                }
        }
@@ -685,8 +682,10 @@ public class UserDao implements IDataPro
                }
                u.setDeleted(false);
                u.setPictureuri(pictureuri);
-               for (Long grpId : groupIds) {
-                       u.getGroupUsers().add(new 
GroupUser(groupDao.get(grpId), u));
+               if (groupIds != null) {
+                       for (Long grpId : groupIds) {
+                               u.getGroupUsers().add(new 
GroupUser(groupDao.get(grpId), u));
+                       }
                }
                
                return update(u, null);

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
 Thu Sep 22 17:03:47 2016
@@ -39,7 +39,7 @@ import org.simpleframework.xml.Root;
 
 @Entity
 @NamedQueries({
-       @NamedQuery(name="deleteUsersFromGroup", query="DELETE FROM GroupUser c 
WHERE c.group.id = :id")
+       @NamedQuery(name="deleteGroupUsersByGroup", query="DELETE FROM 
GroupUser gu WHERE gu.group.id = :id")
        , @NamedQuery(name="countGroupUsers", query="SELECT COUNT(c) FROM 
GroupUser c WHERE c.group.id = :id")
        , @NamedQuery(name="getGroupUsersById", query="SELECT c FROM GroupUser 
c WHERE c.id = :id")
        , @NamedQuery(name="getGroupUsersByGroupId", query="SELECT c FROM 
GroupUser c WHERE c.group.id = :id")

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
 Thu Sep 22 17:03:47 2016
@@ -112,16 +112,14 @@ public class GroupDao implements IDataPr
        }
 
        @Override
-       public void delete(Group entity, Long userId) {
-               em.createNamedQuery("deleteUsersFromGroup")
-                       .setParameter("id", entity.getId())
-                       .executeUpdate();
+       public void delete(Group g, Long userId) {
+               
em.createNamedQuery("deleteGroupUsersByGroup").setParameter("id", 
g.getId()).executeUpdate();
 
-               entity.setDeleted(true);
+               g.setDeleted(true);
                if (userId != null) {
-                       entity.setUpdatedby(userId);
+                       g.setUpdatedby(userId);
                }
 
-               em.merge(entity);
+               em.merge(g);
        }
 }

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 Thu Sep 22 17:03:47 2016
@@ -24,6 +24,7 @@ import static org.apache.openmeetings.ut
 
 import java.io.UnsupportedEncodingException;
 import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
@@ -287,10 +288,7 @@ public class UserDao implements IDataPro
        @Override
        public void delete(User u, Long userId) {
                if (u != null && u.getId() != null) {
-                       for (GroupUser ou : u.getGroupUsers()){
-                               em.remove(ou);
-                       }
-                       u.setGroupUsers(null);
+                       u.setGroupUsers(new ArrayList<>());
                        u.setDeleted(true);
                        u.setUpdated(new Date());
                        u.setSipUser(null);
@@ -298,7 +296,6 @@ public class UserDao implements IDataPro
                        if (adr != null) {
                                adr.setDeleted(true);
                        }
-
                        update(u, userId);
                }
        }

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
 Thu Sep 22 17:03:47 2016
@@ -39,7 +39,7 @@ import org.simpleframework.xml.Root;
 
 @Entity
 @NamedQueries({
-       @NamedQuery(name="deleteUsersFromGroup", query="DELETE FROM GroupUser c 
WHERE c.group.id = :id")
+       @NamedQuery(name="deleteGroupUsersByGroup", query="DELETE FROM 
GroupUser gu WHERE gu.group.id = :id")
        , @NamedQuery(name="countGroupUsers", query="SELECT COUNT(c) FROM 
GroupUser c WHERE c.group.id = :id")
        , @NamedQuery(name="getGroupUsersById", query="SELECT c FROM GroupUser 
c WHERE c.id = :id")
        , @NamedQuery(name="getGroupUsersByGroupId", query="SELECT c FROM 
GroupUser c WHERE c.group.id = :id")

Modified: 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
 Thu Sep 22 17:03:47 2016
@@ -112,16 +112,14 @@ public class GroupDao implements IDataPr
        }
 
        @Override
-       public void delete(Group entity, Long userId) {
-               em.createNamedQuery("deleteUsersFromGroup")
-                       .setParameter("id", entity.getId())
-                       .executeUpdate();
+       public void delete(Group g, Long userId) {
+               
em.createNamedQuery("deleteGroupUsersByGroup").setParameter("id", 
g.getId()).executeUpdate();
 
-               entity.setDeleted(true);
+               g.setDeleted(true);
                if (userId != null) {
-                       entity.setUpdatedby(userId);
+                       g.setUpdatedby(userId);
                }
 
-               em.merge(entity);
+               em.merge(g);
        }
 }

Modified: 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 Thu Sep 22 17:03:47 2016
@@ -24,6 +24,7 @@ import static org.apache.openmeetings.ut
 
 import java.io.UnsupportedEncodingException;
 import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
@@ -287,10 +288,7 @@ public class UserDao implements IDataPro
        @Override
        public void delete(User u, Long userId) {
                if (u != null && u.getId() != null) {
-                       for (GroupUser ou : u.getGroupUsers()){
-                               em.remove(ou);
-                       }
-                       u.setGroupUsers(null);
+                       u.setGroupUsers(new ArrayList<>());
                        u.setDeleted(true);
                        u.setUpdated(new Date());
                        u.setSipUser(null);
@@ -298,7 +296,6 @@ public class UserDao implements IDataPro
                        if (adr != null) {
                                adr.setDeleted(true);
                        }
-
                        update(u, userId);
                }
        }

Modified: 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java?rev=1761979&r1=1761978&r2=1761979&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/GroupUser.java
 Thu Sep 22 17:03:47 2016
@@ -39,7 +39,7 @@ import org.simpleframework.xml.Root;
 
 @Entity
 @NamedQueries({
-       @NamedQuery(name="deleteUsersFromGroup", query="DELETE FROM GroupUser c 
WHERE c.group.id = :id")
+       @NamedQuery(name="deleteGroupUsersByGroup", query="DELETE FROM 
GroupUser gu WHERE gu.group.id = :id")
        , @NamedQuery(name="countGroupUsers", query="SELECT COUNT(c) FROM 
GroupUser c WHERE c.group.id = :id")
        , @NamedQuery(name="getGroupUsersById", query="SELECT c FROM GroupUser 
c WHERE c.id = :id")
        , @NamedQuery(name="getGroupUsersByGroupId", query="SELECT c FROM 
GroupUser c WHERE c.group.id = :id")


Reply via email to