Exemple #1
0
 /**
  * generate unique string id for annotation
  */
 public function getUniqueAnnotationId()
 {
     $dc = kDataCenterMgr::getCurrentDc();
     for ($i = 0; $i < 10; $i++) {
         $id = $dc["id"] . '_' . kString::generateStringId();
         $existingObject = AnnotationPeer::retrieveByPK($id);
         if ($existingObject) {
             KalturaLog::log(__METHOD__ . ": id [{$id}] already exists");
         } else {
             return $id;
         }
     }
     throw new Exception("Could not find unique id for annotation");
 }
 /**
  * @param int $entryId
  */
 protected function entryDeleted($entryId)
 {
     $c = new Criteria();
     $c->add(AnnotationPeer::ENTRY_ID, $entryId);
     $c->add(AnnotationPeer::STATUS, AnnotationStatus::ANNOTATION_STATUS_DELETED, Criteria::NOT_EQUAL);
     AnnotationPeer::setUseCriteriaFilter(false);
     $annotations = AnnotationPeer::doSelect($c);
     foreach ($annotations as $annotation) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($annotation));
     }
     $update = new Criteria();
     $update->add(AnnotationPeer::STATUS, AnnotationStatus::ANNOTATION_STATUS_DELETED);
     $con = Propel::getConnection(AnnotationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     BasePeer::doUpdate($c, $update, $con);
 }
Exemple #3
0
 public static function setDefaultCriteriaFilterByKuser()
 {
     if (self::$s_criteria_filter == null) {
         self::$s_criteria_filter = new criteriaFilter();
     }
     $c = new Criteria();
     $puserId = kCurrentContext::$ks_uid;
     $partnerId = kCurrentContext::$ks_partner_id;
     if ($puserId && $partnerId) {
         $kuserId = kuserPeer::getKuserByPartnerAndUid($partnerId, $puserId);
         if (!$kuserId) {
             throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID);
         }
         $c->addAnd(AnnotationPeer::KUSER_ID, $kuserId->getId());
     }
     self::$s_criteria_filter->setFilter($c);
 }
 public function validateStartTime(KalturaAnnotation $annotation, $annotationId = null)
 {
     if ($annotation->startTime === null) {
         $annotation->startTime = 0;
     }
     if ($annotation->startTime < 0) {
         throw new KalturaAPIException(KalturaAnnotationErrors::START_TIME_CANNOT_BE_LESS_THAN_0);
     }
     if ($annotationId !== null) {
         //update
         $dbAnnotation = AnnotationPeer::retrieveByPK($annotationId);
         if (!$dbAnnotation) {
             throw new KalturaAPIException(KalturaAnnotationErrors::INVALID_OBJECT_ID, $annotationId);
         }
         $dbEntry = entryPeer::retrieveByPK($dbAnnotation->getEntryId());
     } else {
         $dbEntry = entryPeer::retrieveByPK($annotation->entryId);
         if (!$dbEntry) {
             throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $annotation->entryId);
         }
     }
     if ($dbEntry->getLengthInMsecs() < $annotation->startTime) {
         throw new KalturaAPIException(KalturaAnnotationErrors::START_TIME_IS_BIGGER_THAN_ENTRY_END_TIME, $annotation->startTime, $dbEntry->getLengthInMsecs());
     }
 }
 /**
  * Update annotation by id 
  * 
  * @action update
  * @param string $id
  * @param KalturaAnnotation $annotation
  * @return KalturaAnnotation
  */
 function updateAction($id, KalturaAnnotation $annotation)
 {
     kalturalog::debug("annotation service updateAction");
     $dbAnnotation = AnnotationPeer::retrieveByPK($id);
     if ($dbAnnotation->getType() != AnnotationType::ANNOTATION) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $id);
     }
     if (!$dbAnnotation) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $id);
     }
     if ($annotation->text !== null) {
         $annotation->validatePropertyMaxLength("text", AnnotationPeer::MAX_ANNOTATION_TEXT);
     }
     if ($annotation->tags !== null) {
         $annotation->validatePropertyMaxLength("tags", AnnotationPeer::MAX_ANNOTATION_TAGS);
     }
     if ($annotation->entryId !== null) {
         $annotation->validateEntryId($annotation, $id);
     }
     if ($annotation->parentId !== null) {
         $annotation->validateParentId($annotation, $id);
     }
     if ($annotation->startTime !== null) {
         $annotation->validateStartTime($annotation, $id);
     }
     if ($annotation->endTime !== null) {
         $annotation->validateEndTime($annotation, $id);
     }
     $dbAnnotation = $annotation->toUpdatableObject($dbAnnotation);
     $dbAnnotation->setKuserId($this->getKuser()->getId());
     $dbAnnotation->save();
     $annotation->fromObject($dbAnnotation);
     return $annotation;
 }
 public function getFieldNameFromPeer($field_name)
 {
     $res = AnnotationPeer::translateFieldName($field_name, $this->field_name_translation_type, BasePeer::TYPE_COLNAME);
     return $res;
 }
 /**
  * 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(AnnotationPeer::DATABASE_NAME);
         $criteria->add(AnnotationPeer::ID, $pks, Criteria::IN);
         $objs = AnnotationPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemple #8
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param      string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  *                        BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
  * @param      boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns.  Defaults to TRUE.
  * @return     an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
 {
     $keys = AnnotationPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getIntId(), $keys[1] => $this->getId(), $keys[2] => $this->getParentId(), $keys[3] => $this->getEntryId(), $keys[4] => $this->getPartnerId(), $keys[5] => $this->getCreatedAt(), $keys[6] => $this->getUpdatedAt(), $keys[7] => $this->getText(), $keys[8] => $this->getTags(), $keys[9] => $this->getStartTime(), $keys[10] => $this->getEndTime(), $keys[11] => $this->getStatus(), $keys[12] => $this->getType(), $keys[13] => $this->getKuserId(), $keys[14] => $this->getCustomData(), $keys[15] => $this->getPartnerData());
     return $result;
 }