All Implemented Interfaces:
Serializable, Tool, ValidExecution

Since:
18.0
See Also:
GCApi:
task
  • Field Details

    • activityId

      protected Long activityId
  • Constructor Details

    • BTActivityRemoval

      public BTActivityRemoval()
  • Method Details

    • isValidExecution

      public boolean isValidExecution()
      Description copied from interface: ValidExecution
      Determines whether the current state is valid for execution.
      Returns:
      true if execution is valid, false otherwise
    • getIntegrationService

      protected SchedulingIntegrationService getIntegrationService(PoolKit poolKit) throws DAValidateException
      Throws:
      DAValidateException
    • execute

      protected void execute(ActivityRemovalEvent event, PoolKit poolKit) throws DAException, DAValidateException
      Description copied from class: ValidExecutionBusinessTask
      Executes the actual business logic after validation has passed.
      Specified by:
      execute in class ValidExecutionBusinessTask<ActivityRemovalEvent>
      Parameters:
      event - the input event to process
      poolKit - the PoolKit
      Throws:
      DAException - if a data access error occurs during execution
      DAValidateException - if validation fails during execution
    • initializeContext

      protected void initializeContext(PoolKit poolKit) throws DAValidateException, DAException
      Initialize the context object that will store all the data and configurations of the task.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • getContext

      public ManualRemovalContext getContext()
    • setContext

      public void setContext(ManualRemovalContext context)
    • retrieveAppointment

      protected void retrieveAppointment(PoolKit poolKit) throws DAValidateException, DAException
      Retrieve the appointment related to the activity to remove.
      For not multi-day activities, we will have only one open appointment, or one or more close appointments (activities with outcome that can also be cancelled)
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException
      DAException
    • retrieveAgenda

      protected void retrieveAgenda(PoolKit poolKit) throws DAValidateException, DAException
      Retrieve the agenda related to the activity to remove.
      At this point we have already calculated the right appointment, so we can have only one open or closed agenda
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException
      DAException
    • prepareTeam

      protected void prepareTeam(PoolKit poolKit) throws DAValidateException, DAException
      The method distinguishes between two main scenarios: 1. Empty Crew Shell Scenario: If the foreman is marked as a "dummy", the method identifies this as an empty crew shell scenario. Empty crew shell scenario means that the crew shell is empty or the technicians still don't have the transferred scheduling. It retrieves the corresponding BOCrewShell using the foremanId. 2. Single, Team, and Crew Shell with Technician Scenario(technicians already have the transferred scheduling): If the foreman is not a dummy, the method identifies this as a scenario where actual scheduling is involved. It retrieves a list of BOScheduling objects representing scheduled activities. From these, it filters out the work shift associated with the foreman and stores it in workShiftForeman. If workShiftForeman is part of a crew shell, the method retrieves the corresponding BOCrewShellComposition and loads the BOCrewShell. Team Construction: Depending on whether a crewShell is available: 1. Without Crew Shell: The method collects the IDs of the team members from their work shifts and ensures the workShiftForemanId is not null. It then constructs a SchedulingTeam using the SchedulingTeamBuilder. 2. With Crew Shell: The method constructs a SchedulingTeam using the CrewShellSchedulingTeamBuilder, passing in the crewShell and startDate.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException - if there are any issues with the data retrieved
      DAException - if there are any other exceptions during the data retrieval process
    • findActivitySchedulings

      protected List<BOScheduling> findActivitySchedulings(PoolKit poolKit) throws DAValidateException, DAException
      Loads the schedulings related to the activity to remove
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException
      DAException
    • getWorkShiftFromScheduling

      protected List<BOWorkShift> getWorkShiftFromScheduling(List<BOScheduling> schedulings, PoolKit poolKit) throws DAValidateException, DAException
      Retrieves the work shifts associated with the team members in the provided list of schedulings.
      Parameters:
      schedulings - The list of BOScheduling objects to retrieve the work shifts for.
      poolKit - The PoolKit
      Returns:
      A list of BOWorkShift objects representing the work shifts for the team members.
      Throws:
      DAValidateException - If there is an issue validating the input data.
      DAException - If there is an error retrieving the work shifts.
    • checkActivity

      protected void checkActivity() throws DAValidateException
      Checks the status of the work-order operation before start the scheduling process.
      Throws:
      DAValidateException - the DA validate exception
    • checkLinkedActivity

      protected void checkLinkedActivity() throws DAValidateException
      Checks if the activity is related to another activity, and stop the process if necessary
      Throws:
      DAValidateException - the DA validate exception
    • checkFreezingDay

      protected void checkFreezingDay(PoolKit poolKit) throws DAValidateException, DAException
      Check if the activity can be removed evaluating the freezing days defined in the operation center.
      Activities scheduled before today or scheduled in freezing days cannot be removed.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • getLock

      protected SchedulingLock getLock() throws DAException, DAValidateException
      Gets the timeslot for the activity removal
      Returns:
      Throws:
      DAException
      DAValidateException
    • removeActivity

      protected void removeActivity(PoolKit poolKit) throws DAValidateException, DAException
      Remove all the schedulings of the input activity.
      In this version of the removal activity functionality, we don't support linked activities,
      so the full set of schedulings to remove is completely defined into the SchedulingTeam schedulings
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAException
      DAValidateException
    • updatedPreviousAndNextSchedulings

      protected void updatedPreviousAndNextSchedulings(SchedulingTeamResource resource, PoolKit poolKit) throws DAValidateException, DAException
      Calculates the new time and space distance for the previous and the next schedulings.
      Parameters:
      resource - the SchedulingTeamResource
      poolKit - the PoolKit
      Throws:
      DAValidateException
      DAException
    • getScheduledActivityAddress

      protected Long getScheduledActivityAddress(BOScheduling scheduling, PoolKit poolKit) throws DAValidateException, DAException
      Returns the address Id of the input scheduling
      Parameters:
      scheduling - the BOScheduling
      poolKit - the PoolKit
      Returns:
      the address Id of the input scheduling
      Throws:
      DAValidateException
      DAException
    • updateNextSchedulingsOrder

      protected void updateNextSchedulingsOrder(SchedulingTeamResource resource)
      Updates the execution order of all the schedulings after the current one.
    • updatedFirstSchedulingArrivalDate

      protected void updatedFirstSchedulingArrivalDate(SchedulingTeamResource resource)
      Updates the arrival date of the new first activity if the removed activity was the first of the day.
    • updateWorkshiftTourData

      protected void updateWorkshiftTourData(SchedulingTeamResource resource, PoolKit poolKit) throws DAValidateException, DAException
      Calculates the new tour data for the current work shift and updates all the schedulings.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • calculateMissingSkills

      protected void calculateMissingSkills(PoolKit poolKit) throws DAValidateException, DAException
      Calculates the resource/team missing skills for the current work order operation.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • updateSchedulings

      protected void updateSchedulings(PoolKit poolKit) throws DAValidateException, DAException
      Save all the schedulings of the work shifts.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • updateStatus

      protected void updateStatus(PoolKit poolKit) throws DAValidateException, DAException
      Method that calls UpdateStatusRemovalSchedulingEvent and updates the status of the appointment, agenda, work order and operation entities related to the scheduling.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • saveInitialSchedulings

      protected void saveInitialSchedulings()
      Saves the initial list of scheduling of the agenda in order to call the procedure that replace the trigger
    • getAllResourcesSchedulings

      protected List<BOScheduling> getAllResourcesSchedulings()
      Gets a list of all the work shift scheduling for all the resources in the team.
      Returns:
      a list of BOScheduling
    • alignAgenda

      protected void alignAgenda(PoolKit poolKit) throws DAException, DAValidateException
      Method that calls the align agenda task, this task will do some checks and modify values related to the agendas of the scheduling. This is the call to the new business task that is replacing the trigger AGGIORNAAAGENDA.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAException - the DA exception
      DAValidateException - the DA validate exception
    • savePlanningHistory

      protected void savePlanningHistory(PoolKit poolKit) throws DAValidateException, DAException
      Launch PlanningActionHistorySaveEvent to save a planning action history.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • launchPlanningAction

      protected void launchPlanningAction(PoolKit poolKit) throws DAValidateException, DAException
      Notify the activity removal in order to launch the planning action
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAValidateException
      DAException
    • launchSchedulingCheckEvent

      protected void launchSchedulingCheckEvent(PoolKit poolKit) throws DAValidateException, DAException
      Event for notify that some schedulings has been removed.
      Parameters:
      poolKit - the pool kit
      Throws:
      DAValidateException - the DA validate exception
      DAException - the DA exception
    • launchCompleteRemovalActionEvent

      protected void launchCompleteRemovalActionEvent(PoolKit poolKit) throws DAException, DAValidateException
      Launch SchedulingNotificationEvent to notify that the scheduling removal action is completed.
      Parameters:
      poolKit - the PoolKit
      Throws:
      DAException - the DA exception
      DAValidateException - the DA validate exception
    • getChangedSchedulings

      protected Set<Long> getChangedSchedulings()
      Retrieves a set of all scheduling IDs associated with the team resources. This includes the previous scheduling ID for each resource, as well as the IDs of all schedulings in the work shift schedule for each resource
      Returns:
      a set of scheduling IDs
    • buildOutput

      protected void buildOutput()
      Builds the response object of the paste task