com.sybase.uep.bobclient.data
Class MBOModel

java.lang.Object
  extended by com.sybase.uep.bobclient.data.CommonMBOModel
      extended by com.sybase.uep.bobclient.data.MBOModel
Direct Known Subclasses:
ClientMBOModel, OtherOperationModel, SPMBOModel

public class MBOModel
extends CommonMBOModel

MBOModel is the access layer to MBO application. It provides wrapper methods to retrieve data from MBO application as well as insert/update/delete data. IModelChangeListener instances could be registered to MBOModel as listeners. Each time when the model is changed, listeners will receive notification. And there is only one MBOModel instance created for each MBO application.

Note: Current implementation is based on the assumption that the java package name for object API always equals to MBO package name defined in AFX.

Author:
haowang

Field Summary
 
Fields inherited from class com.sybase.uep.bobclient.data.CommonMBOModel
_databaseMetaData, _log, _mboApp, _metaData, KEY, PENDING_OP_SCOPE_MBO, PENDING_OP_SCOPE_PACKAGE, PENDING_OP_SCOPE_SYNCGROUP, SYNCHRONIZATION_NORMAL, SYNCHRONIZATION_NOTIFICATION
 
Constructor Summary
protected MBOModel()
           
  MBOModel(java.lang.String id)
          Constructor
 
Method Summary
 void cancelPending(java.lang.Object mbo)
          Restores the original state of the MBO instance.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData.
 void cancelPendingObjects()
          Cancel all the pending operations for this MBO object
 void clearSyncParameter()
          Resets synchronization parameter to null
 void currentSelectChanged()
          Fires CURRENT_SELECT_CHANGE_TYPE event.
 void deleteFromModel(java.lang.Object mbo)
          Deletes the given mbo from MBO application.
 java.util.Vector find(Query q)
          Queries the MBOModel with Query q and returns the result
 java.util.Vector findNamedQuery(java.lang.String namedQuery, java.util.Hashtable parameters)
          Queries the MBOModel by the named query name and returns the result
 java.lang.String getLastOperation(java.lang.Object mbo)
          Gets this MBO application's last called operation.
static LogRecord[] getLogs(java.lang.String packageName, Query q)
          Get operation logs
 OtherOperationModel getOtherOperationModel(java.lang.String operationName)
           
 java.util.Hashtable getOtherOperationModelTable()
           
 ObjectList getPendingObjects()
          Retrieve the list of pending operations for this MBO object
 java.lang.String getProfileRefID()
          Get the mobile application reference ID
protected  ReflectionManager getReflectionManager()
          Get the reflection manager
 java.util.Vector getRelationshipData(java.lang.Object mbo, java.lang.String referenceName)
          Gets the data derived from a relationship.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData.
 java.util.Vector getRelationshipDataFilterBy(java.lang.Object mbo, java.lang.String relation, Query q)
          Gets the data through relationship, and the Query q is used to filter the result data.
 int getSize(Query query)
          Queries the size of the total records in the MBOModel with Query q
 java.lang.Object getSK(java.lang.Object mbo)
          Gets the surrogate key of a given mbo instance
 java.lang.String getSynchronizationGroup()
          Obtains the synchronization group registered by this MBO; Returns null if no synchronization group found
 MBOModelSyncParameters getSyncParameter()
          Get the synchronization parameters for this MBO
 java.lang.Object getValue(java.lang.Object mbo, java.lang.String attributeName)
          Gets the attribute value from a given MBO instance.
 boolean isDeleted(java.lang.Object mbo)
          Checks if the MBO object has been deleted since last synchronization.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData.
 boolean isDirty(java.lang.Object mbo)
          Checks if the MBO object has been updated since last synchronization.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData.
 boolean isNew(java.lang.Object mbo)
          Checks if the MBO object is a new created one since last synchronization.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData.
 boolean isSynchronized()
          Gets whether this MBO application has been synchronized.
 void namedQueryChanged()
          Fires NAMED_QUERY_TYPE event.
 void namedQueryInitialized()
          Fires NAMED_QUERY_INITIALIZED_TYPE event.
 java.lang.Object newMBOInstance()
          Creates a new MBO instance for this MBO application.
 void parentSelectChanged()
          Fires PARENT_SELECT_CHANGE_TYPE event.
 void refresh(java.lang.Object mbo)
          Refresh the given mbo.
 void relationshipChanged()
          Fires the relationship change event
 void saveUpdate(java.lang.Object mbo)
          Saves the changes to MBO application.
 void setValue(java.lang.Object mbo, java.lang.String attributeName, java.lang.Object value)
          Sets the attribute value for a given MBO instance.
 int size()
          Returns mbo data size.
 void submitPending(java.lang.Object mbo)
          Submit the pending change of the mobile business object (ready for sending to server).
 void submitPendingObjects()
          Submits all the pending operations for this MBO object.
 void synchronize(SyncStatusListener syncStatusListener, int pendingOpScope)
          Synchronizes the MBO application with a sync status listener.
 
Methods inherited from class com.sybase.uep.bobclient.data.CommonMBOModel
addModelChangeListener, deleteDatabase, fireModelChanged, fireSyncEvent, fireSyncEvent, getDataType, getID, getLastSynchronized, getLogger, getLogs, getMetaData, getName, getPackageName, getSynchronizationGroup, getSynchronizationProfile, getSynchronizationProfile, getType, invoke, invoke, loginToSync, registerCallbackHandler, removeModelChangeListener, startBackgroundSynchronization, startBackgroundSynchronization, submitPendingOperations, submitPendingOperations, synchronize, synchronize, syncSyncGroup, syncSyncGroupNoSubmit, uploadLogs
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBOModel

protected MBOModel()

MBOModel

public MBOModel(java.lang.String id)
Constructor

Parameters:
id -
Method Detail

getReflectionManager

protected ReflectionManager getReflectionManager()
Get the reflection manager

Returns:

newMBOInstance

public java.lang.Object newMBOInstance()
Creates a new MBO instance for this MBO application.

Returns:

find

public java.util.Vector find(Query q)
                      throws java.lang.Exception
Queries the MBOModel with Query q and returns the result

Parameters:
q, - Query instance that is used for searching.
Returns:
a Vector that contains MBO instances. Return an empty vector if no data is found.
Throws:
NoSuchOperationException - if find(Query q) is not defined in mbo.
java.lang.Exception

size

public int size()
Returns mbo data size.

Returns:
mbo data size.

findNamedQuery

public java.util.Vector findNamedQuery(java.lang.String namedQuery,
                                       java.util.Hashtable parameters)
                                throws java.lang.Exception
Queries the MBOModel by the named query name and returns the result

Parameters:
namedQuery - String value for the named query method name
parameters - Hashtable value for the list of parameters
Returns:
Vector value for the result set.
Throws:
NoSuchOperationException - if namedQuery is not defined in mbo.
java.lang.Exception

getPendingObjects

public ObjectList getPendingObjects()
Retrieve the list of pending operations for this MBO object

Returns:
ObjectList list of MBO objects
See Also:
ObjectList

cancelPendingObjects

public void cancelPendingObjects()
Cancel all the pending operations for this MBO object


submitPending

public void submitPending(java.lang.Object mbo)
Submit the pending change of the mobile business object (ready for sending to server). For controls that are assigned multiple operations, each operation need to be submit pending as soon as executed, otherwise only the last operation gets executed. No need to fire model change event as this is only for use in SubmitAction before synchronizing data.

Parameters:
mbo - mobile business object instance

submitPendingObjects

public void submitPendingObjects()
Submits all the pending operations for this MBO object. During MBO sync, synchronization group level pending operations should be submitted, so this API is only intended to be called in pending operations screen, when user selects a MBO model.


deleteFromModel

public void deleteFromModel(java.lang.Object mbo)
Deletes the given mbo from MBO application. The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to delete a SalesOrder instance

Parameters:
mbo - MBO instance to delete from MBO application
Throws:
NoSuchOperationException - if delete() is not defined in mbo.

isDirty

public boolean isDirty(java.lang.Object mbo)
Checks if the MBO object has been updated since last synchronization.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to check the status of a SalesOrder instance

Parameters:
mbo -
Returns:
Throws:
NoSuchOperationException - if isDirty() is not defined in mbo.

isDeleted

public boolean isDeleted(java.lang.Object mbo)
Checks if the MBO object has been deleted since last synchronization.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to check the status of a SalesOrder instance

Parameters:
mbo -
Returns:
Throws:
NoSuchOperationException - if isDelete() is not defined in mbo.

isNew

public boolean isNew(java.lang.Object mbo)
Checks if the MBO object is a new created one since last synchronization.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to check the status of a SalesOrder instance

Parameters:
mbo -
Returns:

getSyncParameter

public MBOModelSyncParameters getSyncParameter()
Get the synchronization parameters for this MBO

Returns:
MBOModelSyncParameters object

getLogs

public static LogRecord[] getLogs(java.lang.String packageName,
                                  Query q)
Get operation logs

Parameters:
packageName - - package name
q - - query object
Returns:
LogRecord[] - list of LogRecord objects

getRelationshipData

public java.util.Vector getRelationshipData(java.lang.Object mbo,
                                            java.lang.String referenceName)
Gets the data derived from a relationship.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to get the relationship data from a SalesOrder instance

Parameters:
mbo -
referenceName -
Throws:
NoSuchOperationException - if no matched operation in mbo.

getSK

public java.lang.Object getSK(java.lang.Object mbo)
Gets the surrogate key of a given mbo instance

Parameters:
mbo -
Returns:

refresh

public void refresh(java.lang.Object mbo)
Refresh the given mbo.

Parameters:
mbo -

getProfileRefID

public java.lang.String getProfileRefID()
Get the mobile application reference ID

Overrides:
getProfileRefID in class CommonMBOModel
Returns:
string value of ID

getRelationshipDataFilterBy

public java.util.Vector getRelationshipDataFilterBy(java.lang.Object mbo,
                                                    java.lang.String relation,
                                                    Query q)
Gets the data through relationship, and the Query q is used to filter the result data.

Parameters:
mbo - the parent mbo to retrieve the child data
relation - relationship name
q - query
Returns:
the data matches the query
Throws:
NoSuchOperationException

getSize

public int getSize(Query query)
Queries the size of the total records in the MBOModel with Query q

Parameters:
q, - Query instance that is used for searching.
Returns:
the count of the records
Throws:
NoSuchOperationException - if getSize(Query q) is not defined in mbo.

saveUpdate

public void saveUpdate(java.lang.Object mbo)
Saves the changes to MBO application. The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to save the update on a SalesOrder instance

Parameters:
mbo - the changed MBO instance
Throws:
NoSuchOperationException - if save() is not defined in mbo.

getValue

public java.lang.Object getValue(java.lang.Object mbo,
                                 java.lang.String attributeName)
Gets the attribute value from a given MBO instance. The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to get the attribute value from a SalesOrder instance

Parameters:
mbo -
attributeName -
Returns:
Throws:
NoSuchOperationException - if attribute name is not defined in mbo.

setValue

public void setValue(java.lang.Object mbo,
                     java.lang.String attributeName,
                     java.lang.Object value)
Sets the attribute value for a given MBO instance. The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to set the attribute value for a SalesOrder instance

Parameters:
mbo -
attributeName -
Throws:
NoSuchOperationException - if attribute name is not defined in mbo.

cancelPending

public void cancelPending(java.lang.Object mbo)
Restores the original state of the MBO instance.The caller takes the responsibility to make sure the metaData of mbo equals to _metaData. For example, caller should not try to use a Customer MBOModel to restore the state of a SalesOrder instance

Parameters:
mbo -
Throws:
NoSuchOperationException - if cancelPending() is not defined in mbo.

parentSelectChanged

public void parentSelectChanged()
Fires PARENT_SELECT_CHANGE_TYPE event.


relationshipChanged

public void relationshipChanged()
Fires the relationship change event


currentSelectChanged

public void currentSelectChanged()
Fires CURRENT_SELECT_CHANGE_TYPE event.


namedQueryChanged

public void namedQueryChanged()
Fires NAMED_QUERY_TYPE event.


namedQueryInitialized

public void namedQueryInitialized()
Fires NAMED_QUERY_INITIALIZED_TYPE event.


synchronize

public void synchronize(SyncStatusListener syncStatusListener,
                        int pendingOpScope)
                 throws java.lang.Exception
Synchronizes the MBO application with a sync status listener.

Specified by:
synchronize in class CommonMBOModel
Parameters:
syncStatusListener - - Sync status listener
pendingOpScope - - @see CommonMBOModel.PENDING_OP_SCOPE_SYNCGROUP, CommonMBOModel.PENDING_OP_SCOPE_MBO, CommonMBOModel.PENDING_OP_SCOPE_PACKAGE
Throws:
NoSuchOperationException - if synchronize() is not defined in corresponding database class.
java.lang.Exception

isSynchronized

public boolean isSynchronized()
Gets whether this MBO application has been synchronized.

Specified by:
isSynchronized in class CommonMBOModel
Returns:

getSynchronizationGroup

public java.lang.String getSynchronizationGroup()
Description copied from class: CommonMBOModel
Obtains the synchronization group registered by this MBO; Returns null if no synchronization group found

Specified by:
getSynchronizationGroup in class CommonMBOModel
Returns:
the synchronization group name

getLastOperation

public java.lang.String getLastOperation(java.lang.Object mbo)
Gets this MBO application's last called operation.

Parameters:
mbo - Object value for the mbo
Returns:
String value for last called operation name.

getOtherOperationModelTable

public java.util.Hashtable getOtherOperationModelTable()

getOtherOperationModel

public OtherOperationModel getOtherOperationModel(java.lang.String operationName)

clearSyncParameter

public void clearSyncParameter()
Resets synchronization parameter to null