120 lines
34 KiB
HTML
120 lines
34 KiB
HTML
<!doctype html><html lang=en class="js csstransforms3d"><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=generator content="Hugo 0.80.0"><meta name=description content="Strolch is a parameterized framework for use on servers and IoT"><meta name=author content="Strolch"><link rel=icon href=/favicon.ico type=image/ico><title>Model - Strolch</title><link href=/css/nucleus.css?1650626698 rel=stylesheet><link href=/css/fontawesome-all.min.css?1650626698 rel=stylesheet><link href=/css/hybrid.css?1650626698 rel=stylesheet><link href=/css/featherlight.min.css?1650626698 rel=stylesheet><link href=/css/perfect-scrollbar.min.css?1650626698 rel=stylesheet><link href=/css/auto-complete.css?1650626698 rel=stylesheet><link href=/css/atom-one-dark-reasonable.css?1650626698 rel=stylesheet><link href=/css/theme.css?1650626698 rel=stylesheet><link href=/css/hugo-theme.css?1650626698 rel=stylesheet><link href=/css/theme-green.css?1650626698 rel=stylesheet><script src=/js/jquery-3.3.1.min.js?1650626698></script><style>:root #header+#content>#left>#rlblock_left{display:none!important}</style></head><body data-url=/tutorial/model/><nav id=sidebar><div id=header-wrapper><div id=header><a id=logo href=/><img src=/logo.png></a></div><div class=searchbox><label for=search-by><i class="fas fa-search"></i></label><input data-search-input id=search-by type=search placeholder=Search...>
|
|
<span data-search-clear><i class="fas fa-times"></i></span></div><script type=text/javascript src=/js/lunr.min.js?1650626698></script><script type=text/javascript src=/js/auto-complete.js?1650626698></script><script type=text/javascript>var baseurl="https:\/\/strolch.li\/";</script><script type=text/javascript src=/js/search.js?1650626698></script></div><section id=homelinks><ul><li><a class=padding href=/><i class="fas fa-home"></i>Home</a></li></ul></section><div class=highlightable><ul class=topics><li data-nav-id=/api/ title=API class=dd-item><a href=/api/>API</a></li><li data-nav-id=/documentation/ title=Documentation class=dd-item><a href=/documentation/>Documentation</a><ul><li data-nav-id=/documentation/architecture/ title=Architecture class=dd-item><a href=/documentation/architecture/>Architecture</a></li><li data-nav-id=/documentation/model/ title=Model class=dd-item><a href=/documentation/model/>Model</a></li><li data-nav-id=/documentation/do-and-donts/ title="Do and Don't" class=dd-item><a href=/documentation/do-and-donts/>Do and Don't</a></li><li data-nav-id=/documentation/runtime-configuration/ title="Runtime Configuration" class=dd-item><a href=/documentation/runtime-configuration/>Runtime Configuration</a></li><li data-nav-id=/documentation/realms/ title=Realms class=dd-item><a href=/documentation/realms/>Realms</a></li><li data-nav-id=/documentation/components/ title=Components class=dd-item><a href=/documentation/components/>Components</a></li><li data-nav-id=/documentation/services-and-commands/ title="Services and Commands" class=dd-item><a href=/documentation/services-and-commands/>Services and Commands</a></li><li data-nav-id=/documentation/searches/ title=Searches class=dd-item><a href=/documentation/searches/>Searches</a></li><li data-nav-id=/documentation/queries/ title=Queries class=dd-item><a href=/documentation/queries/>Queries</a></li><li data-nav-id=/documentation/transactions/ title=Transactions class=dd-item><a href=/documentation/transactions/>Transactions</a></li><li data-nav-id=/documentation/policies/ title=Policies class=dd-item><a href=/documentation/policies/>Policies</a></li><li data-nav-id=/documentation/observers/ title=Observers class=dd-item><a href=/documentation/observers/>Observers</a></li><li data-nav-id=/documentation/versioning/ title=Versioning class=dd-item><a href=/documentation/versioning/>Versioning</a></li><li data-nav-id=/documentation/reports/ title=Reports class=dd-item><a href=/documentation/reports/>Reports</a></li><li data-nav-id=/documentation/priviles/ title=Privileges class=dd-item><a href=/documentation/priviles/>Privileges</a></li></ul></li><li data-nav-id=/plc/ title=PLC class=dd-item><a href=/plc/>PLC</a><ul><li data-nav-id=/plc/architecture/ title=Architecture class=dd-item><a href=/plc/architecture/>Architecture</a></li><li data-nav-id=/plc/example-set-up/ title="Example Set-Up" class=dd-item><a href=/plc/example-set-up/>Example Set-Up</a></li></ul></li><li data-nav-id=/tutorial/ title=Tutorial class="dd-item
|
|
parent"><a href=/tutorial/>Tutorial</a><ul><li data-nav-id=/tutorial/configuration/ title=Configuration class=dd-item><a href=/tutorial/configuration/>Configuration</a></li><li data-nav-id=/tutorial/model/ title=Model class="dd-item active"><a href=/tutorial/model/>Model</a></li><li data-nav-id=/tutorial/crud-book/ title="CRUD Book" class=dd-item><a href=/tutorial/crud-book/>CRUD Book</a></li></ul></li><li data-nav-id=/download/ title=Download class=dd-item><a href=/download/>Download</a></li><li data-nav-id=/development/ title=Development class=dd-item><a href=/development/>Development</a></li><li data-nav-id=/blog/ title=Blog class=dd-item><a href=/blog/>Blog</a><ul><li data-nav-id=/blog/post-00016/ title="Strolch PLC now also on Maven Central" class=dd-item><a href=/blog/post-00016/>Strolch PLC now also on Maven Central</a></li><li data-nav-id=/blog/post-00015/ title="Release of Strolch 1.6.100" class=dd-item><a href=/blog/post-00015/>Release of Strolch 1.6.100</a></li><li data-nav-id=/blog/post-00014/ title="Strolch Reports" class=dd-item><a href=/blog/post-00014/>Strolch Reports</a></li><li data-nav-id=/blog/post-00013/ title="Strolch Searches" class=dd-item><a href=/blog/post-00013/>Strolch Searches</a></li><li data-nav-id=/blog/post-00012/ title="Wow, the many changes!" class=dd-item><a href=/blog/post-00012/>Wow, the many changes!</a></li><li data-nav-id=/blog/post-00011/ title="Strolch now on Maven Central" class=dd-item><a href=/blog/post-00011/>Strolch now on Maven Central</a></li><li data-nav-id=/blog/post-00010/ title="Versioning of objects" class=dd-item><a href=/blog/post-00010/>Versioning of objects</a></li><li data-nav-id=/blog/post-00009/ title="Release 1.2.0" class=dd-item><a href=/blog/post-00009/>Release 1.2.0</a></li><li data-nav-id=/blog/post-00008/ title="Strolch Update" class=dd-item><a href=/blog/post-00008/>Strolch Update</a></li><li data-nav-id=/blog/post-00007/ title="Activities: Beginning of the planning engine" class=dd-item><a href=/blog/post-00007/>Activities: Beginning of the planning engine</a></li><li data-nav-id=/blog/post-00006/ title="Strolch Documentation" class=dd-item><a href=/blog/post-00006/>Strolch Documentation</a></li><li data-nav-id=/blog/post-00005/ title="Strolch Release 1.0.0" class=dd-item><a href=/blog/post-00005/>Strolch Release 1.0.0</a></li><li data-nav-id=/blog/post-00004/ title="DurationParameter and other minor changes: Release 1.0.0-RC4" class=dd-item><a href=/blog/post-00004/>DurationParameter and other minor changes: Release 1.0.0-RC4</a></li><li data-nav-id=/blog/post-00003/ title="DB Initialization: Release 1.0.0-RC3" class=dd-item><a href=/blog/post-00003/>DB Initialization: Release 1.0.0-RC3</a></li><li data-nav-id=/blog/post-00002/ title="Release 1.0.0-RC2" class=dd-item><a href=/blog/post-00002/>Release 1.0.0-RC2</a></li><li data-nav-id=/blog/post-00001/ title="Release 1.0.0-RC1" class=dd-item><a href=/blog/post-00001/>Release 1.0.0-RC1</a></li></ul></li></ul><section id=shortcuts><h3>More</h3><ul><li><a class=padding href=https://strolch.li/tags><i class="fas fa-tags"></i>Tags</a></li><li><a class=padding href=https://github.com/strolch-li target=_blank><i class="fab fa-github"></i>GitHub project</a></li></ul></section><section id=footer><p>Built with <a href=https://github.com/matcornic/hugo-theme-learn target=_blank><i class="fas fa-heart"></i></a>from <a href=https://getgrav.org target=_blank>Grav</a> and <a href=https://gohugo.io/ target=_blank>Hugo</a></p></section></div></nav><section id=body><div id=overlay></div><div class="padding highlightable"><div><div id=top-bar><div id=top-github-link><a class=github-link title="Edit this page" href=https://github.com/strolch-li/strolch-website/tree/develop/content/tutorial/model.md target=blank><i class="fas fa-code-branch"></i><span id=top-github-link-text>Edit this page</span></a></div><div id=breadcrumbs itemscope itemtype=http://data-vocabulary.org/Breadcrumb><span id=sidebar-toggle-span><a href=# id=sidebar-toggle data-sidebar-toggle><i class="fas fa-bars"></i></a></span><span id=toc-menu><i class="fas fa-list-alt"></i></span><span class=links><a href=/>Strolch Overview</a> > <a href=/tutorial/>Tutorial</a> > Model</span></div><div class=progress><div class=wrapper><nav id=TableOfContents><ul><li><a href=#model>Model</a></li></ul></nav></div></div></div></div><div id=head-tags></div><div id=body-inner><h1>Model</h1><h2 id=model>Model</h2><p>Looking back at our functionality, we can list the following entities that need
|
|
to be modelled (We’ll go into detail further down):</p><ul><li>Book → books can be orderd</li><li>UserCart → we want to store the cart of the user</li><li>Account → we need to know where to send the orders</li><li>PurchaseOrder → we need to know what was ordered and keep track of its state</li><li>FromStock → we want to use activities to implement the process of an order</li></ul><p>In Strolch we model entities by defining the element as a template. Thus in the
|
|
<code>templates.xml</code> file we can add the templates with the following content:</p><p><strong>Book</strong></p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml>
|
|
<span style=color:#f92672><Resource</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"Book"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Book Template"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Template"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"parameters"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Parameters"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Parameters"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"description"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Description"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"quantity"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Quantity in Stock"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Integer"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"0"</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
<span style=color:#f92672></Resource></span>
|
|
</code></pre></div><p><strong>Account</strong></p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml>
|
|
<span style=color:#f92672><Resource</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"Account"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Account Template"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Template"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"parameters"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Parameters"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Parameters"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"user"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"User"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"firstName"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"First Name"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"lastName"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Last Name"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"email"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"E-Mail"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Address"</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"address"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Address"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"phone"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Telephone Number"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"street"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Street"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"city"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"City"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"zip"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Postal Code"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"country"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Country"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
<span style=color:#f92672></Resource></span>
|
|
</code></pre></div><p><strong>UserCart</strong></p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml>
|
|
<span style=color:#f92672><Resource</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"UserCart"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"UserCart Template"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Template"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"books"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Books"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Book"</span><span style=color:#f92672>></span>
|
|
<span style=color:#75715e><!-- Parameter Id="bookId" Name="Book reference" Type="Float" Value="0" / --></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"relations"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Relations"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Parameters"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"account"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Account"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span>
|
|
<span style=color:#a6e22e>Interpretation=</span><span style=color:#e6db74>"Resource-Ref"</span> <span style=color:#a6e22e>Uom=</span><span style=color:#e6db74>"Account"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
<span style=color:#f92672></Resource></span>
|
|
</code></pre></div><p><strong>PurchaseOrder</strong></p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml>
|
|
<span style=color:#f92672><Order</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"PurchaseOrder"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"PurchaseOrder Template"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Template"</span>
|
|
<span style=color:#a6e22e>State=</span><span style=color:#e6db74>"Created"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"books"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Books"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Book"</span><span style=color:#f92672>></span>
|
|
<span style=color:#75715e><!-- Parameter Id="bookId" Name="Book reference" Type="Float" Value="0" / --></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"relations"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Relations"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Parameters"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"account"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Account"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"String"</span>
|
|
<span style=color:#a6e22e>Interpretation=</span><span style=color:#e6db74>"Resource-Ref"</span> <span style=color:#a6e22e>Uom=</span><span style=color:#e6db74>"Account"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>""</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
<span style=color:#f92672></Order></span>
|
|
</code></pre></div><p><strong>FromStock</strong></p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml>
|
|
<span style=color:#f92672><Activity</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"FromStock"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"From Stock Template"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"FromStock"</span>
|
|
<span style=color:#a6e22e>TimeOrdering=</span><span style=color:#e6db74>"Series"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"objectives"</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"Objectives"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Objectives"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Duration"</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"duration"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"PT1MS"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Duration"</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
|
|
<span style=color:#f92672><Action</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"validate"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Validation of order"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Use"</span>
|
|
<span style=color:#a6e22e>ResourceType=</span><span style=color:#e6db74>"Validation"</span> <span style=color:#a6e22e>ResourceId=</span><span style=color:#e6db74>"validation"</span><span style=color:#f92672>/></span>
|
|
|
|
<span style=color:#75715e><!-- for each book we do a consume, i.e. reduce the stock quantity --></span>
|
|
<span style=color:#f92672><Action</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"Consume"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Consume Template for book"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Template"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><ParameterBag</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"parameters"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Parameters"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Parameters"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Parameter</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"quantity"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Quantity"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Float"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"0"</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></ParameterBag></span>
|
|
<span style=color:#f92672></Action></span>
|
|
|
|
<span style=color:#f92672><Action</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"package"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Packaging of PurchaseOrder"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Use"</span>
|
|
<span style=color:#a6e22e>ResourceType=</span><span style=color:#e6db74>"Packaging"</span> <span style=color:#a6e22e>ResourceId=</span><span style=color:#e6db74>"packaging"</span><span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Action</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"send"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Sending of package"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Use"</span> <span style=color:#a6e22e>ResourceType=</span><span style=color:#e6db74>"Sending"</span>
|
|
<span style=color:#a6e22e>ResourceId=</span><span style=color:#e6db74>"sending"</span><span style=color:#f92672>/></span>
|
|
|
|
<span style=color:#f92672></Activity></span>
|
|
|
|
</code></pre></div><p>Let’s explain a few things:</p><ul><li><p>The <code>Book</code> entity is a <code>Resource</code> object and only contains the description and the
|
|
current quantity in stock.</p></li><li><p>The <code>Account</code> entity is a Resource and contains the address and further details
|
|
of the user, and with the <code>user</code> parameter the username is defined, thus
|
|
referencing the real user.</p></li><li><p>The <code>UserCart</code> entity is a Resource and has a reference to the <code>account</code> Resource.</p><div class="notices tip"><p>Note how the reference is done using a StringParameter, where <code>Interpretation</code>,
|
|
<code>UOM</code> and the <code>value</code> is set in a specific manner.</p></div></li><li><p>The <code>UserCart</code> entity is a Resource and references <code>books</code> using a special
|
|
ParameterBag with the type set to <code>Book</code>, the actual type of the book entity.
|
|
Each Parameter is of type Float and the ID of the parameter is the ID of the
|
|
book, and the value is the quantity that the user would like to purchase.</p><p>There will only be one cart per user/account.</p></li><li><p>The <code>PurchaseOrder</code> entity is an <code>Order</code> object, and is basically a copy of the
|
|
UserCart entity. This is the confirmed purchase order for the contents of a
|
|
cart, and can then be used for reports on how much of which book was sold.</p></li><li><p>The <code>FromStock</code> entity is an <code>Activity</code> object and defines the process we will go
|
|
through when delivering a purchase to a user.</p><div class="notices tip"><p>Note how the activity has a
|
|
ParameterBag <code>objectives</code> with a <code>duration</code> parameter. This defines for
|
|
this activity how long each <code>Action</code> should execute. This can be overridden in
|
|
each Action and can help to plan how much effort goes into the delivering of
|
|
each PurchaseOrder.</p></div><div class="notices tip"><p>Further note how the activity has three special actions (<code>validate</code>, <code>package</code> and
|
|
<code>send</code>) on which a <code>ResourceType</code> and <code>ResourceId</code> are defined. Actions are always
|
|
performed on a Resource, as the referenced Resource defines the behaviour of
|
|
the action through defined <code>Policy</code> objects.</p></div></li><li><p>For each book which will be purchased, an Action will be created of type
|
|
<code>Consume</code>. In the template this is defined by a template <code>Action</code> with the id
|
|
<code>Consume</code> and will later be changed accordingly.</p></li></ul><p>Since we are referencing resources from actions in the activity, we need to add
|
|
these as well, but not as templates. They can be added to the <code>defaultModel.xml</code>
|
|
file:</p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml><span style=color:#f92672><Resource</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"validation"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Validation Resource"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Validation"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Policies></span>
|
|
<span style=color:#f92672><Policy</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"ExecutionPolicy"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"key:ValidationExecution"</span> <span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Policy</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"ConfirmationPolicy"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"key:DefaultConfirmation"</span> <span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></Policies></span>
|
|
<span style=color:#f92672></Resource></span>
|
|
|
|
<span style=color:#f92672><Resource</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"packaging"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Packaging Resource"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Packaging"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Policies></span>
|
|
<span style=color:#f92672><Policy</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"ExecutionPolicy"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"key:PackagingExecution"</span> <span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Policy</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"ConfirmationPolicy"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"key:DefaultConfirmation"</span> <span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></Policies></span>
|
|
<span style=color:#f92672></Resource></span>
|
|
|
|
<span style=color:#f92672><Resource</span> <span style=color:#a6e22e>Id=</span><span style=color:#e6db74>"sending"</span> <span style=color:#a6e22e>Name=</span><span style=color:#e6db74>"Sending Resource"</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"Sending"</span><span style=color:#f92672>></span>
|
|
<span style=color:#f92672><Policies></span>
|
|
<span style=color:#f92672><Policy</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"ExecutionPolicy"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"key:SendingExecution"</span> <span style=color:#f92672>/></span>
|
|
<span style=color:#f92672><Policy</span> <span style=color:#a6e22e>Type=</span><span style=color:#e6db74>"ConfirmationPolicy"</span> <span style=color:#a6e22e>Value=</span><span style=color:#e6db74>"key:DefaultConfirmation"</span> <span style=color:#f92672>/></span>
|
|
<span style=color:#f92672></Policies></span>
|
|
<span style=color:#f92672></Resource></span>
|
|
</code></pre></div><p>What should now be noted by these three new Resources is that they have Policy
|
|
definitions:</p><ul><li><code>ExecutionPolicy</code> → defines how an action on this resource is executed by
|
|
referencing an ExecutionPolicy implementation.</li><li><code>ConfirmationPolicy</code> → defines behaviour to be performed on every state change
|
|
of an action being performed on this resource by referencing an
|
|
ConfirmationPolicy implementation.</li></ul><p>Currently these resources reference policies which don’t exist. We will resolve
|
|
this issue later, when we implement the execution of the activity.</p><p>This concludes the model definition. In the next step we’ll start creating
|
|
services and commands for our model.</p><footer class=footline></footer></div></div><div id=navigation><a class="nav nav-prev" href=/tutorial/configuration/ title=Configuration><i class="fa fa-chevron-left"></i></a><a class="nav nav-next" href=/tutorial/crud-book/ title="CRUD Book" style=margin-right:0><i class="fa fa-chevron-right"></i></a></div></section><div style=left:-1000px;overflow:scroll;position:absolute;top:-1000px;border:none;box-sizing:content-box;height:200px;margin:0;padding:0;width:200px><div style=border:none;box-sizing:content-box;height:200px;margin:0;padding:0;width:200px></div></div><script src=/js/clipboard.min.js?1650626698></script><script src=/js/perfect-scrollbar.min.js?1650626698></script><script src=/js/perfect-scrollbar.jquery.min.js?1650626698></script><script src=/js/jquery.sticky.js?1650626698></script><script src=/js/featherlight.min.js?1650626698></script><script src=/js/highlight.pack.js?1650626698></script><script>hljs.initHighlightingOnLoad();</script><script src=/js/modernizr.custom-3.6.0.js?1650626698></script><script src=/js/learn.js?1650626698></script><script src=/js/hugo-learn.js?1650626698></script><script src=/mermaid/mermaid.js?1650626698></script><script>mermaid.initialize({startOnLoad:true});</script><script type=text/javascript>var _paq=window._paq=window._paq||[];_paq.push(["setDocumentTitle",document.domain+"/"+document.title]);_paq.push(["setCookieDomain","*.strolch.li"]);_paq.push(['trackPageView']);_paq.push(['enableLinkTracking']);(function(){var u="https://piwik.eitchnet.ch/";_paq.push(['setTrackerUrl',u+'matomo.php']);_paq.push(['setSiteId','2']);var d=document,g=d.createElement('script'),s=d.getElementsByTagName('script')[0];g.type='text/javascript';g.async=true;g.src=u+'matomo.js';s.parentNode.insertBefore(g,s);})();</script></body></html> |