Previous: ConfigurationNext: CRUD Books

Looking back at our functionality, we can list the following entities that need to be modelled (We'll go into detail further down):

In Strolch we model entities by defining the element as a template. Thus in the templates.xml file we can add the templates with the following content:

Book
<Resource Id="Book" Name="Book Template" Type="Template">
  <ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
    <Parameter Id="description" Name="Description" Type="String" Value="" />
    <Parameter Id="quantity" Name="Quantity in Stock" Type="Integer" Value="0" />
  </ParameterBag>
</Resource>
Account
<Resource Id="Account" Name="Account Template" Type="Template">
  <ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
    <Parameter Id="user" Name="User" Type="String" Value="" />
    <Parameter Id="firstName" Name="First Name" Type="String" Value="" />
    <Parameter Id="lastName" Name="Last Name" Type="String" Value="" />
    <Parameter Id="email" Name="E-Mail" Type="String" Value="" />
  </ParameterBag>
  <ParameterBag Name="Address" Id="address" Type="Address">
    <Parameter Id="phone" Name="Telephone Number" Type="String" Value="" />
    <Parameter Id="street" Name="Street" Type="String" Value="" />
    <Parameter Id="city" Name="City" Type="String" Value="" />
    <Parameter Id="zip" Name="Postal Code" Type="String" Value="" />
    <Parameter Id="country" Name="Country" Type="String" Value="" />
  </ParameterBag>
</Resource>
UserCart
<Resource Id="UserCart" Name="UserCart Template" Type="Template">
  <ParameterBag Id="books" Name="Books" Type="Book">
    <!-- Parameter Id="bookId" Name="Book reference" Type="Float" Value="0" / -->
  </ParameterBag>
  <ParameterBag Id="relations" Name="Relations" Type="Parameters">
    <Parameter Id="account" Name="Account" Type="String" Interpretation="Resource-Ref" Uom="Account" Value="" />
  </ParameterBag>
</Resource>
PurchaseOrder
<Order Id="PurchaseOrder" Name="PurchaseOrder Template" Type="Template" State="Created">
  <ParameterBag Id="books" Name="Books" Type="Book">
    <!-- Parameter Id="bookId" Name="Book reference" Type="Float" Value="0" / -->
  </ParameterBag>
  <ParameterBag Id="relations" Name="Relations" Type="Parameters">
    <Parameter Id="account" Name="Account" Type="String" Interpretation="Resource-Ref" Uom="Account" Value="" />
  </ParameterBag>
</Order>
FromStock
<Activity Id="FromStock" Name="From Stock Template" Type="FromStock" TimeOrdering="Series">
  <ParameterBag Name="objectives" Id="Objectives" Type="Objectives">
    <Parameter Name="Duration" Id="duration" Value="PT1MS" Type="Duration" />
  </ParameterBag>

  <Action Id="validate" Name="Validation of order" Type="Use" ResourceType="Validation" ResourceId="validation" />

  <!-- for each book we do a consume, i.e. reduce the stock quantity -->
  <Action Id="Consume" Name="Consume Template for book" Type="Template">
    <ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
      <Parameter Id="quantity" Name="Quantity" Type="Float" Value="0" />
    </ParameterBag>
  </Action>

  <Action Id="package" Name="Packaging of PurchaseOrder" Type="Use" ResourceType="Packaging" ResourceId="packaging" />
  <Action Id="send" Name="Sending of package" Type="Use" ResourceType="Sending" ResourceId="sending" />

</Activity>

Let's explain a few things:

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 defaultModel.xml file:

<Resource Id="validation" Name="Validation Resource" Type="Validation">
  <Policies>
    <Policy Type="ExecutionPolicy" Value="key:ValidationExecution" />
    <Policy Type="ConfirmationPolicy" Value="key:DefaultConfirmation" />
  </Policies>
</Resource>

<Resource Id="packaging" Name="Packaging Resource" Type="Packaging">
  <Policies>
    <Policy Type="ExecutionPolicy" Value="key:PackagingExecution" />
    <Policy Type="ConfirmationPolicy" Value="key:DefaultConfirmation" />
  </Policies>
</Resource>

<Resource Id="sending" Name="Sending Resource" Type="Sending">
  <Policies>
    <Policy Type="ExecutionPolicy" Value="key:SendingExecution" />
    <Policy Type="ConfirmationPolicy" Value="key:DefaultConfirmation" />
  </Policies>
</Resource>

What should now be noted by these three new Resources is that they have Policy definitions:

Currently these resources reference policies which don't exist. We will resolve this issue later, when we implement the execution of the activity.

This concludes the model definition. In the next step we'll start creating services and commands for our model.

Previous: ConfigurationNext: CRUD Books