<?php

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


  public function preInsert($event) {
    $this->uniqueid = UUID::generate(UUID::UUID_TIME, UUID::FMT_STRING,     "mosatags");
    $this->creation_date = strftime('%Y-%m-%d %H:%M:%S');
  }


  public function getThdTags() {
    $objs = Array();
    $query = Doctrine_Query::create()
      ->from('ThdSegmentTag')
      ->where("segment_id='{$this->getId()}'");

    foreach ($query->execute() as $item) {
      $objs[] = $item->getThdTag();
    }

    return $objs;
  }

  public function getTags() {
    $tags = Array();

    foreach ($this->getThdTags() as $item) {
      $tags[] = $item->getTag();
    }

    return $tags;
  }

  public function getDistinctTags() {
    $tags = Array();

    foreach ($this->getThdTags() as $item) {
      $tag = $item->getTag();
      if (in_array($tag, $tags)) continue;
      $tags[] = $tag;
    }

    return $tags;
  }

}
