General information
Provider for delegating attribute value. Using this interface it is possible to delegate the real value of AttributeValue object to database (relational, graph, ...), index/search engine, ...
For every node/edge it is possible to add, get, set and remove every attribute value.
Implementation details
As of implementation detail of AttributeValue immutability, both adding and setting the attribute value is done through the set[Edge|Node]AttributeValue() method, so it is absolutely necessary to treat both cases in the method body.
Every method takes at least 2 arguments:
- delegate id
- attribute column
Delegate id is any type of object necessary to get the right node/edge. For instance for Neo4j it is of type Long, which is directly used as Neo4j node/relationship id. For other storing engines which require indexing key and value it could be crate (wrapper object) wrapping both values with proper types.
Attribute column is used usually for getting the column id which is used as property name.
Automatic and manual type conversions
Important thing about the whole delegating process is type conversion. It is clear that there might exist type mismatch between Gephi types and types which are supported in storing engine. During implementation it is necessary to fulfill following requirements:
- get[Edge|Node]AttributeValue() method must return any of primitive types, String or array of these types. The conversion from array type into appropriate List type is done automatically using ListFactory method.
- set[Edge|Node]AttributeValue() can accept any of Gephi supported types described in AttributeType constructors as class objects. It is up to the Provider to make appropriate conversion if this is needed, especially conversion from List types.
Usage
Every AttributeColumn has direct link to its own AttributeValueDelegateProvider. This means that it is possible to have more Providers in the same AttributeTable, each delegating from a subset of all columns. And because the fact that every AttributeValue has link to its AttributeColumn, it has direct access to its Provider too.
Provider will be called for getting value for every AttributeValue which has column with AttributeOrigin.DELEGATE. The first setValue() method call on Attributes/AttributeRow will set the delegate id and every other will change data in storing engine.
Best practises
Every implementing class should be implemented as singleton because of memory savings. This singleton should be passed during populating AttributeTable / creating columns.
Any other necessary implementation information / resources (as concrete database instance) should be set using static methods.
Any necessary convertor described in
Automatic and manual type conversions should be implemented as static inner class.
@author Martin Ć kurla
@param < T> type parameter used to restrict delegate id type