Example #1
0
 private function insertAfter($scheduleItems, $schedFiles, $adjustSched = true)
 {
     try {
         $affectedShowInstances = array();
         //dont want to recalculate times for moved items.
         $excludeIds = array();
         foreach ($schedFiles as $file) {
             if (isset($file["sched_id"])) {
                 $excludeIds[] = intval($file["sched_id"]);
             }
         }
         $startProfile = microtime(true);
         foreach ($scheduleItems as $schedule) {
             $id = intval($schedule["id"]);
             if ($id !== 0) {
                 $schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
                 $instance = $schedItem->getCcShowInstances($this->con);
                 $schedItemEndDT = $schedItem->getDbEnds(null);
                 $nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
             } else {
                 $instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
                 $showStartDT = $instance->getDbStarts(null);
                 $nextStartDT = $this->findNextStartTime($showStartDT, $instance);
             }
             if (!in_array($instance->getDbId(), $affectedShowInstances)) {
                 $affectedShowInstances[] = $instance->getDbId();
             }
             if ($adjustSched === true) {
                 $pstart = microtime(true);
                 $followingSchedItems = CcScheduleQuery::create()->filterByDBStarts($nextStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL)->filterByDbInstanceId($instance->getDbId())->filterByDbId($excludeIds, Criteria::NOT_IN)->orderByDbStarts()->find($this->con);
                 $pend = microtime(true);
                 Logging::debug("finding all following items.");
                 Logging::debug(floatval($pend) - floatval($pstart));
             }
             foreach ($schedFiles as $file) {
                 $endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
                 //item existed previously and is being moved.
                 //need to keep same id for resources if we want REST.
                 if (isset($file['sched_id'])) {
                     $sched = CcScheduleQuery::create()->findPK($file['sched_id'], $this->con);
                 } else {
                     $sched = new CcSchedule();
                 }
                 Logging::info($file);
                 $sched->setDbStarts($nextStartDT)->setDbEnds($endTimeDT)->setDbCueIn($file['cuein'])->setDbCueOut($file['cueout'])->setDbFadeIn($file['fadein'])->setDbFadeOut($file['fadeout'])->setDbClipLength($file['cliplength'])->setDbInstanceId($instance->getDbId());
                 switch ($file["type"]) {
                     case 0:
                         $sched->setDbFileId($file['id']);
                         break;
                     case 1:
                         $sched->setDbStreamId($file['id']);
                         break;
                     default:
                         break;
                 }
                 $sched->save($this->con);
                 $nextStartDT = $endTimeDT;
             }
             if ($adjustSched === true) {
                 $pstart = microtime(true);
                 //recalculate the start/end times after the inserted items.
                 foreach ($followingSchedItems as $item) {
                     $endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
                     $item->setDbStarts($nextStartDT);
                     $item->setDbEnds($endTimeDT);
                     $item->save($this->con);
                     $nextStartDT = $endTimeDT;
                 }
                 $pend = microtime(true);
                 Logging::debug("adjusting all following items.");
                 Logging::debug(floatval($pend) - floatval($pstart));
             }
         }
         $endProfile = microtime(true);
         Logging::debug("finished adding scheduled items.");
         Logging::debug(floatval($endProfile) - floatval($startProfile));
         //update the status flag in cc_schedule.
         $instances = CcShowInstancesQuery::create()->filterByPrimaryKeys($affectedShowInstances)->find($this->con);
         $startProfile = microtime(true);
         foreach ($instances as $instance) {
             $instance->updateScheduleStatus($this->con);
         }
         $endProfile = microtime(true);
         Logging::debug("updating show instances status.");
         Logging::debug(floatval($endProfile) - floatval($startProfile));
         $startProfile = microtime(true);
         //update the last scheduled timestamp.
         CcShowInstancesQuery::create()->filterByPrimaryKeys($affectedShowInstances)->update(array('DbLastScheduled' => new DateTime("now", new DateTimeZone("UTC"))), $this->con);
         $endProfile = microtime(true);
         Logging::debug("updating last scheduled timestamp.");
         Logging::debug(floatval($endProfile) - floatval($startProfile));
     } catch (Exception $e) {
         Logging::debug($e->getMessage());
         throw $e;
     }
 }
 /**
  * Filter the query by a related CcSchedule object
  *
  * @param     CcSchedule $ccSchedule  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    CcWebstreamQuery The current query, for fluid interface
  */
 public function filterByCcSchedule($ccSchedule, $comparison = null)
 {
     return $this->addUsingAlias(CcWebstreamPeer::ID, $ccSchedule->getDbStreamId(), $comparison);
 }
 /**
  * Filter the query by a related CcSchedule object
  *
  * @param     CcSchedule $ccSchedule  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    CcWebstreamMetadataQuery The current query, for fluid interface
  */
 public function filterByCcSchedule($ccSchedule, $comparison = null)
 {
     return $this->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $ccSchedule->getDbId(), $comparison);
 }
Example #4
0
 /**
  * Exclude object from result
  *
  * @param     CcSchedule $ccSchedule Object to remove from the list of results
  *
  * @return    CcScheduleQuery The current query, for fluid interface
  */
 public function prune($ccSchedule = null)
 {
     if ($ccSchedule) {
         $this->addUsingAlias(CcSchedulePeer::ID, $ccSchedule->getDbId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Filter the query by a related CcSchedule object
  *
  * @param     CcSchedule $ccSchedule  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    CcShowInstancesQuery The current query, for fluid interface
  */
 public function filterByCcSchedule($ccSchedule, $comparison = null)
 {
     return $this->addUsingAlias(CcShowInstancesPeer::ID, $ccSchedule->getDbInstanceId(), $comparison);
 }
Example #6
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      CcSchedule $value A CcSchedule object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(CcSchedule $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getDbId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
 public static function fillPreservedLinkedShowContent($ccShow, $showStamp)
 {
     $item = $showStamp->getFirst();
     $timeFilled = $item->getCcShowInstances()->getDbTimeFilled();
     foreach ($ccShow->getCcShowInstancess() as $ccShowInstance) {
         $ccSchedules = CcScheduleQuery::create()->filterByDbInstanceId($ccShowInstance->getDbId())->find();
         if ($ccSchedules->isEmpty()) {
             $nextStartDT = $ccShowInstance->getDbStarts(null);
             foreach ($showStamp as $item) {
                 $endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
                 $ccSchedule = new CcSchedule();
                 $ccSchedule->setDbStarts($nextStartDT)->setDbEnds($endTimeDT)->setDbFileId($item->getDbFileId())->setDbStreamId($item->getDbStreamId())->setDbClipLength($item->getDbClipLength())->setDbFadeIn($item->getDbFadeIn())->setDbFadeOut($item->getDbFadeOut())->setDbCuein($item->getDbCueIn())->setDbCueOut($item->getDbCueOut())->setDbInstanceId($ccShowInstance->getDbId())->setDbPosition($item->getDbPosition())->save();
                 $nextStartDT = self::findTimeDifference($endTimeDT, Application_Model_Preference::GetDefaultCrossfadeDuration());
             }
             //foreach show item
             $ccShowInstance->setDbTimeFilled($timeFilled)->setDbLastScheduled(gmdate("Y-m-d H:i:s"))->save();
         }
     }
 }
Example #8
0
 private function findNextStartTime($DT, $instanceId)
 {
     $sEpoch = $DT->format("U.u");
     $nEpoch = $this->epochNow;
     //check for if the show has started.
     if (bccomp($nEpoch, $sEpoch, 6) === 1) {
         $this->applyCrossfades = false;
         //need some kind of placeholder for cc_schedule.
         //playout_status will be -1.
         $nextDT = $this->nowDT;
         $length = bcsub($nEpoch, $sEpoch, 6);
         $cliplength = Application_Common_DateHelper::secondsToPlaylistTime($length);
         //fillers are for only storing a chunk of time space that has already passed.
         $filler = new CcSchedule();
         $filler->setDbStarts($DT)->setDbEnds($this->nowDT)->setDbClipLength($cliplength)->setDbCueIn('00:00:00')->setDbCueOut('00:00:00')->setDbPlayoutStatus(-1)->setDbInstanceId($instanceId)->save($this->con);
     } else {
         $nextDT = $DT;
     }
     return $nextDT;
 }
 /**
  * Declares an association between this object and a CcSchedule object.
  *
  * @param      CcSchedule $v
  * @return     CcWebstreamMetadata The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setCcSchedule(CcSchedule $v = null)
 {
     if ($v === null) {
         $this->setDbInstanceId(NULL);
     } else {
         $this->setDbInstanceId($v->getDbId());
     }
     $this->aCcSchedule = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the CcSchedule object, it will not be re-added.
     if ($v !== null) {
         $v->addCcWebstreamMetadata($this);
     }
     return $this;
 }