<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use RxConnexionBundle\Entity\Base\BaseEntity;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use JMS\Serializer\Annotation\Groups;


/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\ChatRepository")
 * @ORM\Table(name="chat")
 */

class ChatEntity extends BaseEntity
{

    /**
     * @ORM\Column(name="description", type="string")
     */
    protected $description;

    /**
     * @ORM\Column(name="chat_type", type="string")
     */
    protected $chatType;

    /**
     * @ORM\Column(name="is_deleted", type="boolean")
     */
    protected $isDeleted;

    /**
     * @ORM\ManyToOne(targetEntity="AccountUserEntity", inversedBy="chats")
     * @ORM\JoinColumn(name="account_user_id", referencedColumnName="id")
     */
    protected $accountUser;

    /**
     * @ORM\OneToMany(targetEntity="ChatMessageEntity", mappedBy="chat")
     */
    protected $chatMessages;

    /**
     * @ORM\OneToMany(targetEntity="ChatParticipantEntity", mappedBy="chat" , cascade={"persist", "remove"}, orphanRemoval=true)
     */
    protected $chatParticipants;


    /*--------------------------------------------------------------------------------------------------------*/
    /*					Use Defined Setters and Getters														  */
    /*--------------------------------------------------------------------------------------------------------*/

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->isDeleted = 0;
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/


    /**
     * Constructor
     */
    public function __construct()
    {
        $this->chatMessages = new \Doctrine\Common\Collections\ArrayCollection();
        $this->chatParticipants = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Set description
     *
     * @param string $description
     *
     * @return ChatEntity
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set isDeleted
     *
     * @param boolean $isDeleted
     *
     * @return ChatEntity
     */
    public function setIsDeleted($isDeleted)
    {
        $this->isDeleted = $isDeleted;

        return $this;
    }

    /**
     * Get isDeleted
     *
     * @return boolean
     */
    public function getIsDeleted()
    {
        return $this->isDeleted;
    }

    /**
     * Add chatMessage
     *
     * @param \RxConnexionBundle\Entity\ChatMessageEntity $chatMessage
     *
     * @return ChatEntity
     */
    public function addChatMessage(\RxConnexionBundle\Entity\ChatMessageEntity $chatMessage)
    {
        $this->chatMessages[] = $chatMessage;

        return $this;
    }

    /**
     * Remove chatMessage
     *
     * @param \RxConnexionBundle\Entity\ChatMessageEntity $chatMessage
     */
    public function removeChatMessage(\RxConnexionBundle\Entity\ChatMessageEntity $chatMessage)
    {
        $this->chatMessages->removeElement($chatMessage);
    }

    /**
     * Get chatMessages
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getChatMessages()
    {
        return $this->chatMessages;
    }

    /**
     * Add chatParticipant
     *
     * @param \RxConnexionBundle\Entity\ChatParticipantEntity $chatParticipant
     *
     * @return ChatEntity
     */
    public function addChatParticipant(\RxConnexionBundle\Entity\ChatParticipantEntity $chatParticipant)
    {
        $chatParticipant->setChat($this);
        $this->chatParticipants[] = $chatParticipant;

        return $this;
    }

    /**
     * Remove chatParticipant
     *
     * @param \RxConnexionBundle\Entity\ChatParticipantEntity $chatParticipant
     */
    public function removeChatParticipant(\RxConnexionBundle\Entity\ChatParticipantEntity $chatParticipant)
    {
        $this->chatParticipants->removeElement($chatParticipant);
    }

    /**
     * Get chatParticipants
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getChatParticipants()
    {
        return $this->chatParticipants;
    }

    /**
     * Set chatType
     *
     * @param string $chatType
     *
     * @return ChatEntity
     */
    public function setChatType($chatType)
    {
        $this->chatType = $chatType;

        return $this;
    }

    /**
     * Get chatType
     *
     * @return string
     */
    public function getChatType()
    {
        return $this->chatType;
    }

    /**
     * Set accountUser
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $accountUser
     *
     * @return ChatEntity
     */
    public function setAccountUser(\RxConnexionBundle\Entity\AccountUserEntity $accountUser = null)
    {
        $this->accountUser = $accountUser;

        return $this;
    }

    /**
     * Get accountUser
     *
     * @return \RxConnexionBundle\Entity\AccountUserEntity
     */
    public function getAccountUser()
    {
        return $this->accountUser;
    }
}
