-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoperations.eol
153 lines (133 loc) · 4.28 KB
/
operations.eol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**
* Converts an element to the native Java BigInteger type
* @return a java.math.BigInteger
*/
operation Any asBigInteger(): Native("java.math.BigInteger")
{
// Converts an element to the java native type BigInteger
return new Native("java.math.BigInteger")(self);
}
/**
* Retrieves the artifacts representing an element
* @return a collection comprising the set of artifacts
*/
operation UML!NamedElement getArtifacts(): Collection
{
var artifacts = UML!Artifact.all();
var output = new Sequence();
for(artifact in artifacts)
{
var manifestation = artifact.manifestation;
manifestation = manifestation.select(i | i.supplier.first = self);
if(manifestation.notEmpty)
output.add(artifact);
}
return output;
}
/**
* Checks if it exists a behavioral description involving self
* @param element: element under investigation
* @return a boolean
*/
operation UML!NamedElement isInteracting(): Boolean
{
// Gets all the lifelines involving the input 'element'
var lifelines = self.getLifelines();
var interacting = lifelines.select(i | i.isInteracting());
var artifacts = self.getArtifacts().flatten;
var deployments = artifacts.collect(i | i.getDeployments()).flatten;
return interacting.notEmpty();
}
operation UML!Lifeline getWorkload(): Sequence
{
var pattern = self.getValue(gaworkload, "pattern").trim();
var reg = '(closed|open):[0-9]+(.[0-9]+)?';
if(not pattern.matches(reg))
throw "value not recognized GaWorkloadEvent::pattern at " + self.name;
return pattern.split(":");
}
/**
* Gets all the lifelines representing self
* @return a Collection of Lifelines
*/
operation UML!NamedElement getLifelines(): Collection
{
// All the lifelines of the Model
var lifelines = UML!Lifeline.all();
// Get all the lifelines involving "element"
return lifelines.select(i | i.represents.type = self);
}
/*
* Operations on UML!Node;
*/
/**
* Retrieves the manifestation of the artifact deployed on a Node
* @return the object representing the deployed component or null
*/
operation UML!Node getDeployed(): Collection
{
// If the deployment dependency does not exists, then the deployed element is
if(self.deployment.isEmpty())
return new Sequence();
// This variable represents the 'deployment' association between a Node and an Artifact
var deployment = self.deployment;
// It is the object of the artifact deployed on self (Node)
var artifacts = deployment.collect(i | i.getSuppliers()).flatten;
var manifestation = artifacts.manifestation.flatten;
return manifestation.collect(i | i.getSuppliers()).flatten;
}
/*
* Operations on UML!Lifeline;
*/
operation UML!Lifeline isInteracting(): Boolean
{
return self.coveredBy.notEmpty();
}
/**
* Returns the elements, inside a lifeline, having 'type' as type
* @returns a OrderedSet of elements with type 'type'
*/
operation UML!Lifeline getElements(type: String): OrderedSet
{
var elements = self.coveredBy.asOrderedSet();
return elements.select(i | i.eClass.name == type);
}
/*
* Operations on UML!BehaviorExecutionSpecification;
*/
/**
* Checks if the BehaviorExecutionSpecification is well specified.
* This means that is has a MessageOccurrenceSpecifiation for both the
* start event and the finish event
* @return a boolean stating if the property is verified or not
*/
operation UML!BehaviorExecutionSpecification isWellFormed() : Boolean
{
if(self.start.isTypeOf(MessageOccurrenceSpecification) and
self.finish.isTypeOf(MessageOccurrenceSpecification))
return true;
return false;
}
/**
* Builds an ordered data structure cointaining the MessageOccurenceSpecification
* of 'self' (BES)
* @return a collection of MessageOccurenceSpecification
*/
operation UML!BehaviorExecutionSpecification getMessages(): Collection
{
var modelMessages = UML!MessageOccurrenceSpecification.all();
var lifeline = self.covered.first;
var elements = lifeline.getElements("MessageOccurrenceSpecification");
elements = modelMessages.select(i | elements.includes(i));
var start = elements.indexOf(self.start);
var end = elements.indexOf(self.finish);
return modelMessages.select(i | elements.indexOf(i) >= start
and elements.indexOf(i) <= end);
}
/*
* Operations on UML!Artifact;
*/
operation UML!Artifact getDeployments() : Sequence
{
return UML!Deployment.all().select(i | i.supplier.first = self).flatten;
}