# HG changeset patch # User IRI # Date 1270029427 -7200 # Node ID 47df1cde32e9aa5819dafcf53748d200dcf38cdc # Parent 99497716e36d35fa7f0f537e8bec8408ffd067eb Intermediary commit diff -r 99497716e36d -r 47df1cde32e9 .hgignore --- a/.hgignore Wed Mar 31 10:33:40 2010 +0200 +++ b/.hgignore Wed Mar 31 11:57:07 2010 +0200 @@ -24,4 +24,8 @@ ^web/thdProject/desktop\.ini$ syntax: regexp -^engine/sonyengine/context\.xml$ \ No newline at end of file +^engine/sonyengine/context\.xml$ +syntax: regexp +^web/thdProject/plugins/uvmcSolrSearchPlugin/config/solr\.yml$ +syntax: regexp +^web/thdProject/plugins/iriSonyenginePlugin/config/sonyengine\.yml$ \ No newline at end of file diff -r 99497716e36d -r 47df1cde32e9 web/thdProject/lib/model/doctrine/ThdDoctrineListener.class.php --- a/web/thdProject/lib/model/doctrine/ThdDoctrineListener.class.php Wed Mar 31 10:33:40 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/ThdDoctrineListener.class.php Wed Mar 31 11:57:07 2010 +0200 @@ -5,6 +5,12 @@ public function postInsert(Doctrine_Event $event) { $obj = $event->getInvoker(); + if (method_exists($obj, 'getSolrDocumentFields')) + { + $dispatcher = sfContext::getInstance()->getEventDispatcher(); + $dispatcher->notify(new sfEvent($mySubject, 'uvmc_solr.add_document', array('object' => $obj, 'commit' => true))); + } + // Index in solr sfContext::getInstance()->getLogger()->info("Insert object. Index in solr"); } @@ -12,7 +18,22 @@ public function postUpdate(Doctrine_Event $event) { $obj = $event->getInvoker(); + if (method_exists($obj, 'getSolrDocumentFields')) + { + $dispatcher = sfContext::getInstance()->getEventDispatcher(); + $dispatcher->notify(new sfEvent($mySubject, 'uvmc_solr.update_document', array('object' => $obj, 'commit' => true))); + } + // Reindex in solr sfContext::getInstance()->getLogger()->info("Update object. Reindex in solr"); } + + public function preDelete(Doctrine_Event $event) { + $obj = $event->getInvoker(); + if (method_exists($obj, 'getSolrDocumentFields')) + { + $dispatcher = sfContext::getInstance()->getEventDispatcher(); + $dispatcher->notify(new sfEvent($mySubject, 'uvmc_solr.delete_document', array('object' => $obj, 'commit' => true))); + } + } } \ No newline at end of file diff -r 99497716e36d -r 47df1cde32e9 web/thdProject/plugins/iriSonyenginePlugin/config/iriSonyenginePluginConfiguration.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/plugins/iriSonyenginePlugin/config/iriSonyenginePluginConfiguration.class.php Wed Mar 31 11:57:07 2010 +0200 @@ -0,0 +1,42 @@ + + * @version $Id: uvmcSolrSearchPluginConfiguration.class.php 21181 2009-08-17 08:18:16Z futurecat $ + */ +class iriSonyenginePluginConfiguration extends sfPluginConfiguration +{ + public function initialize() + { + if($this->configuration instanceof sfApplicationConfiguration) + { + $configCache = $this->configuration->getConfigCache(); + $configCache->registerConfigHandler('config/sonyengine.yml', 'sfDefineEnvironmentConfigHandler', array('prefix' => 'iri_sonyengine_')); + require_once($configCache->checkConfig('config/sonyengine.yml')); + } + + $isEnabled = sfConfig::get('iri_sonyengine_enabled', false); + $isEnabled = $isEnabled == true || $isEnabled == 'on' ? true : false; + + if ($isEnabled) + { + $this->connectEvents(); + } + } + + /** + * Connect events to listeners + */ + public function connectEvents() + { + $this->dispatcher->connect('iri_sonyengine.search', array('uvmcSolrEventListener', 'listenToSearch')); + $this->dispatcher->connect('iri_sonyengine.commit', array('uvmcSolrEventListener', 'listenToCommit')); + $this->dispatcher->connect('iri_sonyengine.add_document', array('uvmcSolrEventListener', 'listenToAddDocument')); + $this->dispatcher->connect('iri_sonyengine.update_document', array('uvmcSolrEventListener', 'listenToAddDocument')); + $this->dispatcher->connect('iri_sonyengine.delete_document', array('uvmcSolrEventListener', 'listenToDeleteDocument')); + $this->dispatcher->connect('iri_sonyengine.add_document_to_collection', array('uvmcSolrEventListener', 'listenToAddDocumentToCollection')); + $this->dispatcher->connect('iri_sonyengine.add_collection', array('uvmcSolrEventListener', 'listenToAddCollection')); + } +} \ No newline at end of file diff -r 99497716e36d -r 47df1cde32e9 web/thdProject/plugins/iriSonyenginePlugin/config/sonyengine.yml.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/plugins/iriSonyenginePlugin/config/sonyengine.yml.tmpl Wed Mar 31 11:57:07 2010 +0200 @@ -0,0 +1,11 @@ +# uvmcSolrSearchPlugin configuration file +# solr.yml can be configured at application level +# prefix: iri_sonyengine_ +# + +all: + enabled: on + service: + host: localhost + port: 8080 + path: "/sonyengine" \ No newline at end of file diff -r 99497716e36d -r 47df1cde32e9 web/thdProject/plugins/iriSonyenginePlugin/lib/iriSonyengineEventListener.class.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/thdProject/plugins/iriSonyenginePlugin/lib/iriSonyengineEventListener.class.php Wed Mar 31 11:57:07 2010 +0200 @@ -0,0 +1,17 @@ +dispatcher->connect('admin.save_object', array('uvmcSolrEventListener', 'listenToAdminSaveObject')); - $this->dispatcher->connect('admin.delete_object', array('uvmcSolrEventListener', 'listenToAdminDeleteObject')); + //$this->dispatcher->connect('admin.save_object', array('uvmcSolrEventListener', 'listenToAdminSaveObject')); + //$this->dispatcher->connect('admin.delete_object', array('uvmcSolrEventListener', 'listenToAdminDeleteObject')); $this->dispatcher->connect('uvmc_solr.search', array('uvmcSolrEventListener', 'listenToSearch')); $this->dispatcher->connect('uvmc_solr.commit', array('uvmcSolrEventListener', 'listenToCommit')); $this->dispatcher->connect('uvmc_solr.add_document', array('uvmcSolrEventListener', 'listenToAddDocument'));