Class BranchMergeService
-
Constructor Summary
ConstructorsConstructorDescriptionBranchMergeService(org.apache.jena.query.Dataset assertions, BranchRepository branchRepository, ProvenanceRecorder provenanceRecorder) Creates the service. -
Method Summary
Modifier and TypeMethodDescriptionMerges the assertions staged on the given branch into the default graph — removing the statements it stages for removal and adding those it stages for addition — closing theprovenance activityof the ingestion, recording the reification of every merged statement linked to the activity in theprovenance graphand clearing the reifications of every retracted one, and deletes the branch.voidRejects the given branch, discarding both the assertions it stages for addition and those it stages for removal, if it exists.
-
Constructor Details
-
BranchMergeService
public BranchMergeService(org.apache.jena.query.Dataset assertions, BranchRepository branchRepository, ProvenanceRecorder provenanceRecorder) Creates the service.- Parameters:
assertions- the dataset holding the approved assertions and the staged branchesbranchRepository- guards every operation against an unknown branchprovenanceRecorder- builds the provenance recorded when a branch is approved
-
-
Method Details
-
approve
Merges the assertions staged on the given branch into the default graph — removing the statements it stages for removal and adding those it stages for addition — closing theprovenance activityof the ingestion, recording the reification of every merged statement linked to the activity in theprovenance graphand clearing the reifications of every retracted one, and deletes the branch.Retractions are applied before additions, so an edit that replaces the object of a statement leaves the replacement in place rather than removing it again.
The novelty diff, the merge, and the branch deletion all happen inside one write transaction on the assertions dataset: TDB2 serializes writers, so two branches can never be approved concurrently, and a failure partway through aborts the whole transaction rather than leaving the data merged while the branch is still pending (which used to risk a second, duplicate
prov:Activityon a retried approval). Staged triples that were approved through another branch in the meantime are skipped, and staged retractions of statements another branch already retracted are no-ops, so a statement is never merged or reified twice — this is now guaranteed by that same serialization, rather than a best-effort race with the other branch's approval.- Parameters:
branch- the branch name- Returns:
- what the merge did — the newly approved assertions, empty if every staged triple was
approved through another branch in the meantime, and whether anything was retracted — or
nullif the branch does not exist
-
reject
Rejects the given branch, discarding both the assertions it stages for addition and those it stages for removal, if it exists.- Parameters:
branch- the branch name
-