de.deepamehta.core.impl
Class EmbeddedService

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.impl.EmbeddedService
All Implemented Interfaces:
DeepaMehtaService

public class EmbeddedService
extends Object
implements DeepaMehtaService

Implementation of the DeepaMehta core service. Embeddable into Java applications.


Field Summary
(package private)  BundleContext bundleContext
           
(package private)  EventManager eventManager
           
private  Logger logger
           
(package private)  MigrationManager migrationManager
           
(package private)  PluginManager pluginManager
           
(package private)  StorageDecorator storageDecorator
           
(package private)  TypeCache typeCache
           
(package private)  TypeStorageImpl typeStorage
           
private static String URI_PREFIX_ASSOCIATION_TYPE
           
private static String URI_PREFIX_ROLE_TYPE
           
private static String URI_PREFIX_TOPIC_TYPE
           
(package private)  ValueStorage valueStorage
           
 
Constructor Summary
EmbeddedService(StorageDecorator storageDecorator, BundleContext bundleContext)
           
 
Method Summary
private  void _associateDataType(String typeUri, String dataTypeUri)
          Low-level method that stores an (data type) association without its "Instantiation" association.
private  void _createTopic(TopicModel model)
          Low-level method that stores a topic without its "Instantiation" association.
private  Association associationFactory(AssociationModel model)
          Factory method: creates a new association in the DB according to the given association model and returns an association instance.
private  AssociationType associationTypeFactory(AssociationTypeModel model)
          Factory method: creates a new association type in the DB according to the given association type model and returns a topic type instance.
 DeepaMehtaTransaction beginTx()
           
private  void bootstrapTypeCache()
           
 Association createAssociation(AssociationModel model)
           
(package private)  Association createAssociation(String typeUri, RoleModel roleModel1, RoleModel roleModel2)
          Convenience method.
(package private)  void createAssociationInstantiation(long assocId, String assocTypeUri)
           
 AssociationType createAssociationType(AssociationTypeModel model)
           
 Topic createRoleType(TopicModel model)
           
 Topic createTopic(TopicModel model)
           
private  Topic createTopic(TopicModel model, String uriPrefix)
           
(package private)  void createTopicInstantiation(long topicId, String topicTypeUri)
           
 TopicType createTopicType(TopicTypeModel model)
           
 void deleteAssociation(long assocId)
           
 void deleteAssociationType(String assocTypeUri)
           
 void deleteTopic(long topicId)
           
 void deleteTopicType(String topicTypeUri)
           
 void deliverEvent(String pluginUri, DeepaMehtaEvent event, Object... params)
           
 void fireEvent(DeepaMehtaEvent event, Object... params)
           
 Iterable<Association> getAllAssociations()
           
 List<AssociationType> getAllAssociationTypes()
           
 Iterable<Topic> getAllTopics()
           
 List<TopicType> getAllTopicTypes()
           
 Association getAssociation(long assocId)
           
 Association getAssociation(String assocTypeUri, long topic1Id, long topic2Id, String roleTypeUri1, String roleTypeUri2)
          Returns the association between two topics, qualified by association type and both role types.
 Association getAssociationBetweenTopicAndAssociation(String assocTypeUri, long topicId, long assocId, String topicRoleTypeUri, String assocRoleTypeUri)
           
 List<Association> getAssociations(long topic1Id, long topic2Id)
          Returns all associations between two topics.
 List<Association> getAssociations(long topic1Id, long topic2Id, String assocTypeUri)
          Returns the associations between two topics.
 ResultList<RelatedAssociation> getAssociations(String assocTypeUri)
           
 List<Association> getAssociationsByProperty(String propUri, Object propValue)
           
 List<Association> getAssociationsByPropertyRange(String propUri, Number from, Number to)
           
 AssociationType getAssociationType(String uri)
           
 List<String> getAssociationTypeUris()
           
 Object getDatabaseVendorObject()
           
 Plugin getPlugin(String pluginUri)
           
 List<PluginInfo> getPluginInfo()
           
 Topic getTopic(long topicId)
           
 Topic getTopic(String key, SimpleValue value)
          Looks up a single topic by exact value.
 ResultList<RelatedTopic> getTopics(String topicTypeUri, int maxResultSize)
           
 List<Topic> getTopics(String key, SimpleValue value)
          Looks up topics by key and value.
 List<Topic> getTopicsByProperty(String propUri, Object propValue)
           
 List<Topic> getTopicsByPropertyRange(String propUri, Number from, Number to)
           
 TopicType getTopicType(String uri)
           
 List<String> getTopicTypeUris()
           
 TypeStorage getTypeStorage()
           
(package private)  Association instantiateAssociation(AssociationModel model)
          Attaches this core service to an association fetched from storage layer.
(package private)  List<Association> instantiateAssociations(List<AssociationModel> models)
           
(package private)  RelatedAssociation instantiateRelatedAssociation(RelatedAssociationModel model)
           
(package private)  ResultList<RelatedAssociation> instantiateRelatedAssociations(Iterable<RelatedAssociationModel> models)
           
(package private)  RelatedTopic instantiateRelatedTopic(RelatedTopicModel model)
           
(package private)  ResultList<RelatedTopic> instantiateRelatedTopics(ResultList<RelatedTopicModel> models)
           
(package private)  Topic instantiateTopic(TopicModel model)
          Attaches this core service to a topic model fetched from storage layer.
private  List<Topic> instantiateTopics(List<TopicModel> models)
           
 List<Topic> searchTopics(String searchTerm, String fieldUri)
          Performs a fulltext search.
private  void setupBootstrapContent()
           
private  void setupDB()
          Setups the database: 1) initializes the database.
private  Topic topicFactory(TopicModel model, String uriPrefix)
          Factory method: creates a new topic in the DB according to the given topic model and returns a topic instance.
private  TopicType topicTypeFactory(TopicTypeModel model)
          Factory method: creates a new topic type in the DB according to the given topic type model and returns a topic type instance.
 void updateAssociation(AssociationModel model)
           
 void updateAssociationType(AssociationTypeModel model)
           
 void updateTopic(TopicModel model)
           
 void updateTopicType(TopicTypeModel model)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URI_PREFIX_TOPIC_TYPE

private static final String URI_PREFIX_TOPIC_TYPE
See Also:
Constant Field Values

URI_PREFIX_ASSOCIATION_TYPE

private static final String URI_PREFIX_ASSOCIATION_TYPE
See Also:
Constant Field Values

URI_PREFIX_ROLE_TYPE

private static final String URI_PREFIX_ROLE_TYPE
See Also:
Constant Field Values

storageDecorator

StorageDecorator storageDecorator

bundleContext

BundleContext bundleContext

migrationManager

MigrationManager migrationManager

pluginManager

PluginManager pluginManager

eventManager

EventManager eventManager

typeCache

TypeCache typeCache

typeStorage

TypeStorageImpl typeStorage

valueStorage

ValueStorage valueStorage

logger

private Logger logger
Constructor Detail

EmbeddedService

public EmbeddedService(StorageDecorator storageDecorator,
                       BundleContext bundleContext)
Parameters:
bundleContext - The context of the DeepaMehta 4 Core bundle.
Method Detail

getTopic

public Topic getTopic(long topicId)
Specified by:
getTopic in interface DeepaMehtaService

getTopic

public Topic getTopic(String key,
                      SimpleValue value)
Description copied from interface: DeepaMehtaService
Looks up a single topic by exact value. If no such topic exists null is returned. If more than one topic is found a runtime exception is thrown.

Note: wildcards like "*" in String values are treated literally. They are not interpreted. Compare to #getTopics(String,SimpleValue,boolean)

IMPORTANT: Looking up a topic this way requires the corresponding type to be indexed with indexing mode dm4.core.key.

Specified by:
getTopic in interface DeepaMehtaService

getTopics

public List<Topic> getTopics(String key,
                             SimpleValue value)
Description copied from interface: DeepaMehtaService
Looks up topics by key and value.

Wildcards like "*" in String values are interpreted.

IMPORTANT: Looking up topics this way requires the corresponding type to be indexed with indexing mode dm4.core.key.

Specified by:
getTopics in interface DeepaMehtaService

getTopics

public ResultList<RelatedTopic> getTopics(String topicTypeUri,
                                          int maxResultSize)
Specified by:
getTopics in interface DeepaMehtaService

searchTopics

public List<Topic> searchTopics(String searchTerm,
                                String fieldUri)
Description copied from interface: DeepaMehtaService
Performs a fulltext search.

IMPORTANT: Searching topics this way requires the corresponding type to be indexed with indexing mode dm4.core.fulltext or dm4.core.fulltext_key. ### FIXDOC

Specified by:
searchTopics in interface DeepaMehtaService
fieldUri - The URI of the data field to search. If null is provided all fields are searched. ### FIXDOC ### TODO: rename parameter to "key"?

getAllTopics

public Iterable<Topic> getAllTopics()
Specified by:
getAllTopics in interface DeepaMehtaService

createTopic

public Topic createTopic(TopicModel model)
Specified by:
createTopic in interface DeepaMehtaService

updateTopic

public void updateTopic(TopicModel model)
Specified by:
updateTopic in interface DeepaMehtaService

deleteTopic

public void deleteTopic(long topicId)
Specified by:
deleteTopic in interface DeepaMehtaService

getAssociation

public Association getAssociation(long assocId)
Specified by:
getAssociation in interface DeepaMehtaService

getAssociation

public Association getAssociation(String assocTypeUri,
                                  long topic1Id,
                                  long topic2Id,
                                  String roleTypeUri1,
                                  String roleTypeUri2)
Description copied from interface: DeepaMehtaService
Returns the association between two topics, qualified by association type and both role types. If no such association exists null is returned. If more than one association exist, a runtime exception is thrown.

Specified by:
getAssociation in interface DeepaMehtaService
Parameters:
assocTypeUri - Association type filter. Pass null to switch filter off.

getAssociationBetweenTopicAndAssociation

public Association getAssociationBetweenTopicAndAssociation(String assocTypeUri,
                                                            long topicId,
                                                            long assocId,
                                                            String topicRoleTypeUri,
                                                            String assocRoleTypeUri)
Specified by:
getAssociationBetweenTopicAndAssociation in interface DeepaMehtaService

getAssociations

public ResultList<RelatedAssociation> getAssociations(String assocTypeUri)
Specified by:
getAssociations in interface DeepaMehtaService

getAssociations

public List<Association> getAssociations(long topic1Id,
                                         long topic2Id)
Description copied from interface: DeepaMehtaService
Returns all associations between two topics. If no such association exists an empty set is returned.

Specified by:
getAssociations in interface DeepaMehtaService

getAssociations

public List<Association> getAssociations(long topic1Id,
                                         long topic2Id,
                                         String assocTypeUri)
Description copied from interface: DeepaMehtaService
Returns the associations between two topics. If no such association exists an empty set is returned.

Specified by:
getAssociations in interface DeepaMehtaService
assocTypeUri - Association type filter. Pass null to switch filter off.

getAllAssociations

public Iterable<Association> getAllAssociations()
Specified by:
getAllAssociations in interface DeepaMehtaService

createAssociation

public Association createAssociation(AssociationModel model)
Specified by:
createAssociation in interface DeepaMehtaService

updateAssociation

public void updateAssociation(AssociationModel model)
Specified by:
updateAssociation in interface DeepaMehtaService

deleteAssociation

public void deleteAssociation(long assocId)
Specified by:
deleteAssociation in interface DeepaMehtaService

getTopicTypeUris

public List<String> getTopicTypeUris()
Specified by:
getTopicTypeUris in interface DeepaMehtaService

getTopicType

public TopicType getTopicType(String uri)
Specified by:
getTopicType in interface DeepaMehtaService

getAllTopicTypes

public List<TopicType> getAllTopicTypes()
Specified by:
getAllTopicTypes in interface DeepaMehtaService

createTopicType

public TopicType createTopicType(TopicTypeModel model)
Specified by:
createTopicType in interface DeepaMehtaService

updateTopicType

public void updateTopicType(TopicTypeModel model)
Specified by:
updateTopicType in interface DeepaMehtaService

deleteTopicType

public void deleteTopicType(String topicTypeUri)
Specified by:
deleteTopicType in interface DeepaMehtaService

getAssociationTypeUris

public List<String> getAssociationTypeUris()
Specified by:
getAssociationTypeUris in interface DeepaMehtaService

getAssociationType

public AssociationType getAssociationType(String uri)
Specified by:
getAssociationType in interface DeepaMehtaService

getAllAssociationTypes

public List<AssociationType> getAllAssociationTypes()
Specified by:
getAllAssociationTypes in interface DeepaMehtaService

createAssociationType

public AssociationType createAssociationType(AssociationTypeModel model)
Specified by:
createAssociationType in interface DeepaMehtaService

updateAssociationType

public void updateAssociationType(AssociationTypeModel model)
Specified by:
updateAssociationType in interface DeepaMehtaService

deleteAssociationType

public void deleteAssociationType(String assocTypeUri)
Specified by:
deleteAssociationType in interface DeepaMehtaService

createRoleType

public Topic createRoleType(TopicModel model)
Specified by:
createRoleType in interface DeepaMehtaService

getPlugin

public Plugin getPlugin(String pluginUri)
Specified by:
getPlugin in interface DeepaMehtaService

getPluginInfo

public List<PluginInfo> getPluginInfo()
Specified by:
getPluginInfo in interface DeepaMehtaService

fireEvent

public void fireEvent(DeepaMehtaEvent event,
                      Object... params)
Specified by:
fireEvent in interface DeepaMehtaService

deliverEvent

public void deliverEvent(String pluginUri,
                         DeepaMehtaEvent event,
                         Object... params)
Specified by:
deliverEvent in interface DeepaMehtaService

getTopicsByProperty

public List<Topic> getTopicsByProperty(String propUri,
                                       Object propValue)
Specified by:
getTopicsByProperty in interface DeepaMehtaService

getTopicsByPropertyRange

public List<Topic> getTopicsByPropertyRange(String propUri,
                                            Number from,
                                            Number to)
Specified by:
getTopicsByPropertyRange in interface DeepaMehtaService

getAssociationsByProperty

public List<Association> getAssociationsByProperty(String propUri,
                                                   Object propValue)
Specified by:
getAssociationsByProperty in interface DeepaMehtaService

getAssociationsByPropertyRange

public List<Association> getAssociationsByPropertyRange(String propUri,
                                                        Number from,
                                                        Number to)
Specified by:
getAssociationsByPropertyRange in interface DeepaMehtaService

beginTx

public DeepaMehtaTransaction beginTx()
Specified by:
beginTx in interface DeepaMehtaService

getTypeStorage

public TypeStorage getTypeStorage()
Specified by:
getTypeStorage in interface DeepaMehtaService

getDatabaseVendorObject

public Object getDatabaseVendorObject()
Specified by:
getDatabaseVendorObject in interface DeepaMehtaService

createTopicInstantiation

void createTopicInstantiation(long topicId,
                              String topicTypeUri)

createAssociationInstantiation

void createAssociationInstantiation(long assocId,
                                    String assocTypeUri)

createAssociation

Association createAssociation(String typeUri,
                              RoleModel roleModel1,
                              RoleModel roleModel2)
Convenience method. ### to be dropped?


instantiateTopic

Topic instantiateTopic(TopicModel model)
Attaches this core service to a topic model fetched from storage layer.


instantiateTopics

private List<Topic> instantiateTopics(List<TopicModel> models)

instantiateRelatedTopic

RelatedTopic instantiateRelatedTopic(RelatedTopicModel model)

instantiateRelatedTopics

ResultList<RelatedTopic> instantiateRelatedTopics(ResultList<RelatedTopicModel> models)

instantiateAssociation

Association instantiateAssociation(AssociationModel model)
Attaches this core service to an association fetched from storage layer.


instantiateAssociations

List<Association> instantiateAssociations(List<AssociationModel> models)

instantiateRelatedAssociation

RelatedAssociation instantiateRelatedAssociation(RelatedAssociationModel model)

instantiateRelatedAssociations

ResultList<RelatedAssociation> instantiateRelatedAssociations(Iterable<RelatedAssociationModel> models)

createTopic

private Topic createTopic(TopicModel model,
                          String uriPrefix)

topicFactory

private Topic topicFactory(TopicModel model,
                           String uriPrefix)
Factory method: creates a new topic in the DB according to the given topic model and returns a topic instance.


associationFactory

private Association associationFactory(AssociationModel model)
Factory method: creates a new association in the DB according to the given association model and returns an association instance.


topicTypeFactory

private TopicType topicTypeFactory(TopicTypeModel model)
Factory method: creates a new topic type in the DB according to the given topic type model and returns a topic type instance.


associationTypeFactory

private AssociationType associationTypeFactory(AssociationTypeModel model)
Factory method: creates a new association type in the DB according to the given association type model and returns a topic type instance.


setupDB

private void setupDB()
Setups the database: 1) initializes the database. 2) in case of a clean install: sets up the bootstrap content. 3) runs the core migrations.


setupBootstrapContent

private void setupBootstrapContent()

_createTopic

private void _createTopic(TopicModel model)
Low-level method that stores a topic without its "Instantiation" association. Needed for bootstrapping.


_associateDataType

private void _associateDataType(String typeUri,
                                String dataTypeUri)
Low-level method that stores an (data type) association without its "Instantiation" association. Needed for bootstrapping.


bootstrapTypeCache

private void bootstrapTypeCache()


Copyright © 2014. All Rights Reserved.