public class PersistenceContext extends Object
All non-saved modified data is referenced here. At save time, the data is
sent to the database by the Mapper
. The database will at some time
later be committed by the external transaction manager in effect.
Internally a fragment can be in at most one of the "pristine" or "modified" map. After a save() all the fragments are pristine, and may be partially invalidated after commit by other local or clustered contexts that committed too.
Depending on the table, the context may hold SimpleFragment
s, which
represent one row, CollectionFragment
s, which represent several rows.
This class is not thread-safe, it should be tied to a single session and the session itself should not be used concurrently.
Modifier and Type | Class and Description |
---|---|
static class |
PersistenceContext.PathAndId |
Modifier and Type | Field and Description |
---|---|
SelectionContext |
hierNonComplex |
Constructor and Description |
---|
PersistenceContext(Model model,
RowMapper mapper,
SessionImpl session) |
Modifier and Type | Method and Description |
---|---|
void |
addedProxyTarget(SimpleFragment fragment) |
Serializable |
checkIn(Node node,
String label,
String checkinComment)
Checks in a node (creates a version).
|
void |
checkInvalidationsConflict() |
void |
checkOut(Node node)
Checks out a node.
|
Serializable |
copy(Node source,
Serializable parentId,
String name)
Copy a child to a new parent with a new name.
|
void |
createdProxyFragment(SimpleFragment fragment) |
SimpleFragment |
createHierarchyFragment(Row row) |
SimpleFragment |
getChildHierByName(Serializable parentId,
String name,
boolean complexProp) |
List<SimpleFragment> |
getChildren(Serializable parentId,
String name,
boolean complexProp)
Gets hier fragments for children.
|
Serializable |
getContainingDocument(Serializable id)
Finds the id of the enclosing non-complex-property node.
|
List<Fragment> |
getMulti(Collection<RowId> rowIds,
boolean allowAbsent)
Gets a list of fragments.
|
Long |
getNextPos(Serializable nodeId,
boolean complexProp)
Gets the next pos value for a new child in a folder.
|
String |
getPath(SimpleFragment hierFragment)
Gets the path by recursing up the hierarchy.
|
PersistenceContext.PathAndId |
getPathOrMissingParentId(SimpleFragment hierFragment,
boolean fetch)
Gets the full path, or the closest parent id which we don't have in
cache.
|
List<Serializable> |
getSeriesProxyIds(Serializable versionSeriesId) |
List<Serializable> |
getTargetProxyIds(Serializable targetId) |
List<Serializable> |
getVersionIds(Serializable versionSeriesId)
Gets the version ids for a version series, ordered by creation time.
|
boolean |
isDeleted(Serializable id)
Recursively checks if any of a fragment's parents has been deleted.
|
void |
move(Node source,
Serializable parentId,
String name)
Move a child to a new parent with a new name.
|
void |
orderBefore(Serializable parentId,
Serializable sourceId,
Serializable destId)
Order a child before another.
|
void |
processReceivedInvalidations()
Applies all invalidations accumulated.
|
void |
recomputeVersionSeries(Serializable versionSeriesId)
Recomputes isLatest / isLatestMajor on all versions.
|
void |
removedProxyTarget(SimpleFragment fragment) |
void |
removeFragment(Fragment fragment,
boolean primary)
Deletes a fragment from the context.
|
void |
removeNode(SimpleFragment hierFragment)
Removes a document node and its children.
|
void |
removePropertyNode(SimpleFragment hierFragment)
Removes a property node and its children.
|
void |
restoreVersion(Node node,
Node version)
Restores a node to a given version.
|
void |
sendInvalidationsToOthers()
Post-transaction invalidations notification.
|
public final SelectionContext hierNonComplex
public PersistenceContext(Model model, RowMapper mapper, SessionImpl session) throws StorageException
StorageException
public void sendInvalidationsToOthers() throws StorageException
Called post-transaction by session commit/rollback or transactionless save.
StorageException
public void processReceivedInvalidations() throws StorageException
Called pre-transaction by start or transactionless save;
StorageException
public void checkInvalidationsConflict()
public List<Fragment> getMulti(Collection<RowId> rowIds, boolean allowAbsent) throws StorageException
If a fragment is not in the context, fetch it from the mapper. If it's not in the database, use an absent fragment or skip it.
Deleted fragments are skipped.
id
- the fragment idallowAbsent
- true
to return an absent fragment as an object
instead of skipping itnull
s)StorageException
public SimpleFragment createHierarchyFragment(Row row) throws StorageException
StorageException
public void createdProxyFragment(SimpleFragment fragment) throws StorageException
StorageException
public void removedProxyTarget(SimpleFragment fragment) throws StorageException
StorageException
public void addedProxyTarget(SimpleFragment fragment) throws StorageException
StorageException
public void removePropertyNode(SimpleFragment hierFragment) throws StorageException
There's less work to do than when we have to remove a generic document node (less selections, and we can assume the depth is small so recurse).
StorageException
public void removeNode(SimpleFragment hierFragment) throws StorageException
Assumes a full flush was done.
StorageException
public void removeFragment(Fragment fragment, boolean primary) throws StorageException
true
, otherwise consider that database removal will be
a cascade-induced consequence of another DELETE.StorageException
public void recomputeVersionSeries(Serializable versionSeriesId) throws StorageException
StorageException
public List<Serializable> getVersionIds(Serializable versionSeriesId) throws StorageException
StorageException
public List<Serializable> getSeriesProxyIds(Serializable versionSeriesId) throws StorageException
StorageException
public List<Serializable> getTargetProxyIds(Serializable targetId) throws StorageException
StorageException
public String getPath(SimpleFragment hierFragment) throws StorageException
StorageException
public PersistenceContext.PathAndId getPathOrMissingParentId(SimpleFragment hierFragment, boolean fetch) throws StorageException
If fetch
is true
, returns the full path.
If fetch
is false
, does not touch the mapper, only the
context, therefore may return a missing parent id instead of the path.
fetch
- true
if we can use the database, false
if
only caches should be usedStorageException
public Serializable getContainingDocument(Serializable id) throws StorageException
id
- the idnull
if there is no
parent or the parent has been deleted.StorageException
public boolean isDeleted(Serializable id) throws StorageException
StorageException
public Long getNextPos(Serializable nodeId, boolean complexProp) throws StorageException
nodeId
- the folder node idcomplexProp
- whether to deal with complex properties or regular
childrennull
if not orderableStorageException
public void orderBefore(Serializable parentId, Serializable sourceId, Serializable destId) throws StorageException
parentId
- the parent idsourceId
- the node id to movedestId
- the node id before which to place the source node, if
null
then move the source to the endStorageException
public SimpleFragment getChildHierByName(Serializable parentId, String name, boolean complexProp) throws StorageException
StorageException
public List<SimpleFragment> getChildren(Serializable parentId, String name, boolean complexProp) throws StorageException
StorageException
public void move(Node source, Serializable parentId, String name) throws StorageException
source
- the sourceparentId
- the destination parent idname
- the new nameStorageException
public Serializable copy(Node source, Serializable parentId, String name) throws StorageException
source
- the source of the copyparentId
- the destination parent idname
- the new nameStorageException
public Serializable checkIn(Node node, String label, String checkinComment) throws StorageException
node
- the node to check inlabel
- the version labelcheckinComment
- the version descriptionStorageException
public void checkOut(Node node) throws StorageException
node
- the node to check outStorageException
public void restoreVersion(Node node, Node version) throws StorageException
The restored node is checked in.
node
- the nodeversion
- the version to restore on this nodeStorageException
Copyright © 2013 Nuxeo SA. All Rights Reserved.