1 package de.fhdw.wtf.context.core;
2
3 import java.math.BigInteger;
4 import java.util.Collection;
5 import java.util.Date;
6
7 import de.fhdw.wtf.context.exception.ManipulationDuringRevisionException;
8 import de.fhdw.wtf.persistence.exception.PersistenceException;
9 import de.fhdw.wtf.persistence.exception.RuntimePersistenceException;
10 import de.fhdw.wtf.persistence.facade.ObjectFacade;
11 import de.fhdw.wtf.persistence.facade.TypeManager;
12 import de.fhdw.wtf.persistence.meta.Link;
13 import de.fhdw.wtf.persistence.meta.MapLink;
14 import de.fhdw.wtf.persistence.meta.Object;
15 import de.fhdw.wtf.persistence.meta.UnidirectionalLink;
16 import de.fhdw.wtf.persistence.meta.UserObject;
17 import de.fhdw.wtf.persistence.utils.Tuple;
18
19
20
21
22
23
24 public class RevisionContext extends ContextWithDatabaseAccess {
25
26
27
28
29 private final ManipulationDuringRevisionException exception;
30
31
32
33
34 private final Date date;
35
36
37
38
39
40
41
42
43
44 public RevisionContext(final ObjectFacade objectFacade, final Date date) {
45 super(objectFacade);
46 this.date = new Date(date.getTime());
47 this.exception = new ManipulationDuringRevisionException();
48 }
49
50 @Override
51 public Collection<UserObject> find(final String associationName, final String value) {
52 try {
53 return this.objectFacade.find(
54 this.typeManager.getUnidirectionalAssociationForName(associationName),
55 value,
56 this.date);
57 } catch (final PersistenceException e) {
58 Logger.getInstance().log(e);
59 throw new RuntimePersistenceException();
60 }
61 }
62
63 @Override
64 public Collection<UserObject> find(final String associationName, final BigInteger value) {
65 try {
66 return this.objectFacade.find(
67 this.typeManager.getUnidirectionalAssociationForName(associationName),
68 value,
69 this.date);
70 } catch (final PersistenceException e) {
71 Logger.getInstance().log(e);
72 throw new RuntimePersistenceException();
73 }
74 }
75
76 @Override
77 public Collection<Tuple<UnidirectionalLink, UserObject>> inverseGet(final String associationName,
78 final UserObject object) {
79 try {
80 return this.objectFacade.inverseGet(
81 object,
82 this.typeManager.getUnidirectionalAssociationForName(associationName),
83 this.date);
84 } catch (final PersistenceException e) {
85 Logger.getInstance().log(e);
86 throw new RuntimePersistenceException();
87 }
88 }
89
90 @Override
91 public Collection<Tuple<UnidirectionalLink, Object>> get(final UserObject object, final String associationName) {
92 try {
93 return this.objectFacade.get(
94 object,
95 this.typeManager.getUnidirectionalAssociationForName(associationName),
96 this.date);
97 } catch (final PersistenceException e) {
98 Logger.getInstance().log(e);
99 throw new RuntimePersistenceException();
100 }
101 }
102
103 @Override
104 public Collection<Tuple<MapLink, Object>> get(final UserObject object,
105 final String associationName,
106 final String key) {
107
108 throw new RuntimePersistenceException();
109
110
111
112
113 }
114
115 @Override
116 public Collection<Tuple<MapLink, Object>> get(final UserObject object,
117 final String associationName,
118 final BigInteger key) {
119
120 throw new RuntimePersistenceException();
121
122
123
124
125 }
126
127 @Override
128 public Collection<Tuple<MapLink, Object>> get(final UserObject object,
129 final String associationName,
130 final UserObject key) {
131
132 throw new RuntimePersistenceException();
133
134
135
136
137 }
138
139 @Override
140 public UserObject create(final String typeName) {
141 Logger.getInstance().logError(this.exception.getMessage());
142 throw this.exception;
143 }
144
145 @Override
146 public UnidirectionalLink set(final UserObject object, final String associationName, final String val) {
147 Logger.getInstance().logError(this.exception.getMessage());
148 throw this.exception;
149 }
150
151 @Override
152 public UnidirectionalLink set(final UserObject object, final String associationName, final BigInteger val) {
153 Logger.getInstance().logError(this.exception.getMessage());
154 throw this.exception;
155 }
156
157 @Override
158 public UnidirectionalLink set(final UserObject object, final String associationName, final UserObject target) {
159 Logger.getInstance().logError(this.exception.getMessage());
160 throw this.exception;
161 }
162
163 @Override
164 public MapLink put(final UserObject owner, final String associationName, final UserObject target, final String key) {
165 Logger.getInstance().logError(this.exception.getMessage());
166 throw this.exception;
167 }
168
169 @Override
170 public MapLink put(final UserObject owner, final String associationName, final BigInteger target, final String key) {
171 Logger.getInstance().logError(this.exception.getMessage());
172 throw this.exception;
173 }
174
175 @Override
176 public MapLink put(final UserObject owner, final String associationName, final String target, final String key) {
177 Logger.getInstance().logError(this.exception.getMessage());
178 throw this.exception;
179 }
180
181 @Override
182 public MapLink put(final UserObject owner,
183 final String associationName,
184 final UserObject target,
185 final BigInteger key) {
186 Logger.getInstance().logError(this.exception.getMessage());
187 throw this.exception;
188 }
189
190 @Override
191 public MapLink put(final UserObject owner,
192 final String associationName,
193 final BigInteger target,
194 final BigInteger key) {
195 Logger.getInstance().logError(this.exception.getMessage());
196 throw this.exception;
197 }
198
199 @Override
200 public MapLink put(final UserObject owner, final String associationName, final String target, final BigInteger key) {
201 Logger.getInstance().logError(this.exception.getMessage());
202 throw this.exception;
203 }
204
205 @Override
206 public MapLink put(final UserObject owner,
207 final String associationName,
208 final UserObject target,
209 final UserObject key) {
210 Logger.getInstance().logError(this.exception.getMessage());
211 throw this.exception;
212 }
213
214 @Override
215 public MapLink put(final UserObject owner,
216 final String associationName,
217 final BigInteger target,
218 final UserObject key) {
219 Logger.getInstance().logError(this.exception.getMessage());
220 throw this.exception;
221 }
222
223 @Override
224 public MapLink put(final UserObject owner, final String associationName, final String target, final UserObject key) {
225 Logger.getInstance().logError(this.exception.getMessage());
226 throw this.exception;
227 }
228
229 @Override
230 public void commit() {
231
232 }
233
234 @Override
235 public void rollback() {
236
237 }
238
239 @Override
240 public void savePoint() {
241
242 }
243
244 @Override
245 public void rollbackToSavePoint() {
246
247 }
248
249 @Override
250 public void unset(final Link toUnset) {
251 Logger.getInstance().logError(this.exception.getMessage());
252 throw this.exception;
253 }
254
255 @Override
256 public TypeManager getTypeManager() {
257 return this.objectFacade.getTypeManager();
258 }
259
260 @Override
261 public Collection<UserObject> getObjectsByType(final String typeName) {
262 Logger.getInstance().logError(this.exception.getMessage());
263 throw this.exception;
264 }
265
266 @Override
267 public UserObject checkout(final long object) {
268 Logger.getInstance().logError(this.exception.getMessage());
269 throw this.exception;
270 }
271
272 }