strolch/li.strolch.website/www.strolch.li/tutorial-model.html

196 lines
8.2 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="google-site-verification" content="CPhbjooaiTdROm7Vs4E7kuHZvBfkeLUtonGgcVUbTL8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="ico/favicon.ico">
<title>Strolch: Tutorial Model</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/custom.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script><![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Strolch</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Overview</a></li>
<li><a href="api.html">API</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li class="active"><a href="tutorial.html">Tutorial</a></li>
<li><a href="downloads.html">Downloads</a></li>
<li><a href="development.html">Development</a></li>
<li><a href="blog.html">Blog</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="container">
<div class="page-header">
<h1 class="page-title">Tutorial: Model</h1>
<p class="lead page-description">Defining the model for the bookshop</p>
</div>
<div class="content">
<a href="tutorial-configuration.html" class="pull-left">Previous: Configuration</a><a href="tutorial-.html"
class="pull-right">Next: </a>
<br><br>
<p>Looking back at our functionality, we can list the following entities that need to be modelled:</p>
<ul>
<li>Book &rightarrow; books can be orderd</li>
<li>UserCart &rightarrow; we want to store the cart of the user</li>
<li>Account &rightarrow; we need to know where to send the orders</li>
<li>Order &rightarrow; we need to know what was ordered and keep track of its state</li>
<li>FromStock &rightarrow; 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>
<b>Book</b>
<pre class="pre-scrollable">
&lt;Resource Id="Book" Name="Book Template" Type="Template"&gt;
&lt;ParameterBag Id="parameters" Name="Parameters" Type="Parameters"&gt;
&lt;Parameter Id="description" Name="Description" Type="String" Value="" /&gt;
&lt;Parameter Id="quantity" Name="Quantity in Stock" Type="Integer" Value="0" /&gt;
&lt;/ParameterBag&gt;
&lt;/Resource&gt;
</pre>
<b>UserCart</b>
<pre class="pre-scrollable">
&lt;Resource Id="UserCart" Name="UserCart Template" Type="Template"&gt;
&lt;ParameterBag Id="books" Name="Books" Type="Book"&gt;
&lt;!-- Parameter Id="bookId" Name="Book reference" Type="Float" Value="0" / --&gt;
&lt;/ParameterBag&gt;
&lt;ParameterBag Id="relations" Name="Relations" Type="Parameters"&gt;
&lt;Parameter Id="account" Name="Account" Type="String" Interpretation="Resource-Ref" Uom="Account" Value="" /&gt;
&lt;/ParameterBag&gt;
&lt;/Resource&gt;
</pre>
<b>Account</b>
<pre class="pre-scrollable">
&lt;Resource Id="Account" Name="Account Template" Type="Template"&gt;
&lt;ParameterBag Id="parameters" Name="Parameters" Type="Parameters"&gt;
&lt;Parameter Id="user" Name="User" Type="String" Value="" /&gt;
&lt;Parameter Id="firstName" Name="First Name" Type="String" Value="" /&gt;
&lt;Parameter Id="lastName" Name="Last Name" Type="String" Value="" /&gt;
&lt;Parameter Id="email" Name="E-Mail" Type="String" Value="" /&gt;
&lt;/ParameterBag&gt;
&lt;ParameterBag Name="Address" Id="address" Type="Address"&gt;
&lt;Parameter Id="phone" Name="Telephone Number" Type="String" Value="" /&gt;
&lt;Parameter Id="street" Name="Street" Type="String" Value="" /&gt;
&lt;Parameter Id="city" Name="City" Type="String" Value="" /&gt;
&lt;Parameter Id="zip" Name="Postal Code" Type="String" Value="" /&gt;
&lt;Parameter Id="country" Name="Country" Type="String" Value="" /&gt;
&lt;/ParameterBag&gt;
&lt;/Resource&gt;
</pre>
<b>Order</b>
<pre class="pre-scrollable">
&lt;Order Id="Order" Name="Order Template" Type="Template" State="Created"&gt;
&lt;ParameterBag Id="books" Name="Books" Type="Book"&gt;
&lt;!-- Parameter Id="bookId" Name="Book reference" Type="Float" Value="0" / --&gt;
&lt;/ParameterBag&gt;
&lt;ParameterBag Id="relations" Name="Relations" Type="Parameters"&gt;
&lt;Parameter Id="account" Name="Account" Type="String" Interpretation="Resource-Ref" Uom="Account" Value="" /&gt;
&lt;/ParameterBag&gt;
&lt;/Order&gt;
</pre>
<b>FromStock</b>
<pre class="pre-scrollable">
&lt;Activity Id="FromStock" Name="From Stock Template" Type="FromStock" TimeOrdering="Series"&gt;
&lt;ParameterBag Name="objectives" Id="Objectives" Type="Objectives"&gt;
&lt;Parameter Name="Duration" Id="duration" Value="PT1MS" Type="Duration" /&gt;
&lt;/ParameterBag&gt;
&lt;Action Id="Validate" Name="Validation of order" Type="Use" ResourceType="Validation" ResourceId="validation" /&gt;
&lt;!-- for each book we do a consume, i.e. reduce the stock quantity --&gt;
&lt;Action Id="Consume" Name="Consume Template for book" Type="Template"&gt;
&lt;ParameterBag Id="parameters" Name="Parameters" Type="Parameters"&gt;
&lt;Parameter Id="quantity" Name="Quantity" Type="Float" Value="0" /&gt;
&lt;/ParameterBag&gt;
&lt;/Action&gt;
&lt;Action Id="Package" Name="Packaging of Order" Type="Use" ResourceType="Packaging" ResourceId="packaging" /&gt;
&lt;Action Id="Send" Name="Sending of package" Type="Use" ResourceType="Sending" ResourceId="sending" /&gt;
&lt;/Activity&gt;
</pre>
<p>Let's explain a few things:</p>
<ul>
<li></li>
</ul>
<a href="tutorial-configuration.html" class="pull-left">Previous: Configuration</a><a href="tutorial-.html"
class="pull-right">Next: </a>
<!-- content here -->
<a href="tutorial-model.html"></a>
</div>
<!-- /.content -->
<div id="footer">
<div class="container">
<p class="text-muted">&copy; Strolch / <a href="mailto:eitch@eitchnet.ch">Robert von Burg</a> / Hosting by
<a href="http://www.eitchnet.ch">eitchnet.ch</a></p>
</div>
</div>
</div>
<!-- /.container -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual xsd as needed -->
<script src="js/bootstrap.min.js"></script>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = (("https:" == document.location.protocol) ? "https" : "http") + "://piwik.eitchnet.ch/";
_paq.push(['setTrackerUrl', u + 'piwik.php']);
_paq.push(['setSiteId', 2]);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.defer = true;
g.async = true;
g.src = u + 'piwik.js';
s.parentNode.insertBefore(g, s);
})();
</script>
<noscript><p><img src="http://piwik.eitchnet.ch/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
</body>
</html>