1 28 package com.genimen.djeneric.repository; 29 30 import com.genimen.djeneric.repository.exceptions.DjenericException; 31 32 45 public abstract class DjContext 46 { 47 protected final static long NOT_YET_PERSISTED = -1; 48 49 56 public abstract void delete(DjSession session) throws DjenericException; 57 58 65 public abstract void deleteContents(DjSession session) throws DjenericException; 66 67 73 public abstract void reload(DjSession session) throws DjenericException; 74 75 82 public abstract void persist(DjSession session) throws DjenericException; 83 84 91 public abstract void removeAllUserAssociations(DjSession session) throws DjenericException; 92 93 101 public abstract DjUserContextAssociation[] getUsers(DjSession session) throws DjenericException; 102 103 105 long _id; 106 String _code = ""; 107 String _name = ""; 108 DjPersistenceManager _mgr; 109 110 115 protected DjContext(DjPersistenceManager mgr) 116 117 { 118 _id = NOT_YET_PERSISTED; 119 _mgr = mgr; 120 } 121 122 130 protected DjContext(DjPersistenceManager mgr, long id, String code, String name) 131 { 132 _id = id; 133 _code = code; 134 _name = name; 135 _mgr = mgr; 136 } 137 138 public DjPersistenceManager getPersistenceManager() 139 { 140 return _mgr; 141 } 142 143 148 public long getId() 149 { 150 return _id; 151 } 152 153 159 protected void setId(long id) 160 { 161 _id = id; 162 } 163 164 169 public String getName() 170 { 171 return _name; 172 } 173 174 179 public void setName(String name) 180 { 181 _name = name; 182 } 183 184 189 public String getCode() 190 { 191 return _code; 192 } 193 194 199 public void setCode(String code) 200 { 201 _code = code.toLowerCase(); 202 } 203 204 210 public boolean equals(Object obj) 211 { 212 if (!(obj instanceof DjContext)) return false; 213 DjContext r = (DjContext) obj; 214 215 return getId() == r.getId(); 216 } 217 218 public int hashCode() 219 { 220 return (int) getId(); 221 } 222 223 228 public String toString() 229 { 230 return getName(); 231 } 232 233 } | Popular Tags |