Class BTBundling
java.lang.Object
overit.geocall.bl.BusinessTask<BundlingEvent>
overit.geocallapp.utilities.core.bl.common.validexecution.ValidExecutionBusinessTask<BundlingEvent>
overit.geocallapp.wfm.bundler.bl.task.BTBundler<BundlingEvent>
overit.geocallapp.wfm.orchestrator.workorders.bl.bundler.bundling.task.BTBundling
- All Implemented Interfaces:
Serializable,Tool,ValidExecution
Business task that implements all the phases of the
When the
Bundle creation
process. When the
BundlingEvent is launched the BT notices the call and
performs several actions:
- it selects the list of needed
BOWorkOrderOperationby callingBundlingOperationSelectEvent - it validates the selected
BOWorkOrderOperationby checking their state - it creates a new
Bundlewith the selectedBOWorkOrderOperationby callingBundleCreateEvent
Required fields, at least:
- one work order operation id
- a Primary Bundling Criteria
Permission:
Error Code:
Codes.OPERATION_NOT_PERMITTEDCodes.Bundler.NO_SAME_EXECUTION_TYPECodes.Bundler.INVALID_BUNDLING_RULECodes.Bundler.NO_OPERATIONS_OR_CRITERIA_SPECIFIEDCodes.Bundler.INVALID_WO_OPERATIONS
Visibility:
- work order operations that belong to the same current user's operation center
- bundling rules that belong to the same current user's operation center
- Since:
- 10.1
- See Also:
- GCApi:
- task
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Map<BOBundleCriterion, List<BOWorkOrderOperation>> applyBundlingCriteria(BundlingInput bundlingInput, BundlingRule rule, List<BOWorkOrderOperation> woOperations, PoolKit poolKit) Applies the bundling criteria.protected StringbuildBundleName(BundlingInput bundlingInput, BOBundleCriterion bundleCriterion, PoolKit poolKit) Builds the bundle name starting from the given template and the bundling input.protected voidChecks the bundling input parameters.protected voidcheckUserPermission(BundlingInput input) Checks whether the currentBOUserhas the permission to create a bundle.protected LongcreateBundle(BOBundleCriterion bundleCriterion, List<BOWorkOrderOperation> woOperations, BundlingInput bundlingInput, PoolKit poolKit) Creates a newBundlewith all obtained characteristics by callingBundleCreateEvent.createBundlesByCriterion(BundlingRule rule, BOBundleCriterion bundleCriterion, List<BOWorkOrderOperation> workOrderOperations, BundlingInput bundlingInput, PoolKit poolKit) Creates theBundles starting from the givenBOBundleCriterionand the list ofBOWorkOrderOperationto aggregate.protected voidexecute(BundlingEvent event, PoolKit poolKit) Starting from a list of givenBundlingRules, it tries to create as manyBundlethat meet the requirements.protected LonggetMaxBundleDuration(BOBundlingRuleHeader bundlingRuleHeader) Returns the max bundle duration set in theBOBundlingRuleHeader.protected intgetMaxBundleSize(BOBundlingRuleHeader bundlingRuleHeader) Returns the max bundle size set in theBOBundlingRuleHeader.protected intgetMinBundleSize(BOBundlingRuleHeader bundlingRuleHeader) Returns the min bundle size set in theBOBundlingRuleHeader.protected List<BOWorkOrderOperation> getWorkOrderOperations(BundlingInput input, BundlingRule rule, PoolKit poolKit) Returns the sorted list of all theBOWorkOrderOperations that are valid for the aggregation.protected voidinitializeCache(List<BOWorkOrderOperation> woOperations, BundleEntitiesCache cache, PoolKit poolKit) Initializes theBundleEntitiesCachewith theBOWorkOrderOperations appointments.protected voidinitializeLog(BundlingInput input) Initializes the log for the current process.protected LonginsertBundleCriterion(BOBundleCriterion bundleCriterion, PoolKit poolKit) Inserts the givenBOBundleCriterion.protected List<BOWorkOrderOperation> loadWorkOrderOperations(BundlingRule rule, List<Long> workOrderOperationIds, BundleEntitiesCache cache, PoolKit poolKit) Loads the list ofBOWorkOrderOperationfrom the given input, using also the work order filters set on theBundlingRuleprotected List<List<BOWorkOrderOperation>> partitionBundleWorkOrderOperations(BundlingRule rule, List<BOWorkOrderOperation> workOrderOperations) If a maximum size was previously selected, it divides the list ofBOWorkOrderOperationinto different sized list.processBundlingRule(BundlingInput input, BundlingRule rule, PoolKit poolKit) Creates the bundles starting from the givenBundlingRuleand theBundlingInput.protected List<BOWorkOrderOperation> sortWorkOrderOperations(List<BOWorkOrderOperation> woOperations, BundlingRule bundlingRule, BundlingInput input, PoolKit poolKit) Sorts the list ofBOWorkOrderOperation.Methods inherited from class overit.geocallapp.wfm.bundler.bl.task.BTBundler
getException, isValidExecution, throwExceptionIfInvalidMethods inherited from class overit.geocallapp.utilities.core.bl.common.validexecution.ValidExecutionBusinessTask
body, checkValidExecution, getEventMethods inherited from class overit.geocall.bl.BusinessTask
start, start, startAlone, startInBackground
-
Field Details
-
logHelper
-
bundlerMessageHelper
-
-
Constructor Details
-
BTBundling
public BTBundling()
-
-
Method Details
-
execute
protected void execute(BundlingEvent event, PoolKit poolKit) throws DAException, DAValidateException Starting from a list of givenBundlingRules, it tries to create as manyBundlethat meet the requirements. Finally, it writes the set of just createdBOBundleHeaderid into the event journal.- Specified by:
executein classValidExecutionBusinessTask<BundlingEvent>- Parameters:
event- theBundlingEventpoolKit- thePoolKit- Throws:
DAException- the DA exceptionDAValidateException- the DA validate exception
-
initializeLog
Initializes the log for the current process.- Parameters:
input- theBundlingInput- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
processBundlingRule
protected List<Long> processBundlingRule(BundlingInput input, BundlingRule rule, PoolKit poolKit) throws DAException, DAValidateException Creates the bundles starting from the givenBundlingRuleand theBundlingInput.- Parameters:
input- theBundlingInputrule- theBundlingRulepoolKit- thePoolKit- Returns:
- a list of
Bundleid created - Throws:
DAException- the DA exceptionDAValidateException- the DA validate exception
-
getWorkOrderOperations
protected List<BOWorkOrderOperation> getWorkOrderOperations(BundlingInput input, BundlingRule rule, PoolKit poolKit) throws DAValidateException, DAException Returns the sorted list of all theBOWorkOrderOperations that are valid for the aggregation.- Parameters:
input- theBundlingInputrule- theBundlingRulepoolKit- thePoolKit- Returns:
- a list of valid and sorted
BOWorkOrderOperations - Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
checkUserPermission
Checks whether the currentBOUserhas the permission to create a bundle.- Parameters:
input- theBundlingInput- Throws:
DAValidateException- the DA validate exception when the user has not the right permission
-
checkInputParameters
Checks the bundling input parameters.- Parameters:
input- theBundlingInput- Throws:
DAValidateException- the DA validate exception
-
loadWorkOrderOperations
protected List<BOWorkOrderOperation> loadWorkOrderOperations(BundlingRule rule, List<Long> workOrderOperationIds, BundleEntitiesCache cache, PoolKit poolKit) throws DAValidateException, DAException Loads the list ofBOWorkOrderOperationfrom the given input, using also the work order filters set on theBundlingRule- Parameters:
rule- theBundlingRuleworkOrderOperationIds- list of work order operation idscache- theBundleEntitiesCachepoolKit- thePoolKit- Returns:
- the list of the loaded
BOWorkOrderOperations - Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
initializeCache
protected void initializeCache(List<BOWorkOrderOperation> woOperations, BundleEntitiesCache cache, PoolKit poolKit) Initializes theBundleEntitiesCachewith theBOWorkOrderOperations appointments.- Parameters:
woOperations- list ofBOWorkOrderOperationelementscache- theBundleEntitiesCachepoolKit- thePoolKit
-
sortWorkOrderOperations
protected List<BOWorkOrderOperation> sortWorkOrderOperations(List<BOWorkOrderOperation> woOperations, BundlingRule bundlingRule, BundlingInput input, PoolKit poolKit) throws DAValidateException, DAException Sorts the list ofBOWorkOrderOperation.- Parameters:
woOperations- list ofBOWorkOrderOperationto sortbundlingRule- theBundlingRuleinput- theBundlingInputpoolKit- thePoolKit- Returns:
- the
BOWorkOrderOperationordered list - Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
applyBundlingCriteria
protected Map<BOBundleCriterion,List<BOWorkOrderOperation>> applyBundlingCriteria(BundlingInput bundlingInput, BundlingRule rule, List<BOWorkOrderOperation> woOperations, PoolKit poolKit) throws DAValidateException, DAException Applies the bundling criteria.- Parameters:
bundlingInput- the bundling inputrule- theBundlingRulewoOperations- list ofBOWorkOrderOperationpoolKit- thePoolKit- Returns:
- a map of
BOWorkOrderOperations grouped by the correspondingBOBundleCriterion - Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
createBundlesByCriterion
protected List<Long> createBundlesByCriterion(BundlingRule rule, BOBundleCriterion bundleCriterion, List<BOWorkOrderOperation> workOrderOperations, BundlingInput bundlingInput, PoolKit poolKit) throws DAValidateException, DAException Creates theBundles starting from the givenBOBundleCriterionand the list ofBOWorkOrderOperationto aggregate.- Parameters:
rule- theBundlingRulebundleCriterion- theBOBundleCriterionworkOrderOperations- list ofBOWorkOrderOperationto aggregatebundlingInput- theBundlingInputpoolKit- thePoolKit- Returns:
- a list of created
Bundleids - Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
insertBundleCriterion
protected Long insertBundleCriterion(BOBundleCriterion bundleCriterion, PoolKit poolKit) throws DAValidateException, DAException Inserts the givenBOBundleCriterion.- Parameters:
bundleCriterion- theBOBundleCriterionto insertpoolKit- thePoolKit- Returns:
- the
BOBundleCriterionid - Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
partitionBundleWorkOrderOperations
protected List<List<BOWorkOrderOperation>> partitionBundleWorkOrderOperations(BundlingRule rule, List<BOWorkOrderOperation> workOrderOperations) If a maximum size was previously selected, it divides the list ofBOWorkOrderOperationinto different sized list.- Parameters:
rule- theBundlingRuleworkOrderOperations- list ofBOWorkOrderOperation- Returns:
- a list of
BOWorkOrderOperationlists of different size
-
getMinBundleSize
Returns the min bundle size set in theBOBundlingRuleHeader.- Parameters:
bundlingRuleHeader- theBOBundlingRuleHeader- Returns:
- the min bundle size
-
getMaxBundleSize
Returns the max bundle size set in theBOBundlingRuleHeader.- Parameters:
bundlingRuleHeader- theBOBundlingRuleHeader- Returns:
- the max bundle size
-
getMaxBundleDuration
Returns the max bundle duration set in theBOBundlingRuleHeader.- Parameters:
bundlingRuleHeader- theBOBundlingRuleHeader- Returns:
- the max bundle duration
-
createBundle
protected Long createBundle(BOBundleCriterion bundleCriterion, List<BOWorkOrderOperation> woOperations, BundlingInput bundlingInput, PoolKit poolKit) throws DAValidateException, DAException Creates a newBundlewith all obtained characteristics by callingBundleCreateEvent.- Parameters:
bundleCriterion- theBOBundleCriterionwoOperations- list ofBOWorkOrderOperationwe want to aggregate into the newBundlebundlingInput- theBundlingInputpoolKit- thePoolKit- Returns:
- the id of the created
BOBundleHeader - Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
buildBundleName
protected String buildBundleName(BundlingInput bundlingInput, BOBundleCriterion bundleCriterion, PoolKit poolKit) Builds the bundle name starting from the given template and the bundling input. If a template is not provided, a default one is used, which is composed by the execution type and the bundling rule name and the current date.- Parameters:
bundlingInput- theBundlingInputbundleCriterion- theBOBundleCriterionpoolKit- thePoolKit- Returns:
- the bundle name
-