I have modelled a simple finite state machine graph in neo4j, where the domain consists of State
entities and a FOLLOWED_BY
relationship (in cypher: (s1:State)-[r:FOLLOWS]->(s2:State)
).
Each has some properties. I need now to analyse relations among the states and don't know how the return type in
the repository interface should look like.
The (shortened) code for the entity and relationship classes (with lombok annotations):
@NodeEntity
@NoArgsConstructor
public class State {
@Getter
private String name;
@Getter
private String inputVariable;
@Getter
private String outputVariable;
}
@RelationshipEntity(type = "FOLLOWED_BY")
@NoArgsConstructor
public class Transition implements FlowTransition {
@Getter
@Property
private String guard;
@Getter
@StartNode
private State sourceState;
@Getter
@EndNode
private State targetState;
}
For some analysis which paths exists from an state to following states where the output variable of first state is used as the input variable of the following state, I need the path returned from the query. As I'm using SDN I would like to have it returned in a (custom) query from the repository.
@Repository
public interface StateRepository extends Neo4jRepository<State, Long> {
@Query("MATCH p=allShortestpaths((s1:State)-[r:FOLLOWED_BY*1..200]->(s2:State))"
+ " WHERE s1.outputVariable = s2.inputVariable AND id(s1) = {eId}"
+ " RETURN p)"
??? findAllByBpelPathRegEx(@Param("eId") String startId);
}
My question is: what class should I use as the return type to get the path object? EntityPath
or EndResult
doesn't seem to exists anymore in SDN5(maybe 4 also), so what to take? Maybe projections, but should they look like?