Skip to content

Commit b40c232

Browse files
committed
Issue #4 - Third (and final) step.
- Implemented constraint checks for StereotypeAnnotation argument names and tagged values. - Implemented mapping for tagged values. - Corrected stereotype resolution.
1 parent 03f6465 commit b40c232

29 files changed

+84276
-83839
lines changed

org.modeldriven.alf.eclipse/UML/_RunTests.uml

Lines changed: 83768 additions & 83672 deletions
Large diffs are not rendered by default.
5.1 KB
Binary file not shown.

org.modeldriven.alf.eclipse/src/org/modeldriven/alf/eclipse/uml/Classifier.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011-2015 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -10,12 +10,14 @@
1010

1111
import java.util.HashSet;
1212
import java.util.List;
13-
import java.util.ArrayList;
13+
import java.util.ArrayList;
14+
import java.util.Collection;
1415
import java.util.Set;
1516

1617
import org.eclipse.emf.ecore.EObject;
1718
import org.eclipse.emf.ecore.EReference;
1819
import org.eclipse.emf.ecore.util.EcoreUtil;
20+
import org.modeldriven.alf.uml.StereotypeApplication;
1921

2022
public class Classifier extends Type implements
2123
org.modeldriven.alf.uml.Classifier {
@@ -265,16 +267,29 @@ protected EObject createCopy(EObject eObject) {
265267
EObject result = super.createCopy(eObject);
266268
org.modeldriven.alf.uml.Element copy =
267269
wrap((org.eclipse.uml2.uml.Element)result);
268-
// TODO: Handle copying of tagged values.
269-
for (org.eclipse.uml2.uml.Stereotype stereotype:
270-
((org.eclipse.uml2.uml.Element)eObject).getAppliedStereotypes()) {
270+
org.eclipse.uml2.uml.Element element = (org.eclipse.uml2.uml.Element)eObject;
271+
for (org.eclipse.uml2.uml.Stereotype stereotype: element.getAppliedStereotypes()) {
271272
org.modeldriven.alf.uml.StereotypeApplication.
272273
addStereotypeApplication(
273-
copy, (Stereotype)wrap(stereotype));
274+
copy, (Stereotype)wrap(stereotype), this.getTaggedValues(element, stereotype));
274275
}
275276
return result;
276277
}
277278

279+
protected Collection<org.modeldriven.alf.uml.StereotypeApplication.TaggedValue> getTaggedValues(
280+
org.eclipse.uml2.uml.Element element, org.eclipse.uml2.uml.Stereotype stereotype) {
281+
ArrayList<StereotypeApplication.TaggedValue> taggedValues =
282+
new ArrayList<StereotypeApplication.TaggedValue>();
283+
for (org.eclipse.uml2.uml.Property attribute: stereotype.getAllAttributes()) {
284+
String name = attribute.getName();
285+
Object value = element.getValue(stereotype, name);
286+
if (value != null) {
287+
taggedValues.add(new StereotypeApplication.TaggedValue(name, value));
288+
}
289+
}
290+
return taggedValues;
291+
}
292+
278293
// Add to the set of external references any reference that is not
279294
// to a copied object, or any object that has a template binding.
280295
@Override

org.modeldriven.alf.eclipse/src/org/modeldriven/alf/eclipse/uml/Element.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.eclipse.emf.ecore.EStructuralFeature;
1919
import org.eclipse.emf.ecore.util.EcoreUtil;
2020
import org.eclipse.uml2.uml.UMLFactory;
21+
import org.modeldriven.alf.uml.StereotypeApplication;
2122

2223
public class Element implements org.modeldriven.alf.uml.Element {
2324

@@ -49,9 +50,17 @@ public static Element wrap(org.eclipse.uml2.uml.Element base) {
4950
}
5051

5152
@Override
52-
public void applyStereotype(org.modeldriven.alf.uml.Stereotype stereotype) {
53-
this.getBase().applyStereotype(stereotype == null? null:
54-
((Stereotype)stereotype).getBase());
53+
public void applyStereotype(
54+
org.modeldriven.alf.uml.Stereotype stereotype,
55+
Collection<StereotypeApplication.TaggedValue> taggedValues) {
56+
org.eclipse.uml2.uml.Element base = this.getBase();
57+
if (stereotype != null) {
58+
org.eclipse.uml2.uml.Stereotype baseStereotype = ((Stereotype)stereotype).getBase();
59+
base.applyStereotype(baseStereotype);
60+
for (StereotypeApplication.TaggedValue taggedValue: taggedValues) {
61+
base.setValue(baseStereotype, taggedValue.getName(), taggedValue.getValue());
62+
}
63+
}
5564
}
5665

5766
@Override

org.modeldriven.alf.eclipse/src/org/modeldriven/alf/eclipse/uml/Property.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011, 2012 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -95,6 +95,11 @@ public boolean getIsID() {
9595

9696
public void setIsID(boolean isID) {
9797
this.getBase().setIsID(isID);
98+
}
99+
100+
@Override
101+
public boolean isStereotypeBaseProperty() {
102+
return this.getBase().getAssociation() instanceof org.eclipse.uml2.uml.Extension;
98103
}
99104

100105
}

org.modeldriven.alf.fuml.impl/src/org/modeldriven/alf/fuml/impl/uml/Element.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011-2013 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -8,8 +8,11 @@
88
*******************************************************************************/
99
package org.modeldriven.alf.fuml.impl.uml;
1010

11-
import java.util.ArrayList;
12-
import java.util.List;
11+
import java.util.ArrayList;
12+
import java.util.Collection;
13+
import java.util.List;
14+
15+
import org.modeldriven.alf.uml.StereotypeApplication;
1316

1417
public abstract class Element implements org.modeldriven.alf.uml.Element {
1518

@@ -42,7 +45,9 @@ public boolean isElement() {
4245
}
4346

4447
@Override
45-
public void applyStereotype(org.modeldriven.alf.uml.Stereotype stereotype) {
48+
public void applyStereotype(
49+
org.modeldriven.alf.uml.Stereotype stereotype,
50+
Collection<StereotypeApplication.TaggedValue> taggedValues) {
4651
}
4752

4853
@Override

org.modeldriven.alf.fuml.impl/src/org/modeldriven/alf/fuml/impl/uml/Property.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011, 2012 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -80,6 +80,11 @@ public org.modeldriven.alf.uml.Class_ getClass_() {
8080

8181
public org.modeldriven.alf.uml.Property getOpposite() {
8282
return (Property)wrap(this.getBase().opposite);
83+
}
84+
85+
@Override
86+
public boolean isStereotypeBaseProperty() {
87+
return false;
8388
}
8489

8590
}
5.1 KB
Binary file not shown.

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/expressions/BooleanLiteralExpressionMapping.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*******************************************************************************
3-
* Copyright 2011, 2012 Data Access Technologies, Inc. (Model Driven Solutions)
3+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
44
* All rights reserved worldwide. This program and the accompanying materials
55
* are made available for use under the terms of the GNU General Public License
66
* (GPL) version 3 that accompanies this distribution and is available at
@@ -19,11 +19,15 @@
1919
import org.modeldriven.alf.uml.LiteralBoolean;
2020

2121
public class BooleanLiteralExpressionMapping extends LiteralExpressionMapping {
22+
23+
public static boolean valueOf(String image) {
24+
return "true".equals(image);
25+
}
2226

2327
@Override
2428
public ValueSpecificationAction mapValueSpecificationAction() throws MappingError {
2529
String image = this.getBooleanLiteralExpression().getImage();
26-
return this.graph.addBooleanValueSpecificationAction(image.equals("true"));
30+
return this.graph.addBooleanValueSpecificationAction(valueOf(image));
2731
}
2832

2933
public BooleanLiteralExpression getBooleanLiteralExpression() {

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/expressions/NaturalLiteralExpressionMapping.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*******************************************************************************
3-
* Copyright 2011, 2012 Data Access Technologies, Inc. (Model Driven Solutions)
3+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
44
* All rights reserved worldwide. This program and the accompanying materials
55
* are made available for use under the terms of the GNU General Public License
66
* (GPL) version 3 that accompanies this distribution and is available at
@@ -19,10 +19,8 @@
1919
import org.modeldriven.alf.uml.LiteralInteger;
2020

2121
public class NaturalLiteralExpressionMapping extends LiteralExpressionMapping {
22-
23-
@Override
24-
public ValueSpecificationAction mapValueSpecificationAction() throws MappingError {
25-
String image = this.getNaturalLiteralExpression().getImage();
22+
23+
public static int valueOf(String image) {
2624
int radix = 10;
2725
if (image.length() > 1 && image.charAt(0) == '0') {
2826
char radixChar = image.charAt(1);
@@ -33,8 +31,13 @@ public ValueSpecificationAction mapValueSpecificationAction() throws MappingErro
3331
image = image.substring(2);
3432
}
3533
}
36-
return this.graph.addNaturalValueSpecificationAction(
37-
Integer.parseInt(image.replaceAll("_", ""), radix));
34+
return Integer.parseInt(image.replaceAll("_", ""), radix);
35+
}
36+
37+
@Override
38+
public ValueSpecificationAction mapValueSpecificationAction() throws MappingError {
39+
String image = this.getNaturalLiteralExpression().getImage();
40+
return this.graph.addNaturalValueSpecificationAction(valueOf(image));
3841
}
3942

4043
public NaturalLiteralExpression getNaturalLiteralExpression() {

0 commit comments

Comments
 (0)