Klasse SellbackRepository

java.lang.Object
de.delinkedde.areashopreborn.persistence.SellbackRepository

public final class SellbackRepository extends Object
Persists sellback journals and their atomic ownership transition.
  • Konstruktordetails

    • SellbackRepository

      public SellbackRepository(Database database)
      Creates the sellback repository.
      Parameter:
      database - database connection provider
  • Methodendetails

    • findLatestPurchasePrice

      public Optional<BigDecimal> findLatestPurchasePrice(UUID regionId) throws SQLException
      Finds the gross amount of the most recent completed purchase for a region.
      Parameter:
      regionId - region identifier
      Gibt zurück:
      reference price when the parcel has purchase history
      Löst aus:
      SQLException - when the query fails
    • findNonTerminal

      public List<SellbackTransaction> findNonTerminal() throws SQLException
      Lists sellback journals whose cross-system workflow did not reach a terminal state.
      Gibt zurück:
      oldest incomplete sellbacks first
      Löst aus:
      SQLException - when the query fails
    • findNonTerminal

      public List<SellbackTransaction> findNonTerminal(int limit) throws SQLException
      Lists a bounded oldest-first batch of nonterminal sellback journals.
      Parameter:
      limit - maximum journals returned
      Gibt zurück:
      oldest nonterminal sellbacks first
      Löst aus:
      SQLException - when the query fails
    • insert

      public void insert(SellbackTransaction transaction) throws SQLException
      Creates a durable sellback journal before any economy mutation occurs.
      Parameter:
      transaction - journal snapshot
      Löst aus:
      SQLException - when insertion fails
    • reserve

      public boolean reserve(SellbackTransaction transaction) throws SQLException
      Atomically reserves seller ownership and creates the journal before Vault is touched.
      Parameter:
      transaction - prepared sellback journal
      Gibt zurück:
      true only when the seller still owns a sold parcel
      Löst aus:
      SQLException - when persistence fails
    • releaseReservation

      public void releaseReservation(SellbackTransaction transaction, TransactionState terminalState, String failureDetail) throws SQLException
      Atomically releases an uncommitted ownership reservation and closes its journal.
      Parameter:
      transaction - reserved transaction
      terminalState - FAILED or COMPENSATED
      failureDetail - bounded diagnostic detail
      Löst aus:
      SQLException - when either compare-and-set transition fails
    • persistOwnership

      public void persistOwnership(SellbackTransaction transaction) throws SQLException
      Atomically transfers a sold parcel, removes access grants, and advances its journal.
      Parameter:
      transaction - transaction to persist
      Löst aus:
      SQLException - when ownership changed concurrently or persistence fails
    • updateState

      public void updateState(UUID id, TransactionState state, String failureDetail) throws SQLException
      Updates a journal after completion, compensation, or a failure requiring review.
      Parameter:
      id - transaction identifier
      state - new durable state
      failureDetail - optional diagnostic detail
      Löst aus:
      SQLException - when the update fails
    • quarantine

      public void quarantine(UUID transactionId, UUID regionId, String failureDetail) throws SQLException
      Atomically quarantines an ambiguous sellback journal and its region.
      Parameter:
      transactionId - sellback journal identifier
      regionId - affected region identifier
      failureDetail - bounded diagnostic detail
      Löst aus:
      SQLException - when either required state transition cannot be persisted
    • resolvePayoutConfirmed

      public void resolvePayoutConfirmed(SellbackTransaction transaction, UUID administratorId, String evidence, Instant resolvedAt) throws SQLException
      Completes a quarantined sellback after an administrator verifies the external payout.
      Parameter:
      transaction - expected manual-review journal
      administratorId - resolving administrator
      evidence - external payout reference
      resolvedAt - resolution timestamp
      Löst aus:
      SQLException - when ownership or journal state changed concurrently
    • resolveRefundConfirmed

      public void resolveRefundConfirmed(SellbackTransaction transaction, UUID administratorId, String evidence, Instant resolvedAt) throws SQLException
      Restores a quarantined sellback after an administrator verifies the payout reversal.
      Parameter:
      transaction - expected manual-review journal
      administratorId - resolving administrator
      evidence - external refund reference
      resolvedAt - resolution timestamp
      Löst aus:
      SQLException - when seller ownership or journal state changed concurrently
    • findById

      public Optional<SellbackTransaction> findById(UUID id) throws SQLException
      Reads one sellback journal in its current durable state.
      Parameter:
      id - transaction identifier
      Gibt zurück:
      current transaction snapshot when present
      Löst aus:
      SQLException - when the query fails