/**
  * Retrieve EntryDistribution objects by entry id according to specified statuses list
  *
  * @param      string $entryId
  * @param      array $statuses
  * @param      PropelPDO $con the connection to use
  * @return     EntryDistribution
  */
 public static function retrieveByEntryAndStatuses($entryId, array $statuses, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(EntryDistributionPeer::ENTRY_ID, $entryId);
     $criteria->add(EntryDistributionPeer::STATUS, $statuses, Criteria::IN);
     return EntryDistributionPeer::doSelect($criteria, $con);
 }
 public static function retrieveByEntryIdsAndProfileId(array $entryIds, $distributionProfileId, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(EntryDistributionPeer::ENTRY_ID, $entryIds, Criteria::IN);
     $criteria->add(EntryDistributionPeer::DISTRIBUTION_PROFILE_ID, $distributionProfileId);
     return EntryDistributionPeer::doSelect($criteria, $con);
 }
 public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $c = new Criteria();
     $entryDistributionFilter = $this->toObject();
     $entryDistributionFilter->attachToCriteria($c);
     $count = EntryDistributionPeer::doCount($c);
     $pager->attachToCriteria($c);
     $list = EntryDistributionPeer::doSelect($c);
     $response = new KalturaEntryDistributionListResponse();
     $response->objects = KalturaEntryDistributionArray::fromDbArray($list, $responseProfile);
     $response->totalCount = $count;
     return $response;
 }
 /**
  * creates all required jobs according to entry distribution dirty flags 
  * 
  * @action createRequiredJobs
  */
 function createRequiredJobsAction()
 {
     // serach all records that their next report time arrived
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::NEXT_REPORT, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitFetchEntryDistributionReport($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunrise time and requires submittion
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::SUBMIT_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitAddEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunrise time and requires enable
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::ENABLE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitEnableEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunset time and requires deletion
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::DELETE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitDeleteEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
     // serach all records that arrived their sunset time and requires disable
     $criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
     $criteria->add(EntryDistributionPeer::DIRTY_STATUS, EntryDistributionDirtyStatus::DISABLE_REQUIRED);
     $criteria->add(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_EQUAL);
     $entryDistributions = EntryDistributionPeer::doSelect($criteria);
     foreach ($entryDistributions as $entryDistribution) {
         $distributionProfile = DistributionProfilePeer::retrieveByPK($entryDistribution->getDistributionProfileId());
         if ($distributionProfile) {
             kContentDistributionManager::submitDisableEntryDistribution($entryDistribution, $distributionProfile);
         } else {
             KalturaLog::err("Distribution profile [" . $entryDistribution->getDistributionProfileId() . "] not found for entry distribution [" . $entryDistribution->getId() . "]");
         }
     }
 }
 /**
  * Retrieve objects by entry id.
  *
  * @param      string $entryId
  * @param      PropelPDO $con the connection to use
  * @return     array<EntryDistribution>
  */
 public static function retrieveByEntryId($entryId, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(EntryDistributionPeer::ENTRY_ID, $entryId);
     return EntryDistributionPeer::doSelect($criteria, $con);
 }
KAutoloader::register();
error_reporting(E_ALL);
KalturaLog::setLogger(new KalturaStdoutLogger());
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$c = new Criteria();
if ($argc > 1 && is_numeric($argv[1])) {
    $c->add(EntryDistributionPeer::ID, $argv[1], Criteria::GREATER_EQUAL);
}
$c->addAscendingOrderByColumn(EntryDistributionPeer::ID);
$c->setLimit(10000);
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2);
//$sphinxCon = DbManager::getSphinxConnection();
$entries = EntryDistributionPeer::doSelect($c, $con);
$sphinx = new kSphinxSearchManager();
while (count($entries)) {
    foreach ($entries as $entry) {
        KalturaLog::log('entry distribution id ' . $entry->getId());
        try {
            $ret = $sphinx->saveToSphinx($entry, true);
        } catch (Exception $e) {
            KalturaLog::err($e->getMessage());
            exit - 1;
        }
    }
    $c->setOffset($c->getOffset() + count($entries));
    EntryDistributionPeer::clearInstancePool();
    $entries = EntryDistributionPeer::doSelect($c, $con);
}
KalturaLog::log('Done');
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(EntryDistributionPeer::DATABASE_NAME);
         $criteria->add(EntryDistributionPeer::ID, $pks, Criteria::IN);
         $objs = EntryDistributionPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * List all distribution providers
  * 
  * @action list
  * @param KalturaEntryDistributionFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaEntryDistributionListResponse
  */
 function listAction(KalturaEntryDistributionFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaEntryDistributionFilter();
     }
     $c = new Criteria();
     $entryDistributionFilter = new EntryDistributionFilter();
     $filter->toObject($entryDistributionFilter);
     $entryDistributionFilter->attachToCriteria($c);
     $count = EntryDistributionPeer::doCount($c);
     if ($pager) {
         $pager->attachToCriteria($c);
     }
     $list = EntryDistributionPeer::doSelect($c);
     $response = new KalturaEntryDistributionListResponse();
     $response->objects = KalturaEntryDistributionArray::fromDbArray($list);
     $response->totalCount = $count;
     return $response;
 }