/**
  * @param      int $metadataProfileId
  * @param      PropelPDO $con the connection to use
  * @return     array<MetadataProfileField>
  */
 public static function retrieveActiveByMetadataProfileId($metadataProfileId, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(MetadataProfileFieldPeer::METADATA_PROFILE_ID, $metadataProfileId);
     $criteria->add(MetadataProfileFieldPeer::STATUS, MetadataProfileField::STATUS_ACTIVE);
     return MetadataProfileFieldPeer::doSelect($criteria, $con);
 }
 /**
  * @param      int $partnerId
  * @param      int $objectType
  * @return     array<MetadataProfileField>
  */
 public static function retrieveIndexableByPartnerAndType($partnerId, $objectType)
 {
     $criteria = new Criteria();
     $criteria->addSelectColumn(MetadataProfilePeer::ID);
     $criteria->add(MetadataProfilePeer::PARTNER_ID, $partnerId);
     $criteria->add(MetadataProfilePeer::OBJECT_TYPE, $objectType);
     $stmt = MetadataProfilePeer::doSelectStmt($criteria);
     $metadataProfileIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
     $criteria = new Criteria();
     $criteria->add(MetadataProfileFieldPeer::PARTNER_ID, $partnerId);
     $criteria->add(MetadataProfileFieldPeer::METADATA_PROFILE_ID, $metadataProfileIds, Criteria::IN);
     $criteria->add(MetadataProfileFieldPeer::STATUS, MetadataProfileField::STATUS_ACTIVE, Criteria::EQUAL);
     $criteria->add(MetadataProfileFieldPeer::SEARCH_INDEX, null, Criteria::ISNOTNULL);
     return MetadataProfileFieldPeer::doSelect($criteria);
 }
 /**
  * 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(MetadataProfileFieldPeer::DATABASE_NAME);
         $criteria->add(MetadataProfileFieldPeer::ID, $pks, Criteria::IN);
         $objs = MetadataProfileFieldPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * Delete an existing metadata profile
  *
  * @action delete
  * @param int $id
  * @throws MetadataErrors::METADATA_PROFILE_NOT_FOUND
  */
 function deleteAction($id)
 {
     $dbMetadataProfile = MetadataProfilePeer::retrieveByPK($id);
     if (!$dbMetadataProfile) {
         throw new KalturaAPIException(MetadataErrors::METADATA_PROFILE_NOT_FOUND, $id);
     }
     // if this profile is a dynamic object, check for references in other profiles
     if ($dbMetadataProfile->getObjectType() == MetadataObjectType::DYNAMIC_OBJECT) {
         $referencedFields = MetadataProfileFieldPeer::retrieveByPartnerAndRelatedMetadataProfileId(kCurrentContext::getCurrentPartnerId(), $dbMetadataProfile->getId());
         if (count($referencedFields)) {
             /** @var MetadataProfileField $referencedField */
             $referencedField = $referencedFields[0];
             throw new KalturaAPIException(MetadataErrors::METADATA_PROFILE_REFERENCE_EXISTS, $referencedField->getMetadataProfileId(), $referencedField->getKey());
         }
     }
     $dbMetadataProfile->setStatus(KalturaMetadataProfileStatus::DEPRECATED);
     $dbMetadataProfile->save();
     $c = new Criteria();
     $c->add(MetadataProfileFieldPeer::METADATA_PROFILE_ID, $id);
     $c->add(MetadataProfileFieldPeer::STATUS, MetadataProfileField::STATUS_DEPRECATED, Criteria::NOT_EQUAL);
     $MetadataProfileFields = MetadataProfileFieldPeer::doSelect($c);
     foreach ($MetadataProfileFields as $MetadataProfileField) {
         $MetadataProfileField->setStatus(MetadataProfileField::STATUS_DEPRECATED);
         $MetadataProfileField->save();
     }
     $c = new Criteria();
     $c->add(MetadataPeer::METADATA_PROFILE_ID, $id);
     $c->add(MetadataPeer::STATUS, KalturaMetadataStatus::DELETED, Criteria::NOT_EQUAL);
     $peer = null;
     MetadataPeer::setUseCriteriaFilter(false);
     $metadatas = MetadataPeer::doSelect($c);
     foreach ($metadatas as $metadata) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($metadata));
     }
     $update = new Criteria();
     $update->add(MetadataPeer::STATUS, KalturaMetadataStatus::DELETED);
     $con = Propel::getConnection(MetadataPeer::DATABASE_NAME);
     BasePeer::doUpdate($c, $update, $con);
 }
 /**
  * Delete an existing metadata profile
  * 
  * @action delete
  * @param int $id
  * @throws KalturaErrors::INVALID_OBJECT_ID
  */
 function deleteAction($id)
 {
     $dbMetadataProfile = MetadataProfilePeer::retrieveByPK($id);
     if (!$dbMetadataProfile) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $id);
     }
     $dbMetadataProfile->setStatus(KalturaMetadataProfileStatus::DEPRECATED);
     $dbMetadataProfile->save();
     $c = new Criteria();
     $c->add(MetadataProfileFieldPeer::METADATA_PROFILE_ID, $id);
     $c->add(MetadataProfileFieldPeer::STATUS, MetadataProfileField::STATUS_DEPRECATED, Criteria::NOT_EQUAL);
     $MetadataProfileFields = MetadataProfileFieldPeer::doSelect($c);
     foreach ($MetadataProfileFields as $MetadataProfileField) {
         $MetadataProfileField->setStatus(MetadataProfileField::STATUS_DEPRECATED);
         $MetadataProfileField->save();
     }
     $c = new Criteria();
     $c->add(MetadataPeer::METADATA_PROFILE_ID, $id);
     $c->add(MetadataPeer::STATUS, KalturaMetadataStatus::DELETED, Criteria::NOT_EQUAL);
     $peer = null;
     MetadataPeer::setUseCriteriaFilter(false);
     $metadatas = MetadataPeer::doSelect($c);
     foreach ($metadatas as $metadata) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($metadata));
     }
     $update = new Criteria();
     $update->add(MetadataPeer::STATUS, KalturaMetadataStatus::DELETED);
     $con = Propel::getConnection(MetadataPeer::DATABASE_NAME);
     BasePeer::doUpdate($c, $update, $con);
 }