From 27de4ce63466eb071a9e3ea790f3c50b2128dcb9 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 9 Jan 2025 10:21:48 +0100 Subject: [PATCH 1/6] post new contact: process postalAddress --- .../hsadminng/hs/office/contact/HsOfficeContactController.java | 1 + .../hsadminng/hs/office/relation/HsOfficeRelationController.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java index 572a0ce8..3c506573 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java @@ -131,6 +131,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @SuppressWarnings("unchecked") final BiConsumer RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { + entity.putPostalAddress(from(resource.getPostalAddress())); entity.putEmailAddresses(from(resource.getEmailAddresses())); entity.putPhoneNumbers(from(resource.getPhoneNumbers())); }; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java index a4f17edf..1d1e69ae 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java @@ -185,6 +185,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @SuppressWarnings("unchecked") final BiConsumer CONTACT_RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { + entity.putPostalAddress(from(resource.getPostalAddress())); entity.putEmailAddresses(from(resource.getEmailAddresses())); entity.putPhoneNumbers(from(resource.getPhoneNumbers())); }; From 6a673c66d480a4c9eadb10c3f0e312da9b466760 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Mon, 13 Jan 2025 16:26:34 +0100 Subject: [PATCH 2/6] add view for list subscriptions --- .../9-hs-global/9130-integration-mlmmj.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql diff --git a/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql b/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql new file mode 100644 index 00000000..a7ab0d9e --- /dev/null +++ b/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql @@ -0,0 +1,14 @@ + +--liquibase formatted sql + +-- ============================================================================ +--changeset timotheus.pokorra:hs-global-integration-znuny endDelimiter:--// +CREATE OR REPLACE VIEW hs_integration.subscription AS + SELECT DISTINCT + relation.mark as subscription, + contact.emailaddresses->>'main' as email + FROM hs_office.contact AS contact + JOIN hs_office.relation AS relation ON relation.contactuuid = contact.uuid AND relation.type = 'SUBSCRIBER' + ORDER BY subscription, email; + +--// From d6edfa4dc7e5b0fa18bb8e16d031bf4e161c9e01 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 16 Jan 2025 08:36:30 +0100 Subject: [PATCH 3/6] add sql file for mlmmj integration view to db changelog --- src/main/resources/db/changelog/db.changelog-master.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index b97e3f2d..1f4e8ea0 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -176,4 +176,6 @@ databaseChangeLog: - include: file: db/changelog/9-hs-global/9110-integration-kimai.sql - include: - file: db/changelog/9-hs-global/9120-integration-znuny.sql \ No newline at end of file + file: db/changelog/9-hs-global/9120-integration-znuny.sql + - include: + file: db/changelog/9-hs-global/9130-integration-mlmmj.sql From 78cc729a97005959ef407f1da81868f02153229a Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 16 Jan 2025 08:54:19 +0100 Subject: [PATCH 4/6] improve test for adding contact with postal address --- .../HsOfficeContactControllerAcceptanceTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java index a4b19eef..1049fcf2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java @@ -110,6 +110,14 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu .body(""" { "caption": "Temp Contact", + "postalAddress": { + "name": "Herr Test Contact", + "firm": "Test Contact GmbH", + "street": "Am Schieferbruch 3", + "zipcode": "12345", + "city": "Dachstadt", + "country": "Germany" + }, "emailAddresses": { "main": "test@example.org" } @@ -124,6 +132,8 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu .body("uuid", isUuidValid()) .body("caption", is("Temp Contact")) .body("emailAddresses", is(Map.of("main", "test@example.org"))) + .body("postalAddress", hasEntry("name", "Herr Test Contact") + .body("postalAddress", hasEntry("street", "Am Schieferbruch 3") .header("Location", startsWith("http://localhost")) .extract().header("Location"); // @formatter:on From 15e94a1800153025b45cdabff3af89e2cf5cd0f9 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 16 Jan 2025 09:42:07 +0100 Subject: [PATCH 5/6] fix previous commit --- .../contact/HsOfficeContactControllerAcceptanceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java index 1049fcf2..bf22c77e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java @@ -132,8 +132,8 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu .body("uuid", isUuidValid()) .body("caption", is("Temp Contact")) .body("emailAddresses", is(Map.of("main", "test@example.org"))) - .body("postalAddress", hasEntry("name", "Herr Test Contact") - .body("postalAddress", hasEntry("street", "Am Schieferbruch 3") + .body("postalAddress", hasEntry("name", "Herr Test Contact")) + .body("postalAddress", hasEntry("street", "Am Schieferbruch 3")) .header("Location", startsWith("http://localhost")) .extract().header("Location"); // @formatter:on From a31159eb5b02a6e884558f77c34b751d2793f9ad Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 16 Jan 2025 09:47:08 +0100 Subject: [PATCH 6/6] improve Test for addRelation with postalAddress --- ...HsOfficeRelationControllerAcceptanceTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java index 0ed4b82f..8e33c35a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java @@ -18,13 +18,14 @@ import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.context.ActiveProfiles; import org.springframework.transaction.annotation.Transactional; +import java.util.Map; import java.util.UUID; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.startsWith; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.hasEntry; @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -291,6 +292,14 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean }, "contact": { "caption": "Temp Contact", + "postalAddress": { + "name": "Herr Test Contact", + "firm": "Test Contact GmbH", + "street": "Am Schieferbruch 3", + "zipcode": "12345", + "city": "Dachstadt", + "country": "Germany" + }, "emailAddresses": { "main": "test@example.org" } @@ -315,6 +324,9 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .body("holder.givenName", is("Temp")) .body("holder.familyName", is("Person")) .body("contact.caption", is("Temp Contact")) + .body("contact.emailAddresses", is(Map.of("main", "test@example.org"))) + .body("contact.postalAddress", hasEntry("name", "Herr Test Contact")) + .body("contact.postalAddress", hasEntry("street", "Am Schieferbruch 3")) .header("Location", startsWith("http://localhost")) .extract().header("Location"); // @formatter:on