Class JenaCortex

java.lang.Object
ai.chatur.cortex.JenaCortex
All Implemented Interfaces:
ai.chatur.cortex.Cortex, ai.chatur.cortex.CortexArchive, ai.chatur.cortex.CortexBranches, ai.chatur.cortex.CortexInference, ai.chatur.cortex.CortexIngestor, ai.chatur.cortex.CortexLinter, ai.chatur.cortex.CortexOntology, ai.chatur.cortex.CortexQuery, ai.chatur.cortex.CortexSearch, ai.chatur.cortex.CortexStatistics

public class JenaCortex extends Object implements ai.chatur.cortex.Cortex
Cortex implementation backed by Apache Jena.

Composes the core services: OntologyService for the ontology and its class hierarchy, LintService for linting assertions against the ontology, IngestService for validated ingestion, BranchRepository for branch existence and listing, BranchQueryService for reading a branch pending review, BranchEditService for reviewer edits to a branch, BranchMergeService for approving or rejecting a branch, ArchiveService for exporting the approved assertions, InferenceService for rule-based inference, QueryService for SPARQL queries and full-text search, and StatsService for statistics. Approving a branch extends the inference closure incrementally with the newly approved statements.

Backing the store up is deliberately not part of this surface — see BackupService.

  • Constructor Details

    • JenaCortex

      public JenaCortex(OntologyService ontologyService, LintService lintService, IngestService ingestService, BranchRepository branchRepository, BranchQueryService branchQueryService, BranchEditService branchEditService, BranchMergeService branchMergeService, ArchiveService archiveService, InferenceService inferenceService, QueryService queryService, StatsService statsService)
      Creates the composed implementation.
      Parameters:
      ontologyService - the ontology and its class hierarchy
      lintService - linting of assertions against the ontology
      ingestService - validated, branch-based ingestion
      branchRepository - branch existence and listing
      branchQueryService - reading the assertions staged on a branch
      branchEditService - reviewer edits to a branch
      branchMergeService - approving or rejecting a branch
      archiveService - export of the approved assertions
      inferenceService - rule-based inference over the approved assertions
      queryService - SPARQL queries and full-text search
      statsService - knowledge graph statistics
  • Method Details

    • getOntology

      public String getOntology()
      Specified by:
      getOntology in interface ai.chatur.cortex.CortexOntology
    • lint

      public ai.chatur.cortex.LintResult lint(String ttl)
      Specified by:
      lint in interface ai.chatur.cortex.CortexLinter
    • ingest

      public ai.chatur.cortex.IngestResult ingest(String ttl)
      Specified by:
      ingest in interface ai.chatur.cortex.CortexIngestor
    • listBranches

      public List<String> listBranches()
      Specified by:
      listBranches in interface ai.chatur.cortex.CortexBranches
    • hasBranch

      public boolean hasBranch(String branch)
      Specified by:
      hasBranch in interface ai.chatur.cortex.CortexBranches
    • getBranch

      public String getBranch(String branch)
      Specified by:
      getBranch in interface ai.chatur.cortex.CortexBranches
    • getBranchInfo

      public ai.chatur.cortex.BranchInfo getBranchInfo(String branch)
      Specified by:
      getBranchInfo in interface ai.chatur.cortex.CortexBranches
    • getBranchSubjects

      public List<ai.chatur.cortex.BranchSubject> getBranchSubjects(String branch)
      Specified by:
      getBranchSubjects in interface ai.chatur.cortex.CortexBranches
    • updateBranch

      public boolean updateBranch(String branch, List<ai.chatur.cortex.BranchChange> changes)
      Specified by:
      updateBranch in interface ai.chatur.cortex.CortexBranches
    • renameBranchSubjects

      public boolean renameBranchSubjects(String branch, List<ai.chatur.cortex.BranchRename> renames)
      Specified by:
      renameBranchSubjects in interface ai.chatur.cortex.CortexBranches
    • approve

      public void approve(String branch)

      The merge itself (BranchMergeService.approve(java.lang.String)) is one atomic write transaction: it either fully commits or leaves the branch untouched. Extending the inference closure afterward, however, is a second, separate transaction against a different dataset — the two cannot be combined into one transaction, since InferenceService and BranchMergeService guard independent Dataset instances. If InferenceService.addInference(org.apache.jena.rdf.model.Model) throws, the branch is already merged and cannot be un-merged here; rather than leave the closure silently stale until restart, this recomputes it from scratch — which reads the assertions dataset the merge already committed to, so the closure is correct again even though the incremental update failed — and then rethrows so the caller still learns the approval did not complete cleanly.

      Specified by:
      approve in interface ai.chatur.cortex.CortexBranches
    • reject

      public void reject(String branch)
      Specified by:
      reject in interface ai.chatur.cortex.CortexBranches
    • exportAssertions

      public String exportAssertions()
      Specified by:
      exportAssertions in interface ai.chatur.cortex.CortexArchive
    • getClassHierarchy

      public List<ai.chatur.cortex.OntologyClass> getClassHierarchy()
      Specified by:
      getClassHierarchy in interface ai.chatur.cortex.CortexOntology
    • getInstances

      public List<ai.chatur.cortex.Term> getInstances(String type)
      Specified by:
      getInstances in interface ai.chatur.cortex.CortexQuery
    • describe

      public List<ai.chatur.cortex.ProvenancedStatement> describe(String id)
      Specified by:
      describe in interface ai.chatur.cortex.CortexQuery
    • query

      public String query(String sparql)
      Specified by:
      query in interface ai.chatur.cortex.CortexQuery
    • search

      public String search(String text)
      Specified by:
      search in interface ai.chatur.cortex.CortexSearch
    • searchSubjects

      public List<ai.chatur.cortex.SearchResult> searchSubjects(String text)
      Specified by:
      searchSubjects in interface ai.chatur.cortex.CortexSearch
    • getStats

      public ai.chatur.cortex.CortexStats getStats()
      Specified by:
      getStats in interface ai.chatur.cortex.CortexStatistics
    • recomputeInference

      public void recomputeInference()
      Specified by:
      recomputeInference in interface ai.chatur.cortex.CortexInference