LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.data
Class LyExtendObjectSource

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

public class LyExtendObjectSource
extends LyObjectSource

An extends object source is associated to a logical class (LyClassInfo) which has derived classes.

Objects sources are associated to data sources to dispatch demands on the underlying physical layer when requests are made for logical objects.

See Also:
LyObject, LyClassInfo

Field Summary
static java.lang.String __VERSION
          File version
 
Fields inherited from class leon.data.LyObjectSource
GET_SIZE_CACHE_DELAY
 
Constructor Summary
LyExtendObjectSource(LyDataProvider provider, LyClassInfo classInfo)
          Constructs an extends object source for a given class info.
LyExtendObjectSource(LyDataProvider provider, LyClassInfo classInfo, LyObjectSource objectSource)
          Constructs an extends object source for a given class info.
 
Method Summary
 void addListener(LyDataSourceListener listener, short type)
          Registers a listener to receive events of the given type on objects contained within this data source.
 void addListener(LyDataSourceListener listener, java.util.Vector<LyField> fields)
          Registers a listener to receive modification events concerning given fields on objects contained within this data source.
 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)
          Tests if the given object is found in the cache of this data source.
 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 finalizeObject(LyObject object)
          Finalize method for an object, remove from cache
 void free()
          Free this object source.
 LyDataSourceListener getListener()
          To get the instance of LyDataSourceListener 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.
 LyObject getObject(LyObjectId id, boolean godown, boolean local)
          Gets an object from this object source by the specified identifier.
 LyObject getObjectFromPeer(java.lang.Object peer)
          Finds an object from its object peer (associated physical object).
 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()
          To get the objectSource associated with the classInfo when this classInfo is not abstract.
 LyClassInfo getRealClassInfo(LyObject object)
          Given an object id corresponding to this extend object source, compute the real classinfo (corresponding to the correct sub class.
 int getSize(LyFilter filter)
          Return the number of objects within this object source matching the given filter.
 int getSize(LyFilter filter, boolean local)
          Return the number of objects within this object source matching the given filter.
 void listenToSubClasses()
          Internal method to listen to sub-classes.
 void load()
          Loads completely this object source : loads the associated cache according to the cache policy.
 void notifyClassLoading(LyClassInfo classInfo)
          Method to notify the loading of a class to an object source.
 void setCache(LyInfoCache cachePolicy)
          Sets the cache for this object source.
 void setLoaded(boolean loaded)
          Marks the associated cache as loaded or not.
 void setLoaded(boolean loaded, boolean subClassesOnly)
          Marks the associated cache as loaded or not.
 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.
 void unload(boolean notify)
          Unloads completely this object source : unloads the associated cache and data source.
 void validate()
          To validate this objectSource.
 
Methods inherited from class leon.data.LyObjectSource
addLoadedFieldInfos, areFieldsLoaded, createObject, createObject, createObject, deleteObject, deleteObject, deleteObject, deleteObject, deleteObjects, deleteObjects, deleteObjects, deleteObjects, getClassInfo, getObject, getObjects, getObjects, getObjects, getPeerDataSource, getSize, listenTo, loadObject, loadObject, loadObject, loadObject, loadObjects, loadObjects, loadObjects, raiseError, receiveEvent, receiveResponse, recordId, rehash, reloadObject, reloadObject, reloadObject, removeError, removeListener, resetLoadedFieldInfos, setObject, setObject, setObject, setObjects, setObjects
 
Methods inherited from class leon.data.LyDataSource
addListener, getApplication, getCache, getDataClass, getDataProvider, getLastModified, getObject, getSize, isReadOnly, isRollBack, isSynchronous, reloadObject, 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

LyExtendObjectSource

public LyExtendObjectSource(LyDataProvider provider,
                            LyClassInfo classInfo)
Constructs an extends object source for a given class info.

Parameters:
provider - the data provider
classInfo - Class info for which an extends object source is constructed.

LyExtendObjectSource

public LyExtendObjectSource(LyDataProvider provider,
                            LyClassInfo classInfo,
                            LyObjectSource objectSource)
Constructs an extends object source for a given class info.

Parameters:
provider - the data provider
classInfo - Class info for which an extends object source is constructed.
objectSource - the objectsource
Method Detail

free

public void free()
Free this object source. Remove this object source as listener of the sub classes objectsources.

Overrides:
free in class LyObjectSource

listenToSubClasses

public void listenToSubClasses()
Internal method to listen to sub-classes.


notifyClassLoading

public void notifyClassLoading(LyClassInfo classInfo)
Method to notify the loading of a class to an object source.

Overrides:
notifyClassLoading in class LyObjectSource
Parameters:
classInfo - the classInfo

getObjectSource

public LyObjectSource getObjectSource()
To get the objectSource associated with the classInfo when this classInfo is not abstract.

Returns:
the object source that managed the objects of the classInfo.

setCache

public void setCache(LyInfoCache cachePolicy)
Sets the cache for this object source.

Overrides:
setCache in class LyObjectSource
Parameters:
cachePolicy - Informations for the cache to associate to this object source.
Throws:
java.lang.IllegalArgumentException - If the given cache is null.
java.lang.IllegalStateException - If the object source is already associated to a cache that contains objects.

checkObject

public boolean checkObject(java.lang.Object object)
Tests if the given object is found in the cache of this data source.

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

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.

load

public void load()
Loads completely this object source : loads the associated cache according to the cache policy.

Overrides:
load in class LyObjectSource

unload

public void unload(boolean notify)
Unloads completely this object source : unloads the associated cache and data source. This method does noting since no cache is supported on this source

Overrides:
unload in class LyObjectSource
Parameters:
notify - indicates wether the unload action should notify objects deletion. Notifying deletions makes sense when views are opened and when application is not exiting.

addListener

public void addListener(LyDataSourceListener listener,
                        short type)
Registers a listener to receive events of the given type on objects contained within this data source.

Overrides:
addListener in class LyObjectSource
Parameters:
listener - New listener. To receive these events, the listener have to implement the LyDataSourceListener interface.
type - Indicates which type of event the listener wants to receive. Types are defined as constant in LyDataSourceEvent class : TYPE_CREATE, TYPE_SET, TYPE_DELETE
Throws:
java.lang.IllegalArgumentException - If the listener is null or if the given type is unknown.

addListener

public void addListener(LyDataSourceListener listener,
                        java.util.Vector<LyField> fields)
Registers a listener to receive modification events concerning given fields on objects contained within this data source. Warning ! This method only registers the listener for modification events.

Overrides:
addListener in class LyObjectSource
Parameters:
listener - New listener. To receive these events, the listener have to implement the LyDataSourceListener interface.
fields - List of fields on which the listener wants to be notified when they are modified.
Throws:
java.lang.IllegalArgumentException - If the listener is null.

getObject

public LyObject getObject(LyObjectId id,
                          boolean godown,
                          boolean local)
Gets an object from this object source by the specified identifier.

Parameters:
id - Object identifier of the searched object.
godown - indicates if the object is searched recursivly in inherited classes.
local - indicates if the request is local (from memory) or not.
Returns:
The requested object if it was found, or null if it could not be found. This object is an instance of LyObject (or an inherited class).

getObject

public java.lang.Object getObject(LyObjectId id)
Gets an object from this object source by the specified identifier.

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. This object is an instance of LyObject (or an inherited class).

getObject

public java.lang.Object getObject(LyObjectId id,
                                  boolean local)
Gets an object from this object source by the specified identifier.

Overrides:
getObject in class LyObjectSource
Parameters:
id - Object identifier of the searched object.
local - Indicates if the demand is local (gets object from memory) or not.
Returns:
The requested object if it was found, or null if it could not be found. This object is an instance of LyObject (or an inherited class).

getSize

public int getSize(LyFilter filter)
Return the number of objects within this object source matching the given filter.

Overrides:
getSize in class LyObjectSource
Parameters:
filter - Filter applied on objects for counting.
Returns:
Number of objects matching the given filter in this object source.

getSize

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

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.

getRealClassInfo

public LyClassInfo getRealClassInfo(LyObject object)
Given an object id corresponding to this extend object source, compute the real classinfo (corresponding to the correct sub class.

Overrides:
getRealClassInfo in class LyObjectSource
Parameters:
object - the LyObject
Returns:
the correct classInfo for this object.

createObject

public LyResponse createObject(LyObject object,
                               LyResponseListener listener,
                               boolean local,
                               boolean refresh)
Create a new object in this object source. This method commits local creation by creating the corresponding physical object.

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. This method commits local modification by setting the corresponding physical object.

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. This method commits local modifications by setting the corresponding physical objects.

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. This method commits local deletion by deleting the corresponding physical object.

Parameters:
object - Object to delete.
listener - Listener of the response.
local - Indicates if the operation is local or not.
refresh - Indicates if the operation 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. This method commits local deletions by deleting the corresponding physical objects.

Overrides:
deleteObjects in class LyObjectSource
Parameters:
objects - List of objects to delete.
listener - Listener of the response.
local - Indicates if the operation is local or not.
refresh - Indicates if the operation 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.

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. These objects are first searched in the associated cache to avoid requests to the physical layer.

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.

getObjectFromPeer

public LyObject getObjectFromPeer(java.lang.Object peer)
Finds an object from its object peer (associated physical object). The object is searched in the cache and if it is not found, it is created.

Overrides:
getObjectFromPeer in class LyObjectSource
Parameters:
peer - Physical object.
Returns:
The logical object that was found or created, or null if the creation fails.

validate

public void validate()
To validate this objectSource. This method scans all fields of the associated class info and register this object source as listener on all object sources corresponding to classes that are pointed by relations. The purpose is to receive events on id. and name changes on related objects to transform them as modifications on objects managed by this objects source. As related objects are presented by their names, the goal is to ease the refreshing of the display when names change.

Overrides:
validate in class LyObjectSource

getListener

public LyDataSourceListener getListener()
To get the instance of LyDataSourceListener of this object source.

Overrides:
getListener in class LyObjectSource
Returns:
the instance of LyDataSourceListener of this object source.

setLoaded

public void setLoaded(boolean loaded)
Marks the associated cache as loaded or not.

Parameters:
loaded - True to mark the cache loaded, false otherwise.

setLoaded

public void setLoaded(boolean loaded,
                      boolean subClassesOnly)
Marks the associated cache as loaded or not.

Parameters:
loaded - True to mark the cache loaded, false otherwise.

finalizeObject

public void finalizeObject(LyObject object)
Finalize method for an object, remove from cache

Overrides:
finalizeObject in class LyObjectSource
Parameters:
object - LyObject being finalized

(c) January 2013 - W4 S.A.

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