Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sequences for generating zaak and document id #372

Merged
merged 6 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions docker_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mv ./src/main/resources/config.json_example ./src/main/resources/config.json

mvn install -Dmaven.javadoc.skip=true -B -V -DskipTests

sudo docker-compose -f docker-compose.yml up --build -d
sudo docker compose -f docker-compose.yml up --build -d

# start the counter from 5 seconds
timeCounter=5
Expand All @@ -30,4 +30,4 @@ else
echo "=== Something went wrong while starting the application check log files. ==="
exit 1
fi
sudo docker-compose logs
sudo docker compose logs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ public void load() throws ResponseStatusException {
@Override
public ResponseEntity<?> execute() throws ConverterException {
EmulateParameterRepository repository = SpringContext.getBean(EmulateParameterRepository.class);
var prefixparam = repository.getOne("DocumentIdentificatiePrefix");
var idparam = repository.getOne("DocumentIdentificatieHuidige");
var identificatie = Long.parseLong(idparam.getParameterValue()) + 1;
idparam.setParameterValue(Long.toString(identificatie));
repository.save(idparam);
var did = prefixparam.getParameterValue() + identificatie;
var identificatie = repository.getDocumentId();
var did = zaakService.getDocumentIdentificatiePrefix() + identificatie;
this.getSession().setFunctie("GenereerDocumentIdentificatie");
this.getSession().setKenmerk("documentidentificatie:" + did);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import nl.haarlem.translations.zdstozgw.translation.zds.services.ZaakService;
import nl.haarlem.translations.zdstozgw.utils.XmlUtils;


public class GenereerZaakIdentificatieEmulator extends Converter {

public GenereerZaakIdentificatieEmulator(RequestResponseCycle session, Translation translation,
Expand All @@ -50,14 +51,10 @@ zaakidentificatie, hiervoor gelden de volgende regels (genomen uit RGBZ):
1e 4 posities: gemeentecode van de gemeente die verantwoordelijk is voor de behandeling van de zaak;
pos. 5 – 40: alle alfanumerieke tekens m.u.v. diacrieten
*/

EmulateParameterRepository repository = SpringContext.getBean(EmulateParameterRepository.class);
var prefixparam = repository.getOne("ZaakIdentificatiePrefix");
var idparam = repository.getOne("ZaakIdentificatieHuidige");
var identificatie = Long.parseLong(idparam.getParameterValue()) + 1;
idparam.setParameterValue(Long.toString(identificatie));
repository.save(idparam);
var zid = prefixparam.getParameterValue() + identificatie;
var identificatie = repository.getZaakId();
var zid = zaakService.getZaakIdentificatiePrefix() + identificatie;
this.getSession().setFunctie("GenereerZaakIdentificatie");
this.getSession().setKenmerk("zaakidentificatie:" + zid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@
package nl.haarlem.translations.zdstozgw.jpa;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import nl.haarlem.translations.zdstozgw.jpa.model.EmulateParameter;

@Repository
public interface EmulateParameterRepository extends JpaRepository<EmulateParameter, String> {

@Query(value = "SELECT NEXTVAL('ZaakIdentificatieHuidige')", nativeQuery = true)
Long getZaakId();

@Query(value = "SELECT NEXTVAL('DocumentIdentificatieHuidige')", nativeQuery = true)
Long getDocumentId();

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import lombok.Getter;
import nl.haarlem.translations.zdstozgw.config.ConfigService;
import nl.haarlem.translations.zdstozgw.config.ModelMapperConfig;
import nl.haarlem.translations.zdstozgw.config.model.Organisatie;
Expand Down Expand Up @@ -82,6 +84,13 @@ public class ZaakService {
private final ModelMapper modelMapper;
public final ConfigService configService;

@Value("${id.generatie.documentIdentificatiePrefix:1900}")
private @Getter String documentIdentificatiePrefix;

@Value("${id.generatie.zaakIdentificatiePrefix:1900}")
private @Getter String zaakIdentificatiePrefix;


@Autowired
public ZaakService(ZGWClient zgwClient, ModelMapper modelMapper, ConfigService configService) {
this.zgwClient = zgwClient;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/data-h2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ INSERT INTO emulate_parameter (parameter_name, parameter_description, parameter_
SELECT 'DocumentIdentificatieHuidige', 'Het laatste volgnummer dat is gebruikt voor de documentidentificatie in nl.haarlem.translations.zdstozgw.convertor.impl.GenereerDocumentIdentificatie', '1'
WHERE ( SELECT COUNT(*) FROM emulate_parameter WHERE parameter_name = 'DocumentIdentificatieHuidige') = 0;

CREATE SEQUENCE IF NOT EXISTS ZaakIdentificatieHuidige START WITH 1 INCREMENT BY 1;
CREATE SEQUENCE IF NOT EXISTS DocumentIdentificatieHuidige START WITH 1 INCREMENT BY 1;
3 changes: 3 additions & 0 deletions src/main/resources/data-postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ INSERT INTO emulate_parameter (parameter_name, parameter_description, parameter_
SELECT 'DocumentIdentificatieHuidige', 'Het laatste volgnummer dat is gebruikt voor de documentidentificatie in nl.haarlem.translations.zdstozgw.convertor.impl.GenereerDocumentIdentificatie', '1'
WHERE ( SELECT COUNT(*) FROM emulate_parameter WHERE parameter_name = 'DocumentIdentificatieHuidige') = 0;

CREATE SEQUENCE IF NOT EXISTS ZaakIdentificatieHuidige START WITH 1 INCREMENT BY 1;
CREATE SEQUENCE IF NOT EXISTS DocumentIdentificatieHuidige START WITH 1 INCREMENT BY 1;

CREATE OR REPLACE FUNCTION tekstTussenTekst(zoektekst TEXT, voorTussen TEXT, naTussen TEXT) RETURNS TEXT AS $$
DECLARE
resultaat text;
Expand Down
Loading