Class BranchQueryService

java.lang.Object
ai.chatur.cortex.core.branch.BranchQueryService

public class BranchQueryService extends Object
Reads the assertions staged on a branch pending review.

Every reader is routed through BranchRepository.onBranch(java.lang.String, java.lang.String, java.util.function.Function<org.apache.jena.rdf.model.Resource, T>, T), the same guard the write operations in BranchEditService and BranchMergeService use, so the provenance graph — a named graph of the same dataset, but never a branch — is never rendered as one: a branch named provenance is treated exactly like an unknown branch. Each method's missing value is chosen to match what it already returns for a genuinely unknown branch, so "provenance" and "unknown" are indistinguishable to callers: getBranch(java.lang.String) returns the shared prefix header with no data, getBranchInfo(java.lang.String) returns the requested name with a null start time and a size of 0, and getBranchSubjects(java.lang.String) returns an empty list.

  • Constructor Details

    • BranchQueryService

      public BranchQueryService(org.apache.jena.query.Dataset assertions, org.apache.jena.ontapi.model.OntModel ontModel, BranchRepository branchRepository)
      Creates the service.
      Parameters:
      assertions - the dataset holding the approved assertions and the staged branches
      ontModel - the ontology model, used to abbreviate terms for display
      branchRepository - guards every read against an unknown branch or the provenance graph
  • Method Details

    • getBranch

      public String getBranch(String branch)
      Returns the assertions staged on the given branch.
      Parameters:
      branch - the branch name
      Returns:
      the staged assertions serialized in Turtle syntax, or just the shared prefix header with no data if the branch does not exist or is the reserved provenance graph name
    • getBranchInfo

      public ai.chatur.cortex.BranchInfo getBranchInfo(String branch)
      Summarizes a branch pending review from its staged provenance activity.
      Parameters:
      branch - the branch name
      Returns:
      the branch summary, or (branch, null, 0) if the branch does not exist or is the reserved provenance graph name
    • getBranchSubjects

      public List<ai.chatur.cortex.BranchSubject> getBranchSubjects(String branch)
      Returns the assertions staged on the given branch grouped by subject, excluding the provenance activity of the ingestion.
      Parameters:
      branch - the branch name
      Returns:
      the staged subjects sorted by name, each with its statements sorted by predicate, or an empty list if the branch does not exist or is the reserved provenance graph name