org.ofbiz.entityext.synchronization
Class EntitySyncContext

java.lang.Object
  extended by org.ofbiz.entityext.synchronization.EntitySyncContext

public class EntitySyncContext
extends java.lang.Object

Entity Engine Sync Services


Nested Class Summary
static class EntitySyncContext.SyncAbortException
          This class signifies an abort condition, so the state and such of the EntitySync value in the datasource should not be changed
static class EntitySyncContext.SyncDataErrorException
          This class signifies an error condition, so the state of the EntitySync value and the EntitySyncHistory value in the datasource should be changed to reflect the error
static class EntitySyncContext.SyncErrorException
           
static class EntitySyncContext.SyncOtherErrorException
          This class signifies an error condition, so the state of the EntitySync value and the EntitySyncHistory value in the datasource should be changed to reflect the error
static class EntitySyncContext.SyncServiceErrorException
          This class signifies an error condition, so the state of the EntitySync value and the EntitySyncHistory value in the datasource should be changed to reflect the error
 
Field Summary
 java.util.Map<java.lang.String,? extends java.lang.Object> context
           
 java.sql.Timestamp currentRunEndTime
           
 java.sql.Timestamp currentRunStartTime
           
static long defaultMaxRunningNoUpdateMillis
           
static long defaultOfflineSyncSplitMillis
           
static long defaultSyncEndBufferMillis
           
static long defaultSyncSplitMillis
           
 GenericDelegator delegator
           
 LocalDispatcher dispatcher
           
 java.util.List<ModelEntity> entityModelToUseList
           
 java.util.Set<java.lang.String> entityNameToUseSet
           
 GenericValue entitySync
           
 java.lang.String entitySyncId
           
 boolean isOfflineSync
           
 java.sql.Timestamp lastSuccessfulSynchTime
           
 long maxRunningNoUpdateMillis
           
static java.lang.String module
           
 java.sql.Timestamp nextCreateTxTime
           
 java.util.Map<java.lang.String,java.sql.Timestamp> nextEntityCreateTxTime
           
 java.util.Map<java.lang.String,java.sql.Timestamp> nextEntityUpdateTxTime
           
 java.sql.Timestamp nextRemoveTxTime
           
 java.sql.Timestamp nextUpdateTxTime
           
 long offlineSyncSplitMillis
           
 java.sql.Timestamp startDate
           
 long syncEndBufferMillis
           
 java.sql.Timestamp syncEndStamp
           
 long syncSplitMillis
           
 java.lang.String targetDelegatorName
           
 java.lang.String targetServiceName
           
 GenericValue userLogin
           
 
Constructor Summary
EntitySyncContext(DispatchContext dctx, java.util.Map<java.lang.String,? extends java.lang.Object> context)
           
 
Method Summary
 void advanceRunTimes()
           
 java.util.LinkedList<GenericEntity> assembleKeysToRemove()
           
 java.util.ArrayList<GenericValue> assembleValuesToCreate()
           
 java.util.ArrayList<GenericValue> assembleValuesToStore()
           
 void createInitialHistory()
          create history record, target service should run in own tx
protected static java.sql.Timestamp getCurrentRunStartTime(java.sql.Timestamp lastSuccessfulSynchTime, java.util.List<ModelEntity> entityModelToUseList, GenericDelegator delegator)
           
static java.util.Set getEntitySyncModelNamesToUse(LocalDispatcher dispatcher, java.lang.String entitySyncId)
          Static method to obtain a list of entity names which will be synchronized
protected static long getMaxRunningNoUpdateMillis(GenericValue entitySync)
           
protected  java.sql.Timestamp getNextRunEndTime()
           
protected static long getOfflineSyncSplitMillis(GenericValue entitySync)
           
protected static long getSyncEndBufferMillis(GenericValue entitySync)
           
protected static long getSyncSplitMillis(GenericValue entitySync)
           
 boolean hasMoreTimeToSync()
           
 boolean isEntitySyncRunning()
          To see if it is running check: - in the running status - AND when the entitySync was last updated, and if it was more than maxRunningNoUpdateMillis ago, then don't consider it to be running
protected  java.util.List<ModelEntity> makeEntityModelToUseList()
          prepare a list of all entities we want to synchronize: remove all view-entities and all entities that don't match the patterns attached to this EntitySync
 java.util.Set<java.lang.String> makeEntityNameToUseSet()
           
 void runOfflineStartRunning()
           
 void runPullStartOrRestoreSavedResults()
           
 void runPushSendData(java.util.ArrayList<GenericValue> valuesToCreate, java.util.ArrayList<GenericValue> valuesToStore, java.util.List<GenericEntity> keysToRemove)
           
 void runPushStartRunning()
           
 void runSaveOfflineSyncInfo(long rowsInSplit)
           
 void saveFinalSyncResults()
           
 void saveResultsReportedFromDataStore()
           
 void saveSyncErrorInfo(java.lang.String runStatusId, java.util.List<java.lang.Object> errorMessages)
           
protected  void setCurrentRunEndTime()
           
 void setSplitStartTime()
           
 long setTotalRowCounts(java.util.ArrayList<GenericValue> valuesToCreate, java.util.ArrayList<GenericValue> valuesToStore, java.util.List<GenericEntity> keysToRemove)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module

defaultSyncSplitMillis

public static final long defaultSyncSplitMillis
See Also:
Constant Field Values

defaultOfflineSyncSplitMillis

public static final long defaultOfflineSyncSplitMillis
See Also:
Constant Field Values

defaultSyncEndBufferMillis

public static final long defaultSyncEndBufferMillis
See Also:
Constant Field Values

defaultMaxRunningNoUpdateMillis

public static final long defaultMaxRunningNoUpdateMillis
See Also:
Constant Field Values

delegator

public GenericDelegator delegator

dispatcher

public LocalDispatcher dispatcher

context

public java.util.Map<java.lang.String,? extends java.lang.Object> context

userLogin

public GenericValue userLogin

isOfflineSync

public boolean isOfflineSync

entitySyncId

public java.lang.String entitySyncId

entitySync

public GenericValue entitySync

targetServiceName

public java.lang.String targetServiceName

targetDelegatorName

public java.lang.String targetDelegatorName

syncEndStamp

public java.sql.Timestamp syncEndStamp

offlineSyncSplitMillis

public long offlineSyncSplitMillis

syncSplitMillis

public long syncSplitMillis

syncEndBufferMillis

public long syncEndBufferMillis

maxRunningNoUpdateMillis

public long maxRunningNoUpdateMillis

lastSuccessfulSynchTime

public java.sql.Timestamp lastSuccessfulSynchTime

entityModelToUseList

public java.util.List<ModelEntity> entityModelToUseList

entityNameToUseSet

public java.util.Set<java.lang.String> entityNameToUseSet

currentRunStartTime

public java.sql.Timestamp currentRunStartTime

currentRunEndTime

public java.sql.Timestamp currentRunEndTime

nextEntityCreateTxTime

public java.util.Map<java.lang.String,java.sql.Timestamp> nextEntityCreateTxTime

nextEntityUpdateTxTime

public java.util.Map<java.lang.String,java.sql.Timestamp> nextEntityUpdateTxTime

nextCreateTxTime

public java.sql.Timestamp nextCreateTxTime

nextUpdateTxTime

public java.sql.Timestamp nextUpdateTxTime

nextRemoveTxTime

public java.sql.Timestamp nextRemoveTxTime

startDate

public java.sql.Timestamp startDate
Constructor Detail

EntitySyncContext

public EntitySyncContext(DispatchContext dctx,
                         java.util.Map<java.lang.String,? extends java.lang.Object> context)
                  throws EntitySyncContext.SyncDataErrorException,
                         EntitySyncContext.SyncAbortException
Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncAbortException
Method Detail

isEntitySyncRunning

public boolean isEntitySyncRunning()
To see if it is running check: - in the running status - AND when the entitySync was last updated, and if it was more than maxRunningNoUpdateMillis ago, then don't consider it to be running

Returns:
boolean representing if the EntitySync should be considered running

hasMoreTimeToSync

public boolean hasMoreTimeToSync()

setCurrentRunEndTime

protected void setCurrentRunEndTime()

getNextRunEndTime

protected java.sql.Timestamp getNextRunEndTime()

advanceRunTimes

public void advanceRunTimes()

setSplitStartTime

public void setSplitStartTime()

getSyncSplitMillis

protected static long getSyncSplitMillis(GenericValue entitySync)

getOfflineSyncSplitMillis

protected static long getOfflineSyncSplitMillis(GenericValue entitySync)

getSyncEndBufferMillis

protected static long getSyncEndBufferMillis(GenericValue entitySync)

getMaxRunningNoUpdateMillis

protected static long getMaxRunningNoUpdateMillis(GenericValue entitySync)

createInitialHistory

public void createInitialHistory()
                          throws EntitySyncContext.SyncDataErrorException,
                                 EntitySyncContext.SyncServiceErrorException
create history record, target service should run in own tx

Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncServiceErrorException

assembleValuesToCreate

public java.util.ArrayList<GenericValue> assembleValuesToCreate()
                                                         throws EntitySyncContext.SyncDataErrorException
Throws:
EntitySyncContext.SyncDataErrorException

assembleValuesToStore

public java.util.ArrayList<GenericValue> assembleValuesToStore()
                                                        throws EntitySyncContext.SyncDataErrorException
Throws:
EntitySyncContext.SyncDataErrorException

assembleKeysToRemove

public java.util.LinkedList<GenericEntity> assembleKeysToRemove()
                                                         throws EntitySyncContext.SyncDataErrorException
Throws:
EntitySyncContext.SyncDataErrorException

saveResultsReportedFromDataStore

public void saveResultsReportedFromDataStore()
                                      throws EntitySyncContext.SyncDataErrorException,
                                             EntitySyncContext.SyncServiceErrorException
Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncServiceErrorException

saveFinalSyncResults

public void saveFinalSyncResults()
                          throws EntitySyncContext.SyncDataErrorException,
                                 EntitySyncContext.SyncServiceErrorException
Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncServiceErrorException

makeEntityNameToUseSet

public java.util.Set<java.lang.String> makeEntityNameToUseSet()

makeEntityModelToUseList

protected java.util.List<ModelEntity> makeEntityModelToUseList()
                                                        throws GenericEntityException
prepare a list of all entities we want to synchronize: remove all view-entities and all entities that don't match the patterns attached to this EntitySync

Throws:
GenericEntityException

getCurrentRunStartTime

protected static java.sql.Timestamp getCurrentRunStartTime(java.sql.Timestamp lastSuccessfulSynchTime,
                                                           java.util.List<ModelEntity> entityModelToUseList,
                                                           GenericDelegator delegator)
                                                    throws GenericEntityException
Throws:
GenericEntityException

saveSyncErrorInfo

public void saveSyncErrorInfo(java.lang.String runStatusId,
                              java.util.List<java.lang.Object> errorMessages)

runPushStartRunning

public void runPushStartRunning()
                         throws EntitySyncContext.SyncDataErrorException,
                                EntitySyncContext.SyncServiceErrorException,
                                EntitySyncContext.SyncAbortException
Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncServiceErrorException
EntitySyncContext.SyncAbortException

setTotalRowCounts

public long setTotalRowCounts(java.util.ArrayList<GenericValue> valuesToCreate,
                              java.util.ArrayList<GenericValue> valuesToStore,
                              java.util.List<GenericEntity> keysToRemove)

runPushSendData

public void runPushSendData(java.util.ArrayList<GenericValue> valuesToCreate,
                            java.util.ArrayList<GenericValue> valuesToStore,
                            java.util.List<GenericEntity> keysToRemove)
                     throws EntitySyncContext.SyncOtherErrorException,
                            EntitySyncContext.SyncServiceErrorException
Throws:
EntitySyncContext.SyncOtherErrorException
EntitySyncContext.SyncServiceErrorException

runPullStartOrRestoreSavedResults

public void runPullStartOrRestoreSavedResults()
                                       throws EntitySyncContext.SyncDataErrorException,
                                              EntitySyncContext.SyncServiceErrorException,
                                              EntitySyncContext.SyncAbortException
Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncServiceErrorException
EntitySyncContext.SyncAbortException

runOfflineStartRunning

public void runOfflineStartRunning()
                            throws EntitySyncContext.SyncDataErrorException,
                                   EntitySyncContext.SyncServiceErrorException,
                                   EntitySyncContext.SyncAbortException
Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncServiceErrorException
EntitySyncContext.SyncAbortException

runSaveOfflineSyncInfo

public void runSaveOfflineSyncInfo(long rowsInSplit)
                            throws EntitySyncContext.SyncDataErrorException,
                                   EntitySyncContext.SyncServiceErrorException,
                                   EntitySyncContext.SyncAbortException
Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncServiceErrorException
EntitySyncContext.SyncAbortException

getEntitySyncModelNamesToUse

public static java.util.Set getEntitySyncModelNamesToUse(LocalDispatcher dispatcher,
                                                         java.lang.String entitySyncId)
                                                  throws EntitySyncContext.SyncDataErrorException,
                                                         EntitySyncContext.SyncAbortException
Static method to obtain a list of entity names which will be synchronized

Throws:
EntitySyncContext.SyncDataErrorException
EntitySyncContext.SyncAbortException