Update of 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao
In directory 
james.mmbase.org:/tmp/cvs-serv15966/community/src/java/com/finalist/cmsc/services/community/dao

Modified Files:
        RoleDAO.java UserDAOImpl.java RoleDAOImpl.java 
        GroupUserRoleDAOImpl.java UserDAO.java GroupUserRoleDAO.java 
        GroupDAO.java GroupDAOImpl.java 
Added Files:
        GenericDAO.java DAO.java ModulePrefDAOImpl.java 
        ModulePrefDAO.java 
Removed Files:
        NewsPrefDAO.java NewsPrefDAOImpl.java 
Log Message:
CMSC-211 Added generic Hibernate function for extra modules


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao
See also: http://www.mmbase.org/jira/browse/CMSC-211


GenericDAO.java is new



DAO.java is new



ModulePrefDAOImpl.java is new



ModulePrefDAO.java is new



Index: RoleDAO.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao/RoleDAO.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- RoleDAO.java        26 Nov 2007 11:42:01 -0000      1.1
+++ RoleDAO.java        16 Jan 2008 12:16:10 -0000      1.2
@@ -1,38 +1,7 @@
 package com.finalist.cmsc.services.community.dao;
 
-import java.util.List;
-import java.util.Set;
-
 import com.finalist.cmsc.services.community.data.Role;
 
-public interface RoleDAO {
-
-   /**
-    * Inserts a Client into the persistence mechanism, returning a primary key
-    * used to identify it.
-    * 
-    * @param Client
-    *           The client to persist.
-    * @return a primary key if inserted, null on error
-    */
-   public Role insertRole(Role role) throws Exception;
-
-
-   public Role getRole(final Long id);
-
-
-   /**
-    * Deletes a Client from the persistence mechanism.
-    * 
-    * @param primaryKey
-    *           The primary key of the client to delete.
-    * @return true if the client is deleted, false on error
-    */
-   public void deleteRole(Role role);
-
-
-   public void saveRecords(final Set<Role> records) throws Exception;
-
+public interface RoleDAO extends DAO<Role>{
 
-   public void updateRole(Role role) throws Exception;
 }


Index: UserDAOImpl.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao/UserDAOImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UserDAOImpl.java    5 Dec 2007 18:07:53 -0000       1.2
+++ UserDAOImpl.java    16 Jan 2008 12:16:10 -0000      1.3
@@ -1,98 +1,10 @@
 package com.finalist.cmsc.services.community.dao;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.hibernate.FlushMode;
-import org.hibernate.criterion.DetachedCriteria;
-import org.hibernate.criterion.Restrictions;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-import org.springframework.transaction.annotation.Transactional;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.store.Directory;
-
 import com.finalist.cmsc.services.community.data.User;
 
-public class UserDAOImpl extends HibernateDaoSupport implements UserDAO {
-   protected final Log log = LogFactory.getLog(UserDAOImpl.class);
-
-   private Directory luceneDirectory;
-
-
-   /**
-    * Sets directory of type Directory
-    * 
-    * @param directory
-    *           The directory to set.
-    */
-   public void setLuceneDirectory(Directory luceneDirectory) {
-      this.luceneDirectory = luceneDirectory;
-   }
-
-
-   @Transactional(readOnly = false)
-   public User insertUser(User user) throws Exception {
-      Set set = new HashSet();
-      set.add(user);
-      saveRecords(set);
-      return user;
-   }
-
-
-   @Transactional(readOnly = false)
-   public User getUser(String userId) {
-      DetachedCriteria criteria = 
DetachedCriteria.forClass(getPersistentClass());
-      criteria.add(Restrictions.eq("userId", userId));
-      List resultList = getHibernateTemplate().findByCriteria(criteria);
-      return (resultList.size() != 1) ? null : (User) resultList.get(0);
-   }
-
-
-   @Transactional(readOnly = false)
-   public void saveRecords(final Set<User> records) throws Exception {
-      getSession().setFlushMode(FlushMode.AUTO);
-      getHibernateTemplate().saveOrUpdateAll(records);
-      getHibernateTemplate().flush();
-   }
-
-
-   public void deleteUser(User user) {
-      removeObject(user);
-      getSession().flush();
-   }
-
-
-   @Transactional(readOnly = false)
-   public void removeObject(final Long id) {
-      Object record = getHibernateTemplate().load(getPersistentClass(), id);
-      getHibernateTemplate().delete(record);
-   }
-
-
-   @Transactional(readOnly = false)
-   public void removeObject(final Object o) {
-      getHibernateTemplate().delete(o);
-      getSession().flush();
-   }
-
-
-   protected Class getPersistentClass() {
-      return User.class;
-   }
-
-
-   public void updateUser(User user) throws Exception {
-      Set<User> set = new HashSet<User>();
-      set.add(user);
-      saveRecords(set);
-   }
+public class UserDAOImpl extends GenericDAO<User> implements UserDAO {
    
-   public List<String> getAllUsers(){
-      DetachedCriteria criteria = 
DetachedCriteria.forClass(getPersistentClass());
-      List<String> resultList = 
getHibernateTemplate().findByCriteria(criteria);
-      return resultList;
+   public UserDAOImpl() {
+      super(User.class);
    }
 }


Index: RoleDAOImpl.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao/RoleDAOImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- RoleDAOImpl.java    26 Nov 2007 11:42:01 -0000      1.1
+++ RoleDAOImpl.java    16 Jan 2008 12:16:10 -0000      1.2
@@ -1,93 +1,10 @@
 package com.finalist.cmsc.services.community.dao;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.hibernate.FlushMode;
-import org.hibernate.criterion.DetachedCriteria;
-import org.hibernate.criterion.Restrictions;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-import org.springframework.transaction.annotation.Transactional;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.store.Directory;
-
 import com.finalist.cmsc.services.community.data.Role;
 
-public class RoleDAOImpl extends HibernateDaoSupport implements RoleDAO {
-
-   protected final Log log = LogFactory.getLog(RoleDAOImpl.class);
-
-   private Directory luceneDirectory;
-
-
-   /**
-    * Sets directory of type Directory
-    * 
-    * @param directory
-    *           The directory to set.
-    */
-   public void setLuceneDirectory(Directory luceneDirectory) {
-      this.luceneDirectory = luceneDirectory;
-   }
-
-
-   @Transactional(readOnly = false)
-   public Role insertRole(Role role) throws Exception {
-      Set set = new HashSet();
-      set.add(role);
-      saveRecords(set);
-      return role;
-   }
-
-
-   @Transactional(readOnly = false)
-   public Role getRole(final Long id) {
-      DetachedCriteria criteria = 
DetachedCriteria.forClass(getPersistentClass());
-      criteria.add(Restrictions.eq("id", id));
-      List resultList = getHibernateTemplate().findByCriteria(criteria);
-      return (resultList.size() != 1) ? null : (Role) resultList.get(0);
-   }
-
-
-   @Transactional(readOnly = false)
-   public void saveRecords(final Set<Role> records) throws Exception {
-      getSession().setFlushMode(FlushMode.AUTO);
-      getHibernateTemplate().saveOrUpdateAll(records);
-      getHibernateTemplate().flush();
-   }
-
-
-   public void deleteRole(Role role) {
-      removeObject(role);
-      getSession().flush();
-   }
-
-
-   @Transactional(readOnly = false)
-   public void removeObject(final Long id) {
-      Object record = getHibernateTemplate().load(getPersistentClass(), id);
-      getHibernateTemplate().delete(record);
-   }
-
-
-   @Transactional(readOnly = false)
-   public void removeObject(final Object o) {
-      getHibernateTemplate().delete(o);
-      getSession().flush();
-   }
-
-
-   protected Class getPersistentClass() {
-      return Role.class;
-   }
-
+public class RoleDAOImpl extends GenericDAO<Role> implements RoleDAO {
 
-   public void updateRole(Role role) throws Exception {
-      Set<Role> set = new HashSet<Role>();
-      set.add(role);
-      saveRecords(set);
+   public RoleDAOImpl() {
+      super(Role.class);
    }
 }


Index: GroupUserRoleDAOImpl.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao/GroupUserRoleDAOImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- GroupUserRoleDAOImpl.java   19 Dec 2007 13:16:29 -0000      1.1
+++ GroupUserRoleDAOImpl.java   16 Jan 2008 12:16:10 -0000      1.2
@@ -1,109 +1,10 @@
 package com.finalist.cmsc.services.community.dao;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.store.Directory;
-import org.hibernate.FlushMode;
-import org.hibernate.criterion.DetachedCriteria;
-import org.hibernate.criterion.Restrictions;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-import org.springframework.transaction.annotation.Transactional;
-
 import com.finalist.cmsc.services.community.data.GroupUserRole;
 
-public class GroupUserRoleDAOImpl  extends HibernateDaoSupport implements 
GroupUserRoleDAO {
-
-   protected final Log log = LogFactory.getLog(GroupUserRoleDAOImpl.class);
-
-   private Directory luceneDirectory;
-
-
-   /**
-    * Sets directory of type Directory
-    * 
-    * @param directory
-    *           The directory to set.
-    */
-   public void setLuceneDirectory(Directory luceneDirectory) {
-      this.luceneDirectory = luceneDirectory;
-   }
-
-
-   @Transactional(readOnly = false)
-   public GroupUserRole insertGroupUserRole(GroupUserRole groupUserRole) 
throws Exception {
-      Set set = new HashSet();
-      set.add(groupUserRole);
-      saveRecords(set);
-      return groupUserRole;
-   }
-
-
-   @Transactional(readOnly = false)
-   public GroupUserRole getGroupUserRole(final Long id) {
-      DetachedCriteria criteria = 
DetachedCriteria.forClass(getPersistentClass());
-      criteria.add(Restrictions.eq("id", id));
-      List resultList = getHibernateTemplate().findByCriteria(criteria);
-      return (resultList.size() != 1) ? null : (GroupUserRole) 
resultList.get(0);
-   }
-   
-   @Transactional(readOnly = false)
-   public GroupUserRole getGroupUserRoleByUserId(String userName) {
-      DetachedCriteria criteria = 
DetachedCriteria.forClass(getPersistentClass());
-      criteria.add(Restrictions.eq("userId", userName));
-      List resultList = getHibernateTemplate().findByCriteria(criteria);
-      return (resultList.size() != 1) ? null : (GroupUserRole) 
resultList.get(0);
-   }
-   
-   @Transactional(readOnly = false)
-   public List getGroupUserRoleList(String userName) {
-      System.out.println("GroupUserRoleDAOImpl Ingevoerde user: " + userName);
-      DetachedCriteria criteria = 
DetachedCriteria.forClass(getPersistentClass());
-      criteria.add(Restrictions.eq("userId", userName));
-      List resultList = (List)getHibernateTemplate().findByCriteria(criteria);
-      return resultList;
-   }
-
-
-   @Transactional(readOnly = false)
-   public void saveRecords(final Set<GroupUserRole> records) throws Exception {
-      getSession().setFlushMode(FlushMode.AUTO);
-      getHibernateTemplate().saveOrUpdateAll(records);
-      getHibernateTemplate().flush();
-   }
-
-
-   public void deleteGroupUserRole(GroupUserRole groupUserRole) {
-      removeObject(groupUserRole);
-      getSession().flush();
-   }
-
-
-   @Transactional(readOnly = false)
-   public void removeObject(final Long id) {
-      Object record = getHibernateTemplate().load(getPersistentClass(), id);
-      getHibernateTemplate().delete(record);
-   }
-
-
-   @Transactional(readOnly = false)
-   public void removeObject(final Object o) {
-      getHibernateTemplate().delete(o);
-      getSession().flush();
-   }
-
-
-   protected Class getPersistentClass() {
-      return GroupUserRole.class;
-   }
-
+public class GroupUserRoleDAOImpl  extends GenericDAO<GroupUserRole> 
implements GroupUserRoleDAO {
 
-   public void updateGroupUserRole(GroupUserRole groupUserRole) throws 
Exception {
-      Set<GroupUserRole> set = new HashSet<GroupUserRole>();
-      set.add(groupUserRole);
-      saveRecords(set);
+   public GroupUserRoleDAOImpl() {
+      super(GroupUserRole.class);
    }
 }


Index: UserDAO.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao/UserDAO.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- UserDAO.java        5 Dec 2007 18:07:53 -0000       1.2
+++ UserDAO.java        16 Jan 2008 12:16:10 -0000      1.3
@@ -1,40 +1,8 @@
 package com.finalist.cmsc.services.community.dao;
 
-import java.util.List;
-import java.util.Set;
-
 import com.finalist.cmsc.services.community.data.User;
 
-public interface UserDAO {
-
-   /**
-    * Inserts a Client into the persistence mechanism, returning a primary key
-    * used to identify it.
-    * 
-    * @param Client
-    *           The client to persist.
-    * @return a primary key if inserted, null on error
-    */
-   public User insertUser(User user) throws Exception;
-
-
-   public User getUser(String userId);
-   
-   public List<String> getAllUsers();
-
-
-   /**
-    * Deletes a Client from the persistence mechanism.
-    * 
-    * @param primaryKey
-    *           The primary key of the client to delete.
-    * @return true if the client is deleted, false on error
-    */
-   public void deleteUser(User user);
-
-
-   public void saveRecords(final Set<User> records) throws Exception;
+public interface UserDAO extends DAO<User>{
 
 
-   public void updateUser(User user) throws Exception;
 }


Index: GroupUserRoleDAO.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao/GroupUserRoleDAO.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- GroupUserRoleDAO.java       19 Dec 2007 13:16:29 -0000      1.1
+++ GroupUserRoleDAO.java       16 Jan 2008 12:16:10 -0000      1.2
@@ -1,42 +1,7 @@
 package com.finalist.cmsc.services.community.dao;
 
-import java.util.*;
-
-import org.springframework.transaction.annotation.Transactional;
-
 import com.finalist.cmsc.services.community.data.GroupUserRole;
 
-public interface GroupUserRoleDAO {
-  
-   /**
-    * Inserts a Client into the persistence mechanism, returning a primary key
-    * used to identify it.
-    * 
-    * @param Client
-    *           The client to persist.
-    * @return a primary key if inserted, null on error
-    */
-   public GroupUserRole insertGroupUserRole(GroupUserRole groupUserRole) 
throws Exception;
-
-
-   public GroupUserRole getGroupUserRole(final Long id);
-   
-   public GroupUserRole getGroupUserRoleByUserId(String userId);
-   
-   public List getGroupUserRoleList(String userId);
-
-   /**
-    * Deletes a Client from the persistence mechanism.
-    * 
-    * @param primaryKey
-    *           The primary key of the client to delete.
-    * @return true if the client is deleted, false on error
-    */
-   public void deleteGroupUserRole(GroupUserRole groupUserRole);
-
-
-   public void saveRecords(final Set<GroupUserRole> records) throws Exception;
-
+public interface GroupUserRoleDAO extends DAO<GroupUserRole>{
 
-   public void updateGroupUserRole(GroupUserRole groupUserRole) throws 
Exception;
 }


Index: GroupDAO.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao/GroupDAO.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- GroupDAO.java       26 Nov 2007 11:42:01 -0000      1.1
+++ GroupDAO.java       16 Jan 2008 12:16:10 -0000      1.2
@@ -1,38 +1,7 @@
 package com.finalist.cmsc.services.community.dao;
 
-import java.util.List;
-import java.util.Set;
-
 import com.finalist.cmsc.services.community.data.Group;
 
-public interface GroupDAO {
-
-   /**
-    * Inserts a Client into the persistence mechanism, returning a primary key
-    * used to identify it.
-    * 
-    * @param Client
-    *           The client to persist.
-    * @return a primary key if inserted, null on error
-    */
-   public Group insertGroup(Group group) throws Exception;
-
-
-   public Group getGroup(final Long id);
-
-
-   /**
-    * Deletes a Client from the persistence mechanism.
-    * 
-    * @param primaryKey
-    *           The primary key of the client to delete.
-    * @return true if the client is deleted, false on error
-    */
-   public void deleteGroup(Group group);
-
-
-   public void saveRecords(final Set<Group> records) throws Exception;
-
+public interface GroupDAO extends DAO<Group>{
 
-   public void updateGroup(Group group) throws Exception;
 }


Index: GroupDAOImpl.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Modules/community/src/java/com/finalist/cmsc/services/community/dao/GroupDAOImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- GroupDAOImpl.java   26 Nov 2007 11:42:01 -0000      1.1
+++ GroupDAOImpl.java   16 Jan 2008 12:16:10 -0000      1.2
@@ -1,93 +1,10 @@
 package com.finalist.cmsc.services.community.dao;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.hibernate.FlushMode;
-import org.hibernate.criterion.DetachedCriteria;
-import org.hibernate.criterion.Restrictions;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-import org.springframework.transaction.annotation.Transactional;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.store.Directory;
-
 import com.finalist.cmsc.services.community.data.Group;
 
-public class GroupDAOImpl extends HibernateDaoSupport implements GroupDAO {
-
-   protected final Log log = LogFactory.getLog(GroupDAOImpl.class);
-
-   private Directory luceneDirectory;
-
-
-   /**
-    * Sets directory of type Directory
-    * 
-    * @param directory
-    *           The directory to set.
-    */
-   public void setLuceneDirectory(Directory luceneDirectory) {
-      this.luceneDirectory = luceneDirectory;
-   }
-
-
-   @Transactional(readOnly = false)
-   public Group insertGroup(Group group) throws Exception {
-      Set set = new HashSet();
-      set.add(group);
-      saveRecords(set);
-      return group;
-   }
-
-
-   @Transactional(readOnly = false)
-   public Group getGroup(final Long id) {
-      DetachedCriteria criteria = 
DetachedCriteria.forClass(getPersistentClass());
-      criteria.add(Restrictions.eq("id", id));
-      List resultList = getHibernateTemplate().findByCriteria(criteria);
-      return (resultList.size() != 1) ? null : (Group) resultList.get(0);
-   }
-
-
-   @Transactional(readOnly = false)
-   public void saveRecords(final Set<Group> records) throws Exception {
-      getSession().setFlushMode(FlushMode.AUTO);
-      getHibernateTemplate().saveOrUpdateAll(records);
-      getHibernateTemplate().flush();
-   }
-
-
-   public void deleteGroup(Group group) {
-      removeObject(group);
-      getSession().flush();
-   }
-
-
-   @Transactional(readOnly = false)
-   public void removeObject(final Long id) {
-      Object record = getHibernateTemplate().load(getPersistentClass(), id);
-      getHibernateTemplate().delete(record);
-   }
-
-
-   @Transactional(readOnly = false)
-   public void removeObject(final Object o) {
-      getHibernateTemplate().delete(o);
-      getSession().flush();
-   }
-
-
-   protected Class getPersistentClass() {
-      return Group.class;
-   }
-
+public class GroupDAOImpl extends GenericDAO<Group> implements GroupDAO {
 
-   public void updateGroup(Group group) throws Exception {
-      Set<Group> set = new HashSet<Group>();
-      set.add(group);
-      saveRecords(set);
+   public GroupDAOImpl() {
+      super(Group.class);
    }
 }




_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to