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 TaskFactory 18 extends ObjectFactoryBase 19 implements ObjectFactory 20 { 21 22 24 26 29 private static TaskFactory SINGLETON = null; 30 31 32 34 37 private TaskFactory () 38 { 39 super(); 40 } 41 42 43 45 51 public static synchronized final TaskFactory getInstance () 52 throws TKException 53 { 54 if (SINGLETON == null) 55 { 56 SINGLETON = new TaskFactory(); 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 TaskDBInterface.getInstance(); 77 } 78 79 85 public final ObjectDBData getDBData (Integer id) 86 { 87 return new TaskDBData(id, null, null); 88 } 89 90 96 public final ObjectDBData getDBData (WMObject object) 97 { 98 return new TaskDBData((Task) object); 99 } 100 101 107 public final WMObject buildObject (ObjectDBData data) 108 { 109 return new Task((TaskDBData) data); 110 } 111 112 113 115 122 public final Task getTask (Integer id) 123 throws TKException 124 { 125 return (Task) getObject(id); 126 } 127 128 134 public final TKVector getTasks () 135 throws TKException 136 { 137 return getObjects(); 138 } 139 140 147 public final TKVector getTasks (TKVector ids) 148 throws TKException 149 { 150 return getObjects(ids); 151 } 152 153 160 public final TKVector getTasks (Context context) 161 throws TKException 162 { 163 TKVector objects = null; 164 165 try 166 { 167 TaskDBData data = new TaskDBData((Integer ) null, null, context.getID()); 169 data.setQuery(TaskDBInterface.WM_TASK_SELECT_BY_CONTEXT); 170 data.setPrototype(new ObjectCollectionDBData(null, 171 null, 172 TaskDBInterface.PRIMARY_KEY_NAME, 173 null)); 174 175 objects = getObjects(getObjectIDs(data)); 177 } 178 catch (Exception x) 179 { 180 throw WebmanExceptionHandler.getException(x); 181 } 182 183 return objects; 184 } 185 186 193 public final TKVector getTasks (Action action) 194 throws TKException 195 { 196 TKVector objects = null; 197 198 try 199 { 200 TaskDBData data = new TaskDBData((Integer ) null, null, null); 202 data.setQuery(TaskDBInterface.WM_TASK_ACTION_SELECT_BY_ACTION); 203 data.setPrototype(new ObjectCollectionDBData(ActionDBInterface.PRIMARY_KEY_NAME, 204 action.getID(), 205 TaskDBInterface.PRIMARY_KEY_NAME, 206 null)); 207 208 objects = getObjects(getObjectIDs(data)); 210 } 211 catch (Exception x) 212 { 213 throw WebmanExceptionHandler.getException(x); 214 } 215 216 return objects; 217 } 218 219 227 public final Task createTask (String name, 228 Context context) 229 throws TKException 230 { 231 return (Task) createObject(new TaskDBData(null, 232 name, 233 context.getID())); 234 } 235 236 242 public final void modifyTask (Task task) 243 throws TKException 244 { 245 if (task.isModifiedAssociations()) 246 { 247 ResolverFactory.getInstance().removeResolvers(); 248 } 249 250 modifyObject(task); 251 } 252 253 259 public final void deleteTask (Task task) 260 throws TKException 261 { 262 ResolverFactory.getInstance().removeResolvers(); 263 264 deleteObject(task); 265 } 266 267 } 268 | Popular Tags |