# HG changeset patch # User ymh # Date 1271259551 -7200 # Node ID 2c84c98aacb62d45ebc44d1c24b46e3dea086459 # Parent f736ee27a189f4282ba421d706e58169f7d7a3ce correct segment a dd diff -r f736ee27a189 -r 2c84c98aacb6 engine/solr/solr/conf/schema.xml --- a/engine/solr/solr/conf/schema.xml Wed Apr 14 16:20:20 2010 +0200 +++ b/engine/solr/solr/conf/schema.xml Wed Apr 14 17:39:11 2010 +0200 @@ -50,7 +50,7 @@ - + diff -r f736ee27a189 -r 2c84c98aacb6 engine/sonyengine/mosatags.sonyengine.war Binary file engine/sonyengine/mosatags.sonyengine.war has changed diff -r f736ee27a189 -r 2c84c98aacb6 web/thdProject/lib/model/doctrine/ThdSegment.class.php --- a/web/thdProject/lib/model/doctrine/ThdSegment.class.php Wed Apr 14 16:20:20 2010 +0200 +++ b/web/thdProject/lib/model/doctrine/ThdSegment.class.php Wed Apr 14 17:39:11 2010 +0200 @@ -6,7 +6,7 @@ class ThdSegment extends BaseThdSegment { - public function getSolrDocumentFields() + /*public function getSolrDocumentFields() { // keys of this array are fields' name of solr's schema.xml $type = "ThdFilm"; $fields = array('type' => $type, @@ -18,12 +18,52 @@ ); return $fields; - } + }*/ public function preInsert($event) { $this->uniqueid = UUID::generate(UUID::UUID_TIME, UUID::FMT_STRING, "mosatags"); } + + public function getTagsArray() { + + $tags = $this->getTags(); + $res = array(); + + foreach (explode(',',$tags) as $tag_name) { + $res[] = trim($tag_name); + } + + return $res; + } + + + public function postInsert($event) { + + $q = Doctrine_Query::create() + ->from('ThdSegment s') + ->innerJoin('s.ThdVideo v') + ->innerJoin('v.ThdFilm f') + ->where('s.id = ?', $this->id); + + $segment = $q->fetchOne(); + + $tags_array = array(); + + $tags = $this->getTagsArray(); + foreach ($tags as $tag_name) { + $tags_array[] = array('segment_id'=>$segment->ThdVideo->ThdFilm->uniqueid,'name'=>$tag_name); + } + + sfContext::getInstance()->getLogger()->info("insert segment " . print_r($tags_array,true)); + + $dispatcher = sfContext::getInstance()->getEventDispatcher(); + $dispatcher->notify(new sfEvent($this, 'iri_sonyengine.tag_add', array('object'=>$tags_array, 'retrain'=>true))); + + $dispatcher->notify(new sfEvent($this, 'uvmc_solr.update_document', array('object' => $segment->ThdVideo->ThdFilm, 'commit' => true))); + + + } }