1 package de.webman.acl.db; 2 3 import java.sql.ResultSet ; 4 import java.sql.SQLException ; 5 import com.teamkonzept.db.TKQuery; 6 import de.webman.acl.Policy; 7 import com.teamkonzept.webman.mainint.db.queries.oracle.helper.ConvertBigDecimal; 8 9 18 public class PolicyDBData 19 extends ObjectDBData 20 { 21 22 24 27 private Integer login = null; 28 29 32 private Integer role = null; 33 34 37 private Integer context = null; 38 39 42 private Integer type = null; 43 44 47 private Integer reference = null; 48 49 52 private String access = null; 53 54 55 57 68 public PolicyDBData (Integer id, 69 Integer login, 70 Integer role, 71 Integer context, 72 Integer type, 73 Integer reference, 74 String access) 75 { 76 super(id); 77 78 this.login = login; 79 this.role = role; 80 this.context = context; 81 this.type = type; 82 this.reference = reference; 83 this.access = access; 84 85 super.setIgnore(true); 86 } 87 88 93 public PolicyDBData (Policy policy) 94 { 95 super(policy); 96 97 this.login = policy.getLoginID(); 98 this.role = policy.getRoleID(); 99 this.context = policy.getContextID(); 100 this.type = policy.getObjectType(); 101 this.reference = policy.getObjectReference(); 102 this.access = policy.isAllowed() 103 ? PolicyDBInterface.MODE_ALLOW 104 : PolicyDBInterface.MODE_DENY; 105 } 106 107 108 110 115 public final ObjectDBInterface getDBInterface () 116 { 117 return PolicyDBInterface.getInstance(); 118 } 119 120 128 public void insertInitialIntoQuery (TKQuery query) 129 throws SQLException 130 { 131 super.insertInitialIntoQuery(query); 132 133 query.setQueryParams(LoginDBInterface.getInstance().getPrimaryKeyName(), this.login); 134 query.setQueryParams(RoleDBInterface.getInstance().getPrimaryKeyName(), this.role); 135 query.setQueryParams(ContextDBInterface.getInstance().getPrimaryKeyName(), this.context); 136 query.setQueryParams("OBJECT_TYPE", this.type); 137 query.setQueryParams("OBJECT_REFERENCE", this.reference); 138 query.setQueryParams("POLICY_ACCESS", this.access); 139 } 140 141 150 public void fill (ResultSet result) 151 throws SQLException 152 { 153 Object value = null; 154 155 this.login = new Integer (result.getInt(LoginDBInterface.getInstance().getPrimaryKeyName())); 156 this.role = new Integer (result.getInt(RoleDBInterface.getInstance().getPrimaryKeyName())); 157 this.context = new Integer (result.getInt(ContextDBInterface.getInstance().getPrimaryKeyName())); 158 159 value = result.getObject("OBJECT_TYPE"); 160 this.type = ConvertBigDecimal.getInteger(value); 163 164 value = result.getObject("OBJECT_REFERENCE"); 165 this.reference = ConvertBigDecimal.getInteger(value); 168 169 this.access = result.getString("POLICY_ACCESS"); 170 171 super.fill(result); 172 } 173 174 179 public final Integer getLogin () 180 { 181 return this.login; 182 } 183 184 189 public final Integer getRole () 190 { 191 return this.role; 192 } 193 194 199 public final Integer getContext () 200 { 201 return this.context; 202 } 203 204 209 public final Integer getObjectType () 210 { 211 return this.type; 212 } 213 214 219 public final Integer getObjectReference () 220 { 221 return this.reference; 222 } 223 224 230 public final boolean isAllowed () 231 { 232 return this.access != null && this.access.equals(PolicyDBInterface.MODE_ALLOW); 233 } 234 235 241 public final boolean isDenied () 242 { 243 return this.access != null && this.access.equals(PolicyDBInterface.MODE_DENY); 244 } 245 246 } 247 | Popular Tags |