01: package org.andromda.cartridges.ejb.metafacades;
02:
03: import org.andromda.cartridges.ejb.EJBProfile;
04: import org.andromda.metafacades.uml.AttributeFacade;
05:
06: import java.util.Collection;
07:
08: /**
09: * Metaclass facade implementation.
10: */
11: public class EJBPrimaryKeyFacadeLogicImpl extends
12: EJBPrimaryKeyFacadeLogic {
13: // ---------------- constructor -------------------------------
14:
15: public EJBPrimaryKeyFacadeLogicImpl(java.lang.Object metaObject,
16: String context) {
17: super (metaObject, context);
18: }
19:
20: protected boolean handleIsComplex() {
21: return getSimplePkField() == null;
22: }
23:
24: /**
25: * If this <code>object</code> does not have a complex primary key, get the (unqiue) attribute that is used as the
26: * primary key.
27: *
28: * @return the attribute used as primary key, or <code>null</code> if there is none or the class has a complex
29: * primary key.
30: */
31: private AttributeFacade getSimplePkField() {
32: AttributeFacade primaryKey = null;
33: Collection primaryKeys = ((EJBEntityFacade) this .getOwner())
34: .getIdentifiers();
35: if (primaryKeys.size() == 1) {
36: AttributeFacade pkField = (AttributeFacade) primaryKeys
37: .iterator().next();
38: if (pkField.hasStereotype(EJBProfile.STEREOTYPE_IDENTIFIER)) {
39: primaryKey = pkField;
40: }
41: }
42: return primaryKey;
43: }
44:
45: // ------------- relations ------------------
46:
47: }
|