Files
pi_mcps/java/mss-failsafe/.github/ai_context.instructions.md
Patrick Plate 1a0a56a626 chore(java): consolidate mss-failsafe to single canonical copy
Replace the stale multi-module java/mss-failsafe skeleton (old user-management
prototype) with the active single-module machine-safety inspection app that was
living in its own standalone repo at the repo root.

- Remove old java/mss-failsafe/ multi-module tree (mss, userdata, userManagement,
  mssfailsafe.datalayer, mssfailsafeWeblayer) incl. committed build artifacts
- Add the active app (PrimeFaces 11 / JSF 2.3 / Hibernate 5.6 / iText / POI)
  flattened into java/mss-failsafe/ as the only mss-failsafe in git
- Working tree captured = master tip 2a142b5 + in-progress uncommitted work
  (incl. .github/*.instructions.md AI-context files)
- Archive the standalone repo's 33-commit history in GIT_HISTORY_ARCHIVE.md
  since its .git was not migrated

This is the source of truth / base for the upcoming upgraded rewrite.
2026-06-13 19:55:28 +02:00

85 lines
2.8 KiB
Markdown
Executable File

# AI Context Instructions
## Essentials
- Base Classes: AbstractEntity, AbstractManager<T>, AbstractController<E>
- Fake ID Mechanismus für neue Objekte
- Hibernate.initialize für Lazy Collections
# Architecture Instructions
## Typical Generation Tasks
1. Neue Domain (Entity/Manager/Controller/XHTML)
2. PDF Utility Erweiterung (iText7)
3. Sammel-Speichern (saveAll) bereitstellen
4. Klon-Operationen (IDs null setzen, Collections duplizieren kontrolliert)
5. Fragebogen Zuordnung (add/remove, available list)
## Edge Cases
- Null Entities im save -> return false
- Negative IDs beim remove -> zuerst persistieren oder aus UI entfernen
- Concurrency Refresh: Nach batch Änderungen refreshSelected()
## Do / Don't
- DO: Logging bei jeder Exception
- DO: Konsistente Nutzung von @Transactional bei Schreiboperationen
- DON'T: System.out oder ungefangene Exceptions durchreichen ohne Logging
- DON'T: Business Logik direkt in XHTML Event Handler schreiben
## Upgrade Ideas
- Exception Layer
- Bean Validation
- Service Layer zwischen Controller und Manager falls Logik wächst
---
Aktualisiert: 2025-10-20
## Purpose
Verdichtete Architekturhinweise für automatische Code-Generierung und schnelle Orientierung.
## Stack
- Java EE 8 (javax), WAR
- JSF 2.3 + PrimeFaces 11 + PrimeFlex 2.0
- Hibernate JPA (Persistence Unit: pu_person)
- Log4j2
## Layer
1. View (XHTML)
2. Controller (JSF/CDI Beans, extends AbstractController<E>)
3. Business (Stateless EJB Manager, extends AbstractManager<T>)
4. Persistence (JPA Entities, extends AbstractEntity)
## Base Classes
- AbstractManager<T>: CRUD (save, saveAll, refresh, remove), flush nach Persist/Merge.
- AbstractController<E>: UI State (selected, created, entities), Messages, PDF Utilities, Fake-ID-Erzeugung.
## Entity Lifecycle UI
- Neue Objekte: erhalten negative Fake-ID
- Vor Persist: negative IDs -> null setzen
- save/saveAll entscheidet anhand id == null zwischen persist/merge
## Lazy Loading
- Refresh via AbstractManager.refresh(entity) + Hibernate.initialize(entity)
- Für Collections: dedizierte reload Methoden (z.B. SecurityAreaManager.reloadWithQuestionnaires)
## PDF
- iText7 bevorzugt; Altbestand iText5 (itextpdf 5.5.13) kann später entfernt werden.
## Logging & Fehler
- LOGGER.error(e) bei Fehlern
- Aktuell viele bool Rückgaben; Verbesserungspotential: BusinessException
## Erweiterung Pattern
Entity -> Manager -> Controller -> XHTML
## Schulden / Verbesserungen
- Mischung iText5/7
- Inkonsistente Fehlerbehandlung
- Kein DTO Layer
- Wenige Tests
## Empfehlungen für Generator
- Bestehende Signaturen unverändert lassen
- @Transactional nur bei Schreibmethoden hinzufügen
- Collections initialisieren bevor darauf iteriert wird
---
Aktualisiert: 2025-10-20