/**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      MetadataProfile $value A MetadataProfile object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(MetadataProfile $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      MetadataProfile $value A MetadataProfile object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(MetadataProfile $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('MetadataProfilePeer');
         }
     }
 }
 /**
  * @param MetadataProfile $metadataProfile
  */
 protected function metadataProfileDeleted(MetadataProfile $metadataProfile)
 {
     $this->syncableDeleted($metadataProfile->getId(), FileSyncObjectType::METADATA_PROFILE);
 }
function createMetadataProfile($version, $versionToXsdMap)
{
    $metadataProfile = new MetadataProfile();
    $metadataProfile->setPartnerId(99);
    $metadataProfile->setStatus(MetadataProfile::STATUS_ACTIVE);
    $metadataProfile->setName('Tvinci ingest v' . $version);
    $metadataProfile->setSystemName('TvinciIngestV' . $version);
    $metadataProfile->setDescription('Tvinci ingest schema version ' . $version);
    $metadataProfile->setObjectType(MetadataObjectType::ENTRY);
    $metadataProfile->setRequiredCopyTemplatePermissions(FEATURE_TVINCI_INGEST_BASE . $version);
    $metadataProfile->save();
    $xsdData = $versionToXsdMap[$version];
    $key = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
    kFileSyncUtils::file_put_contents($key, $xsdData);
    kMetadataManager::parseProfileSearchFields($metadataProfile->getPartnerId(), $metadataProfile);
}
示例#5
0
 /**
  * Check if transforming required and create job if needed
  *
  * @param MetadataProfile $metadataProfile
  * @param int $prevVersion
  * @param string $prevXsd
  */
 public static function diffMetadataProfile(MetadataProfile $metadataProfile, $prevXsd, $newXsd)
 {
     $xsl = true;
     if (!PermissionPeer::isValidForPartner(MetadataPermissionName::FEATURE_METADATA_NO_VALIDATION, $metadataProfile->getPartnerId())) {
         $xsl = kXsd::compareXsd($prevXsd, $newXsd);
     }
     if ($xsl === true) {
         return;
     }
     if (PermissionPeer::isValidForPartner(MetadataPermissionName::FEATURE_METADATA_NO_TRANSFORMATION, $metadataProfile->getPartnerId())) {
         throw new kXsdException(kXsdException::TRANSFORMATION_REQUIRED);
     }
     $prevVersion = $metadataProfile->getVersion();
     $metadataProfile->incrementVersion();
     $newVersion = $metadataProfile->getVersion();
     $metadataProfile->save();
     //save has to be before we create a batch to make sure there is no race-condition where XSD is not updated before the batch runs.
     return self::addTransformMetadataJob($metadataProfile->getPartnerId(), $metadataProfile->getId(), $prevVersion, $newVersion, $xsl);
 }
示例#6
0
 /**
  * Function returns metadata object which needs to be set with the new metadata XML
  * @param BaseObject $object
  * @param MetadataProfile $metadataProfileId
  */
 protected static function createOrFindMetadataObject(BaseObject $object, MetadataProfile $metadataProfile)
 {
     $c = new Criteria();
     $c->addAnd(MetadataPeer::PARTNER_ID, $object->getPartnerId(), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::OBJECT_ID, $object->getId(), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::METADATA_PROFILE_ID, $metadataProfile->getId(), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::METADATA_PROFILE_VERSION, $metadataProfile->getVersion(), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::OBJECT_TYPE, kMetadataManager::getTypeNameFromObject($object), Criteria::EQUAL);
     $c->addAnd(MetadataPeer::STATUS, Metadata::STATUS_VALID);
     $dbMetadata = MetadataPeer::doSelectOne($c);
     if (!$dbMetadata) {
         $dbMetadata = new Metadata();
         $dbMetadata->setPartnerId($object->getPartnerId());
         $dbMetadata->setMetadataProfileId($metadataProfile->getId());
         $dbMetadata->setMetadataProfileVersion($metadataProfile->getVersion());
         $dbMetadata->setObjectType(kMetadataManager::getTypeNameFromObject($object));
         $dbMetadata->setObjectId($object->getId());
         $dbMetadata->setStatus(Metadata::STATUS_VALID);
         $dbMetadata->save();
     } else {
         $dbMetadata->incrementVersion();
         $dbMetadata->save();
     }
     return $dbMetadata;
 }
示例#7
0
 /**
  * Check if transforming required and create job if needed
  * 
  * @param MetadataProfile $metadataProfile
  * @param int $prevVersion
  * @param string $prevXsdPath
  * 
  * @return BatchJob
  */
 public static function diffMetadataProfile(MetadataProfile $metadataProfile, $prevVersion, $prevXsdPath, $newVersion, $newXsdPath)
 {
     $xsl = kXsd::compareXsd($prevXsdPath, $newXsdPath);
     if (!$xsl) {
         return;
     }
     if (is_bool($xsl)) {
         return self::addTransformMetadataJob($metadataProfile->getPartnerId(), $metadataProfile->getId(), $prevVersion, $newVersion);
     }
     return self::addTransformMetadataJob($metadataProfile->getPartnerId(), $metadataProfile->getId(), $prevVersion, $newVersion, $xsl);
 }
function createMetadataProfile()
{
    $metadataProfile = new MetadataProfile();
    $metadataProfile->setPartnerId(99);
    $metadataProfile->setStatus(MetadataProfile::STATUS_ACTIVE);
    $metadataProfile->setName('Live Stream Monitoring');
    $metadataProfile->setSystemName('LiveMonitor');
    $metadataProfile->setDescription('Email notification flag indicating a 24/7 live-entry should be monitored.');
    $metadataProfile->setObjectType(MetadataObjectType::ENTRY);
    $metadataProfile->setRequiredCopyTemplatePermissions(FEATURE_KALTURA_LIVE_MONITOR);
    $metadataProfile->save();
    $xsdData = '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<xsd:element name="metadata">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="Monitor" minOccurs="1" maxOccurs="1">
					<xsd:annotation>
						<xsd:documentation></xsd:documentation>
						<xsd:appinfo>
							<label>Monitor 24/7</label>
							<key>monitor</key>
							<searchable>true</searchable>
							<description>Send E-mail notification if live-stream broadcast stopped</description>
						</xsd:appinfo>
					</xsd:annotation>
					<xsd:simpleType>
						<xsd:restriction base="listType">
							<xsd:enumeration value="on"/>
							<xsd:enumeration value="off"/>
						</xsd:restriction>
					</xsd:simpleType>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:simpleType name="listType">
		<xsd:restriction base="xsd:string"/>
	</xsd:simpleType>
</xsd:schema>';
    $key = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
    kFileSyncUtils::file_put_contents($key, $xsdData);
    kMetadataManager::parseProfileSearchFields($metadataProfile->getPartnerId(), $metadataProfile);
}
 /**
  * Check if transforming required and create job if needed
  * 
  * @param MetadataProfile $metadataProfile
  * @param int $prevVersion
  * @param string $prevXsdPath
  */
 public static function diffMetadataProfile(MetadataProfile $metadataProfile, $prevVersion, $prevXsdPath, $newVersion, $newXsdPath)
 {
     $xsl = true;
     if (!PermissionPeer::isValidForPartner(MetadataPermissionName::FEATURE_METADATA_NO_VALIDATION, $metadataProfile->getPartnerId())) {
         $xsl = kXsd::compareXsd($prevXsdPath, $newXsdPath);
         if (!$xsl) {
             return;
         }
     }
     if (is_bool($xsl)) {
         return self::upgradeMetadataObjects($metadataProfile->getId(), $prevVersion, $newVersion);
     }
     return self::addTransformMetadataJob($metadataProfile->getPartnerId(), $metadataProfile->getId(), $prevVersion, $newVersion, $xsl);
 }