1
2
3
4
5 package org.andromda.metafacades.uml14;
6
7 import java.util.Collection;
8 import org.andromda.core.metafacade.MetafacadeBase;
9 import org.andromda.core.metafacade.ModelValidationMessage;
10 import org.andromda.metafacades.uml.EntityAssociationEnd;
11 import org.andromda.translation.ocl.validation.OCLCollections;
12 import org.andromda.translation.ocl.validation.OCLIntrospector;
13 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
14 import org.apache.commons.collections.Predicate;
15 import org.apache.log4j.Logger;
16 import org.omg.uml.foundation.core.AssociationEnd;
17
18
19
20
21
22
23
24 public abstract class EntityAssociationEndLogic
25 extends AssociationEndFacadeLogicImpl
26 implements EntityAssociationEnd
27 {
28
29
30
31
32 protected Object metaObject;
33
34
35
36
37
38 protected EntityAssociationEndLogic(Object metaObjectIn, String context)
39 {
40 super((AssociationEnd)metaObjectIn, getContext(context));
41 this.metaObject = metaObjectIn;
42 }
43
44
45
46
47 private static final Logger logger = Logger.getLogger(EntityAssociationEndLogic.class);
48
49
50
51
52
53
54 private static String getContext(String context)
55 {
56 if (context == null)
57 {
58 context = "org.andromda.metafacades.uml.EntityAssociationEnd";
59 }
60 return context;
61 }
62
63
64
65
66 @Override
67 public void resetMetafacadeContext(String context)
68 {
69 if (!this.contextRoot)
70 {
71 context = getContext(context);
72 setMetafacadeContext (context);
73 }
74 }
75
76
77
78
79
80 public boolean isEntityAssociationEndMetaType()
81 {
82 return true;
83 }
84
85
86
87
88
89
90
91 protected abstract String handleGetColumnName();
92
93 private String __columnName1a;
94 private boolean __columnName1aSet = false;
95
96
97
98
99
100 public final String getColumnName()
101 {
102 String columnName1a = this.__columnName1a;
103 if (!this.__columnName1aSet)
104 {
105
106 columnName1a = handleGetColumnName();
107
108 this.__columnName1a = columnName1a;
109 if (isMetafacadePropertyCachingEnabled())
110 {
111 this.__columnName1aSet = true;
112 }
113 }
114 return columnName1a;
115 }
116
117
118
119
120
121 protected abstract String handleGetForeignKeySuffix();
122
123 private String __foreignKeySuffix2a;
124 private boolean __foreignKeySuffix2aSet = false;
125
126
127
128
129
130 public final String getForeignKeySuffix()
131 {
132 String foreignKeySuffix2a = this.__foreignKeySuffix2a;
133 if (!this.__foreignKeySuffix2aSet)
134 {
135
136 foreignKeySuffix2a = handleGetForeignKeySuffix();
137
138 this.__foreignKeySuffix2a = foreignKeySuffix2a;
139 if (isMetafacadePropertyCachingEnabled())
140 {
141 this.__foreignKeySuffix2aSet = true;
142 }
143 }
144 return foreignKeySuffix2a;
145 }
146
147
148
149
150
151 protected abstract boolean handleIsForeignIdentifier();
152
153 private boolean __foreignIdentifier3a;
154 private boolean __foreignIdentifier3aSet = false;
155
156
157
158
159
160
161
162
163 public final boolean isForeignIdentifier()
164 {
165 boolean foreignIdentifier3a = this.__foreignIdentifier3a;
166 if (!this.__foreignIdentifier3aSet)
167 {
168
169 foreignIdentifier3a = handleIsForeignIdentifier();
170
171 this.__foreignIdentifier3a = foreignIdentifier3a;
172 if (isMetafacadePropertyCachingEnabled())
173 {
174 this.__foreignIdentifier3aSet = true;
175 }
176 }
177 return foreignIdentifier3a;
178 }
179
180
181
182
183
184 protected abstract String handleGetForeignKeyConstraintName();
185
186 private String __foreignKeyConstraintName4a;
187 private boolean __foreignKeyConstraintName4aSet = false;
188
189
190
191
192
193 public final String getForeignKeyConstraintName()
194 {
195 String foreignKeyConstraintName4a = this.__foreignKeyConstraintName4a;
196 if (!this.__foreignKeyConstraintName4aSet)
197 {
198
199 foreignKeyConstraintName4a = handleGetForeignKeyConstraintName();
200
201 this.__foreignKeyConstraintName4a = foreignKeyConstraintName4a;
202 if (isMetafacadePropertyCachingEnabled())
203 {
204 this.__foreignKeyConstraintName4aSet = true;
205 }
206 }
207 return foreignKeyConstraintName4a;
208 }
209
210
211
212
213
214 protected abstract String handleGetColumnIndex();
215
216 private String __columnIndex5a;
217 private boolean __columnIndex5aSet = false;
218
219
220
221
222
223 public final String getColumnIndex()
224 {
225 String columnIndex5a = this.__columnIndex5a;
226 if (!this.__columnIndex5aSet)
227 {
228
229 columnIndex5a = handleGetColumnIndex();
230
231 this.__columnIndex5a = columnIndex5a;
232 if (isMetafacadePropertyCachingEnabled())
233 {
234 this.__columnIndex5aSet = true;
235 }
236 }
237 return columnIndex5a;
238 }
239
240
241
242
243
244 protected abstract String handleGetSqlType();
245
246 private String __sqlType6a;
247 private boolean __sqlType6aSet = false;
248
249
250
251
252
253 public final String getSqlType()
254 {
255 String sqlType6a = this.__sqlType6a;
256 if (!this.__sqlType6aSet)
257 {
258
259 sqlType6a = handleGetSqlType();
260
261 this.__sqlType6a = sqlType6a;
262 if (isMetafacadePropertyCachingEnabled())
263 {
264 this.__sqlType6aSet = true;
265 }
266 }
267 return sqlType6a;
268 }
269
270
271
272
273
274 protected abstract boolean handleIsTransient();
275
276 private boolean __transient7a;
277 private boolean __transient7aSet = false;
278
279
280
281
282
283 public final boolean isTransient()
284 {
285 boolean transient7a = this.__transient7a;
286 if (!this.__transient7aSet)
287 {
288
289 transient7a = handleIsTransient();
290
291 this.__transient7a = transient7a;
292 if (isMetafacadePropertyCachingEnabled())
293 {
294 this.__transient7aSet = true;
295 }
296 }
297 return transient7a;
298 }
299
300
301
302
303
304 protected abstract boolean handleIsIdentifiersPresent();
305
306 private boolean __identifiersPresent8a;
307 private boolean __identifiersPresent8aSet = false;
308
309
310
311
312
313 public final boolean isIdentifiersPresent()
314 {
315 boolean identifiersPresent8a = this.__identifiersPresent8a;
316 if (!this.__identifiersPresent8aSet)
317 {
318
319 identifiersPresent8a = handleIsIdentifiersPresent();
320
321 this.__identifiersPresent8a = identifiersPresent8a;
322 if (isMetafacadePropertyCachingEnabled())
323 {
324 this.__identifiersPresent8aSet = true;
325 }
326 }
327 return identifiersPresent8a;
328 }
329
330
331
332
333
334 protected abstract String handleGetUniqueGroup();
335
336 private String __uniqueGroup9a;
337 private boolean __uniqueGroup9aSet = false;
338
339
340
341
342
343 public final String getUniqueGroup()
344 {
345 String uniqueGroup9a = this.__uniqueGroup9a;
346 if (!this.__uniqueGroup9aSet)
347 {
348
349 uniqueGroup9a = handleGetUniqueGroup();
350
351 this.__uniqueGroup9a = uniqueGroup9a;
352 if (isMetafacadePropertyCachingEnabled())
353 {
354 this.__uniqueGroup9aSet = true;
355 }
356 }
357 return uniqueGroup9a;
358 }
359
360
361
362
363
364 protected abstract boolean handleIsIdentifier();
365
366 private boolean __identifier10a;
367 private boolean __identifier10aSet = false;
368
369
370
371
372
373 public final boolean isIdentifier()
374 {
375 boolean identifier10a = this.__identifier10a;
376 if (!this.__identifier10aSet)
377 {
378
379 identifier10a = handleIsIdentifier();
380
381 this.__identifier10a = identifier10a;
382 if (isMetafacadePropertyCachingEnabled())
383 {
384 this.__identifier10aSet = true;
385 }
386 }
387 return identifier10a;
388 }
389
390
391
392
393
394
395
396
397
398
399
400 @Override
401 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
402 {
403 super.validateInvariants(validationMessages);
404 try
405 {
406 final Object contextElement = this.THIS();
407 boolean constraintValid = OCLResultEnsurer.ensure((Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"foreignIdentifier"))).booleanValue()?(Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"one2One"))).booleanValue()&&Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(contextElement,"child"))).booleanValue()&&OCLCollections.one(OCLIntrospector.invoke(contextElement,"type.associationEnds"),new Predicate(){public boolean evaluate(Object object){return Boolean.valueOf(String.valueOf(OCLIntrospector.invoke(object,"foreignIdentifier"))).booleanValue();}})):true));
408 if (!constraintValid)
409 {
410 validationMessages.add(
411 new ModelValidationMessage(
412 (MetafacadeBase)contextElement ,
413 "org::andromda::metafacades::uml::EntityAssociationEnd::valid foreign identifiers.",
414 "Only ONE association end on an entity can be flagged as having a foreign identifier at any given time. It also MUST be the child end (the other side is flagged as having composite aggregation) of a one-to-one association."));
415 }
416 }
417 catch (Throwable th)
418 {
419 Throwable cause = th.getCause();
420 int depth = 0;
421 while (cause != null && depth < 7)
422 {
423 th = cause;
424 depth++;
425 }
426 logger.error("Error validating constraint 'org::andromda::metafacades::uml::EntityAssociationEnd::valid foreign identifiers.' ON "
427 + this.THIS().toString() + ": " + th.getMessage(), th);
428 }
429 }
430 }