Class BTInterventionResourceInsert
java.lang.Object
overit.geocall.bl.BusinessTask<InterventionResourceInsertEvent>
overit.geocallapp.utilities.core.bl.common.validexecution.ValidExecutionBusinessTask<InterventionResourceInsertEvent>
overit.geocallapp.utilities.core.bl.common.validexecution.ValidPermissionBusinessTask<InterventionResourceInsertEvent>
overit.geocallapp.wfm.orchestrator.workorders.bl.intervention.resource.task.BTInterventionResourceInsert
- All Implemented Interfaces:
Serializable,Tool,ValidExecution
@Event(InterventionResourceInsertEvent.class)
public class BTInterventionResourceInsert
extends ValidPermissionBusinessTask<InterventionResourceInsertEvent>
Business task to insert a intervention resource.
Permission:
Error Code:
- Since:
- 18.0
- See Also:
- GCApi:
- task
-
Field Summary
FieldsFields inherited from class overit.geocallapp.utilities.core.bl.common.validexecution.ValidPermissionBusinessTask
LOG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckWorkOrderStatus(BOInterventionResource interventionResource, PoolKit poolKit) Checks the status of the work order associated with the providedBOInterventionResource.protected voidexecute(InterventionResourceInsertEvent event, PoolKit poolKit) Executes the intervention resource insertion process.protected WorkOrdersIntegrationServicegetIntegrationService(PoolKit poolKit) Retrieves the WorkOrdersIntegrationService instance.protected List<BOInterventionResource> getInterventionResources(BOInterventionResource interventionResource, PoolKit poolKit) Retrieves a list ofBOInterventionResourceobjects based on the providedBOInterventionResource.protected LonggetNearestWorkShift(BOInterventionResource interventionResource, PoolKit poolKit) Retrieves the nearest work shift for the given intervention resource.protected BOWorkOrderOperationgetWorkOrderOperation(BOInterventionResource interventionResource, PoolKit poolKit) Retrieves theBOWorkOrderOperationassociated with the providedBOInterventionResource.protected voidinsertInterventionResource(BOInterventionResource interventionResource, PoolKit poolKit) Inserts a newBOInterventionResource.protected voidinsertWorkOrderOperationResource(BOInterventionResource interventionResource, PoolKit poolKit) Inserts a newBOWorkOrderOperationResourcebased on the providedBOInterventionResource.booleanDetermines whether the current state is valid for execution.protected voidnotifyInterventionResource(BOInterventionResource interventionResource, PoolKit poolKit) Sends an intervention resource notification.protected voidupdateValidationStatus(PoolKit poolKit) Updates the validation status by calling theInterventionOutcomeValidationStatusUpdateEventprotected voidupdateWorkOrder(PoolKit poolKit) Updates the work order header after an intervention resource has been inserted.protected voidupdateWorkOrderOperationResource(BOInterventionResource interventionResource, List<BOWorkOrderOperationResource> workOrderOperationResources, PoolKit poolKit) Updates the spent time of an existingBOWorkOrderOperationResourcebased on the providedBOInterventionResource.protected voidupsertWorkOrderOperationResource(BOInterventionResource interventionResource, PoolKit poolKit) Upserts aBOWorkOrderOperationResourcebased on the providedBOInterventionResource.protected voidvalidate(BOInterventionResource interventionResource, PoolKit poolKit) Check on mandatory fields and visibility of properties.protected voidvalidateDates(BOInterventionResource interventionResource, PoolKit poolKit) Validates the date-related properties of the providedBOInterventionResource.Methods inherited from class overit.geocallapp.utilities.core.bl.common.validexecution.ValidPermissionBusinessTask
checkValidExecution, getException, throwExceptionIfInvalidMethods inherited from class overit.geocallapp.utilities.core.bl.common.validexecution.ValidExecutionBusinessTask
body, getEventMethods inherited from class overit.geocall.bl.BusinessTask
start, start, startAlone, startInBackground
-
Field Details
-
intervention
-
workOrderOperation
-
-
Constructor Details
-
BTInterventionResourceInsert
public BTInterventionResourceInsert()
-
-
Method Details
-
execute
protected void execute(InterventionResourceInsertEvent event, PoolKit poolKit) throws DAException, DAValidateException Executes the intervention resource insertion process.This method performs the following steps:
- Validates the provided
BOInterventionResourceinstance - Inserts the intervention resource
- Upserts the work order operation resource
- Updates the work order
- Notifies about the intervention resource
- Updates the intervention outcome validation status
- Writes the intervention resource ID to the event journal
- Specified by:
executein classValidExecutionBusinessTask<InterventionResourceInsertEvent>- Parameters:
event- theInterventionResourceInsertEventcontaining the inputBOInterventionResourcepoolKit- thePoolKit- Throws:
DAException- if any data access exception occursDAValidateException- if any data validation exception occurs
- Validates the provided
-
validate
protected void validate(BOInterventionResource interventionResource, PoolKit poolKit) throws DAValidateException, DAException Check on mandatory fields and visibility of properties.- Parameters:
interventionResource- theBOInterventionResourcepoolKit- thePoolKit- Throws:
DAException- the DA exceptionDAValidateException- the DA validate exception
-
validateDates
protected void validateDates(BOInterventionResource interventionResource, PoolKit poolKit) throws DAValidateException, DAException Validates the date-related properties of the providedBOInterventionResource.- Parameters:
interventionResource- theBOInterventionResourceto validatepoolKit- thePoolKitto use for the validation- Throws:
DAValidateException- if any of the date-related properties are missing or invalidDAException- if an error occurs during the validation
-
checkWorkOrderStatus
protected void checkWorkOrderStatus(BOInterventionResource interventionResource, PoolKit poolKit) throws DAValidateException, DAException Checks the status of the work order associated with the providedBOInterventionResource.- Parameters:
interventionResource- theBOInterventionResourceto check the work order status forpoolKit- thePoolKit- Throws:
DAValidateException- if the work order is in a closed, aligned, or cancelled stateDAException- if an error occurs during the check
-
getWorkOrderOperation
protected BOWorkOrderOperation getWorkOrderOperation(BOInterventionResource interventionResource, PoolKit poolKit) throws DAValidateException, DAException Retrieves theBOWorkOrderOperationassociated with the providedBOInterventionResource.- Parameters:
interventionResource- theBOInterventionResourceto use for retrieving theBOWorkOrderOperationpoolKit- thePoolKitto use for the retrieval- Returns:
- the
BOWorkOrderOperationassociated with the providedBOInterventionResource - Throws:
DAValidateException- if any validation error occurs during the retrievalDAException- if an error occurs during the retrieval
-
getInterventionResources
protected List<BOInterventionResource> getInterventionResources(BOInterventionResource interventionResource, PoolKit poolKit) throws DAValidateException, DAException Retrieves a list ofBOInterventionResourceobjects based on the providedBOInterventionResource.- Parameters:
interventionResource- theBOInterventionResourceto use as a filterpoolKit- thePoolKitto use for the search- Returns:
- a list of
BOInterventionResourceobjects matching the filter - Throws:
DAValidateException- if any required properties are missing in theBOInterventionResourceDAException- if an error occurs during the search
-
insertInterventionResource
protected void insertInterventionResource(BOInterventionResource interventionResource, PoolKit poolKit) throws DAException, DAValidateException Inserts a newBOInterventionResource.- Parameters:
interventionResource- theBOInterventionResourceto insertpoolKit- thePoolKit- Throws:
DAValidateException- If there is a validation error.DAException- If an error occurs during the data access.
-
getNearestWorkShift
protected Long getNearestWorkShift(BOInterventionResource interventionResource, PoolKit poolKit) throws DAException, DAValidateException Retrieves the nearest work shift for the given intervention resource.- Parameters:
interventionResource- theBOInterventionResourceto find the nearest work shift forpoolKit- thePoolKit- Returns:
- the id of the nearest work shift, or null if no work shift is found
- Throws:
DAValidateException- If there is a validation error.DAException- If an error occurs during the data access.
-
upsertWorkOrderOperationResource
protected void upsertWorkOrderOperationResource(BOInterventionResource interventionResource, PoolKit poolKit) throws DAValidateException, DAException Upserts aBOWorkOrderOperationResourcebased on the providedBOInterventionResource. If a matchingBOWorkOrderOperationResourceis found, the spent time is updated. Otherwise, a newBOWorkOrderOperationResourceis created.- Parameters:
interventionResource- theBOInterventionResourcepoolKit- thePoolKit- Throws:
DAValidateException- If there is a validation error.DAException- If an error occurs during the data access.
-
updateWorkOrderOperationResource
protected void updateWorkOrderOperationResource(BOInterventionResource interventionResource, List<BOWorkOrderOperationResource> workOrderOperationResources, PoolKit poolKit) throws DAValidateException, DAException Updates the spent time of an existingBOWorkOrderOperationResourcebased on the providedBOInterventionResource.- Parameters:
interventionResource- theBOInterventionResourceworkOrderOperationResources- the list of existingBOWorkOrderOperationResourceto updatepoolKit- thePoolKit- Throws:
DAValidateException- If there is a validation error.DAException- If an error occurs during the data access.
-
insertWorkOrderOperationResource
protected void insertWorkOrderOperationResource(BOInterventionResource interventionResource, PoolKit poolKit) throws DAValidateException, DAException Inserts a newBOWorkOrderOperationResourcebased on the providedBOInterventionResource.- Parameters:
interventionResource- theBOInterventionResourceto use for creating the newBOWorkOrderOperationResourcepoolKit- thePoolKit- Throws:
DAValidateException- If there is a validation error.DAException- If an error occurs during the data access.
-
updateWorkOrder
Updates the work order header after an intervention resource has been inserted.- Parameters:
poolKit- thePoolKit- Throws:
DAValidateException- if there is a validation errorDAException- if there is a data access exception
-
notifyInterventionResource
protected void notifyInterventionResource(BOInterventionResource interventionResource, PoolKit poolKit) throws DAValidateException, DAException Sends an intervention resource notification.- Parameters:
interventionResource- TheBOInterventionResourceobject representing the intervention resource.poolKit- ThePoolKit- Throws:
DAValidateException- If there is a validation error.DAException- If an error occurs during the data access.
-
updateValidationStatus
Updates the validation status by calling theInterventionOutcomeValidationStatusUpdateEvent- Parameters:
poolKit- thePoolKit- Throws:
DAValidateException- the DA validate exceptionDAException- the DA exception
-
getIntegrationService
protected WorkOrdersIntegrationService getIntegrationService(PoolKit poolKit) throws DAValidateException Retrieves the WorkOrdersIntegrationService instance. If the instance hasn't been created yet, it will be created and stored for future use.- Parameters:
poolKit- ThePoolKit.- Returns:
- The
WorkOrdersIntegrationServiceinstance. - Throws:
DAValidateException- If any validation error occurs.
-
isValidExecution
public boolean isValidExecution()Description copied from interface:ValidExecutionDetermines whether the current state is valid for execution.- Returns:
- true if execution is valid, false otherwise
-