Skip to content

Commit 20f6747

Browse files
committed
FUML15-28 Updated to handle reclassify object and unmarshall actions.
1 parent 755931b commit 20f6747

12 files changed

Lines changed: 1533 additions & 546 deletions

File tree

org.modeldriven.fuml/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>fuml</artifactId>
66
<packaging>jar</packaging>
77
<name>FUML Reference Implementation</name>
8-
<version>1.4.3-SNAPSHOT</version>
8+
<version>1.4.3/FUML15-28</version>
99
<description>This open source software is a reference implementation, consisting of software and related files, for the OMG specification called the Semantics of a Foundational Subset for Executable UML Models (fUML). The reference implementation is intended to implement the execution semantics of UML activity models, accepting an XMI file from a conformant UML model as its input and providing an execution trace of the selected activity model(s) as its output. The core execution engine, which is directly generated from the normative syntactic and semantic models for fUML, may also be used as a library implementation of fUML in other software.</description>
1010
<url>http:/fuml.modeldriven.org</url>
1111
<licenses>

org.modeldriven.fuml/src/main/java/fuml/semantics/actions/ActionActivation.java

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
* Initial version copyright 2008 Lockheed Martin Corporation, except
33
* as stated in the file entitled Licensing-Information.
44
*
5-
* All modifications copyright 2009-2017 Data Access Technologies, Inc.
5+
* Modifications:
6+
* Copyright 2009-2012 Data Access Technologies, Inc.
7+
* Copyright 2020 Model Driven Solutions, Inc.
68
*
79
* Licensed under the Academic Free License version 3.0
810
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -25,6 +27,11 @@
2527
import fuml.semantics.activities.TokenList;
2628
import fuml.semantics.simpleclassifiers.BooleanValue;
2729
import fuml.semantics.simpleclassifiers.FeatureValueList;
30+
import fuml.semantics.simpleclassifiers.StructuredValue;
31+
import fuml.semantics.structuredclassifiers.ExtensionalValue;
32+
import fuml.semantics.structuredclassifiers.ExtensionalValueList;
33+
import fuml.semantics.structuredclassifiers.Link;
34+
import fuml.semantics.structuredclassifiers.LinkList;
2835
import fuml.semantics.values.Value;
2936
import fuml.semantics.values.ValueList;
3037
import fuml.syntax.actions.Action;
@@ -34,6 +41,8 @@
3441
import fuml.syntax.actions.OutputPinList;
3542
import fuml.syntax.activities.ActivityNode;
3643
import fuml.syntax.activities.ActivityNodeList;
44+
import fuml.syntax.classification.Property;
45+
import fuml.syntax.structuredclassifiers.Association;
3746
import fuml.syntax.values.LiteralBoolean;
3847

3948
public abstract class ActionActivation extends
@@ -418,6 +427,115 @@ public boolean valueParticipatesInLink(
418427

419428
return participates;
420429
} // valueParticipatesInLink
430+
431+
public fuml.syntax.structuredclassifiers.Association getAssociation(
432+
fuml.syntax.classification.StructuralFeature feature) {
433+
// If the given structural feature is an association end, then get
434+
// the associated association.
435+
436+
Association association = null;
437+
if (feature instanceof Property) {
438+
association = ((Property) feature).association;
439+
}
440+
441+
return association;
442+
} // getAssociation
443+
444+
public fuml.semantics.values.ValueList getValues(
445+
fuml.semantics.values.Value sourceValue,
446+
fuml.syntax.classification.StructuralFeature feature) {
447+
// Get the values of the feature for the given source value.
448+
// If the feature is an association end, then get the values of
449+
// the feature end of the links with the source value as the
450+
// opposite end.
451+
// Otherwise, if the source value is a structured value, get
452+
// the values of the feature value for feature in the structured value.
453+
454+
ValueList values = new ValueList();
455+
456+
Association association = this.getAssociation(feature);
457+
if (association != null) {
458+
LinkList links = this.getMatchingLinks(association, feature, sourceValue);
459+
for (int j = 0; j < links.size(); j++) {
460+
Link link = links.getValue(j);
461+
values.addValue(link.getFeatureValue(feature).values.getValue(0));
462+
}
463+
} else {
464+
values = ((StructuredValue)sourceValue).getFeatureValue(feature).values;
465+
}
466+
467+
return values;
468+
}
469+
470+
public fuml.semantics.structuredclassifiers.LinkList getMatchingLinks(
471+
fuml.syntax.structuredclassifiers.Association association,
472+
fuml.syntax.classification.StructuralFeature end,
473+
fuml.semantics.values.Value oppositeValue) {
474+
// Get the links of the given binary association whose end opposite
475+
// to the given end has the given value
476+
477+
return this.getMatchingLinksForEndValue(association, end, oppositeValue, null);
478+
}
479+
480+
481+
public fuml.semantics.structuredclassifiers.LinkList getMatchingLinksForEndValue(
482+
fuml.syntax.structuredclassifiers.Association association,
483+
fuml.syntax.classification.StructuralFeature end,
484+
fuml.semantics.values.Value oppositeValue,
485+
fuml.semantics.values.Value endValue) {
486+
// Get the links of the given binary association whose end opposite
487+
// to the given end has the given opposite value and, optionally, that
488+
// has a given end value for the given end.
489+
490+
Property oppositeEnd = this.getOppositeEnd(association, end);
491+
492+
ExtensionalValueList extent = this.getExecutionLocus().getExtent(
493+
association);
494+
495+
LinkList links = new LinkList();
496+
for (int i = 0; i < extent.size(); i++) {
497+
ExtensionalValue link = extent.getValue(i);
498+
if (link.getFeatureValue(oppositeEnd).values.getValue(0).equals(oppositeValue)) {
499+
boolean matches = true;
500+
if (endValue != null) {
501+
matches = link.getFeatureValue(end).values.getValue(0).equals(endValue);
502+
}
503+
if (matches) {
504+
if (!end.multiplicityElement.isOrdered | links.size() == 0) {
505+
links.addValue((Link) link);
506+
} else {
507+
int n = link.getFeatureValue(end).position;
508+
boolean continueSearching = true;
509+
int j = 0;
510+
while (continueSearching & j < links.size()) {
511+
j = j + 1;
512+
continueSearching = links.getValue(j - 1).getFeatureValue(end).position < n;
513+
}
514+
if (continueSearching) {
515+
links.addValue((Link) link);
516+
} else {
517+
links.addValue(j - 1, (Link) link);
518+
}
519+
}
520+
}
521+
}
522+
}
523+
524+
return links;
525+
} // getMatchingLinksForEndValue
526+
527+
public fuml.syntax.classification.Property getOppositeEnd(
528+
fuml.syntax.structuredclassifiers.Association association,
529+
fuml.syntax.classification.StructuralFeature end) {
530+
// Get the end of a binary association opposite to the given end.
531+
532+
Property oppositeEnd = association.memberEnd.getValue(0);
533+
if (oppositeEnd == end) {
534+
oppositeEnd = association.memberEnd.getValue(1);
535+
}
536+
537+
return oppositeEnd;
538+
} // getOppositeEnd
421539

422540
public fuml.semantics.simpleclassifiers.BooleanValue makeBooleanValue(
423541
boolean value) {

org.modeldriven.fuml/src/main/java/fuml/semantics/actions/ReadStructuralFeatureActionActivation.java

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Initial version copyright 2008 Lockheed Martin Corporation, except
44
* as stated in the file entitled Licensing-Information.
55
*
6-
* All modifications copyright 2009-2012 Data Access Technologies, Inc.
6+
* Modifications:
7+
* Copyright 2009-2012 Data Access Technologies, Inc.
8+
* Copyright 2020 Model Driven Solutions, Inc.
79
*
810
* Licensed under the Academic Free License version 3.0
911
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -12,51 +14,26 @@
1214

1315
package fuml.semantics.actions;
1416

15-
import fuml.semantics.simpleclassifiers.StructuredValue;
16-
import fuml.semantics.structuredclassifiers.Link;
17-
import fuml.semantics.structuredclassifiers.LinkList;
1817
import fuml.semantics.values.Value;
19-
import fuml.semantics.values.ValueList;
2018
import fuml.syntax.actions.ReadStructuralFeatureAction;
2119
import fuml.syntax.classification.StructuralFeature;
22-
import fuml.syntax.structuredclassifiers.Association;
2320

24-
public class ReadStructuralFeatureActionActivation
25-
extends
26-
fuml.semantics.actions.StructuralFeatureActionActivation {
21+
public class ReadStructuralFeatureActionActivation extends fuml.semantics.actions.StructuralFeatureActionActivation {
2722

2823
public void doAction() {
2924
// Get the value of the object input pin.
3025
// If the given feature is an association end, then get all values of
31-
// the that end.
32-
// for which the opposite end has the object input value and place them
33-
// on the result pin.
34-
// Otherwise, if the object input value is a structural value, then get
35-
// the values
36-
// of the appropriate feature of the input value and place them on the
37-
// result output pin.
26+
// that end for which the opposite end has the object input value and
27+
// place them on the result pin.
28+
// Otherwise, if the object input value is a structured value, then get
29+
// the values of the appropriate feature of the input value and place
30+
// them on the result output pin.
3831

3932
ReadStructuralFeatureAction action = (ReadStructuralFeatureAction) (this.node);
4033
StructuralFeature feature = action.structuralFeature;
41-
Association association = this.getAssociation(feature);
4234

4335
Value value = this.takeTokens(action.object).getValue(0);
44-
ValueList resultValues = new ValueList();
45-
46-
if (association != null) {
47-
LinkList links = this.getMatchingLinks(association, feature, value);
48-
for (int i = 0; i < links.size(); i++) {
49-
Link link = links.getValue(i);
50-
resultValues.addValue(link.getFeatureValue(feature).values
51-
.getValue(0));
52-
}
53-
} else if (value instanceof StructuredValue) {
54-
// Debug.println("[ReadStructuralFeatureActionActivation] value = "
55-
// + value +", structural feature = " + feature.name);
56-
resultValues = ((StructuredValue) value).getFeatureValue(feature).values;
57-
}
58-
59-
this.putTokens(action.result, resultValues);
36+
this.putTokens(action.result, this.getValues(value, feature));
6037
} // doAction
6138

6239
} // ReadStructuralFeatureActionActivation

org.modeldriven.fuml/src/main/java/fuml/semantics/actions/ReclassifyObjectActionActivation.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Initial version copyright 2008 Lockheed Martin Corporation, except
44
* as stated in the file entitled Licensing-Information.
55
*
6-
* All modifications copyright 2009-2015 Data Access Technologies, Inc.
6+
* Modifications:
7+
* Copyright 2009-2015 Data Access Technologies, Inc.
8+
* Copyright 2020 Model Driven Solutions, Inc.
79
*
810
* Licensed under the Academic Free License version 3.0
911
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -13,12 +15,17 @@
1315
package fuml.semantics.actions;
1416

1517
import fuml.semantics.simpleclassifiers.FeatureValueList;
18+
import fuml.semantics.structuredclassifiers.Link;
19+
import fuml.semantics.structuredclassifiers.LinkList;
1620
import fuml.semantics.structuredclassifiers.Object_;
1721
import fuml.semantics.structuredclassifiers.Reference;
1822
import fuml.semantics.values.Value;
1923
import fuml.syntax.actions.ReclassifyObjectAction;
2024
import fuml.syntax.classification.Classifier;
2125
import fuml.syntax.classification.ClassifierList;
26+
import fuml.syntax.classification.StructuralFeature;
27+
import fuml.syntax.classification.StructuralFeatureList;
28+
import fuml.syntax.structuredclassifiers.Association;
2229
import fuml.syntax.structuredclassifiers.Class_;
2330

2431
public class ReclassifyObjectActionActivation extends
@@ -47,6 +54,7 @@ public void doAction() {
4754

4855
if (input instanceof Reference) {
4956
Object_ object = ((Reference) input).referent;
57+
StructuralFeatureList oldFeatures = object.getStructuralFeatures();
5058

5159
int i = 1;
5260
while (i <= object.types.size()) {
@@ -94,7 +102,37 @@ public void doAction() {
94102
FeatureValueList oldFeatureValues = object.getFeatureValues();
95103
object.featureValues = new FeatureValueList();
96104
object.addFeatureValues(oldFeatureValues);
105+
106+
// Destroy links involving association ends that were previously features
107+
// but no longer have feature values after the reclassification.
108+
StructuralFeatureList newFeatures = object.getStructuralFeatures();
109+
for (int j = 0; j < oldFeatures.size(); j++) {
110+
StructuralFeature feature = oldFeatures.getValue(j);
111+
Association association = this.getAssociation(feature);
112+
if (association != null) {
113+
if (this.checkForMissingFeature(newFeatures, feature)) {
114+
LinkList links = this.getMatchingLinks(association, feature, input);
115+
for (int k = 0; k < links.size(); k++) {
116+
Link link = links.getValue(k);
117+
link.destroy();
118+
}
119+
}
120+
}
121+
}
97122
}
123+
98124
} // doAction
99-
125+
126+
public boolean checkForMissingFeature(StructuralFeatureList features, StructuralFeature feature) {
127+
boolean isMissing = true;
128+
129+
int i = 1;
130+
while (isMissing & i <= features.size()) {
131+
StructuralFeature containedFeature = features.getValue(i-1);
132+
isMissing = containedFeature != feature;
133+
i = i + 1;
134+
}
135+
136+
return isMissing;
137+
}
100138
} // ReclassifyObjectActionActivation

0 commit comments

Comments
 (0)