From 41560d09f3b7dc6c9814699a626da7bade973538 Mon Sep 17 00:00:00 2001 From: Giuseppe Baittiner Date: Thu, 16 Mar 2023 12:30:17 +0100 Subject: [PATCH 1/8] feat(ts): Add system support --- .../ms/gtw/rulesmanager/dto/eds/data/SchematronDTO.java | 2 ++ .../gtw/rulesmanager/repository/entity/SchematronETY.java | 5 ++++- .../scheduler/entity/impl/SchematronQuery.java | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/dto/eds/data/SchematronDTO.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/dto/eds/data/SchematronDTO.java index 72f7d39..7b786d7 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/dto/eds/data/SchematronDTO.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/dto/eds/data/SchematronDTO.java @@ -34,6 +34,8 @@ public static class Schematron { @JsonProperty private String version; @JsonProperty + private String system; + @JsonProperty private String templateIdRoot; @JsonProperty private Date lastUpdateDate; diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/repository/entity/SchematronETY.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/repository/entity/SchematronETY.java index 55c66c6..243accd 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/repository/entity/SchematronETY.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/repository/entity/SchematronETY.java @@ -24,7 +24,8 @@ public class SchematronETY { public static final String FIELD_FILENAME = "name_schematron"; public static final String FIELD_CONTENT = "content_schematron"; public static final String FIELD_VERSION = "version"; - public static final String FIELD_ROOT = "template_id_root"; + public static final String FIELD_SYSTEM = "system"; + public static final String FIELD_ROOT = "template_id_root"; public static final String FIELD_LAST_UPDATE = "last_update_date"; public static final String FIELD_LAST_SYNC = "last_sync"; public static final String FIELD_DELETED = "deleted"; @@ -39,6 +40,8 @@ public class SchematronETY { private String templateIdRoot; @Field(name = FIELD_VERSION) private String version; + @Field(name = FIELD_SYSTEM) + private String system; @Field(name = FIELD_LAST_UPDATE) private Date lastUpdateDate; @Field(name = FIELD_LAST_SYNC) diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/scheduler/entity/impl/SchematronQuery.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/scheduler/entity/impl/SchematronQuery.java index c2f3ac3..c8bac0c 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/scheduler/entity/impl/SchematronQuery.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/scheduler/entity/impl/SchematronQuery.java @@ -26,14 +26,19 @@ public Document getUpsertQuery(SchematronDTO dto) { // Get data SchematronDTO.Schematron schematron = dto.getDocument(); // Create - return new org.bson.Document() + Document doc = new Document() .append(FIELD_ID, new ObjectId(schematron.getId())) .append(FIELD_FILENAME, schematron.getName()) .append(FIELD_CONTENT, new Binary(StringUtility.decodeBase64(schematron.getContent()))) .append(FIELD_VERSION, schematron.getVersion()) + .append(FIELD_SYSTEM, schematron.getSystem()) .append(FIELD_ROOT, schematron.getTemplateIdRoot()) .append(FIELD_LAST_UPDATE, schematron.getLastUpdateDate()) .append(FIELD_DELETED, false); + + if(schematron.getSystem() == null) doc.remove(FIELD_SYSTEM); + + return doc; } /** @@ -72,6 +77,7 @@ public Document getComparatorQuery(Document doc) { .append(FIELD_CONTENT, doc.get(FIELD_CONTENT, Binary.class)) .append(FIELD_VERSION, doc.getString(FIELD_VERSION)) .append(FIELD_ROOT, doc.getString(FIELD_ROOT)) + .append(FIELD_SYSTEM, doc.getString(FIELD_SYSTEM)) .append(FIELD_LAST_UPDATE, doc.getDate(FIELD_LAST_UPDATE)) .append(FIELD_LAST_SYNC, doc.getDate(FIELD_LAST_SYNC)) .append(FIELD_DELETED, doc.getBoolean(FIELD_DELETED)); From 7d3fcf562c88c145c19263bc1a830d171318567d Mon Sep 17 00:00:00 2001 From: Giuseppe Baittiner Date: Mon, 9 Oct 2023 15:10:56 +0200 Subject: [PATCH 2/8] fix: missing db_name props --- src/main/resources/application-docker.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties index 17ed8ee..03d18ed 100644 --- a/src/main/resources/application-docker.properties +++ b/src/main/resources/application-docker.properties @@ -5,6 +5,7 @@ management.server.port=8011 ### MONGODB ### data.mongodb.uri=mongodb://mongoadmin:secret@host.docker.internal:27888/fse +data.mongodb.schema-name=FSE_GTW ### EDS CLIENT (REST) ### eds.rest.secured=false From b2e7a83958810a89254476ca1980d699ba2ade90 Mon Sep 17 00:00:00 2001 From: Giuseppe Baittiner Date: Thu, 12 Oct 2023 16:13:23 +0200 Subject: [PATCH 3/8] feat(docker): add dictionary setup --- .../gtw/rulesmanager/config/DockerSetup.java | 82 ++++++++++++++----- 1 file changed, 61 insertions(+), 21 deletions(-) diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/config/DockerSetup.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/config/DockerSetup.java index c8ccf3a..583a007 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/config/DockerSetup.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/rulesmanager/config/DockerSetup.java @@ -1,44 +1,84 @@ package it.finanze.sanita.fse2.ms.gtw.rulesmanager.config; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.event.ApplicationStartedEvent; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.context.event.EventListener; - +import it.finanze.sanita.fse2.ms.gtw.rulesmanager.config.eds.changeset.impl.DictionaryCFG; import it.finanze.sanita.fse2.ms.gtw.rulesmanager.config.eds.changeset.impl.EngineCFG; import it.finanze.sanita.fse2.ms.gtw.rulesmanager.config.eds.changeset.impl.FhirStructuresCFG; +import it.finanze.sanita.fse2.ms.gtw.rulesmanager.config.eds.changeset.impl.TerminologyCFG; import it.finanze.sanita.fse2.ms.gtw.rulesmanager.exceptions.eds.EdsDbException; import it.finanze.sanita.fse2.ms.gtw.rulesmanager.repository.IExecutorRepo; +import it.finanze.sanita.fse2.ms.gtw.rulesmanager.scheduler.executors.impl.DictionaryExecutor; import it.finanze.sanita.fse2.ms.gtw.rulesmanager.scheduler.executors.impl.EnginesExecutor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.event.ApplicationStartedEvent; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.context.event.EventListener; -@Profile(value = Constants.Profile.DOCKER) +import static it.finanze.sanita.fse2.ms.gtw.rulesmanager.config.Constants.Profile.DOCKER; + +@Profile(value = DOCKER) @Configuration @Slf4j public class DockerSetup { + // Executors @Autowired - private EnginesExecutor engineExecutors; + private EnginesExecutor engineExecutor; @Autowired - private IExecutorRepo executorRepo; - + private DictionaryExecutor dictionaryExecutor; + + // Data-layer @Autowired - private FhirStructuresCFG fhirStructuresCFG; + private IExecutorRepo repository; + + // Configurations + @Autowired + private FhirStructuresCFG transforms; @Autowired - private EngineCFG engineCFG; + private EngineCFG engine; + + @Autowired + private DictionaryCFG dictionary; + @Autowired + private TerminologyCFG terminology; + @EventListener(value = ApplicationStartedEvent.class) - public void dockerInit() throws EdsDbException { - log.info("Docker init engines start"); - executorRepo.drop(engineCFG.getProduction()); - log.info("Delete collection engine production"); - executorRepo.clone(fhirStructuresCFG.getProduction(), fhirStructuresCFG.getStaging()); - engineExecutors.execute(); - executorRepo.drop(fhirStructuresCFG.getStaging()); - log.info("Delete collection transform-staging"); + public void init() throws EdsDbException { + log.info("[DOCKER] Setup has started"); + setupEngine(); + setupDictionary(); + log.info("[DOCKER] Setup has finished"); } - + + private void setupEngine() throws EdsDbException { + log.info("[DOCKER] Starting docker-routine to initialize engine"); + repository.drop(engine.getProduction()); + log.info("[DOCKER] Clean-up previous engines, if they exist"); + repository.clone(transforms.getProduction(), transforms.getStaging()); + log.info("[DOCKER] Spawning engine ..."); + engineExecutor.execute(); + log.info("[DOCKER] Engine spawned!"); + repository.drop(transforms.getStaging()); + repository.drop(engine.getBackup()); + log.info("[DOCKER] Cleaning-up"); + } + + private void setupDictionary() throws EdsDbException { + log.info("[DOCKER] Starting docker-routine to initialize dictionary"); + repository.drop(dictionary.getProduction()); + log.info("[DOCKER] Clean-up previous dictionaries, if they exist"); + repository.clone(terminology.getProduction(), terminology.getStaging()); + log.info("[DOCKER] Creating dictionaries ..."); + dictionaryExecutor.execute(); + log.info("[DOCKER] Dictionaries created!"); + repository.drop(terminology.getStaging()); + repository.drop(dictionary.getBackup()); + log.info("[DOCKER] Cleaning-up"); + } + + } From aacfd63c4196229d7360a1d57b72349da0c5f498 Mon Sep 17 00:00:00 2001 From: Giuseppe Baittiner Date: Fri, 13 Oct 2023 15:53:35 +0200 Subject: [PATCH 4/8] fix(docker): revise url --- src/main/resources/application-docker.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties index 03d18ed..ef56dc7 100644 --- a/src/main/resources/application-docker.properties +++ b/src/main/resources/application-docker.properties @@ -4,7 +4,7 @@ server.port=8011 management.server.port=8011 ### MONGODB ### -data.mongodb.uri=mongodb://mongoadmin:secret@host.docker.internal:27888/fse +data.mongodb.uri=mongodb://mongoadmin:secret@mongo:27888/fse data.mongodb.schema-name=FSE_GTW ### EDS CLIENT (REST) ### @@ -19,7 +19,7 @@ log.output.format=console log.level=trace log.kafka-log.enable=true kafka.log.base-topic=MDS-SA-0004_FU_001_LOG -kafka.bootstrap-servers=host.docker.internal:29092 +kafka.bootstrap-servers=kafka:29092 spring.sleuth.messaging.kafka.enabled=false kafka.properties.security.protocol=PLAINTEXT kafka.properties.sasl.mechanism=PLAINTEXT From 8c62683b4567edec6e6e0480d001bfdbf49e4823 Mon Sep 17 00:00:00 2001 From: Giuseppe Baittiner Date: Fri, 13 Oct 2023 17:01:50 +0200 Subject: [PATCH 5/8] fix: use private mongo port --- src/main/resources/application-docker.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties index ef56dc7..99f9dda 100644 --- a/src/main/resources/application-docker.properties +++ b/src/main/resources/application-docker.properties @@ -4,7 +4,7 @@ server.port=8011 management.server.port=8011 ### MONGODB ### -data.mongodb.uri=mongodb://mongoadmin:secret@mongo:27888/fse +data.mongodb.uri=mongodb://mongoadmin:secret@mongo:27017/fse data.mongodb.schema-name=FSE_GTW ### EDS CLIENT (REST) ### From 4af4f557ca9847d40325e0ad86c4c94104913a00 Mon Sep 17 00:00:00 2001 From: Giuseppe Baittiner Date: Mon, 16 Oct 2023 16:05:03 +0200 Subject: [PATCH 6/8] feat: update docker props --- .../resources/application-docker.properties | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties index 99f9dda..dcce550 100644 --- a/src/main/resources/application-docker.properties +++ b/src/main/resources/application-docker.properties @@ -4,7 +4,7 @@ server.port=8011 management.server.port=8011 ### MONGODB ### -data.mongodb.uri=mongodb://mongoadmin:secret@mongo:27017/fse +data.mongodb.uri=mongodb://mongoadmin:secret@mongo:27017 data.mongodb.schema-name=FSE_GTW ### EDS CLIENT (REST) ### @@ -29,17 +29,17 @@ kafka.properties.ssl.truststore.password=PLAINTEXT kafka.enablessl=false ### EDS CLIENT (CHANGESET) ### -eds.changeset.schema.status=http://host.docker.internal:9100/v1/changeset/schema/status -eds.changeset.schema.data=http://host.docker.internal:9100/v1/schema/id/ +eds.changeset.schema.status=http://it-fse-srv-syntax-rules-manager/v1/changeset/schema/status +eds.changeset.schema.data=http://it-fse-srv-syntax-rules-manager/v1/schema/id/ # Schematron -eds.changeset.schematron.status=http://host.docker.internal:9085/v1/changeset/schematron/status -eds.changeset.schematron.data=http://host.docker.internal:9085/v1/schematron/id/ +eds.changeset.schematron.status=http://it-fse-srv-semantic-rules-manager/v1/changeset/schematron/status +eds.changeset.schematron.data=http://it-fse-srv-semantic-rules-manager/v1/schematron/id/ # Fhir Structures -eds.changeset.fhir.status=http://host.docker.internal:9086/v1/changeset/transform/status -eds.changeset.fhir.data=http://host.docker.internal:9086/v1/transform/id/ +eds.changeset.fhir.status=http://it-fse-srv-fhir:9086/v1/changeset/transform/status +eds.changeset.fhir.data=http://it-fse-srv-fhir:9086/v1/transform/id/ # Terminology (Chunked) -eds.changeset.terminology.chunks.status=http://host.docker.internal:9088/v1/changeset/terminology/chunks -eds.changeset.terminology.chunks.ins=http://host.docker.internal:9088/v1/changeset/terminology/chunks/ins -eds.changeset.terminology.chunks.del=http://host.docker.internal:9088/v1/changeset/terminology/chunks/del +eds.changeset.terminology.chunks.status=http:/it-fse-srv-dictionary:9088/v1/changeset/terminology/chunks +eds.changeset.terminology.chunks.ins=http://it-fse-srv-dictionary:9088/v1/changeset/terminology/chunks/ins +eds.changeset.terminology.chunks.del=http://it-fse-srv-dictionary:9088/v1/changeset/terminology/chunks/del -ms.url.gtw-config=http://host.docker.internal:8018 \ No newline at end of file +ms.url.gtw-config=http://it-fse-gtw-config:8018 \ No newline at end of file From 2fc65477fc0c6d96e22a75ac2a2233b3862f9f1d Mon Sep 17 00:00:00 2001 From: Giuseppe Baittiner Date: Mon, 16 Oct 2023 18:01:16 +0200 Subject: [PATCH 7/8] fix(docker): typo --- src/main/resources/application-docker.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties index dcce550..3810b47 100644 --- a/src/main/resources/application-docker.properties +++ b/src/main/resources/application-docker.properties @@ -38,7 +38,7 @@ eds.changeset.schematron.data=http://it-fse-srv-semantic-rules-manager/v1/schema eds.changeset.fhir.status=http://it-fse-srv-fhir:9086/v1/changeset/transform/status eds.changeset.fhir.data=http://it-fse-srv-fhir:9086/v1/transform/id/ # Terminology (Chunked) -eds.changeset.terminology.chunks.status=http:/it-fse-srv-dictionary:9088/v1/changeset/terminology/chunks +eds.changeset.terminology.chunks.status=http://it-fse-srv-dictionary:9088/v1/changeset/terminology/chunks eds.changeset.terminology.chunks.ins=http://it-fse-srv-dictionary:9088/v1/changeset/terminology/chunks/ins eds.changeset.terminology.chunks.del=http://it-fse-srv-dictionary:9088/v1/changeset/terminology/chunks/del From 6ac9f55af22445df09c7ed6c3480dc4ad9fdf822 Mon Sep 17 00:00:00 2001 From: Giuseppe Baittiner Date: Mon, 16 Oct 2023 18:03:26 +0200 Subject: [PATCH 8/8] fix(docker): typo --- src/main/resources/application-docker.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties index 3810b47..a3849c0 100644 --- a/src/main/resources/application-docker.properties +++ b/src/main/resources/application-docker.properties @@ -29,11 +29,11 @@ kafka.properties.ssl.truststore.password=PLAINTEXT kafka.enablessl=false ### EDS CLIENT (CHANGESET) ### -eds.changeset.schema.status=http://it-fse-srv-syntax-rules-manager/v1/changeset/schema/status -eds.changeset.schema.data=http://it-fse-srv-syntax-rules-manager/v1/schema/id/ +eds.changeset.schema.status=http://it-fse-srv-syntax-rules-manager:9100/v1/changeset/schema/status +eds.changeset.schema.data=http://it-fse-srv-syntax-rules-manager:9100/v1/schema/id/ # Schematron -eds.changeset.schematron.status=http://it-fse-srv-semantic-rules-manager/v1/changeset/schematron/status -eds.changeset.schematron.data=http://it-fse-srv-semantic-rules-manager/v1/schematron/id/ +eds.changeset.schematron.status=http://it-fse-srv-semantic-rules-manager:9085/v1/changeset/schematron/status +eds.changeset.schematron.data=http://it-fse-srv-semantic-rules-manager:9085/v1/schematron/id/ # Fhir Structures eds.changeset.fhir.status=http://it-fse-srv-fhir:9086/v1/changeset/transform/status eds.changeset.fhir.data=http://it-fse-srv-fhir:9086/v1/transform/id/