.

RescheduleSchedulerBaseCommand Class Reference

Reschedule a given task. More...

Inheritance diagram for RescheduleSchedulerBaseCommand:
CommandChain CommandBase ICommand IAction ISerializable RescheduleSchedulerCommand

List of all members.

Public Member Functions

  get_description ()
  Returns a description of this command.
  get_name ()
  Returns title of command.

Protected Member Functions

  do_execute ()
  Does executing.
  do_reschedule (DAOScheduler $task, $policy, $params, $new_status, Status $err)
  Actually perform rescheduling.
  error_get_params (DAOScheduler $task, Status $err)
  Return properties of rescheduled tasks.
  error_on_give_up (DAOScheduler $task, $params, Status $err)
  Called if task was not successfull and does not get rescheduled any more.
  error_on_rescheduled (DAOScheduler $task, $params, Status $err)
  Called if task was not successfull and rescheduled.
  reschedule_error (DAOScheduler $task, Status $err)
  Reschedule on error.
  reschedule_success (DAOScheduler $task, Status $err)
  Reschedule on success.
  success_get_params (DAOScheduler $task, Status $err)
  Return properties of rescheduled tasks.
  success_on_finished (DAOScheduler $task, $params, Status $err)
  Called if task was successfull and does not get rescheduled any more.
  success_on_rescheduled (DAOScheduler $task, $params, Status $err)
  Called if task was successfull and rescheduled.

Detailed Description

Reschedule a given task.

Definition at line 5 of file reschedulescheduler.cmd.php.


Member Function Documentation

RescheduleSchedulerBaseCommand::do_execute (  )  [protected]

Does executing.

Reimplemented from CommandChain.

Definition at line 9 of file reschedulescheduler.cmd.php.

00009                                         {
00010                 $ret = new Status();
00011 
00012                 /* @var $task DAOScheduler */
00013                 $task = $this->get_instance();
00014                 /* @var $err Status */
00015                 $err = $this->get_params();
00016                 
00017                 if ($err->is_ok()) {
00018                         $ret->merge($this->reschedule_success($task, $err));
00019                 }
00020                 else {
00021                         $ret->merge($this->reschedule_error($task, $err));
00022                 }
00023                 
00024                 return $ret;
00025         } 
RescheduleSchedulerBaseCommand::do_reschedule ( DAOScheduler task,
policy,
params,
new_status,
Status err  
) [protected]

Actually perform rescheduling.

Parameters:
DAOScheduler  $task The task to reschedule
string  $policy Reschedule policy. Must map to a file and class in behaviour/scheduler
array  $params Params for updateing task
string  $new_status Either ACTIVE or RESCHEDULED
Status  $err The result of the task
Returns:
bool TRUE if task was rescheduled. FALSE if task has had its last run and no rescheduling was done

Definition at line 173 of file reschedulescheduler.cmd.php.

00173                                                                                                          {
00174                 $ret = false;
00175                 
00176                 $policy = strtolower($policy);
00177                 Load::classes_in_directory('behaviour/scheduler/', $policy, 'rescheduler');
00178                 $cls = 'Rescheduler' . ucfirst($policy);
00179                 $rescheduler = new $cls();
00180 
00181                 $newdate = $rescheduler->reschedule($task, $err);
00182                 if ($newdate !== false) {
00183                         // Reschedule
00184                         $params['scheduledate'] = $newdate;
00185                         $this->append(CommandsFactory::create_command($task, 'update', $params));
00186                         $this->append(CommandsFactory::create_command($task, 'status', $new_status));
00187                         
00188                         $ret = true;
00189                 }
00190 
00191                 return $ret;
00192         }
RescheduleSchedulerBaseCommand::error_get_params ( DAOScheduler task,
Status err  
) [protected]

Return properties of rescheduled tasks.

Parameters:
DAOScheduler  $task The task to reschedule
Status  $err The result of task's last run
Returns:
array

Definition at line 126 of file reschedulescheduler.cmd.php.

00126                                                                              {
00127                 return array(
00128                         'runs_success' => $task->runs_success,
00129                         'runs_error' => $task->runs_error + 1,
00130                         'error_message' => $err->to_string(Status::OUTPUT_PLAIN),
00131                 );              
00132         }
RescheduleSchedulerBaseCommand::error_on_give_up ( DAOScheduler task,
params,
Status err  
) [protected]

Called if task was not successfull and does not get rescheduled any more.

Parameters:
DAOScheduler  $task The task to reschedule
array  $params Params for updateing task
Status  $err The result of the task
Returns:
Status

Definition at line 156 of file reschedulescheduler.cmd.php.

00156                                                                                       {
00157                 $this->append(CommandsFactory::create_command($task, 'update', $params));
00158                 $this->append(CommandsFactory::create_command($task, 'status', Scheduler::STATUS_ERROR));
00159                 return new Status();
00160         }       
RescheduleSchedulerBaseCommand::error_on_rescheduled ( DAOScheduler task,
params,
Status err  
) [protected]

Called if task was not successfull and rescheduled.

Parameters:
DAOScheduler  $task The task to reschedule
array  $params Params for updateing task
Status  $err The result of the task
Returns:
Status

Definition at line 143 of file reschedulescheduler.cmd.php.

00143                                                                                           {
00144                 return new Status();
00145         }
RescheduleSchedulerBaseCommand::get_description (  ) 

Returns a description of this command.

Reimplemented from CommandBase.

Definition at line 204 of file reschedulescheduler.cmd.php.

00204                                           {
00205                 return tr('Reschedule', 'scheduler');   
00206         }       
RescheduleSchedulerBaseCommand::get_name (  ) 

Returns title of command.

Reimplemented from CommandBase.

Definition at line 197 of file reschedulescheduler.cmd.php.

00197                                    {
00198                 return 'reschedule';
00199         }
RescheduleSchedulerBaseCommand::reschedule_error ( DAOScheduler task,
Status err  
) [protected]

Reschedule on error.

Parameters:
DAOScheduler  $task The task to reschedule
Status  The result of task's last run
Returns:
Status

Definition at line 102 of file reschedulescheduler.cmd.php.

00102                                                                              {
00103                 $ret = new Status();
00104                 
00105                 $policy = $task->reschedule_error;
00106                 $params = $this->error_get_params($task, $err);
00107                 
00108                 if ($this->do_reschedule($task, $policy, $params, Scheduler::STATUS_RESCHEDULED, $err)) {
00109                         $ret->merge($this->error_on_rescheduled($task, $params, $err));
00110                 }
00111                 else {
00112                         $ret->merge($this->error_on_give_up($task, $params, $err));
00113                 }
00114                 
00115                 return $ret;
00116         }
RescheduleSchedulerBaseCommand::reschedule_success ( DAOScheduler task,
Status err  
) [protected]

Reschedule on success.

Parameters:
DAOScheduler  $task The task to reschedule
Status  $err The result of task's last run
Returns:
Status

Definition at line 35 of file reschedulescheduler.cmd.php.

00035                                                                                {
00036                 $ret = new Status();
00037                 
00038                 $policy = $task->reschedule_success;
00039                 $params = $this->success_get_params($task, $err);
00040                 
00041                 if ($this->do_reschedule($task, $policy, $params, Scheduler::STATUS_ACTIVE, $err)) {
00042                         $ret->merge($this->success_on_rescheduled($task, $params, $err));
00043                 }
00044                 else {
00045                         $ret->merge($this->success_on_finished($task, $params, $err));
00046                 }
00047                 
00048                 return $ret;            
00049         }
RescheduleSchedulerBaseCommand::success_get_params ( DAOScheduler task,
Status err  
) [protected]

Return properties of rescheduled tasks.

Parameters:
DAOScheduler  $task The task to reschedule
Status  $err The result of task's last run
Returns:
array

Definition at line 59 of file reschedulescheduler.cmd.php.

00059                                                                                {
00060                 return array(
00061                         'runs_success' => $task->runs_success + 1,
00062                         'runs_error' => 0,
00063                         'error_message' => '',
00064                 );                              
00065         }
RescheduleSchedulerBaseCommand::success_on_finished ( DAOScheduler task,
params,
Status err  
) [protected]

Called if task was successfull and does not get rescheduled any more.

Parameters:
DAOScheduler  $task The task to reschedule
array  $params Params for updateing task
Status  $err The result of the task
Returns:
Status

Definition at line 89 of file reschedulescheduler.cmd.php.

00089                                                                                          {
00090                 $this->append(CommandsFactory::create_command($task, 'delete', false));
00091                 return new Status();
00092         }
RescheduleSchedulerBaseCommand::success_on_rescheduled ( DAOScheduler task,
params,
Status err  
) [protected]

Called if task was successfull and rescheduled.

Parameters:
DAOScheduler  $task The task to reschedule
array  $params Params for updateing task
Status  $err The result of the task
Returns:
Status

Definition at line 76 of file reschedulescheduler.cmd.php.

00076                                                                                             {
00077                 return new Status();
00078         }

The documentation for this class was generated from the following file: