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
           
private static String DEFAULT_ASSOCIATION_TYPE_URI
           
private static String DEFAULT_TOPIC_TYPE_URI
           
(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
           
(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, ClientState clientState, Directives directives)
          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, ClientState clientState)
           
(package private)  Association createAssociation(String typeUri, RoleModel roleModel1, RoleModel roleModel2)
          Convenience method.
(package private)  Association createAssociation(String typeUri, RoleModel roleModel1, RoleModel roleModel2, ClientState clientState)
          Convenience method.
(package private)  void createAssociationInstantiation(long assocId, String assocTypeUri)
           
 AssociationType createAssociationType(AssociationTypeModel model, ClientState clientState)
           
 Topic createTopic(TopicModel model, ClientState clientState)
           
(package private)  void createTopicInstantiation(long topicId, String topicTypeUri)
           
 TopicType createTopicType(TopicTypeModel model, ClientState clientState)
           
private  void createTypeTopic(TopicModel model, String defaultUriPrefix)
           
 Directives deleteAssociation(long assocId)
           
 Directives deleteTopic(long topicId)
           
private  void fetchCompositeValue(DeepaMehtaObjectModel model, boolean fetchComposite)
           
private  void fetchCompositeValue(RelatedTopicModel model, boolean fetchComposite, boolean fetchRelatingComposite)
           
(package private)  void fireEvent(CoreEvent event, Object... params)
           
 Iterable<Association> getAllAssociations()
           
 List<AssociationType> getAllAssociationTypes()
           
 Iterable<Topic> getAllTopics()
           
 List<TopicType> getAllTopicTypes()
           
 Association getAssociation(long assocId, boolean fetchComposite)
           
 Association getAssociation(String assocTypeUri, long topic1Id, long topic2Id, String roleTypeUri1, String roleTypeUri2, boolean fetchComposite)
          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, boolean fetchComposite)
           
 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.
 List<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()
           
 Plugin getPlugin(String pluginUri)
           
 List<PluginInfo> getPluginInfo()
           
 Topic getTopic(long topicId, boolean fetchComposite)
           
 Topic getTopic(String key, SimpleValue value, boolean fetchComposite)
          Looks up a single topic by exact value.
 ResultList<RelatedTopic> getTopics(String topicTypeUri, boolean fetchComposite, int maxResultSize)
           
 List<Topic> getTopics(String key, SimpleValue value, boolean fetchComposite)
          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, boolean fetchComposite)
          Attaches this core service to an association fetched from storage layer.
(package private)  List<Association> instantiateAssociations(List<AssociationModel> models, boolean fetchComposite)
           
(package private)  RelatedAssociation instantiateRelatedAssociation(RelatedAssociationModel model, boolean fetchComposite, boolean fetchRelatingComposite)
           
(package private)  List<RelatedAssociation> instantiateRelatedAssociations(Iterable<RelatedAssociationModel> models, boolean fetchComposite, boolean fetchRelatingComposite)
           
(package private)  RelatedTopic instantiateRelatedTopic(RelatedTopicModel model, boolean fetchComposite, boolean fetchRelatingComposite)
           
(package private)  ResultList<RelatedTopic> instantiateRelatedTopics(ResultList<RelatedTopicModel> models, boolean fetchComposite, boolean fetchRelatingComposite)
           
(package private)  Topic instantiateTopic(TopicModel model, boolean fetchComposite)
          Attaches this core service to a topic model fetched from storage layer.
private  List<Topic> instantiateTopics(List<TopicModel> models, boolean fetchComposite)
           
 List<Topic> searchTopics(String searchTerm, String fieldUri)
          Performs a fulltext search.
private  void setDefaults(DeepaMehtaObjectModel model)
           
private  void setupBootstrapContent()
           
private  void setupDB()
          Setups the database: 1) initializes the database.
private  Topic topicFactory(TopicModel model, ClientState clientState, Directives directives)
          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.
 Directives updateAssociation(AssociationModel model, ClientState clientState)
           
 Directives updateAssociationType(AssociationTypeModel model, ClientState clientState)
           
 Directives updateTopic(TopicModel model, ClientState clientState)
           
 Directives updateTopicType(TopicTypeModel model, ClientState clientState)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TOPIC_TYPE_URI

private static final String DEFAULT_TOPIC_TYPE_URI
See Also:
Constant Field Values

DEFAULT_ASSOCIATION_TYPE_URI

private static final String DEFAULT_ASSOCIATION_TYPE_URI
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,
                      boolean fetchComposite)
Specified by:
getTopic in interface DeepaMehtaService

getTopic

public Topic getTopic(String key,
                      SimpleValue value,
                      boolean fetchComposite)
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.

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,
                             boolean fetchComposite)
Description copied from interface: DeepaMehtaService
Looks up topics by key and value. String values can contain wildcards like "*".

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,
                                          boolean fetchComposite,
                                          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.

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

getAllTopics

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

createTopic

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

updateTopic

public Directives updateTopic(TopicModel model,
                              ClientState clientState)
Specified by:
updateTopic in interface DeepaMehtaService

deleteTopic

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

getAssociation

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

getAssociation

public Association getAssociation(String assocTypeUri,
                                  long topic1Id,
                                  long topic2Id,
                                  String roleTypeUri1,
                                  String roleTypeUri2,
                                  boolean fetchComposite)
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,
                                                            boolean fetchComposite)
Specified by:
getAssociationBetweenTopicAndAssociation in interface DeepaMehtaService

getAssociations

public List<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,
                                     ClientState clientState)
Specified by:
createAssociation in interface DeepaMehtaService

updateAssociation

public Directives updateAssociation(AssociationModel model,
                                    ClientState clientState)
Specified by:
updateAssociation in interface DeepaMehtaService

deleteAssociation

public Directives 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,
                                 ClientState clientState)
Specified by:
createTopicType in interface DeepaMehtaService

updateTopicType

public Directives updateTopicType(TopicTypeModel model,
                                  ClientState clientState)
Specified by:
updateTopicType 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,
                                             ClientState clientState)
Specified by:
createAssociationType in interface DeepaMehtaService

updateAssociationType

public Directives updateAssociationType(AssociationTypeModel model,
                                        ClientState clientState)
Specified by:
updateAssociationType 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

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

fireEvent

void fireEvent(CoreEvent event,
               Object... params)

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?


createAssociation

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


instantiateTopic

Topic instantiateTopic(TopicModel model,
                       boolean fetchComposite)
Attaches this core service to a topic model fetched from storage layer. Optionally fetches the topic's composite value from storage layer.


instantiateTopics

private List<Topic> instantiateTopics(List<TopicModel> models,
                                      boolean fetchComposite)

instantiateRelatedTopic

RelatedTopic instantiateRelatedTopic(RelatedTopicModel model,
                                     boolean fetchComposite,
                                     boolean fetchRelatingComposite)

instantiateRelatedTopics

ResultList<RelatedTopic> instantiateRelatedTopics(ResultList<RelatedTopicModel> models,
                                                  boolean fetchComposite,
                                                  boolean fetchRelatingComposite)

instantiateAssociation

Association instantiateAssociation(AssociationModel model,
                                   boolean fetchComposite)
Attaches this core service to an association fetched from storage layer. Optionally fetches the topic's composite value from storage layer.


instantiateAssociations

List<Association> instantiateAssociations(List<AssociationModel> models,
                                          boolean fetchComposite)

instantiateRelatedAssociation

RelatedAssociation instantiateRelatedAssociation(RelatedAssociationModel model,
                                                 boolean fetchComposite,
                                                 boolean fetchRelatingComposite)

instantiateRelatedAssociations

List<RelatedAssociation> instantiateRelatedAssociations(Iterable<RelatedAssociationModel> models,
                                                        boolean fetchComposite,
                                                        boolean fetchRelatingComposite)

fetchCompositeValue

private void fetchCompositeValue(DeepaMehtaObjectModel model,
                                 boolean fetchComposite)

fetchCompositeValue

private void fetchCompositeValue(RelatedTopicModel model,
                                 boolean fetchComposite,
                                 boolean fetchRelatingComposite)

topicFactory

private Topic topicFactory(TopicModel model,
                           ClientState clientState,
                           Directives directives)
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,
                                       ClientState clientState,
                                       Directives directives)
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.


setDefaults

private void setDefaults(DeepaMehtaObjectModel model)

createTypeTopic

private void createTypeTopic(TopicModel model,
                             String defaultUriPrefix)

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.

Called from CoreActivator#start.


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 © 2013. All Rights Reserved.