-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: zaak geometry should not be deleted on zaak update (#2588)
Fixed issue where zaak geometry was deleted on every zaak update and fixed issue where zaak geometry update and deletions sometimes worked and sometimes did not. The issue was that for deletions a @JsonbNillable annotation was used on the Zaak object in the ZrcClient but for normal updates not. However this annotation is static and there is only one zaak patch method in the ZrcClient and this resulted in inconsistent behaviour. This was solved by introducing a custom JSONB serializer for the zaak Geometry class that dynamically either writes a null (for deletions) or the geometry (Point only for now) object to JSON. Solves PZ-5299 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Hristo Iliev <[email protected]>
- Loading branch information
1 parent
c4c179e
commit d5f471d
Showing
13 changed files
with
296 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/net/atos/client/zgw/zrc/model/GeometryToBeDeleted.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2025 Lifely | ||
* SPDX-License-Identifier: EUPL-1.2+ | ||
*/ | ||
|
||
package net.atos.client.zgw.zrc.model | ||
|
||
/** | ||
* Geometry class to indicate that the current geometry should be deleted. | ||
* Used to mark a geometry field for deletion in the ZGW ZRC API using | ||
* the [nl.info.client.zgw.zrc.jsonb.GeometryJsonbSerializer]. | ||
*/ | ||
class GeometryToBeDeleted : Geometry { | ||
constructor() { setMarkGeometryForDeletion() } | ||
|
||
override fun toString() = "Not implemented" | ||
} |
26 changes: 0 additions & 26 deletions
26
src/main/java/net/atos/client/zgw/zrc/model/LocatieZaakPatch.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/kotlin/nl/info/client/zgw/zrc/jsonb/GeometryJsonbSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2025 Lifely | ||
* SPDX-License-Identifier: EUPL-1.2+ | ||
*/ | ||
package nl.info.client.zgw.zrc.jsonb | ||
|
||
import jakarta.json.bind.serializer.JsonbSerializer | ||
import jakarta.json.bind.serializer.SerializationContext | ||
import jakarta.json.stream.JsonGenerator | ||
import net.atos.client.zgw.shared.util.JsonbUtil | ||
import net.atos.client.zgw.zrc.model.Geometry | ||
import net.atos.client.zgw.zrc.model.GeometryType | ||
import net.atos.client.zgw.zrc.model.Point | ||
|
||
/** | ||
* Custom JSONB serializer for [Geometry] objects. | ||
* If [Geometry.markGeometryForDeletion] is set to true a null value is written | ||
* to indicate that the geometry field should be deleted, as per the ZGW ZRC API specification. | ||
*/ | ||
class GeometryJsonbSerializer : JsonbSerializer<Geometry> { | ||
|
||
override fun serialize( | ||
geometry: Geometry, | ||
jsonGenerator: JsonGenerator, | ||
ctx: SerializationContext | ||
) { | ||
if (geometry.markGeometryForDeletion) { | ||
jsonGenerator.writeNull() | ||
} else { | ||
when (geometry.type) { | ||
GeometryType.POINT -> jsonGenerator.write(JsonbUtil.JSONB.toJson(geometry, Point::class.java)) | ||
GeometryType.POLYGON -> throw IllegalArgumentException( | ||
"Polygon serialization is not implemented" | ||
) | ||
GeometryType.GEOMETRYCOLLECTION -> throw IllegalArgumentException( | ||
"GeometryCollection serialization is not implemented" | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.