MDrivenWiki
Log in

Difference between revisions of "Turnkey session 7: Expressions"

From MDrivenWiki
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<html>
 
<html>
<h4> Session 7 - In this session we take a deeper look at OCL expressions and what you can do with them. OCL is a complete language that can act on everything that you have in your model, it has operators on objects and on collections. The ocl language is a functional language –different in approach compared to imperative languages like javascript and c#. The ocl language is optimized for querying your model. It uses a bit of set theory from your math classes. It is compact in the sense that it does a lot with short snippets. OCL is defined by ObjectManagementGroup OMG.</h4>
+
<p> Session 7 - In this session, we take a deeper look at OCL expressions and what you can do with them. OCL is a complete language
 +
  that can act on everything that you have in your model, it has operators on objects and on collections. The ocl language
 +
  is a functional language –different in approach compared to imperative languages like javascript and c#. The ocl language
 +
  is optimized for querying your model. It uses a bit of set theory from your math classes. It is compact in the sense that
 +
  it does a lot with short snippets. OCL is defined by ObjectManagementGroup OMG.</p>
  
<p class = war>
+
<p class="video-warn">
<em>To make your experience more comfortable, we set the main tags mentioned in the video to the right bar menu of this mini player. Choose the interesting subtitle on the list and immediately get to the exact theme timeplace in the video. Now you can pick any topic to be instructed without watching the whole video.</em>
+
  <em>To make your experience more comfortable, we set the main tags mentioned in the video to the right bar menu of this mini
<style type="text/css">
+
    player. Choose the interesting subtitle on the list and immediately get to the exact theme navigation-itemplace in the
p.war {
+
    video. Now you can pick any topic to be instructed without watching the whole video.</em>
opacity: 0.7;
 
text-align: justify;
 
width: 90%
 
}
 
</style>
 
 
</p>
 
</p>
  
<style>
+
<br>
#video12 {
+
<div class="video">
  position: relative;
+
   <div class="video__wrapper">
  height: 500px;
+
    <iframe src="https://www.youtube.com/embed/nB-Fj_iZjY0?rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe>
  width:560px;
+
   </div>
  padding-bottom: 10px;
+
  <div class="video__navigation">
}
+
     <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="55" tabindex="0"> "all instances" expression </span>
#video12 iframe {
+
    <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="119" tabindex="0"> "Last" expression </span>
  position: absolute;
+
     <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="130" tabindex="0"> "First" </span>
  min-height: auto;
+
     <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="159" tabindex="0"> "Order By" </span>
  min-width: auto;
+
     <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="220" tabindex="0"> SubSequence </span>
}
+
     <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="260" tabindex="0"> Combine the expressions </span>
#video12 div {
+
     <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="290" tabindex="0"> select operator </span>
  position: absolute;
+
     <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="340" tabindex="0"> combine with logic expressions </span>
  top: 0;
+
     <span class="navigation-item" data-video="nB-Fj_iZjY0" data-start="367" tabindex="0"> loop variable </span>
  left:760px;
+
  </div>
  width: 260px;
 
  height: 100%;
 
  padding-left: 10px;
 
  overflow-y: auto;
 
}
 
span {
 
    font-size: 18;
 
    display:block;
 
  padding: 2px 10px 2px 10px;
 
    padding-bottom: 0.5;
 
    padding-top: 0.5;
 
  opacity: 0.7;
 
}
 
span:hover {
 
   color: #0000FF;
 
  cursor: pointer;
 
}
 
span:focus {
 
  color: blue;
 
</style>
 
 
 
<div id="video12">
 
<iframe width="740" height="500" src="https://www.youtube.com/embed/37Qoij5KZX4?rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe>
 
   <div>
 
     <span data-video="37Qoij5KZX4" data-start="114" tabindex="0"> "Last" expression </span>
 
     <span data-video="37Qoij5KZX4" data-start="125" tabindex="0"> "First" </span>
 
     <span data-video="37Qoij5KZX4" data-start="154" tabindex="0"> "Order By" </span>
 
     <span data-video="37Qoij5KZX4" data-start="215" tabindex="0"> SubSequence </span>
 
     <span data-video="37Qoij5KZX4" data-start="255" tabindex="0"> Combine the expressions </span>
 
     <span data-video="37Qoij5KZX4" data-start="285" tabindex="0"> select operator </span>
 
     <span data-video="37Qoij5KZX4" data-start="335" tabindex="0"> combine with logic expressions </span>
 
     <span data-video="37Qoij5KZX4" data-start="362" tabindex="0"> loop variable </span>
 
</div> 
 
</div>
 
 
</div>
 
</div>
  
<script>
 
var IMG = document.querySelectorAll('#video12 span'),
 
    IFRAME = document.querySelector('#video12 iframe');
 
for (var i = 0; i < IMG.length; i++) {
 
  IMG[i].onclick = function() {
 
    IFRAME.src = 'http://www.youtube.com/embed/' + this.dataset.video + '?rel=0&autoplay=1';
 
    if(this.dataset.end) IFRAME.src = IFRAME.src.replace(/([\s\S]*)/g, '$1&end=' + this.dataset.end);
 
    if(this.dataset.start) IFRAME.src = IFRAME.src.replace(/([\s\S]*)/g, '$1&start=' + this.dataset.start);
 
    this.style.backgroundColor='rgba(0,0,0,.2)';
 
  }
 
}
 
</script>
 
 
</html>
 
</html>
 
    
 
    
To learn more about the object constraints language you can watch the OCL Sessions Series
+
===== OCL expressions =====
 
 
=== [[Part 1|Part 1 OCL Common Expressions]] ===
 
 
 
=== [[Part 2 OCL: Derivation. Associations|Part 2 OCL: Operators]] ===
 
 
 
=== [[Part 3 OCL: Derivation properties|Part 3 Derivation properties]] ===
 
 
 
 
 
clicking up the system prototyper and starting
 
 
 
0:00:16.580,0:00:19.680
 
the system connecting to our database
 
 
 
0:00:19.680,0:00:23.500
 
and here we can write expression
 
 
 
0:00:23.500,0:00:27.960
 
what happens here ia that we have a
 
database with
 
 
 
0:00:27.960,0:00:31.609
 
objects in it and somehow we want
 
 
 
0:00:31.609,0:00:34.800
 
to transport those objects
 
 
 
0:00:34.800,0:00:39.649
 
into our application and
 
 
 
0:00:39.649,0:00:48.660
 
this is what the turnkey
 
application does for us, we do this by
 
 
 
0:00:48.110,0:00:53.010
 
using different expressions one common
 
operator is
 
 
 
0:00:53.010,0:00:56.090
 
all instances and all the instances
 
 
 
0:00:56.090,0:00:59.109
 
mean that it takes all of
 
 
 
0:00:59.109,0:01:02.320
 
the class referenced
 
 
 
0:01:02.320,0:01:05.950
 
and post them back to the application
 
and I look
 
 
 
0:01:05.950,0:01:09.049
 
how that looks in the debugger
 
 
 
0:01:09.049,0:01:11.880
 
I'm gonna use the class car from our model and
 
allinstances
 
 
 
0:01:11.880,0:01:22.330
 
we see four cars that the database, so far
 
 
 
0:01:24.990,0:01:30.430
 
and if you have a set of objects, we have
 
different types of operators
 
 
 
0:01:30.430,0:01:33.610
 
likes size, this one operator in this case it
 
would
 
 
 
0:01:33.610,0:01:38.320
 
return 6, but in our case we have four cars
 
 
 
0:01:38.320,0:01:42.720
 
I look on how that looks
 
 
 
0:01:42.720,0:01:46.540
 
so we can stack the operators after each other like now
 
we use
 
 
 
0:01:46.540,0:01:50.940
 
all instances and than size it returns four
 
 
 
0:01:50.940,0:01:54.080
 
yeah, many different operators
 
 
 
0:01:54.080,0:01:57.790
 
look at last
 
 
 
0:01:57.790,0:02:01.090
 
it checks the list of retrieved
 
 
 
0:02:01.090,0:02:05.490
 
or selected objects and  picks the last
 
one
 
 
 
0:02:05.490,0:02:10.260
 
returns only one, there's an operator called
 
first
 
 
 
0:02:10.260,0:02:13.550
 
that does almost the same thing but
 
 
 
0:02:13.550,0:02:16.709
 
the first one, so let's check
 
 
 
0:02:16.709,0:02:23.209
 
that in the debugger as well
 
 
 
0:02:30.069,0:02:34.760
 
25, and now we take the first
 
the one with tire radius 5
 
 
 
0:02:34.760,0:02:38.750
 
order by
 
 
 
0:02:38.750,0:02:42.099
 
is an operator that could sort
 
 
 
0:02:42.099,0:02:45.980
 
our objects on some property
 
 
 
0:02:45.980,0:02:49.390
 
so let's say that is
 
 
 
0:02:49.390,0:02:53.590
 
B C A D E F
 
 
 
0:02:53.590,0:02:57.260
 
oreder by on that property would fetch "A" first
 
 
 
0:02:57.260,0:03:03.260
 
"B" then "C" "D" "E" "F"
 
 
 
0:03:03.409,0:03:09.000
 
we can try that in the debugger as well
 
 
 
0:03:15.240,0:03:17.810
 
order by
 
 
 
0:03:17.810,0:03:21.960
 
changes to registration number
 
 
 
0:03:26.080,0:03:29.980
 
now they are sorted by registration number
 
 
 
0:03:35.350,0:03:37.780
 
SubSequence
 
 
 
0:03:37.780,0:03:41.110
 
spell that wrong it's "q"
 
 
 
0:03:41.110,0:03:46.820
 
not "c"
 
 
 
0:03:48.920,0:03:53.140
 
takes only a subset of returned
 
set from allinstances
 
 
 
0:04:06.510,0:04:10.810
 
1,2, like that, so instead of 4
 
we have got only two
 
 
 
0:04:16.739,0:04:20.130
 
and we could combine, so that's
 
 
 
0:04:26.310,0:04:33.710
 
add the order by registration number
 
that we had before behind here
 
 
 
0:04:33.180,0:04:39.810
 
then we get one set and if we would move the order
 
by
 
 
 
0:04:39.810,0:04:43.130
 
in front the subsequence we get
 
another result
 
 
 
0:04:43.130,0:04:48.860
 
the most important operator
 
 
 
0:04:48.860,0:04:54.010
 
that you will use most likely is 'select'
 
it requires some boolean value
 
 
 
0:04:54.010,0:04:57.250
 
so it checks each and every
 
 
 
0:04:57.250,0:05:00.800
 
value object that runs through on some
 
property
 
 
 
0:05:00.800,0:05:04.979
 
checks if it has it and then it either
 
 
 
0:05:04.979,0:05:09.169
 
chooses to return it or not
 
 
 
0:05:09.169,0:05:12.669
 
let's now select on tire radius
 
 
 
0:05:19.330,0:05:24.470
 
in this case a radius bigger than 5
 
returns 2 objects
 
 
 
0:05:24.470,0:05:26.530
 
bigger or equal 5
 
 
 
0:05:26.530,0:05:30.470
 
it returns three objects
 
 
 
0:05:30.470,0:05:35.620
 
that's okay, when it comes to select you
 
can
 
 
 
0:05:35.620,0:05:38.990
 
combine any boolean
 
expression like logic operators with 'and'
 
 
 
0:05:42.080,0:05:47.220
 
and 'or' 'not'  and things like that
 
 
 
0:05:47.220,0:05:51.060
 
so let's add another constraint here
 
to brand.name
 
 
 
0:05:51.060,0:05:56.909
 
should be Volvo, then we get two
 
 
 
0:06:02.330,0:06:07.319
 
and one important concept in using select
 
 
 
0:06:07.319,0:06:10.659
 
is the loop variable
 
  
0:06:10.659,0:06:14.009
+
To learn more about object constraint language expressions (OCL expressions) you can watch the OCL Sessions Series
the loop variable is the name on the  
 
  
0:06:14.009,0:06:17.139
+
[[Part 1|Part 1 OCL Common Expressions]]
iterated object it's in the expressions
 
  
0:06:17.139,0:06:20.650
+
[[Part 2 OCL: Derivation. Associations|Part 2 OCL: Operators]]
gonna call that "one car"
 
then there's a pipe sign
 
  
0:06:20.650,0:06:24.710
+
[[Part 3 OCL: Derivation properties|Part 3 Derivation properties]]
so means that we could use
 
  
0:06:24.710,0:06:27.919
+
We can use the system protoyper to connect to our database and write expressions. There are objects in the database that we need to transport into our application. And this is exactly what the turnkey application does by using different expressions.
this variable "one car"
 
  
0:06:27.919,0:06:31.270
+
One common operator is '''all instances'''. It takes all of the class referenced and post them back to the application. Following the explanation in the video if we have a set of objects, we have different types of operators - likes size, for example, it would return 6, but in our case, we have 4 cars. So we can stack the operators after each other and use all instances to make size returns 4.
in our expressions it helps when
 
  
0:06:31.270,0:06:34.830
+
There are many different operators, one of them is '''"last"'''. It checks the list of retrieved or selected objects and picks the last one. There's an operator called '''"first"''' - that does almost the same thing, but with the first one.
the expressions get complex and change
 
  
0:06:34.830,0:06:39.190
+
'''Order by''' is an operator that could sort our objects on some property. Let's say that is  B C A D E F "order by" on that property would fetch "A" first "B" then "C" "D" "E" "F".
the volvo brand to audi and see how that works
 
  
0:06:39.190,0:06:42.650
+
'''SubSequence''' operator takes only a subset of returned set from allinstances. For example 1,2, like that, so instead of 4 we have got only two and we could combine. So following the video, that's add the order by registration number behind the subsequence expression that we have in the debugger.
okay that was a few things on expressions
 
  
0:06:42.650,0:06:45.000
+
The most important operator that you will use most likely is '<nowiki/>'''select'''' it requires some boolean value, so it checks each and every value object that runs through on some property. Then it either chooses to return it or not. When it comes to select you can combine any boolean expression like logic operators with 'and' and 'or' 'not'  and things like that. One important concept in using select is the loop variable - it is the name on the iterated object in the expressions. For example, we are going to call that "one car". There's a pipe sign, it means that we could use this variable "one car" in our expressions. It helps when the expressions get complex.
subscribe to this, thank yous
+
[[Category:MDriven Turnkey]]
 +
[[Category:MDriven Turnkey Sessions]]
 +
[[Category:OCL]]
 +
[[Category:OCL Editor]]
 +
[[Category:Expressions]]
 +
[[Category:Operators]]

Latest revision as of 22:35, 31 July 2018

Session 7 - In this session, we take a deeper look at OCL expressions and what you can do with them. OCL is a complete language that can act on everything that you have in your model, it has operators on objects and on collections. The ocl language is a functional language –different in approach compared to imperative languages like javascript and c#. The ocl language is optimized for querying your model. It uses a bit of set theory from your math classes. It is compact in the sense that it does a lot with short snippets. OCL is defined by ObjectManagementGroup OMG.

To make your experience more comfortable, we set the main tags mentioned in the video to the right bar menu of this mini player. Choose the interesting subtitle on the list and immediately get to the exact theme navigation-itemplace in the video. Now you can pick any topic to be instructed without watching the whole video.


"all instances" expression "Last" expression "First" "Order By" SubSequence Combine the expressions select operator combine with logic expressions loop variable

OCL expressions

To learn more about object constraint language expressions (OCL expressions) you can watch the OCL Sessions Series

Part 1 OCL Common Expressions

Part 2 OCL: Operators

Part 3 Derivation properties

We can use the system protoyper to connect to our database and write expressions. There are objects in the database that we need to transport into our application. And this is exactly what the turnkey application does by using different expressions.

One common operator is all instances. It takes all of the class referenced and post them back to the application. Following the explanation in the video if we have a set of objects, we have different types of operators - likes size, for example, it would return 6, but in our case, we have 4 cars. So we can stack the operators after each other and use all instances to make size returns 4.

There are many different operators, one of them is "last". It checks the list of retrieved or selected objects and picks the last one. There's an operator called "first" - that does almost the same thing, but with the first one.

Order by is an operator that could sort our objects on some property. Let's say that is B C A D E F "order by" on that property would fetch "A" first "B" then "C" "D" "E" "F".

SubSequence operator takes only a subset of returned set from allinstances. For example 1,2, like that, so instead of 4 we have got only two and we could combine. So following the video, that's add the order by registration number behind the subsequence expression that we have in the debugger.

The most important operator that you will use most likely is 'select' it requires some boolean value, so it checks each and every value object that runs through on some property. Then it either chooses to return it or not. When it comes to select you can combine any boolean expression like logic operators with 'and' and 'or' 'not' and things like that. One important concept in using select is the loop variable - it is the name on the iterated object in the expressions. For example, we are going to call that "one car". There's a pipe sign, it means that we could use this variable "one car" in our expressions. It helps when the expressions get complex.