Class WorkOrderUtil

java.lang.Object
overit.geocallapp.wfm.core.bl.workorder.WorkOrderUtil

public class WorkOrderUtil extends Object
Utility class to work with the WorkOrder
  • Method Details

    • loadCustomerMeasuringElements

      public static DBView loadCustomerMeasuringElements(Long addressId, PooledConnection conn)
      Load the DBView of the measuring elements related to the given address id.
      Parameters:
      addressId - the address id for which retrieve the measuring elements
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Returns:
      a DBView with the retrieved measuring elements
    • findInterventionGroup

      public static Long findInterventionGroup(Long workOrderTypeId, Long workOrderOperationTypeId, PooledConnection conn)
      Try to identify the intervention group defined for the activity related to the given work order type and operation type
      Parameters:
      workOrderTypeId - the work order type id to use
      workOrderOperationTypeId - the work order operation type id to use
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Returns:
      the id of the retrieved intervention group if exists, null otherwise
    • loadWorkOrderTypeByComponents

      public static HashGetter loadWorkOrderTypeByComponents(Long workOrderRequestTypeId, Long workOrderServiceTypeId, Long technicalObjectTypeId, PooledConnection conn)
      Given the work order type main components, this method try to retrieve a work order type. If more than one component match the input, the first one will be returned
      Parameters:
      workOrderRequestTypeId - the work order request type id to use
      workOrderServiceTypeId - the work order service type id to use
      technicalObjectTypeId - the technical object type id to use
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Returns:
      the raw data of the first matching work order type
    • evaluateNewWorkOrderState

      public static Long evaluateNewWorkOrderState(Long workOrderTypeId, Long workOrderOriginId, BOWorkOrderHeader workOrderHeader, PooledConnection conn)
      Evaluate the starting state for a new Work Order looking at the defined rules
      Parameters:
      workOrderTypeId - the work order type of the new work order
      workOrderOriginId - the id that identify the work order source
      workOrderHeader - BOWorkOrderHeader the whole work order header
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Returns:
      the evaluated work order state if the given input match a rule, BOWorkOrderState.Values.OPEN as default otherwise.
    • evaluateNewWorkOrderState

      public static Long evaluateNewWorkOrderState(WorkOrder workOrder, PoolKit poolKit) throws DAException
      Evaluate the starting state for a new Work Order looking at the defined rules.
      Parameters:
      workOrder - the work order
      poolKit - a PoolKit to execute the operation in transaction. Can't be null.
      Returns:
      the evaluated work order state if the given input match a rule, BOWorkOrderState.Values.OPEN as default otherwise.
      Throws:
      DAException - the DA exception
    • loadLinkedWorkOrders

      public static DBView loadLinkedWorkOrders(Long workOrderId)
      Load the DBView with the raw data of the work order linked with given one
      Parameters:
      workOrderId - the work order id for which retrieve the linked work orders
      Returns:
      the DBView (eventually empty if no work orders are linked with the given one)
    • load

      public static WorkOrder load(Long id) throws DAValidateException
      Load the WorkOrder object with all its components
      Parameters:
      id - the id of the work order to load
      Returns:
      the whole WorkOrder object loaded
      Throws:
      DAValidateException - if something went wrong in the loading process
    • load

      public static WorkOrder load(Long id, PooledConnection conn) throws DAValidateException
      Load the WorkOrder object with all its components
      Parameters:
      id - the id of the work order to load
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Returns:
      the whole WorkOrder object loaded
      Throws:
      DAValidateException - if something went wrong in the loading process
    • refreshOperations

      public static void refreshOperations(WorkOrder workOrder) throws DAValidateException
      Allow to load and refresh the operation in memory of a given WorkOrder object
      Parameters:
      workOrder - the WorkOrder for which refresh the operations list
      Throws:
      DAValidateException - if something went wrong in the loading process
    • refreshOperations

      public static void refreshOperations(WorkOrder workOrder, PooledConnection conn) throws DAValidateException
      Allow to load and refresh the operation in memory of a given WorkOrder object
      Parameters:
      workOrder - the WorkOrder for which refresh the operations list
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Throws:
      DAValidateException - if something went wrong in the loading process
    • checkInterventionGroupNetaCustomerStateMatching

      public static boolean checkInterventionGroupNetaCustomerStateMatching(BOTechnicalObjectHeader technicalObjectHeader, Long interventioGroupId)
      Check if the Neta Integration customer state match the intervention group configuration
      Parameters:
      technicalObjectHeader - the technical object to check
      interventioGroupId - the id of the intervention group to consider
      Returns:
      true if the check is ok, false otherwise
    • findDefaultWareHouseId

      public static Long findDefaultWareHouseId(WorkOrder workOrder)
      Retrieve the id of the default warehouse for the operation center of the given work order
      Parameters:
      workOrder - the work order
      Returns:
      the id of the default warehouse if exists. Null otherwise.
    • loadAssociatedMaterials

      public static void loadAssociatedMaterials(WorkOrder workOrder) throws DAValidateException
      Load and set as extension of the BOWorkOrderOperations of the given work order the raw data of the materials related to them
      Parameters:
      workOrder - the work order for which load the associated materials
      Throws:
      DAValidateException - if something went wrong in the loading process
      See Also:
    • loadAssociatedMaterials

      public static void loadAssociatedMaterials(WorkOrder workOrder, PooledConnection conn) throws DAValidateException
      Load and set as extension of the BOWorkOrderOperations of the given work order the raw data of the materials related to them
      Parameters:
      workOrder - the work order for which load the associated materials
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Throws:
      DAValidateException - if something went wrong in the loading process
      See Also:
    • loadAssociatedMaterials

      public static void loadAssociatedMaterials(BOWorkOrderOperation operation) throws DAValidateException
      Load and set as extension of the given BOWorkOrderOperation the materials associated with the operation
      Parameters:
      operation - the BOWorkOrderOperation for which load the associated materials
      Throws:
      DAValidateException - if something went wrong in the loading process
    • loadMaterialiAssociati

      public static void loadMaterialiAssociati(BOWorkOrderOperation operation, PooledConnection conn) throws DAValidateException
      Load and set as extension of the given BOWorkOrderOperation the materials associated with the operation
      Parameters:
      operation - the BOWorkOrderOperation for which load the associated materials
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Throws:
      DAValidateException - if something went wrong in the loading process
    • save

      public static void save(WorkOrder workOrder) throws DAException, DAValidateException
      Store the whole WorkOrder informations, including BOWorkOrderOperation and TechnicalObject
      Parameters:
      workOrder - the work order to save
      Throws:
      DAException - the DA exception
      DAValidateException - the DA validate exception
    • save

      public static void save(WorkOrder workOrder, PooledConnection conn) throws DAException, DAValidateException
      Store the whole WorkOrder informations, including BOWorkOrderOperation and TechnicalObject
      Parameters:
      workOrder - the work order to save
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Throws:
      DAException - the DA exception
      DAValidateException - the DA validate exception
    • save

      public static void save(WorkOrder workOrder, WorkOrderSaveEventOptions options, PooledConnection conn) throws DAException, DAValidateException
      Store the whole WorkOrder informations, including BOWorkOrderOperation and TechnicalObject
      Parameters:
      workOrder - the work order to save
      options - workOrder saving specific options
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Throws:
      DAException - the DA exception
      DAValidateException - the DA validate exception
      See Also:
    • getWorkOrderTypeRawData

      public static HashGetter getWorkOrderTypeRawData(WorkOrder workOrder)
      Retrieve the raw data of the work order type of the given work order
      Parameters:
      workOrder - the WorkOrder for which retrieve the work order type data
      Returns:
      the HashGetter with the raw data of the retrieved work order type
    • isFromNetaIntegration

      public static boolean isFromNetaIntegration(WorkOrder workOrder)
      Say if the given WorkOrder has a type related to a Neta type.
      Parameters:
      workOrder - the WorkOrder to analyze
      Returns:
      true if the given WorkOrder is related to a Neta type, false otherwise
    • isDuplicable

      public static boolean isDuplicable(WorkOrder workOrder)
      Say if the given WorkOrder can be duplicated
      Parameters:
      workOrder - the WorkOrder to analyze
      Returns:
      true if the given WorkOrder can be duplicated, false otherwise
    • loadOperationObjectList

      public static overit.geocallapp.wfm.schedulazione.odl.listaoggetti.TechnicalObjectList loadOperationObjectList(BOWorkOrderOperation operation, PooledConnection conn) throws DAValidateException, DAException
      Retrieve the TechnicalObjectList containing the TechnicalObjects associated with the given BOWorkOrderOperation
      Parameters:
      operation - the BOWorkOrderOperation for which retrieve the TechnicalObjectList
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Returns:
      the TechnicalObjectList
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • loadWorkOrderOperationsTools

      public static void loadWorkOrderOperationsTools(WorkOrder workOrder, PooledConnection conn) throws DAValidateException
      For each BOWorkOrderOperation of the given WorkOrder load and set as extension the raw data of the related tools.
      Parameters:
      workOrder - the WorkOrder to for which retrieve the tools
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Throws:
      DAValidateException - if something went wrong in the loading process
    • loadWorkOrderOperationsPerformances

      public static void loadWorkOrderOperationsPerformances(WorkOrder workOrder) throws DAValidateException
      For each BOWorkOrderOperation of the given WorkOrder load and set as extension the raw data of the related performances.
      Parameters:
      workOrder - the WorkOrder to for which retrieve the performances
      Throws:
      DAValidateException - if something went wrong in the loading process
    • loadWorkOrderOperationsPerformances

      public static void loadWorkOrderOperationsPerformances(WorkOrder workOrder, PooledConnection conn) throws DAValidateException
      For each BOWorkOrderOperation of the given WorkOrder load and set as extension the raw data of the related performances.
      Parameters:
      workOrder - the WorkOrder to for which retrieve the performances
      conn - a PooledConnection to execute the operation in transaction. Can be null.
      Throws:
      DAValidateException - if something went wrong in the loading process
    • getDefaultInterventionGroupId

      public static Long getDefaultInterventionGroupId()
      Load the default intervention group id
      Returns:
      the default intervention group configured at company level
    • getIdBookingOperation

      public static Long getIdBookingOperation(WorkOrder workOrder)
      Inspect the WorkOrder to find the first BOWorkOrderOperation marked as booking
      Parameters:
      workOrder - the WorkOrder to inspect
      Returns:
      the id of the first BOWorkOrderOperation marked as booking if exists, null otherwise.
    • isBooking

      public static boolean isBooking(WorkOrder workOrder)
      Say if the given WorkOrder can be considered as booking
      Parameters:
      workOrder - the WorkOrder to consider
      Returns:
      true if the WorkOrder can be considered as booking, false otherwise
    • getResidualTime

      public static Long getResidualTime(WorkOrder workOrder)
      Returns the difference in time between the current date and the work order end one.
      Parameters:
      workOrder - the WorkOrder to consider
      Returns:
      the work order residual time in minutes, null when the end date is null or is equal to DateUtils.DATE_MAX