From 924219a992ca9e57cd3db9adc24b46001584dd49 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 1 Oct 2024 10:57:49 +0200 Subject: [PATCH] remove completed flag from hs_booking.item_created_event --- .../hs/booking/item/BookingItemCreatedEventEntity.java | 8 -------- .../asset/factories/HsBookingItemCreatedListener.java | 8 ++++++-- .../630-booking-item/6300-hs-booking-item.sql | 3 +-- .../item/HsBookingItemControllerAcceptanceTest.java | 3 +-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventEntity.java index 03b39d88..4a97dddf 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventEntity.java @@ -43,14 +43,6 @@ public class BookingItemCreatedEventEntity { @Column(name = "statusmessage") private String statusMessage; - @Setter - @Column - private boolean completed; - - public void setBookingItem(HsBookingItemRealEntity bookingItem) { - this.bookingItem = bookingItem; - } - public BookingItemCreatedEventEntity( @NotNull final HsBookingItemRealEntity newBookingItem, final String assetJson) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/HsBookingItemCreatedListener.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/HsBookingItemCreatedListener.java index 3143c841..3f63c50f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/HsBookingItemCreatedListener.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/HsBookingItemCreatedListener.java @@ -33,8 +33,12 @@ public class HsBookingItemCreatedListener implements ApplicationListener new DomainSetupHostingAssetFactory(emw, newBookingItemRealEntity, asset, standardMapper); }; if (factory != null) { - event.getEntity().setStatusMessage(factory.performSaveProcess()); - emw.persist(event.getEntity()); // TODO.impl: once we implement retry, we might need merge + final var statusMessage = factory.performSaveProcess(); + // TODO.impl: once we implement retry, we need to amend this code (persist/merge/delete) + if (statusMessage != null) { + event.getEntity().setStatusMessage(statusMessage); + emw.persist(event.getEntity()); + } } } } diff --git a/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql b/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql index 5a3cc9d4..4c145652 100644 --- a/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql +++ b/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql @@ -40,8 +40,7 @@ create table if not exists hs_booking.item_created_event bookingItemUuid uuid unique references hs_booking.item (uuid), version int not null default 0, assetJson text, - statusMessage text, - completed boolean not null default false + statusMessage text ); --// diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index f7d616aa..db62357a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -264,8 +264,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup .map(HsHostingAsset::getParentAsset) .isEqualTo(domainSetupHostingAsset); final var event = bookingItemCreationEventRepo.findByBookingItem(newBookingItem); - assertThat(event.isCompleted()); - + assertThat(event).isNull(); } @Test