Author: jablko
Date: Thu Aug 27 11:27:09 2009
New Revision: 3082
Log:
Add actors to search index
Modified:
trunk/lib/model/QubitActor.php
Modified: trunk/lib/model/QubitActor.php
==============================================================================
--- trunk/lib/model/QubitActor.php Wed Aug 26 16:11:59 2009 (r3081)
+++ trunk/lib/model/QubitActor.php Thu Aug 27 11:27:09 2009 (r3082)
@@ -37,6 +37,58 @@
return (string) $authorizedFormOfName;
}
+ public function updateLuceneIndex()
+ {
+ $search = new QubitSearch;
+ $query = new Zend_Search_Lucene_Search_Query_Term(new
Zend_Search_Lucene_Index_Term($this->id, 'id'));
+
+ foreach ($search->getEngine()->getIndex()->find($query) as $hit)
+ {
+ $search->getEngine()->getIndex()->delete($hit->id);
+ }
+
+ foreach ($this->actorI18ns as $actorI18n)
+ {
+ $doc = new Zend_Search_Lucene_Document;
+
+ $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $this->id));
+ $doc->addField(Zend_Search_Lucene_Field::Keyword('className',
$this->className));
+
+ $doc->addField(Zend_Search_Lucene_Field::Keyword('culture',
$actorI18n->culture));
+
+ if (isset($actorI18n->authorizedFormOfName))
+ {
+
$doc->addField(Zend_Search_Lucene_Field::UnStored('authorizedFormOfName',
$actorI18n->authorizedFormOfName));
+ }
+
+ $search->getEngine()->getIndex()->addDocument($doc);
+ }
+
+ $search->getEngine()->getIndex()->commit();
+ }
+
+ public function save($connection = null)
+ {
+ $ret = parent::save($connection);
+
+ $this->updateLuceneIndex();
+
+ return $ret;
+ }
+
+ public function delete($connection = null)
+ {
+ $search = new QubitSearch;
+ $query = new Zend_Search_Lucene_Search_Query_Term(new
Zend_Search_Lucene_Index_Term($this->id, 'id'));
+
+ foreach ($search->getEngine()->getIndex()->find($query) as $hit)
+ {
+ $search->getEngine()->getIndex()->delete($hit->id);
+ }
+
+ return parent::delete($connection);
+ }
+
public static function getAllExceptUsers($options = array())
{
//returns all Actor objects except those that are
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---