/**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     ConceptPropertyPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new ConceptPropertyPeer();
     }
     return self::$peer;
 }
 /**
  * wraps the save function to update concept first
  * adds history function
  *
  * Stores the object in the database.  If the object is new,
  * it inserts it; otherwise an update is performed.  This method
  * wraps the doSave() worker method in a transaction.
  *
  * @param Connection $con
  * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see doSave()
  */
 public function save($con = null)
 {
     $concept = $this->getConceptRelatedByConceptId();
     $userId = sfContext::getInstance()->getUser()->getSubscriberId();
     if ($userId) {
         $this->setUpdatedUserId($userId);
     }
     if ($concept) {
         if ($userId) {
             $concept->setUpdatedUserId($userId);
         }
         //check to see if the primary pref label flag is set
         if ($this->primary_pref_label) {
             //if set, then update the associated concept fields
             $concept->setPrefLabel($this->getObject());
             $concept->setStatusId($this->getStatusId());
             $concept->setLanguage($this->getLanguage());
         }
         $vocabularyId = $concept->getVocabularyId();
     }
     if ($this->isModified()) {
         if ($this->isNew()) {
             $action = 'added';
         } elseif ($this->isDeleted()) {
             $action = 'force_deleted';
         } else {
             $action = 'updated';
         }
     } else {
         $action = 'added';
     }
     //continue with save
     parent::save();
     //do the history
     $history = new ConceptPropertyHistory();
     if ($action == 'updated' && $this->getDeletedAt()) {
         $action = 'deleted';
     }
     $history->setAction($action);
     $history->setVocabularyId($vocabularyId);
     $history->setConceptId($this->getConceptId());
     $history->setConceptPropertyId($this->getId());
     $history->setSkosPropertyId($this->getSkosPropertyId());
     $history->setObject($this->getObject());
     $history->setSchemeId($this->getSchemeId());
     $history->setRelatedConceptId($this->getRelatedConceptId());
     $history->setLanguage($this->getLanguage());
     $history->setStatusId($this->getStatusId());
     $history->setCreatedUserId($this->getUpdatedUserId());
     $history->setCreatedAt($this->getUpdatedAt());
     if (!empty($this->importId)) {
         $history->setImportId($this->importId);
     }
     $history->save();
 }