Flowgro Delegate Helper Package¶
This document describes the prerequisites, required variables, and usage details for the Camunda JavaDelegate classes located in the com.kafein.dataprivacy.flowgro.delegate.helper package.
Variable Initialization
Before invoking any delegate, all required variables must be set.
These variables are typically set via:
- User Task forms (user input)
- Previous Service Tasks (automatically)
- Script Tasks (programmatically)
- Start Event form fields
1. InitializeRequestDelegate¶
Component Name: initializeRequestDelegate
Description¶
Creates and initializes a new Data Subject Request (DSR). This delegate is typically invoked at the very beginning of the process, immediately after the Start Event.
How Are Variables Set?¶
These variables are usually set when starting the process via a Start Event Form or an external API call.
// Programmatic process start example
Map<String, Object> variables = new HashMap<>();
variables.put("name", "Ahmet");
variables.put("surname", "Yılmaz");
variables.put("email", "ahmet@example.com");
variables.put("subjectTypeId", "uuid-here");
variables.put("categoryId", "uuid-here");
runtimeService.startProcessInstanceByKey("dsr-process", variables);
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
name |
String | ✅ | Start Form / API | Requester first name |
surname |
String | ✅ | Start Form / API | Requester last name |
email |
String | ✅ | Start Form / API | Requester email address |
subjectTypeId |
String (UUID) | ✅ | Start Form / API | Subject type ID |
categoryId |
String (UUID) | ✅ | Start Form / API | Category ID |
Output Variables¶
| Variable | Type | Description |
|---|---|---|
applicationProcessId |
UUID | ID of the created DSR |
| Business Key | String | Set as the DSR code and used by all subsequent delegates |
Side Effects¶
-
A new DSR record is created in the database
-
Application Documents and Response Documents folders are created
-
An audit log entry is written
2. DeclineReasonDelegate¶
Component Name: declineReasonDelegate
Açıklama¶
Stores the reason for a declined request in the database.Before invoking this delegate, the DSR_DECLINE_REASON variable must be set.
How Is the Variable Set?¶
Method 1: User Task Form (Recommended)
<bpmn:userTask id="fillDeclineForm" name="Enter Decline Reason">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="DSR_DECLINE_REASON" label="Decline Reason" type="string">
<camunda:validation>
<camunda:constraint name="required" />
</camunda:validation>
</camunda:formField>
</camunda:formData>
</bpmn:extensionElements>
</bpmn:userTask>
<!-- The delegate is executed immediately after the form submission -->
<bpmn:serviceTask id="saveDeclineReason" name="Save the Decline Reason"
camunda:delegateExpression="${declineReasonDelegate}" />
Method 2: Script Task
<bpmn:scriptTask id="setReason" scriptFormat="javascript">
<bpmn:script>
execution.setVariable("DSR_DECLINE_REASON", "Missing documents, please upload an ID copy.");
</bpmn:script>
</bpmn:scriptTask>
Method 3: Input Mapping
<bpmn:serviceTask id="saveDeclineReason" camunda:delegateExpression="${declineReasonDelegate}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="DSR_DECLINE_REASON">${rejectionReason}</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
</bpmn:serviceTask>
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
DSR_DECLINE_REASON |
String | ❌ | User Task Form / Script | Decline reason text |
If DSR_DECLINE_REASON is not set, the delegate exits silently and no database record is created.
3. StatusChangeDelegate¶
Component Name: statusChangeDelegate
Description¶
Updates the DSR status based on the provided status code.
The statusCode variable must be set before invoking this delegate.
How Is the Variable Set?¶
Method 1: Static Value via BPMN
<bpmn:serviceTask id="changeStatus" name="Change the Status"
camunda:delegateExpression="${statusChangeDelegate}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="statusCode">IN_PROGRESS</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
</bpmn:serviceTask>
Method 2: Dynamic Based on a Previous Gateway Decision
<bpmn:exclusiveGateway id="decisionGateway" />
<!-- If approved -->
<bpmn:sequenceFlow sourceRef="decisionGateway" targetRef="setApproved">
<bpmn:conditionExpression>${approved == true}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:scriptTask id="setApproved" scriptFormat="javascript">
<bpmn:script>execution.setVariable("statusCode", "APPROVED");</bpmn:script>
</bpmn:scriptTask>
<!-- If rejected -->
<bpmn:sequenceFlow sourceRef="decisionGateway" targetRef="setRejected">
<bpmn:conditionExpression>${approved == false}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:scriptTask id="setRejected" scriptFormat="javascript">
<bpmn:script>execution.setVariable("statusCode", "REJECTED");</bpmn:script>
</bpmn:scriptTask>
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
statusCode |
String | ✅ | Script Task / Input Mapping | Must exist in database |
If statusCode is invalid or undefined, a NullPointerException occurs.
4. NextStatusDelegate¶
Component Name: nextStatusDelegate
Description¶
Automatically moves the DSR to the next status defined in the workflow.
Required Input Variables¶
No additional variables are required.
The next status is determined by the order field in the DataSubjectRequestTypeStatus table.
Example Usage (BPMN)¶
<bpmn:serviceTask id="moveToNextStatus" name="Move to Next Status"
camunda:delegateExpression="${nextStatusDelegate}" />
The next status is resolved according to the order field in the DataSubjectRequestTypeStatus table.
5. LastStatusDelegate¶
Component Name: lastStatusDelegate
Description¶
Moves the DSR to the final status (typically Completed or Closed).
Required Input Variables¶
No additional variables are required.
Example Usage (BPMN)¶
<bpmn:serviceTask id="closeRequest" name="Close the Request"
camunda:delegateExpression="${lastStatusDelegate}" />
6. ProcessStatusChangeDelegate¶
Component Name: processStatusChangeDelegate
Description¶
Updates the DSR process status (ProcessStatus enum).
Before invoking this delegate, the processStatus variable must be set to a valid enum value.
How Is the Variable Set?¶
Via User Task Form:
<bpmn:userTask id="approvalTask" name="Make Approval Decision">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="processStatus" label="Decision" type="enum">
<camunda:value id="APPROVED" name="Approve" />
<camunda:value id="REJECTED" name="Reject" />
<camunda:value id="PENDING" name="Pending" />
</camunda:formField>
</camunda:formData>
</bpmn:extensionElements>
</bpmn:userTask>
<bpmn:serviceTask id="updateProcessStatus" name="Update Process Status"
camunda:delegateExpression="${processStatusChangeDelegate}" />
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
processStatus |
String | ✅ | User Task Form / Script | ProcessStatus enum value such as PENDING, APPROVED, REJECTED, etc. |
7. EmailSenderDelegate¶
Component Name: emailSenderDelegate
Description¶
Sends an email based on the specified template code.
Before invoking this delegate, the mailTemplateCode variable must be set
to the code of the email template to be sent.
How Is the Variable Set?¶
Method 1: Via BPMN Input Mapping (Recommended)
<bpmn:serviceTask id="sendConfirmationEmail" name="Send Confirmation Email"
camunda:delegateExpression="${emailSenderDelegate}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="mailTemplateCode">DSR_CONFIRMATION</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
</bpmn:serviceTask>
Dynamic Template Selection (via Gateway)
<bpmn:exclusiveGateway id="emailTypeGateway" />
<bpmn:sequenceFlow sourceRef="emailTypeGateway" targetRef="sendApprovalEmail">
<bpmn:conditionExpression>${processStatus == 'APPROVED'}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:serviceTask id="sendApprovalEmail" camunda:delegateExpression="${emailSenderDelegate}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="mailTemplateCode">DSR_APPROVED</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
</bpmn:serviceTask>
<bpmn:sequenceFlow sourceRef="emailTypeGateway" targetRef="sendRejectionEmail">
<bpmn:conditionExpression>${processStatus == 'REJECTED'}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:serviceTask id="sendRejectionEmail" camunda:delegateExpression="${emailSenderDelegate}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="mailTemplateCode">DSR_REJECTED</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
</bpmn:serviceTask>
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
mailTemplateCode |
String | ✅ | Input Mapping / Script | Email template code defined in the database |
Example Template Codes¶
| Template Code | Description | When to Use |
|---|---|---|
DSR_CONFIRMATION |
Request received confirmation | Immediately after the request is created |
DSR_VERIFICATION |
Identity verification | When user verification is required |
DSR_COMPLETED |
Request completed | When the process is successfully completed |
DSR_REJECTED |
Request rejected | When the request is rejected |
DSR_REMINDER |
Reminder | For pending or overdue actions |
Important
The template code must be defined in the mail_template table.
Otherwise, the email cannot be sent.
8. VerificationMailRepliedCheckDelegate¶
Component Name: verificationMailRepliedCheckDelegate
Description¶
Checks whether a reply has been received for the verification email sent to the user.
Searches the INBOX for an email containing the DSR code and writes the result to the verificationMailReplied variable.
Required Input Variables¶
No additional variables required — the email search is performed using the Business Key (DSR code).
Output Variables¶
| Variable | Type | Description |
|---|---|---|
verificationMailReplied |
Boolean | true: Reply received, false: No reply received |
Example Usage (BPMN)¶
<!-- Periodic check using a Timer -->
<bpmn:intermediateCatchEvent id="waitTimer">
<bpmn:timerEventDefinition>
<bpmn:timeDuration>PT1H</bpmn:timeDuration> <!-- Hourly Check -->
</bpmn:timerEventDefinition>
</bpmn:intermediateCatchEvent>
<bpmn:serviceTask id="checkVerification" name="Doğrulama Kontrolü"
camunda:delegateExpression="${verificationMailRepliedCheckDelegate}" />
<bpmn:exclusiveGateway id="verificationGateway" />
<bpmn:sequenceFlow sourceRef="verificationGateway" targetRef="continueProcess">
<bpmn:conditionExpression>${verificationMailReplied == true}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow sourceRef="verificationGateway" targetRef="waitTimer">
<bpmn:conditionExpression>${verificationMailReplied == false}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
9. DocgroSendEventDelegate¶
Component Name: docgroSendEventDelegate
Description¶
Sends a PDF generation event to Kafka. Before invoking this delegate, the variables docgroBucketName, docgroFileName and docgroUrl MUST be set.
How to Set Variables¶
<bpmn:serviceTask id="generatePDF" name="Generate PDF"
camunda:delegateExpression="${docgroSendEventDelegate}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="docgroBucketName">dsr-documents</camunda:inputParameter>
<camunda:inputParameter name="docgroFileName">${execution.processBusinessKey}_report.pdf</camunda:inputParameter>
<camunda:inputParameter name="docgroUrl">http://template-service/templates/dsr-report</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
</bpmn:serviceTask>
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
docgroBucketName |
String | ✅ | Input Mapping | MinIO bucket name (e.g. dsr-documents) |
docgroFileName |
String | ✅ | Input Mapping | Name of the generated file (e.g. DSR-001_report.pdf) |
docgroUrl |
String | ✅ | Input Mapping | PDF template URL |
10. FileTransferDelegate¶
Component Name: statusDelegate
Description¶
Uploads a downloaded file to the DSR Response Documents folder.
Before invoking this delegate, the downloadedFilePath variable must be set.
How to Set Variables¶
From a Previous Task (e.g. after an external service call):
<bpmn:serviceTask id="downloadFromExternal" name="Download from External Service"
camunda:delegateExpression="${externalDownloadDelegate}">
<!-- This delegate sets the downloadedFilePath variable -->
</bpmn:serviceTask>
<bpmn:serviceTask id="uploadToFolder" name="Upload to Folder"
camunda:delegateExpression="${statusDelegate}" />
Using a Script Task:
<bpmn:scriptTask id="setPath" scriptFormat="javascript">
<bpmn:script>
execution.setVariable("downloadedFilePath", "/tmp/downloads/report_12345.pdf");
</bpmn:script>
</bpmn:scriptTask>
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
downloadedFilePath |
String | ❌ | Previous Service Task / Script | Absolute file system path of the file. If null or empty, the operation is skipped. |
After the file is uploaded, the temporary file is automatically deleted.
11. MinioToFolderDelegate¶
Component Name: minioToFolderDelegate
Description¶
Moves a file stored in MinIO to the DSR Response Documents folder.
Before invoking this delegate, the reportUrl variable must be set with the MinIO file URL.
How to Set Variables¶
Using a Kafka Event (via Message Correlation):
<bpmn:intermediateCatchEvent id="waitForPDF">
<bpmn:messageEventDefinition messageRef="pdfGeneratedMessage" />
</bpmn:intermediateCatchEvent>
<!-- Kafka consumer sets the reportUrl variable using message correlation -->
<bpmn:serviceTask id="moveReport" name="Move Report"
camunda:delegateExpression="${minioToFolderDelegate}" />
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
reportUrl |
String | ✅ | Message Correlation / Script | MinIO file URL (e.g. http://minio:9000/bucket/path/file.pdf) |
12. LogActionDelegate¶
Component Name: logActionDelegate
Description¶
Creates an operation log entry (audit trail) for the DSR.
Before invoking this delegate, the variables logActionOperationType and logDescription must be set.
How to Set Variables¶
<bpmn:serviceTask id="logApproval" name="Approval Log"
camunda:delegateExpression="${logActionDelegate}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="logActionOperationType">APPROVE</camunda:inputParameter>
<camunda:inputParameter name="logDescription">Request ${execution.processBusinessKey} was approved by an administrator</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
</bpmn:serviceTask>
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
logActionOperationType |
String | ✅ | Input Mapping | OperationType enum value: CREATE, UPDATE, APPROVE, REJECT, SUCCESS, ERROR |
logDescription |
String | ✅ | Input Mapping | Log description (Turkish or English) |
13. SystemParametersFetchDelegate¶
Component Name: systemParametersFetchDelegate
Description¶
Fetches system parameters in bulk and assigns them to workflow variables.
Before invoking this delegate, the SYSTEM_PARAMETERS_REQUEST variable may be set with the list of requested parameters (optional).
How to Set Variables¶
<bpmn:serviceTask id="fetchParams" name="Fetch Parameters"
camunda:delegateExpression="${systemParametersFetchDelegate}">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="SYSTEM_PARAMETERS_REQUEST">
[["EMAIL", "SMTP_HOST"], ["EMAIL", "SMTP_PORT"], ["GENERAL", "COMPANY_NAME"]]
</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
</bpmn:serviceTask>
<!-- Using parameters in subsequent tasks -->
<bpmn:scriptTask id="useParams" scriptFormat="javascript">
<bpmn:script>
var params = execution.getVariable("SYSTEM_PARAMETER_VALUES");
var smtpHost = params.get(0); // First parameter
var companyName = params.get(2); // Third parameter
// ...
</bpmn:script>
</bpmn:scriptTask>
Required Input Variables¶
| Variable | Type | Required | Source | Description |
|---|---|---|---|---|
SYSTEM_PARAMETERS_REQUEST |
JSON Array | ❌ | Input Mapping / Script | In the format [["GROUP_CODE", "KEY"], ...]. Returns an empty list if null. |
Output Variables¶
| Variable | Type | Description |
|---|---|---|
SYSTEM_PARAMETER_VALUES |
List\<String> | Values of the requested parameters (in the same order) |
General Notes¶
Variable Initialization Rule
All required variables must be set before invoking any delegate.
Delegates only read existing values using execution.getVariable().
Note
All delegates access the DSR code via execution.getProcessBusinessKey().
Therefore, the Business Key must be set when InitializeRequestDelegate is invoked.
Ways to Set Variables
- Input Mapping:
<camunda:inputOutput>element of a Service Task - User Task Form: User form fields
- Script Task:
execution.setVariable("name", value) - Message Correlation: From Kafka/Event messages
Warning
If required variables are missing, a NullPointerException may occur.
Validation at the BPMN design level is strongly recommended.
File Locations¶
com.kafein.dataprivacy.flowgro.delegate.helper/
├── DeclineReasonDelegate.java
├── DocgroSendEventDelegate.java
├── EmailSenderDelegate.java
├── FileTransferDelegate.java
├── InitializeRequestDelegate.java
├── LastStatusDelegate.java
├── LogActionDelegate.java
├── MinioToFolderDelegate.java
├── NextStatusDelegate.java
├── ProcessStatusChangeDelegate.java
├── StatusChangeDelegate.java
├── SystemParametersFetchDelegate.java
└── VerificationMailRepliedCheckDelegate.java