de.deepamehta.core.impl
Class AttachedCompositeValue

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

 class AttachedCompositeValue
extends Object
implements CompositeValue

A composite value model that is attached to the DB.


Field Summary
private  Map<String,Object> childTopics
          Attached object cache.
private  EmbeddedService dms
           
private  Logger logger
           
private  CompositeValueModel model
           
private  AttachedDeepaMehtaObject parent
           
 
Constructor Summary
AttachedCompositeValue(CompositeValueModel model, AttachedDeepaMehtaObject parent, EmbeddedService dms)
           
 
Method Summary
private  Topic _getTopic(String childTypeUri)
           
private  Topic _getTopic(String childTypeUri, Topic defaultTopic)
           
private  List<Topic> _getTopics(String childTypeUri)
           
private  List<Topic> _getTopics(String childTypeUri, List<Topic> defaultValue)
           
private  CompositeValue _update(String childTypeUri, TopicModel newChildTopic, ClientState clientState, Directives directives)
           
private  void add(String childTypeUri, Topic topic)
          Adds a value to a multiple-valued child.
private  void addToCompositeValue(Topic childTopic, AssociationDefinition assocDef)
          For multiple-valued childs
 Iterable<String> childTypeUris()
           
private  void createChildTopicMany(TopicModel newChildTopic, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
private  void createChildTopicOne(TopicModel newChildTopic, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
private  Topic createTopic(TopicModel model)
           
private  RelatedTopic findChildTopic(long childTopicId, AssociationDefinition assocDef)
           
 Object get(String childTypeUri)
           
private  AssociationDefinition getAssocDef(String childTypeUri)
           
 boolean getBoolean(String childTypeUri)
          Convenience accessor for the *simple* value of a single-valued child.
 boolean getBoolean(String childTypeUri, boolean defaultValue)
          Convenience accessor for the *simple* value of a single-valued child.
 CompositeValue getCompositeValue(String childTypeUri)
          Convenience accessor for the *composite* value of a single-valued child.
 CompositeValue getCompositeValue(String childTypeUri, CompositeValue defaultValue)
          Convenience accessor for the *composite* value of a single-valued child.
 double getDouble(String childTypeUri)
          Convenience accessor for the *simple* value of a single-valued child.
 double getDouble(String childTypeUri, double defaultValue)
          Convenience accessor for the *simple* value of a single-valued child.
 int getInt(String childTypeUri)
          Convenience accessor for the *simple* value of a single-valued child.
 int getInt(String childTypeUri, int defaultValue)
          Convenience accessor for the *simple* value of a single-valued child.
 long getLong(String childTypeUri)
          Convenience accessor for the *simple* value of a single-valued child.
 long getLong(String childTypeUri, long defaultValue)
          Convenience accessor for the *simple* value of a single-valued child.
 CompositeValueModel getModel()
           
 Object getObject(String childTypeUri)
          Convenience accessor for the *simple* value of a single-valued child.
 Object getObject(String childTypeUri, Object defaultValue)
          Convenience accessor for the *simple* value of a single-valued child.
 String getString(String childTypeUri)
          Convenience accessor for the *simple* value of a single-valued child.
 String getString(String childTypeUri, String defaultValue)
          Convenience accessor for the *simple* value of a single-valued child.
 Topic getTopic(String childTypeUri)
          Accesses a single-valued child.
 Topic getTopic(String childTypeUri, Topic defaultTopic)
          Accesses a single-valued child.
 List<Topic> getTopics(String childTypeUri)
          Accesses a multiple-valued child.
 List<Topic> getTopics(String childTypeUri, List<Topic> defaultValue)
          Accesses a multiple-valued child.
 boolean has(String childTypeUri)
           
private  void initChildTopics(CompositeValueModel model)
           
private  void initChildTopics(CompositeValueModel model, String childTypeUri)
           
private  boolean isReferingToAny(TopicReferenceModel topicRef, AssociationDefinition assocDef)
          Checks weather the given topic reference refers to any of the child topics.
private  void loadChildTopics(AssociationDefinition assocDef)
          Lazy-loads child topics (model) and updates this attached object cache accordingly.
(package private)  void loadChildTopics(String childTypeUri)
           
private  void put(String childTypeUri, Topic topic)
          Puts a single-valued child.
private  void putInCompositeValue(Topic childTopic, AssociationDefinition assocDef)
          For single-valued childs
private  void reinit(String childTypeUri)
           
 CompositeValue remove(String childTypeUri, long topicId, ClientState clientState, Directives directives)
           
private  void remove(String childTypeUri, Topic topic)
          Removes a value from a multiple-valued child.
private  void removeFromCompositeValue(Topic childTopic, AssociationDefinition assocDef)
          For multiple-valued childs
 CompositeValue set(String childTypeUri, CompositeValueModel value, ClientState clientState, Directives directives)
          Convenience method to set the composite value of a child.
 CompositeValue set(String childTypeUri, Object value, ClientState clientState, Directives directives)
          Convenience method to set the simple value of a child.
 CompositeValue set(String childTypeUri, TopicModel value, ClientState clientState, Directives directives)
          Sets a child.
 CompositeValue setRef(String childTypeUri, long refTopicId, ClientState clientState, Directives directives)
           
 CompositeValue setRef(String childTypeUri, String refTopicUri, ClientState clientState, Directives directives)
           
 int size()
           
(package private)  void update(CompositeValueModel newComp, ClientState clientState, Directives directives)
           
private  void updateAggregationMany(List<? extends TopicModel> newChildTopics, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
private  void updateAggregationOne(TopicModel newChildTopic, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
private  void updateChildTopicMany(TopicModel newChildTopic, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
private  void updateChildTopicOne(TopicModel newChildTopic, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
(package private)  void updateChildTopics(TopicModel newChildTopic, List<? extends TopicModel> newChildTopics, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
private  void updateCompositionMany(List<? extends TopicModel> newChildTopics, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
private  void updateCompositionOne(TopicModel newChildTopic, AssociationDefinition assocDef, ClientState clientState, Directives directives)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

private CompositeValueModel model

parent

private AttachedDeepaMehtaObject parent

childTopics

private Map<String,Object> childTopics
Attached object cache. Key: child type URI (String), value: AttachedTopic or List


dms

private EmbeddedService dms

logger

private Logger logger
Constructor Detail

AttachedCompositeValue

AttachedCompositeValue(CompositeValueModel model,
                       AttachedDeepaMehtaObject parent,
                       EmbeddedService dms)
Method Detail

getTopic

public Topic getTopic(String childTypeUri)
Description copied from interface: CompositeValue
Accesses a single-valued child. Throws if there is no such child.

Specified by:
getTopic in interface CompositeValue

getTopic

public Topic getTopic(String childTypeUri,
                      Topic defaultTopic)
Description copied from interface: CompositeValue
Accesses a single-valued child. Returns a default value if there is no such child.

Specified by:
getTopic in interface CompositeValue

getTopics

public List<Topic> getTopics(String childTypeUri)
Description copied from interface: CompositeValue
Accesses a multiple-valued child. Throws if there is no such child.

Specified by:
getTopics in interface CompositeValue

getTopics

public List<Topic> getTopics(String childTypeUri,
                             List<Topic> defaultValue)
Description copied from interface: CompositeValue
Accesses a multiple-valued child. Returns a default value if there is no such child.

Specified by:
getTopics in interface CompositeValue

get

public Object get(String childTypeUri)
Specified by:
get in interface CompositeValue

has

public boolean has(String childTypeUri)
Specified by:
has in interface CompositeValue

childTypeUris

public Iterable<String> childTypeUris()
Specified by:
childTypeUris in interface CompositeValue

size

public int size()
Specified by:
size in interface CompositeValue

getModel

public CompositeValueModel getModel()
Specified by:
getModel in interface CompositeValue

getString

public String getString(String childTypeUri)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Throws if the child doesn't exist.

Specified by:
getString in interface CompositeValue

getString

public String getString(String childTypeUri,
                        String defaultValue)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Returns a default value if the child doesn't exist.

Specified by:
getString in interface CompositeValue

getInt

public int getInt(String childTypeUri)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Throws if the child doesn't exist.

Specified by:
getInt in interface CompositeValue

getInt

public int getInt(String childTypeUri,
                  int defaultValue)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Returns a default value if the child doesn't exist.

Specified by:
getInt in interface CompositeValue

getLong

public long getLong(String childTypeUri)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Throws if the child doesn't exist.

Specified by:
getLong in interface CompositeValue

getLong

public long getLong(String childTypeUri,
                    long defaultValue)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Returns a default value if the child doesn't exist.

Specified by:
getLong in interface CompositeValue

getDouble

public double getDouble(String childTypeUri)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Throws if the child doesn't exist.

Specified by:
getDouble in interface CompositeValue

getDouble

public double getDouble(String childTypeUri,
                        double defaultValue)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Returns a default value if the child doesn't exist.

Specified by:
getDouble in interface CompositeValue

getBoolean

public boolean getBoolean(String childTypeUri)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Throws if the child doesn't exist.

Specified by:
getBoolean in interface CompositeValue

getBoolean

public boolean getBoolean(String childTypeUri,
                          boolean defaultValue)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Returns a default value if the child doesn't exist.

Specified by:
getBoolean in interface CompositeValue

getObject

public Object getObject(String childTypeUri)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Throws if the child doesn't exist.

Specified by:
getObject in interface CompositeValue

getObject

public Object getObject(String childTypeUri,
                        Object defaultValue)
Description copied from interface: CompositeValue
Convenience accessor for the *simple* value of a single-valued child. Returns a default value if the child doesn't exist.

Specified by:
getObject in interface CompositeValue

getCompositeValue

public CompositeValue getCompositeValue(String childTypeUri)
Description copied from interface: CompositeValue
Convenience accessor for the *composite* value of a single-valued child. Throws if the child doesn't exist.

Specified by:
getCompositeValue in interface CompositeValue

getCompositeValue

public CompositeValue getCompositeValue(String childTypeUri,
                                        CompositeValue defaultValue)
Description copied from interface: CompositeValue
Convenience accessor for the *composite* value of a single-valued child. Returns a default value if the child doesn't exist.

Specified by:
getCompositeValue in interface CompositeValue

set

public CompositeValue set(String childTypeUri,
                          TopicModel value,
                          ClientState clientState,
                          Directives directives)
Description copied from interface: CompositeValue
Sets a child. Works for both, single-valued child and multiple-valued child (cardinality "many").

Specified by:
set in interface CompositeValue

set

public CompositeValue set(String childTypeUri,
                          Object value,
                          ClientState clientState,
                          Directives directives)
Description copied from interface: CompositeValue
Convenience method to set the simple value of a child. Works for both, single-valued child and multiple-valued child (cardinality "many").

Specified by:
set in interface CompositeValue
value - The simple value. Either String, Integer, Long, Double, or Boolean. Primitive values are auto-boxed.

set

public CompositeValue set(String childTypeUri,
                          CompositeValueModel value,
                          ClientState clientState,
                          Directives directives)
Description copied from interface: CompositeValue
Convenience method to set the composite value of a child. Works for both, single-valued child and multiple-valued child (cardinality "many").

Specified by:
set in interface CompositeValue

setRef

public CompositeValue setRef(String childTypeUri,
                             long refTopicId,
                             ClientState clientState,
                             Directives directives)
Specified by:
setRef in interface CompositeValue

setRef

public CompositeValue setRef(String childTypeUri,
                             String refTopicUri,
                             ClientState clientState,
                             Directives directives)
Specified by:
setRef in interface CompositeValue

remove

public CompositeValue remove(String childTypeUri,
                             long topicId,
                             ClientState clientState,
                             Directives directives)
Specified by:
remove in interface CompositeValue

update

void update(CompositeValueModel newComp,
            ClientState clientState,
            Directives directives)

updateChildTopics

void updateChildTopics(TopicModel newChildTopic,
                       List<? extends TopicModel> newChildTopics,
                       AssociationDefinition assocDef,
                       ClientState clientState,
                       Directives directives)

loadChildTopics

void loadChildTopics(String childTypeUri)

_getTopic

private Topic _getTopic(String childTypeUri)

_getTopic

private Topic _getTopic(String childTypeUri,
                        Topic defaultTopic)

_getTopics

private List<Topic> _getTopics(String childTypeUri)

_getTopics

private List<Topic> _getTopics(String childTypeUri,
                               List<Topic> defaultValue)

_update

private CompositeValue _update(String childTypeUri,
                               TopicModel newChildTopic,
                               ClientState clientState,
                               Directives directives)

updateCompositionOne

private void updateCompositionOne(TopicModel newChildTopic,
                                  AssociationDefinition assocDef,
                                  ClientState clientState,
                                  Directives directives)

updateCompositionMany

private void updateCompositionMany(List<? extends TopicModel> newChildTopics,
                                   AssociationDefinition assocDef,
                                   ClientState clientState,
                                   Directives directives)

updateAggregationOne

private void updateAggregationOne(TopicModel newChildTopic,
                                  AssociationDefinition assocDef,
                                  ClientState clientState,
                                  Directives directives)

updateAggregationMany

private void updateAggregationMany(List<? extends TopicModel> newChildTopics,
                                   AssociationDefinition assocDef,
                                   ClientState clientState,
                                   Directives directives)

updateChildTopicOne

private void updateChildTopicOne(TopicModel newChildTopic,
                                 AssociationDefinition assocDef,
                                 ClientState clientState,
                                 Directives directives)

updateChildTopicMany

private void updateChildTopicMany(TopicModel newChildTopic,
                                  AssociationDefinition assocDef,
                                  ClientState clientState,
                                  Directives directives)

createChildTopicOne

private void createChildTopicOne(TopicModel newChildTopic,
                                 AssociationDefinition assocDef,
                                 ClientState clientState,
                                 Directives directives)

createChildTopicMany

private void createChildTopicMany(TopicModel newChildTopic,
                                  AssociationDefinition assocDef,
                                  ClientState clientState,
                                  Directives directives)

loadChildTopics

private void loadChildTopics(AssociationDefinition assocDef)
Lazy-loads child topics (model) and updates this attached object cache accordingly.

Parameters:
assocDef - the child topics according to this association definition are loaded. Note: the association definition must not necessarily originate from this object's type definition. It may originate from a facet definition as well.

initChildTopics

private void initChildTopics(CompositeValueModel model)

initChildTopics

private void initChildTopics(CompositeValueModel model,
                             String childTypeUri)

createTopic

private Topic createTopic(TopicModel model)

reinit

private void reinit(String childTypeUri)

putInCompositeValue

private void putInCompositeValue(Topic childTopic,
                                 AssociationDefinition assocDef)
For single-valued childs


addToCompositeValue

private void addToCompositeValue(Topic childTopic,
                                 AssociationDefinition assocDef)
For multiple-valued childs


removeFromCompositeValue

private void removeFromCompositeValue(Topic childTopic,
                                      AssociationDefinition assocDef)
For multiple-valued childs


put

private void put(String childTypeUri,
                 Topic topic)
Puts a single-valued child. An existing value is overwritten.


add

private void add(String childTypeUri,
                 Topic topic)
Adds a value to a multiple-valued child.


remove

private void remove(String childTypeUri,
                    Topic topic)
Removes a value from a multiple-valued child.


findChildTopic

private RelatedTopic findChildTopic(long childTopicId,
                                    AssociationDefinition assocDef)

isReferingToAny

private boolean isReferingToAny(TopicReferenceModel topicRef,
                                AssociationDefinition assocDef)
Checks weather the given topic reference refers to any of the child topics.

Parameters:
assocDef - the child topics according to this association definition are considered.

getAssocDef

private AssociationDefinition getAssocDef(String childTypeUri)


Copyright © 2013. All Rights Reserved.