Exemple #1
0
 /**
  * @param string $baseClass
  * @param string $enumValue
  * @param array $constructorArgs
  * @return object
  */
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     if ($baseClass == 'ISyncableFile' && isset($constructorArgs['objectId'])) {
         $objectId = $constructorArgs['objectId'];
         switch ($enumValue) {
             case FileSyncObjectType::METADATA:
                 MetadataPeer::setUseCriteriaFilter(false);
                 $object = MetadataPeer::retrieveByPK($objectId);
                 MetadataPeer::setUseCriteriaFilter(true);
                 return $object;
             case FileSyncObjectType::METADATA_PROFILE:
                 MetadataProfilePeer::setUseCriteriaFilter(false);
                 $object = MetadataProfilePeer::retrieveByPK($objectId);
                 MetadataProfilePeer::setUseCriteriaFilter(true);
                 return $object;
         }
     }
     if ($baseClass == 'kJobData') {
         switch ($enumValue) {
             case KalturaBatchJobType::METADATA_IMPORT:
                 return new kImportJobData();
             case KalturaBatchJobType::METADATA_TRANSFORM:
                 return new kTransformMetadataJobData();
         }
     }
     if ($baseClass == 'KalturaJobData') {
         switch ($enumValue) {
             case KalturaBatchJobType::METADATA_IMPORT:
                 return new KalturaImportJobData();
             case KalturaBatchJobType::METADATA_TRANSFORM:
                 return new KalturaTransformMetadataJobData();
         }
     }
     return null;
 }
 /**
  * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  *
  * This will only work if the object has been saved and has a valid primary key set.
  *
  * @param      boolean $deep (optional) Whether to also de-associated any related objects.
  * @param      PropelPDO $con (optional) The PropelPDO connection to use.
  * @return     void
  * @throws     PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  */
 public function reload($deep = false, PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("Cannot reload a deleted object.");
     }
     if ($this->isNew()) {
         throw new PropelException("Cannot reload an unsaved object.");
     }
     if ($con === null) {
         $con = Propel::getConnection(MetadataProfilePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     // We don't need to alter the object instance pool; we're just modifying this instance
     // already in the pool.
     MetadataProfilePeer::setUseCriteriaFilter(false);
     $criteria = $this->buildPkeyCriteria();
     entryPeer::addSelectColumns($criteria);
     $stmt = BasePeer::doSelect($criteria, $con);
     MetadataProfilePeer::setUseCriteriaFilter(true);
     $row = $stmt->fetch(PDO::FETCH_NUM);
     $stmt->closeCursor();
     if (!$row) {
         throw new PropelException('Cannot find matching row in the database to reload object values.');
     }
     $this->hydrate($row, 0, true);
     // rehydrate
     if ($deep) {
         // also de-associate any related objects?
     }
     // if (deep)
 }
Exemple #3
0
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     if ($baseClass == 'ISyncableFile' && isset($constructorArgs['objectId'])) {
         $objectId = $constructorArgs['objectId'];
         switch ($enumValue) {
             case FileSyncObjectType::METADATA:
                 MetadataPeer::setUseCriteriaFilter(false);
                 $object = MetadataPeer::retrieveByPK($objectId);
                 MetadataPeer::setUseCriteriaFilter(true);
                 return $object;
             case FileSyncObjectType::METADATA_PROFILE:
                 MetadataProfilePeer::setUseCriteriaFilter(false);
                 $object = MetadataProfilePeer::retrieveByPK($objectId);
                 MetadataProfilePeer::setUseCriteriaFilter(true);
                 return $object;
         }
     }
     if ($baseClass == 'kJobData') {
         switch ($enumValue) {
             case KalturaBatchJobType::METADATA_IMPORT:
                 return new kImportJobData();
             case KalturaBatchJobType::METADATA_TRANSFORM:
                 return new kTransformMetadataJobData();
         }
     }
     if ($baseClass == 'KalturaJobData') {
         switch ($enumValue) {
             case KalturaBatchJobType::METADATA_IMPORT:
                 return new KalturaImportJobData();
             case KalturaBatchJobType::METADATA_TRANSFORM:
                 return new KalturaTransformMetadataJobData();
         }
     }
     if ($baseClass == 'KalturaCondition') {
         if ($enumValue == MetadataPlugin::getConditionTypeCoreValue(MetadataConditionType::METADATA_FIELD_COMPARE)) {
             return new KalturaCompareMetadataCondition();
         }
         if ($enumValue == MetadataPlugin::getConditionTypeCoreValue(MetadataConditionType::METADATA_FIELD_MATCH)) {
             return new KalturaMatchMetadataCondition();
         }
         if ($enumValue == MetadataPlugin::getConditionTypeCoreValue(MetadataConditionType::METADATA_FIELD_CHANGED)) {
             return new KalturaMetadataFieldChangedCondition();
         }
     }
     if ($baseClass == 'KalturaFilter') {
         if ($enumValue == 'MetadataFilter') {
             return new KalturaMetadataFilter();
         }
     }
     if ($baseClass == 'KIndexingEngine') {
         if ($enumValue == KalturaIndexObjectType::METADATA) {
             return new KIndexingMetadataEngine();
         }
     }
     if ($baseClass == 'KalturaResponseProfileMapping') {
         if ($enumValue == 'kMetadataResponseProfileMapping') {
             return new KalturaMetadataResponseProfileMapping();
         }
     }
     return null;
 }
Exemple #4
0
 protected static function init()
 {
     kEventsManager::enableDeferredEvents(false);
     MetadataProfilePeer::setUseCriteriaFilter(false);
     MetadataPeer::setUseCriteriaFilter(false);
     entryPeer::setUseCriteriaFilter(false);
     uiConfPeer::setUseCriteriaFilter(false);
     assetPeer::setUseCriteriaFilter(false);
     PartnerPeer::setUseCriteriaFilter(false);
     FileSyncPeer::setUseCriteriaFilter(false);
     $options = getopt('hrl:p:o:b:e:', array('real-run', 'error-objects', 'old-versions', 'blocked-partners', 'files'));
     if (isset($options['h'])) {
         self::failWrongInputs();
     }
     if (isset($options['blocked-partners'])) {
         self::$deleteDeletedPartnersFileSyncs = true;
     }
     if (isset($options['error-objects'])) {
         self::$deleteErrorObjects = true;
     }
     if (isset($options['old-versions'])) {
         self::$deleteOldVersions = true;
     }
     if (isset($options['files'])) {
         self::$purgeDeletedFileSyncs = true;
     }
     if (isset($options['r']) || isset($options['real-run'])) {
         self::$dryRun = false;
     }
     KalturaStatement::setDryRun(self::$dryRun);
     $cacheFilePath = kConf::get('cache_root_path') . '/scripts/deleteOldContent.cache';
     if (file_exists($cacheFilePath)) {
         $cache = unserialize(file_get_contents($cacheFilePath));
         if (isset($cache['oldVersionsStartUpdatedAt'])) {
             self::$oldVersionsStartUpdatedAt = $cache['oldVersionsStartUpdatedAt'];
         }
         if (isset($cache['purgeStartUpdatedAt'])) {
             self::$purgeStartUpdatedAt = $cache['purgeStartUpdatedAt'];
         }
     }
     if (!self::$purgeStartUpdatedAt) {
         $criteria = new Criteria();
         $criteria->add(FileSyncPeer::UPDATED_AT, 0, Criteria::GREATER_THAN);
         $criteria->add(FileSyncPeer::DC, kDataCenterMgr::getCurrentDcId());
         $criteria->add(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_DELETED);
         $criteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . FileSyncPeer::UPDATED_AT . '))');
         $stmt = FileSyncPeer::doSelectStmt($criteria);
         $mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
         if (count($mins)) {
             self::$purgeStartUpdatedAt = reset($mins);
         }
     }
     if (is_null(self::$purgeStartUpdatedAt)) {
         self::$purgeStartUpdatedAt = 0;
     }
     self::$purgeNextStartUpdatedAt = self::$purgeStartUpdatedAt;
     $oldVersionsUpdatedAtPeriod = 30;
     // days
     if (isset($options['o'])) {
         if (!is_numeric($options['o']) || $options['o'] < 0) {
             self::failWrongInputs("Period of old versions to delete must be positive numeric of days");
         }
         $oldVersionsUpdatedAtPeriod = $options['o'];
     }
     foreach (self::$oldVersionsStartUpdatedAt as $objectType => $oldVersionsStartUpdatedAt) {
         self::$oldVersionsEndUpdatedAt[$objectType] = $oldVersionsStartUpdatedAt + $oldVersionsUpdatedAtPeriod * 60 * 60 * 24;
     }
     // days
     $purgeUpdatedAtPeriod = 30;
     // days
     if (isset($options['p'])) {
         if (!is_numeric($options['p']) || $options['p'] < 0) {
             self::failWrongInputs("Period of purge must be positive numeric of days");
         }
         $purgeUpdatedAtPeriod = $options['p'];
     }
     self::$purgeEndUpdatedAt = self::$purgeStartUpdatedAt + $purgeUpdatedAtPeriod * 60 * 60 * 24;
     // days
     $oldPartnersUpdatedAtPeriod = 24;
     // months
     if (isset($options['b'])) {
         if (!is_numeric($options['b']) || $options['b'] < 0) {
             self::failWrongInputs("Period of blocked partners to delete must be positive numeric of months");
         }
         $oldPartnersUpdatedAtPeriod = $options['b'];
     }
     self::$oldPartnersUpdatedAt = time() - $oldPartnersUpdatedAtPeriod * 60 * 60 * 24 * 30;
     // months
     $errObjectsUpdatedAtPeriod = 24;
     // months
     if (isset($options['e'])) {
         if (!is_numeric($options['e']) || $options['e'] < 0) {
             self::failWrongInputs("Period of error objects to delete must be positive numeric of months");
         }
         $errObjectsUpdatedAtPeriod = $options['e'];
     }
     self::$errObjectsUpdatedAt = time() - $errObjectsUpdatedAtPeriod * 60 * 60 * 24 * 30;
     // months
     if (isset($options['l'])) {
         if (!is_numeric($options['l']) || $options['l'] < 0) {
             self::failWrongInputs("Limit querymust be positive numeric value");
         }
         self::$queryLimit = $options['l'];
     }
 }
 /**
  * Code to be run after inserting to database
  * @param PropelPDO $con 
  */
 public function postInsert(PropelPDO $con = null)
 {
     MetadataProfilePeer::setUseCriteriaFilter(false);
     $this->reload();
     MetadataProfilePeer::setUseCriteriaFilter(true);
     kEventsManager::raiseEvent(new kObjectCreatedEvent($this));
     if ($this->copiedFrom) {
         kEventsManager::raiseEvent(new kObjectCopiedEvent($this->copiedFrom, $this));
     }
 }