de.deepamehta.core.impl
Class ValueStorage

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.impl.ValueStorage

 class ValueStorage
extends Object

Helper for storing/fetching simple values and composite value models.


Field Summary
private  EmbeddedService dms
           
private static String LABEL_CHILD_SEPARATOR
           
private static String LABEL_TOPIC_SEPARATOR
           
private  Logger logger
           
 
Constructor Summary
ValueStorage(EmbeddedService dms)
           
 
Method Summary
private  void appendLabel(String label, StringBuilder builder, String separator)
           
(package private)  void associateChildTopic(DeepaMehtaObjectModel parent, RelatedTopicModel childTopic, AssociationDefinitionModel assocDef)
          Creates an association between the given parent object ("Parent" role) and the child topic ("Child" role).
private  String buildChildLabel(DeepaMehtaObjectModel parent, String childTypeUri)
           
private  String buildLabel(DeepaMehtaObjectModel model)
           
private  RelatedTopicModel fetchChildTopic(long parentId, AssociationDefinitionModel assocDef)
          Fetches and returns a child topic or null if no such topic extists.
private  void fetchChildTopics(DeepaMehtaObjectModel parent)
          Fetches the child topic models (recursively) of the given parent object model and updates it in-place.
(package private)  void fetchChildTopics(DeepaMehtaObjectModel parent, AssociationDefinitionModel assocDef)
          Fetches the child topic models (recursively) of the given parent object model and updates it in-place.
private  ResultList<RelatedTopicModel> fetchChildTopics(long parentId, AssociationDefinitionModel assocDef)
           
private  Topic fetchReferencedTopic(TopicReferenceModel topicRef)
           
private  SimpleValue getIndexValue(DeepaMehtaObjectModel model)
          Calculates the simple value that is to be indexed for this object.
(package private)  List<String> getLabelChildTypeUris(DeepaMehtaObjectModel parent)
          Prerequisite: parent is a composite model.
private  TypeModel getType(DeepaMehtaObjectModel model)
          Returns the type model of a DeepaMehta object model.
(package private)  void indexSimpleValue(DeepaMehtaObjectModel model, IndexMode indexMode)
          Indexes the simple value of the given object model according to the given index mode.
(package private)  void refreshLabel(DeepaMehtaObjectModel parent)
          Recalculates the label of the given parent object model and updates it in-place.
(package private)  void resolveReference(TopicReferenceModel topicRef)
          Replaces a reference with the real thing.
(package private)  void setSimpleValue(DeepaMehtaObjectModel model, SimpleValue value)
           
private  void storeChildTopic(RelatedTopicModel childTopic, DeepaMehtaObjectModel parent, AssociationDefinitionModel assocDef)
           
private  void storeChildTopics(DeepaMehtaObjectModel parent)
          Stores the composite value (child topics) of the specified topic or association model.
private  void storeSimpleValue(DeepaMehtaObjectModel model)
          Stores and indexes the simple value of the specified topic or association model.
(package private)  void storeValue(DeepaMehtaObjectModel model)
          Stores and indexes the specified model's value, either a simple value or a composite value (child topics).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LABEL_CHILD_SEPARATOR

private static final String LABEL_CHILD_SEPARATOR
See Also:
Constant Field Values

LABEL_TOPIC_SEPARATOR

private static final String LABEL_TOPIC_SEPARATOR
See Also:
Constant Field Values

dms

private EmbeddedService dms

logger

private Logger logger
Constructor Detail

ValueStorage

ValueStorage(EmbeddedService dms)
Method Detail

fetchChildTopics

private void fetchChildTopics(DeepaMehtaObjectModel parent)
Fetches the child topic models (recursively) of the given parent object model and updates it in-place. ### TODO: recursion is required in some cases (e.g. when fetching a topic through REST API) but is possibly overhead in others (e.g. when updating composite structures).


fetchChildTopics

void fetchChildTopics(DeepaMehtaObjectModel parent,
                      AssociationDefinitionModel assocDef)
Fetches the child topic models (recursively) of the given parent object model and updates it in-place. ### TODO: recursion is required in some cases (e.g. when fetching a topic through REST API) but is possibly overhead in others (e.g. when updating composite structures).

Works for both, "one" and "many" association definitions.

Parameters:
assocDef - The child topic models according to this association definition are fetched.

storeValue

void storeValue(DeepaMehtaObjectModel model)
Stores and indexes the specified model's value, either a simple value or a composite value (child topics). Depending on the model type's data type dispatches either to storeSimpleValue() or to storeChildTopics().

Called to store the initial value of a newly created topic/association.


indexSimpleValue

void indexSimpleValue(DeepaMehtaObjectModel model,
                      IndexMode indexMode)
Indexes the simple value of the given object model according to the given index mode.

Called to index existing topics/associations once an index mode has been added to a type definition.


refreshLabel

void refreshLabel(DeepaMehtaObjectModel parent)
Recalculates the label of the given parent object model and updates it in-place. Note: no child topics are loaded from the DB. The given parent object model is expected to contain all the child topic models required for the label calculation.

Parameters:
parent - The object model the label is calculated for. This is expected to be a composite model.

setSimpleValue

void setSimpleValue(DeepaMehtaObjectModel model,
                    SimpleValue value)

storeSimpleValue

private void storeSimpleValue(DeepaMehtaObjectModel model)
Stores and indexes the simple value of the specified topic or association model. Determines the index key and index modes.


storeChildTopics

private void storeChildTopics(DeepaMehtaObjectModel parent)
Stores the composite value (child topics) of the specified topic or association model. Called to store the initial value of a newly created topic/association.

Note: the given model can contain childs not defined in the type definition. Only the childs defined in the type definition are stored.


storeChildTopic

private void storeChildTopic(RelatedTopicModel childTopic,
                             DeepaMehtaObjectModel parent,
                             AssociationDefinitionModel assocDef)

resolveReference

void resolveReference(TopicReferenceModel topicRef)
Replaces a reference with the real thing.


fetchReferencedTopic

private Topic fetchReferencedTopic(TopicReferenceModel topicRef)

associateChildTopic

void associateChildTopic(DeepaMehtaObjectModel parent,
                         RelatedTopicModel childTopic,
                         AssociationDefinitionModel assocDef)
Creates an association between the given parent object ("Parent" role) and the child topic ("Child" role). The association type is taken from the given association definition.


buildLabel

private String buildLabel(DeepaMehtaObjectModel model)

getLabelChildTypeUris

List<String> getLabelChildTypeUris(DeepaMehtaObjectModel parent)
Prerequisite: parent is a composite model.


buildChildLabel

private String buildChildLabel(DeepaMehtaObjectModel parent,
                               String childTypeUri)

appendLabel

private void appendLabel(String label,
                         StringBuilder builder,
                         String separator)

fetchChildTopic

private RelatedTopicModel fetchChildTopic(long parentId,
                                          AssociationDefinitionModel assocDef)
Fetches and returns a child topic or null if no such topic extists.


fetchChildTopics

private ResultList<RelatedTopicModel> fetchChildTopics(long parentId,
                                                       AssociationDefinitionModel assocDef)

getIndexValue

private SimpleValue getIndexValue(DeepaMehtaObjectModel model)
Calculates the simple value that is to be indexed for this object. HTML tags are stripped from HTML values. Non-HTML values are returned directly.


getType

private TypeModel getType(DeepaMehtaObjectModel model)
Returns the type model of a DeepaMehta object model. The type is obtained from the type storage.



Copyright © 2015. All Rights Reserved.