feat(lesereisen): data model + Flyway migration — GeschichteType, JourneyItem, migrate geschichten_documents #787

Open
marcel wants to merge 172 commits from feat/issue-750-lesereisen-data-model into main
3 changed files with 10 additions and 9 deletions
Showing only changes of commit 598ad622e7 - Show all commits

View File

@@ -86,7 +86,8 @@ backend/src/main/java/org/raddatz/familienarchiv/
│ └── transcription/ TranscriptionBlock, TranscriptionService, TranscriptionBlockQueryService
├── exception/ DomainException, ErrorCode, GlobalExceptionHandler
├── filestorage/ FileService (S3/MinIO)
├── geschichte/ Geschichte (story) domain
├── geschichte/ Geschichte (story) domain — GeschichteService, GeschichteQueryService
│ └── journeyitem/ JourneyItem sub-domain — JourneyItemService, JourneyItemController
├── importing/ CanonicalImportOrchestrator + four loaders (TagTree/PersonRegister/PersonTree/Document) + CanonicalSheetReader
├── notification/ Notification domain + SseEmitterRegistry
├── ocr/ OCR domain — OcrService, OcrBatchService, training

View File

@@ -47,14 +47,14 @@ public class JourneyItemService {
"Journey not found: " + geschichteId));
if (g.getType() != GeschichteType.JOURNEY) {
throw DomainException.badRequest(ErrorCode.VALIDATION_ERROR,
"Geschichte is not a JOURNEY — cannot append items");
throw DomainException.conflict(ErrorCode.GESCHICHTE_TYPE_MISMATCH,
"Journey items can only be added to a JOURNEY-type Geschichte");
}
long count = journeyItemRepository.countByGeschichteId(geschichteId);
if (count >= MAX_ITEMS) {
throw DomainException.badRequest(ErrorCode.VALIDATION_ERROR,
"Journey already has the maximum of " + MAX_ITEMS + " items");
throw DomainException.conflict(ErrorCode.JOURNEY_AT_CAPACITY,
"Journey has reached the maximum of 100 items");
}
String note = normalizeNote(dto.getNote());

View File

@@ -221,7 +221,7 @@ class JourneyItemServiceTest {
}
@Test
void append_returns400_on_non_JOURNEY_type() {
void append_returns409_on_non_JOURNEY_type() {
Geschichte story = Geschichte.builder()
.id(geschichteId)
.title("Story")
@@ -236,7 +236,7 @@ class JourneyItemServiceTest {
assertThatThrownBy(() -> journeyItemService.append(geschichteId, dto))
.isInstanceOf(DomainException.class)
.satisfies(e -> assertThat(((DomainException) e).getCode())
.isEqualTo(ErrorCode.VALIDATION_ERROR));
.isEqualTo(ErrorCode.GESCHICHTE_TYPE_MISMATCH));
}
@Test
@@ -257,7 +257,7 @@ class JourneyItemServiceTest {
}
@Test
void append_returns400_when_100_items_exist() {
void append_returns409_when_100_items_exist() {
Geschichte journey = journey(geschichteId);
when(geschichteRepository.findById(geschichteId)).thenReturn(Optional.of(journey));
when(journeyItemRepository.countByGeschichteId(geschichteId)).thenReturn(100L);
@@ -268,7 +268,7 @@ class JourneyItemServiceTest {
assertThatThrownBy(() -> journeyItemService.append(geschichteId, dto))
.isInstanceOf(DomainException.class)
.satisfies(e -> assertThat(((DomainException) e).getCode())
.isEqualTo(ErrorCode.VALIDATION_ERROR));
.isEqualTo(ErrorCode.JOURNEY_AT_CAPACITY));
}
@Test