Class EntitySyncContext
java.lang.Object
org.apache.ofbiz.entityext.synchronization.EntitySyncContext
Entity Engine Sync Services
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class signifies an abort condition, so the state and such of the EntitySync value in the datasource should not be changedstatic class
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 errorstatic class
static class
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 errorstatic class
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 -
Constructor Summary
ConstructorDescriptionEntitySyncContext
(DispatchContext dctx, Map<String, ? extends Object> context) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Advance run times.Assemble keys to remove linked list.Assemble values to create array list.Assemble values to store array list.void
create history record, target service should run in own txGets current run end time.Gets current run start time.protected static Timestamp
getCurrentRunStartTime
(Timestamp lastSuccessfulSynchTime, List<ModelEntity> entityModelToUseList, Delegator delegator) Gets entity sync.Gets entity sync id.getEntitySyncModelNamesToUse
(LocalDispatcher dispatcher, String entitySyncId) Static method to obtain a list of entity names which will be synchronizedprotected static long
getMaxRunningNoUpdateMillis
(GenericValue entitySync) protected Timestamp
Gets next run end time.protected static long
getOfflineSyncSplitMillis
(GenericValue entitySync) Gets start date.protected static long
getSyncEndBufferMillis
(GenericValue entitySync) protected static long
getSyncSplitMillis
(GenericValue entitySync) long
Gets total rows per split.long
Gets total splits.boolean
Has more time to sync boolean.boolean
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 runningprotected List<ModelEntity>
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 EntitySyncMake entity name to use set set.void
Run offline start running.void
Run pull start or restore saved results.void
runPushSendData
(ArrayList<GenericValue> valuesToCreate, ArrayList<GenericValue> valuesToStore, List<GenericEntity> keysToRemove) Run push send data.void
Run push start running.void
runSaveOfflineSyncInfo
(long rowsInSplit) Run save offline sync info.void
Save final sync results.void
Save results reported from data store.void
saveSyncErrorInfo
(String runStatusId, List<Object> errorMessages) Save sync error info.protected void
Sets current run end time.void
Sets split start time.long
setTotalRowCounts
(ArrayList<GenericValue> valuesToCreate, ArrayList<GenericValue> valuesToStore, List<GenericEntity> keysToRemove) Sets total row counts.void
setTotalSplits
(long totalSplits) Sets total splits.
-
Constructor Details
-
EntitySyncContext
public EntitySyncContext(DispatchContext dctx, Map<String, ? extends Object> context) throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncAbortException
-
-
Method Details
-
getCurrentRunEndTime
Gets current run end time.- Returns:
- the current run end time
-
getStartDate
Gets start date.- Returns:
- the start date
-
getTotalRowsPerSplit
public long getTotalRowsPerSplit()Gets total rows per split.- Returns:
- the total rows per split
-
getCurrentRunStartTime
Gets current run start time.- Returns:
- the current run start time
-
getEntitySyncId
Gets entity sync id.- Returns:
- the entity sync id
-
setTotalSplits
public void setTotalSplits(long totalSplits) Sets total splits.- Parameters:
totalSplits
- the total splits
-
getEntitySync
Gets entity sync.- Returns:
- the entity sync
-
getTotalSplits
public long getTotalSplits()Gets total splits.- Returns:
- the total splits
-
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()Has more time to sync boolean.- Returns:
- the boolean
-
setCurrentRunEndTime
protected void setCurrentRunEndTime()Sets current run end time. -
getNextRunEndTime
Gets next run end time.- Returns:
- the next run end time
-
advanceRunTimes
public void advanceRunTimes()Advance run times. -
setSplitStartTime
public void setSplitStartTime()Sets split start time. -
getSyncSplitMillis
-
getOfflineSyncSplitMillis
-
getSyncEndBufferMillis
-
getMaxRunningNoUpdateMillis
-
createInitialHistory
public void createInitialHistory() throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncServiceErrorExceptioncreate history record, target service should run in own tx -
assembleValuesToCreate
public ArrayList<GenericValue> assembleValuesToCreate() throws EntitySyncContext.SyncDataErrorExceptionAssemble values to create array list.- Returns:
- the array list
- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exception
-
assembleValuesToStore
public ArrayList<GenericValue> assembleValuesToStore() throws EntitySyncContext.SyncDataErrorExceptionAssemble values to store array list.- Returns:
- the array list
- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exception
-
assembleKeysToRemove
public LinkedList<GenericEntity> assembleKeysToRemove() throws EntitySyncContext.SyncDataErrorExceptionAssemble keys to remove linked list.- Returns:
- the linked list
- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exception
-
saveResultsReportedFromDataStore
public void saveResultsReportedFromDataStore() throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncServiceErrorExceptionSave results reported from data store.- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exceptionEntitySyncContext.SyncServiceErrorException
- the sync service error exception
-
saveFinalSyncResults
public void saveFinalSyncResults() throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncServiceErrorExceptionSave final sync results.- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exceptionEntitySyncContext.SyncServiceErrorException
- the sync service error exception
-
makeEntityNameToUseSet
Make entity name to use set set.- Returns:
- the set
-
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- Throws:
GenericEntityException
-
getCurrentRunStartTime
protected static Timestamp getCurrentRunStartTime(Timestamp lastSuccessfulSynchTime, List<ModelEntity> entityModelToUseList, Delegator delegator) throws GenericEntityException - Throws:
GenericEntityException
-
saveSyncErrorInfo
Save sync error info.- Parameters:
runStatusId
- the run status iderrorMessages
- the error messages
-
runPushStartRunning
public void runPushStartRunning() throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncServiceErrorException, EntitySyncContext.SyncAbortExceptionRun push start running.- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exceptionEntitySyncContext.SyncServiceErrorException
- the sync service error exceptionEntitySyncContext.SyncAbortException
- the sync abort exception
-
setTotalRowCounts
public long setTotalRowCounts(ArrayList<GenericValue> valuesToCreate, ArrayList<GenericValue> valuesToStore, List<GenericEntity> keysToRemove) Sets total row counts.- Parameters:
valuesToCreate
- the values to createvaluesToStore
- the values to storekeysToRemove
- the keys to remove- Returns:
- the total row counts
-
runPushSendData
public void runPushSendData(ArrayList<GenericValue> valuesToCreate, ArrayList<GenericValue> valuesToStore, List<GenericEntity> keysToRemove) throws EntitySyncContext.SyncOtherErrorException, EntitySyncContext.SyncServiceErrorException Run push send data.- Parameters:
valuesToCreate
- the values to createvaluesToStore
- the values to storekeysToRemove
- the keys to remove- Throws:
EntitySyncContext.SyncOtherErrorException
- the sync other error exceptionEntitySyncContext.SyncServiceErrorException
- the sync service error exception
-
runPullStartOrRestoreSavedResults
public void runPullStartOrRestoreSavedResults() throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncServiceErrorException, EntitySyncContext.SyncAbortExceptionRun pull start or restore saved results.- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exceptionEntitySyncContext.SyncServiceErrorException
- the sync service error exceptionEntitySyncContext.SyncAbortException
- the sync abort exception
-
runOfflineStartRunning
public void runOfflineStartRunning() throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncServiceErrorException, EntitySyncContext.SyncAbortExceptionRun offline start running.- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exceptionEntitySyncContext.SyncServiceErrorException
- the sync service error exceptionEntitySyncContext.SyncAbortException
- the sync abort exception
-
runSaveOfflineSyncInfo
public void runSaveOfflineSyncInfo(long rowsInSplit) throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncServiceErrorException, EntitySyncContext.SyncAbortException Run save offline sync info.- Parameters:
rowsInSplit
- the rows in split- Throws:
EntitySyncContext.SyncDataErrorException
- the sync data error exceptionEntitySyncContext.SyncServiceErrorException
- the sync service error exceptionEntitySyncContext.SyncAbortException
- the sync abort exception
-
getEntitySyncModelNamesToUse
public static Set<String> getEntitySyncModelNamesToUse(LocalDispatcher dispatcher, String entitySyncId) throws EntitySyncContext.SyncDataErrorException, EntitySyncContext.SyncAbortException Static method to obtain a list of entity names which will be synchronized
-