svn commit: r16949 - trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java
Tom Morris <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: tfmorris
Date: 2009-03-26 10:35:39-0700
New Revision: 16949
Modified:
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java
Log:
Issue 5758: Move Property ownership to Association. Refactor.
Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java?view=diff&pathrev=16949&r1=16948&r2=16949
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java (original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/CoreFactoryEUMLImpl.java 2009-03-26 10:35:39-0700
@@ -1,5 +1,4 @@
-// $Id$
-// Copyright (c) 2007, The ArgoUML Project
+// Copyright (c) 2007,2009 Tom Morris and other contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -9,14 +8,14 @@
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-// * Neither the name of the ArgoUML Project nor the
-// names of its contributors may be used to endorse or promote products
-// derived from this software without specific prior written permission.
+// * Neither the name of the project or its contributors may be used
+// to endorse or promote products derived from this software without
+// specific prior written permission.
//
-// THIS SOFTWARE IS PROVIDED BY THE ArgoUML PROJECT ``AS IS'' AND ANY
+// THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE ArgoUML PROJECT BE LIABLE FOR ANY
+// DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -155,39 +154,30 @@
RunnableClass run = new RunnableClass() {
public void run() {
Association association = createAssociation();
- Property property1 = createAssociationEnd();
- Property property2 = createAssociationEnd();
- property1.setType((Type) type2);
- property2.setType((Type) type1);
- property1.setAssociation(association);
- property2.setAssociation(association);
- if (aggregationKind1 != null) {
- property1.setAggregation(
- (AggregationKind) aggregationKind1);
- }
- if (aggregationKind2 != null) {
- property2.setAggregation(
- (AggregationKind) aggregationKind2);
- }
+ Property property1 = buildAssociationEndInternal(association,
+ null, (Type) type1, null, null, navigability1, null,
+ (AggregationKind) aggregationKind1, null, null, null);
+ Property property2 = buildAssociationEndInternal(association,
+ null, (Type) type2, null, null, navigability2, null,
+ (AggregationKind) aggregationKind2, null, null, null);
if (associationName != null) {
association.setName(associationName);
}
- if (UMLUtil.getOwnedAttributes((Type) type1) == null) {
- association.getOwnedEnds().add(property1);
- } else {
- UMLUtil.getOwnedAttributes((Type) type1).add(property1);
- }
- if (UMLUtil.getOwnedAttributes((Type) type2) == null) {
- association.getOwnedEnds().add(property2);
- } else {
- UMLUtil.getOwnedAttributes((Type) type2).add(property2);
- }
- if (navigability1 != null) {
- property1.setIsNavigable(navigability1);
- }
- if (navigability2 != null) {
- property2.setIsNavigable(navigability2);
- }
+ association.getOwnedEnds().add(property1);
+ association.getOwnedEnds().add(property2);
+ // The code below will make navigable ends owned by the classifier
+ // at the opposite end, but let's just make them owned by the association
+ // for simplicity (don't assume everything will be like this though!)
+// if (UMLUtil.getOwnedAttributes((Type) type2) == null) {
+// association.getOwnedEnds().add(property1);
+// } else {
+// UMLUtil.getOwnedAttributes((Type) type2).add(property1);
+// }
+// if (UMLUtil.getOwnedAttributes((Type) type1) == null) {
+// association.getOwnedEnds().add(property2);
+// } else {
+// UMLUtil.getOwnedAttributes((Type) type1).add(property2);
+// }
((Type) type1).getNearestPackage().getPackagedElements().add(
association);
getParams().add(association);
@@ -324,48 +314,13 @@
}
RunnableClass run = new RunnableClass() {
public void run() {
- Property property = createAssociationEnd();
- property.setType((Type) type);
- property.setAssociation((Association) assoc);
- if (name != null) {
- property.setName(name);
- }
- if (navigable != null) {
- property.setIsNavigable(navigable);
- if (!(Boolean) navigable) {
- ((Association) assoc).getOwnedEnds().add(property);
- }
- }
- if (aggregation != null) {
- property.setAggregation((AggregationKind) aggregation);
- }
- if (visibility != null) {
- property.setVisibility((VisibilityKind) visibility);
- }
- if (multi != null) {
- if (((MultiplicityElement) multi).getLowerValue() != null) {
- property.setLowerValue(
- ((MultiplicityElement) multi).getLowerValue());
- }
- if (((MultiplicityElement) multi).getUpperValue() != null) {
- property.setLowerValue(
- ((MultiplicityElement) multi).getUpperValue());
- }
- }
- if (order != null) {
- property.setIsOrdered((Boolean) order);
- }
- if (changeable != null) {
- property.setIsReadOnly((Boolean) changeable);
- }
- if (stereo != null) {
- if (property.isStereotypeApplicable((Stereotype) stereo)) {
- property.applyStereotype((Stereotype) stereo);
- } else {
- return;
- }
- }
- getParams().add(property);
+ Property property = buildAssociationEndInternal(
+ (Association) assoc, name, (Type) type,
+ (MultiplicityElement) multi, (Stereotype) stereo,
+ navigable, (Boolean) order,
+ (AggregationKind) aggregation, (Boolean) scope,
+ (Boolean) changeable, (VisibilityKind) visibility);
+ getParams().add(property);
}
};
modelImpl.getModelEventPump().getRootContainer().setHoldEvents(true);
@@ -389,6 +344,57 @@
return (Property) run.getParams().get(0);
}
+ private Property buildAssociationEndInternal(final Association assoc,
+ final String name, final Type type,
+ final MultiplicityElement multi, final Stereotype stereo,
+ final Boolean navigable, final Boolean order,
+ final AggregationKind aggregation, final Object scope,
+ final Object changeable, final VisibilityKind visibility) {
+ // The attribute 'targetScope' of an AssociationEnd in UML1.x is no
+ // longer supported in UML2.x
+
+ Property property = createAssociationEnd();
+ property.setType((Type) type);
+ property.setAssociation((Association) assoc);
+ if (name != null) {
+ property.setName(name);
+ }
+ if (navigable != null) {
+ property.setIsNavigable(navigable);
+ if (!(Boolean) navigable) {
+ ((Association) assoc).getOwnedEnds().add(property);
+ }
+ }
+ if (aggregation != null) {
+ property.setAggregation((AggregationKind) aggregation);
+ }
+ if (visibility != null) {
+ property.setVisibility((VisibilityKind) visibility);
+ }
+ if (multi != null) {
+ if (((MultiplicityElement) multi).getLowerValue() != null) {
+ property.setLowerValue(
+ ((MultiplicityElement) multi).getLowerValue());
+ }
+ if (((MultiplicityElement) multi).getUpperValue() != null) {
+ property.setLowerValue(
+ ((MultiplicityElement) multi).getUpperValue());
+ }
+ }
+ if (order != null) {
+ property.setIsOrdered((Boolean) order);
+ }
+ if (changeable != null) {
+ property.setIsReadOnly((Boolean) changeable);
+ }
+ if (stereo != null) {
+ if (property.isStereotypeApplicable((Stereotype) stereo)) {
+ property.applyStereotype((Stereotype) stereo);
+ }
+ }
+ return property;
+ }
+
public Property buildAssociationEnd(Object assoc, String name, Object type,
Object multi, Object stereo, boolean navigable, Object order,
Object aggregation, Object scope, Object changeable,
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1432754
To unsubscribe from this discussion, e-mail: [[email protected]].