Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api
Interface DataModel

All Superinterfaces:
Serializable
All Known Implementing Classes:
DataModelImpl, SimpleDocumentModel.SimpleDataModel

public interface DataModel
extends Serializable

A data model is a concrete representation of a schema.

The schema describe the data structure and the data model object is storing concrete values according to that structure.

When the user modifies a data structure the modified fields are tracked so that at any time you can query about the dirty state of the data model by using the isDirty() and isDirty(String) methods.

The data model can be modified only through the set methods:

This is ensuring the dirty state will be correctly updated

This is the reason why the getMap() method is returning a read only map.

Data structure are usually part of a composite model as the DocumentModel.

Author:
Bogdan Stefanescu

Method Summary
 Object getData(String key)
          Gets the named field value.
 Collection<String> getDirtyFields()
          Gets the collection of the dirty fields in this data model.
 Map<String,Object> getMap()
          Gets all the fields set in this data model.
 String getSchema()
          Gets the schema of this data model.
 Object getValue(String path)
          Gets a value given its path.
 boolean isDirty()
          Tests whether or not this data model is dirty (i.e.
 boolean isDirty(String name)
          Tests whether or not the specified field from this data model is dirty.
 void setData(String key, Object value)
          Sets the name field.
 void setDirty(String name)
          Marks the specified field from this data model as dirty.
 void setMap(Map<String,Object> data)
          Sets several field at once.
 Object setValue(String path, Object value)
          Sets a value to a property given its path.
 

Method Detail

getSchema

String getSchema()
Gets the schema of this data model.

Returns:
the data model schema

setData

void setData(String key,
             Object value)
             throws PropertyException
Sets the name field.

Parameters:
key - the field name
value - the value to set. Accept null values.
Throws:
PropertyException

getData

Object getData(String key)
               throws PropertyException
Gets the named field value.

Parameters:
key - the field key
Returns:
the value or null if no such field exists
Throws:
PropertyException

getMap

Map<String,Object> getMap()
                          throws PropertyException
Gets all the fields set in this data model.

It is not guaranteed that the returned map will contain all the fields defined by the schema. It may even be empty.

The returned map is null if the data model was not yet loaded.

Returns:
a read only map containing actual data in this object
Throws:
PropertyException

setMap

void setMap(Map<String,Object> data)
            throws PropertyException
Sets several field at once.

Parameters:
data - the fields to set as a map
Throws:
PropertyException

isDirty

boolean isDirty()
Tests whether or not this data model is dirty (i.e. it was changed by the client).

Returns:
true if the data model is dirty, false otherwise

isDirty

boolean isDirty(String name)
                throws PropertyNotFoundException
Tests whether or not the specified field from this data model is dirty.

Parameters:
name - the field name to tests
Returns:
true if the field is dirty, false otherwise
Throws:
PropertyNotFoundException

setDirty

void setDirty(String name)
              throws PropertyNotFoundException
Marks the specified field from this data model as dirty.

Parameters:
name - the field name to be dirty
Throws:
PropertyNotFoundException

getDirtyFields

Collection<String> getDirtyFields()
Gets the collection of the dirty fields in this data model.

Returns:
the dirty fields or null if there are no dirty fields

getValue

Object getValue(String path)
                throws PropertyException
Gets a value given its path.

The path is a subset of XPath: / and [] are supported.

Parameters:
path - the property path
Returns:
Throws:
PropertyException

setValue

Object setValue(String path,
                Object value)
                throws PropertyException
Sets a value to a property given its path.

Parameters:
path -
value -
Returns:
Throws:
PropertyException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.