public interface ProcessDefinitionService
A process flow definition is deployed from a BPMN file in the repository. See
deployProcessDefinitionFromRepository
. The BPMN file defines the elements, form properties, completion properties,
and 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 be created only from the latest deployed definition.
A process flow 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 flow definition element attributes, such a name and type, see
getProcessDefinitionMappingMetadata()
. This returns ProcessDefinitionMappingMetadata for each
AutoFlowType
, such as TLF. It indicates for each element type, the element attribute that maps to which TLF
attribute.
To create or update a definition mapping, first get the process definition and then get the process definition
mapping. For example,
ProcessDefinitionInfo processDef = service.getProcessDefinitionByKey("SimpleFlow");
ProcessDefinitionMapping defMapping = service.getProcessDefinitionMappingByType(AutoFlowType.TLF,
processDef.getProcessDefinitionKey());
List<FlowElementMapping> elementMapping = defMapping.getElementMapping();
If the process flow definition has never been mapped, the element mapping is empty.
To create a mapping and enable the definition for auto flow, see the example below. For simplicity, this process flow
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, see
getProcessDefinitionMappingMetadata()
and
StudyTlfService.getTlfAttributeMetadata()
.
Set<FlowElementDefinition> elements = service.getProcessDefinitionElements(def.getId());
FlowElementDefinition userTask = elements.iterator().next();
FlowElementMapping userTaskMapping = new FlowElementMapping(userTask.getElementId(), userTask.getType());
List<AttributeMapping> attrMap = userTaskMapping.getAttributeMapping();
attrMap.add(new AttributeMapping("Assignee", "User Assignment 1", FlowAttributeType.USER));
elementMapping.add(userTaskMapping);
defMapping.setEnableAutoFlowMapping(true);
defMapping = service.updateProcessDefinitionMapping(defMapping);
NOTE: You must set enable auto flow to true in order to save the element mapping.
Once you have saved the mapping by calling updateProcessDefinitionMapping(ProcessDefinitionMapping)
, you can
check that the mapping is complete with isMappingComplete()
. If
true
, the process flow definition is available to automatically create process flows. To find all such
process flow 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 flow definition contains elements such as
SignalEventDefintion
or
TimerEventDefinition
, that have required attributes, those elements
must 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 identifier.
|
ProcessDefinitionInfo |
getProcessDefinitionByKey(String processDefinitionKey)
Gets the latest deployed version of the process flow definition by the specified process flow 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 flow definition based on the auto flow type.
|
List<ProcessDefinitionMappingMetadata> |
getProcessDefinitionMappingMetadata()
Gets the process flow definition mapping metadata that describes the elements that 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 flow 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
- Indicates whether to overwrite the existing process flow definition with the new version.ProcessFlowDeploymentException
- Thrown when there is an issue when deploying the process flow definition file.ProcessDefinitionDeploymentException
ProcessDefinitionInfo activateProcessDefinition(String processDefinitionKey) throws ProcessDefinitionStateException, ProcessDefinitionNotFoundException
processDefinitionKey
- The process flow 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 identifier 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 flow 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 flow definition mapping for the auto flow type.ProcessDefinitionMappingUpdateException
- Thrown when the process definition mapping is not updated.ProcessDefinitionNotFoundException
ProcessDefinitionMapping getProcessDefinitionMappingByType(AutoFlowType type, String processDefinitionKey) throws ProcessDefinitionNotFoundException
See getProcessDefinitionMappingMetadata()
for all process flow definition element attributes and metadata. It
indicates the attributes that are available for each process flow definition element type and other
information
, such as attribute name, attribute
type
, and whether it supports multiple values. In addition, it
indicates the auto flow type (such as 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 flow 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 the process flow definitions. Specifying null looks across all
contexts.autoFlowType
- The type from which a process flow can be automatically created.activeOnly
- Indicates whether to return only active process flows.Set<FlowElementDefinition> getProcessDefinitionElements(String id) throws ProcessDefinitionNotFoundException
id
- The identifier of a process flow definition.ProcessDefinitionNotFoundException
- Thrown when the process flow definition does not exist.<i>Copyright (c) 2021, SAS Institute Inc., Cary, NC, USA</i>