public class SQLDocumentLive extends BaseDocument<Node> implements SQLDocument
BaseDocument.BlobWriteContext<T extends StateAccessor>, BaseDocument.StateBlobAccessor, BaseDocument.Visit
Document.BlobAccessor, Document.WriteContext
Modifier and Type | Field and Description |
---|---|
protected Node |
node |
protected List<Schema> |
proxySchemas
Proxy-induced types.
|
protected boolean |
readonly
Read-only flag, used to allow/disallow writes on versions.
|
protected SQLSession |
session |
protected static Map<String,String> |
systemPropNameMap |
protected Type |
type |
BLOB_DATA, BLOB_DIGEST, BLOB_ENCODING, BLOB_LENGTH, BLOB_MIME_TYPE, BLOB_NAME, DC_ISSUED, DC_PREFIX, EMPTY_STRING_ARRAY, FULLTEXT_BINARYTEXT_PROP, FULLTEXT_JOBID_PROP, FULLTEXT_SIMPLETEXT_PROP, LOCK_CREATED_PROP, LOCK_OWNER_PROP, MISC_LIFECYCLE_STATE_PROP, NO_DIRTY, NON_CANONICAL_INDEX, RELATED_TEXT, RELATED_TEXT_ID, RELATED_TEXT_RESOURCES, VERSION_WRITABLE_PROPS
BINARY_TEXT_SYS_PROP, FULLTEXT_JOBID_SYS_PROP, SIMPLE_TEXT_SYS_PROP
Modifier | Constructor and Description |
---|---|
protected |
SQLDocumentLive(Node node,
ComplexType type,
SQLSession session,
boolean readonly) |
Modifier and Type | Method and Description |
---|---|
Document |
addChild(String name,
String typeName)
Creates a new child document of the given type.
|
boolean |
addFacet(String facet)
Adds a facet to this document.
|
Document |
checkIn(String label,
String checkinComment)
Creates a new version.
|
void |
checkOut() |
boolean |
equals(Object other) |
void |
followTransition(String transition)
Follows a given life cycle transition.
|
Set<String> |
getAllFacets()
Gets the facets available on this document (from the type and the instance facets).
|
Collection<String> |
getAllowedStateTransitions()
Returns the allowed state transitions for this document.
|
Document |
getBaseVersion()
Gets the version to which a checked in document is linked.
|
String |
getCheckinComment()
Gets the version check in comment of this document if it's a version or a proxy.
|
protected Node |
getChild(Node node,
String name,
Type type)
Gets a child state.
|
Document |
getChild(String name)
Gets a child document given its name.
|
protected List<Node> |
getChildAsList(Node node,
String name)
Gets a child state which is a list.
|
protected Node |
getChildForWrite(Node node,
String name,
Type type)
Gets a child state into which we will want to write data.
|
List<Document> |
getChildren()
Gets the children of the document.
|
List<String> |
getChildrenIds()
Gets a list of the children ids.
|
protected Lock |
getDocumentLock()
Gets the lock from this recently created and unsaved document.
|
String[] |
getFacets()
Gets the facets defined on this document instance.
|
Document |
getLastVersion()
Gets the last version of this document.
|
String |
getLifeCyclePolicy()
Gets the life cycle policy of this document.
|
String |
getLifeCycleState()
Gets the life cycle state of this document.
|
String |
getName()
Gets the name of this document.
|
Node |
getNode()
Returns the node with info about the hierarchy location.
|
Document |
getParent()
Gets the parent document, or
null if this is the root document. |
String |
getPath()
Gets the path of this document.
|
Long |
getPos()
Gets the document's position in its containing folder (if ordered).
|
Serializable |
getPropertyValue(String name)
Gets a simple property value.
|
protected List<Schema> |
getProxySchemas()
Gets the list of proxy schemas, if this is a proxy.
|
String |
getRepositoryName()
Gets the repository in which the document lives.
|
SQLSession |
getSession()
Gets the session that owns this document.
|
Document |
getSourceDocument()
Gets the source for this document.
|
<T extends Serializable> |
getSystemProp(String name,
Class<T> type)
Gets a system property.
|
Document |
getTargetDocument()
Gets the document (version or live document) to which this proxy points.
|
DocumentType |
getType()
Gets the type of this document.
|
String |
getUUID()
Gets this document's UUID.
|
Object |
getValue(String xpath)
Gets a property value.
|
Document |
getVersion(String label)
Gets a version of this document, given its label.
|
Calendar |
getVersionCreationDate()
Gets the version creation date of this document if it's a version or a proxy.
|
String |
getVersionLabel()
Gets the version label.
|
List<Document> |
getVersions()
Gets the versions for this document.
|
String |
getVersionSeriesId()
Gets the version series id.
|
List<String> |
getVersionsIds()
Gets the list of version ids for this document.
|
Document |
getWorkingCopy()
Gets the working copy for this document.
|
boolean |
hasChild(String name)
Checks whether this document has a child of the given name.
|
boolean |
hasChildren()
Tests if the document has any children.
|
boolean |
hasFacet(String facet)
Checks whether this document has a given facet, either from its type or added on the instance.
|
int |
hashCode() |
protected String |
internalName(String name)
Finds the internal name to use to refer to this property.
|
boolean |
isCheckedOut()
Checks whether this document is checked out.
|
boolean |
isFolder()
Checks whether this document is a folder.
|
boolean |
isLatestMajorVersion()
Checks whether this document is the latest major version.
|
boolean |
isLatestVersion()
Checks whether this document is the latest version.
|
boolean |
isMajorVersion()
Checks whether this document is a major version.
|
boolean |
isProxy()
Checks whether or not this document is a proxy.
|
boolean |
isReadOnly()
Checks whether this document is readonly or not.
|
boolean |
isVersion()
Checks whether this document is a version document.
|
boolean |
isVersionSeriesCheckedOut()
Checks if there is a checked out working copy for the version series of this document.
|
void |
orderBefore(String src,
String dest)
Orders the given source child before the destination child.
|
void |
readDocumentPart(DocumentPart dp)
Reads into the
DocumentPart the values from this SQLDocument . |
Map<String,Serializable> |
readPrefetch(ComplexType complexType,
Set<String> xpaths)
Reads a set of prefetched fields.
|
void |
remove()
Removes this document and all its children, if any.
|
protected Lock |
removeDocumentLock(String owner)
Removes a lock from this recently created and unsaved document.
|
boolean |
removeFacet(String facet)
Removes a facet from this document.
|
void |
restore(Document version)
Replaces this document's content with the version specified.
|
void |
setCurrentLifeCycleState(String state)
Sets the life cycle state of this document.
|
protected Lock |
setDocumentLock(Lock lock)
Sets a lock on this recently created and unsaved document.
|
void |
setLifeCyclePolicy(String policy)
Sets the life cycle policy of this document.
|
void |
setPropertyValue(String name,
Serializable value)
Sets a simple property value.
|
void |
setReadOnly(boolean readonly)
Sets this document as readonly or not.
|
void |
setSystemProp(String name,
Serializable value)
Sets a system property.
|
void |
setTargetDocument(Document target)
Sets the document (version or live document) to which this proxy points.
|
void |
setValue(String xpath,
Object value)
Sets a property value.
|
String |
toString() |
protected void |
updateList(Node node,
String name,
List<Object> values,
Field field)
Update a list.
|
protected List<Node> |
updateList(Node node,
String name,
Property property)
Update a list.
|
void |
visitBlobs(Consumer<Document.BlobAccessor> blobVisitor)
Visits all the blobs of this document and calls the passed blob visitor on each one.
|
boolean |
writeDocumentPart(DocumentPart dp,
Document.WriteContext writeContext)
Writes a
DocumentPart to storage. |
canonicalXPath, checkReadOnlyIgnoredWrite, clearDirtyFlags, getBlobInfo, getLock, getValueBlob, getValueComplex, getValueField, getValueObject, getWriteContext, isVersionWritableProperty, readComplexProperty, readPrefetch, readPrefetch, readPrefetchField, removeLock, setBlobInfo, setLock, setValueBlob, setValueComplex, setValueField, setValueObject, typedArray, visitBlobs, writeComplexProperty, writeComplexProperty
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getLock, getWriteContext, removeLock, setLock
protected SQLSession session
protected final List<Schema> proxySchemas
protected boolean readonly
protected static final Map<String,String> systemPropNameMap
protected SQLDocumentLive(Node node, ComplexType type, SQLSession session, boolean readonly)
public void setReadOnly(boolean readonly)
Document
setReadOnly
in interface Document
public boolean isReadOnly()
Document
isReadOnly
in interface Document
public Node getNode()
SQLDocument
getNode
in interface SQLDocument
public String getName()
Document
public Long getPos()
Document
public DocumentType getType()
Document
public SQLSession getSession()
Document
getSession
in interface Document
public boolean isFolder()
Document
public String getUUID()
Document
public Document getParent()
Document
null
if this is the root document.public String getPath()
Document
public boolean isProxy()
Document
public String getRepositoryName()
Document
getRepositoryName
in interface Document
protected List<Schema> getProxySchemas()
BaseDocument
getProxySchemas
in class BaseDocument<Node>
null
public void remove()
Document
public void readDocumentPart(DocumentPart dp) throws PropertyException
DocumentPart
the values from this SQLDocument
.readDocumentPart
in interface Document
PropertyException
public Map<String,Serializable> readPrefetch(ComplexType complexType, Set<String> xpaths) throws PropertyException
Document
Reading data is done by ComplexType
because of per-proxy schemas.
readPrefetch
in interface Document
PropertyException
public boolean writeDocumentPart(DocumentPart dp, Document.WriteContext writeContext) throws PropertyException
Document
DocumentPart
to storage.
Writing data is done by DocumentPart
because of per-proxy schemas.
writeDocumentPart
in interface Document
true
if something changedPropertyException
protected Node getChild(Node node, String name, Type type) throws PropertyException
BaseDocument
getChild
in class BaseDocument<Node>
node
- the parent statename
- the child nametype
- the child's typenull
if it doesn't existPropertyException
protected Node getChildForWrite(Node node, String name, Type type) throws PropertyException
BaseDocument
Creates it if needed.
getChildForWrite
in class BaseDocument<Node>
node
- the parent statename
- the child nametype
- the child's typenull
PropertyException
protected List<Node> getChildAsList(Node node, String name) throws PropertyException
BaseDocument
getChildAsList
in class BaseDocument<Node>
node
- the parent statename
- the child namenull
PropertyException
protected void updateList(Node node, String name, List<Object> values, Field field) throws PropertyException
BaseDocument
updateList
in class BaseDocument<Node>
node
- the parent statename
- the child namevalues
- the valuesfield
- the list element typePropertyException
protected List<Node> updateList(Node node, String name, Property property) throws PropertyException
BaseDocument
updateList
in class BaseDocument<Node>
node
- the parent statename
- the child nameproperty
- the propertyPropertyException
protected String internalName(String name)
BaseDocument
internalName
in class BaseDocument<Node>
public Object getValue(String xpath) throws PropertyException
Document
The xpath may point to a partial path, in which case the value may be a complex List
or Map
.
getValue
in interface Document
xpath
- the xpath of the property to setnull
if the property is not setPropertyException
- if the property does not existpublic void setValue(String xpath, Object value) throws PropertyException
Document
The xpath may point to a partial path, in which case the value may be a complex List
or Map
.
setValue
in interface Document
xpath
- the xpath of the property to setvalue
- the value to setPropertyException
- if the property does not exist or the value is of the wrong typepublic void visitBlobs(Consumer<Document.BlobAccessor> blobVisitor) throws PropertyException
Document
visitBlobs
in interface Document
PropertyException
public Serializable getPropertyValue(String name)
Document
For more generic properties described by an xpath, use Document.getValue(java.lang.String)
instead.
getPropertyValue
in interface Document
name
- the name of the property to getnull
if the property is not setDocument.getValue(java.lang.String)
public void setPropertyValue(String name, Serializable value)
Document
For more generic properties described by an xpath, use Document.setValue(java.lang.String, java.lang.Object)
instead.
setPropertyValue
in interface Document
name
- the name of the property to setvalue
- the value to setDocument.setValue(java.lang.String, java.lang.Object)
public void setSystemProp(String name, Serializable value)
Document
setSystemProp
in interface Document
public <T extends Serializable> T getSystemProp(String name, Class<T> type)
Document
getSystemProp
in interface Document
public String getLifeCyclePolicy()
Document
getLifeCyclePolicy
in interface Document
public void setLifeCyclePolicy(String policy)
Document
setLifeCyclePolicy
in interface Document
policy
- the life cycle policypublic String getLifeCycleState()
Document
getLifeCycleState
in interface Document
public void setCurrentLifeCycleState(String state)
Document
setCurrentLifeCycleState
in interface Document
state
- the life cycle statepublic void followTransition(String transition) throws LifeCycleException
Document
This will update the life cycle state of the document.
followTransition
in interface Document
transition
- the name of the transition to followLifeCycleException
public Collection<String> getAllowedStateTransitions()
Document
getAllowedStateTransitions
in interface Document
public boolean isVersion()
Document
public Document getBaseVersion()
Document
Returns null
for a checked out document or a version or a proxy.
getBaseVersion
in interface Document
null
public String getVersionSeriesId()
Document
getVersionSeriesId
in interface Document
public Document getSourceDocument()
Document
For a version, it's the working copy.
For a proxy, it's the version the proxy points to.
getSourceDocument
in interface Document
public Document checkIn(String label, String checkinComment)
Document
public boolean isCheckedOut()
Document
isCheckedOut
in interface Document
true
if the document is checked out, or false
otherwisepublic boolean isMajorVersion()
Document
isMajorVersion
in interface Document
true
if this is a major version, or false
otherwisepublic boolean isLatestVersion()
Document
isLatestVersion
in interface Document
true
if this is the latest version, or false
otherwisepublic boolean isLatestMajorVersion()
Document
isLatestMajorVersion
in interface Document
true
if this is the latest major version, or false
otherwisepublic boolean isVersionSeriesCheckedOut()
Document
isVersionSeriesCheckedOut
in interface Document
true
if there is a checked out working copypublic String getVersionLabel()
Document
getVersionLabel
in interface Document
public String getCheckinComment()
Document
getCheckinComment
in interface Document
null
if it's not a version or a proxypublic Document getWorkingCopy()
Document
getWorkingCopy
in interface Document
public Calendar getVersionCreationDate()
Document
getVersionCreationDate
in interface Document
null
if it's not a version or a proxypublic void restore(Document version)
Document
public List<String> getVersionsIds()
Document
getVersionsIds
in interface Document
public Document getVersion(String label)
Document
getVersion
in interface Document
label
- the version labelpublic List<Document> getVersions()
Document
getVersions
in interface Document
public Document getLastVersion()
Document
Returns null
if there is no version at all.
getLastVersion
in interface Document
null
if there is no versionpublic Document getChild(String name)
Document
Throws DocumentNotFoundException
if the document could not be found.
public List<Document> getChildren()
Document
Returns an empty list for non-folder documents.
getChildren
in interface Document
public List<String> getChildrenIds()
Document
Returns an empty list for non-folder documents.
getChildrenIds
in interface Document
public boolean hasChild(String name)
Document
Returns false
for non-folder documents.
public boolean hasChildren()
Document
Returns false
for non-folder documents.
hasChildren
in interface Document
true
if the document has children, false
otherwisepublic Document addChild(String name, String typeName)
Document
Throws an error if this document is not a folder.
public void orderBefore(String src, String dest)
Document
Both source and destination must be names that point to child documents of this document. The source document
will be placed before the destination one. If destination is null
, the source document will be appended
at the end of the children list.
orderBefore
in interface Document
src
- the document to movedest
- the document before which to place the source documentpublic Set<String> getAllFacets()
Document
getAllFacets
in interface Document
public String[] getFacets()
Document
public boolean hasFacet(String facet)
Document
public boolean addFacet(String facet)
Document
Does nothing if the facet was already present on the document.
public boolean removeFacet(String facet)
Document
It's not possible to remove a facet coming from the document type.
removeFacet
in interface Document
facet
- the facet nametrue
if the facet was removed, or false
if it isn't present or is present on the type or
does not exitpublic Document getTargetDocument()
Document
getTargetDocument
in interface Document
public void setTargetDocument(Document target)
Document
setTargetDocument
in interface Document
protected Lock getDocumentLock()
BaseDocument
getDocumentLock
in class BaseDocument<Node>
null
if no lock is setprotected Lock setDocumentLock(Lock lock)
BaseDocument
setDocumentLock
in class BaseDocument<Node>
lock
- the lock to setnull
if locking succeeded, or the existing lock if locking failedprotected Lock removeDocumentLock(String owner)
BaseDocument
removeDocumentLock
in class BaseDocument<Node>
null
if there was no lock or if removal succeeded, or a lock if it blocks removal due to owner
mismatchCopyright © 2015 Nuxeo SA. All rights reserved.