Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.core.storage.sql.coremodel
Class SQLDocumentVersion

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLBaseProperty
      extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexProperty
          extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocumentLive
              extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocumentVersion
All Implemented Interfaces:
Document, DocumentContainer, Lockable, Property, PropertyContainer, SQLDocument, VersionableDocument

public class SQLDocumentVersion
extends SQLDocumentLive

Author:
Florent Guillaume

Nested Class Summary
static class SQLDocumentVersion.VersionNotModifiableException
           
 
Field Summary
 
Fields inherited from interface org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocument
BINARY_TEXT_SYS_PROP
 
Method Summary
 Document addChild(java.lang.String name, java.lang.String typeName)
          Creates a new child document given its typename.
 Document checkIn(java.lang.String label, java.lang.String description)
          Creates a new version.
 void checkOut()
           
 boolean equals(java.lang.Object other)
           
 Document getBaseVersion()
          Gets the version to which a checked in document is linked.
 Document getChild(java.lang.String name)
          Gets a child document given its name.
 java.util.Iterator<Document> getChildren()
          Gets an iterator over the children of the document.
 java.util.List<java.lang.String> getChildrenIds()
          Gets a list of the children ids.
 Document getLastVersion()
          Gets the last version of this document.
 Document getParent()
          Gets the parent document or null if this is the root document.
 java.lang.String getPath()
          Gets the path of this document.
 Document getSourceDocument()
          Gets the head ("live") version of this document.
 Document getVersion(java.lang.String label)
          Gets a version of this document, given its label.
 java.util.List<Document> getVersions()
           
 java.lang.String getVersionSeriesId()
          Gets the version series id.
 Document getWorkingCopy()
           
 boolean hasChild(java.lang.String name)
          Tests if the document has the named child.
 boolean hasChildren()
          Tests if the document has any children.
 int hashCode()
           
 boolean hasVersions()
          Tells the caller if this document has versions or not.
 void importFlatMap(java.util.Map<java.lang.String,java.lang.Object> map)
          Imports a flat map of properties into this document.
 void importMap(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> map)
          Imports the tree properties from the given Java Map.
 boolean isCheckedOut()
           
 boolean isFolder()
          Tests whether this document represent a folder or a leaf document.
 boolean isLatestMajorVersion()
           
 boolean isLatestVersion()
           
 boolean isMajorVersion()
           
 boolean isVersion()
          Checks whether or not this doc is a version document.
 boolean isVersionSeriesCheckedOut()
           
 void orderBefore(java.lang.String src, java.lang.String dest)
          Orders the given source child before the destination child.
 void removeChild(java.lang.String name)
          Removes the child having the given name If this is not a folder does nothing.
 void removeProperty(java.lang.String name)
          Removes the property with the given name.
 void restore(Document version)
          Replaces current version with version specified.
 void setBoolean(java.lang.String name, boolean value)
          Sets the scalar property value to the given boolean value.
 void setContent(java.lang.String name, Blob value)
          Sets the content property to the given value.
 void setDate(java.lang.String name, java.util.Calendar value)
          Sets the scalar property value to the given date value.
 void setDouble(java.lang.String name, double value)
          Set the scalar property value to the given double value.
 void setLong(java.lang.String name, long value)
          Sets the scalar property value to the given long value.
 void setPropertyValue(java.lang.String name, java.lang.Object value)
          Generic method to set a property value.
 void setString(java.lang.String name, java.lang.String value)
          Sets the scalar property value to the given string value.
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocumentLive
followTransition, getACLProperty, getAllowedStateTransitions, getCheckinComment, getChildren, getLastModified, getLifeCyclePolicy, getLifeCycleState, getLock, getRepository, getSession, getSystemProp, getType, getUUID, getVersionCreationDate, getVersionLabel, getVersionsIds, isLocked, isProxy, readDocumentPart, remove, resolvePath, save, setCurrentLifeCycleState, setLifeCyclePolicy, setLock, setSystemProp, toString, unlock, writeDocumentPart
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexProperty
exportFlatMap, exportMap, exportMap, getBoolean, getContent, getDate, getDirtyFields, getDouble, getLong, getName, getNode, getProperties, getProperty, getPropertyIterator, getPropertyValue, getString, getValue, isPropertySet, setValue
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.coremodel.SQLBaseProperty
checkWritable, isNull, setNull
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nuxeo.ecm.core.storage.sql.coremodel.SQLDocument
checkWritable, getNode
 
Methods inherited from interface org.nuxeo.ecm.core.model.Document
getName
 
Methods inherited from interface org.nuxeo.ecm.core.model.PropertyContainer
exportFlatMap, exportMap, exportMap, getBoolean, getContent, getDate, getDirtyFields, getDouble, getLong, getProperties, getProperty, getPropertyIterator, getPropertyValue, getString, isPropertySet
 
Methods inherited from interface org.nuxeo.ecm.core.model.Property
getName, getProperties, getProperty, getPropertyIterator, getValue, isNull, isPropertySet, setNull, setValue
 

Method Detail

isVersion

public boolean isVersion()
Description copied from interface: VersionableDocument
Checks whether or not this doc is a version document.

Specified by:
isVersion in interface VersionableDocument
Overrides:
isVersion in class SQLDocumentLive
Returns:
true if it's a version, false otherwise

isCheckedOut

public boolean isCheckedOut()
                     throws DocumentException
Specified by:
isCheckedOut in interface VersionableDocument
Overrides:
isCheckedOut in class SQLDocumentLive
Throws:
DocumentException

isVersionSeriesCheckedOut

public boolean isVersionSeriesCheckedOut()
                                  throws DocumentException
Specified by:
isVersionSeriesCheckedOut in interface VersionableDocument
Overrides:
isVersionSeriesCheckedOut in class SQLDocumentLive
Throws:
DocumentException

isMajorVersion

public boolean isMajorVersion()
                       throws DocumentException
Specified by:
isMajorVersion in interface VersionableDocument
Overrides:
isMajorVersion in class SQLDocumentLive
Throws:
DocumentException

isLatestVersion

public boolean isLatestVersion()
                        throws DocumentException
Specified by:
isLatestVersion in interface VersionableDocument
Overrides:
isLatestVersion in class SQLDocumentLive
Throws:
DocumentException

isLatestMajorVersion

public boolean isLatestMajorVersion()
                             throws DocumentException
Specified by:
isLatestMajorVersion in interface VersionableDocument
Overrides:
isLatestMajorVersion in class SQLDocumentLive
Throws:
DocumentException

getWorkingCopy

public Document getWorkingCopy()
                        throws DocumentException
Specified by:
getWorkingCopy in interface VersionableDocument
Overrides:
getWorkingCopy in class SQLDocumentLive
Throws:
DocumentException

getBaseVersion

public Document getBaseVersion()
                        throws DocumentException
Description copied from interface: VersionableDocument
Gets the version to which a checked in document is linked.

Returns null for a checked out document or a version or a proxy.

Specified by:
getBaseVersion in interface VersionableDocument
Overrides:
getBaseVersion in class SQLDocumentLive
Returns:
the version, or null
Throws:
DocumentException

getVersionSeriesId

public java.lang.String getVersionSeriesId()
                                    throws DocumentException
Description copied from interface: VersionableDocument
Gets the version series id.

Specified by:
getVersionSeriesId in interface VersionableDocument
Overrides:
getVersionSeriesId in class SQLDocumentLive
Returns:
the version series id
Throws:
DocumentException

getSourceDocument

public Document getSourceDocument()
                           throws DocumentException
Description copied from interface: VersionableDocument
Gets the head ("live") version of this document.

Specified by:
getSourceDocument in interface VersionableDocument
Overrides:
getSourceDocument in class SQLDocumentLive
Returns:
Throws:
DocumentException

getPath

public java.lang.String getPath()
                         throws DocumentException
Description copied from interface: Document
Gets the path of this document.

Specified by:
getPath in interface Document
Overrides:
getPath in class SQLDocumentLive
Returns:
the path
Throws:
DocumentException

getParent

public Document getParent()
                   throws DocumentException
Description copied from interface: Document
Gets the parent document or null if this is the root document.

Specified by:
getParent in interface Document
Overrides:
getParent in class SQLDocumentLive
Returns:
the parent document or null if this is the root document
Throws:
DocumentException

isFolder

public boolean isFolder()
Description copied from interface: Document
Tests whether this document represent a folder or a leaf document.

Specified by:
isFolder in interface Document
Overrides:
isFolder in class SQLDocumentLive
Returns:
true if the document is a folder document, false otherwise

removeChild

public void removeChild(java.lang.String name)
                 throws DocumentException
Description copied from interface: DocumentContainer
Removes the child having the given name

If this is not a folder does nothing.

If this is a folder and no child exists with the given name then throws an exception

Specified by:
removeChild in interface DocumentContainer
Overrides:
removeChild in class SQLDocumentLive
Parameters:
name - the child name
Throws:
DocumentException

orderBefore

public void orderBefore(java.lang.String src,
                        java.lang.String dest)
                 throws DocumentException
Description copied from interface: DocumentContainer
Orders the given source child before the destination child. Both source and destination must be names that point to child documents of the current 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.

Specified by:
orderBefore in interface DocumentContainer
Overrides:
orderBefore in class SQLDocumentLive
Parameters:
src - the document to move
dest - the document before which to place the source document
Throws:
DocumentException - if this document is not an orderable folder or any other exception occurs

addChild

public Document addChild(java.lang.String name,
                         java.lang.String typeName)
                  throws DocumentException
Description copied from interface: DocumentContainer
Creates a new child document given its typename.

This operation throws an error if the current document is not a folder.

Specified by:
addChild in interface DocumentContainer
Overrides:
addChild in class SQLDocumentLive
Parameters:
name - the name of the new child to create
typeName - the type of the child to create
Returns:
the newly created document
Throws:
DocumentException

getChild

public Document getChild(java.lang.String name)
                  throws DocumentException
Description copied from interface: DocumentContainer
Gets a child document given its name.

Throws an exception if the document could not be found.

If the supplied name is null, returns the default child of the document if any, otherwise raises an exception.

Specified by:
getChild in interface DocumentContainer
Overrides:
getChild in class SQLDocumentLive
Parameters:
name - the name of the child to retrieve
Returns:
the named child if exists, raises a NoSuchDocumentException otherwise
Throws:
DocumentException

getChildren

public java.util.Iterator<Document> getChildren()
                                         throws DocumentException
Description copied from interface: DocumentContainer
Gets an iterator over the children of the document.

This operation silently ignores non-folder documents: if the document is not a folder then it returns an empty iterator.

Specified by:
getChildren in interface DocumentContainer
Overrides:
getChildren in class SQLDocumentLive
Returns:
the children iterator
Throws:
DocumentException

getChildrenIds

public java.util.List<java.lang.String> getChildrenIds()
                                                throws DocumentException
Description copied from interface: DocumentContainer
Gets a list of the children ids.

Specified by:
getChildrenIds in interface DocumentContainer
Overrides:
getChildrenIds in class SQLDocumentLive
Returns:
a list of children ids.
Throws:
DocumentException

hasChild

public boolean hasChild(java.lang.String name)
                 throws DocumentException
Description copied from interface: DocumentContainer
Tests if the document has the named child.

This operation silently ignores non-folder documents: If the document is not a folder then return false.

Specified by:
hasChild in interface DocumentContainer
Overrides:
hasChild in class SQLDocumentLive
Parameters:
name - the name of the child to test
Returns:
true if the named child exists, false otherwise
Throws:
DocumentException

hasChildren

public boolean hasChildren()
                    throws DocumentException
Description copied from interface: DocumentContainer
Tests if the document has any children.

This operation silently ignores non-folder documents: If the document is not a folder then returns false.

Specified by:
hasChildren in interface DocumentContainer
Overrides:
hasChildren in class SQLDocumentLive
Returns:
true if document has children, false otherwise
Throws:
DocumentException

checkIn

public Document checkIn(java.lang.String label,
                        java.lang.String description)
Description copied from interface: VersionableDocument
Creates a new version.

Specified by:
checkIn in interface VersionableDocument
Overrides:
checkIn in class SQLDocumentLive
Parameters:
label - the version label
description - the checkin comment
Returns:
the created version

checkOut

public void checkOut()
Specified by:
checkOut in interface VersionableDocument
Overrides:
checkOut in class SQLDocumentLive

restore

public void restore(Document version)
Description copied from interface: VersionableDocument
Replaces current version with version specified.

Specified by:
restore in interface VersionableDocument
Overrides:
restore in class SQLDocumentLive
Parameters:
version - the version to replace with

getVersion

public Document getVersion(java.lang.String label)
Description copied from interface: VersionableDocument
Gets a version of this document, given its label.

Specified by:
getVersion in interface VersionableDocument
Overrides:
getVersion in class SQLDocumentLive
Parameters:
label - the version label
Returns:
the version

getVersions

public java.util.List<Document> getVersions()
Specified by:
getVersions in interface VersionableDocument
Overrides:
getVersions in class SQLDocumentLive
Returns:
all versions of the document, empty list if there's no version

hasVersions

public boolean hasVersions()
Description copied from interface: VersionableDocument
Tells the caller if this document has versions or not.

Needed to know if we need to use checkin/checkout methods when changing a document.

Specified by:
hasVersions in interface VersionableDocument
Overrides:
hasVersions in class SQLDocumentLive
Returns:
true if there are versions

getLastVersion

public Document getLastVersion()
Description copied from interface: VersionableDocument
Gets the last version of this document.

Specified by:
getLastVersion in interface VersionableDocument
Overrides:
getLastVersion in class SQLDocumentLive
Returns:
the last version

importFlatMap

public void importFlatMap(java.util.Map<java.lang.String,java.lang.Object> map)
Description copied from interface: PropertyContainer
Imports a flat map of properties into this document.

Specified by:
importFlatMap in interface PropertyContainer
Overrides:
importFlatMap in class SQLComplexProperty

importMap

public void importMap(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> map)
Description copied from interface: PropertyContainer
Imports the tree properties from the given Java Map.

The property tree is recursively traversed and all property exported as entry of the Map.

Specified by:
importMap in interface PropertyContainer
Overrides:
importMap in class SQLComplexProperty

setPropertyValue

public void setPropertyValue(java.lang.String name,
                             java.lang.Object value)
                      throws DocumentException
Description copied from interface: PropertyContainer
Generic method to set a property value.

This is a shortcut for getProperty(String).setValue(Object)

The following type of objects can be used as values depending on the property type:

Specified by:
setPropertyValue in interface PropertyContainer
Overrides:
setPropertyValue in class SQLComplexProperty
Parameters:
name - the name of the property to set
value - the value to set
Throws:
DocumentException - if any error occurs

setString

public void setString(java.lang.String name,
                      java.lang.String value)
               throws DocumentException
Description copied from interface: PropertyContainer
Sets the scalar property value to the given string value.

If the property with that name doesn't exists, it will be created.

This is a shortcut to create or set string properties.

Specified by:
setString in interface PropertyContainer
Overrides:
setString in class SQLComplexProperty
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setString(String)}

setBoolean

public void setBoolean(java.lang.String name,
                       boolean value)
                throws DocumentException
Description copied from interface: PropertyContainer
Sets the scalar property value to the given boolean value.

If the property with that name doesn't exists, it will be created.

This is a shortcut to create or set boolean properties.

Specified by:
setBoolean in interface PropertyContainer
Overrides:
setBoolean in class SQLComplexProperty
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setBoolean(boolean)}

setLong

public void setLong(java.lang.String name,
                    long value)
Description copied from interface: PropertyContainer
Sets the scalar property value to the given long value.

If the property with that name doesn't exists, it will be created.

This is a shortcut to create or set long properties.

Specified by:
setLong in interface PropertyContainer
Overrides:
setLong in class SQLComplexProperty
See Also:
SimpleProperty#setLong(long)}

setDouble

public void setDouble(java.lang.String name,
                      double value)
Description copied from interface: PropertyContainer
Set the scalar property value to the given double value.

If the property with that name doesn't exists, it will be created.

This is a shortcut to create or set double properties

Specified by:
setDouble in interface PropertyContainer
Overrides:
setDouble in class SQLComplexProperty
See Also:
SimpleProperty#setDouble(double)}

setDate

public void setDate(java.lang.String name,
                    java.util.Calendar value)
Description copied from interface: PropertyContainer
Sets the scalar property value to the given date value.

If the property with that name doesn't exists, it will be created

This is a shortcut to create or set date properties.

Specified by:
setDate in interface PropertyContainer
Overrides:
setDate in class SQLComplexProperty
See Also:
SimpleProperty#setDate(Calendar)}

setContent

public void setContent(java.lang.String name,
                       Blob value)
Description copied from interface: PropertyContainer
Sets the content property to the given value.

If the property with that name doesn't exists, it will be created

Specified by:
setContent in interface PropertyContainer
Overrides:
setContent in class SQLComplexProperty

removeProperty

public void removeProperty(java.lang.String name)
Description copied from interface: PropertyContainer
Removes the property with the given name.

Specified by:
removeProperty in interface PropertyContainer
Overrides:
removeProperty in class SQLComplexProperty
Parameters:
name - the property to remove

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class SQLDocumentLive

hashCode

public int hashCode()
Overrides:
hashCode in class SQLDocumentLive

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.