/**
  * 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);
 }
Beispiel #4
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);
 }
Beispiel #5
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;
 }
Beispiel #6
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);
 }
 /**
  * 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);
 }