Klasse RegionGroupRepository

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

public final class RegionGroupRepository extends Object
Persists named region groups and their many-to-many region assignments.
  • Konstruktordetails

    • RegionGroupRepository

      public RegionGroupRepository(Database database)
      Creates the group repository.
      Parameter:
      database - SQLite connection provider
  • Methodendetails

    • insert

      public void insert(RegionGroup group) throws SQLException
      Inserts a new named group.
      Parameter:
      group - group to create
      Löst aus:
      SQLException - when the name already exists or insertion fails
    • insert

      public boolean insert(RegionGroup group, int maximumGroups) throws SQLException
      Inserts a group only while the global group ceiling has not been reached.
      Parameter:
      group - group to create
      maximumGroups - maximum persistent groups
      Gibt zurück:
      whether the group was inserted
      Löst aus:
      SQLException - when insertion fails
    • insertAudited

      public boolean insertAudited(RegionGroup group, int maximumGroups) throws SQLException
      Atomically creates a group and its immutable audit entry.
      Parameter:
      group - group to create
      maximumGroups - maximum persistent groups
      Gibt zurück:
      whether both records were committed
      Löst aus:
      SQLException - when either write fails
    • find

      public Optional<RegionGroup> find(String name) throws SQLException
      Finds a group by command name.
      Parameter:
      name - case-insensitive group name
      Gibt zurück:
      matching group when present
      Löst aus:
      SQLException - when the query fails
    • findAll

      public List<RegionGroup> findAll() throws SQLException
      Lists all groups by stable name.
      Gibt zurück:
      immutable group list
      Löst aus:
      SQLException - when the query fails
    • findAll

      public List<RegionGroup> findAll(int limit) throws SQLException
      Lists a bounded prefix of groups by stable name.
      Parameter:
      limit - maximum groups returned
      Gibt zurück:
      immutable group list
      Löst aus:
      SQLException - when the query fails
    • findNames

      public List<String> findNames(int limit) throws SQLException
      Loads only the lightweight names required by command completion.
      Parameter:
      limit - maximum number of names to return
      Gibt zurück:
      immutable names ordered case-insensitively
      Löst aus:
      SQLException - when the query fails
    • delete

      public boolean delete(UUID groupId) throws SQLException
      Deletes a group and its assignments.
      Parameter:
      groupId - group identifier
      Gibt zurück:
      whether a group was removed
      Löst aus:
      SQLException - when deletion fails
    • deleteAudited

      public boolean deleteAudited(RegionGroup group, UUID actorId) throws SQLException
      Atomically deletes a group, cascades assignments, and records the deletion.
      Parameter:
      group - group snapshot to delete
      actorId - administrator performing the deletion
      Gibt zurück:
      whether both deletion and audit were committed
      Löst aus:
      SQLException - when either write fails
    • assign

      public boolean assign(UUID groupId, UUID regionId, UUID actorId) throws SQLException
      Assigns a region to a group idempotently.
      Parameter:
      groupId - group identifier
      regionId - region identifier
      actorId - assigning administrator
      Gibt zurück:
      whether a new assignment was created
      Löst aus:
      SQLException - when insertion fails
    • assign

      public boolean assign(UUID groupId, UUID regionId, UUID actorId, int maximumAssignments) throws SQLException
      Assigns a region only while its direct assignment ceiling has not been reached.

      The count predicate and insert are one SQLite statement, so concurrent callers cannot both pass a separate preflight count and exceed the limit.

      Parameter:
      groupId - group identifier
      regionId - region identifier
      actorId - assigning administrator
      maximumAssignments - maximum direct groups on one region
      Gibt zurück:
      whether a new assignment was created
      Löst aus:
      SQLException - when insertion fails
    • isAssigned

      public boolean isAssigned(UUID groupId, UUID regionId) throws SQLException
      Tests an exact assignment without loading group rows.
      Parameter:
      groupId - group identifier
      regionId - region identifier
      Gibt zurück:
      whether the assignment exists
      Löst aus:
      SQLException - when the query fails
    • changeAssignmentAudited

      public RegionGroupRepository.AssignmentResult changeAssignmentAudited(RegionGroup group, EstateRegion region, UUID actorId, boolean assigning, int maximumAssignments) throws SQLException
      Atomically changes one assignment and appends its audit record.
      Parameter:
      group - group snapshot
      region - region snapshot
      actorId - administrator performing the change
      assigning - whether to assign rather than unassign
      maximumAssignments - maximum direct groups on one region
      Gibt zurück:
      precise mutation outcome
      Löst aus:
      SQLException - when mutation or audit persistence fails
    • unassign

      public boolean unassign(UUID groupId, UUID regionId) throws SQLException
      Removes one region assignment.
      Parameter:
      groupId - group identifier
      regionId - region identifier
      Gibt zurück:
      whether an assignment was removed
      Löst aus:
      SQLException - when deletion fails
    • findRegions

      public List<EstateRegion> findRegions(UUID groupId) throws SQLException
      Lists regions directly assigned to a group.
      Parameter:
      groupId - group identifier
      Gibt zurück:
      immutable region list
      Löst aus:
      SQLException - when the query fails
    • findRegions

      public List<EstateRegion> findRegions(UUID groupId, int limit) throws SQLException
      Lists a bounded prefix of regions directly assigned to a group.
      Parameter:
      groupId - group identifier
      limit - maximum regions returned
      Gibt zurück:
      immutable region list
      Löst aus:
      SQLException - when the query fails
    • findNamesForRegion

      public List<String> findNamesForRegion(UUID regionId) throws SQLException
      Lists normalized group names assigned directly to a region.
      Parameter:
      regionId - region identifier
      Gibt zurück:
      immutable names ordered deterministically
      Löst aus:
      SQLException - when the query fails
    • findNamesForRegionHierarchy

      public List<String> findNamesForRegionHierarchy(UUID regionId) throws SQLException
      Lists group names assigned to a region or its direct parent city. Direct and inherited duplicate names are collapsed deterministically.
      Parameter:
      regionId - region identifier
      Gibt zurück:
      immutable direct and parent group names
      Löst aus:
      SQLException - when the query fails
    • findNamesForRegionHierarchy

      public List<String> findNamesForRegionHierarchy(UUID regionId, int limit) throws SQLException
      Lists a bounded prefix of direct and parent group names.
      Parameter:
      regionId - region identifier
      limit - maximum distinct names returned
      Gibt zurück:
      immutable deterministic group names
      Löst aus:
      SQLException - when the query fails