de.deepamehta.core.impl
Class AttachedChildTopics

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.impl.AttachedChildTopics
All Implemented Interfaces:
ChildTopics, Iterable<String>

 class AttachedChildTopics
extends Object
implements ChildTopics

A child topics model that is attached to the DB.


Field Summary
private  Map<String,Object> childTopics
          Attached object cache.
private  EmbeddedService dms
           
private  Logger logger
           
private  ChildTopicsModel model
           
private  AttachedDeepaMehtaObject parent
           
 
Constructor Summary
AttachedChildTopics(ChildTopicsModel model, AttachedDeepaMehtaObject parent, EmbeddedService dms)
           
 
Method Summary
private  RelatedTopic _getTopic(String childTypeUri)
           
private  RelatedTopic _getTopic(String childTypeUri, RelatedTopic defaultTopic)
           
private  List<RelatedTopic> _getTopics(String childTypeUri)
           
private  List<RelatedTopic> _getTopics(String childTypeUri, List<RelatedTopic> defaultValue)
           
private  ChildTopics _updateMany(String childTypeUri, RelatedTopicModel newChildTopic)
           
private  ChildTopics _updateOne(String childTypeUri, RelatedTopicModel newChildTopic)
           
 ChildTopics add(String childTypeUri, ChildTopicsModel value)
           
 ChildTopics add(String childTypeUri, Object value)
           
private  void add(String childTypeUri, RelatedTopic topic)
          Adds a value to a multiple-valued child.
 ChildTopics add(String childTypeUri, TopicModel value)
           
 ChildTopics addDeletionRef(String childTypeUri, long refTopicId)
           
 ChildTopics addDeletionRef(String childTypeUri, String refTopicUri)
           
 ChildTopics addRef(String childTypeUri, long refTopicId)
           
 ChildTopics addRef(String childTypeUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics)
           
 ChildTopics addRef(String childTypeUri, String refTopicUri)
           
 ChildTopics addRef(String childTypeUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics)
           
private  void addToChildTopics(RelatedTopic childTopic, AssociationDefinition assocDef)
          For multiple-valued childs
private  RelatedTopic associateChildTopic(RelatedTopicModel childTopic, AssociationDefinition assocDef)
           
private  RelatedTopic createAndAssociateChildTopic(RelatedTopicModel childTopic, AssociationDefinition assocDef)
           
private  void createAssignmentMany(TopicReferenceModel newChildTopic, AssociationDefinition assocDef)
           
private  void createAssignmentOne(RelatedTopic childTopic, TopicReferenceModel newChildTopic, AssociationDefinition assocDef, boolean deleteChildTopic)
           
private  void createChildTopicMany(RelatedTopicModel newChildTopic, AssociationDefinition assocDef)
           
private  void createChildTopicOne(RelatedTopicModel newChildTopic, AssociationDefinition assocDef)
           
private  void deleteChildTopicMany(long childTopicId, AssociationDefinition assocDef, boolean deleteChildTopic)
           
private  void deleteChildTopicOne(RelatedTopic childTopic, AssociationDefinition assocDef, boolean deleteChildTopic)
           
private  RelatedTopic findChildTopicById(long childTopicId, AssociationDefinition assocDef)
          For multiple-valued childs: looks in the attached object cache for a child topic by ID.
private  RelatedTopic findChildTopicByRef(TopicReferenceModel topicRef, AssociationDefinition assocDef)
          For multiple-valued childs: looks in the attached object cache for the child topic the given reference refers to.
 Object get(String childTypeUri)
           
private  AssociationDefinition getAssocDef(String childTypeUri)
           
 boolean getBoolean(String childTypeUri)
          Convenience accessor for the *simple* value of a single-valued child.
 ChildTopics getChildTopics(String childTypeUri)
          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.
 int getInt(String childTypeUri)
          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.
 ChildTopicsModel getModel()
           
 Object getObject(String childTypeUri)
          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.
 RelatedTopic getTopic(String childTypeUri)
          Accesses a single-valued child.
 List<RelatedTopic> getTopics(String childTypeUri)
          Accesses a multiple-valued child.
 boolean has(String childTypeUri)
           
private  void initAttachedObjectCache()
          Initializes this attached object cache.
private  void initAttachedObjectCache(String childTypeUri)
          Initializes this attached object cache selectively.
private  RelatedTopic instantiateRelatedTopic(RelatedTopicModel model)
          Creates an attached topic to be put in this attached object cache.
 Iterator<String> iterator()
           
(package private)  void loadChildTopics()
           
private  void loadChildTopics(AssociationDefinition assocDef)
          Recursively 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 putInChildTopics(RelatedTopic childTopic, AssociationDefinition assocDef)
          For single-valued childs
private  void refreshParentLabel()
           
private  void remove(String childTypeUri)
          Removes a single-valued child.
private  void remove(String childTypeUri, Topic topic)
          Removes a value from a multiple-valued child.
private  void removeChildTopic(AssociationDefinition assocDef)
          For single-valued childs
private  void removeFromChildTopics(Topic childTopic, AssociationDefinition assocDef)
          For multiple-valued childs
(package private)  RelatedTopic resolveRefAndAssociateChildTopic(TopicReferenceModel childTopicRef, AssociationDefinition assocDef)
          Creates an association between our parent object ("Parent" role) and the referenced topic ("Child" role).
 ChildTopics set(String childTypeUri, ChildTopicsModel value)
          Convenience method to set the composite value of a child.
 ChildTopics set(String childTypeUri, Object value)
          Convenience method to set the simple value of a child.
 ChildTopics set(String childTypeUri, TopicModel value)
          Sets a child.
 ChildTopics setDeletionRef(String childTypeUri, long refTopicId)
           
 ChildTopics setDeletionRef(String childTypeUri, String refTopicUri)
           
 ChildTopics setRef(String childTypeUri, long refTopicId)
           
 ChildTopics setRef(String childTypeUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics)
           
 ChildTopics setRef(String childTypeUri, String refTopicUri)
           
 ChildTopics setRef(String childTypeUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics)
           
 int size()
           
(package private)  void update(ChildTopicsModel newComp)
           
private  void updateAggregationMany(List<RelatedTopicModel> newChildTopics, AssociationDefinition assocDef)
           
private  void updateAggregationOne(RelatedTopicModel newChildTopic, AssociationDefinition assocDef)
           
private  void updateChildTopicMany(RelatedTopicModel newChildTopic, AssociationDefinition assocDef)
           
private  void updateChildTopicOne(RelatedTopicModel newChildTopic, AssociationDefinition assocDef)
           
(package private)  void updateChildTopics(RelatedTopicModel newChildTopic, List<RelatedTopicModel> newChildTopics, AssociationDefinition assocDef)
           
private  void updateCompositionMany(List<RelatedTopicModel> newChildTopics, AssociationDefinition assocDef)
           
private  void updateCompositionOne(RelatedTopicModel newChildTopic, AssociationDefinition assocDef)
           
private  void updateRelatedTopic(RelatedTopic childTopic, RelatedTopicModel newChildTopic)
           
private  void updateRelatingAssociation(RelatedTopic childTopic, RelatedTopicModel newChildTopic)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

private ChildTopicsModel model

parent

private AttachedDeepaMehtaObject parent

childTopics

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


dms

private EmbeddedService dms

logger

private Logger logger
Constructor Detail

AttachedChildTopics

AttachedChildTopics(ChildTopicsModel model,
                    AttachedDeepaMehtaObject parent,
                    EmbeddedService dms)
Method Detail

getTopic

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

Specified by:
getTopic in interface ChildTopics

getTopics

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

Specified by:
getTopics in interface ChildTopics

get

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

has

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

size

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

getModel

public ChildTopicsModel getModel()
Specified by:
getModel in interface ChildTopics

getString

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

Specified by:
getString in interface ChildTopics

getInt

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

Specified by:
getInt in interface ChildTopics

getLong

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

Specified by:
getLong in interface ChildTopics

getDouble

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

Specified by:
getDouble in interface ChildTopics

getBoolean

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

Specified by:
getBoolean in interface ChildTopics

getObject

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

Specified by:
getObject in interface ChildTopics

getChildTopics

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

Specified by:
getChildTopics in interface ChildTopics

set

public ChildTopics set(String childTypeUri,
                       TopicModel value)
Description copied from interface: ChildTopics
Sets a child.

Specified by:
set in interface ChildTopics

set

public ChildTopics set(String childTypeUri,
                       Object value)
Description copied from interface: ChildTopics
Convenience method to set the simple value of a child.

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

set

public ChildTopics set(String childTypeUri,
                       ChildTopicsModel value)
Description copied from interface: ChildTopics
Convenience method to set the composite value of a child.

Specified by:
set in interface ChildTopics

setRef

public ChildTopics setRef(String childTypeUri,
                          long refTopicId)
Specified by:
setRef in interface ChildTopics

setRef

public ChildTopics setRef(String childTypeUri,
                          long refTopicId,
                          ChildTopicsModel relatingAssocChildTopics)
Specified by:
setRef in interface ChildTopics

setRef

public ChildTopics setRef(String childTypeUri,
                          String refTopicUri)
Specified by:
setRef in interface ChildTopics

setRef

public ChildTopics setRef(String childTypeUri,
                          String refTopicUri,
                          ChildTopicsModel relatingAssocChildTopics)
Specified by:
setRef in interface ChildTopics

setDeletionRef

public ChildTopics setDeletionRef(String childTypeUri,
                                  long refTopicId)
Specified by:
setDeletionRef in interface ChildTopics

setDeletionRef

public ChildTopics setDeletionRef(String childTypeUri,
                                  String refTopicUri)
Specified by:
setDeletionRef in interface ChildTopics

add

public ChildTopics add(String childTypeUri,
                       TopicModel value)
Specified by:
add in interface ChildTopics

add

public ChildTopics add(String childTypeUri,
                       Object value)
Specified by:
add in interface ChildTopics

add

public ChildTopics add(String childTypeUri,
                       ChildTopicsModel value)
Specified by:
add in interface ChildTopics

addRef

public ChildTopics addRef(String childTypeUri,
                          long refTopicId)
Specified by:
addRef in interface ChildTopics

addRef

public ChildTopics addRef(String childTypeUri,
                          long refTopicId,
                          ChildTopicsModel relatingAssocChildTopics)
Specified by:
addRef in interface ChildTopics

addRef

public ChildTopics addRef(String childTypeUri,
                          String refTopicUri)
Specified by:
addRef in interface ChildTopics

addRef

public ChildTopics addRef(String childTypeUri,
                          String refTopicUri,
                          ChildTopicsModel relatingAssocChildTopics)
Specified by:
addRef in interface ChildTopics

addDeletionRef

public ChildTopics addDeletionRef(String childTypeUri,
                                  long refTopicId)
Specified by:
addDeletionRef in interface ChildTopics

addDeletionRef

public ChildTopics addDeletionRef(String childTypeUri,
                                  String refTopicUri)
Specified by:
addDeletionRef in interface ChildTopics

iterator

public Iterator<String> iterator()
Specified by:
iterator in interface Iterable<String>

update

void update(ChildTopicsModel newComp)

updateChildTopics

void updateChildTopics(RelatedTopicModel newChildTopic,
                       List<RelatedTopicModel> newChildTopics,
                       AssociationDefinition assocDef)

loadChildTopics

void loadChildTopics()

loadChildTopics

void loadChildTopics(String childTypeUri)

loadChildTopics

private void loadChildTopics(AssociationDefinition assocDef)
Recursively loads child topics (model) and updates this attached object cache accordingly. If the child topics are loaded already nothing is performed.

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

Note: the association definition must not necessarily originate from the parent object's type definition. It may originate from a facet definition as well.


refreshParentLabel

private void refreshParentLabel()

_updateOne

private ChildTopics _updateOne(String childTypeUri,
                               RelatedTopicModel newChildTopic)

_updateMany

private ChildTopics _updateMany(String childTypeUri,
                                RelatedTopicModel newChildTopic)

updateCompositionOne

private void updateCompositionOne(RelatedTopicModel newChildTopic,
                                  AssociationDefinition assocDef)

updateCompositionMany

private void updateCompositionMany(List<RelatedTopicModel> newChildTopics,
                                   AssociationDefinition assocDef)

updateAggregationOne

private void updateAggregationOne(RelatedTopicModel newChildTopic,
                                  AssociationDefinition assocDef)

updateAggregationMany

private void updateAggregationMany(List<RelatedTopicModel> newChildTopics,
                                   AssociationDefinition assocDef)

updateChildTopicOne

private void updateChildTopicOne(RelatedTopicModel newChildTopic,
                                 AssociationDefinition assocDef)

updateChildTopicMany

private void updateChildTopicMany(RelatedTopicModel newChildTopic,
                                  AssociationDefinition assocDef)

updateRelatedTopic

private void updateRelatedTopic(RelatedTopic childTopic,
                                RelatedTopicModel newChildTopic)

updateRelatingAssociation

private void updateRelatingAssociation(RelatedTopic childTopic,
                                       RelatedTopicModel newChildTopic)

createChildTopicOne

private void createChildTopicOne(RelatedTopicModel newChildTopic,
                                 AssociationDefinition assocDef)

createChildTopicMany

private void createChildTopicMany(RelatedTopicModel newChildTopic,
                                  AssociationDefinition assocDef)

createAndAssociateChildTopic

private RelatedTopic createAndAssociateChildTopic(RelatedTopicModel childTopic,
                                                  AssociationDefinition assocDef)

createAssignmentOne

private void createAssignmentOne(RelatedTopic childTopic,
                                 TopicReferenceModel newChildTopic,
                                 AssociationDefinition assocDef,
                                 boolean deleteChildTopic)

createAssignmentMany

private void createAssignmentMany(TopicReferenceModel newChildTopic,
                                  AssociationDefinition assocDef)

resolveRefAndAssociateChildTopic

RelatedTopic resolveRefAndAssociateChildTopic(TopicReferenceModel childTopicRef,
                                              AssociationDefinition assocDef)
Creates an association between our parent object ("Parent" role) and the referenced topic ("Child" role). The association type is taken from the given association definition.

Returns:
the resolved child topic.

associateChildTopic

private RelatedTopic associateChildTopic(RelatedTopicModel childTopic,
                                         AssociationDefinition assocDef)

deleteChildTopicOne

private void deleteChildTopicOne(RelatedTopic childTopic,
                                 AssociationDefinition assocDef,
                                 boolean deleteChildTopic)

deleteChildTopicMany

private void deleteChildTopicMany(long childTopicId,
                                  AssociationDefinition assocDef,
                                  boolean deleteChildTopic)

_getTopic

private RelatedTopic _getTopic(String childTypeUri)

_getTopic

private RelatedTopic _getTopic(String childTypeUri,
                               RelatedTopic defaultTopic)

_getTopics

private List<RelatedTopic> _getTopics(String childTypeUri)

_getTopics

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

findChildTopicById

private RelatedTopic findChildTopicById(long childTopicId,
                                        AssociationDefinition assocDef)
For multiple-valued childs: looks in the attached object cache for a child topic by ID.


findChildTopicByRef

private RelatedTopic findChildTopicByRef(TopicReferenceModel topicRef,
                                         AssociationDefinition assocDef)
For multiple-valued childs: looks in the attached object cache for the child topic the given reference refers to.

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

getAssocDef

private AssociationDefinition getAssocDef(String childTypeUri)

putInChildTopics

private void putInChildTopics(RelatedTopic childTopic,
                              AssociationDefinition assocDef)
For single-valued childs


removeChildTopic

private void removeChildTopic(AssociationDefinition assocDef)
For single-valued childs


addToChildTopics

private void addToChildTopics(RelatedTopic childTopic,
                              AssociationDefinition assocDef)
For multiple-valued childs


removeFromChildTopics

private void removeFromChildTopics(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.


remove

private void remove(String childTypeUri)
Removes a single-valued child.


add

private void add(String childTypeUri,
                 RelatedTopic 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.


initAttachedObjectCache

private void initAttachedObjectCache()
Initializes this attached object cache. Creates a hierarchy of attached topics (recursively) that is isomorph to the underlying model.


initAttachedObjectCache

private void initAttachedObjectCache(String childTypeUri)
Initializes this attached object cache selectively. Creates a hierarchy of attached topics (recursively) that is isomorph to the underlying model, starting at the given child sub-tree.


instantiateRelatedTopic

private RelatedTopic instantiateRelatedTopic(RelatedTopicModel model)
Creates an attached topic to be put in this attached object cache.



Copyright © 2015. All Rights Reserved.