public interface ProcessDefinitionService
A process definition is deployed from a .bpmn file in the repository. See
deployProcessDefinitionFromRepository
. The .bpmn file defines the elements, form properties, completion properties
and any sequence flow logic. A definition can be updated by re-deploying from a .bpmn file. This will create a new
deployed version of the process definition. Process flows can only be created from the latest deployed definition.
A process definition can be mapped by associating element attributes with other
AutoFlowLaunchable
object attributes so that process flows
can be automatically created. For example, a study TLFs
attributes can be
mapped for auto flow creation.
For information about process definition element attributes such a name and type, see
getProcessDefinitionMappingMetadata()
. This will return ProcessDefinitionMappingMetadata for each
AutoFlowType
such as Tlf. It will tell you for each element type, which element attribute map to what TLF
attributes.
To create or update a definition mapping, first get the process definition and then get the process definition
mapping. For example,
{ @code ProcessDefinitionInfo processDef = service.getProcessDefinitionByKey("SimpleFlow"); ProcessDefinitionMapping defMapping = service.getProcessDefinitionMappingByType(AutoFlowType.TLF, processDef.getProcessDefinitionKey()); ListIf the process definition has never been mapped, the element mapping will be empty. To create a mapping and enable the definition for auto flow, see the example below. For simplicity, this process definition has a single user task and a mapping is created for the user task Assignee attribute only. Hard-coded attribute names are used for convenience. For the full list of attributes and their metadata, seeelementMapping = defMapping.getElementMapping(); }
getProcessDefinitionMappingMetadata()
and
StudyTlfService.getTlfAttributeMetadata()
.
{ @code SetNOTE: You must set enable auto flow to true in order to save the element mapping. Once you have saved the mapping by callingelements = service.getProcessDefinitionElements(def.getId()); FlowElementDefinition userTask = elements.iterator().next(); FlowElementMapping userTaskMapping = new FlowElementMapping(userTask.getElementId(), userTask.getType()); List attrMap = userTaskMapping.getAttributeMapping(); attrMap.add(new AttributeMapping("Assignee", "User Assignment 1", FlowAttributeType.USER)); elementMapping.add(userTaskMapping); defMapping.setEnableAutoFlowMapping(true); defMapping = service.updateProcessDefinitionMapping(defMapping); }
updateProcessDefinitionMapping(ProcessDefinitionMapping)
, you can
check that the mapping is complete with isMappingComplete()
. If
true
, the process definition is available to automatically create process flows. To find all such
process definitions, see
getProcessDefinitionsMappedForAutoFlow(String, AutoFlowType, boolean)
.
A mapping is considered complete when the required attributes have been specified so that a process flow can be
successfully activated. In the example above, the process definition contains only a single user task, and no user
task attributes are required for activation, so once
setEnableAutoFlowMapping
is set to
true
, the mapping is complete. If the process definition contains elements such as
SignalEventDefintion
or
TimerEventDefinition
which have required attributes, those will have
to be mapped before mapping is complete and flows can be automatically created.
Modifier and Type | Method and Description |
---|---|
ProcessDefinitionInfo |
activateProcessDefinition(String processDefinitionKey)
Activates the latest deployed version of the process flow definition so that process flows can be created from
it.
|
ProcessDefinitionInfo |
deployProcessDefinitionFromRepository(String path,
String version,
Set<String> contextTypeIds,
String comment,
boolean activate,
boolean overwrite)
Deploys the process flow definition file from the repository.
|
List<ProcessDefinitionInfo> |
getAllProcessDefinitions()
Gets all of the latest deployed process flow definitions.
|
ProcessDefinitionInfo |
getProcessDefinitionById(String id)
Gets the process flow definition with the specified unique id.
|
ProcessDefinitionInfo |
getProcessDefinitionByKey(String processDefinitionKey)
Gets the latest deployed version of the process flow definition by the specified process definition key.
|
Set<FlowElementDefinition> |
getProcessDefinitionElements(String id)
Gets the elements of a process flow definition.
|
ProcessDefinitionMapping |
getProcessDefinitionMappingByType(AutoFlowType type,
String processDefinitionKey)
Gets the element mapping for the process definition based on the auto flow type.
|
List<ProcessDefinitionMappingMetadata> |
getProcessDefinitionMappingMetadata()
Gets the process definition mapping metadata that describes what elements can be mapped to what attribute types.
|
List<ProcessDefinitionInfo> |
getProcessDefinitionsByContextType(String contextTypeId)
Gets the latest deployed process flow definitions at the context with the context type.
|
List<ProcessDefinitionInfo> |
getProcessDefinitionsMappedForAutoFlow(String contextTypeId,
AutoFlowType autoFlowType,
boolean activeOnly)
Gets the process definitions that are enabled and mapped for automatic process flow creation by the specified
context type.
|
ProcessDefinitionInfo |
suspendProcessDefinition(String processDefinitionKey)
Suspends the latest deployed version of the process flow definition so that process flows cannot be created from
it.
|
ProcessDefinitionMapping |
updateProcessDefinitionMapping(ProcessDefinitionMapping mapping)
Updates the element mapping for the process definition based on the auto flow type.
|
List<ProcessDefinitionInfo> getProcessDefinitionsByContextType(String contextTypeId) throws ProcessFlowException
contextTypeId
- The context type identifier for which to get the process flow definitions.ProcessFlowException
- Thrown when there is an issue getting the process flow definitions.List<ProcessDefinitionInfo> getAllProcessDefinitions()
ProcessDefinitionInfo deployProcessDefinitionFromRepository(String path, String version, Set<String> contextTypeIds, String comment, boolean activate, boolean overwrite) throws ProcessDefinitionDeploymentException
activate
is specified as False, the
process flow definition is deployed but in a suspended state, which means no process flows can be created from
that process flow definition until it is activated.path
- The path of the process flow definition file.version
- The version of the process flow definition file.contextTypeIds
- The context type identifiers in which to make process flow definition available.comment
- The comment that is associated with the deployment action of the process flow definition.activate
- Indicates whether to activate the process flow definition so that process flows can be created
from it.overwrite
- Whether to overwrite the existing process flow definition with the new version.ProcessFlowDeploymentException
- Thrown when there is an issue deploying the process flow definition file.ProcessDefinitionDeploymentException
ProcessDefinitionInfo activateProcessDefinition(String processDefinitionKey) throws ProcessDefinitionStateException, ProcessDefinitionNotFoundException
processDefinitionKey
- The process definition key of the process flow definition.ProcessDefinitionStateException
- Thrown when the process flow definition is currently activated.ProcessDefinitionNotFoundException
- Thrown when the process flow definition with the specified identifier
is not found.ProcessDefinitionInfo getProcessDefinitionById(String id) throws ProcessDefinitionNotFoundException
id
- The id of the process flow definition.ProcessDefinitionNotFoundException
- Thrown when the process flow definition with the specified identifier
is not found.ProcessDefinitionInfo getProcessDefinitionByKey(String processDefinitionKey) throws ProcessDefinitionNotFoundException
processDefinitionKey
- The key of the process flow definition.ProcessDefinitionNotFoundException
- Thrown when the process flow definition with the specified identifier
is not found.ProcessDefinitionInfo suspendProcessDefinition(String processDefinitionKey) throws ProcessDefinitionStateException, ProcessDefinitionNotFoundException
processDefinitionKey
- The process definition key of the process flow definition.ProcessDefinitionStateException
- Thrown when the process flow definition is currently suspended.ProcessDefinitionNotFoundException
- Thrown when the process flow definition with the specified key is not
found.ProcessDefinitionMapping updateProcessDefinitionMapping(ProcessDefinitionMapping mapping) throws ProcessDefinitionMappingUpdateException, ProcessDefinitionNotFoundException
FlowElementMapping
.
getProcessDefinitionMappingMetadata()
for more information about which elements map to which Tlf
attributes.mapping
- The process definition mapping for the auto flow type.ProcessDefinitionMappingUpdateException
- Thrown when the process definition mapping could not be updated.ProcessDefinitionNotFoundException
ProcessDefinitionMapping getProcessDefinitionMappingByType(AutoFlowType type, String processDefinitionKey) throws ProcessDefinitionNotFoundException
See getProcessDefinitionMappingMetadata()
for all process definition element attributes and metadata. It
will tell you the attributes available for each process definition element type and other
information
like attribute name, attribute
type
, and whether it supports multiple values. In addition, it
tells you what auto flow type (ex: Tlf) attributes map to each element attribute. For example, if you have a
process definition with a UserTask, the attribute, Assignee, could be mapped to a Tlf attribute of the same type,
such as User Assignment 1.
For Tlf attributes and metadata, see
StudyTlfService.getTlfAttributeMetadata()
.
type
- The auto flow type.processDefinitionKey
- The key of the process definition.ProcessDefinitionNotFoundException
- Thrown when the process flow definition does not exist.List<ProcessDefinitionMappingMetadata> getProcessDefinitionMappingMetadata()
List<ProcessDefinitionInfo> getProcessDefinitionsMappedForAutoFlow(String contextTypeId, AutoFlowType autoFlowType, boolean activeOnly)
contextTypeId
- The context type in which to get process definitions. Specifying null will look across all
contexts.autoFlowType
- The type from which a process flow can be automatically created.activeOnly
- Whether to return only active process flows.Set<FlowElementDefinition> getProcessDefinitionElements(String id) throws ProcessDefinitionNotFoundException
id
- The id of a process definition.ProcessDefinitionNotFoundException
- Thrown when the process flow definition does not exist.<i>Copyright (c) 2020, SAS Institute Inc., Cary, NC, USA</i>