Exemplo n.º 1
0
 public static function shouldCreateLockObject(BatchJob $batchJob, $isNew, PropelPDO $con = null)
 {
     if ($isNew) {
         if (in_array($batchJob->getStatus(), self::getSchedulingRequiredStatusList())) {
             return true;
         }
         return false;
     }
     $oldStatus = $batchJob->getColumnsOldValue(BatchJobPeer::STATUS);
     $oldValueInClosed = is_null($oldStatus) ? false : in_array($oldStatus, BatchJobPeer::getClosedStatusList());
     $newValue = $batchJob->getStatus();
     $newValueInOpen = in_array($newValue, BatchJobPeer::getUnClosedStatusList());
     // if the object is not a new object, a batch_job_lock object should exist.
     // an exception is when we move from a closed state to a open open.
     // f.i. retry request of an entry that was in closed status and we now restarted it.
     if (!($oldValueInClosed && $newValueInOpen)) {
         return false;
     }
     $lockEntry = BatchJobLockPeer::retrieveByPK($batchJob->getId());
     if ($lockEntry === null) {
         return true;
     }
     return false;
 }