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