Skip to content

Commit

Permalink
Improve replication (#288)
Browse files Browse the repository at this point in the history
* fix tests

* use h2 db while running unit tests

* use db vendor specific db files

* bugfix

* fixed utf-8 error

* bugfix for not utf-8 characters in string

* adding configuration for #284

* - dont add multiple end-statusses

* update test configuration

Co-authored-by: alisihab <sihab.akcan@gmail.com>
  • Loading branch information
EduardWitteveen and alisihab committed Dec 15, 2021
1 parent 644d8e0 commit 4afdbfb
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.google.gson.Gson;

import lombok.Data;
import nl.haarlem.translations.zdstozgw.config.model.BeeindigZaakWanneerEinddatum;
import nl.haarlem.translations.zdstozgw.config.model.ZaaktypeMetCoalesceResultaat;
import nl.haarlem.translations.zdstozgw.config.model.Configuration;
import nl.haarlem.translations.zdstozgw.config.model.Organisatie;
import nl.haarlem.translations.zdstozgw.config.model.Translation;
Expand Down Expand Up @@ -85,11 +85,18 @@ private void validateConfiguration() throws Exception {

section = "beeindigZaakWanneerEinddatum";
log.debug("=== " + section + " #" + this.configuration.getBeeindigZaakWanneerEinddatum().size() + " ===");
for (BeeindigZaakWanneerEinddatum beeindigZaakWanneerEinddatum : this.configuration.getBeeindigZaakWanneerEinddatum()) {
for (ZaaktypeMetCoalesceResultaat beeindigZaakWanneerEinddatum : this.configuration.getBeeindigZaakWanneerEinddatum()) {
log.debug("\t===>\tzaakType:" + beeindigZaakWanneerEinddatum.getZaakType());
log.debug("\t\tcoalesceResultaat:" + beeindigZaakWanneerEinddatum.getCoalesceResultaat());
}

section = "einddatumEnResultaatWanneerLastStatus";
log.debug("=== " + section + " #" + this.configuration.getEinddatumEnResultaatWanneerLastStatus().size() + " ===");
for (ZaaktypeMetCoalesceResultaat beeindigZaakWanneerEinddatum : this.configuration.getEinddatumEnResultaatWanneerLastStatus()) {
log.debug("\t===>\tzaakType:" + beeindigZaakWanneerEinddatum.getZaakType());
log.debug("\t\tcoalesceResultaat:" + beeindigZaakWanneerEinddatum.getCoalesceResultaat());
}

section = "replicatie";
log.debug("=== " + section + " ===");
var replicatie = this.configuration.getReplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class Configuration {
@Expose
public ZgwRolOmschrijving zgwRolOmschrijving = null;
@Expose
public List<BeeindigZaakWanneerEinddatum> beeindigZaakWanneerEinddatum = null;
public List<ZaaktypeMetCoalesceResultaat> beeindigZaakWanneerEinddatum = null;
@Expose
public List<ZaaktypeMetCoalesceResultaat> einddatumEnResultaatWanneerLastStatus = null;
@Expose
public Replication replication = null;
@Expose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import lombok.Data;

@Data
public class BeeindigZaakWanneerEinddatum {
public class ZaaktypeMetCoalesceResultaat {
@Expose
public String zaakType;
@Expose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package nl.haarlem.translations.zdstozgw.converter.impl.replicate;

import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -102,9 +103,12 @@ private ZdsZaak getLegacyZaak(String zaakidentificatie) {
var zdsResponse = this.zdsClient.post(this.converter.getSession().getReferentienummer(), zdsUrl, zdsSoapAction, zdsRequest);

// fetch the zaak details
log.debug("GeefZaakDetails response:" + zdsResponse);
ZdsZakLa01GeefZaakDetails zakLa01 = (ZdsZakLa01GeefZaakDetails) XmlUtils.getStUFObject(zdsResponse.getBody().toString(), ZdsZakLa01GeefZaakDetails.class);
return zakLa01.antwoord.zaak.get(0);
String rawResponse = zdsResponse.getBody().toString();
byte[] bytes = rawResponse.getBytes();
var response = new String(bytes, StandardCharsets.UTF_8);
log.debug("GeefZaakDetails response:" + response);
ZdsZakLa01GeefZaakDetails zakLa01 = (ZdsZakLa01GeefZaakDetails) XmlUtils.getStUFObject(response, ZdsZakLa01GeefZaakDetails.class);
return zakLa01.antwoord.zaak.get(0);
}

private void createZaak(ZdsZaak zdsZaak, String rsin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ public boolean setResultaatAndStatus(ZdsZaak zdsZaak, ZgwZaak zgwZaak, ZgwZaakTy
zgwStatus.zaak = zgwZaak.url;
zgwStatus.statustype = zgwStatusType.url;
zgwStatus.statustoelichting = zgwStatusType.omschrijving;

String zdsStatusDatum = zdsHeeftIterator.getDatumStatusGezet();

if("true".equals(zgwStatusType.getIsEindstatus())) {
// Difference between ZDS --> ZGW the behaviour of ending a zaak has changed.
// (more info at: https://vng-realisatie.github.io/gemma-zaken/standaard/zaken/index#zrc-007 )
Expand All @@ -433,6 +433,7 @@ public boolean setResultaatAndStatus(ZdsZaak zdsZaak, ZgwZaak zgwZaak, ZgwZaakTy
beeindigd = true;
}
zgwStatus.setDatumStatusGezet(convertZdsStatusDatumtoZgwDateTime(zgwZaak, zdsStatusDatum));

// check if the status doesnt exist yet
var statusexists = false;
for(ZgwStatus s : statussen) {
Expand All @@ -446,6 +447,11 @@ public boolean setResultaatAndStatus(ZdsZaak zdsZaak, ZgwZaak zgwZaak, ZgwZaakTy
// already exist
statusexists = true;
}
else if(beeindigd && s.statustype.equals(zgwZaakType.url)) {
// laatste status hoeft ook maar één keer
// TODO: dit moet toch slimmer kunnen?
statusexists = true;
}
}
if(!statusexists) {
this.zgwClient.addZaakStatus(zgwStatus);
Expand Down Expand Up @@ -490,6 +496,42 @@ public boolean setResultaatAndStatus(ZdsZaak zdsZaak, ZgwZaak zgwZaak, ZgwZaakTy
}
}
}

// einddatumEnResultaatWanneerLastStatus logica
/*
if(zdsZaak.einddatum != null && zdsZaak.einddatum.length() > 0 && !beeindigd) {
for(var beeindig : this.configService.getConfiguration().getBeeindigZaakWanneerEinddatum() ) {
if(beeindig.zaakType.equals(zgwZaakType.getIdentificatie())) {
// is the result also missing?
var resultaten = this.zgwClient.getResultatenByZaakUrl(zgwZaak.url);
if(resultaten.size() == 0) {
var zgwResultaatType = this.zgwClient.getResultaatTypeByZaakTypeAndOmschrijving(zgwZaakType, beeindig.coalesceResultaat);
if(zgwResultaatType == null) {
throw new ConverterException("Resultaattype: '" + beeindig.coalesceResultaat + "' niet gevonden bij Zaaktype:'" + zgwZaakType.identificatie + "'");
}
ZgwResultaat zgwResultaat = new ZgwResultaat();
zgwResultaat.zaak = zgwZaak.url;
zgwResultaat.resultaattype = zgwResultaatType.url;
zgwResultaat.toelichting = zgwResultaatType.omschrijving;
debugWarning("BeeindigZaakWanneerEinddatum was defined for zaaktype:'" + zgwZaakType.identificatie + "' and an einddatum was provided, no resultaat, zaak will get resultaat:'" + zgwResultaatType.getOmschrijving() + "'");
this.zgwClient.addZaakResultaat(zgwResultaat);
}
var zgwStatusType = this.zgwClient.getLastStatusTypeByZaakType(zgwZaakType);
ZgwStatus zgwStatus = new ZgwStatus();
zgwStatus.zaak = zgwZaak.url;
zgwStatus.statustype = zgwStatusType.url;
zgwStatus.statustoelichting = zgwStatusType.omschrijving;
zgwStatus.setDatumStatusGezet(convertZdsStatusDatumtoZgwDateTime(zgwZaak, zdsZaak.einddatum));
debugWarning("BeeindigZaakWanneerEinddatum was defined for zaaktype:'" + zgwZaakType.identificatie + "' and an einddatum was provided, no eindstatus, zaak will get status:'" + zgwStatusType.getOmschrijving() + "' with time:" + zgwStatus.getDatumStatusGezet());
this.zgwClient.addZaakStatus(zgwStatus);
beeindigd = true;
changed = true;
}
}
}
*/

return changed;
}

Expand Down Expand Up @@ -1162,4 +1204,4 @@ private void debugWarning(String message) {
log.info("[processing warning] " + message);
debug.infopoint("Warning", message);
}
}
}
6 changes: 6 additions & 0 deletions src/main/resources/config.json_example
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
"coalesceResultaat":"Onbekend"
}
],
"einddatumEnResultaatWanneerLastStatus": [
{
"zaakType": "B9999",
"coalesceResultaat": "Onbekend"
}
],
"replication": {
"geefZaakdetails": {
"soapaction": "http://www.egem.nl/StUF/sector/zkn/0310/geefZaakdetails_Lv01",
Expand Down
8 changes: 7 additions & 1 deletion src/test/resources/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@
"soapaction" : "http://www.egem.nl/StUF/sector/zkn/0310/geefZaakdocumentLezen_Lv01",
"url" : "http://localhost:8181/zds/BeantwoordVraag"
}
},
},
"einddatumEnResultaatWanneerLastStatus": [
{
"zaakType": "B9999",
"coalesceResultaat": "Onbekend"
}
],
"translations": [
{
"translation": "Translate ZDS 1.1 Generic genereerZaakIdentificatie_Di02",
Expand Down

0 comments on commit 4afdbfb

Please sign in to comment.