001// license-header java merge-point
002//
003// Attention: generated code (by MetafacadeLogic.vsl) - do not modify!
004//
005package org.andromda.metafacades.uml14;
006
007import java.util.Collection;
008import java.util.List;
009import org.andromda.core.metafacade.MetafacadeBase;
010import org.andromda.core.metafacade.ModelValidationMessage;
011import org.andromda.metafacades.uml.AssociationEndFacade;
012import org.andromda.metafacades.uml.AttributeFacade;
013import org.andromda.metafacades.uml.DependencyFacade;
014import org.andromda.metafacades.uml.Entity;
015import org.andromda.metafacades.uml.EntityAssociationEnd;
016import org.andromda.metafacades.uml.EntityQueryOperation;
017import org.andromda.metafacades.uml.ModelElementFacade;
018import org.andromda.metafacades.uml.OperationFacade;
019import org.andromda.translation.ocl.validation.OCLCollections;
020import org.andromda.translation.ocl.validation.OCLIntrospector;
021import org.andromda.translation.ocl.validation.OCLResultEnsurer;
022import org.apache.commons.collections.Predicate;
023import org.apache.log4j.Logger;
024import org.omg.uml.foundation.core.Classifier;
025
026/**
027 * Represents a persistent entity.
028 * MetafacadeLogic for Entity
029 *
030 * @see Entity
031 */
032public abstract class EntityLogic
033    extends ClassifierFacadeLogicImpl
034    implements Entity
035{
036    /**
037     * The underlying UML object
038     * @see Object
039     */
040    protected Object metaObject;
041
042    /** Create Metafacade implementation instance using the MetafacadeFactory from the context
043     * @param metaObjectIn
044     * @param context
045     */
046    protected EntityLogic(Object metaObjectIn, String context)
047    {
048        super((Classifier)metaObjectIn, getContext(context));
049        this.metaObject = metaObjectIn;
050    }
051
052    /**
053     * The logger instance.
054     */
055    private static final Logger logger = Logger.getLogger(EntityLogic.class);
056
057    /**
058     * Gets the context for this metafacade logic instance.
059     * @param context String. Set to Entity if null
060     * @return context String
061     */
062    private static String getContext(String context)
063    {
064        if (context == null)
065        {
066            context = "org.andromda.metafacades.uml.Entity";
067        }
068        return context;
069    }
070
071    /** Reset context only for non-root metafacades
072     * @param context
073     */
074    @Override
075    public void resetMetafacadeContext(String context)
076    {
077        if (!this.contextRoot) // reset context only for non-root metafacades
078        {
079            context = getContext(context);  // to have same value as in original constructor call
080            setMetafacadeContext (context);
081        }
082    }
083
084    /**
085     * @return boolean true always
086     * @see Entity
087     */
088    public boolean isEntityMetaType()
089    {
090        return true;
091    }
092
093    // --------------- attributes ---------------------
094
095   /**
096    * @see Entity#isChild()
097    * @return boolean
098    */
099    protected abstract boolean handleIsChild();
100
101    private boolean __child1a;
102    private boolean __child1aSet = false;
103
104    /**
105     * Returns true/false depending on whether or not this entity represetns a child in an
106     * association (this occurs when this entity is on the opposite end of an assocation end defined
107     * as composite).
108     * @return (boolean)handleIsChild()
109     */
110    public final boolean isChild()
111    {
112        boolean child1a = this.__child1a;
113        if (!this.__child1aSet)
114        {
115            // child has no pre constraints
116            child1a = handleIsChild();
117            // child has no post constraints
118            this.__child1a = child1a;
119            if (isMetafacadePropertyCachingEnabled())
120            {
121                this.__child1aSet = true;
122            }
123        }
124        return child1a;
125    }
126
127   /**
128    * @see Entity#getTableName()
129    * @return String
130    */
131    protected abstract String handleGetTableName();
132
133    private String __tableName2a;
134    private boolean __tableName2aSet = false;
135
136    /**
137     * The name of the database table to which this entity is persisted.
138     * @return (String)handleGetTableName()
139     */
140    public final String getTableName()
141    {
142        String tableName2a = this.__tableName2a;
143        if (!this.__tableName2aSet)
144        {
145            // tableName has no pre constraints
146            tableName2a = handleGetTableName();
147            // tableName has no post constraints
148            this.__tableName2a = tableName2a;
149            if (isMetafacadePropertyCachingEnabled())
150            {
151                this.__tableName2aSet = true;
152            }
153        }
154        return tableName2a;
155    }
156
157   /**
158    * @see Entity#isIdentifiersPresent()
159    * @return boolean
160    */
161    protected abstract boolean handleIsIdentifiersPresent();
162
163    /**
164     * True if the entity has any identifiers defined, false otherwise.
165     * @return (boolean)handleIsIdentifiersPresent()
166     */
167    public final boolean isIdentifiersPresent()
168    {
169        boolean identifiersPresent3a = false;
170        // identifiersPresent has no pre constraints
171        identifiersPresent3a = handleIsIdentifiersPresent();
172        // identifiersPresent has no post constraints
173        return identifiersPresent3a;
174    }
175
176   /**
177    * @see Entity#getMaxSqlNameLength()
178    * @return short
179    */
180    protected abstract short handleGetMaxSqlNameLength();
181
182    private short __maxSqlNameLength4a;
183    private boolean __maxSqlNameLength4aSet = false;
184
185    /**
186     * The maximum length a SQL name may be.
187     * @return (short)handleGetMaxSqlNameLength()
188     */
189    public final short getMaxSqlNameLength()
190    {
191        short maxSqlNameLength4a = this.__maxSqlNameLength4a;
192        if (!this.__maxSqlNameLength4aSet)
193        {
194            // maxSqlNameLength has no pre constraints
195            maxSqlNameLength4a = handleGetMaxSqlNameLength();
196            // maxSqlNameLength has no post constraints
197            this.__maxSqlNameLength4a = maxSqlNameLength4a;
198            if (isMetafacadePropertyCachingEnabled())
199            {
200                this.__maxSqlNameLength4aSet = true;
201            }
202        }
203        return maxSqlNameLength4a;
204    }
205
206   /**
207    * @see Entity#isUsingForeignIdentifier()
208    * @return boolean
209    */
210    protected abstract boolean handleIsUsingForeignIdentifier();
211
212    /**
213     * Indicates whether or not this entity is using a foreign identifier as its identifiers.  That
214     * is: the foreignIdentifier flag was set on an incoming association end and the entity is
215     * therefore using the related foreign parent entity's identifier.
216     * @return (boolean)handleIsUsingForeignIdentifier()
217     */
218    public final boolean isUsingForeignIdentifier()
219    {
220        boolean usingForeignIdentifier5a = false;
221        // usingForeignIdentifier has no pre constraints
222        usingForeignIdentifier5a = handleIsUsingForeignIdentifier();
223        // usingForeignIdentifier has no post constraints
224        return usingForeignIdentifier5a;
225    }
226
227   /**
228    * @see Entity#isDynamicIdentifiersPresent()
229    * @return boolean
230    */
231    protected abstract boolean handleIsDynamicIdentifiersPresent();
232
233    /**
234     * True if the entity has its identifiers dynamically added, false otherwise.
235     * @return (boolean)handleIsDynamicIdentifiersPresent()
236     */
237    public final boolean isDynamicIdentifiersPresent()
238    {
239        boolean dynamicIdentifiersPresent6a = false;
240        // dynamicIdentifiersPresent has no pre constraints
241        dynamicIdentifiersPresent6a = handleIsDynamicIdentifiersPresent();
242        // dynamicIdentifiersPresent has no post constraints
243        return dynamicIdentifiersPresent6a;
244    }
245
246   /**
247    * @see Entity#isUsingAssignedIdentifier()
248    * @return boolean
249    */
250    protected abstract boolean handleIsUsingAssignedIdentifier();
251
252    /**
253     * Indiciates if this entity is using an assigned identifier or not.
254     * @return (boolean)handleIsUsingAssignedIdentifier()
255     */
256    public final boolean isUsingAssignedIdentifier()
257    {
258        boolean usingAssignedIdentifier7a = false;
259        // usingAssignedIdentifier has no pre constraints
260        usingAssignedIdentifier7a = handleIsUsingAssignedIdentifier();
261        // usingAssignedIdentifier has no post constraints
262        return usingAssignedIdentifier7a;
263    }
264
265   /**
266    * @see Entity#getSchema()
267    * @return String
268    */
269    protected abstract String handleGetSchema();
270
271    private String __schema8a;
272    private boolean __schema8aSet = false;
273
274    /**
275     * The name of the schema that contains the database table
276     * @return (String)handleGetSchema()
277     */
278    public final String getSchema()
279    {
280        String schema8a = this.__schema8a;
281        if (!this.__schema8aSet)
282        {
283            // schema has no pre constraints
284            schema8a = handleGetSchema();
285            // schema has no post constraints
286            this.__schema8a = schema8a;
287            if (isMetafacadePropertyCachingEnabled())
288            {
289                this.__schema8aSet = true;
290            }
291        }
292        return schema8a;
293    }
294
295   /**
296    * @see Entity#isCompositeIdentifier()
297    * @return boolean
298    */
299    protected abstract boolean handleIsCompositeIdentifier();
300
301    /**
302     * True if this entity identifier is a composite (consists of multiple key columns, typically
303     * abstracted into an external composite identifier class)
304     * @return (boolean)handleIsCompositeIdentifier()
305     */
306    public final boolean isCompositeIdentifier()
307    {
308        boolean compositeIdentifier9a = false;
309        // compositeIdentifier has no pre constraints
310        compositeIdentifier9a = handleIsCompositeIdentifier();
311        // compositeIdentifier has no post constraints
312        return compositeIdentifier9a;
313    }
314
315   /**
316    * @see Entity#getEmbeddedValues()
317    * @return Collection<AttributeFacade>
318    */
319    protected abstract Collection<AttributeFacade> handleGetEmbeddedValues();
320
321    private Collection<AttributeFacade> __embeddedValues10a;
322    private boolean __embeddedValues10aSet = false;
323
324    /**
325     * The embedded values belonging to this entity.
326     * @return (Collection<AttributeFacade>)handleGetEmbeddedValues()
327     */
328    public final Collection<AttributeFacade> getEmbeddedValues()
329    {
330        Collection<AttributeFacade> embeddedValues10a = this.__embeddedValues10a;
331        if (!this.__embeddedValues10aSet)
332        {
333            // embeddedValues has no pre constraints
334            embeddedValues10a = handleGetEmbeddedValues();
335            // embeddedValues has no post constraints
336            this.__embeddedValues10a = embeddedValues10a;
337            if (isMetafacadePropertyCachingEnabled())
338            {
339                this.__embeddedValues10aSet = true;
340            }
341        }
342        return embeddedValues10a;
343    }
344
345   /**
346    * @see Entity#getFullyQualifiedIdentifierTypeName()
347    * @return String
348    */
349    protected abstract String handleGetFullyQualifiedIdentifierTypeName();
350
351    private String __fullyQualifiedIdentifierTypeName11a;
352    private boolean __fullyQualifiedIdentifierTypeName11aSet = false;
353
354    /**
355     * The full name of the type of the identifier. If composite identifier add the PK sufix to the
356     * class name. If not, retorns the fully qualified name of the identifier.
357     * @return (String)handleGetFullyQualifiedIdentifierTypeName()
358     */
359    public final String getFullyQualifiedIdentifierTypeName()
360    {
361        String fullyQualifiedIdentifierTypeName11a = this.__fullyQualifiedIdentifierTypeName11a;
362        if (!this.__fullyQualifiedIdentifierTypeName11aSet)
363        {
364            // fullyQualifiedIdentifierTypeName has no pre constraints
365            fullyQualifiedIdentifierTypeName11a = handleGetFullyQualifiedIdentifierTypeName();
366            // fullyQualifiedIdentifierTypeName has no post constraints
367            this.__fullyQualifiedIdentifierTypeName11a = fullyQualifiedIdentifierTypeName11a;
368            if (isMetafacadePropertyCachingEnabled())
369            {
370                this.__fullyQualifiedIdentifierTypeName11aSet = true;
371            }
372        }
373        return fullyQualifiedIdentifierTypeName11a;
374    }
375
376   /**
377    * @see Entity#getIdentifierGetterName()
378    * @return String
379    */
380    protected abstract String handleGetIdentifierGetterName();
381
382    private String __identifierGetterName12a;
383    private boolean __identifierGetterName12aSet = false;
384
385    /**
386     * The getter name of the identifier.
387     * @return (String)handleGetIdentifierGetterName()
388     */
389    public final String getIdentifierGetterName()
390    {
391        String identifierGetterName12a = this.__identifierGetterName12a;
392        if (!this.__identifierGetterName12aSet)
393        {
394            // identifierGetterName has no pre constraints
395            identifierGetterName12a = handleGetIdentifierGetterName();
396            // identifierGetterName has no post constraints
397            this.__identifierGetterName12a = identifierGetterName12a;
398            if (isMetafacadePropertyCachingEnabled())
399            {
400                this.__identifierGetterName12aSet = true;
401            }
402        }
403        return identifierGetterName12a;
404    }
405
406   /**
407    * @see Entity#getIdentifierName()
408    * @return String
409    */
410    protected abstract String handleGetIdentifierName();
411
412    private String __identifierName13a;
413    private boolean __identifierName13aSet = false;
414
415    /**
416     * The name of the identifier. If composite identifier add the Pk suffix. If not composite
417     * returns the attribute name of the identifier.
418     * @return (String)handleGetIdentifierName()
419     */
420    public final String getIdentifierName()
421    {
422        String identifierName13a = this.__identifierName13a;
423        if (!this.__identifierName13aSet)
424        {
425            // identifierName has no pre constraints
426            identifierName13a = handleGetIdentifierName();
427            // identifierName has no post constraints
428            this.__identifierName13a = identifierName13a;
429            if (isMetafacadePropertyCachingEnabled())
430            {
431                this.__identifierName13aSet = true;
432            }
433        }
434        return identifierName13a;
435    }
436
437   /**
438    * @see Entity#getIdentifierSetterName()
439    * @return String
440    */
441    protected abstract String handleGetIdentifierSetterName();
442
443    private String __identifierSetterName14a;
444    private boolean __identifierSetterName14aSet = false;
445
446    /**
447     * The setter name of the identifier.
448     * @return (String)handleGetIdentifierSetterName()
449     */
450    public final String getIdentifierSetterName()
451    {
452        String identifierSetterName14a = this.__identifierSetterName14a;
453        if (!this.__identifierSetterName14aSet)
454        {
455            // identifierSetterName has no pre constraints
456            identifierSetterName14a = handleGetIdentifierSetterName();
457            // identifierSetterName has no post constraints
458            this.__identifierSetterName14a = identifierSetterName14a;
459            if (isMetafacadePropertyCachingEnabled())
460            {
461                this.__identifierSetterName14aSet = true;
462            }
463        }
464        return identifierSetterName14a;
465    }
466
467   /**
468    * @see Entity#getIdentifierTypeName()
469    * @return String
470    */
471    protected abstract String handleGetIdentifierTypeName();
472
473    private String __identifierTypeName15a;
474    private boolean __identifierTypeName15aSet = false;
475
476    /**
477     * The name of the type of the identifier. If composite identifier add the PK suffix to the
478     * class name. If not, returns the name of the identifier.
479     * @return (String)handleGetIdentifierTypeName()
480     */
481    public final String getIdentifierTypeName()
482    {
483        String identifierTypeName15a = this.__identifierTypeName15a;
484        if (!this.__identifierTypeName15aSet)
485        {
486            // identifierTypeName has no pre constraints
487            identifierTypeName15a = handleGetIdentifierTypeName();
488            // identifierTypeName has no post constraints
489            this.__identifierTypeName15a = identifierTypeName15a;
490            if (isMetafacadePropertyCachingEnabled())
491            {
492                this.__identifierTypeName15aSet = true;
493            }
494        }
495        return identifierTypeName15a;
496    }
497
498    // ---------------- business methods ----------------------
499
500    /**
501     * Method to be implemented in descendants
502     * Gets the attributes as a list within an operation call, optionally including the type names
503     * and the identifier attributes.
504     * @param withIdentifiers
505     * @return String
506     */
507    protected abstract String handleGetOperationCallFromAttributes(boolean withIdentifiers);
508
509    /**
510     * Gets the attributes as a list within an operation call, optionally including the type names
511     * and the identifier attributes.
512     * @param withIdentifiers boolean
513     * True if you want to include identifiers within the attribute list, false otherwise.
514     * @return handleGetOperationCallFromAttributes(withIdentifiers)
515     */
516    public String getOperationCallFromAttributes(boolean withIdentifiers)
517    {
518        // getOperationCallFromAttributes has no pre constraints
519        String returnValue = handleGetOperationCallFromAttributes(withIdentifiers);
520        // getOperationCallFromAttributes has no post constraints
521        return returnValue;
522    }
523
524    /**
525     * Method to be implemented in descendants
526     * Gets all identifiers for an entity. If 'follow' is true, and if no identifiers can be found
527     * on the entity, a search up the inheritance chain will be performed, and the identifiers from
528     * the first super class having them will be used.   If no identifiers exist, a default
529     * identifier will be created if the allowDefaultIdentifiers property is set to true.
530     * Identifiers can be on attributes or associations (composite primary key).
531     * @param follow
532     * @return Collection<ModelElementFacade>
533     */
534    protected abstract Collection<ModelElementFacade> handleGetIdentifiers(boolean follow);
535
536    /**
537     * Gets all identifiers for an entity. If 'follow' is true, and if no identifiers can be found
538     * on the entity, a search up the inheritance chain will be performed, and the identifiers from
539     * the first super class having them will be used.   If no identifiers exist, a default
540     * identifier will be created if the allowDefaultIdentifiers property is set to true.
541     * Identifiers can be on attributes or associations (composite primary key).
542     * @param follow boolean
543     * TODO: Model Documentation for Entity.getIdentifiers(follow)
544     * @return handleGetIdentifiers(follow)
545     */
546    public Collection<ModelElementFacade> getIdentifiers(boolean follow)
547    {
548        // getIdentifiers has no pre constraints
549        Collection<ModelElementFacade> returnValue = handleGetIdentifiers(follow);
550        // getIdentifiers has no post constraints
551        return returnValue;
552    }
553
554    /**
555     * Method to be implemented in descendants
556     * Gets the attributes as a list within an operation call.  If 'withTypeNames' is true, it will
557     * include the type names, if 'withIdentifiers' is true it will include the identifiers.  If
558     * 'follow' is true it will follow the inheritance hierarchy and get the attributes of the super
559     * class as well.
560     * @param withIdentifiers
561     * @param follow
562     * @return String
563     */
564    protected abstract String handleGetOperationCallFromAttributes(boolean withIdentifiers, boolean follow);
565
566    /**
567     * Gets the attributes as a list within an operation call.  If 'withTypeNames' is true, it will
568     * include the type names, if 'withIdentifiers' is true it will include the identifiers.  If
569     * 'follow' is true it will follow the inheritance hierarchy and get the attributes of the super
570     * class as well.
571     * @param withIdentifiers boolean
572     * If true, identifiers will be included in the list.
573     * @param follow boolean
574     * If this is true, the inheritance hierarchy will be followed when retrieving all attrbutes.
575     * @return handleGetOperationCallFromAttributes(withIdentifiers, follow)
576     */
577    public String getOperationCallFromAttributes(boolean withIdentifiers, boolean follow)
578    {
579        // getOperationCallFromAttributes has no pre constraints
580        String returnValue = handleGetOperationCallFromAttributes(withIdentifiers, follow);
581        // getOperationCallFromAttributes has no post constraints
582        return returnValue;
583    }
584
585    /**
586     * Method to be implemented in descendants
587     * Returns all attributes that are specified as 'required' in the model.  If 'follow' is true,
588     * then required attributes in super classes will also be returned, if false, just the ones
589     * directly on the entity will be returned.  If 'withIdentifiers' is true, the identifiers will
590     * be include, if false, no identifiers will be included.
591     * @param follow
592     * @param withIdentifiers
593     * @return Collection<AttributeFacade>
594     */
595    protected abstract Collection<AttributeFacade> handleGetRequiredAttributes(boolean follow, boolean withIdentifiers);
596
597    /**
598     * Returns all attributes that are specified as 'required' in the model.  If 'follow' is true,
599     * then required attributes in super classes will also be returned, if false, just the ones
600     * directly on the entity will be returned.  If 'withIdentifiers' is true, the identifiers will
601     * be include, if false, no identifiers will be included.
602     * @param follow boolean
603     * Whether or not to follow the inheritance hierarchy when retreiving the attributes. If true,
604     * the required attributes in super classes will also be returned, if false, just the ones
605     * directly on the entity will be returned.
606     * @param withIdentifiers boolean
607     * Whether or not to include identifiers in the list of required attributes.
608     * @return handleGetRequiredAttributes(follow, withIdentifiers)
609     */
610    public Collection<AttributeFacade> getRequiredAttributes(boolean follow, boolean withIdentifiers)
611    {
612        // getRequiredAttributes has no pre constraints
613        Collection<AttributeFacade> returnValue = handleGetRequiredAttributes(follow, withIdentifiers);
614        // getRequiredAttributes has no post constraints
615        return returnValue;
616    }
617
618    /**
619     * Method to be implemented in descendants
620     * Gets all required properties for this entity.  These consist of any required attributes as
621     * well as navigable associations that are marked as 'required'.  If 'follow' is true, then the
622     * inheritance hierchy will be followed and all required properties from super classes will be
623     * included as well.
624     * If 'withIdentifiers' is true, the identifiers will be include, if false, no identifiers will
625     * be included.
626     * @param follow
627     * @param withIdentifiers
628     * @return Collection<ModelElementFacade>
629     */
630    protected abstract Collection<ModelElementFacade> handleGetRequiredProperties(boolean follow, boolean withIdentifiers);
631
632    /**
633     * Gets all required properties for this entity.  These consist of any required attributes as
634     * well as navigable associations that are marked as 'required'.  If 'follow' is true, then the
635     * inheritance hierchy will be followed and all required properties from super classes will be
636     * included as well.
637     * If 'withIdentifiers' is true, the identifiers will be include, if false, no identifiers will
638     * be included.
639     * @param follow boolean
640     * Whether or not to follow the inheritance hierarchy when retreiving the properties. If true,
641     * the required propertis in super classes will also be returned, if false, just the ones
642     * directly on the entity will be returned.
643     * @param withIdentifiers boolean
644     * Whether or not to include identifiers in the list of required attributes.
645     * @return handleGetRequiredProperties(follow, withIdentifiers)
646     */
647    public Collection<ModelElementFacade> getRequiredProperties(boolean follow, boolean withIdentifiers)
648    {
649        // getRequiredProperties has no pre constraints
650        Collection<ModelElementFacade> returnValue = handleGetRequiredProperties(follow, withIdentifiers);
651        // getRequiredProperties has no post constraints
652        return returnValue;
653    }
654
655    /**
656     * Method to be implemented in descendants
657     * Gets all attributes of the entity, and optionally retieves the super entities attributes as
658     * well as excludes the entity's identifiers if 'withIdentifiers' is set to false.
659     * @param follow
660     * @param withIdentifiers
661     * @return Collection<AttributeFacade>
662     */
663    protected abstract Collection<AttributeFacade> handleGetAttributes(boolean follow, boolean withIdentifiers);
664
665    /**
666     * Gets all attributes of the entity, and optionally retieves the super entities attributes as
667     * well as excludes the entity's identifiers if 'withIdentifiers' is set to false.
668     * @param follow boolean
669     * Whether or not to follow the inheritance hierarchy when retreiving attributes.
670     * @param withIdentifiers boolean
671     * Whether or not to include identifiers in the returned attributes.
672     * @return handleGetAttributes(follow, withIdentifiers)
673     */
674    public Collection<AttributeFacade> getAttributes(boolean follow, boolean withIdentifiers)
675    {
676        // getAttributes has no pre constraints
677        Collection<AttributeFacade> returnValue = handleGetAttributes(follow, withIdentifiers);
678        // getAttributes has no post constraints
679        return returnValue;
680    }
681
682    /**
683     * Method to be implemented in descendants
684     * Gets a comma separated list of attribute types.  If 'follow' is true, will travel up the
685     * inheritance hierarchy to include attributes in parent entities as well.  If 'withIdentifiers'
686     * is true, will include identifiers.
687     * @param follow
688     * @param withIdentifiers
689     * @return String
690     */
691    protected abstract String handleGetAttributeTypeList(boolean follow, boolean withIdentifiers);
692
693    /**
694     * Gets a comma separated list of attribute types.  If 'follow' is true, will travel up the
695     * inheritance hierarchy to include attributes in parent entities as well.  If 'withIdentifiers'
696     * is true, will include identifiers.
697     * @param follow boolean
698     * Whether or not to 'follow' the inheritance hierarchy.
699     * @param withIdentifiers boolean
700     * Whether or not to include identifiers.
701     * @return handleGetAttributeTypeList(follow, withIdentifiers)
702     */
703    public String getAttributeTypeList(boolean follow, boolean withIdentifiers)
704    {
705        // getAttributeTypeList has no pre constraints
706        String returnValue = handleGetAttributeTypeList(follow, withIdentifiers);
707        // getAttributeTypeList has no post constraints
708        return returnValue;
709    }
710
711    /**
712     * Method to be implemented in descendants
713     * Gets a comma separated list of attribute names.  If 'follow' is true, will travel up the
714     * inheritance hiearchy to include attributes in parent entities as well.  If 'withIdentifiers'
715     * is true, will include identifiers.
716     * @param follow
717     * @param withIdentifiers
718     * @return String
719     */
720    protected abstract String handleGetAttributeNameList(boolean follow, boolean withIdentifiers);
721
722    /**
723     * Gets a comma separated list of attribute names.  If 'follow' is true, will travel up the
724     * inheritance hiearchy to include attributes in parent entities as well.  If 'withIdentifiers'
725     * is true, will include identifiers.
726     * @param follow boolean
727     * Whether or not to 'follow' the inheritance hierarchy.
728     * @param withIdentifiers boolean
729     * Whether or not to include identifiers in the returned attributes.
730     * @return handleGetAttributeNameList(follow, withIdentifiers)
731     */
732    public String getAttributeNameList(boolean follow, boolean withIdentifiers)
733    {
734        // getAttributeNameList has no pre constraints
735        String returnValue = handleGetAttributeNameList(follow, withIdentifiers);
736        // getAttributeNameList has no post constraints
737        return returnValue;
738    }
739
740    /**
741     * Method to be implemented in descendants
742     * Gets a comma separated list of attribute types with are required.  If 'follow' is true, will
743     * travel up the inheritance hierarchy to include attributes in parent entities as well.  If
744     * 'withIdentifiers' is true, will include identifiers.
745     * @param follow
746     * @param withIdentifiers
747     * @return String
748     */
749    protected abstract String handleGetRequiredAttributeTypeList(boolean follow, boolean withIdentifiers);
750
751    /**
752     * Gets a comma separated list of attribute types with are required.  If 'follow' is true, will
753     * travel up the inheritance hierarchy to include attributes in parent entities as well.  If
754     * 'withIdentifiers' is true, will include identifiers.
755     * @param follow boolean
756     * Whether or not to 'follow' the inheritance hierarchy.
757     * @param withIdentifiers boolean
758     * Whether or not to include identifiers in the list of required attributes.
759     * @return handleGetRequiredAttributeTypeList(follow, withIdentifiers)
760     */
761    public String getRequiredAttributeTypeList(boolean follow, boolean withIdentifiers)
762    {
763        // getRequiredAttributeTypeList has no pre constraints
764        String returnValue = handleGetRequiredAttributeTypeList(follow, withIdentifiers);
765        // getRequiredAttributeTypeList has no post constraints
766        return returnValue;
767    }
768
769    /**
770     * Method to be implemented in descendants
771     * Gets a comma separated list of required attribute names.  If 'follow' is true, will travel up
772     * the inheritance hierarchy to include attributes in parent entities as well.  If
773     * 'withIdentifiers' is true, will include identifiers.
774     * @param follow
775     * @param withIdentifiers
776     * @return String
777     */
778    protected abstract String handleGetRequiredAttributeNameList(boolean follow, boolean withIdentifiers);
779
780    /**
781     * Gets a comma separated list of required attribute names.  If 'follow' is true, will travel up
782     * the inheritance hierarchy to include attributes in parent entities as well.  If
783     * 'withIdentifiers' is true, will include identifiers.
784     * @param follow boolean
785     * Whether or not to follow the inheritance hierarchy when retreiving the attributes. If true,
786     * the required attributes in super classes will also be used, if false, just the ones directly
787     * on the entity will be added to the list.
788     * @param withIdentifiers boolean
789     * Whether or not to include identifiers in the list of required attribute names.
790     * @return handleGetRequiredAttributeNameList(follow, withIdentifiers)
791     */
792    public String getRequiredAttributeNameList(boolean follow, boolean withIdentifiers)
793    {
794        // getRequiredAttributeNameList has no pre constraints
795        String returnValue = handleGetRequiredAttributeNameList(follow, withIdentifiers);
796        // getRequiredAttributeNameList has no post constraints
797        return returnValue;
798    }
799
800    /**
801     * Method to be implemented in descendants
802     * Gets all query operations for an entity. If 'follow' is true, and if no query operations can
803     * be found on the entity, a search up the inheritance chain will be performed, and the
804     * identifiers from the first super class having them will be used.   If no identifiers exist, a
805     * default identifier will be created if the allowDefaultIdentifiers property is set to true.
806     * @param follow
807     * @return Collection<OperationFacade>
808     */
809    protected abstract Collection<OperationFacade> handleGetQueryOperations(boolean follow);
810
811    /**
812     * Gets all query operations for an entity. If 'follow' is true, and if no query operations can
813     * be found on the entity, a search up the inheritance chain will be performed, and the
814     * identifiers from the first super class having them will be used.   If no identifiers exist, a
815     * default identifier will be created if the allowDefaultIdentifiers property is set to true.
816     * @param follow boolean
817     * TODO: Model Documentation for Entity.getQueryOperations(follow)
818     * @return handleGetQueryOperations(follow)
819     */
820    public Collection<OperationFacade> getQueryOperations(boolean follow)
821    {
822        // getQueryOperations has no pre constraints
823        Collection<OperationFacade> returnValue = handleGetQueryOperations(follow);
824        // getQueryOperations has no post constraints
825        return returnValue;
826    }
827
828    /**
829     * Method to be implemented in descendants
830     * Creates a comma separated list of the required property names.
831     * @param follow
832     * @param withIdentifiers
833     * @return String
834     */
835    protected abstract String handleGetRequiredPropertyNameList(boolean follow, boolean withIdentifiers);
836
837    /**
838     * Creates a comma separated list of the required property names.
839     * @param follow boolean
840     * Whether or not to follow the inheritance hierarchy when retrieving the properties.
841     * @param withIdentifiers boolean
842     * Whether or not to include identifiers in the list.
843     * @return handleGetRequiredPropertyNameList(follow, withIdentifiers)
844     */
845    public String getRequiredPropertyNameList(boolean follow, boolean withIdentifiers)
846    {
847        // getRequiredPropertyNameList has no pre constraints
848        String returnValue = handleGetRequiredPropertyNameList(follow, withIdentifiers);
849        // getRequiredPropertyNameList has no post constraints
850        return returnValue;
851    }
852
853    /**
854     * Method to be implemented in descendants
855     * A comma separated list of the required property types.
856     * @param follow
857     * @param withIdentifiers
858     * @return String
859     */
860    protected abstract String handleGetRequiredPropertyTypeList(boolean follow, boolean withIdentifiers);
861
862    /**
863     * A comma separated list of the required property types.
864     * @param follow boolean
865     * Whether or not to follow the inheritance hierarchy
866     * @param withIdentifiers boolean
867     * Whether or not to include identifiers in the list.
868     * @return handleGetRequiredPropertyTypeList(follow, withIdentifiers)
869     */
870    public String getRequiredPropertyTypeList(boolean follow, boolean withIdentifiers)
871    {
872        // getRequiredPropertyTypeList has no pre constraints
873        String returnValue = handleGetRequiredPropertyTypeList(follow, withIdentifiers);
874        // getRequiredPropertyTypeList has no post constraints
875        return returnValue;
876    }
877
878    /**
879     * Method to be implemented in descendants
880     * Gets all properties of this entity, this includes the attributes and navigable association
881     * ends of the entity.  The 'follow' flag indcates whether or not the inheritance hierarchy
882     * should be followed when getting all the properties.  The 'withIdentifiers' flag indicates
883     * whether or not identifiers should be included in the collection of properties.
884     * @param follow
885     * @param withIdentifiers
886     * @return Collection<ModelElementFacade>
887     */
888    protected abstract Collection<ModelElementFacade> handleGetProperties(boolean follow, boolean withIdentifiers);
889
890    /**
891     * Gets all properties of this entity, this includes the attributes and navigable association
892     * ends of the entity.  The 'follow' flag indcates whether or not the inheritance hierarchy
893     * should be followed when getting all the properties.  The 'withIdentifiers' flag indicates
894     * whether or not identifiers should be included in the collection of properties.
895     * @param follow boolean
896     * TODO: Model Documentation for Entity.getProperties(follow)
897     * @param withIdentifiers boolean
898     * TODO: Model Documentation for
899     * Entity.getProperties(withIdentifiers)
900     * @return handleGetProperties(follow, withIdentifiers)
901     */
902    public Collection<ModelElementFacade> getProperties(boolean follow, boolean withIdentifiers)
903    {
904        // getProperties has no pre constraints
905        Collection<ModelElementFacade> returnValue = handleGetProperties(follow, withIdentifiers);
906        // getProperties has no post constraints
907        return returnValue;
908    }
909
910    /**
911     * Method to be implemented in descendants
912     * Gets all the associationEnds of this entity marked with the identifiers stereotype.
913     * @return Collection<AssociationEndFacade>
914     */
915    protected abstract Collection<AssociationEndFacade> handleGetIdentifierAssociationEnds();
916
917    /**
918     * Gets all the associationEnds of this entity marked with the identifiers stereotype.
919     * @return handleGetIdentifierAssociationEnds()
920     */
921    public Collection<AssociationEndFacade> getIdentifierAssociationEnds()
922    {
923        // getIdentifierAssociationEnds has no pre constraints
924        Collection<AssociationEndFacade> returnValue = handleGetIdentifierAssociationEnds();
925        // getIdentifierAssociationEnds has no post constraints
926        return returnValue;
927    }
928
929    /**
930     * Method to be implemented in descendants
931     * Gets all attributes of the entity, and optionally retieves the super entities attributes as
932     * well as excludes the entity's identifiers if 'withIdentifiers' is set to false and exclude
933     * derived attributes if 'withDerived' is set to false.
934     * @param follow
935     * @param withIdentifiers
936     * @param withDerived
937     * @return Collection<AttributeFacade>
938     */
939    protected abstract Collection<AttributeFacade> handleGetAttributes(boolean follow, boolean withIdentifiers, boolean withDerived);
940
941    /**
942     * Gets all attributes of the entity, and optionally retieves the super entities attributes as
943     * well as excludes the entity's identifiers if 'withIdentifiers' is set to false and exclude
944     * derived attributes if 'withDerived' is set to false.
945     * @param follow boolean
946     * Whether or not to follow the inheritance hierarchy when retreiving attributes.
947     * @param withIdentifiers boolean
948     * Whether or not to include identifiers in the returned attributes.
949     * @param withDerived boolean
950     * Whether or not to include derived attributes in the returned attributes.
951     * @return handleGetAttributes(follow, withIdentifiers, withDerived)
952     */
953    public Collection<AttributeFacade> getAttributes(boolean follow, boolean withIdentifiers, boolean withDerived)
954    {
955        // getAttributes has no pre constraints
956        Collection<AttributeFacade> returnValue = handleGetAttributes(follow, withIdentifiers, withDerived);
957        // getAttributes has no post constraints
958        return returnValue;
959    }
960
961    /**
962     * Method to be implemented in descendants
963     * Gets a comma separated list of attribute names.  If 'follow' is true, will travel up the
964     * inheritance hiearchy to include attributes in parent entities as well.  If 'withIdentifiers'
965     * is true, will include identifiers  and  if 'withDerived' is set to true, will include derived
966     * attributes.
967     * @param follow
968     * @param withIdentifiers
969     * @param withDerived
970     * @return String
971     */
972    protected abstract String handleGetAttributeNameList(boolean follow, boolean withIdentifiers, boolean withDerived);
973
974    /**
975     * Gets a comma separated list of attribute names.  If 'follow' is true, will travel up the
976     * inheritance hiearchy to include attributes in parent entities as well.  If 'withIdentifiers'
977     * is true, will include identifiers  and  if 'withDerived' is set to true, will include derived
978     * attributes.
979     * @param follow boolean
980     * Whether or not to 'follow' the inheritance hierarchy.
981     * @param withIdentifiers boolean
982     * Whether or not to include identifiers in the returned attributes.
983     * @param withDerived boolean
984     * Whether or not to include derived attributes in the returned attributes.
985     * @return handleGetAttributeNameList(follow, withIdentifiers, withDerived)
986     */
987    public String getAttributeNameList(boolean follow, boolean withIdentifiers, boolean withDerived)
988    {
989        // getAttributeNameList has no pre constraints
990        String returnValue = handleGetAttributeNameList(follow, withIdentifiers, withDerived);
991        // getAttributeNameList has no post constraints
992        return returnValue;
993    }
994
995    // ------------- associations ------------------
996
997    /**
998     * Represents a persistent entity.
999     * @return (Collection<DependencyFacade>)handleGetEntityReferences()
1000     */
1001    public final Collection<DependencyFacade> getEntityReferences()
1002    {
1003        Collection<DependencyFacade> getEntityReferences1r = null;
1004        // entity has no pre constraints
1005        Collection result = handleGetEntityReferences();
1006        List shieldedResult = this.shieldedElements(result);
1007        try
1008        {
1009            getEntityReferences1r = (Collection<DependencyFacade>)shieldedResult;
1010        }
1011        catch (ClassCastException ex)
1012        {
1013            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
1014            EntityLogic.logger.warn("incorrect metafacade cast for EntityLogic.getEntityReferences Collection<DependencyFacade> " + result + ": " + shieldedResult);
1015        }
1016        // entity has no post constraints
1017        return getEntityReferences1r;
1018    }
1019
1020    /**
1021     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
1022     * @return  Collection
1023     */
1024    protected abstract Collection handleGetEntityReferences();
1025
1026    /**
1027     * Represents a persistent entity.
1028     * @return (EntityAssociationEnd)handleGetParentEnd()
1029     */
1030    public final EntityAssociationEnd getParentEnd()
1031    {
1032        EntityAssociationEnd getParentEnd2r = null;
1033        // entity has no pre constraints
1034        Object result = handleGetParentEnd();
1035        MetafacadeBase shieldedResult = this.shieldedElement(result);
1036        try
1037        {
1038            getParentEnd2r = (EntityAssociationEnd)shieldedResult;
1039        }
1040        catch (ClassCastException ex)
1041        {
1042            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
1043            EntityLogic.logger.warn("incorrect metafacade cast for EntityLogic.getParentEnd EntityAssociationEnd " + result + ": " + shieldedResult);
1044        }
1045        // entity has no post constraints
1046        return getParentEnd2r;
1047    }
1048
1049    /**
1050     * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type
1051     * @return Object
1052     */
1053    protected abstract Object handleGetParentEnd();
1054
1055    /**
1056     * Represents a persistent entity.
1057     * @return (Collection<ModelElementFacade>)handleGetIdentifiers()
1058     */
1059    public final Collection<ModelElementFacade> getIdentifiers()
1060    {
1061        Collection<ModelElementFacade> getIdentifiers3r = null;
1062        // entity has no pre constraints
1063        Collection result = handleGetIdentifiers();
1064        List shieldedResult = this.shieldedElements(result);
1065        try
1066        {
1067            getIdentifiers3r = (Collection<ModelElementFacade>)shieldedResult;
1068        }
1069        catch (ClassCastException ex)
1070        {
1071            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
1072            EntityLogic.logger.warn("incorrect metafacade cast for EntityLogic.getIdentifiers Collection<ModelElementFacade> " + result + ": " + shieldedResult);
1073        }
1074        // entity has no post constraints
1075        return getIdentifiers3r;
1076    }
1077
1078    /**
1079     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
1080     * @return  Collection
1081     */
1082    protected abstract Collection handleGetIdentifiers();
1083
1084    /**
1085     * Represents a persistent entity.
1086     * @return (Collection<EntityAssociationEnd>)handleGetChildEnds()
1087     */
1088    public final Collection<EntityAssociationEnd> getChildEnds()
1089    {
1090        Collection<EntityAssociationEnd> getChildEnds4r = null;
1091        // entity has no pre constraints
1092        Collection result = handleGetChildEnds();
1093        List shieldedResult = this.shieldedElements(result);
1094        try
1095        {
1096            getChildEnds4r = (Collection<EntityAssociationEnd>)shieldedResult;
1097        }
1098        catch (ClassCastException ex)
1099        {
1100            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
1101            EntityLogic.logger.warn("incorrect metafacade cast for EntityLogic.getChildEnds Collection<EntityAssociationEnd> " + result + ": " + shieldedResult);
1102        }
1103        // entity has no post constraints
1104        return getChildEnds4r;
1105    }
1106
1107    /**
1108     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
1109     * @return  Collection
1110     */
1111    protected abstract Collection handleGetChildEnds();
1112
1113    /**
1114     * Represents a persistent entity.
1115     * @return (Collection<EntityQueryOperation>)handleGetQueryOperations()
1116     */
1117    public final Collection<EntityQueryOperation> getQueryOperations()
1118    {
1119        Collection<EntityQueryOperation> getQueryOperations5r = null;
1120        // entity has no pre constraints
1121        Collection result = handleGetQueryOperations();
1122        List shieldedResult = this.shieldedElements(result);
1123        try
1124        {
1125            getQueryOperations5r = (Collection<EntityQueryOperation>)shieldedResult;
1126        }
1127        catch (ClassCastException ex)
1128        {
1129            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
1130            EntityLogic.logger.warn("incorrect metafacade cast for EntityLogic.getQueryOperations Collection<EntityQueryOperation> " + result + ": " + shieldedResult);
1131        }
1132        // entity has no post constraints
1133        return getQueryOperations5r;
1134    }
1135
1136    /**
1137     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
1138     * @return  Collection
1139     */
1140    protected abstract Collection handleGetQueryOperations();
1141
1142    /**
1143     * Represents a persistent entity.
1144     * @return (Collection<OperationFacade>)handleGetBusinessOperations()
1145     */
1146    public final Collection<OperationFacade> getBusinessOperations()
1147    {
1148        Collection<OperationFacade> getBusinessOperations6r = null;
1149        // entity has no pre constraints
1150        Collection result = handleGetBusinessOperations();
1151        List shieldedResult = this.shieldedElements(result);
1152        try
1153        {
1154            getBusinessOperations6r = (Collection<OperationFacade>)shieldedResult;
1155        }
1156        catch (ClassCastException ex)
1157        {
1158            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
1159            EntityLogic.logger.warn("incorrect metafacade cast for EntityLogic.getBusinessOperations Collection<OperationFacade> " + result + ": " + shieldedResult);
1160        }
1161        // entity has no post constraints
1162        return getBusinessOperations6r;
1163    }
1164
1165    /**
1166     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
1167     * @return  Collection
1168     */
1169    protected abstract Collection handleGetBusinessOperations();
1170
1171    /**
1172     * Represents a persistent entity.
1173     * @return (Collection<DependencyFacade>)handleGetAllEntityReferences()
1174     */
1175    public final Collection<DependencyFacade> getAllEntityReferences()
1176    {
1177        Collection<DependencyFacade> getAllEntityReferences7r = null;
1178        // entity has no pre constraints
1179        Collection result = handleGetAllEntityReferences();
1180        List shieldedResult = this.shieldedElements(result);
1181        try
1182        {
1183            getAllEntityReferences7r = (Collection<DependencyFacade>)shieldedResult;
1184        }
1185        catch (ClassCastException ex)
1186        {
1187            // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn
1188            EntityLogic.logger.warn("incorrect metafacade cast for EntityLogic.getAllEntityReferences Collection<DependencyFacade> " + result + ": " + shieldedResult);
1189        }
1190        // entity has no post constraints
1191        return getAllEntityReferences7r;
1192    }
1193
1194    /**
1195     * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type
1196     * @return  Collection
1197     */
1198    protected abstract Collection handleGetAllEntityReferences();
1199
1200    /**
1201     * <p><b>Constraint:</b> org::andromda::metafacades::uml::Entity::entity must have at least one primary key</p>
1202     * <p><b>Error:</b> Each entity must have at least one identifier defined.</p>
1203     * <p><b>OCL:</b> context Entity inv: identifiersPresent</p>
1204     * <p><b>Constraint:</b> org::andromda::metafacades::uml::Entity::entities can only specialize other entites</p>
1205     * <p><b>Error:</b> An entity can only specialize another entity.</p>
1206     * <p><b>OCL:</b> context Entity inv : specializations -> notEmpty() implies specializations -> forAll(oclIsKindOf(Entity))</p>
1207     * @param validationMessages Collection<ModelValidationMessage>
1208     * @see ClassifierFacadeLogicImpl#validateInvariants(Collection validationMessages)
1209     */
1210    @Override
1211    public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
1212    {
1213        super.validateInvariants(validationMessages);
1214        try
1215        {
1216            final Object contextElement = this.THIS();
1217            boolean constraintValid = OCLResultEnsurer.ensure(OCLIntrospector.invoke(contextElement,"identifiersPresent"));
1218            if (!constraintValid)
1219            {
1220                validationMessages.add(
1221                    new ModelValidationMessage(
1222                        (MetafacadeBase)contextElement ,
1223                        "org::andromda::metafacades::uml::Entity::entity must have at least one primary key",
1224                        "Each entity must have at least one identifier defined."));
1225            }
1226        }
1227        catch (Throwable th)
1228        {
1229            Throwable cause = th.getCause();
1230            int depth = 0; // Some throwables have infinite recursion
1231            while (cause != null && depth < 7)
1232            {
1233                th = cause;
1234                depth++;
1235            }
1236            logger.error("Error validating constraint 'org::andromda::metafacades::uml::Entity::entity must have at least one primary key' ON "
1237                + this.THIS().toString() + ": " + th.getMessage(), th);
1238        }
1239        try
1240        {
1241            final Object contextElement = this.THIS();
1242            boolean constraintValid = OCLResultEnsurer.ensure((Boolean.valueOf(String.valueOf(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"specializations")))).booleanValue()?OCLCollections.forAll(OCLIntrospector.invoke(contextElement,"specializations"),new Predicate(){public boolean evaluate(Object object){return Boolean.valueOf(String.valueOf(object instanceof Entity)).booleanValue();}}):true));
1243            if (!constraintValid)
1244            {
1245                validationMessages.add(
1246                    new ModelValidationMessage(
1247                        (MetafacadeBase)contextElement ,
1248                        "org::andromda::metafacades::uml::Entity::entities can only specialize other entites",
1249                        "An entity can only specialize another entity."));
1250            }
1251        }
1252        catch (Throwable th)
1253        {
1254            Throwable cause = th.getCause();
1255            int depth = 0; // Some throwables have infinite recursion
1256            while (cause != null && depth < 7)
1257            {
1258                th = cause;
1259                depth++;
1260            }
1261            logger.error("Error validating constraint 'org::andromda::metafacades::uml::Entity::entities can only specialize other entites' ON "
1262                + this.THIS().toString() + ": " + th.getMessage(), th);
1263        }
1264    }
1265}