Skip to content

Commit

Permalink
adding test case
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-ritense committed Nov 11, 2024
1 parent 265b7cb commit 029b2db
Show file tree
Hide file tree
Showing 25 changed files with 1,952 additions and 21 deletions.
5 changes: 4 additions & 1 deletion backend/app/.env.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ SMART_DOCUMENTS_URL=https://example.com/
SMART_DOCUMENTS_USERNAME=test-user
SMART_DOCUMENTS_PASSWORD=test-password

VALTIMO_OPENKLANT_SECRET=e09b8bc5-5831-4618-ab28-41411304309d
VALTIMO_OPENKLANT_SECRET=e09b8bc5-5831-4618-ab28-41411304309d
#org.openapitools.client.baseUrl=${BASEURL}
org.openapitools.client.baseUrl=wdwwer

2 changes: 2 additions & 0 deletions backend/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ bootRun {
}
}
}
args("-Peeen=eeen")
args("-Dtwee=twee")
}
5 changes: 5 additions & 0 deletions backend/app/src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,8 @@ keycloak:
resource: valtimo-user-m2m-client
credentials:
secret: 6ef6ca16-6b86-482a-a3d9-0561704c1db9


plugin:
xential:
baseurl: http://localhost:1080
6 changes: 3 additions & 3 deletions backend/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies {
implementation "com.ritense.valtimo:openzaak-plugin-authentication:${valtimoVersion}"
implementation "com.ritense.valtimo:zaken-api:${valtimoVersion}"
implementation "com.ritense.valtimo:documenten-api:${valtimoVersion}"

implementation "com.ritense.valtimo:zgw:${valtimoVersion}"
implementation "org.springframework.boot:spring-boot-starter-webflux:${springVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springVersion}"

Expand Down Expand Up @@ -122,8 +122,8 @@ test {
useJUnitPlatform()
}

sourceCompatibility = 20
targetCompatibility = 20
sourceCompatibility = 21
targetCompatibility = 21

apply plugin: "com.avast.gradle.docker-compose"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@

package com.ritense.valtimo.xential.autoconfiguration

import com.ritense.documentenapi.client.DocumentenApiClient
import com.ritense.plugin.service.PluginService
import com.ritense.valtimo.contract.config.LiquibaseMasterChangeLogLocation
import com.ritense.valtimo.xential.plugin.XentialPluginFactory
import com.ritense.valtimo.xential.repository.XentialTokenRepository
import com.ritense.valtimo.xential.service.DocumentGenerationService
import com.ritense.valueresolver.ValueResolverService
import com.ritense.zakenapi.ZaakUrlProvider
import com.ritense.zakenapi.client.ZakenApiClient
import com.rotterdam.xential.api.DefaultApi
import org.camunda.bpm.engine.RuntimeService
import org.openapitools.client.infrastructure.ApiClient
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.domain.EntityScan
import org.springframework.context.ApplicationEventPublisher
import org.springframework.context.annotation.Bean
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.web.reactive.function.client.WebClient
Expand Down Expand Up @@ -60,21 +66,35 @@ class XentialAutoConfiguration {
return DefaultApi()
}

// @Value("\${plugin.xential.baseurl: }") baseUrl: String

@Bean
@ConditionalOnMissingBean
fun apiClient(
@Value("plugin.xential.baseurl")
baseUrl: String,
) = ApiClient(baseUrl)
) = ApiClient("http://localhost:1080")

@Bean
@ConditionalOnMissingBean
fun documentGenerationService(
defaultApi: DefaultApi,
xentialTokenRepository: XentialTokenRepository
xentialTokenRepository: XentialTokenRepository,
pluginService: PluginService,
documentenApiClient: DocumentenApiClient,
applicationEventPublisher: ApplicationEventPublisher,
zaakUrlProvider: ZaakUrlProvider,
zakenApiClient: ZakenApiClient,
runtimeService: RuntimeService,
valueResolverService: ValueResolverService
) = DocumentGenerationService(
defaultApi,
xentialTokenRepository,
pluginService,
documentenApiClient,
applicationEventPublisher,
zaakUrlProvider,
zakenApiClient,
runtimeService,
valueResolverService
)

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.ritense.valtimo.xential.domain

import com.ritense.valtimo.xential.plugin.TemplateDataEntry
import java.util.UUID

data class GenerateDocumentProperties(
val templateId: UUID,
val fileFormat: FileFormat,
val documentId: String,
val messageName: String,
val templateData: Map<String, String>
val templateData: Array<TemplateDataEntry>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.ritense.valtimo.xential.plugin

data class TemplateDataEntry(
val key: String,
val value: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@
package com.ritense.valtimo.xential.plugin

import com.ritense.documentenapi.DocumentenApiPlugin
import com.ritense.openzaak.plugin.OpenZaakPlugin
import com.ritense.plugin.annotation.Plugin
import com.ritense.plugin.annotation.PluginAction
import com.ritense.plugin.annotation.PluginActionProperty
import com.ritense.plugin.annotation.PluginProperty
import com.ritense.processlink.domain.ActivityTypeWithEventName
import com.ritense.valtimo.xential.domain.FileFormat
import com.ritense.valtimo.xential.domain.GenerateDocumentProperties
import com.ritense.valtimo.xential.domain.XentialToken
import com.ritense.valtimo.xential.plugin.XentialPlugin.Companion.PLUGIN_KEY
import com.ritense.valtimo.xential.repository.XentialTokenRepository
import com.ritense.valtimo.xential.service.DocumentGenerationService
import com.ritense.zakenapi.ZakenApiPlugin
import com.rotterdam.xential.api.DefaultApi
import com.rotterdam.xential.model.Sjabloondata
import org.camunda.bpm.engine.delegate.DelegateExecution
import java.util.UUID

Expand All @@ -54,18 +51,34 @@ class XentialPlugin(
@PluginProperty(key = "zakenApiPluginConfiguration", secret = false)
lateinit var zakenApiPluginConfiguration: ZakenApiPlugin


@PluginAction(
key = "generate-document",
title = "Generate document",
description = "Generate a document using xential.",
activityTypes = [ActivityTypeWithEventName.SERVICE_TASK_START]
)
fun generateDocument(execution: DelegateExecution, generateDocumentProperties: GenerateDocumentProperties) {
fun generateDocument(
@PluginActionProperty templateId: UUID,
@PluginActionProperty fileFormat: FileFormat,
@PluginActionProperty documentId: String,
@PluginActionProperty messageName: String,
@PluginActionProperty templateData: Array<TemplateDataEntry>,
execution: DelegateExecution
) {
val generateDocumentProperties = GenerateDocumentProperties(
templateId,
fileFormat,
documentId,
messageName,
templateData
)
documentGenerationService.generateDocument(
UUID.fromString(execution.processInstanceId),
generateDocumentProperties,
clientId,
clientPassword
clientPassword,
execution
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ritense.valtimo.xential.service

import com.ritense.documentenapi.DocumentenApiPlugin
import com.ritense.documentenapi.client.CreateDocumentRequest
import com.ritense.documentenapi.client.DocumentStatusType
import com.ritense.documentenapi.client.DocumentenApiClient
Expand All @@ -9,18 +8,19 @@ import com.ritense.plugin.service.PluginService
import com.ritense.valtimo.xential.domain.DocumentCreatedMessage
import com.ritense.valtimo.xential.domain.GenerateDocumentProperties
import com.ritense.valtimo.xential.domain.XentialToken
import com.ritense.valtimo.xential.plugin.TemplateDataEntry
import com.ritense.valtimo.xential.plugin.XentialPlugin
import com.ritense.valtimo.xential.repository.XentialTokenRepository
import com.ritense.valueresolver.ValueResolverService
import com.ritense.zakenapi.ZaakUrlProvider
import com.ritense.zakenapi.ZakenApiPlugin
import com.ritense.zakenapi.client.LinkDocumentRequest
import com.ritense.zakenapi.client.ZakenApiClient
import com.rotterdam.xential.api.DefaultApi
import com.rotterdam.xential.model.Sjabloondata
import org.camunda.bpm.engine.RuntimeService
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.openapitools.client.infrastructure.ApiClient
import org.springframework.context.ApplicationEventPublisher
import org.springframework.security.core.context.SecurityContextHolder
import java.io.ByteArrayInputStream
import java.time.LocalDate
import java.util.Base64
Expand All @@ -35,15 +35,19 @@ class DocumentGenerationService(
val zaakUrlProvider: ZaakUrlProvider,
val zakenApiClient: ZakenApiClient,
val runtimeService: RuntimeService,
val valueResolverService: ValueResolverService
) {

fun generateDocument(
processId: UUID,
generateDocumentProperties: GenerateDocumentProperties,
clientId: String,
clientPassword: String,
execution: DelegateExecution,
) {
val sjabloonVulData = generateDocumentProperties.templateData.entries.map { "<${it.key}>${it.value}</${it.key}>" }.joinToString()

val resolvedMap = resolveTemplateData(generateDocumentProperties.templateData,execution)
val sjabloonVulData = resolvedMap.map { "<${it.key}>${it.value}</${it.key}>" }.joinToString()

ApiClient.username = clientId
ApiClient.password = clientPassword
Expand Down Expand Up @@ -83,6 +87,7 @@ class DocumentGenerationService(
bronorganisatie = documentenApiPlugin.bronorganisatie,
creatiedatum = LocalDate.now(),
titel = message.documentkenmerk,
vertrouwelijkheidaanduiding = null,
auteur = message.gebruiker,
status = DocumentStatusType.DEFINITIEF,
taal = "nld",
Expand Down Expand Up @@ -128,6 +133,18 @@ class DocumentGenerationService(
}
}

private fun resolveTemplateData(
templateData: Array<TemplateDataEntry>,
execution: DelegateExecution
): Map<String, Any?> {
val placeHolderValueMap = valueResolverService.resolveValues(
execution.processInstanceId,
execution,
templateData.map { it.value }.toList()
)
return templateData.associate { it.key to placeHolderValueMap.getOrDefault(it.value, null) }
}

private fun getXentialPlugin(message: DocumentCreatedMessage): XentialPlugin {
//FIXME needs a way of determining the right plugin
val pluginConfig = pluginService.findPluginConfiguration(XentialPlugin.PLUGIN_KEY) { _ -> true}
Expand Down
66 changes: 66 additions & 0 deletions backend/plugin/src/main/resources/config/bpmn/xential-test.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_13f33lz" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.23.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.21.0">
<bpmn:message id="Message_1cbdmsu" name="MESSAGE_DOC_RECEIVED" />
<bpmn:collaboration id="Collaboration_15s7f2e">
<bpmn:participant id="Participant_06az24z" name="Xential test" processRef="xential-test" />
</bpmn:collaboration>
<bpmn:process id="xential-test" name="xential test" isExecutable="true">
<bpmn:startEvent id="XentialTestStartEvent" name="Start event">
<bpmn:outgoing>Flow_1iic9b3</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:endEvent id="Event_1hl2nsy">
<bpmn:incoming>Flow_12ouxh8</bpmn:incoming>
</bpmn:endEvent>
<bpmn:intermediateCatchEvent id="Event_0w2iwra" name="doc klaar">
<bpmn:incoming>Flow_0z4j34w</bpmn:incoming>
<bpmn:outgoing>Flow_12ouxh8</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_1s7pptr" messageRef="Message_1cbdmsu" />
</bpmn:intermediateCatchEvent>
<bpmn:serviceTask id="MaakDocumentTask" name="doc maken" camunda:expression="${true}">
<bpmn:incoming>Flow_1iic9b3</bpmn:incoming>
<bpmn:outgoing>Flow_0z4j34w</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1iic9b3" sourceRef="XentialTestStartEvent" targetRef="MaakDocumentTask" />
<bpmn:sequenceFlow id="Flow_12ouxh8" sourceRef="Event_0w2iwra" targetRef="Event_1hl2nsy" />
<bpmn:sequenceFlow id="Flow_0z4j34w" sourceRef="MaakDocumentTask" targetRef="Event_0w2iwra" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_15s7f2e">
<bpmndi:BPMNShape id="Participant_06az24z_di" bpmnElement="Participant_06az24z" isHorizontal="true">
<dc:Bounds x="160" y="60" width="600" height="250" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="XentialTestStartEvent">
<dc:Bounds x="268" y="168" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="260" y="211" width="54" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1hl2nsy_di" bpmnElement="Event_1hl2nsy">
<dc:Bounds x="618" y="168" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1sjxnto_di" bpmnElement="Event_0w2iwra">
<dc:Bounds x="528" y="168" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="525" y="211" width="45" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1q8w7gi_di" bpmnElement="MaakDocumentTask">
<dc:Bounds x="350" y="146" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1iic9b3_di" bpmnElement="Flow_1iic9b3">
<di:waypoint x="304" y="186" />
<di:waypoint x="350" y="186" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_12ouxh8_di" bpmnElement="Flow_12ouxh8">
<di:waypoint x="564" y="186" />
<di:waypoint x="618" y="186" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0z4j34w_di" bpmnElement="Flow_0z4j34w">
<di:waypoint x="450" y="186" />
<di:waypoint x="528" y="186" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"canHaveAssignee": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
{
"title": "",
"key": "zaaknummer",
"path": "doc:openzaak.identificatie",
"displayType": {
"type": "string",
"displayTypeParameters": {}
},
"sortable": true,
"defaultSort": null,
"order": 0
},
{
"title": "",
"key": "createdOn",
"path": "case:createdOn",
"displayType": {
"type": "date",
"displayTypeParameters": {
"dateFormat": "DD-MM-yyyy"
}
},
"sortable": true,
"defaultSort": "DESC",
"order": 1
},
{
"title": "",
"key": "assigneeFullName",
"path": "case:assigneeFullName",
"displayType": {
"type": "string",
"displayTypeParameters": {}
},
"sortable": true,
"defaultSort": null,
"order": 2
},
{
"title": "",
"key": "zaakstatus",
"path": "doc:openzaak.statusOmschrijving",
"displayType": {
"type": "string",
"displayTypeParameters": {}
},
"sortable": true,
"defaultSort": null,
"order": 3
}
]
Loading

0 comments on commit 029b2db

Please sign in to comment.