View Javadoc
1   // license-header java merge-point
2   //
3   // Attention: generated code (by MetafacadeLogic.vsl) - do not modify!
4   //
5   package org.andromda.metafacades.uml14;
6   
7   import java.util.Collection;
8   import java.util.List;
9   import org.andromda.core.metafacade.ModelValidationMessage;
10  import org.andromda.metafacades.uml.ClassifierFacade;
11  import org.andromda.metafacades.uml.ModelElementFacade;
12  import org.andromda.metafacades.uml.PackageFacade;
13  import org.apache.log4j.Logger;
14  import org.omg.uml.modelmanagement.UmlPackage;
15  
16  /**
17   * Used to group elements, and provides a namespace for the grouped elements. A package can have one
18   * or more profile applications to indicate which profiles have been applied. Because a profile is a
19   * package, it is possible to apply a profile not only to packages, but also to profiles. Package
20   * specializes TemplateableElement and PackageableElement specializes ParameterableElement to
21   * specify that a package can be used as a template and a PackageableElement as a template
22   * parameter.
23   * MetafacadeLogic for PackageFacade
24   *
25   * @see PackageFacade
26   */
27  public abstract class PackageFacadeLogic
28      extends ModelElementFacadeLogicImpl
29      implements PackageFacade
30  {
31      /**
32       * The underlying UML object
33       * @see UmlPackage
34       */
35      protected UmlPackage metaObject;
36  
37      /** Create Metafacade implementation instance using the MetafacadeFactory from the context
38       * @param metaObjectIn
39       * @param context
40       */
41      protected PackageFacadeLogic(UmlPackage metaObjectIn, String context)
42      {
43          super(metaObjectIn, getContext(context));
44          this.metaObject = metaObjectIn;
45      }
46  
47      /**
48       * The logger instance.
49       */
50      private static final Logger logger = Logger.getLogger(PackageFacadeLogic.class);
51  
52      /**
53       * Gets the context for this metafacade logic instance.
54       * @param context String. Set to PackageFacade if null
55       * @return context String
56       */
57      private static String getContext(String context)
58      {
59          if (context == null)
60          {
61              context = "org.andromda.metafacades.uml.PackageFacade";
62          }
63          return context;
64      }
65  
66      /** Reset context only for non-root metafacades
67       * @param context
68       */
69      @Override
70      public void resetMetafacadeContext(String context)
71      {
72          if (!this.contextRoot) // reset context only for non-root metafacades
73          {
74              context = getContext(context);  // to have same value as in original constructor call
75              setMetafacadeContext (context);
76          }
77      }
78  
79      /**
80       * @return boolean true always
81       * @see PackageFacade
82       */
83      public boolean isPackageFacadeMetaType()
84      {
85          return true;
86      }
87  
88      // --------------- attributes ---------------------
89  
90     /**
91      * @see PackageFacade#getTablePrefix()
92      * @return String
93      */
94      protected abstract String handleGetTablePrefix();
95  
96      private String __tablePrefix1a;
97      private boolean __tablePrefix1aSet = false;
98  
99      /**
100      * The Entity table prefix to be used for this package.
101      * @return (String)handleGetTablePrefix()
102      */
103     public final String getTablePrefix()
104     {
105         String tablePrefix1a = this.__tablePrefix1a;
106         if (!this.__tablePrefix1aSet)
107         {
108             // tablePrefix has no pre constraints
109             tablePrefix1a = handleGetTablePrefix();
110             // tablePrefix has no post constraints
111             this.__tablePrefix1a = tablePrefix1a;
112             if (isMetafacadePropertyCachingEnabled())
113             {
114                 this.__tablePrefix1aSet = true;
115             }
116         }
117         return tablePrefix1a;
118     }
119 
120     // ---------------- business methods ----------------------
121 
122     /**
123      * Method to be implemented in descendants
124      * Finds the model element with the given 'fullyQualifiedName', or returns null if one can't be
125      * found with that name.
126      * @param fullyQualifiedName
127      * @return ModelElementFacade
128      */
129     protected abstract ModelElementFacade handleFindModelElement(String fullyQualifiedName);
130 
131     /**
132      * Finds the model element with the given 'fullyQualifiedName', or returns null if one can't be
133      * found with that name.
134      * @param fullyQualifiedName String
135      * The fully qualified name of the model element to find.
136      * @return handleFindModelElement(fullyQualifiedName)
137      */
138     public ModelElementFacade findModelElement(String fullyQualifiedName)
139     {
140         // findModelElement has no pre constraints
141         ModelElementFacade returnValue = handleFindModelElement(fullyQualifiedName);
142         // findModelElement has no post constraints
143         return returnValue;
144     }
145 
146     // ------------- associations ------------------
147 
148     /**
149      * Used to group elements, and provides a namespace for the grouped elements. A package can have
150      * one or
151      * more profile applications to indicate which profiles have been applied. Because a profile is
152      * a
153      * package, it is possible to apply a profile not only to packages, but also to profiles.
154      * Package
155      * specializes TemplateableElement and PackageableElement specializes ParameterableElement to
156      * specify
157      * that a package can be used as a template and a PackageableElement as a template parameter.
158      * @return (Collection<ClassifierFacade>)handleGetClasses()
159      */
160     public final Collection<ClassifierFacade> getClasses()
161     {
162         Collection<ClassifierFacade> getClasses1r = null;
163         // packageFacade has no pre constraints
164         Collection result = handleGetClasses();
165         List shieldedResult = this.shieldedElements(result);
166         try
167         {
168             getClasses1r = (Collection<ClassifierFacade>)shieldedResult;
169         }
170         catch (ClassCastException ex)
171         {
172             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
173             PackageFacadeLogic.logger.warn("incorrect metafacade cast for PackageFacadeLogic.getClasses Collection<ClassifierFacade> " + result + ": " + shieldedResult);
174         }
175         // packageFacade has no post constraints
176         return getClasses1r;
177     }
178 
179     /**
180      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
181      * @return  Collection
182      */
183     protected abstract Collection handleGetClasses();
184 
185     /**
186      * Gets the root package for the model element.
187      * @return (Collection<ModelElementFacade>)handleGetModelElements()
188      */
189     public final Collection<ModelElementFacade> getModelElements()
190     {
191         Collection<ModelElementFacade> getModelElements2r = null;
192         // rootPackage has no pre constraints
193         Collection result = handleGetModelElements();
194         List shieldedResult = this.shieldedElements(result);
195         try
196         {
197             getModelElements2r = (Collection<ModelElementFacade>)shieldedResult;
198         }
199         catch (ClassCastException ex)
200         {
201             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
202             PackageFacadeLogic.logger.warn("incorrect metafacade cast for PackageFacadeLogic.getModelElements Collection<ModelElementFacade> " + result + ": " + shieldedResult);
203         }
204         // rootPackage has no post constraints
205         return getModelElements2r;
206     }
207 
208     /**
209      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
210      * @return  Collection
211      */
212     protected abstract Collection handleGetModelElements();
213 
214     /**
215      * Used to group elements, and provides a namespace for the grouped elements. A package can have
216      * one or
217      * more profile applications to indicate which profiles have been applied. Because a profile is
218      * a
219      * package, it is possible to apply a profile not only to packages, but also to profiles.
220      * Package
221      * specializes TemplateableElement and PackageableElement specializes ParameterableElement to
222      * specify
223      * that a package can be used as a template and a PackageableElement as a template parameter.
224      * @return (Collection<PackageFacade>)handleGetSubPackages()
225      */
226     public final Collection<PackageFacade> getSubPackages()
227     {
228         Collection<PackageFacade> getSubPackages3r = null;
229         // packageFacade has no pre constraints
230         Collection result = handleGetSubPackages();
231         List shieldedResult = this.shieldedElements(result);
232         try
233         {
234             getSubPackages3r = (Collection<PackageFacade>)shieldedResult;
235         }
236         catch (ClassCastException ex)
237         {
238             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
239             PackageFacadeLogic.logger.warn("incorrect metafacade cast for PackageFacadeLogic.getSubPackages Collection<PackageFacade> " + result + ": " + shieldedResult);
240         }
241         // packageFacade has no post constraints
242         return getSubPackages3r;
243     }
244 
245     /**
246      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
247      * @return  Collection
248      */
249     protected abstract Collection handleGetSubPackages();
250 
251     /**
252      * Used to group elements, and provides a namespace for the grouped elements. A package can have
253      * one or
254      * more profile applications to indicate which profiles have been applied. Because a profile is
255      * a
256      * package, it is possible to apply a profile not only to packages, but also to profiles.
257      * Package
258      * specializes TemplateableElement and PackageableElement specializes ParameterableElement to
259      * specify
260      * that a package can be used as a template and a PackageableElement as a template parameter.
261      * @return (Collection<ModelElementFacade>)handleGetOwnedElements()
262      */
263     public final Collection<ModelElementFacade> getOwnedElements()
264     {
265         Collection<ModelElementFacade> getOwnedElements4r = null;
266         // packageFacade has no pre constraints
267         Collection result = handleGetOwnedElements();
268         List shieldedResult = this.shieldedElements(result);
269         try
270         {
271             getOwnedElements4r = (Collection<ModelElementFacade>)shieldedResult;
272         }
273         catch (ClassCastException ex)
274         {
275             // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
276             PackageFacadeLogic.logger.warn("incorrect metafacade cast for PackageFacadeLogic.getOwnedElements Collection<ModelElementFacade> " + result + ": " + shieldedResult);
277         }
278         // packageFacade has no post constraints
279         return getOwnedElements4r;
280     }
281 
282     /**
283      * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
284      * @return  Collection
285      */
286     protected abstract Collection handleGetOwnedElements();
287 
288     /**
289      * @param validationMessages Collection<ModelValidationMessage>
290      * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages)
291      */
292     @Override
293     public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
294     {
295         super.validateInvariants(validationMessages);
296     }
297 }