Skip to content

Commit 88c6620

Browse files
authored
Merge pull request #335 from nl-portal/feature/fix-dmn-flow-from-external
revert a part of the dmn changesm because it failed to map from source
2 parents e781a09 + 76f8633 commit 88c6620

File tree

8 files changed

+108
-24
lines changed

8 files changed

+108
-24
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ dokkaVersion=1.9.20
1414

1515
org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=2048m
1616
org.gradle.workers.max=10
17-
version=1.4.33-SNAPSHOT
17+
version=1.4.34-SNAPSHOT

product/src/main/kotlin/nl/nlportal/product/graphql/ProductQuery.kt

+31
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,37 @@ class ProductQuery(
173173
return Mapper.get().convertValue(result, object : TypeReference<List<ObjectNode>>() {})
174174
}
175175

176+
@GraphQLDescription(
177+
"""
178+
Get Decision by key and json as source
179+
Don't use it directly but via custom queries
180+
""",
181+
)
182+
suspend fun getDecision(
183+
sources: ObjectNode? = null,
184+
key: String,
185+
productTypeId: UUID? = null,
186+
productName: String,
187+
dmnVariables: ObjectNode? = null,
188+
): List<ObjectNode> {
189+
val result =
190+
dmnService.getDecision(
191+
sources = sources?.let { Mapper.get().convertValue(it, object : TypeReference<Map<String, String>>() {}) },
192+
key = key,
193+
productTypeId = productTypeId,
194+
productName = productName,
195+
dmnVariables =
196+
dmnVariables?.let {
197+
Mapper.get().convertValue(
198+
dmnVariables,
199+
object : TypeReference<Map<String, DmnVariable>>() {},
200+
)
201+
},
202+
)
203+
204+
return Mapper.get().convertValue(result, object : TypeReference<List<ObjectNode>>() {})
205+
}
206+
176207
@GraphQLDescription(
177208
"""
178209
Prefill data to start a form.

product/src/main/kotlin/nl/nlportal/product/service/DmnService.kt

+24-22
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ class DmnService(
9595
)
9696

9797
sources?.forEach {
98-
beslisTabelConfiguration.variabelen[it.key]?.let { variable ->
99-
{
100-
variablesMapping.putAll(
101-
mapBeslisTabelVariablesWithSource(
102-
variable,
103-
it.value,
104-
),
105-
)
106-
}
107-
} ?: logger.warn(BESLISTABLE_NOT_FOUND_BY_KEY, it.key)
98+
if (beslisTabelConfiguration.variabelen.containsKey(it.key)) {
99+
variablesMapping.putAll(
100+
mapBeslisTabelVariablesWithSource(
101+
beslisTabelConfiguration.variabelen[it.key]!!,
102+
it.value,
103+
),
104+
)
105+
} else {
106+
logger.warn(BESLISTABLE_NOT_FOUND_BY_KEY, it.key)
107+
}
108108
}
109109

110110
// handle the configured static variables
@@ -157,18 +157,20 @@ class DmnService(
157157

158158
// loop through the sources and get the Object as Json and map with the variables
159159
sources?.forEach {
160-
productService.getSourceAsJson(it.key, it.value)?.let { source ->
161-
beslisTabelVariables[it.key]?.let { variable ->
162-
{
163-
variablesMapping.putAll(
164-
mapBeslisTabelVariablesWithSource(
165-
variable,
166-
source,
167-
),
168-
)
169-
}
170-
} ?: logger.warn(BESLISTABLE_NOT_FOUND_BY_KEY, it.key)
171-
} ?: logger.warn("Could not find objects for key {} with uuid {}", it.key, it.value)
160+
val source = productService.getSourceAsJson(it.key, it.value)
161+
162+
if (source == null) {
163+
logger.warn("Could not find objects for key {} with uuid {}", it.key, it.value)
164+
} else {
165+
if (beslisTabelVariables.containsKey(it.key)) {
166+
variablesMapping.putAll(
167+
mapBeslisTabelVariablesWithSource(
168+
beslisTabelVariables[it.key]!!,
169+
source,
170+
),
171+
)
172+
}
173+
}
172174
}
173175

174176
// check if the beslisTabelVariables contains a producttype configuration,

product/src/test/kotlin/nl/nlportal/product/ProductTestConfiguration.kt

+11
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class ProductTestConfiguration {
6060
@Value("classpath:product/graphql/getProductDecision.graphql")
6161
private lateinit var getProductDecision: Resource
6262

63+
@Value("classpath:product/graphql/getDecision.graphql")
64+
private lateinit var getDecision: Resource
65+
6366
@Bean
6467
fun graphqlGetProducten(): String {
6568
return StreamUtils.copyToString(
@@ -155,4 +158,12 @@ class ProductTestConfiguration {
155158
StandardCharsets.UTF_8,
156159
)
157160
}
161+
162+
@Bean
163+
fun graphqlGetDecision(): String {
164+
return StreamUtils.copyToString(
165+
getDecision.inputStream,
166+
StandardCharsets.UTF_8,
167+
)
168+
}
158169
}

product/src/test/kotlin/nl/nlportal/product/graphql/ProductQueryIT.kt

+18
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ internal class ProductQueryIT(
6161
@Autowired private val graphqlGetProductType: String,
6262
@Autowired private val graphqlGetProductTypes: String,
6363
@Autowired private val graphqlGetProductDecision: String,
64+
@Autowired private val graphqlGetDecision: String,
6465
@Autowired private val graphqlProductPrefill: String,
6566
) {
6667
companion object {
@@ -324,6 +325,23 @@ internal class ProductQueryIT(
324325
).isEqualTo("https://formulier.denhaag.nl/Tripleforms/formulier/nl-NL/DefaultEnvironment/scNaheffingsAanslagParkeren.aspx")
325326
}
326327

328+
@Test
329+
@WithBurgerUser("569312864")
330+
fun getDescisionTest() {
331+
val basePath = "$.data.getDecision"
332+
333+
testClient.post()
334+
.uri("/graphql")
335+
.accept(MediaType.APPLICATION_JSON)
336+
.contentType(MediaType("application", "graphql"))
337+
.bodyValue(graphqlGetDecision)
338+
.exchange()
339+
.verifyOnlyDataExists(basePath)
340+
.jsonPath(
341+
"$basePath[0].action.value",
342+
).isEqualTo("https://formulier.denhaag.nl/Tripleforms/formulier/nl-NL/DefaultEnvironment/scNaheffingsAanslagParkeren.aspx")
343+
}
344+
327345
@Test
328346
@WithBurgerUser("569312863")
329347
fun productPrefillTestBurger() {

product/src/test/resources/product/data/get-product-type.json

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@
5858
"classType":"Integer"
5959
}
6060
],
61+
"belastingzakenaanslag": [
62+
{
63+
"name":"jaar",
64+
"classType":"Double",
65+
"regex":"$.aanslagBiljet.belastingjaar"
66+
},
67+
{
68+
"name":"saldo",
69+
"classType":"Double",
70+
"regex":"$.aanslagBiljetTotaal"
71+
}
72+
],
6173
"static": [
6274
{
6375
"name":"formulieren",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
query {
2+
getDecision(
3+
sources: {
4+
belastingzakenaanslag:"{aanslagBiljetTotaal: 79.3}",
5+
},
6+
key: "watkanikregelen",
7+
productTypeId: "7d9cd6c2-8147-46f2-9ae9-c67e8213c200",
8+
productName: "erfpacht"
9+
)
10+
}

product/src/test/resources/product/graphql/getProductDecision.graphql

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ query {
22
getProductDecision(
33
sources: {
44
product:"2d725c07-2f26-4705-8637-438a42b5ac2d",
5-
productverbruiksobject: "2d725c07-2f26-4705-8637-438a42b5a800"
5+
productverbruiksobject: "2d725c07-2f26-4705-8637-438a42b5a800",
66
},
77
key: "watkanikregelen",
88
productTypeId: "7d9cd6c2-8147-46f2-9ae9-c67e8213c200",

0 commit comments

Comments
 (0)