Package systems.dmx.storage.neo4j
Class Neo4jStorage
- java.lang.Object
-
- systems.dmx.storage.neo4j.Neo4jStorage
-
- All Implemented Interfaces:
DMXStorage
public class Neo4jStorage extends Object implements DMXStorage
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DMXTransaction
beginTx()
void
deleteAssoc(long assocId)
void
deleteAssocProperty(long assocId, String propUri)
void
deleteTopic(long topicId)
Deletes the topic.void
deleteTopicProperty(long topicId, String propUri)
Iterable<AssocModelImpl>
fetchAllAssocs()
Iterable<TopicModelImpl>
fetchAllTopics()
AssocModelImpl
fetchAssoc(long assocId)
Fetches an assoc by ID.List<AssocModelImpl>
fetchAssocAssocs(long assocId)
List<RelatedAssocModelImpl>
fetchAssocRelatedAssocs(long assocId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersAssocTypeUri)
<M extends RelatedObjectModel>
List<M>fetchAssocRelatedObjects(long assocId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTypeUri)
List<RelatedTopicModelImpl>
fetchAssocRelatedTopics(long assocId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTopicTypeUri)
List<AssocModelImpl>
fetchAssocs(String assocTypeUri, long topicId1, long topicId2, String roleTypeUri1, String roleTypeUri2)
Returns the associations between two topics.List<AssocModelImpl>
fetchAssocs(String key, Object value)
Fetches assocs by exact value.List<AssocModelImpl>
fetchAssocsBetweenTopicAndAssoc(String assocTypeUri, long topicId, long assocId, String topicRoleTypeUri, String assocRoleTypeUri)
List<AssocModelImpl>
fetchAssocsByProperty(String propUri, Object propValue)
List<AssocModelImpl>
fetchAssocsByPropertyRange(String propUri, Number from, Number to)
DMXObjectModelImpl
fetchObject(long id)
List<PlayerModel>
fetchPlayerModels(long assocId)
Object
fetchProperty(long id, String propUri)
List<RelatedAssocModelImpl>
fetchRelatedAssocs(long id, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersAssocTypeUri)
List<RelatedTopicModelImpl>
fetchRelatedTopics(long id, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTopicTypeUri)
TopicModelImpl
fetchTopic(long topicId)
Fetches a topic by ID.List<AssocModelImpl>
fetchTopicAssocs(long topicId)
List<RelatedAssocModelImpl>
fetchTopicRelatedAssocs(long topicId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersAssocTypeUri)
<M extends RelatedObjectModel>
List<M>fetchTopicRelatedObjects(long topicId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTypeUri)
List<RelatedTopicModelImpl>
fetchTopicRelatedTopics(long topicId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTopicTypeUri)
List<TopicModelImpl>
fetchTopics(String key, Object value)
Fetches topics by exact value.List<TopicModelImpl>
fetchTopicsByProperty(String propUri, Object propValue)
List<TopicModelImpl>
fetchTopicsByPropertyRange(String propUri, Number from, Number to)
Object
getDatabaseVendorObject()
Object
getDatabaseVendorObject(long objectId)
ModelFactoryImpl
getModelFactory()
boolean
hasProperty(long id, String propUri)
void
indexAssocProperty(long assocId, String propUri, Object propValue)
void
indexTopicFulltext(long topicId, String text, String indexKey)
void
indexTopicProperty(long topicId, String propUri, Object propValue)
List<AssocModelImpl>
queryAssocs(String key, Object value)
List<AssocModelImpl>
queryAssocsByRoleType(String roleTypeUri)
List<AssocModelImpl>
queryAssocsFulltext(String key, Object value)
List<TopicModelImpl>
queryTopics(String key, Object value)
List<TopicModelImpl>
queryTopicsFulltext(String key, Object value)
boolean
setupRootNode()
void
shutdown()
void
storeAssoc(AssocModelImpl assocModel)
void
storeAssocProperty(long assocId, String propUri, Object propValue, boolean addToIndex)
void
storeAssocTypeUri(long assocId, String assocTypeUri)
void
storeAssocUri(long assocId, String uri)
Stores and indexes the association's URI.void
storeAssocValue(long assocId, SimpleValue value, String indexKey, boolean isHtmlValue)
Stores and indexes an association value.void
storeRoleTypeUri(long assocId, long playerId, String roleTypeUri)
void
storeTopic(TopicModelImpl topicModel)
Stores a rudimentary topic in the DB.void
storeTopicProperty(long topicId, String propUri, Object propValue, boolean addToIndex)
void
storeTopicTypeUri(long topicId, String topicTypeUri)
void
storeTopicUri(long topicId, String uri)
Stores and indexes the topic's URI.void
storeTopicValue(long topicId, SimpleValue value, String indexKey, boolean isHtmlValue)
Stores and indexes a topic value.
-
-
-
Method Detail
-
fetchTopic
public TopicModelImpl fetchTopic(long topicId)
Description copied from interface:DMXStorage
Fetches a topic by ID.- Specified by:
fetchTopic
in interfaceDMXStorage
- Returns:
- The fetched topic.
-
fetchTopics
public List<TopicModelImpl> fetchTopics(String key, Object value)
Description copied from interface:DMXStorage
Fetches topics by exact value.- Specified by:
fetchTopics
in interfaceDMXStorage
-
queryTopics
public List<TopicModelImpl> queryTopics(String key, Object value)
- Specified by:
queryTopics
in interfaceDMXStorage
-
queryTopicsFulltext
public List<TopicModelImpl> queryTopicsFulltext(String key, Object value)
- Specified by:
queryTopicsFulltext
in interfaceDMXStorage
- Returns:
- The fetched topics.
-
fetchAllTopics
public Iterable<TopicModelImpl> fetchAllTopics()
- Specified by:
fetchAllTopics
in interfaceDMXStorage
-
storeTopic
public void storeTopic(TopicModelImpl topicModel)
Description copied from interface:DMXStorage
Stores a rudimentary topic in the DB.Only the topic URI and the topic type URI are stored. The topic value (simple or composite) is not stored. The "Instantiation" association is not stored.
An URI uniqueness check is performed. If the DB already contains a topic or an association with the URI passed, an exception is thrown and nothing is stored.
- Specified by:
storeTopic
in interfaceDMXStorage
- Parameters:
topicModel
- The topic to store. Once the method returns the topic model contains: - the ID of the stored topic. - an empty URI ("") in casenull
was passed. - an empty simple value ("") in casenull
was passed.
-
storeTopicUri
public void storeTopicUri(long topicId, String uri)
Description copied from interface:DMXStorage
Stores and indexes the topic's URI.- Specified by:
storeTopicUri
in interfaceDMXStorage
-
storeTopicTypeUri
public void storeTopicTypeUri(long topicId, String topicTypeUri)
- Specified by:
storeTopicTypeUri
in interfaceDMXStorage
-
storeTopicValue
public void storeTopicValue(long topicId, SimpleValue value, String indexKey, boolean isHtmlValue)
Description copied from interface:DMXStorage
Stores and indexes a topic value.- Specified by:
storeTopicValue
in interfaceDMXStorage
indexKey
- must not null
-
indexTopicFulltext
public void indexTopicFulltext(long topicId, String text, String indexKey)
- Specified by:
indexTopicFulltext
in interfaceDMXStorage
-
deleteTopic
public void deleteTopic(long topicId)
Description copied from interface:DMXStorage
Deletes the topic.Prerequisite: the topic has no relations.
- Specified by:
deleteTopic
in interfaceDMXStorage
-
fetchAssoc
public AssocModelImpl fetchAssoc(long assocId)
Description copied from interface:DMXStorage
Fetches an assoc by ID.- Specified by:
fetchAssoc
in interfaceDMXStorage
- Returns:
- The fetched assoc.
-
fetchAssocs
public List<AssocModelImpl> fetchAssocs(String key, Object value)
Description copied from interface:DMXStorage
Fetches assocs by exact value.- Specified by:
fetchAssocs
in interfaceDMXStorage
-
queryAssocs
public List<AssocModelImpl> queryAssocs(String key, Object value)
- Specified by:
queryAssocs
in interfaceDMXStorage
-
queryAssocsFulltext
public List<AssocModelImpl> queryAssocsFulltext(String key, Object value)
- Specified by:
queryAssocsFulltext
in interfaceDMXStorage
- Returns:
- The fetched assocs.
-
queryAssocsByRoleType
public List<AssocModelImpl> queryAssocsByRoleType(String roleTypeUri)
- Specified by:
queryAssocsByRoleType
in interfaceDMXStorage
-
fetchAssocs
public List<AssocModelImpl> fetchAssocs(String assocTypeUri, long topicId1, long topicId2, String roleTypeUri1, String roleTypeUri2)
Description copied from interface:DMXStorage
Returns the associations between two topics. If no such association exists an empty set is returned.- Specified by:
fetchAssocs
in interfaceDMXStorage
- Parameters:
assocTypeUri
- Assoc type filter. Passnull
to switch filter off.
-
fetchAssocsBetweenTopicAndAssoc
public List<AssocModelImpl> fetchAssocsBetweenTopicAndAssoc(String assocTypeUri, long topicId, long assocId, String topicRoleTypeUri, String assocRoleTypeUri)
- Specified by:
fetchAssocsBetweenTopicAndAssoc
in interfaceDMXStorage
-
fetchAllAssocs
public Iterable<AssocModelImpl> fetchAllAssocs()
- Specified by:
fetchAllAssocs
in interfaceDMXStorage
-
fetchPlayerModels
public List<PlayerModel> fetchPlayerModels(long assocId)
- Specified by:
fetchPlayerModels
in interfaceDMXStorage
-
storeAssoc
public void storeAssoc(AssocModelImpl assocModel)
- Specified by:
storeAssoc
in interfaceDMXStorage
-
storeAssocUri
public void storeAssocUri(long assocId, String uri)
Description copied from interface:DMXStorage
Stores and indexes the association's URI.- Specified by:
storeAssocUri
in interfaceDMXStorage
-
storeAssocTypeUri
public void storeAssocTypeUri(long assocId, String assocTypeUri)
- Specified by:
storeAssocTypeUri
in interfaceDMXStorage
-
storeAssocValue
public void storeAssocValue(long assocId, SimpleValue value, String indexKey, boolean isHtmlValue)
Description copied from interface:DMXStorage
Stores and indexes an association value.- Specified by:
storeAssocValue
in interfaceDMXStorage
indexKey
- must not null
-
storeRoleTypeUri
public void storeRoleTypeUri(long assocId, long playerId, String roleTypeUri)
- Specified by:
storeRoleTypeUri
in interfaceDMXStorage
-
deleteAssoc
public void deleteAssoc(long assocId)
- Specified by:
deleteAssoc
in interfaceDMXStorage
-
fetchObject
public DMXObjectModelImpl fetchObject(long id)
- Specified by:
fetchObject
in interfaceDMXStorage
-
fetchTopicAssocs
public List<AssocModelImpl> fetchTopicAssocs(long topicId)
- Specified by:
fetchTopicAssocs
in interfaceDMXStorage
-
fetchAssocAssocs
public List<AssocModelImpl> fetchAssocAssocs(long assocId)
- Specified by:
fetchAssocAssocs
in interfaceDMXStorage
-
fetchTopicRelatedTopics
public List<RelatedTopicModelImpl> fetchTopicRelatedTopics(long topicId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTopicTypeUri)
- Specified by:
fetchTopicRelatedTopics
in interfaceDMXStorage
assocTypeUri
- may be nullmyRoleTypeUri
- may be nullothersRoleTypeUri
- may be nullothersTopicTypeUri
- may be null- Returns:
- The fetched topics.
-
fetchTopicRelatedAssocs
public List<RelatedAssocModelImpl> fetchTopicRelatedAssocs(long topicId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersAssocTypeUri)
- Specified by:
fetchTopicRelatedAssocs
in interfaceDMXStorage
assocTypeUri
- may be nullmyRoleTypeUri
- may be nullothersRoleTypeUri
- may be null- Returns:
- The fetched associations.
-
fetchAssocRelatedTopics
public List<RelatedTopicModelImpl> fetchAssocRelatedTopics(long assocId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTopicTypeUri)
- Specified by:
fetchAssocRelatedTopics
in interfaceDMXStorage
assocTypeUri
- may be nullmyRoleTypeUri
- may be nullothersRoleTypeUri
- may be nullothersTopicTypeUri
- may be null- Returns:
- The fetched topics.
-
fetchAssocRelatedAssocs
public List<RelatedAssocModelImpl> fetchAssocRelatedAssocs(long assocId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersAssocTypeUri)
- Specified by:
fetchAssocRelatedAssocs
in interfaceDMXStorage
assocTypeUri
- may be nullmyRoleTypeUri
- may be nullothersRoleTypeUri
- may be null- Returns:
- The fetched associations.
-
fetchTopicRelatedObjects
public <M extends RelatedObjectModel> List<M> fetchTopicRelatedObjects(long topicId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTypeUri)
- Specified by:
fetchTopicRelatedObjects
in interfaceDMXStorage
-
fetchAssocRelatedObjects
public <M extends RelatedObjectModel> List<M> fetchAssocRelatedObjects(long assocId, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTypeUri)
- Specified by:
fetchAssocRelatedObjects
in interfaceDMXStorage
-
fetchRelatedTopics
public List<RelatedTopicModelImpl> fetchRelatedTopics(long id, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersTopicTypeUri)
- Specified by:
fetchRelatedTopics
in interfaceDMXStorage
- Parameters:
id
- id of a topic or an associationassocTypeUri
- may be nullmyRoleTypeUri
- may be nullothersRoleTypeUri
- may be nullothersTopicTypeUri
- may be null- Returns:
- The fetched topics.
-
fetchRelatedAssocs
public List<RelatedAssocModelImpl> fetchRelatedAssocs(long id, String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, String othersAssocTypeUri)
- Specified by:
fetchRelatedAssocs
in interfaceDMXStorage
- Parameters:
id
- id of a topic or an associationassocTypeUri
- may be nullmyRoleTypeUri
- may be nullothersRoleTypeUri
- may be null- Returns:
- The fetched associations.
-
fetchProperty
public Object fetchProperty(long id, String propUri)
- Specified by:
fetchProperty
in interfaceDMXStorage
- Parameters:
id
- id of a topic or an association
-
hasProperty
public boolean hasProperty(long id, String propUri)
- Specified by:
hasProperty
in interfaceDMXStorage
- Parameters:
id
- id of a topic or an association
-
fetchTopicsByProperty
public List<TopicModelImpl> fetchTopicsByProperty(String propUri, Object propValue)
- Specified by:
fetchTopicsByProperty
in interfaceDMXStorage
-
fetchTopicsByPropertyRange
public List<TopicModelImpl> fetchTopicsByPropertyRange(String propUri, Number from, Number to)
- Specified by:
fetchTopicsByPropertyRange
in interfaceDMXStorage
-
fetchAssocsByProperty
public List<AssocModelImpl> fetchAssocsByProperty(String propUri, Object propValue)
- Specified by:
fetchAssocsByProperty
in interfaceDMXStorage
-
fetchAssocsByPropertyRange
public List<AssocModelImpl> fetchAssocsByPropertyRange(String propUri, Number from, Number to)
- Specified by:
fetchAssocsByPropertyRange
in interfaceDMXStorage
-
storeTopicProperty
public void storeTopicProperty(long topicId, String propUri, Object propValue, boolean addToIndex)
- Specified by:
storeTopicProperty
in interfaceDMXStorage
-
storeAssocProperty
public void storeAssocProperty(long assocId, String propUri, Object propValue, boolean addToIndex)
- Specified by:
storeAssocProperty
in interfaceDMXStorage
-
indexTopicProperty
public void indexTopicProperty(long topicId, String propUri, Object propValue)
- Specified by:
indexTopicProperty
in interfaceDMXStorage
-
indexAssocProperty
public void indexAssocProperty(long assocId, String propUri, Object propValue)
- Specified by:
indexAssocProperty
in interfaceDMXStorage
-
deleteTopicProperty
public void deleteTopicProperty(long topicId, String propUri)
- Specified by:
deleteTopicProperty
in interfaceDMXStorage
-
deleteAssocProperty
public void deleteAssocProperty(long assocId, String propUri)
- Specified by:
deleteAssocProperty
in interfaceDMXStorage
-
beginTx
public DMXTransaction beginTx()
- Specified by:
beginTx
in interfaceDMXStorage
-
setupRootNode
public boolean setupRootNode()
- Specified by:
setupRootNode
in interfaceDMXStorage
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceDMXStorage
-
getDatabaseVendorObject
public Object getDatabaseVendorObject()
- Specified by:
getDatabaseVendorObject
in interfaceDMXStorage
-
getDatabaseVendorObject
public Object getDatabaseVendorObject(long objectId)
- Specified by:
getDatabaseVendorObject
in interfaceDMXStorage
-
getModelFactory
public ModelFactoryImpl getModelFactory()
- Specified by:
getModelFactory
in interfaceDMXStorage
-
-