Skip to content

Commit 03f6465

Browse files
committed
Issue #4 - Second step.
- Completed annotationAllowed checks to allow any stereotype annotation for a stereotype that extends the appropriate metaclass. - Updated mapping to apply stereotypes in general based on annotations.
1 parent e671484 commit 03f6465

29 files changed

+83593
-83469
lines changed

org.modeldriven.alf.eclipse.papyrus/Libraries/alf/StandardProfile.alf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
@profile
33
package StandardProfile {
44

5-
@stereotype(Class)
5+
@stereotype(Operation)
66
public class Create { }
77

8-
@stereotype(Class)
8+
@stereotype(Operation)
99
public class Destroy { }
1010

1111
@stereotype(Package)

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

Lines changed: 83371 additions & 83371 deletions
Large diffs are not rendered by default.
1.54 KB
Binary file not shown.

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2013 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2013-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,6 +8,9 @@
88
*******************************************************************************/
99
package org.modeldriven.alf.eclipse.uml;
1010

11+
import java.util.ArrayList;
12+
import java.util.Collection;
13+
1114
import org.eclipse.uml2.uml.UMLFactory;
1215

1316
public class Stereotype extends Class_ implements org.modeldriven.alf.uml.Stereotype {
@@ -25,4 +28,22 @@ public org.eclipse.uml2.uml.Stereotype getBase() {
2528
return (org.eclipse.uml2.uml.Stereotype)this.base;
2629
}
2730

31+
@Override
32+
public Collection<Class<?>> getExtendedMetaclass() {
33+
Collection<Class<?>> metaclasses = new ArrayList<Class<?>>();
34+
for (org.eclipse.uml2.uml.Property attribute: this.getBase().getAllAttributes()) {
35+
org.eclipse.uml2.uml.Association association = attribute.getAssociation();
36+
if (association instanceof org.eclipse.uml2.uml.Extension) {
37+
org.eclipse.uml2.uml.Type type = attribute.getType();
38+
if (type != null) {
39+
Class<?> metaclass = ElementFactory.interfaceForName(type.getName());
40+
if (metaclass != null) {
41+
metaclasses.add(metaclass);
42+
}
43+
}
44+
}
45+
}
46+
return metaclasses;
47+
}
48+
2849
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
@ModelLibrary
2+
@profile
23
package StandardProfile {
4+
5+
@stereotype(Operation)
6+
public class Create { }
7+
8+
@stereotype(Operation)
9+
public class Destroy { }
10+
11+
@stereotype(Package)
12+
public class ModelLibrary { }
13+
314
}

org.modeldriven.alf/Libraries/alf/StandardProfile.alf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
@profile
33
package StandardProfile {
44

5-
@stereotype(Class)
5+
@stereotype(Operation)
66
public class Create { }
77

8-
@stereotype(Class)
8+
@stereotype(Operation)
99
public class Destroy { }
1010

1111
@stereotype(Package)
1.54 KB
Binary file not shown.

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/units/MemberMapping.java

Lines changed: 7 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
@@ -17,7 +17,7 @@
1717
import org.modeldriven.alf.mapping.MappingError;
1818

1919
import org.modeldriven.alf.syntax.units.Member;
20-
20+
import org.modeldriven.alf.syntax.units.StereotypeAnnotation;
2121
import org.modeldriven.alf.uml.Element;
2222
import org.modeldriven.alf.uml.NamedElement;
2323

@@ -37,6 +37,11 @@ public void mapTo(NamedElement namedElement) throws MappingError {
3737
String visibility = member.getVisibility();
3838
namedElement.setVisibility(
3939
visibility == null || visibility.equals("")? "package": visibility);
40+
41+
for (StereotypeAnnotation annotation: member.getImpl().getAllAnnotations()) {
42+
ModelNamespaceMapping.applyStereotype(
43+
member, annotation.getImpl().getStereotypeReference());
44+
}
4045

4146
}
4247

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/units/ModelNamespaceMapping.java

Lines changed: 4 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
@@ -13,7 +13,7 @@
1313
import org.modeldriven.alf.fuml.mapping.FumlMapping;
1414
import org.modeldriven.alf.mapping.MappingError;
1515
import org.modeldriven.alf.syntax.common.ElementReference;
16-
import org.modeldriven.alf.syntax.units.NamespaceDefinition;
16+
import org.modeldriven.alf.syntax.units.Member;
1717
import org.modeldriven.alf.syntax.units.PackageDefinition;
1818
import org.modeldriven.alf.uml.Model;
1919
import org.modeldriven.alf.uml.NamedElement;
@@ -38,13 +38,13 @@ public void addMemberTo(Element element, NamedElement namespace) throws MappingE
3838
}
3939

4040
public static void applyStereotype(
41-
NamespaceDefinition definition, ElementReference stereotypeReference) {
41+
Member member, ElementReference stereotypeReference) {
4242
if (stereotypeReference != null) {
4343
Element stereotype = stereotypeReference.getImpl().getUml();
4444
if (stereotype instanceof Stereotype) {
4545
FumlMapping elementMapping =
4646
(FumlMapping)FumlMapping.getFumlFactory().
47-
getMapping(definition);
47+
getMapping(member);
4848
StereotypeApplication.addStereotypeApplication(
4949
elementMapping.getElement(), (Stereotype)stereotype);
5050
}

org.modeldriven.alf/src/org/modeldriven/alf/fuml/mapping/units/OperationDefinitionMapping.java

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

22
/*******************************************************************************
3-
* Copyright 2011-2013 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
@@ -145,15 +145,6 @@ public void mapTo(Operation operation) throws MappingError {
145145
}
146146
operation.addRedefinedOperation(redefinedOperation);
147147
}
148-
149-
if (definition.getIsConstructor()) {
150-
ModelNamespaceMapping.applyStereotype(
151-
definition, RootNamespace.getRootScope().getCreateStereotype());
152-
} else if (definition.getIsDestructor()) {
153-
ModelNamespaceMapping.applyStereotype(
154-
definition, RootNamespace.getRootScope().getDestroyStereotype());
155-
}
156-
157148
}
158149

159150
@Override

0 commit comments

Comments
 (0)