ContextLoader
From SONIVIS:Wiki
The ContextLoader of SONIVIS is the generic network loader for all context networks. Its purpose is to retrieve the data according to the definition of a network type from the persistence layer and form a Graph object for display.
Contents |
General
The ContextLoader is implemented in the class ContextLoader in the package de.sonivis.tool.core.datamodel.networkloader. It is able to load networks according to a network type definition that represents ContentElement entities as nodes and ContextRelation entities as edges. The loader is not accessed directly. The network type definition is rather passed to the GenericNetworkLoader that is then up to decide which underlying concrete loader to call. The ContextLoader is one of these.
Prerequisits
A context network is a graph that represents a network of context relations connecting content elements. If there is a valid network type definition passed to the loader and corresponding data kept in the persistence store then it produces a graph according to that definition applied to the available data.
Implementation
There are two different workflows provided by the ContextLoader. Which one to take depends on the network type definition. If the definition specifies a non-empty set of, s.c., node grouping relations then the full workflow will be run. Otherwise, there is a simpler, direct workflow that will be taken.
Full workflow
The full workflow starts off by querying the persistence store for any node grouping relation that is provided by the network type definition. The purpose of the node grouping relations is to indicate that its target is the item to be represented as a node but the actual information that is to be displayed is, at least partly, contained in its sources. So, the result set is prepared to be used on a per-target-basis.
If a target item is covered by the network type definition's node types, i.e., ContentElement entities, a Node entity will be created to represent the target in the Graph entity.
The sources that have been found within the node grouping relation in the previous step for each target are taken for the sources of the edge types, i.e., ContextRelation entities, of the network type definition when querying the persistence store in the next step. The query result is inspected to decide what parts are to be represented in the graph. Therefore, each of the relations' targets is examined if it matches a supported node type. If so it can be safely added as a representing Node entity since the Edge entity representing the relation is ensured to be supported by the network type definition. Of course, the relation will be turned into an Edge entity in the follow-up step if the target was found to be a valid node.
Direct workflow
The direct workflow is straight forward. It loads all items that match one of the edge types as given by the network type. In case both the source and the target entity of a resulting item are covered by the network type then an Edge entity is created to represent the relation.
When all items of the result set are dealt with the entities according to the specified node types of the network type are loaded. Each item of the result set is turned into a Node of the resulting graph. This way, it is ensured that items that are supported by node types but have no relations according to the edge types are included in the graph as disconnected Node entities.
Setting up the graph
After all entities had their links been handled the created Node entities are added to the Graph, followed by the created Edge items. Then, the Graph is returned to the caller.
Links
- Javadoc of
ContextLoaderclass - SONIVIS:Data Model
- Data Model in Java

