Search…
How to add a document definition in Valtimo
Every process that we want to execute in Valtimo needs a document definition. This is a JSON file in which we define the structure of our data storage.
Multiple processes can use the same document definition. Only for the first process within a process chain do we need to make a link between the document definition and the BPMN model. For the other BPMN models within the process chain, we create a process link, which we will discuss in more detail in Connecting processes.
Create a JSON file in the folder "app > src > main > resources > config > document.definition". The name will be the process name in kebab-case, followed by '.scheme.json', for example:
1process-name.schema.json
We can now create our data structure in this JSON file. Since we don't have any data to save yet, we'll create an empty document definition with the following content:
1
{
2
"$id": "process-name.schema",
3
"$schema": "http://json-schema.org/draft-07/schema#",
4
"title": "Process name",
5
"type": "object",
6
"properties": {
7
}
8
}
Copied!
Within the "properties" key we later define our data structure, more information about this can be found on the Document definition page. For now this document definition is sufficient to go through our process. We now only need to link this document definition to our BPMN model.
Open DocumentDefinitionDeployedListener (src > main > java > com.ritense.valtim.implementation > config > demo > FormRegisteredEventListener). Here we find the "handle" method, in which all document definitions are linked to the corresponding BPMN models. Within the "handle" method we add the following code:
1
if (documentDefinitionDeployedEvent.documentDefinition().id().name().equals("process-name")) {
2
var processName = new ProcessDocumentDefinitionRequest(
3
"processName",
4
"process-name",
5
true
6
);
7
processDocumentAssociationService.createProcessDocumentDefinition(processName);
8
}
Copied!
Replace processName with the name we have set in our BPMN model, replace process-name with the name of the document definition with which we want to link the BPMN model.
Last modified 3mo ago
Copy link