PMX is based on a very loose component model.
Base component
In a strict sense, a component type is any node type that instantiates a process component node which, when then included using application.require(), returns an object with the following methods.
getContext()
|
Return the process component node.
|
getName()
|
Return the name of the process component.
|
getReference()
|
Return the process component reference.
|
getGroupProcessDefinition()
|
Return the group process definition supported by this module.
|
getGroupStatusRules()
|
Return the status rules for the group processes supported by this module. Group status rules have a role of user, administrator or control. These are additive, e.g. administrator gets user rules too. Use a status of "*" to apply to all statuses.
|
getControlProcessDefinition()
|
Return the control process definition supported by this module, which runs within the PMX instance.
|
runRequest()
|
Optional method, required if the component is to be called as a service. Respond to an incoming request encoded as data in the "requestData" attribute. The type of request will be in the "componentAction" property. Return a response as a JSON object (not a JSON string), or should set the application error. Calls to the control process' "service" action are forwarded to the runRequest() method. See Process module service for details of this call.
|
Component types are written by:
- Create a class in a standalone script which is instantiated with the component instance node, and exports that class.
- Set the type's scriptClass binding to the class script.
- Include the member type Derive node instance in the type. This creates a script which when included using application.require() will return an instance of the class that has been constructed with the context.
You can use this approach to create a component. For example, you could use this with getGroupProcessDefinition(), getGroupStatusRules() and getControlProcessDefinition() which return empty structures, and a runRequest() which performs a service action.
Extensions to the basic process component pattern are provided for different purposes:
Recipe
Recipes are an extension to the base component that are typically used to create new groups and workers, but can be used for other request-based processing. They automate the creation of group process and status rules, automate the serving of multi-page forms, and simplify responding to a user request. They also have built-in methods for sending processes to the worker.
Recipe and Recipe Script provide more details of recipes.
Data driver
Data drivers are an extension to the base component that provide additional methods to support data access.
setProcessIdentifier(processIdentifier) |
Configure the data driver components to access data for the group or worker with the given process identifier. Return this. Must be recallable, i.e. the component must be capable of accessing data for different groups or workers. |
getProcessIdentifier() |
Return the current process identifier for the component.
|
put(record) | Store a record for the current process identifier. The record is a JSON object of any format. It must contain a recordIdentifier field. |
get(record) | Get a record where the recordIdentifier matches the recordIdentifier in the passed in field. If not found, return null. |
getAll() | Get all the records for this group or worker and data type. |
delete(record) | Delete the record where the recordIdentifeir matches the recordIdentifier in the passed in field. If not found, do not raise an error. |
getFileInfo(record) | Return a file info structure for a file returned in a data record, identified by the record identifier and uuid of the file. |
The standard data driver component stores data in process modules. To store data elsewhere, extend the Data Driver Component Script and provide a suitable extension of Data Driver Component.
You can use the Wrapped Data Driver Component to provide a service interface to your data, or to access data belonging to a different group.
File handling
The data driver components use file info structures to pass files. Files are stored as nodes within the individual record nodes, i.e. files "belong" to records.
The getFileInfo() method can be used to re-retrieve details of a file by its UUID. This allows client programs to use the combination of process identifier, data type, record identifier and file UUID to identify a file within a link, without exposing the file storage key.