Menu

Control Flow

Ram Kumar Kumaresan

Below are the major classes and their description

Class QueryManager:
Input: XML from user.
Output: XML with nodes or relations or both.
Description: Responsible for converting input XML to objects and result objects to output XML. It contacts the Repository Manager with the created objects which returns the list of nodes and relations for the query. QueryManager then decides whether to return both nodes and relations (or) just one of them based on the user need. It then creates output XML from the objects and returns it to the controller.
Methods:
String executeQuery(String xml);
IQuery xmlToQueryObject(String xml);
String objectToXML(List<Nodes> nodes, List<Relations> relations, boolean wantNodes, boolean wantRelations);

Class RepositoryManager:
Input: Query object (equivalent of the input xml provided by user).
Output: List of objects(nodes and relations) that match exactly to the query object. Filtering of objects already taken care by this class.
Description: Responsible for providing the list of nodes/relations that match a given query object. Functionality to breakdown a query object into multiple cyphers. It uses queryToCypher(Query q) method to accomplish this task. It can also contact the Cache Manager with a cypher to check for caches. Important functionality is combine the result of multiple cyphers and filter them based on the query object.
Methods:
executeQuery(Query q); -> Only method visible to QueryManager. Contains logic to combine and filter resultset
breakDownQuery(Query q);
queryToCypher(Query subPartQuery);
executeCypher(String cypher)

Class CacheManager:
Input: Cypher string
Output: List of nodes and relations that match the cypher string
Description: Responsible for managing the application cypher-object cache. When a cypher is provided checks if the resultset for that cypher is already cached. If not it queries all the instances of RpositoryHandlers class and then combines the resultset.

Class RepositoryHandler:
Input: Cypher string
Output: List of nodes and relations that match the cypher string
Description: Query the instance of Neo4j.

Below is the control flow in Lerna, for a sample instance:
1. Input xml is submitted to the controller.
2. Controller passes on the xml to the QueryManager.
3. QueryManager generates the query objects from the xml and passes on to the RepositoryManager.
4. RepositoryManager breaks down the query objects into smaller parts. Lets say 4 for example.
5. For each individual part, RepositoryManager creates a cypher and contacts CacheManager with the smaller cypher query.
6. CacheManager checks if there is a cached output for an input cypher. If so it returns the cache output, else it contacts each running instance of the RepositoryHandler to get the resultsets.
7. RepositoryHandler executes the cypher in the Neo4j instance and returns the resulting set of nodes and cyphers.
8. CacheManager does a 'union' of resultsets fetched from all the instances of the RepositoryHandler and returns it to the RepositoryManager.
9. After receiving the outputs for all the smaller cyphers, RepositoryManager filters the resultset for each query from bottom-up order.
10. The final resultset = nodes + relations from the RepositoryManager should match the QueryObject provided.
11. The QueryManager then decides if only nodes or relations or both have to be used in creating the output xml.
12. The output xml is created by the QueryManager based on the decision made in step 11.
13. QueryManager returns the output xml to the controller call that started all this processing.


Related

Wiki: Home