Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright 2015-2026 Ritense BV, the Netherlands.
*
* Licensed under EUPL, Version 1.2 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.ritense.gzac

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.readValue
import com.ritense.authorization.AuthorizationContext.Companion.runWithoutAuthorization
import com.ritense.document.domain.impl.request.NewDocumentRequest
import com.ritense.document.repository.impl.JsonSchemaDocumentRepository
import com.ritense.processdocument.domain.impl.request.NewDocumentAndStartProcessRequest
import com.ritense.processdocument.service.ProcessDocumentService
import io.github.oshai.kotlinlogging.KotlinLogging
import org.springframework.core.io.Resource
import org.springframework.core.io.ResourceLoader
import org.springframework.core.io.support.ResourcePatternUtils
import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Component

/**
* Seeds a handful of `verhuizing` cases on the *source* version (1.0.0) at startup, so they can be
* migrated to 1.0.1 via the migration plans under `config/case/verhuizing/1-0-1/case-migration`.
* Idempotent: only seeds when no `verhuizing` documents exist yet, and never fails startup.
*/
@Component
class DemoDataService(
private val objectMapper: ObjectMapper,
private val processDocumentService: ProcessDocumentService,
private val resourceLoader: ResourceLoader,
private val jsonSchemaDocumentRepository: JsonSchemaDocumentRepository,
) {
fun deployVerhuizingDocuments() {
try {
runWithoutAuthorization {
val alreadySeeded = jsonSchemaDocumentRepository
.findCaseIdsByDocumentDefinitionName(DOCUMENT_DEFINITION_NAME, PageRequest.of(0, 1))
.hasContent()
if (alreadySeeded) {
return@runWithoutAuthorization
}

getDocumentFileList().forEach { resource ->
try {
val content = resource.inputStream.bufferedReader().use { it.readText() }
val documentData = objectMapper.readValue<ObjectNode>(content)

val newDocumentRequest = NewDocumentRequest(
DOCUMENT_DEFINITION_NAME,
CASE_DEFINITION_KEY,
SOURCE_VERSION_TAG,
documentData,
)
processDocumentService.newDocumentAndStartProcess(
NewDocumentAndStartProcessRequest(PROCESS_DEFINITION_KEY, newDocumentRequest),
)
} catch (e: Exception) {
logger.warn(e) { "Failed to seed verhuizing document '${resource.filename}'" }
}
}
logger.info { "Seeded verhuizing demo cases on version $SOURCE_VERSION_TAG" }
}
} catch (e: Exception) {
logger.warn(e) { "Failed to seed verhuizing demo data" }
}
}

private fun getDocumentFileList(): List<Resource> =
ResourcePatternUtils
.getResourcePatternResolver(resourceLoader)
.getResources("classpath*:data/verhuizing/documents/*.json")
.toList()

companion object {
private val logger = KotlinLogging.logger {}
private const val DOCUMENT_DEFINITION_NAME = "verhuizing"
private const val CASE_DEFINITION_KEY = "verhuizing"
private const val SOURCE_VERSION_TAG = "1.0.0"
private const val PROCESS_DEFINITION_KEY = "verhuizing"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.springframework.boot.runApplication
import org.springframework.core.env.Environment
import org.springframework.scheduling.annotation.EnableScheduling
import java.net.InetAddress
import org.springframework.beans.factory.getBean

@SpringBootApplication
@EnableScheduling
Expand Down Expand Up @@ -52,6 +53,7 @@ fun main(args: Array<String>) {
// Development-only demo data for the "Present images as thumbnails" (GH-289) feature.
// Runs after the context is fully initialised so the bezwaar case definition is deployed.
if (environment.activeProfiles.contains("dev")) {
applicationContext.getBean(BezwaarImageDemoDataService::class.java).deployBezwaarWithImages()
applicationContext.getBean<BezwaarImageDemoDataService>().deployBezwaarWithImages()
applicationContext.getBean<DemoDataService>()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_VerhuizingInspectie" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.28.0">
<bpmn:collaboration id="Collaboration_VerhuizingInspectie">
<bpmn:participant id="VerhuizingInspectieParticipant" name="Verhuizing inspectie" processRef="verhuizing-inspectie-process" />
</bpmn:collaboration>
<bpmn:process id="verhuizing-inspectie-process" name="Verhuizing inspectie proces" isExecutable="true" camunda:historyTimeToLive="180">
<bpmn:startEvent id="StartEvent" name="Start inspectie">
<bpmn:outgoing>Flow_Start_To_Voorbereiden</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:serviceTask id="VoorbereidenInspectieTask" name="Inspectie voorbereiden" camunda:expression="${execution.setVariable('inspectieVoorbereid', true)}">
<bpmn:incoming>Flow_Start_To_Voorbereiden</bpmn:incoming>
<bpmn:outgoing>Flow_Voorbereiden_To_Inspectie</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:userTask id="InspectieUitvoerenTask" name="Inspectie uitvoeren">
<bpmn:incoming>Flow_Voorbereiden_To_Inspectie</bpmn:incoming>
<bpmn:outgoing>Flow_Inspectie_To_ResolveAkkoord</bpmn:outgoing>
</bpmn:userTask>
<bpmn:serviceTask id="ResolveAkkoordTask" name="Bepaal akkoord" camunda:expression="${execution.setVariable('akkoord', valueResolverDelegateService.resolveValue(execution, 'doc:/akkoord'))}">
<bpmn:incoming>Flow_Inspectie_To_ResolveAkkoord</bpmn:incoming>
<bpmn:outgoing>Flow_ResolveAkkoord_To_Gateway</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:exclusiveGateway id="Gateway_Akkoord" name="Akkoord?" default="Flow_Gateway_To_Afkeuring">
<bpmn:incoming>Flow_ResolveAkkoord_To_Gateway</bpmn:incoming>
<bpmn:outgoing>Flow_Gateway_To_Goedkeuring</bpmn:outgoing>
<bpmn:outgoing>Flow_Gateway_To_Afkeuring</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:serviceTask id="RegistreerGoedkeuringTask" name="Registreer goedkeuring" camunda:expression="${valueResolverDelegateService.handleValue(execution, 'doc:/inspectieStatus', 'goedgekeurd')}">
<bpmn:incoming>Flow_Gateway_To_Goedkeuring</bpmn:incoming>
<bpmn:outgoing>Flow_Goedkeuring_To_Join</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="RegistreerAfkeuringTask" name="Registreer afkeuring" camunda:expression="${valueResolverDelegateService.handleValue(execution, 'doc:/inspectieStatus', 'afgekeurd')}">
<bpmn:incoming>Flow_Gateway_To_Afkeuring</bpmn:incoming>
<bpmn:outgoing>Flow_Afkeuring_To_Join</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:exclusiveGateway id="Gateway_Join">
<bpmn:incoming>Flow_Goedkeuring_To_Join</bpmn:incoming>
<bpmn:incoming>Flow_Afkeuring_To_Join</bpmn:incoming>
<bpmn:outgoing>Flow_Join_To_End</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:endEvent id="EndEvent" name="Inspectie afgerond">
<bpmn:incoming>Flow_Join_To_End</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_Start_To_Voorbereiden" sourceRef="StartEvent" targetRef="VoorbereidenInspectieTask" />
<bpmn:sequenceFlow id="Flow_Voorbereiden_To_Inspectie" sourceRef="VoorbereidenInspectieTask" targetRef="InspectieUitvoerenTask" />
<bpmn:sequenceFlow id="Flow_Inspectie_To_ResolveAkkoord" sourceRef="InspectieUitvoerenTask" targetRef="ResolveAkkoordTask" />
<bpmn:sequenceFlow id="Flow_ResolveAkkoord_To_Gateway" sourceRef="ResolveAkkoordTask" targetRef="Gateway_Akkoord" />
<bpmn:sequenceFlow id="Flow_Gateway_To_Goedkeuring" name="Ja" sourceRef="Gateway_Akkoord" targetRef="RegistreerGoedkeuringTask">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${akkoord == true}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="Flow_Gateway_To_Afkeuring" name="Nee" sourceRef="Gateway_Akkoord" targetRef="RegistreerAfkeuringTask" />
<bpmn:sequenceFlow id="Flow_Goedkeuring_To_Join" sourceRef="RegistreerGoedkeuringTask" targetRef="Gateway_Join" />
<bpmn:sequenceFlow id="Flow_Afkeuring_To_Join" sourceRef="RegistreerAfkeuringTask" targetRef="Gateway_Join" />
<bpmn:sequenceFlow id="Flow_Join_To_End" sourceRef="Gateway_Join" targetRef="EndEvent" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_VerhuizingInspectie">
<bpmndi:BPMNShape id="VerhuizingInspectieParticipant_di" bpmnElement="VerhuizingInspectieParticipant" isHorizontal="true">
<dc:Bounds x="160" y="60" width="1000" height="280" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="StartEvent_di" bpmnElement="StartEvent">
<dc:Bounds x="202" y="132" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="190" y="175" width="62" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="VoorbereidenInspectieTask_di" bpmnElement="VoorbereidenInspectieTask">
<dc:Bounds x="290" y="110" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="InspectieUitvoerenTask_di" bpmnElement="InspectieUitvoerenTask">
<dc:Bounds x="440" y="110" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ResolveAkkoordTask_di" bpmnElement="ResolveAkkoordTask">
<dc:Bounds x="590" y="110" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_Akkoord_di" bpmnElement="Gateway_Akkoord" isMarkerVisible="true">
<dc:Bounds x="745" y="125" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="752" y="101" width="46" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="RegistreerGoedkeuringTask_di" bpmnElement="RegistreerGoedkeuringTask">
<dc:Bounds x="850" y="110" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="RegistreerAfkeuringTask_di" bpmnElement="RegistreerAfkeuringTask">
<dc:Bounds x="850" y="240" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_Join_di" bpmnElement="Gateway_Join" isMarkerVisible="true">
<dc:Bounds x="1005" y="125" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_di" bpmnElement="EndEvent">
<dc:Bounds x="1102" y="132" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1082" y="175" width="78" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_Start_To_Voorbereiden_di" bpmnElement="Flow_Start_To_Voorbereiden">
<di:waypoint x="238" y="150" />
<di:waypoint x="290" y="150" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_Voorbereiden_To_Inspectie_di" bpmnElement="Flow_Voorbereiden_To_Inspectie">
<di:waypoint x="390" y="150" />
<di:waypoint x="440" y="150" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_Inspectie_To_ResolveAkkoord_di" bpmnElement="Flow_Inspectie_To_ResolveAkkoord">
<di:waypoint x="540" y="150" />
<di:waypoint x="590" y="150" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_ResolveAkkoord_To_Gateway_di" bpmnElement="Flow_ResolveAkkoord_To_Gateway">
<di:waypoint x="690" y="150" />
<di:waypoint x="745" y="150" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_Gateway_To_Goedkeuring_di" bpmnElement="Flow_Gateway_To_Goedkeuring">
<di:waypoint x="795" y="150" />
<di:waypoint x="850" y="150" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_Gateway_To_Afkeuring_di" bpmnElement="Flow_Gateway_To_Afkeuring">
<di:waypoint x="770" y="175" />
<di:waypoint x="770" y="280" />
<di:waypoint x="850" y="280" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_Goedkeuring_To_Join_di" bpmnElement="Flow_Goedkeuring_To_Join">
<di:waypoint x="950" y="150" />
<di:waypoint x="1005" y="150" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_Afkeuring_To_Join_di" bpmnElement="Flow_Afkeuring_To_Join">
<di:waypoint x="950" y="280" />
<di:waypoint x="1030" y="280" />
<di:waypoint x="1030" y="175" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_Join_To_End_di" bpmnElement="Flow_Join_To_End">
<di:waypoint x="1055" y="150" />
<di:waypoint x="1102" y="150" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"processDefinitionKey": "verhuizing-inspectie-process"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"key": "verhuizing-inspectie",
"name": "Verhuizing inspectie",
"description": "Woninginspectie die bij een verhuizing wordt uitgevoerd. Wordt tijdens migratie naar verhuizing 1.0.1 toegevoegd aan bestaande zaken.",
"versionTag": "1.0.0",
"final": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$id": "verhuizing-inspectie.schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Verhuizing Inspectie",
"type": "object",
"properties": {
"aanvragerNaam": {
"type": "string",
"description": "Naam van de aanvrager, overgenomen uit de zaak bij het toevoegen van het bouwblok"
},
"nieuwAdres": {
"type": "string",
"description": "Nieuw adres, overgenomen uit de zaak"
},
"inspectieStatus": {
"type": "string",
"description": "Status van de inspectie"
},
"inspecteur": {
"type": "string",
"description": "Toegewezen inspecteur"
},
"akkoord": {
"type": "boolean",
"description": "Of de inspectie akkoord is bevonden"
},
"aantalKamers": {
"type": "integer",
"description": "Aantal geïnspecteerde kamers"
},
"geschatteWaarde": {
"type": "number",
"description": "Geschatte waarde van de woning"
},
"inspectiedatum": {
"type": "string",
"format": "date",
"description": "Datum waarop de inspectie is uitgevoerd"
},
"bevindingen": {
"type": "array",
"items": {
"type": "string"
},
"description": "Lijst met bevindingen uit de inspectie"
}
}
}
Loading
Loading