Ejemplo n.º 1
0
 /**
  * List metadata objects by filter and pager
  * 
  * @action list
  * @param KalturaMetadataFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaMetadataListResponse
  */
 function listAction(KalturaMetadataFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaMetadataFilter();
     }
     $metadataFilter = new MetadataFilter();
     $filter->toObject($metadataFilter);
     $c = new Criteria();
     $metadataFilter->attachToCriteria($c);
     $count = MetadataPeer::doCount($c);
     if ($pager) {
         $pager->attachToCriteria($c);
     }
     $list = MetadataPeer::doSelect($c);
     $response = new KalturaMetadataListResponse();
     $response->objects = KalturaMetadataArray::fromDbArray($list);
     $response->totalCount = $count;
     return $response;
 }
 /**
  * batch getTransformMetadataObjects action retrieve all metadata objects that requires upgrade and the total count 
  * 
  * @action getTransformMetadataObjects
  * @param int $metadataProfileId The id of the metadata profile
  * @param int $srcVersion The old metadata profile version
  * @param int $destVersion The new metadata profile version
  * @param KalturaFilterPager $pager
  * @return KalturaTransformMetadataResponse
  */
 function getTransformMetadataObjectsAction($metadataProfileId, $srcVersion, $destVersion, KalturaFilterPager $pager = null)
 {
     $response = new KalturaTransformMetadataResponse();
     $c = new Criteria();
     $c->add(MetadataPeer::METADATA_PROFILE_ID, $metadataProfileId);
     $c->add(MetadataPeer::METADATA_PROFILE_VERSION, $srcVersion, Criteria::LESS_THAN);
     $c->add(MetadataPeer::STATUS, KalturaMetadataStatus::VALID);
     $response->lowerVersionCount = MetadataPeer::doCount($c);
     $c = new Criteria();
     $c->add(MetadataPeer::METADATA_PROFILE_ID, $metadataProfileId);
     $c->add(MetadataPeer::METADATA_PROFILE_VERSION, $srcVersion);
     $c->add(MetadataPeer::STATUS, KalturaMetadataStatus::VALID);
     $response->totalCount = MetadataPeer::doCount($c);
     if ($pager) {
         $pager->attachToCriteria($c);
     }
     $list = MetadataPeer::doSelect($c);
     $response->objects = KalturaMetadataArray::fromDbArray($list);
     return $response;
 }
 /**
  * List metadata objects by filter and pager
  * 
  * @action list
  * @param KalturaMetadataFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaMetadataListResponse
  */
 function listAction(KalturaMetadataFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaMetadataFilter();
     }
     if (kEntitlementUtils::getEntitlementEnforcement() && (is_null($filter->objectIdIn) && is_null($filter->objectIdEqual))) {
         throw new KalturaAPIException(MetadataErrors::MUST_FILTER_ON_OBJECT_ID);
     }
     $entryIds = null;
     if ($filter->metadataObjectTypeEqual == MetadataObjectType::ENTRY) {
         if ($filter->objectIdEqual) {
             $entryIds = array($filter->objectIdEqual);
         } else {
             if ($filter->objectIdIn) {
                 $entryIds = explode(',', $filter->objectIdIn);
             }
         }
     }
     if (is_null($entryIds)) {
         myPartnerUtils::addPartnerToCriteria(new MetadataPeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
     } else {
         $entryIds = entryPeer::filterEntriesByPartnerOrKalturaNetwork($entryIds, $this->getPartnerId());
         $filter->objectIdEqual = null;
         $filter->objectIdIn = implode(',', $entryIds);
     }
     $metadataFilter = new MetadataFilter();
     $filter->toObject($metadataFilter);
     $c = new Criteria();
     $metadataFilter->attachToCriteria($c);
     if ($entryIds === array()) {
         $c->addAnd(MetadataPeer::OBJECT_ID, array(), Criteria::IN);
     }
     $count = MetadataPeer::doCount($c);
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $pager->attachToCriteria($c);
     $list = MetadataPeer::doSelect($c);
     $response = new KalturaMetadataListResponse();
     $response->objects = KalturaMetadataArray::fromDbArray($list);
     $response->totalCount = $count;
     return $response;
 }
Ejemplo n.º 4
0
 public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
 {
     if (kEntitlementUtils::getEntitlementEnforcement() && (is_null($this->objectIdIn) && is_null($this->objectIdEqual))) {
         throw new KalturaAPIException(MetadataErrors::MUST_FILTER_ON_OBJECT_ID);
     }
     if (!$this->metadataObjectTypeEqual) {
         throw new KalturaAPIException(MetadataErrors::MUST_FILTER_ON_OBJECT_TYPE);
     }
     if ($this->metadataObjectTypeEqual == MetadataObjectType::CATEGORY) {
         if ($this->objectIdEqual) {
             $categoryIds = array($this->objectIdEqual);
         } else {
             if ($this->objectIdIn) {
                 $categoryIds = explode(',', $this->objectIdIn);
             }
         }
         if ($categoryIds) {
             $categories = categoryPeer::retrieveByPKs($categoryIds);
             if (!count($categories)) {
                 KalturaLog::debug("No categories found");
                 $response = new KalturaMetadataListResponse();
                 $response->objects = new KalturaMetadataArray();
                 $response->totalCount = 0;
                 return $response;
             }
             $categoryIds = array();
             foreach ($categories as $category) {
                 $categoryIds[] = $category->getId();
             }
             $this->objectIdEqual = null;
             $this->objectIdIn = implode(',', $categoryIds);
         }
     }
     $metadataFilter = $this->toObject();
     $c = KalturaCriteria::create(MetadataPeer::OM_CLASS);
     $metadataFilter->attachToCriteria($c);
     $pager->attachToCriteria($c);
     $list = MetadataPeer::doSelect($c);
     $response = new KalturaMetadataListResponse();
     $response->objects = KalturaMetadataArray::fromDbArray($list, $responseProfile);
     if ($c instanceof SphinxMetadataCriteria) {
         $response->totalCount = $c->getRecordsCount();
     } elseif ($pager->pageIndex == 1 && count($response->objects) < $pager->pageSize) {
         $response->totalCount = count($response->objects);
     } else {
         $pager->detachFromCriteria($c);
         $response->totalCount = MetadataPeer::doCount($c);
     }
     return $response;
 }