-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Action in vertex not taken into account #211
Comments
I believe GraphWalker is evaluating the expression |
It seems that actions in vertices are lost, after model.build() public List<Context> create(String jsonStr) {
List<Context> contexts = new ArrayList<>();
JsonMultimodel jsonMultimodel = new Gson().fromJson(jsonStr, JsonMultimodel.class);
if (isNull(jsonMultimodel) || isNull(jsonMultimodel.getModels())) {
throw new ContextFactoryException("The json file is not a valid GraphWalker model(s) file");
}
// Seed the [global] singleton random generator, if any seed was set in the json file
if (jsonMultimodel.getSeed() != null) {
SingletonRandomGenerator.setSeed(jsonMultimodel.getSeed());
}
for (JsonModel jsonModel : jsonMultimodel.getModels()) {
JsonContext context = new JsonContext();
Model model = jsonModel.getModel();
context.setModel(model.build()); // after this line, actions in vertices are lost.
if (jsonModel.getGenerator() != null) {
context.setPathGenerator(GeneratorFactory.parse(jsonModel.getGenerator()));
}
for (Element element : context.getModel().getElements()) {
if (element.getId().equals(jsonModel.getStartElementId())) {
context.setNextElement(element);
break;
}
}
contexts.add(context);
}
return contexts;
} |
Indeed, It's a bug. Good catch @xiechunhong , thanks! Setting actions are missing in: graphwalker-project/graphwalker-io/src/main/java/org/graphwalker/io/factory/json/JsonVertex.java Lines 67 to 83 in c8d1910
I'll fix it during the day. |
I created a PR #233 . |
Super fast response! @KristianKarl private void execute(RuntimeEdge edge) {
execute(edge.getActions()); // this line will execute the actions defined in edge
if (edge.hasName()) {
getCurrentContext().execute(edge.getName());
}
}
private void execute(List<Action> actions) {
for (Action action : actions) {
getCurrentContext().execute(action);
}
}
private void execute(RuntimeVertex vertex) {
// maybe vertex also need to execute the actions here
if (vertex.hasName()) {
getCurrentContext().execute(vertex.getName());
}
} |
OK, I see your changes of the code, the issue (vertex doesn't execute the actions in SimpleMachine.java) I mentioned at the above comment is fixed! Great work! @KristianKarl |
The fix is available now in the latest 4.3.0-SNAPSHOT version, which is available here: https://github.com/GraphWalker/graphwalker-project/releases/tag/LATEST-BUILDS |
I have a model created using the studio. Actions specified in edges are taken into account. Actions specified in Vertex are not taken into account. I have used the same command for the action both in vertex and edges. The action is similar to this one (setting a variable to a value)
test=true;
So the question is : Are actions in vertex taken into account ?
See attached example.
test.json.txt
The text was updated successfully, but these errors were encountered: