Class BranchEditService

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

public class BranchEditService extends Object
Applies reviewer edits — deletions, object edits, and subject renames — to the assertions staged on a branch pending review.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BranchEditService(org.apache.jena.query.Dataset assertions, BranchRepository branchRepository)
    Creates the service.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    renameBranchSubjects(String branch, List<ai.chatur.cortex.BranchRename> renames)
    Renames subjects staged on the given branch, as an RDF patch on the branch graph.
    boolean
    updateBranch(String branch, List<ai.chatur.cortex.BranchChange> changes)
    Applies reviewer changes — deletions and object edits — to the assertions staged on the given branch, as an RDF patch on the branch graph.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BranchEditService

      public BranchEditService(org.apache.jena.query.Dataset assertions, BranchRepository branchRepository)
      Creates the service.
      Parameters:
      assertions - the dataset holding the approved assertions and the staged branches
      branchRepository - guards every operation against an unknown branch
  • Method Details

    • updateBranch

      public boolean updateBranch(String branch, List<ai.chatur.cortex.BranchChange> changes)
      Applies reviewer changes — deletions and object edits — to the assertions staged on the given branch, as an RDF patch on the branch graph.

      When the deletions remove every statement a subject carried, its IRI is gone from the branch, so every staged statement referencing that IRI as object is deleted as well.

      A change flagged retracted addresses the statements the branch stages for removal from the approved assertions rather than those it stages for addition, and can only cancel one: a retraction has no object of its own to edit, because it names a statement that is already approved.

      Changes addressing the provenance activity of the branch are ignored.

      Parameters:
      branch - the branch name
      changes - the changes to apply
      Returns:
      true if the branch existed and the changes were applied
    • renameBranchSubjects

      public boolean renameBranchSubjects(String branch, List<ai.chatur.cortex.BranchRename> renames)
      Renames subjects staged on the given branch, as an RDF patch on the branch graph.

      Every staged statement in which a renamed IRI appears is rewritten to use the new IRI, in both positions: the statements describing the renamed subject keep their content under the new IRI, and the statements referencing it as object come to reference the new IRI.

      Renames addressing the provenance activity of the branch are ignored.

      Parameters:
      branch - the branch name
      renames - the renames to apply
      Returns:
      true if the branch existed and the renames were applied