1 package de.webman.acl; 2 3 import com.teamkonzept.lib.ConfigurationManager; 4 import com.teamkonzept.lib.TKException; 5 import com.teamkonzept.lib.TKVector; 6 import de.webman.acl.db.*; 7 import de.webman.acl.resolver.ResolverFactory; 8 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 9 10 17 public class RoleFactory 18 extends ObjectFactoryBase 19 implements ObjectFactory 20 { 21 22 24 26 29 private static RoleFactory SINGLETON = null; 30 31 32 34 37 private RoleFactory () 38 { 39 super(); 40 } 41 42 43 45 51 public static synchronized final RoleFactory getInstance () 52 throws TKException 53 { 54 if (SINGLETON == null) 55 { 56 SINGLETON = new RoleFactory(); 57 SINGLETON.configurationChanged(); 58 ConfigurationManager.getInstance() 59 .registerConfigurationListener(SINGLETON, 60 PROPERTY_GROUP_NAME); 61 } 62 63 return SINGLETON; 64 } 65 66 67 69 74 public final ObjectDBInterface getDBInterface () 75 { 76 return RoleDBInterface.getInstance(); 77 } 78 79 85 public final ObjectDBData getDBData (Integer id) 86 { 87 return new RoleDBData(id, null); 88 } 89 90 96 public final ObjectDBData getDBData (WMObject object) 97 { 98 return new RoleDBData((Role) object); 99 } 100 101 107 public final WMObject buildObject (ObjectDBData data) 108 { 109 return new Role((RoleDBData) data); 110 } 111 112 113 115 122 public final Role getRole (Integer id) 123 throws TKException 124 { 125 return (Role) getObject(id); 126 } 127 128 134 public final TKVector getRoles () 135 throws TKException 136 { 137 return getObjects(); 138 } 139 140 147 public final TKVector getRoles (Task task) 148 throws TKException 149 { 150 TKVector objects = null; 151 152 try 153 { 154 RoleDBData data = new RoleDBData((Integer ) null, null); 156 data.setQuery(RoleDBInterface.WM_ROLE_TASK_SELECT_BY_TASK); 157 data.setPrototype(new ObjectCollectionDBData(TaskDBInterface.PRIMARY_KEY_NAME, 158 task.getID(), 159 RoleDBInterface.PRIMARY_KEY_NAME, 160 null)); 161 162 objects = getObjects(getObjectIDs(data)); 164 } 165 catch (Exception x) 166 { 167 throw WebmanExceptionHandler.getException(x); 168 } 169 170 return objects; 171 } 172 173 180 public final Role createRole (String name) 181 throws TKException 182 { 183 return (Role) createObject(new RoleDBData(null, 184 name)); 185 } 186 187 193 public final void modifyRole (Role role) 194 throws TKException 195 { 196 if (role.isModifiedAssociations()) 197 { 198 ResolverFactory.getInstance().removeResolvers(); 199 } 200 201 modifyObject(role); 202 } 203 204 210 public final void deleteRole (Role role) 211 throws TKException 212 { 213 ResolverFactory.getInstance().removeResolvers(); 214 215 deleteObject(role); 216 } 217 218 } 219 | Popular Tags |