Class BTWorkOrderHeaderStatusDeductionFromOperations

All Implemented Interfaces:
Serializable, Tool, ValidExecution

Business task in order to calculate the status of a BOWorkOrderHeader using its operations.

When the WorkOrderHeaderStatusDeductionFromOperationsEvent is launched the BT notices the call and calculates the status of the BOWorkOrderHeader basing on the event's input.

Since:
19.0
See Also:
GCApi:
task
  • Constructor Details

    • BTWorkOrderHeaderStatusDeductionFromOperations

      public BTWorkOrderHeaderStatusDeductionFromOperations()
  • Method Details

    • execute

      Updates the status of a BOWorkOrderHeader.
      Specified by:
      execute in class ValidExecutionBusinessTask<WorkOrderHeaderStatusDeductionFromOperationsEvent>
      Parameters:
      event - the WorkOrderHeaderStatusRecalculateEvent
      poolKit - the PoolKit
      Throws:
      DAException - the DA exception
      DAValidateException - the DA validate exception
    • loadWorkOrderOperations

      protected List<BOWorkOrderOperation> loadWorkOrderOperations(Long workOrderId, PoolKit poolKit) throws DAValidateException, DAException
      Loads the operations of a Work Order
      Parameters:
      workOrderId - the Work Order id
      poolKit - the PoolKit
      Returns:
      all the work order operations
      Throws:
      DAValidateException
      DAException
    • calculateWorkOrderHeaderStatus

      public Long calculateWorkOrderHeaderStatus(List<BOWorkOrderOperation> operations, PoolKit poolKit) throws DAValidateException, DAException
      Work Order state automaton.
      The status is deducted starting from the operations.
      Parameters:
      operations - the operations of the Work Order
      poolKit - the PoolKit
      Returns:
      the new work order header status
      Throws:
      DAValidateException
      DAException
    • removeFromSet

      protected Set<Long> removeFromSet(Set<Long> mainSet, Set<Long> valuesToRemove)
      Clones the main set removing all the values defined in the valuesToRemove parameter
      Parameters:
      mainSet - the main set
      valuesToRemove - the set with the values to remove
      Returns:
      a copy of the main set without the elements contained in the valuesToRemove set
    • existsInSet

      protected boolean existsInSet(Set<Long> mainSet, Set<Long> valuesToFind)
      Check if at least one value of the valuesToFind parameter is contained in the mainSet parameter.
      Parameters:
      mainSet - the set with all the data
      valuesToFind - the set with the values to find
      Returns:
      true if at least one value of the valuesToFind parameter is contained in the mainSet parameter, false otherwise.
    • onlyDraftOperations

      protected boolean onlyDraftOperations(List<BOWorkOrderOperation> operations)
      Checks the status of the Work Order Operations
      Parameters:
      operations - the Work Order Operations
      Returns:
      true if all the work order operations are in a draft state, false otherwise
    • getSchedulableOperationsStatus

      protected Set<Long> getSchedulableOperationsStatus(List<BOWorkOrderOperation> operations, PoolKit poolKit) throws DAValidateException, DAException
      Loads the work order operations status related to schedulable operations
      Parameters:
      operations - the operations of the Work Order
      poolKit - the PoolKit
      Returns:
      the work order operations status related to schedulable operations
      Throws:
      DAException
      DAValidateException
    • checkDefaultOpenWOCondition

      protected boolean checkDefaultOpenWOCondition(Set<Long> operationStates)
      Checks if the work order is in status open
      Parameters:
      operationStates - the status of the schedulable operations
      Returns:
      true if there is at least one open operation, false otherwise.
    • onlyClosedOrCancelledActivities

      protected boolean onlyClosedOrCancelledActivities(Set<Long> schedulableOperationsStatus)
      Returns true if all the work order (schedulable) operations are closed or cancelled, false otherwise
      Parameters:
      schedulableOperationsStatus - the status of the scheduled operations
      Returns:
      true if all the work order (schedulable) operations are closed or cancelled, false otherwise
    • loadWorkOrderInterventions

      protected List<InterventionAggregate> loadWorkOrderInterventions(Set<Long> operations, PoolKit poolKit) throws DAException, DAValidateException
      Loads the not cancelled interventions related to the work order operations.
      Parameters:
      operations - the work order operations
      poolKit - the PoolKit
      Returns:
      the interventions related to the work order operations.
      Throws:
      DAException
      DAValidateException
    • isWaitingForTechnicalValidation

      protected boolean isWaitingForTechnicalValidation(List<BOWorkOrderOperation> operations, PoolKit poolKit) throws DAException, DAValidateException
      Returns true if exists at least one work order operation that requires validation, false otherwise
      Parameters:
      operations - the work order operations
      poolKit - the PoolKit
      Returns:
      true if exists at least one work order operation that requires validation, false otherwise
      Throws:
      DAValidateException
      DAException
    • onlyCancelledOperations

      protected boolean onlyCancelledOperations(Set<Long> schedulableOperationsStates)
      Returns true if all the work order (schedulable) operations are cancelled, false otherwise
      Parameters:
      schedulableOperationsStates -
      Returns:
      true if all the work order (schedulable) operations are cancelled, false otherwise
    • isValidExecution

      public boolean isValidExecution()
      Checks if is valid execution.
      Returns:
      true, if successful