Add correct behaviour in case user creates a cycle in the script#81
Merged
Add correct behaviour in case user creates a cycle in the script#81
Conversation
blcham
requested changes
Nov 12, 2025
Contributor
There was a problem hiding this comment.
I see that it solves some of the issues, but it doesn't make sense to do it this complicated way. Moreover, it has a negative side effect that it modifies the file anyway, forcing the s-pipes editor to reload.
The write method should throw an exception, but it should not empty the file.
I believe there are multiple ways how to solve this issue:
- the best way:
- we should investigate why we empty file first, this should no happen. If it is happening using:
public static void writeScript(OutputStream outputStream, Model model) {
RDFWriter.create()
.format(new RDFFormat(CustomLangs.SPIPES_TURTLE))
.source(model)
.output(outputStream);
}
you could even reprogram it to:
public static void writeScript(OutputStream outputStream, Model model) {
Graph graph = model.getGraph();
SPipesFormatter formatter = new SPipesFormatter(graph, PrefixMapFactory.create(graph.getPrefixMapping()));
formatter.writeTo(outputStream);
}
- less optimal -- use builder:
public static SPipesFormatter getScriptFormatter(Model model) {
Graph graph = model.getGraph();
return new SPipesFormatter(graph, PrefixMapFactory.create(graph.getPrefixMapping()));
}
Contributor
|
Please try to investigate 1) using test JenaUtils.writeScriptWhenCycleInDependenciesDoesNotWriteToOutputStream() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #76
Cycles can only be created when new dependencies are added through the
sm:nextrelation, assuming no files contain cycles. So inscriptService.createDependencyI've added a catch that should restore the model before changes were made in casewriteScriptfails withIllegalStateException, which will be thrown in case we have a cycle in the graph.Editor will show a message that will indicate that: