Create closing events

1. Create closing events in a resource

In the previous section, View time values in the dashboard,  you added Age as a column in the search dashboard.

Question: The Age column displays the number of days since the order was received. To an operations professional, that dashboard in live mode shows terrible performance; orders should be turned around quickly – hopefully within 24 hours.

The data shows something completely different. What does the application also need to know?

Answer: This type of "what else do I need" question is part of every implementation. In this case, Decision Insight needs another event to say that the purchase order has been completed. Several types of events can signify purchase completion, as shown in the figure below.

Purchase Order business workflow

Your initial focus is the end-to-end view cycle. The data you brought into the application in part 1 corresponds to the very beginning of the purchase order process. The next set of data you will add corresponds to the very last event – when the payment has been received and the purchase order is closed.

Tip: Create data by faking data

To close the purchase orders, you need a new set of data from the business to close the instance of a purchase order. Sometimes, this can take longer than is practical to keep the data in the deployment. When that happens – and you have a good idea of what the missing data might be like – it makes sense to simply create that data.

Caution: Relying on fictitious data works in early development, but can lead to problems if reality is different than what you imagined.

The only new information you need is the time and the cycle number. It is reasonably safe to generate that data while you wait for the customer to provide a file with the actual events. The table of events you have been using so far holds the two events that represent the beginning and the end of a purchase order processing.

Now, you will simulate the last one:

Process step

Generated events

Purchase Orders Received

New Order

...

...

Receivables

Payment Received

Duplicate a resource

To build a Payment Received event, use the existing resource that contains test data for new orders. Duplicate that first resource, then edit the resulting one.

Step

Action

1

On the Main menu, click the cog icon > Data Integration.

2

On the left menu, click Resources. You currently only have one resource in the list.

3 Modify the name of the existing resource.The name used in part 1 was resOrder but we are going to create a second resource for data input, so that name is no longer relevant. In the Name field for your current resource, change the name to resNew Order.
4 Click Save.
5

To duplicate the resource, in the Actions column for the existing resource, click the Copy icon .

6

In the Into Space drop-down, select the Initializers space, then click Copy. A copy of your resource data is created.

7

In the Name field for this new resource, enter resPaymentReceived. Now you have data that you can use to close the instances of your purchase orders.

8 Click Save.

Think Ahead: mapping and route

You have created a new resource. To bring your PaymentReceived data into Decision Insight, create a new mapping and a new route just like you did for your first resource in part 1.  

In the real world, you could create the mapping and the route in either order, but in this tutorial, you will build the mapping first. Mapping can solve the main issue: get rid of the closed purchase orders.

2. Create the mapping for the closing events

Earlier,  when you processed the resource that created the purchase orders, you selected the Create an instance of Order is not found at resolution time or after option. There is no similar option for deleting an instance of an order. In Decision Insight, instances are considered as created, then completed, but never deleted from the database.  

Instead of deleting the instance, you can unbind an instance from an entity.

Binding

Background: Binding and unbinding

Decision Insight uses the terms bind and unbind for the action of creating and removing a logical link between two instances of entities. When a route calls a map with information that creates a new instance of an entity, the resolution computation of the map is executed, and a new instance of the Order entity is created.

An instance is uniquely identified thanks to:

  • the key for that identifies Order instances, that is keyOrder.
  • the CycleNumber transmitted by the route for the content of that key value.

When the Order instance is created, the instance key binds automatically the instance to the entity, as shown in the following diagram.

Unbinding

Unbinding an instance is as important as binding it. While binding initiates a link between an instance and its entity, unbinding removes the link.

When an instance is unbound from an entity, Decision Insight removes that instance from the live instances, yet the instance remains available in the time machine.

Decision Insight treats the instance as complete. Information about that instance remains in the database, but it is no longer seen on a dashboard unless you use the time machine to set the time of your dashboard earlier than the unbind event.

To unbind an instance, create a mapping that resolves the instance and unbinds the operation. 

Create the mapping for closing events

To create a mapping that unbinds an instance of Order when you receive an event from your new resource, first, rename your first mapping.

Step

Action

1

On the main menu, click Data Integration.

2

Click Mappings on the left menu.

3

Rename your existing mapping to mapNewOrder . This name matches the new name you gave to your first resource earlier.

4

Click Save.


Now, duplicate that existing mapping to create a new one for closing events.

Step

Action

1

Click the Copy icon for mapNewOrder.

2

In the Into space drop-down, select Initializers.

3

In the Name field, enter mapPaymentReceived.

4

Your first mapping contained four parameters. To unbind the instance, you only need two. Click the trash icon next to the unnecessary parameters, that is CustomerName and CustomerReference.

5

In the Resolution area, in the Key drop-down, select the Error if instance of Order not found at resolution time option.

6 In the Operations area, because you provided the customer name and reference when you created the instance, you do not need to use the two existing Set operations. To delete them, click the trash icon for each set.
7 In the Operations area, click the Add an operation drop-down > Unbind key.
8 Make sure the key for the unbind key section is your keyOrder key.
9 Click Save. Your mapping is complete.


You have a resource and a mapping for closing events. Next, you need a route to connect these two elements.

3. Create a route for closing events

About manual injection

Transaction data, for example, data about purchase orders, always exists outside of the deployment. Decision Insight provides the interface, and Camel provides the connectors that enable you to view and analyze that data.

In a production environment, the deployment runs in real-time to collect and receive information from the Camel connectors.

During the initial development work, you will often use a subset of data and manually select the source for the route. Once the test data is producing the expected results, you will migrate that connection to more closely match standard production methods.

The next step in this tutorial is to manually inject data into the deployment for Payment Received events.  

Create a route for closing events

The changes you have made to the resource and the mapping so far are similar to the changes you need to make to the route.

Step

Action

1

Click Routes. Make changes to your existing route before anything else:

  • Update the Name field to rouNewOrder.
  • Update the from uri statement to use the new name of your resource, that is resNewOrder.
  • Update the to uri statement for your mapping to use the new name of the mapping, that is mapNewOrder.
  • Click Save.
2

Click the Copy icon for the rouNewOrder route.

3 In the Name field for the new route, enter rouPaymentReceived.
4 In your new route, change the from uri statement to use manual injection. Change the part of the statement that says tnd-resource:resNewOrder to direct:file.
5

Change the destination mapping to mapPaymentReceived.

6

When you have made those changes, click Save.

7 To start your route, click the Play icon.
8

Click the Manual injection icon for the route.The manual injection dialog box is displayed.

9

In the Data to inject drop-down, which specifies the source file, select the name of your resource for Payment Received events.

10

In the To drop-down, select direct:file.

11

Click Inject. Your route is now running and reading your data resource.

12

Click the log icon for your route under Actions. The logs screen is displayed.

13  Select the Info checkbox.
14

Check the logs. You should see:

  • One log for when the injection started.
  • One log that lists the whole resource.
  • One log that displays the data unmarshalled into four blocks, separated by brackets [ ].
  • Four separate logs, one for each individual line of data in your resource.

If the logs show what is expected, you're done.

Go back to your dashboard. The selected orders section displays no data. The purchase orders seem to have disappeared. Consider the diagram below.

Data visibility across time

In this diagram, time is going in a left-to-right direction. You are in the present looking at past events. Each of the purchase orders existed in the past – they were created and closed. From your current point in time, you cannot expect to see those closed orders since they do not exist in the present any longer.

Once you've finished, you can move on to the next step.


Related Links