A Sequential workflow executes various tasks. If these tasks need to pass information between each other, you need Contexts.
A Context store is a data container. Each task can produce some data, which is then saved into the Context. The following task can read the data from the context (and produce data into a different context or update the source context).
In programming terms, Contexts would be something like variables. But Contexts are much more capable than simple variables. They automatically provide the following functionalities:
- Original Values
When a task finishes and produces some results, the resulting data is saved into the Context. They are not just simply replaced. Leveraging the knowledge of the whole data model, ORIGAM allows you to do enhanced merging easily.
Let's say you want to load data from the database, update some records and than save the data. For that you need to create a workflow:
- Calling the DataService.LoadData service call will load the data
- Calling the TransformationService.Transform service call will take the data and produce a copy with updated values
- Calling the DataService.StoreData service call will save the updated data
For this you need to create one Context:
The first service will load data from the database and since the Context is empty, all the records will appear in the dataset.
After the second service call the resulting records will be looked up and updated in the Context the following way:
- Every record will be looked up by primary key in their respective entity
- Records will be compared and the Context will be updated with the changes.
When the Context gets updated, the original values (The ones loaded from the database) will always be preserved. So the Context will always store the original values and the current values (updated by different tasks in the sequential workflow).
These values will be used especially when saving the data for concurrency checks.
Any data structure based data contained in a context can be accessed as XML, e.g. when using Data Transformation Service.