<?php

/**
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class ThdFilm extends BaseThdFilm
{

    public function getSolrDocumentFields()
    {
        // keys of this array are fields' name of solr's schema.xml
        $type = "ThdFilm";
        $fields = array('type'           => $type,
                        'id'             => $this->getId(),
                        'title'          => array('value' => $this->getTitle(), 'boost' => 1.0),
                        'desc'           => array('value' => $this->getPitch(), 'boost' => 1.0),
                        'directors'      => array('value' => $this->getDirectors(), 'boost' => 1.0),
                        'actors'         => array('value' => $this->getActors(), 'boost' => 1.0),
                        'original_title' => array('value' => $this->getOriginal_title(), 'boost' => 1.0),
                        'uniqueid'       => array('value' => $this->getUniqueid(), 'boost' => 1.0),
        );

        return $fields;
    }

    public function preInsert($event)
    {
        $this->uniqueid = UUID::generate(UUID::UUID_TIME, UUID::FMT_STRING, "mosatags");
    }

    protected function decodeJsonData($attr) {
      $data = $this->getData();
      return json_decode($data[$attr], true);
    }

    public function getDirectorsArray() {
      return $this->decodeJsonData('directors');
    }

    public function getActorsArray() {
      return $this->decodeJsonData('actors');
    }

    public function getProductionCountriesArray() {
      return $this->decodeJsonData('production_countries');
    }

}
