LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.data
Class LyFilteredObjectSource

java.lang.Object
  extended by leon.data.LyDataSource
      extended by leon.data.LyObjectSource
          extended by leon.data.LyFilteredObjectSource

public final class LyFilteredObjectSource
extends LyObjectSource

This class implements an object source with filtered datas. It allows to have a partial view of an object source by filtering its datas. For example, you can have only equipments of a network.

See Also:
LyObjectSource, LyFilter

Field Summary
static java.lang.String __VERSION
          File version
 
Fields inherited from class leon.data.LyObjectSource
GET_SIZE_CACHE_DELAY
 
Constructor Summary
LyFilteredObjectSource(LyDataSession session, LyClassInfo classInfo, LyFilter filter)
          Constructs a filtered object source.
 
Method Summary
 boolean checkObject(LyObjectId objectId)
          Tests if an object corresponding to a given object id is found in the cache of this data source.
 boolean checkObject(java.lang.Object object)
          Internal method to check validy of an object given as parameter.
 LyResponse createObject(LyObject object, LyResponseListener listener, boolean local, boolean refresh)
          Create a new object in this object source.
 LyResponse deleteObject(LyObject object, LyResponseListener listener, boolean local, boolean refresh, boolean deleteLinkedObjects)
          Delete an object of this object source.
 LyResponse deleteObjects(java.util.Vector<? extends java.lang.Object> objects, LyResponseListener listener, boolean local, boolean refresh, boolean deleteLinkedObjects)
          Delete a list of objects of this object source.
 void free()
          Free this object source.
 LyClassInfo getClassInfo()
          Retrieves the class info of this object source.
 LyFilter getFilter()
          Retrieves the filter of this object source.
 java.lang.Object getObject(LyObjectId id)
          Gets an object from this object source by the specified identifier.
 java.lang.Object getObject(LyObjectId id, boolean local)
          Gets an object from this object source by the specified identifier.
 LyResponse getObjects(java.util.Vector<LyFieldInfo> fieldInfos, LySort sort, LyFilter filter, int n, boolean local, LyResponseListener listener)
          Retrieve objects on this object source.
 LyObjectSource getObjectSource()
          Retrieves the object source (not filtered).
 int getSize(LyFilter filter, boolean local)
          Return the number of objects within this object source matching the given filter.
 void listenTo(LyDataSource dataSource)
          Associates this object source to a data source representing the physical layer.
 void load()
          Loads completely this object source.
 LyResponse loadObject(LyObjectId id, java.util.Vector<? extends LyField> fields, LyResponseListener listener)
          Method to load an object by its id from this object source.
 LyResponse loadObjects(java.util.Vector<? extends LyField> fieldInfos, LySort sort, LyFilter filter, int n, LyResponseListener listener)
          Method for loading objects on this object source.
 LyResponse reloadObject(LyObjectId id, java.util.Vector<? extends LyField> fields, LyResponseListener listener, LyClassBinding classBinding)
          Method to reload an object from its id on the associated data provider.
 void setCache(LyCache cache)
          Sets the cache of this object source.
 LyResponse setObject(LyObject object, LyResponseListener listener, boolean local, boolean refresh)
          Set an object of this object source.
 LyResponse setObjects(java.util.Vector<? extends java.lang.Object> objects, LyResponseListener listener)
          Set a list of objects of this object source.
 
Methods inherited from class leon.data.LyObjectSource
addListener, addListener, addLoadedFieldInfos, areFieldsLoaded, createObject, createObject, createObject, deleteObject, deleteObject, deleteObject, deleteObject, deleteObjects, deleteObjects, deleteObjects, deleteObjects, finalizeObject, getListener, getObject, getObjectFromPeer, getObjects, getObjects, getObjects, getPeerDataSource, getRealClassInfo, getSize, getSize, loadObject, loadObject, loadObject, loadObjects, loadObjects, notifyClassLoading, raiseError, receiveEvent, receiveResponse, recordId, rehash, reloadObject, reloadObject, reloadObject, removeError, removeListener, resetLoadedFieldInfos, setCache, setObject, setObject, setObject, setObjects, setObjects, unload, validate
 
Methods inherited from class leon.data.LyDataSource
addListener, getApplication, getCache, getDataClass, getDataProvider, getLastModified, getObject, getSize, isReadOnly, isRollBack, isSynchronous, setIgnoreErrorOnLoad, setReadOnly, setRollBack, setSynchronous, unload
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File version

See Also:
Constant Field Values
Constructor Detail

LyFilteredObjectSource

public LyFilteredObjectSource(LyDataSession session,
                              LyClassInfo classInfo,
                              LyFilter filter)
Constructs a filtered object source.

Parameters:
session - Session owner of this object source.
classInfo - Class info associated with the object source.
filter - Filter critera of this object source.
Method Detail

getClassInfo

public LyClassInfo getClassInfo()
Retrieves the class info of this object source.

Overrides:
getClassInfo in class LyObjectSource
Returns:
Class info of objects within this object source.

getObjectSource

public LyObjectSource getObjectSource()
Retrieves the object source (not filtered).

Returns:
the underlying object source.

getFilter

public LyFilter getFilter()
Retrieves the filter of this object source.

Returns:
Filter used for objects within this object source.

listenTo

public void listenTo(LyDataSource dataSource)
Associates this object source to a data source representing the physical layer. This method throws an exception because a filtered object source can't listen to a data source. The events are treated by the instance of object source from where the datas are filtered.

Overrides:
listenTo in class LyObjectSource
Parameters:
dataSource - Data source to which this object source is associated.
Throws:
java.lang.IllegalStateException - If the given data source is not null.

setCache

public void setCache(LyCache cache)
Sets the cache of this object source. For a filtered object source, this method always throws an exception : there is no cache for a filtered object source. The objects are managed by the instance of LyObjectSource from where the datas are filtered.

Parameters:
cache - Cache to associate to this object source.
Throws:
java.lang.IllegalStateException - If the given cache is not null.

free

public void free()
Free this object source. After calling this method, you must not attempt to access data with this object source.

Overrides:
free in class LyObjectSource

load

public void load()
Loads completely this object source. For a filtering object source, this method does nothing because there is no associated cache.

Overrides:
load in class LyObjectSource

getObject

public java.lang.Object getObject(LyObjectId id)
Gets an object from this object source by the specified identifier. The object is returned only if it matches the filter of this object source.

Overrides:
getObject in class LyObjectSource
Parameters:
id - Object identifier of the searched object.
Returns:
The requested object if it was found, or null if it could not be found or if the found object doesn't match the filter of this object source.

getObject

public java.lang.Object getObject(LyObjectId id,
                                  boolean local)
Gets an object from this object source by the specified identifier. The object is returned only if it matches the filter of this object source.

Overrides:
getObject in class LyObjectSource
Parameters:
id - Object identifier of the searched object.
local - Indicates if the request must be local or not.
Returns:
The requested object if it was found, or null if it could not be found or if the found object doesn't match the filter of this object source.

getSize

public int getSize(LyFilter filter,
                   boolean local)
Return the number of objects within this object source matching the given filter. The specified filter is merged with the filter of this object source.

Overrides:
getSize in class LyObjectSource
Parameters:
filter - Filter applied on objects for counting.
local - Indicates if the request must be local or not.
Returns:
Number of objects matching the given filter in this object source.

createObject

public LyResponse createObject(LyObject object,
                               LyResponseListener listener,
                               boolean local,
                               boolean refresh)
Create a new object in this object source. Redirects creation on the object source on which this object source is plugged.

Overrides:
createObject in class LyObjectSource
Parameters:
object - Object to create.
listener - Listener of the response.
local - Indicates if the creation is local or not.
refresh - Indicates if the creation may be notified or not.
Returns:
Response to the creation.
Throws:
java.lang.IllegalStateException - If the object source is in read only mode.

setObject

public LyResponse setObject(LyObject object,
                            LyResponseListener listener,
                            boolean local,
                            boolean refresh)
Set an object of this object source. Redirects modification on the object source on which this object source is plugged.

Overrides:
setObject in class LyObjectSource
Parameters:
object - Object to modify.
listener - Listener of the response.
local - Indicates if the modification must be local or not.
refresh - Indicates if the modification may be notified or not.
Returns:
Response to the modification.
Throws:
java.lang.IllegalStateException - If the object source is in read only mode.
java.lang.IllegalArgumentException - If the given object is invalid.

setObjects

public LyResponse setObjects(java.util.Vector<? extends java.lang.Object> objects,
                             LyResponseListener listener)
Set a list of objects of this object source. Redirects modifications on the object source on which this object source is plugged.

Overrides:
setObjects in class LyObjectSource
Parameters:
object - List of objects to modify.
listener - Listener of the response.
Returns:
Response to the modification.
Throws:
java.lang.IllegalStateException - If the object source is in read only mode.
java.lang.IllegalArgumentException - If one of the given objects is invalid.

deleteObject

public LyResponse deleteObject(LyObject object,
                               LyResponseListener listener,
                               boolean local,
                               boolean refresh,
                               boolean deleteLinkedObjects)
Delete an object of this object source. Redirects deletion on the object source on which this object source is plugged.

Parameters:
object - Object to delete.
listener - Listener of the response.
local - Indicates if the operation must be local or not.
refresh - Indicates if the operaton may be notified or not.
deleteLinkObjects - Indicates if linked objects (composition relations, ...) must be deleted or not.
Returns:
Response to the deletion.
Throws:
java.lang.IllegalStateException - If the object source is in read only mode.
java.lang.IllegalArgumentException - If the given object is invalid.

deleteObjects

public LyResponse deleteObjects(java.util.Vector<? extends java.lang.Object> objects,
                                LyResponseListener listener,
                                boolean local,
                                boolean refresh,
                                boolean deleteLinkedObjects)
Delete a list of objects of this object source. Redirects deletions on the object source on which this object source is plugged.

Overrides:
deleteObjects in class LyObjectSource
Parameters:
objects - List of objects to delete.
listener - Listener of the response.
local - Indicates if the operation must be local or not.
refresh - Indicates if the operaton may be notified or not.
deleteLinkObjects - Indicates if linked objects (composition relations, ...) must be deleted or not.
Returns:
Response to the deletion.
Throws:
java.lang.IllegalStateException - If the object source is in read only mode.
java.lang.IllegalArgumentException - If one of the given objects is invalid.

loadObject

public LyResponse loadObject(LyObjectId id,
                             java.util.Vector<? extends LyField> fields,
                             LyResponseListener listener)
Method to load an object by its id from this object source. Redirects loading on the object source on which this object source is plugged.

Overrides:
loadObject in class LyObjectSource
Parameters:
id - Object identifier corresponding to the object to load.
listener - Listener of the response.
fields - Fields to load (null means all fields).
Returns:
Response to the loading.

loadObjects

public LyResponse loadObjects(java.util.Vector<? extends LyField> fieldInfos,
                              LySort sort,
                              LyFilter filter,
                              int n,
                              LyResponseListener listener)
Method for loading objects on this object source. Merges the given filter with the filter of this object source and redirects loadings on the object source on which this object source is plugged.

Overrides:
loadObjects in class LyObjectSource
Parameters:
sort - Gives sort criteria, or null if there is no sort (the order is the one of the physical layer).
filter - Gives filter criteria, or null if there is no filter (all objects).
n - Indicates the number of objects to load (-1 means no limit).
listener - Listener of the response.
fieldInfos - The list of the fieldInfos to load if necessary. If this parameter is null all the field infos are loaded. If the list is empty, only fields with mark id or name and fields used by sort and filter are loaded.
Returns:
Response to the loading.

getObjects

public LyResponse getObjects(java.util.Vector<LyFieldInfo> fieldInfos,
                             LySort sort,
                             LyFilter filter,
                             int n,
                             boolean local,
                             LyResponseListener listener)
Retrieve objects on this object source. Retrieve a specified number of objects sorted by a given sort and that match a given filter. Merges the given filter with the filter of this object source and redirects searchs on the object source on which this object source is plugged.

Overrides:
getObjects in class LyObjectSource
Parameters:
sort - Gives sort criteria, or null if there is no sort (the order is the one of the physical layer).
filter - Gives filter criteria, or null if there is no filter (all objects).
n - Indicates the number of objects to retrieve (-1 means no limit).
local - Indicates if the request is local (from memory) or not.
listener - Listener of the response.
fieldInfos - The list of the fieldInfos to load if necessary. If this parameter is null all the field infos are loaded. If the list is empty, only fields with mark id or name and fields used by sort and filter are loaded.
Returns:
Response to this search.

checkObject

public boolean checkObject(LyObjectId objectId)
Tests if an object corresponding to a given object id is found in the cache of this data source.

Overrides:
checkObject in class LyDataSource
Parameters:
objectId - Object id for which an object is searched.
Returns:
True if an object with the given object id is found in the cache, else false.

checkObject

public boolean checkObject(java.lang.Object object)
Internal method to check validy of an object given as parameter.

Overrides:
checkObject in class LyDataSource
Parameters:
object - Checked object.
Returns:
True if the given object is found in the cache, else false.

reloadObject

public LyResponse reloadObject(LyObjectId id,
                               java.util.Vector<? extends LyField> fields,
                               LyResponseListener listener,
                               LyClassBinding classBinding)
Method to reload an object from its id on the associated data provider. Load fields of an object from a given object id.

Overrides:
reloadObject in class LyDataSource
Parameters:
id - Object identifier corresponding to the object to reload.
fields - Fields to load (null means all fields).
listener - Listener of the response.
classBinding - binding between logical class and physical class This binding may contain extra information required for encoding the request.
Returns:
Response to the loading.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com