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 com.teamkonzept.webman.mainint.WebmanExceptionHandler; 8 9 16 public class PropertyFactory 17 extends ObjectFactoryBase 18 implements ObjectFactory 19 { 20 21 23 25 28 private static PropertyFactory SINGLETON = null; 29 30 31 33 36 private PropertyFactory () 37 { 38 super(); 39 } 40 41 42 44 50 public static synchronized final PropertyFactory getInstance () 51 throws TKException 52 { 53 if (SINGLETON == null) 54 { 55 SINGLETON = new PropertyFactory(); 56 SINGLETON.configurationChanged(); 57 ConfigurationManager.getInstance() 58 .registerConfigurationListener(SINGLETON, 59 PROPERTY_GROUP_NAME); 60 } 61 62 return SINGLETON; 63 } 64 65 66 68 73 public final ObjectDBInterface getDBInterface () 74 { 75 return PropertyDBInterface.getInstance(); 76 } 77 78 84 public final ObjectDBData getDBData (Integer id) 85 { 86 return new PropertyDBData(id, null, null, null); 87 } 88 89 95 public final ObjectDBData getDBData (WMObject object) 96 { 97 return new PropertyDBData((Property) object); 98 } 99 100 106 public final WMObject buildObject (ObjectDBData data) 107 { 108 return new Property((PropertyDBData) data); 109 } 110 111 112 114 121 public final Property getProperty (Integer id) 122 throws TKException 123 { 124 return (Property) getObject(id); 125 } 126 127 133 public final TKVector getProperties () 134 throws TKException 135 { 136 return getObjects(); 137 } 138 139 146 public final TKVector getProperties (Login login) 147 throws TKException 148 { 149 TKVector objects = null; 150 151 try 152 { 153 PropertyDBData data = new PropertyDBData((Integer ) null, null, null, null); 155 data.setQuery(PropertyDBInterface.WM_PROPERTY_SELECT_BY_LOGIN); 156 data.setPrototype(new ObjectCollectionDBData(LoginDBInterface.PRIMARY_KEY_NAME, 157 login.getID(), 158 PropertyDBInterface.PRIMARY_KEY_NAME, 159 null)); 160 161 objects = getObjects(getObjectIDs(data)); 163 } 164 catch (Exception x) 165 { 166 throw WebmanExceptionHandler.getException(x); 167 } 168 169 return objects; 170 } 171 172 181 public final Property createProperty (Login login, 182 String name, 183 String value) 184 throws TKException 185 { 186 return (Property) createObject(new PropertyDBData(null, 187 login.getID(), 188 name, 189 value)); 190 } 191 192 198 public final void modifyProperty (Property property) 199 throws TKException 200 { 201 modifyObject(property); 202 } 203 204 210 public final void deleteProperty (Property property) 211 throws TKException 212 { 213 deleteObject(property); 214 } 215 216 } 217 | Popular Tags |