001: package org.andromda.metafacades.uml14;
002:
003: import java.util.ArrayList;
004: import java.util.Collection;
005: import java.util.Iterator;
006: import java.util.LinkedHashSet;
007: import java.util.List;
008: import java.util.Set;
009:
010: import org.andromda.core.metafacade.MetafacadeConstants;
011: import org.andromda.metafacades.uml.AssociationEndFacade;
012: import org.andromda.metafacades.uml.AttributeFacade;
013: import org.andromda.metafacades.uml.ClassifierFacade;
014: import org.andromda.metafacades.uml.DependencyFacade;
015: import org.andromda.metafacades.uml.Entity;
016: import org.andromda.metafacades.uml.EntityAssociationEnd;
017: import org.andromda.metafacades.uml.EntityAttribute;
018: import org.andromda.metafacades.uml.EntityMetafacadeUtils;
019: import org.andromda.metafacades.uml.EntityQueryOperation;
020: import org.andromda.metafacades.uml.FilteredCollection;
021: import org.andromda.metafacades.uml.MetafacadeUtils;
022: import org.andromda.metafacades.uml.ModelElementFacade;
023: import org.andromda.metafacades.uml.NameMasker;
024: import org.andromda.metafacades.uml.UMLMetafacadeProperties;
025: import org.andromda.metafacades.uml.UMLProfile;
026: import org.andromda.utils.StringUtilsHelper;
027: import org.apache.commons.collections.Closure;
028: import org.apache.commons.collections.CollectionUtils;
029: import org.apache.commons.collections.Predicate;
030: import org.apache.commons.collections.Transformer;
031: import org.apache.commons.lang.ObjectUtils;
032: import org.apache.commons.lang.StringUtils;
033: import org.omg.uml.foundation.core.Attribute;
034: import org.omg.uml.foundation.core.Classifier;
035:
036: /**
037: * Metaclass facade implementation.
038: */
039: public class EntityLogicImpl extends EntityLogic {
040: public EntityLogicImpl(final java.lang.Object metaObject,
041: final String context) {
042: super (metaObject, context);
043: }
044:
045: /**
046: * A collection of MOF ids for entities that have dynamic
047: * identifiers present.
048: */
049: private static final Collection dynamicIdentifiersPresent = new ArrayList();
050:
051: /**
052: * @see org.andromda.core.metafacade.MetafacadeBase#initialize()
053: */
054: public void initialize() {
055: super .initialize();
056:
057: // if there are no identifiers on this entity, create and add one.
058: // enumeration don't have identifiers since they are not entities
059: if (!this .isIdentifiersPresent()
060: && this .isAllowDefaultIdentifiers()) {
061: this .createIdentifier();
062: dynamicIdentifiersPresent.add(this .getId());
063: }
064: }
065:
066: /**
067: * Overridden to provide name masking.
068: *
069: * @see org.andromda.metafacades.uml.ModelElementFacade#getName()
070: */
071: protected String handleGetName() {
072: final String nameMask = String
073: .valueOf(this
074: .getConfiguredProperty(UMLMetafacadeProperties.ENTITY_NAME_MASK));
075: return NameMasker.mask(super .handleGetName(), nameMask);
076: }
077:
078: /**
079: * @see org.andromda.metafacades.uml.Entity#getQueryOperations()
080: */
081: protected java.util.Collection handleGetQueryOperations() {
082: return this .getQueryOperations(false);
083: }
084:
085: /**
086: * @see org.andromda.metafacades.uml.Entity#getQueryOperations(boolean)
087: */
088: protected java.util.Collection handleGetQueryOperations(
089: final boolean follow) {
090: final Collection queryOperations = new ArrayList(this
091: .getOperations());
092:
093: MetafacadeUtils.filterByType(queryOperations,
094: EntityQueryOperation.class);
095: for (ClassifierFacade super Class = (ClassifierFacade) getGeneralization(); super Class != null
096: && follow; super Class = (ClassifierFacade) super Class
097: .getGeneralization()) {
098: if (Entity.class.isAssignableFrom(super Class.getClass())) {
099: Entity entity = (Entity) super Class;
100: queryOperations.addAll(entity.getQueryOperations());
101: }
102: }
103: return queryOperations;
104: }
105:
106: /**
107: * @see org.andromda.metafacades.uml.Entity#getIdentifiers()
108: */
109: protected java.util.Collection handleGetIdentifiers() {
110: return this .getIdentifiers(true);
111: }
112:
113: /**
114: * @see org.andromda.metafacades.uml.Entity#getIdentifiers(boolean)
115: */
116: protected java.util.Collection handleGetIdentifiers(
117: final boolean follow) {
118: return EntityMetafacadeUtils.getIdentifiers(this , follow);
119: }
120:
121: /**
122: * Creates an identifier from the default identifier properties specified within a namespace.
123: */
124: private void createIdentifier() {
125: // first check if the foreign identifier flag is set, and
126: // let those taken precedence if so
127: if (!this .checkForAndAddForeignIdentifiers()) {
128: this .createIdentifier(this .getDefaultIdentifier(), this
129: .getDefaultIdentifierType(), this
130: .getDefaultIdentifierVisibility());
131: }
132: }
133:
134: /**
135: * Creates a new identifier and adds it to the underlying meta model
136: * classifier instance.
137: *
138: * @param name the name to give the identifier
139: * @param type the type to give the identifier
140: * @param visibility the visibility to give the identifier
141: */
142: private void createIdentifier(final String name, final String type,
143: final String visibility) {
144: final Classifier classifier = (Classifier) this .metaObject;
145:
146: // if we auto-create entity identifiers it will only be on hierarchy roots,
147: // problems would arise when calls to #checkForAndAddForeignIdentifiers()
148: // navigate over associated entities, effectively initializing their facade instances:
149: // this results in subclasses having an identifier generated before their ancestors
150: // ideally the method mentioned above would not make use of facades but meta-classes only,
151: // if one is to refactor it that way this comment may be removed together with the line of code under it
152: //
153: // notice how the next line of code does not make use of facades, this is done on purpose in order
154: // to avoid using uninitialized facades
155: //
156: // (Wouter, Sept. 20 2006) also see other UML implementations
157: if (!classifier.getGeneralization().isEmpty())
158: return;
159:
160: // only create the identifier if an identifer with the name doesn't
161: // already exist
162: if (!UML14MetafacadeUtils.attributeExists(classifier, name)) {
163: final Attribute identifier = UML14MetafacadeUtils
164: .createAttribute(
165: name,
166: type,
167: visibility,
168: MetafacadeConstants.NAMESPACE_SCOPE_OPERATOR);
169:
170: identifier
171: .getStereotype()
172: .add(
173: UML14MetafacadeUtils
174: .findOrCreateStereotype(UMLProfile.STEREOTYPE_IDENTIFIER));
175:
176: classifier.getFeature().add(identifier);
177: }
178: }
179:
180: /**
181: * @see org.andromda.metafacades.uml.Entity#isIdentifiersPresent()
182: */
183: protected boolean handleIsIdentifiersPresent() {
184: final Collection identifiers = this .getIdentifiers(true);
185: return identifiers != null && !identifiers.isEmpty();
186: }
187:
188: /**
189: * @see org.andromda.metafacades.uml.Entity#isDynamicIdentifiersPresent()
190: */
191: protected boolean handleIsDynamicIdentifiersPresent() {
192: return dynamicIdentifiersPresent.contains(this .getId());
193: }
194:
195: /**
196: * @see org.andromda.metafacades.uml.Entity#getTableName()
197: */
198: protected String handleGetTableName() {
199: final String prefixProperty = UMLMetafacadeProperties.TABLE_NAME_PREFIX;
200: final String tableNamePrefix = this
201: .isConfiguredProperty(prefixProperty) ? ObjectUtils
202: .toString(this .getConfiguredProperty(prefixProperty))
203: : null;
204: return EntityMetafacadeUtils
205: .getSqlNameFromTaggedValue(
206: tableNamePrefix,
207: this ,
208: UMLProfile.TAGGEDVALUE_PERSISTENCE_TABLE,
209: this .getMaxSqlNameLength(),
210: this
211: .getConfiguredProperty(UMLMetafacadeProperties.SQL_NAME_SEPARATOR));
212: }
213:
214: /**
215: * @see org.andromda.metafacades.uml.Entity#getOperationCallFromAttributes(boolean)
216: */
217: protected String handleGetOperationCallFromAttributes(
218: final boolean withIdentifiers) {
219: return this .getOperationCallFromAttributes(withIdentifiers,
220: false);
221: }
222:
223: /**
224: * @see org.andromda.metafacades.uml.Entity#getOperationCallFromAttributes(boolean, boolean)
225: */
226: protected String handleGetOperationCallFromAttributes(
227: final boolean withIdentifiers, final boolean follow) {
228: final StringBuffer buffer = new StringBuffer();
229: String separator = "";
230: buffer.append("(");
231:
232: final Collection attributes = new ArrayList(this
233: .getAttributes());
234:
235: for (ClassifierFacade super Class = (ClassifierFacade) getGeneralization(); super Class != null
236: && follow; super Class = (ClassifierFacade) super Class
237: .getGeneralization()) {
238: if (super Class instanceof Entity) {
239: final Entity entity = (Entity) super Class;
240: attributes.addAll(entity.getAttributes());
241: }
242: }
243:
244: if (attributes != null && !attributes.isEmpty()) {
245: for (final Iterator iterator = attributes.iterator(); iterator
246: .hasNext();) {
247: final EntityAttribute attribute = (EntityAttribute) iterator
248: .next();
249: if (withIdentifiers || !attribute.isIdentifier()) {
250: buffer.append(separator);
251: if (attribute.getType() != null) {
252: buffer.append(attribute.getType()
253: .getFullyQualifiedName());
254: }
255: buffer.append(" ");
256: buffer.append(attribute.getName());
257: separator = ", ";
258: }
259: }
260: }
261: buffer.append(")");
262: return buffer.toString();
263: }
264:
265: /**
266: * @see org.andromda.metafacades.uml.Entity#getAttributeTypeList(boolean, boolean)
267: */
268: protected String handleGetAttributeTypeList(final boolean follow,
269: final boolean withIdentifiers) {
270: return this .getTypeList(this .getAttributes(follow,
271: withIdentifiers));
272: }
273:
274: /**
275: * @see org.andromda.metafacades.uml.Entity#getAttributeNameList(boolean, boolean)
276: */
277: protected String handleGetAttributeNameList(final boolean follow,
278: final boolean withIdentifiers) {
279: return this .getNameList(this .getAttributes(follow,
280: withIdentifiers));
281: }
282:
283: /**
284: * @see org.andromda.metafacades.uml.Entity#getRequiredAttributeTypeList(boolean, boolean)
285: */
286: protected String handleGetRequiredAttributeTypeList(
287: final boolean follow, final boolean withIdentifiers) {
288: return this .getTypeList(this .getRequiredAttributes(follow,
289: withIdentifiers));
290: }
291:
292: /**
293: * @see org.andromda.metafacades.uml.Entity#getRequiredAttributeNameList(boolean, boolean)
294: */
295: protected String handleGetRequiredAttributeNameList(
296: final boolean follow, final boolean withIdentifiers) {
297: return this .getNameList(this .getRequiredAttributes(follow,
298: withIdentifiers));
299: }
300:
301: /**
302: * @see org.andromda.metafacades.uml.Entity#getRequiredPropertyTypeList(boolean, boolean)
303: */
304: protected String handleGetRequiredPropertyTypeList(
305: final boolean follow, final boolean withIdentifiers) {
306: return this .getTypeList(this .getRequiredProperties(follow,
307: withIdentifiers));
308: }
309:
310: /**
311: * @see org.andromda.metafacades.uml.Entity#getRequiredPropertyNameList(boolean, boolean)
312: */
313: protected String handleGetRequiredPropertyNameList(
314: final boolean follow, final boolean withIdentifiers) {
315: return this .getNameList(this .getRequiredProperties(follow,
316: withIdentifiers));
317: }
318:
319: /**
320: * Constructs a comma seperated list of attribute type names from the passed in collection of
321: * <code>attributes</code>.
322: *
323: * @param attributes the attributes to construct the list from.
324: * @return the comma seperated list of attribute types.
325: */
326: private String getTypeList(final Collection attributes) {
327: final StringBuffer list = new StringBuffer();
328: final String comma = ", ";
329: CollectionUtils.forAllDo(attributes, new Closure() {
330: public void execute(final Object object) {
331: if (object instanceof AttributeFacade) {
332: final AttributeFacade attribute = (AttributeFacade) object;
333: if (attribute.getType() != null) {
334: list.append(attribute.getType()
335: .getFullyQualifiedName());
336: list.append(comma);
337: }
338: }
339: if (object instanceof AssociationEndFacade) {
340: final AssociationEndFacade associationEnd = (AssociationEndFacade) object;
341: if (associationEnd.getType() != null) {
342: list.append(associationEnd.getType()
343: .getFullyQualifiedName());
344: list.append(comma);
345: }
346: }
347: }
348: });
349: if (list.toString().endsWith(comma)) {
350: list.delete(list.lastIndexOf(comma), list.length());
351: }
352: return list.toString();
353: }
354:
355: /**
356: * Constructs a comma seperated list of attribute names from the passed in collection of <code>attributes</code>.
357: *
358: * @param properties the properties to construct the list from.
359: * @return the comma seperated list of attribute names.
360: */
361: private String getNameList(final Collection properties) {
362: final StringBuffer list = new StringBuffer();
363: final String comma = ", ";
364: CollectionUtils.forAllDo(properties, new Closure() {
365: public void execute(Object object) {
366: if (object instanceof EntityAttribute) {
367: list.append(((AttributeFacade) object).getName());
368: list.append(comma);
369: }
370: if (object instanceof EntityAssociationEnd) {
371: list.append(((AssociationEndFacade) object)
372: .getName());
373: list.append(comma);
374: }
375: }
376: });
377: if (list.toString().endsWith(comma)) {
378: list.delete(list.lastIndexOf(comma), list.length());
379: }
380: return list.toString();
381: }
382:
383: /**
384: * @see org.andromda.metafacades.uml.Entity#isChild()
385: */
386: protected boolean handleIsChild() {
387: return CollectionUtils.find(this .getAssociationEnds(),
388: new Predicate() {
389: public boolean evaluate(Object object) {
390: return ((AssociationEndFacade) object)
391: .getOtherEnd().isComposition();
392: }
393: }) != null;
394: }
395:
396: /**
397: * @see org.andromda.metafacades.uml.Entity#getParentEnd()
398: */
399: protected Object handleGetParentEnd() {
400: Object parentEnd = null;
401: final AssociationEndFacade end = (AssociationEndFacade) CollectionUtils
402: .find(this .getAssociationEnds(), new Predicate() {
403: public boolean evaluate(Object object) {
404: return ((AssociationEndFacade) object)
405: .getOtherEnd().isComposition();
406: }
407: });
408: if (end != null) {
409: parentEnd = end.getOtherEnd();
410: }
411: return parentEnd;
412: }
413:
414: /**
415: * @see org.andromda.metafacades.uml.Entity#getChildEnds()
416: */
417: protected Collection handleGetChildEnds() {
418: final Collection childEnds = new FilteredCollection(this
419: .getAssociationEnds()) {
420: public boolean evaluate(Object object) {
421: return ((AssociationEndFacade) object).isComposition();
422: }
423: };
424: CollectionUtils.transform(childEnds, new Transformer() {
425: public Object transform(Object object) {
426: return ((AssociationEndFacade) object).getOtherEnd();
427: }
428: });
429: return childEnds;
430: }
431:
432: /**
433: * @see org.andromda.metafacades.uml.Entity#getBusinessOperations()
434: */
435: protected Collection handleGetBusinessOperations() {
436: final Collection businessOperations = new ArrayList(this
437: .getImplementationOperations());
438: MetafacadeUtils.filterByNotType(businessOperations,
439: EntityQueryOperation.class);
440: return businessOperations;
441: }
442:
443: /**
444: * @see org.andromda.metafacades.uml.Entity#getEntityReferences()
445: */
446: protected Collection handleGetEntityReferences() {
447: return new FilteredCollection(this .getSourceDependencies()) {
448: public boolean evaluate(Object object) {
449: ModelElementFacade targetElement = ((DependencyFacade) object)
450: .getTargetElement();
451: return targetElement instanceof Entity;
452: }
453: };
454: }
455:
456: /**
457: * @see org.andromda.metafacades.uml.Entity#getAttributes(boolean, boolean)
458: */
459: protected Collection handleGetAttributes(boolean follow,
460: final boolean withIdentifiers) {
461: final Collection attributes = this .getAttributes(follow);
462: CollectionUtils.filter(attributes, new Predicate() {
463: public boolean evaluate(Object object) {
464: boolean valid = true;
465: if (!withIdentifiers
466: && object instanceof EntityAttribute) {
467: valid = !((EntityAttribute) object).isIdentifier();
468: }
469: return valid;
470: }
471: });
472: return attributes;
473: }
474:
475: /**
476: * @see org.andromda.metafacades.uml.Entity#getProperties(boolean, boolean)
477: */
478: protected Collection handleGetProperties(boolean follow,
479: final boolean withIdentifiers) {
480: final Collection properties = this .getProperties(follow);
481: CollectionUtils.filter(properties, new Predicate() {
482: public boolean evaluate(Object object) {
483: boolean valid = true;
484: if (!withIdentifiers
485: && object instanceof EntityAttribute) {
486: valid = !((EntityAttribute) object).isIdentifier();
487: }
488: return valid;
489: }
490: });
491: return properties;
492: }
493:
494: /**
495: * @see org.andromda.metafacades.uml.Entity#getRequiredAttributes(boolean, boolean)
496: */
497: protected Collection handleGetRequiredAttributes(boolean follow,
498: final boolean withIdentifiers) {
499: final Collection attributes = this .getAttributes(follow,
500: withIdentifiers);
501: CollectionUtils.filter(attributes, new Predicate() {
502: public boolean evaluate(Object object) {
503: boolean valid;
504: valid = ((AttributeFacade) object).isRequired();
505: if (valid && !withIdentifiers
506: && object instanceof EntityAttribute) {
507: valid = !((EntityAttribute) object).isIdentifier();
508: }
509: return valid;
510: }
511: });
512: return attributes;
513: }
514:
515: /**
516: * @see org.andromda.metafacades.uml.Entity#getRequiredProperties(boolean, boolean)
517: */
518: protected Collection handleGetRequiredProperties(
519: final boolean follow, final boolean withIdentifiers) {
520: final Set properties = new LinkedHashSet(this .getProperties(
521: follow, withIdentifiers));
522: CollectionUtils.filter(properties, new Predicate() {
523: public boolean evaluate(final Object object) {
524: boolean valid = false;
525: if (object instanceof AttributeFacade) {
526: valid = ((AttributeFacade) object).isRequired();
527: if (valid && !withIdentifiers
528: && object instanceof EntityAttribute) {
529: valid = !((EntityAttribute) object)
530: .isIdentifier();
531: }
532: } else if (object instanceof AssociationEndFacade) {
533: valid = ((AssociationEndFacade) object)
534: .isRequired();
535: }
536: return valid;
537: }
538: });
539:
540: List sortedProperties = new ArrayList(properties);
541: MetafacadeUtils.sortByFullyQualifiedName(sortedProperties);
542: return sortedProperties;
543: }
544:
545: /**
546: * Gets the maximum name length SQL names may be
547: */
548: protected Short handleGetMaxSqlNameLength() {
549: return Short
550: .valueOf((String) this
551: .getConfiguredProperty(UMLMetafacadeProperties.MAX_SQL_NAME_LENGTH));
552: }
553:
554: /**
555: * Returns true/false on whether or not default identifiers are allowed
556: */
557: private boolean isAllowDefaultIdentifiers() {
558: return Boolean
559: .valueOf(
560: (String) this
561: .getConfiguredProperty(UMLMetafacadeProperties.ALLOW_DEFAULT_IDENTITIFIERS))
562: .booleanValue();
563: }
564:
565: /**
566: * Gets the name of the default identifier.
567: */
568: private String getDefaultIdentifier() {
569: return ObjectUtils
570: .toString(
571: this
572: .getConfiguredProperty(UMLMetafacadeProperties.DEFAULT_IDENTIFIER_PATTERN))
573: .replaceAll(
574: "\\{0\\}",
575: StringUtilsHelper.lowerCamelCaseName(this
576: .getName()));
577: }
578:
579: /**
580: * Gets the name of the default identifier type.
581: */
582: private String getDefaultIdentifierType() {
583: return (String) this
584: .getConfiguredProperty(UMLMetafacadeProperties.DEFAULT_IDENTIFIER_TYPE);
585: }
586:
587: /**
588: * Gets the default identifier visibility.
589: */
590: private String getDefaultIdentifierVisibility() {
591: return (String) this
592: .getConfiguredProperty(UMLMetafacadeProperties.DEFAULT_IDENTIFIER_VISIBILITY);
593: }
594:
595: /**
596: * Checks to see if this entity has any associations where the foreign identifier flag may be set, and if so creates
597: * and adds identifiers just like the foreign entity to this entity.
598: *
599: * @return true if any identifiers were added, false otherwise
600: */
601: private boolean checkForAndAddForeignIdentifiers() {
602: boolean identifiersAdded = false;
603: final EntityAssociationEnd end = this .getForeignIdentifierEnd();
604: if (end != null && end.getType() instanceof Entity) {
605: final Entity foreignEntity = (Entity) end.getOtherEnd()
606: .getType();
607: final Collection identifiers = EntityMetafacadeUtils
608: .getIdentifiers(foreignEntity, true);
609: for (final Iterator iterator = identifiers.iterator(); iterator
610: .hasNext();) {
611: final AttributeFacade identifier = (AttributeFacade) iterator
612: .next();
613: this .createIdentifier(identifier.getName(), identifier
614: .getType().getFullyQualifiedName(true),
615: identifier.getVisibility());
616: identifiersAdded = true;
617: }
618: }
619: return identifiersAdded;
620: }
621:
622: /**
623: * Override to filter out any association ends that point to model elements other than other entities.
624: *
625: * @see org.andromda.metafacades.uml.ClassifierFacade#getAssociationEnds()
626: */
627: public List handleGetAssociationEnds() {
628: final List associationEnds = (List) this .shieldedElements(super
629: .handleGetAssociationEnds());
630: CollectionUtils.filter(associationEnds, new Predicate() {
631: public boolean evaluate(Object object) {
632: return ((AssociationEndFacade) object).getOtherEnd()
633: .getType() instanceof Entity;
634: }
635: });
636: return associationEnds;
637: }
638:
639: /**
640: * @see org.andromda.metafacades.uml14.EntityLogic#handleIsUsingForeignIdentifier()
641: */
642: protected boolean handleIsUsingForeignIdentifier() {
643: return this .getForeignIdentifierEnd() != null;
644: }
645:
646: /**
647: * Gets the association end that is flagged as having the foreign identifier set (or null if none is).
648: */
649: private EntityAssociationEnd getForeignIdentifierEnd() {
650: return (EntityAssociationEnd) CollectionUtils.find(this
651: .getAssociationEnds(), new Predicate() {
652: public boolean evaluate(Object object) {
653: boolean valid = false;
654: if (object != null
655: && EntityAssociationEnd.class
656: .isAssignableFrom(object.getClass())) {
657: EntityAssociationEnd end = (EntityAssociationEnd) object;
658: valid = end.isForeignIdentifier();
659: }
660: return valid;
661: }
662: });
663: }
664:
665: /**
666: * @see org.andromda.metafacades.uml.Entity#isUsingAssignedIdentifier()
667: */
668: protected boolean handleIsUsingAssignedIdentifier() {
669: boolean assigned = false;
670: final Collection identifiers = this .getIdentifiers();
671: if (identifiers != null && !identifiers.isEmpty()) {
672: final AttributeFacade identifier = (AttributeFacade) identifiers
673: .iterator().next();
674: assigned = Boolean
675: .valueOf(
676: ObjectUtils
677: .toString(identifier
678: .findTaggedValue(UMLProfile.TAGGEDVALUE_PERSISTENCE_ASSIGNED_IDENTIFIER)))
679: .booleanValue();
680: }
681: return assigned;
682: }
683:
684: /**
685: * @see org.andromda.metafacades.uml.Entity#getSchema()
686: */
687: protected String handleGetSchema() {
688: String schemaName = ObjectUtils
689: .toString(this
690: .findTaggedValue(UMLProfile.TAGGEDVALUE_PERSISTENCE_SCHEMA));
691: if (StringUtils.isBlank(schemaName)) {
692: schemaName = ObjectUtils
693: .toString(this
694: .getConfiguredProperty(UMLMetafacadeProperties.SCHEMA_NAME));
695: }
696: return schemaName;
697: }
698:
699: /**
700: * @see org.andromda.metafacades.uml.Entity#getIdentifierAssociationEnds()
701: */
702: protected Collection handleGetIdentifierAssociationEnds() {
703: final Collection associationEnds = new ArrayList(this
704: .getAssociationEnds());
705: if (associationEnds != null) {
706: MetafacadeUtils.filterByStereotype(associationEnds,
707: UMLProfile.STEREOTYPE_IDENTIFIER);
708: }
709: return associationEnds;
710: }
711:
712: /**
713: * @see org.andromda.metafacades.uml.Entity#isCompositeIdentifier()
714: */
715: protected boolean handleIsCompositeIdentifier() {
716: int identifiers = (!this .getIdentifiers().isEmpty()) ? this
717: .getIdentifiers().size() : 0;
718: identifiers = identifiers
719: + (!this .getIdentifierAssociationEnds().isEmpty() ? this
720: .getIdentifierAssociationEnds().size()
721: : 0);
722: return identifiers >= 2;
723: }
724: }
|