/**
  * 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      MetadataProfileField $value A MetadataProfileField object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(MetadataProfileField $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #2
0
 public static function setAdditionalProfileFieldData(MetadataProfile $metadataProfile, MetadataProfileField $profileField, $xPathData)
 {
     if ($profileField->getType() === MetadataSearchFilter::KMC_FIELD_TYPE_METADATA_OBJECT && isset($xPathData['metadataProfileId'])) {
         if ($xPathData['metadataProfileId'] == $metadataProfile->getId()) {
             throw new kCoreException('Self metadata reference is not allowed');
         }
         $relatedMetadataProfileId = $xPathData['metadataProfileId'];
         $profileField->setRelatedMetadataProfileId($relatedMetadataProfileId);
     }
 }
 /**
  * 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      MetadataProfileField $value A MetadataProfileField object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(MetadataProfileField $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('MetadataProfileFieldPeer');
         }
     }
 }
Example #4
0
 /**
  * Parse the XSD and update the list of search fields
  * 
  * @param MetadataProfile $metadataProfile
  * 
  * @return TBD
  */
 public static function parseProfileSearchFields(MetadataProfile $metadataProfile)
 {
     $key = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION);
     $xsdPath = kFileSyncUtils::getLocalFilePathForKey($key);
     $xPaths = kXsd::findXpathsByAppInfo($xsdPath, self::APP_INFO_SEARCH, 'true');
     MetadataProfileFieldPeer::setUseCriteriaFilter(false);
     $profileFields = MetadataProfileFieldPeer::retrieveByMetadataProfileId($metadataProfile->getId());
     MetadataProfileFieldPeer::setUseCriteriaFilter(true);
     // check all existing fields
     foreach ($profileFields as $profileField) {
         $xPath = $profileField->getXpath();
         // field removed
         if (!isset($xPaths[$xPath])) {
             $profileField->setStatus(MetadataProfileField::STATUS_DEPRECATED);
             $profileField->save();
             continue;
         }
         $xPathData = $xPaths[$xPath];
         $profileField->setStatus(MetadataProfileField::STATUS_ACTIVE);
         $profileField->setMetadataProfileVersion($metadataProfile->getVersion());
         if (isset($xPathData['name'])) {
             $profileField->setKey($xPathData['name']);
         }
         if (isset($xPathData['label'])) {
             $profileField->setLabel($xPathData['label']);
         }
         if (isset($xPathData['type'])) {
             $profileField->setType($xPathData['type']);
         }
         $profileField->save();
         unset($xPaths[$xPath]);
     }
     // add new searchable fields
     foreach ($xPaths as $xPath => $xPathData) {
         $profileField = new MetadataProfileField();
         $profileField->setMetadataProfileId($metadataProfile->getId());
         $profileField->setMetadataProfileVersion($metadataProfile->getVersion());
         $profileField->setPartnerId($metadataProfile->getPartnerId());
         $profileField->setStatus(MetadataProfileField::STATUS_ACTIVE);
         $profileField->setXpath($xPath);
         if (isset($xPathData['name'])) {
             $profileField->setKey($xPathData['name']);
         }
         if (isset($xPathData['label'])) {
             $profileField->setLabel($xPathData['label']);
         }
         if (isset($xPathData['type'])) {
             $profileField->setType($xPathData['type']);
         }
         $profileField->save();
     }
     // set none searchable existing fields
     $xPaths = kXsd::findXpathsByAppInfo($xsdPath, self::APP_INFO_SEARCH, 'false');
     foreach ($profileFields as $profileField) {
         $xPath = $profileField->getXpath();
         if (!isset($xPaths[$xPath])) {
             continue;
         }
         $xPathData = $xPaths[$xPath];
         if (isset($xPathData['name'])) {
             $profileField->setKey($xPathData['name']);
         }
         if (isset($xPathData['label'])) {
             $profileField->setLabel($xPathData['label']);
         }
         if (isset($xPathData['type'])) {
             $profileField->setType($xPathData['type']);
         }
         $profileField->setStatus(MetadataProfileField::STATUS_NONE_SEARCHABLE);
         $profileField->setMetadataProfileVersion($metadataProfile->getVersion());
         $profileField->save();
         unset($xPaths[$xPath]);
     }
     // add new none searchable fields
     foreach ($xPaths as $xPath => $xPathData) {
         $profileField = new MetadataProfileField();
         $profileField->setMetadataProfileId($metadataProfile->getId());
         $profileField->setMetadataProfileVersion($metadataProfile->getVersion());
         $profileField->setPartnerId($metadataProfile->getPartnerId());
         $profileField->setStatus(MetadataProfileField::STATUS_NONE_SEARCHABLE);
         $profileField->setXpath($xPath);
         if (isset($xPathData['name'])) {
             $profileField->setKey($xPathData['name']);
         }
         if (isset($xPathData['label'])) {
             $profileField->setLabel($xPathData['label']);
         }
         if (isset($xPathData['type'])) {
             $profileField->setType($xPathData['type']);
         }
         $profileField->save();
     }
 }