1 28 package de.nava.informa.utils.manager.hibernate; 29 30 import de.nava.informa.utils.manager.PersistenceManagerException; 31 import de.nava.informa.core.ChannelGroupIF; 32 33 import java.util.Map ; 34 import java.util.HashMap ; 35 36 65 public class PersistenceManager extends NonCachingPersistenceManager { 66 67 private Map groups = new HashMap (); 68 private boolean groupsRead = false; 69 70 77 public ChannelGroupIF createGroup(String title) throws PersistenceManagerException { 78 79 ChannelGroupIF group = super.createGroup(title); 81 82 groups.put(new Long (group.getId()), group); 84 85 return group; 86 } 87 88 94 public void deleteGroup(ChannelGroupIF group) throws PersistenceManagerException { 95 96 long groupId = group.getId(); 98 super.deleteGroup(group); 99 100 if (groupId > -1) { 102 groups.remove(new Long (groupId)); 103 } 104 } 105 106 112 public ChannelGroupIF[] getGroups() throws PersistenceManagerException { 113 114 if (!groupsRead) { 122 final ChannelGroupIF[] hibernateGroups = super.getGroups(); 123 for (int i = 0; i < hibernateGroups.length; i++) { 124 final ChannelGroupIF hibernateGroup = hibernateGroups[i]; 125 final Long groupId = new Long (hibernateGroup.getId()); 126 if (!groups.containsKey(groupId)) { 127 groups.put(groupId, hibernateGroup); 128 } 129 } 130 131 groupsRead = true; 133 } 134 135 return (ChannelGroupIF[]) groups.values().toArray(new ChannelGroupIF[0]); 136 } 137 } 138 | Popular Tags |