Modeling business processes for generating excerpts in csv and docx format
🌐 This document is available in both English and Ukrainian. Use the language toggle in the top right corner to switch between versions. |
The description of the business process modeling mechanism is given in the example of the Registry of certified laboratories, namely in creating the "Laboratory report in csv format" excerpt. Modeling a business process for generating excerpts in the docx format is similar, except for the step where the file format is selected.
Fulfil the required preconditions for creating a business process, follow the link for instructions. |
1. Initial steps for creating a business process
-
Create a new BPMN diagram.
-
Add the Create pool/Participant element.
In the right-hand side window with parameters, you have to enter the appropriate values into the fields:
-
In the
Participant Name
field, enter the pool name —Generate a report on laboratories in csv format
. -
In the
Process id
field, enter the ID of the business process —zvit-csv-bp
. -
In the
Process name
field, enter the business name of the process —Generate a report on laboratories in csv format
.
-
-
Create the start event for starting the business process by a user.
In the settings panel on the right-hand side, enter the appropriate values into the following parameters:
-
In the
General
tab:-
In the
Id
field, enter theStartEvent_lab1
value. -
In the
Name
field, enter the name of the start event —Start Form
. -
in the
Initiator
field, enter theinitiator
value.initiator
is a special variable set for the user, which initiated the process.
-
-
In the Form tab:
-
in the
FormKey
field, enter the form ID —add-startform-zvit
.
-
In the
FormKey
field, enter the service name of the created UI form in the Regulations administrator portal.The following steps describe modeling of the start form.
-
2. Data preparation and signing
-
Create a service task Read data by laboratoryId.
Select the customized Read entity from data factory template.
You can find more details about this delegate on the page Read entity from data factory.
In the settings panel, enter the following values:
-
In the
Name
field, enter the name of the task —Data reading by laboratoryId
. -
In the
Resource
field, enter thelaboratory
resource. -
in the
Resource id
field, enter the resource ID —${submission('StartEvent_lab1').formData.prop('laboratory').prop('laboratoryId').value()}
.In our case, we pass the
StartEvent_lab1
resource identifier from the start form of the business process using thesubmission()
function. -
In the
X-Access-Token
field, specify the access token to the user’s system that is used to perform the${initiator().accessToken}
operation. -
In the
Result Variable
field, enter the output parameter name —labResponse
.
-
-
Create the Search for employees data service task.
Select the configured Search for entities in data factory template.
You can find more details about this delegate on the page Search for entities in data factory.
In the settings panel, enter the following values:
-
In the
Name
field, enter the name of the task —Search for employees data
. -
In the
Input Parameters
section:-
Expand the
Resource
block:-
Local Variable Assignment
is set toon
. This allows creation of a local variable for the request body. -
Variable Assignment Type
, select theString of Expression
variable assignment type from the dropdown list. -
Variable Assignment Value
, enterstaff-equal-laboratory-id
.
-
staff-equal-laboratory-id
is the endpoint name for the search criteria, where a request is made to find entities.-
Expand the
Search variable
block:-
Local Variable Assignment
has theon
value. -
Variable Assignment Type
, selectMap
. -
Add Entry
, enterlaboratoryId
inKey
, and enter${submission('StartEvent_lab1').formData.prop('laboratory').prop('laboratoryId').value()}
inValue
.
-
-
Expand the
X-Access-Token
block:-
Local Variable Assignment
has theon
value. -
Variable Assignment Type
, selectString of Expression
. -
Variable Assignment Value
, enter${initiator().accessToken}
.
-
-
-
In the
Output Parameters
section:-
Expand the
Result variable
block:-
Local Variable Assignment
has theon
value. -
Assign to Process Variable
, enter the value of the variable used for writing the request result —staffResponse
.
-
-
-
-
Create the Prepare data for displaying script task.
In the settings panel, enter the following values:
-
In the
Name
field, enter thePrepare data for displaying
name. -
In the
Script Format
field, enter the script type (language) —groovy
. -
In the
Script Type
field, select the script type —Inline Script
. -
In the
Script
field, insert the following groovy script:def labResponseBody = labResponse.responseBody def payload = [:] def personnelGrid = [] def addPersonPropClosure = { person, staffIt, key -> if (staffIt.hasProp(key)) { if (!staffIt.prop(key).isNull()) { person[key] = staffIt.prop(key).value() } } } staffResponse.responseBody.elements().each { def person = [:] addPersonPropClosure(person, it, 'fullName') addPersonPropClosure(person, it, 'specializationDate') addPersonPropClosure(person, it, 'salary') addPersonPropClosure(person, it, 'hygienistFlag') addPersonPropClosure(person, it, 'fullTimeFlag') personnelGrid.add(person) } payload['name'] = labResponseBody .prop('name').value() payload['edrpou'] = labResponseBody .prop('edrpou').value() payload['address'] = labResponseBody .prop('address').value() payload['headName'] = labResponseBody .prop('headName').value() payload['personnelGrid'] = personnelGrid execution.removeVariable('payload') set_transient_variable('payload', S(payload, 'application/json'))
-
-
Create the Display personnel data custom task.
In the settings panel, set the following values:
-
In the
Id
field, enter thepersonnelDataZvitForm
value. -
In the
Name
field, enter theDisplay personnel data
name. -
In the
Form key
field, enter theread-personnel-data-zvit
value.
In the
FormKey
field, you have to enter the service name of the created UI form in the Regulations administrator portal.The following steps describe modeling of the personnel data display form.
-
In the
Assignee
field, enter the${initiator}
value.${initiator}
indicates that the business process will be assigned to the user who initiated the business process. -
In the
Form data pre-population
field, enter the${payload}
value.
-
-
Create the Prepare data for creating database record (transient var) script task.
In the settings panel, set the following values:
-
In the
Name
field, enter thePrepare data for creating database record (transient var)
value. -
In the
Script Format
field, enter the script type (language) —groovy
. -
In the
Script Type
field, select theInline Script
script type. -
In the
Script
field, insert the following groovy script:def personnelFormData = submission('personnelDataZvitForm').formData def excerptInputData = [:] def requests = [] def prepopulatedDataMap = [:] prepopulatedDataMap['name'] = personnelFormData.prop('name').value() prepopulatedDataMap['address'] = personnelFormData.prop('address').value() prepopulatedDataMap['headName'] = personnelFormData.prop('headName').value() prepopulatedDataMap['edrpou'] = personnelFormData.prop('edrpou').value() personnelFormData.prop('personnelGrid').elements().each { def request = [:] request.putAll(prepopulatedDataMap) it.fieldNames().each { fieldName -> request[fieldName] = it.prop(fieldName).value() } request['hygienistFlag'] = it.prop('hygienistFlag').boolValue() ? '1' : '0' request['fullTimeFlag'] = it.prop('fullTimeFlag').boolValue() ? '1' : '0' requests.add(request) } excerptInputData['requests'] = requests def request = [:] request['recordId'] = null request['excerptType'] = 'lab-staff-excerpt-csv' request['excerptInputData'] = excerptInputData request['requiresSystemSignature'] = false def payload = S(request, 'application/json') execution.removeVariable('payload') set_transient_variable('payload', payload) execution.removeVariable('excerpt') set_transient_variable('excerpt', excerptInputData)
-
-
Add a service task for data signing with the system key.
For a detailed overview of the delegate description for signing data with the system key, follow this link.
Select the configured template Digital signature by DSO service.
In the settings panel, specify the following values:
-
In the Name field, indicate the task name
Sign data with the system key
. -
In the Payload field, enter the data to be signed —
${payload}
. -
In the X-Access-Token source field, indicate the user access token under which the operation is performed —
${initiator().accessToken}
. -
In the Result variable field, specify the variable name
system_signature_ceph_key
, to which the system signing key should be saved.
-
3. Generating a report
-
Create a service task Request for generating an excerpt.
Select the `Generate Excerpt' configured template.
-
In the
Name field
, enter theRequest for generating an excerpt
name. -
In the
Excerpt Type
field, enter the name of the file that defines the format —lab-staff-excerpt-csv
. -
In the
Excerpt Input Data
field, enter the${excerpt}
value. -
In the
Requires System Signature
field, enter thefalse
value.A possibility to sign excerpt data in .csv and .docx formats using a system key is not available. Therefore, the
Requires System Signature
parameter should contain thefalse
value by default. Iftrue
is set, the business process will not run. Signing using the system key is only available for the .pdf format. -
In the
X-Access-Token
field, enter the token to access the user system, which is used to perform the${initiator().accessToken}
operation. -
In the
X-Digital-Signature source
field, enter the source of the digital signature —${sign_submission('StartEvent_lab1').signatureDocumentId}
. -
In the
X-Digital-Signature-Derived source
field, enter the source of the system digital signature —${system_signature_ceph_key}
. -
In the
Result variable
field, enter theresponse
output parameter name.
-
The data transmitted to generate the
|
-
Create a file in the root of the cluster, placing it in the corresponding project directory.
The file name has to be identical to the name entered in
Excerpt Type
(at the previous step). In our example, that islab-staff-excerpt-csv.csv
.At this stage, the .csv and .docx file format is determined.
-
Create a "Save excerpt’s request ID" script task.
In the settings panel, set the following values:
-
In the
Name
field, enter the name of the task — Save excerpt’s request ID. -
In the
Script Format
field, enter the script type (language) —groovy
. -
In the
Script Type
field, select theInline Script
script type. -
In the
Script
field, insert the following groovy script:response.responseBody.prop('excerptIdentifier').value()
-
In the
Result Variable
field, enter the name of the variable to which the extract identifier will be written, —excerptIdentifier
.
-
4. Setting the conditions of the output generation result checks
-
Add the task for calling an external business process (Call Activity) "Check excerpt generation status".
Select the configured
Check excerpt status
template.Follow the link to find more details about the
Check excerpt status
delegate.In the settings panel, enter the following values:
-
In the
Name
field, enter the name of the task —Check the status of excerpt generation
. -
In the
Input excerpt identifier
field, enter the excerpt ID that has to be passed to the called business process —${excerptIdentifier}
. -
In the
Output variable name
field, enter theexcerptStatus
variable, where the excerpt status, recived as the result of a sub-process execution, has to be saved.
Example 1. "Check excerpt generation status" business process -
-
Add the Create Intermediate/Boundary Event element, define its type by clicking the key icon (Change type) and selecting the Timer Boundary Event item from the menu.
Follow the link to find more detailed description of the Timer event modeling element.
Go to the settings panel and configure the event:
-
In the
Name
field, enter theP2M waiting time expired
. -
In the
Timer Definition Type
field, set theDuration
timer type; -
In the
Timer Definition
field, set theP2M
timer duration.
-
-
Add XOR gateways for the "Check excerpt generation status" Call Activity and for the "P2M Timed Out" Timer Boundary Event.
-
Create the "Save the generated excerpt identifier to the system BP" service task.
In the settings panel, set the following values:
-
In the
General
tab:-
In the
Name
field, enter the valueSave the identifier of the generated excerpt to the system BP
. -
in the
Implementation
field ,select theDelegate Expression
value. -
In the
Delegate Expression
field, enter${defineProcessExcerptIdDelegate}
.
-
-
In the
Input/Output
tab:-
In the
Local Variable Name
field, enter theexcerptId
value. -
In the
Variable Assignment Type
field, selectString or Expression
. -
In the
Variable Assignment Value
field, enter${excerptIdentifier}
.
↓
-
The value specified in the
Id
field is used as the name of the file that a user downloads from the portal. -
-
Configure the flow process for the XOR gateway.
Create Connect using sequence (branches):
-
To the "Save the identifier of the generated excerpt to the system BP" service task:
-
Enter
yes
in theName
field. -
In the
Condition Type
field, selectExpression
. -
In the
Expression
field, enter the${excerptStatus.equals('COMPLETED')}
value.
-
-
To another XOR gateway:
-
In the
Name
field, enterno
. -
In the
Condition Type
field, selectExpression
. -
In the
Expression
field, enter${excerptStatus.equals('FAILED')}
.
-
-
5. Process execution result
5.1. Unsuccessful result of business process execution
-
Create the "Execution result "Excerpt not generated"" service task.
Choose the
Define business process status
configured template.+ In the settings panel, set the following values:
-
In the
Name
field, enter theExecution result "Excerpt not generated"
value. -
In the
Status
field, enter theExcerpt not generated
value. This status is displayed after process completion.
-
-
Configure the flow process from the XOR gateway to the service task "Execution result "Excerpt not generated"" by creating a Connect using sequence (branch).
And create the business process completion event.
-
In the
Name
field, enter theExcerpt document not generated
value.
-
5.2. Successful result of business process execution
-
Create the "Execution result "Excerpt generated"" service task.
Choose the
Define business process status
configured template.In the settings panel, set the following values:
-
In the
Name
field, enter theExecution result "Excerpt generated"
value. -
In the
Status
field, enter theExcerpt generated
value. This status is displayed after process completion.
-
-
Create the business process completion event.
-
In the
Name
field, enter theExcerpt document generated
value.
-
6. Modeling forms
Model the forms in accordance with the instructions at the link.
6.1. Modeling the starting form
Modeling the starting form involves creation of a form for searching a laboratory by its name.
-
In the
Form business name
field, enter theStart form lab report
value. -
In the
Form service name
field, enter theadd-startform-zvit
value (which is used at the previous step as the value of theForm Key
parameter).
The configured form can be downloaded from the following link: |
6.2. Modeling the personnel data display form
Modeling the personnel data display form involves creation of a form for generating the data of the called laboratory.
-
In the
Business name of the form
field, enter theDisplay personnel data report
value. -
In the
Form service name
field, enter theread-personnel-data-zvit
value (which is used at the previous step as the value of theForm Key
parameter).
The configured form can be downloaded from the following link: |
7. An example of using the business process by a user
You can learn more about the process of creating excerpts by users based on the result of the modeled business process by the following links: