Running an interactive CM model

The class Aia.ITP.OnLine.Model makes it possible to run KCM Master Templates that interact with a user. Running such a Master Template always follows the below procedure:

  1. Call the method Start to perform an initial run of the Master Template.

  2. Every time the model run returns interaction requests, call the method Continue to send responses to the interaction and re-run the Master Template.

  3. After the last interaction request, the Master Template run is complete. Optionally, call the method Finish to allow KCM ComposerUI to clean up after the Master Template run.

So, running an interactive KCM Master Template is always done by calling the method Start to start running the KCM Master Template, and one or more calls to the method Continue. The number of calls depends on the number of FORM statements and other interaction requests in the KCM Master Template.

Every time the KCM Master Template comes across a FORM statement or other interaction request, KCM will send out an XForms XML document that contains the Form questions. This XML data will be stored into the file specified by the property InfoFile of the object Aia.ITP.OnLine.Model. The Form questions can be extracted from this XML, for instance, by using an XSLT transformation, and presented to the user. The answers have to be passed back to the KCM ComposerUI through the parameter response of the call Continue.

Interaction requests do not result only from FORM statements in the KCM Master Template. There are several other situations in which XML forms are generated by KCM Core. For instance, if the KCM XML File Connection is used and no XML data file using the property DataFile is specified, KCM Core sends out an XML form. In this Form, the user is asked to select the XML data file that will be used to run the KCM Master Template.

Also, for every Continue call the KCM Master Template is actually re-run completely. This could possibly have adverse side effects if the KCM Master Template or one of the parameters of the call Start is changed, for instance, the database. The developer must ensure that such side effects either cannot take place, or cannot influence the outcome.