Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.core.storage.sql
Class Children

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.Children

public class Children
extends java.lang.Object

Holds information about the children of a given parent node. The internal state reflects:

Information about children in the database may be complete, or just partial if only individual children have been retrieved from the database.

Children are stored in no particular order.

When this structure holds information all flushed to the database, then it can safely be GC'ed, so it lives in a memory-sensitive map (softMap), otherwise it's moved to a normal map (hardMap).

This class is not thread-safe and should be used only from a single-threaded session.


Constructor Summary
Children(HierarchyContext hierContext, java.lang.String filterKey, boolean empty, java.io.Serializable mapKey, java.util.Map<java.io.Serializable,Children> softMap, java.util.Map<java.io.Serializable,Children> hardMap)
          Constructs a Children cache.
 
Method Summary
 void addCreated(java.io.Serializable id)
          Adds a created child.
 void addExisting(java.io.Serializable id)
          Adds a known child.
 void addExistingComplete(java.util.List<java.io.Serializable> actualExisting)
          Adds ids actually read from the backend, and mark this complete.
 void flush()
          Flushes to database.
 SimpleFragment getFragmentByValue(java.io.Serializable value)
          Gets a fragment given its name.
 java.util.List<SimpleFragment> getFragmentsByValue(java.io.Serializable value)
          Gets all the fragments, if the list of children is complete.
 boolean isFlushed()
           
 void remove(java.io.Serializable id)
          Removes a known child id.
 void setIncomplete()
          Marks as incomplete.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Children

public Children(HierarchyContext hierContext,
                java.lang.String filterKey,
                boolean empty,
                java.io.Serializable mapKey,
                java.util.Map<java.io.Serializable,Children> softMap,
                java.util.Map<java.io.Serializable,Children> hardMap)
Constructs a Children cache.

It is automatically put in the soft map.

Parameters:
hierContext - the context from which to fetch hierarchy fragments
filterKey - the key to use to filter on names
empty - if the new instance is created empty
mapKey - the key to use in the following maps
softMap - the soft map, when the children are pristine
hardMap - the hard map, when there are modifications to flush
Method Detail

addExisting

public void addExisting(java.io.Serializable id)
Adds a known child.

Parameters:
id - the fragment id

addCreated

public void addCreated(java.io.Serializable id)
Adds a created child.

Parameters:
id - the fragment id

addExistingComplete

public void addExistingComplete(java.util.List<java.io.Serializable> actualExisting)
Adds ids actually read from the backend, and mark this complete.

Note that when adding a complete list of ids retrieved from the database, the deleted ids have already been removed in the result set.

Parameters:
actualExisting - the existing database ids (the list must be mutable)

setIncomplete

public void setIncomplete()
Marks as incomplete.

Called after a database operation added children with unknown ids (restore of complex properties).


remove

public void remove(java.io.Serializable id)
Removes a known child id.

Parameters:
id - the id to remove

flush

public void flush()
Flushes to database. Clears created and deleted map.

Puts this in the soft map. Caller must remove from hard map.


isFlushed

public boolean isFlushed()

getFragmentByValue

public SimpleFragment getFragmentByValue(java.io.Serializable value)
Gets a fragment given its name.

Returns null if there is no such child.

Returns SimpleFragment.UNKNOWN if there's no info about it.

Parameters:
value - the name
Returns:
the fragment, or null, or SimpleFragment.UNKNOWN

getFragmentsByValue

public java.util.List<SimpleFragment> getFragmentsByValue(java.io.Serializable value)
Gets all the fragments, if the list of children is complete.

Parameters:
value - the name to filter on, or null for all children
Returns:
the fragments, or null if the list is not known to be complete

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.