lumis.doui.source
Class AbstractObjectDataProvider<S extends TabularSource,T>

Package class diagram package AbstractObjectDataProvider
java.lang.Object
  extended by lumis.doui.source.AbstractObjectDataProvider<S,T>
Type Parameters:
S - the source class using this provider. If there is no need for source specialization, may be just TabularSource.
T - the class or interface the object's properties accessor methods will be accessed through.
All Implemented Interfaces:
IDataProvider<S>
Direct Known Subclasses:
ClusterConfigDataProvider, DatabaseViewFieldByGroupDataProvider, MailConfigDataProvider, RegistrationManagementInterfaceDataProvider

@StableMinor(version="6.2",
             sinceVersion="4.0")
public abstract class AbstractObjectDataProvider<S extends TabularSource,T>
extends Object
implements IDataProvider<S>

Implements a provider for objects whose properties follows the java bean accessor methods convention.

The fields id in the source definition are used as the object's properties names. For each one, its getter method is queried in the loaded object, and the value is used to populate a tabular data for the source.

Since:
4.0.4

Field Summary
 
Fields inherited from interface lumis.doui.source.IDataProvider
INTERFACE_INSTANCE_PROPERTY_FIELDS, INTERFACE_INSTANCE_PROPERTY_FILTERS, INTERFACE_INSTANCE_PROPERTY_MAX_ROWS, INTERFACE_INSTANCE_PROPERTY_ORDER_BY, MAX_NUM_ORDER_BY_FIELDS
 
Constructor Summary
AbstractObjectDataProvider(Class<? extends T> objectClass)
          Creates a new object data provider for objects of the given class or interface.
 
Method Summary
protected  int getTotalRows(SessionConfig sessionConfig, S source, ITransaction transaction)
          Returns the total rows to be set on the generated tabular data.
 void loadData(SessionConfig sessionConfig, S source, ITransaction transaction)
           
protected abstract  List<T> loadObjects(SessionConfig sessionConfig, S source, ITransaction transaction)
          Loads the objects.
protected  Object readProperty(T object, String propertyName)
          Reads the property value of an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractObjectDataProvider

public AbstractObjectDataProvider(Class<? extends T> objectClass)
Creates a new object data provider for objects of the given class or interface.

Parameters:
objectClass - the class or interface that contains the methods to read the object's properties.
Since:
4.0.4
Method Detail

loadObjects

protected abstract List<T> loadObjects(SessionConfig sessionConfig,
                                       S source,
                                       ITransaction transaction)
                                throws PortalException
Loads the objects. The properties of the objects returned will be used to populate the source's tabular data.

Parameters:
sessionConfig - the user session information.
source - the source that will be populated.
transaction - the transaction for persistence access.
Returns:
a list of objects with the data to populate the source.
Throws:
PortalException
Since:
4.0.4
See Also:
#getTotalRows(SessionConfig, TabularSource, ITransaction)}

getTotalRows

protected int getTotalRows(SessionConfig sessionConfig,
                           S source,
                           ITransaction transaction)
                    throws PortalException
Returns the total rows to be set on the generated tabular data.

If the value returned is a negative value, the total rows on the tabular data is not set. This is the default implementation.

Parameters:
sessionConfig - the user session information.
source - the source that will be populated.
transaction - the transaction for persistence access.
Returns:
the total rows to be set on the generated tabular data, or a negative value if it should not be set.
Throws:
PortalException
Since:
4.0.5

loadData

public void loadData(SessionConfig sessionConfig,
                     S source,
                     ITransaction transaction)
              throws PortalException
Specified by:
loadData in interface IDataProvider<S extends TabularSource>
Throws:
PortalException

readProperty

protected Object readProperty(T object,
                              String propertyName)
                       throws UnexpectedException
Reads the property value of an object.

If the propertyName is propertyName, this method tries to read the value from methods named getPropertyName or isPropertyName, with no parameters.

Parameters:
object - the object instance.
propertyName - the property name.
Returns:
the property value or null if its accessor method could not be accessed.
Throws:
UnexpectedException - if there was an exception thrown by the accessor method.
Since:
4.0.4


Lumisportal  6.2.0.120405 - Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.