<commit_before><?php

/**
 * Add & Manage Conversion Profiles
 *
 * @service conversionProfile
 * @package api
 * @subpackage services
 */
class ConversionProfileService extends KalturaBaseService
{
	public function initService($serviceId, $serviceName, $actionName)
	{
		parent::initService($serviceId, $serviceName, $actionName);
		parent::applyPartnerFilterForClass(flavorAssetPeer::getInstance());
		parent::applyPartnerFilterForClass(flavorParamsOutputPeer::getInstance());
		parent::applyPartnerFilterForClass(new conversionProfile2Peer());
		
		$partnerGroup = null;
		if(
			$actionName == 'add' ||
			$actionName == 'update'
			)
			$partnerGroup = $this->partnerGroup . ',0';
			
		parent::applyPartnerFilterForClass(flavorParamsPeer::getInstance(), $partnerGroup);
	}
	
	/**
	 * Set Conversion Profile to be the partner default
	 * 
	 * @action setAsDefault
	 * @param int $id
	 * @return KalturaConversionProfile
	 */
	public function setAsDefaultAction($id)
	{
		$conversionProfileDb = conversionProfile2Peer::retrieveByPK($id);
		if (!$conversionProfileDb || $conversionProfileDb->getPartnerId() != $this->getPartnerId())
			throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $id);
			
		$partner = $this->getPartner();
		$partner->setDefaultConversionProfileId($id);
		$partner->save();
		PartnerPeer::removePartnerFromCache($partner->getId());
		
		$conversionProfile = new KalturaConversionProfile();
		$conversionProfile->fromObject($conversionProfileDb);
		$conversionProfile->loadFlavorParamsIds($conversionProfileDb);
		
		return $conversionProfile;
	}
	
	/**
	 * Get the partner's default conversion profile
	 * 
	 * @action getDefault
	 * @return int
	 */<commit_msg>Added conversionProfile->getDefault action + permissions<commit_after><?php

/**
 * Add & Manage Conversion Profiles
 *
 * @service conversionProfile
 * @package api
 * @subpackage services
 */
class ConversionProfileService extends KalturaBaseService
{
	public function initService($serviceId, $serviceName, $actionName)
	{
		parent::initService($serviceId, $serviceName, $actionName);
		parent::applyPartnerFilterForClass(flavorAssetPeer::getInstance());
		parent::applyPartnerFilterForClass(flavorParamsOutputPeer::getInstance());
		parent::applyPartnerFilterForClass(new conversionProfile2Peer());
		
		$partnerGroup = null;
		if(
			$actionName == 'add' ||
			$actionName == 'update'
			)
			$partnerGroup = $this->partnerGroup . ',0';
			
		parent::applyPartnerFilterForClass(flavorParamsPeer::getInstance(), $partnerGroup);
	}
	
	/**
	 * Set Conversion Profile to be the partner default
	 * 
	 * @action setAsDefault
	 * @param int $id
	 * @return KalturaConversionProfile
	 */
	public function setAsDefaultAction($id)
	{
		$conversionProfileDb = conversionProfile2Peer::retrieveByPK($id);
		if (!$conversionProfileDb || $conversionProfileDb->getPartnerId() != $this->getPartnerId())
			throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $id);
			
		$partner = $this->getPartner();
		$partner->setDefaultConversionProfileId($id);
		$partner->save();
		PartnerPeer::removePartnerFromCache($partner->getId());
		
		$conversionProfile = new KalturaConversionProfile();
		$conversionProfile->fromObject($conversionProfileDb);
		$conversionProfile->loadFlavorParamsIds($conversionProfileDb);
		
		return $conversionProfile;
	}
	
	/**
	 * Get the partner's default conversion profile
	 * 
	 * @action getDefault
	 * @return KalturaConversionProfile
	 */
{'fraction_non_alphanumeric': 0.12550028587764436, 'fraction_numerical': 0.0017152658662092624, 'mean_word_length': 5.887795275590551, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2263355', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1011, 'n_words': 181}