Nuxeo ECM Projects 5.4.3-SNAPSHOT

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

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLBaseProperty
      extended by org.nuxeo.ecm.core.storage.sql.coremodel.SQLComplexProperty
All Implemented Interfaces:
Property, PropertyContainer
Direct Known Subclasses:
SQLContentProperty, SQLDocumentLive

public class SQLComplexProperty
extends SQLBaseProperty
implements PropertyContainer

A SQLComplexProperty gives access to a wrapped SQL-level Node . This is used for documents and for complex properties.

Author:
Florent Guillaume

Field Summary
 
Fields inherited from class org.nuxeo.ecm.core.storage.sql.coremodel.SQLBaseProperty
DC_ISSUED, RELATED_TEXT_RESOURCES
 
Constructor Summary
SQLComplexProperty(Node node, ComplexType type, SQLSession session, boolean readonly)
          Creates a SQLComplexProperty to wrap a Node.
 
Method Summary
 Map<String,Object> exportFlatMap(String[] schemas)
          Exports a flat view of properties in this document.
 Map<String,Object> exportMap(String schemaName)
           
 Map<String,Map<String,Object>> exportMap(String[] schemas)
          Exports the properties belonging to the given schemas as a java Map.
 boolean getBoolean(String name)
          Gets the value of a scalar property as a boolean.
 Blob getContent(String name)
          Gets the value of the named content property.
 Calendar getDate(String name)
          Gets the value of a scalar property as a date.
 List<String> getDirtyFields()
          Returns fields that were modified.
 double getDouble(String name)
          Gets the value of a scalar property as a double.
 long getLong(String name)
          Gets the value of a scalar property as a long.
 String getName()
          Gets the name used to identify this property by its container.
 Node getNode()
           
 Collection<Property> getProperties()
          Gets the collection of the children properties.
 Property getProperty(String name)
          Gets the children property given its name.
 Iterator<Property> getPropertyIterator()
          Gets an iterator over the children properties.
 Object getPropertyValue(String name)
          Generic method to retrieve a property value.
 String getString(String name)
          Gets the value of a scalar property as a string.
 Object getValue()
          Gets the value of this property.
 void importFlatMap(Map<String,Object> map)
          Imports a flat map of properties into this document.
 void importMap(Map<String,Map<String,Object>> map)
          Imports the tree properties from the given Java Map.
 boolean isPropertySet(String name)
          Checks whether this property has child property with the given name.
 void removeProperty(String name)
          Removes the property with the given name.
 void setBoolean(String name, boolean value)
          Sets the scalar property value to the given boolean value.
 void setContent(String name, Blob value)
          Sets the content property to the given value.
 void setDate(String name, Calendar value)
          Sets the scalar property value to the given date value.
 void setDouble(String name, double value)
          Set the scalar property value to the given double value.
 void setLong(String name, long value)
          Sets the scalar property value to the given long value.
 void setPropertyValue(String name, Object value)
          Generic method to set a property value.
 void setString(String name, String value)
          Sets the scalar property value to the given string value.
 void setValue(Object value)
          Sets the value of this property.
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.coremodel.SQLBaseProperty
checkWritable, getType, isNull, isSpecialSystemProperty, setNull
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLComplexProperty

public SQLComplexProperty(Node node,
                          ComplexType type,
                          SQLSession session,
                          boolean readonly)
Creates a SQLComplexProperty to wrap a Node.

Method Detail

getNode

public Node getNode()

getName

public String getName()
Description copied from interface: Property
Gets the name used to identify this property by its container.

If the container of this property is not supporting accessing properties by names, returns the empty string.

Specified by:
getName in interface Property
Returns:
the object name or the empty string if the object has no name

getValue

public Object getValue()
                throws DocumentException
Description copied from interface: Property
Gets the value of this property.

Specified by:
getValue in interface Property
Returns:
this property's value
Throws:
DocumentException

setValue

public void setValue(Object value)
              throws DocumentException
Description copied from interface: Property
Sets the value of this property.

Specified by:
setValue in interface Property
Parameters:
value - the value to set
Throws:
DocumentException

isPropertySet

public boolean isPropertySet(String name)
                      throws DocumentException
Description copied from interface: Property
Checks whether this property has child property with the given name.

Specified by:
isPropertySet in interface Property
Specified by:
isPropertySet in interface PropertyContainer
Overrides:
isPropertySet in class SQLBaseProperty
Parameters:
name - the path to test
Returns:
true if this property has children properties, false otherwise
Throws:
DocumentException - if any error occurs

getProperty

public Property getProperty(String name)
                     throws DocumentException
Description copied from interface: Property
Gets the children property given its name.

Specified by:
getProperty in interface Property
Specified by:
getProperty in interface PropertyContainer
Overrides:
getProperty in class SQLBaseProperty
Parameters:
name - the property name
Returns:
the property
Throws:
DocumentException - if any error occurs

getProperties

public Collection<Property> getProperties()
                                   throws DocumentException
Description copied from interface: Property
Gets the collection of the children properties.

Specified by:
getProperties in interface Property
Specified by:
getProperties in interface PropertyContainer
Overrides:
getProperties in class SQLBaseProperty
Returns:
an iterator over the children properties
Throws:
DocumentException - if any error occurs

getPropertyIterator

public Iterator<Property> getPropertyIterator()
                                       throws DocumentException
Description copied from interface: Property
Gets an iterator over the children properties.

Specified by:
getPropertyIterator in interface Property
Specified by:
getPropertyIterator in interface PropertyContainer
Overrides:
getPropertyIterator in class SQLBaseProperty
Returns:
an iterator over the children properties
Throws:
DocumentException - if any error occurs

exportFlatMap

public Map<String,Object> exportFlatMap(String[] schemas)
                                 throws DocumentException
Description copied from interface: PropertyContainer
Exports a flat view of properties in this document.

If the given schemas array is null then all schemas will be exported.

Specified by:
exportFlatMap in interface PropertyContainer
Returns:
Throws:
DocumentException - if any error occurs

exportMap

public Map<String,Map<String,Object>> exportMap(String[] schemas)
                                         throws DocumentException
Description copied from interface: PropertyContainer
Exports the properties belonging to the given schemas as a java Map.

If the given schemas array is null then all schemas will be exported

The properties are grouped by schemas

The property tree is recursively traversed and all property in that schema exported as entry of the Map

Specified by:
exportMap in interface PropertyContainer
Returns:
the exported properties as a java Map
Throws:
DocumentException - if any error occurs

exportMap

public Map<String,Object> exportMap(String schemaName)
                             throws DocumentException
Specified by:
exportMap in interface PropertyContainer
Throws:
DocumentException

importFlatMap

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

Specified by:
importFlatMap in interface PropertyContainer
Throws:
DocumentException - if any error occurs

importMap

public void importMap(Map<String,Map<String,Object>> map)
               throws DocumentException
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
Throws:
DocumentException - if any error occurs

getDirtyFields

public List<String> getDirtyFields()
Description copied from interface: PropertyContainer
Returns fields that were modified.

XXX AT: compatibility method for NXP-666

Specified by:
getDirtyFields in interface PropertyContainer

getPropertyValue

public Object getPropertyValue(String name)
                        throws DocumentException
Description copied from interface: PropertyContainer
Generic method to retrieve a property value.

This is a shortcut for getProperty(String).getValue()

Specified by:
getPropertyValue in interface PropertyContainer
Parameters:
name - the name of the property to set
Returns:
the property value or null if the property is not set.
Throws:
DocumentException - if any error occurs
See Also:
for the list of supported value objects

getString

public String getString(String name)
                 throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a string.

This is a shortcut for getScalar(name).getString()

Specified by:
getString in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getString()};

getBoolean

public boolean getBoolean(String name)
                   throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a boolean.

This is a shortcut for getScalar(name).getBoolean()

Specified by:
getBoolean in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getBoolean()};

getLong

public long getLong(String name)
             throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a long.

This is a shortcut for getScalar(name).getLong()

Specified by:
getLong in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getLong()};

getDouble

public double getDouble(String name)
                 throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a double.

This is a shortcut for getScalar(name).getDouble()

Specified by:
getDouble in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getDouble()};

getDate

public Calendar getDate(String name)
                 throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of a scalar property as a date.

This is a shortcut for getScalar(name).getDate()

Specified by:
getDate in interface PropertyContainer
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#getDate()};

getContent

public Blob getContent(String name)
                throws DocumentException
Description copied from interface: PropertyContainer
Gets the value of the named content property.

Specified by:
getContent in interface PropertyContainer
Throws:
DocumentException - if any error occurs

setPropertyValue

public void setPropertyValue(String name,
                             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
Parameters:
name - the name of the property to set
value - the value to set
Throws:
DocumentException - if any error occurs

setString

public void setString(String name,
                      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
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setString(String)}

setBoolean

public void setBoolean(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
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setBoolean(boolean)}

setLong

public void setLong(String name,
                    long value)
             throws DocumentException
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
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setLong(long)}

setDouble

public void setDouble(String name,
                      double value)
               throws DocumentException
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
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setDouble(double)}

setDate

public void setDate(String name,
                    Calendar value)
             throws DocumentException
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
Throws:
DocumentException - if any error occurs
See Also:
SimpleProperty#setDate(Calendar)}

setContent

public void setContent(String name,
                       Blob value)
                throws DocumentException
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
Throws:
DocumentException - if any error occurs

removeProperty

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

Specified by:
removeProperty in interface PropertyContainer
Parameters:
name - the property to remove
Throws:
DocumentException - if any error occurs

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.