ibspan.ecap.merchant.shopdecisions.forecasting
Class ForecastScheduler

java.lang.Object
  extended by ibspan.ecap.merchant.shopdecisions.forecasting.ForecastScheduler

public class ForecastScheduler
extends java.lang.Object

A class managing a list of forecasts scheduled for preparation. A product added for forecast is simply scheduled at a date of the end of the current forecast period.

Author:
Micha³ Drozdowicz

Constructor Summary
ForecastScheduler()
           
 
Method Summary
 void cancelProductForecasts(java.lang.String productId)
          Removes scheduled forecasts for the specified product.
 void confirmTaskCompletion(ForecastTask task)
          Confirms that the forecast result has been received and dispatched and removing it from the pending schedule.
 java.util.Date evaluateNextForecastDate(java.lang.String productId, java.util.Date currentForecastEnd)
          Evaluates a date at which the next forecast of the given product should begin.
 ForecastTask getScheduledTask(java.lang.String productId)
          Retrieves a scheduled task of the specified product.
 java.util.List<ForecastTask> getScheduledTasks(java.util.Date fromDate, java.util.Date toDate)
          Retrieves a list of task scheduled for execution between the given dates.
 java.util.Date scheduleForecast(ForecastTask task)
          Schedules the preparation of the next forecast of the product.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForecastScheduler

public ForecastScheduler()
Method Detail

scheduleForecast

public java.util.Date scheduleForecast(ForecastTask task)
Schedules the preparation of the next forecast of the product.

Parameters:
task - the forecast task to schedule.
Returns:
The date of the next forecast preparation.

evaluateNextForecastDate

public java.util.Date evaluateNextForecastDate(java.lang.String productId,
                                               java.util.Date currentForecastEnd)
Evaluates a date at which the next forecast of the given product should begin.

Parameters:
productId - The global product id of the product to schedule.
currentForecastEnd - The time the current forecast for the product ends.
Returns:
a date at which the next forecast of the given product should begin.

getScheduledTasks

public java.util.List<ForecastTask> getScheduledTasks(java.util.Date fromDate,
                                                      java.util.Date toDate)
Retrieves a list of task scheduled for execution between the given dates.

Parameters:
fromDate - the beginning of the period to which the scheduled dates belong
toDate - the end of the period to which the scheduled dates belong
Returns:
a list of scheduled tasks

getScheduledTask

public ForecastTask getScheduledTask(java.lang.String productId)
Retrieves a scheduled task of the specified product.

Parameters:
productId - the id of the product the forecast task of which is to be returned
Returns:
a forecast task of the specified product

cancelProductForecasts

public void cancelProductForecasts(java.lang.String productId)
Removes scheduled forecasts for the specified product.

Parameters:
productId - the global id of the product, which forecasts are to be cancelled.

confirmTaskCompletion

public void confirmTaskCompletion(ForecastTask task)
Confirms that the forecast result has been received and dispatched and removing it from the pending schedule.

Parameters:
task - the task to confirm