org.formaria.data.pojo
Class PersistentPojoModel

java.lang.Object
  extended by org.formaria.aria.data.DataModel
      extended by org.formaria.data.pojo.PojoModel
          extended by org.formaria.data.pojo.PersistentPojoModel
Direct Known Subclasses:
HibernatePojoModel

public class PersistentPojoModel
extends PojoModel

A model node for interacting with persistent POJOs

Copyright (c) Formaria Ltd., 2008
License: see license.txt


Field Summary
 
Fields inherited from class org.formaria.data.pojo.PojoModel
adapter, collectionElements, dataSource, dirty, elIdx, getterArgTypes, getterArgValues, pojo, properties, propertyKey, propertyName
 
Fields inherited from class org.formaria.aria.data.DataModel
parentModel, tagName
 
Constructor Summary
protected PersistentPojoModel(DataModel parent, java.lang.Object pojo, PojoDataSource ds)
          Creates a new instance of PersistentPojoModel
protected PersistentPojoModel(DataModel parent, java.lang.String subPath, PojoDataSource ds)
          Creates a new instance of PersistentPojoModel
 
Method Summary
 void delete()
          Deletes the underlying POJO from the datastore, removes it from the persistent context.
 void evict()
          Removes the underlying POJO from the persistent context, this method doesn't result in any changes in the datastore.
protected  java.lang.Object getPropertyValue(PojoModel childNode)
          Gets the value returned by the specified getter method call.
protected  boolean getterRequiresTransaction(PojoModel childNode)
          Check if an active transaction is requires before invoking a getter method that is used to obtain the POJO stored in the specified model node
 void lock()
          Reassociates the encapsulated POJO with a session.
 void merge()
          Copies the state of the underlying POJO onto the persistent object with the same identifier and then sets the persistent object as the underlying POJO.
 void persist()
          Persists the underlying POJO.
protected  void setPropertyValue(PojoModel childNode, java.lang.Object value)
          Executes the setter method of the given model node
protected  boolean setterRequiresTransaction(PojoModel childNode, java.lang.Object value)
          Check if an active transaction is required before invoking a setter method that is used to obtain the POJO stored in the specified model node
 
Methods inherited from class org.formaria.data.pojo.PojoModel
append, append, clear, get, get, get, getAttribName, getAttribute, getAttribValue, getAttribValueAsDouble, getAttribValueAsDouble, getAttribValueAsInt, getAttribValueAsString, getCollectionElements, getDataSource, getElIdx, getGetterArgTypes, getGetterArgValues, getId, getNumAttributes, getNumChildren, getPojo, getPropertyKey, getPropertyName, getValueAsDouble, getValueAsInt, getValueAsString, hasAutoId, hashCode, hasSetter, isAlwaysDirty, isCollection, isDirty, isTransient, isTransient, markSubtreeAsAlwaysDirty, markSubtreeAsDirty, retrieveModelNode, saveModelNode, set, set, setAlwaysDirty, setAttribValue, setAttribValue, setDirty, setId, setNumChildren, setPojo, sync
 
Methods inherited from class org.formaria.aria.data.DataModel
addModelListener, fireModelUpdated, getParent, getTagName, hasAutoId, prefixOutputPath, removeChildren, reset, resetAttributes, setNumAttributes, setParent, setTagName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistentPojoModel

protected PersistentPojoModel(DataModel parent,
                              java.lang.String subPath,
                              PojoDataSource ds)
Creates a new instance of PersistentPojoModel

Parameters:
parent - the parent model node
subPath - String in the format: propertyName(property arguments)[collection idx] as it appears in a binding path
ds - the data source object.

PersistentPojoModel

protected PersistentPojoModel(DataModel parent,
                              java.lang.Object pojo,
                              PojoDataSource ds)
Creates a new instance of PersistentPojoModel

Parameters:
parent - the parent model node
ds - the data source object.
Method Detail

getterRequiresTransaction

protected boolean getterRequiresTransaction(PojoModel childNode)
Check if an active transaction is requires before invoking a getter method that is used to obtain the POJO stored in the specified model node

Parameters:
childNode - the POJO model node whose getter is to be queried
Returns:
true if an active transaction is required, false otherwise

setterRequiresTransaction

protected boolean setterRequiresTransaction(PojoModel childNode,
                                            java.lang.Object value)
Check if an active transaction is required before invoking a setter method that is used to obtain the POJO stored in the specified model node

Parameters:
childNode - the POJO model node whose setter is to be queried
value - the value of the setter argument
Returns:
true if an active transaction is required, false otherwise

setPropertyValue

protected void setPropertyValue(PojoModel childNode,
                                java.lang.Object value)
Executes the setter method of the given model node

Overrides:
setPropertyValue in class PojoModel
Parameters:
childNode - the model node whose getter is to be invoked
value - the object to be passed as an argument to the setter call

getPropertyValue

protected java.lang.Object getPropertyValue(PojoModel childNode)
Gets the value returned by the specified getter method call.

Overrides:
getPropertyValue in class PojoModel
Parameters:
childNode - the model node whose getter is to be called.
Returns:
object returned by the getter method call.

persist

public void persist()
Persists the underlying POJO.


merge

public void merge()
Copies the state of the underlying POJO onto the persistent object with the same identifier and then sets the persistent object as the underlying POJO.


lock

public void lock()
Reassociates the encapsulated POJO with a session. This method doesn't result in any changes to the data store.


delete

public void delete()
Deletes the underlying POJO from the datastore, removes it from the persistent context.


evict

public void evict()
Removes the underlying POJO from the persistent context, this method doesn't result in any changes in the datastore.