<?php
/**
* @author OfficeBrain 4160 <info@officebrain.com>
*
* Description :  Activity Logs Document
*
**/
namespace OfficeBrain\Bundle\ActivityBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * @MongoDB\Document(repositoryClass="OfficeBrain\Bundle\ActivityBundle\Document\ActivityLogRepository")
 */
class ActivityLog
{
    /**
     * @MongoDB\Id
     */
    protected $id;

    /**
     * @MongoDB\Field(type="int")
     */
    protected $userId;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $ipAddress;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $userAgent;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $language;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $requestURI;
    /**
     * @MongoDB\Field(type="string")
     */
    protected $hostName;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $device;
    
    /**
     * @MongoDB\Field(type="int")
     */
    protected $instanceId;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $instanceType;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $bundleName;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $entityName;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $actionName;
    
    /**
     * @MongoDB\Field(type="string")
     */
    protected $activityMessage;
    
    /**
     * @MongoDB\Field(type="hash")
     */
    protected $args;
    
    /**
     * @MongoDB\Field(type="date")
     */
    protected $createdAt;
    
    /**
     * @MongoDB\Field(type="hash")
     */
    private $data;
    
    /**
     * Get id
     *
     * @return id $id
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set instanceId
     *
     * @param int $instanceId
     * @return self
     */
    public function setInstanceId($instanceId)
    {
        $this->instanceId = $instanceId;
        return $this;
    }

    /**
     * Get instanceId
     *
     * @return int $instanceId
     */
    public function getInstanceId()
    {
        return $this->instanceId;
    }

    /**
     * Set instanceType
     *
     * @param string $instanceType
     * @return self
     */
    public function setInstanceType($instanceType)
    {
        $this->instanceType = $instanceType;
        return $this;
    }

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

    /**
     * Set entityName
     *
     * @param string $entityName
     * @return self
     */
    public function setEntityName($entityName)
    {
        $this->entityName = $entityName;
        return $this;
    }

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

    /**
     * Set actionName
     *
     * @param string $actionName
     * @return self
     */
    public function setActionName($actionName)
    {
        $this->actionName = $actionName;
        return $this;
    }

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

    /**
     * Set activityMessage
     *
     * @param string $activityMessage
     * @return self
     */
    public function setActivityMessage($activityMessage)
    {
        $this->activityMessage = $activityMessage;
        return $this;
    }

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

    /**
     * Set args
     *
     * @param hash $args
     * @return self
     */
    public function setArgs($args)
    {
        $this->args = $args;
        return $this;
    }

    /**
     * Get args
     *
     * @return hash $args
     */
    public function getArgs()
    {
        return $this->args;
    }

    /**
     * Set createdAt
     *
     * @param date $createdAt
     * @return self
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;
        return $this;
    }

    /**
     * Get createdAt
     *
     * @return date $createdAt
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set userId
     *
     * @param int $userId
     * @return self
     */
    public function setUserId($userId)
    {
        $this->userId = $userId;
        return $this;
    }

    /**
     * Get userId
     *
     * @return int $userId
     */
    public function getUserId()
    {
        return $this->userId;
    }

    /**
     * Set ipAddress
     *
     * @param string $ipAddress
     * @return self
     */
    public function setIpAddress($ipAddress)
    {
        $this->ipAddress = $ipAddress;
        return $this;
    }

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

    /**
     * Set userAgent
     *
     * @param string $userAgent
     * @return self
     */
    public function setUserAgent($userAgent)
    {
        $this->userAgent = $userAgent;
        return $this;
    }

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

    /**
     * Set language
     *
     * @param string $language
     * @return self
     */
    public function setLanguage($language)
    {
        $this->language = $language;
        return $this;
    }

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

    /**
     * Set requestURI
     *
     * @param string $requestURI
     * @return self
     */
    public function setRequestURI($requestURI)
    {
        $this->requestURI = $requestURI;
        return $this;
    }

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

    /**
     * Set bundleName
     *
     * @param string $bundleName
     * @return self
     */
    public function setBundleName($bundleName)
    {
        $this->bundleName = $bundleName;
        return $this;
    }

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

    /**
     * Set device
     *
     * @param string $device
     * @return self
     */
    public function setDevice($device)
    {
        $this->device = $device;
        return $this;
    }

    /**
     * Get device
     *
     * @return string $device
     */
    public function getDevice()
    {
        return $this->device;
    }
    
    /**
     * Set setRequestInfo
     *
     * @param string $request
     * @return self
     */
    public function setRequestInfo($request)
    {
        $projectSetting = $request->get('project_setting');
        $this->setInstanceType($projectSetting['instance_type']);
        $this->setInstanceId($projectSetting['instance_id']);
        $this->setUserId($projectSetting['user_id']);
        $this->setIpAddress($request->getClientIp());
        $this->setLanguage(serialize($request->getLanguages()));
        $this->setRequestURI($request->getRequestUri());
        $this->setHostName($request->getSchemeAndHttpHost());
        $this->setUserAgent($request->headers->get('User-Agent'));
        $this->setDevice($request->headers->get('User-Agent'));
        $this->setCreatedAt(date('Y-m-d H:i:s'));
    }
    /**
     * Get data
     *
     * @return hash $data
     */
    public function getData()
    {
        return $this->data;
    }
    
    /**
     * Set data
     *
     * @param hash $data
     * @return self
     */
    public function setData($data)
    {
        if (!empty($data)) {
            $this->data = $data;
        } else {
            $this->data =array();
        }
        
        return $this;
    }
    public function getHostName()
    {
        return $this->hostName;
    }
    public function setHostName($hostName)
    {
        $this->hostName = $hostName;
        return $this;
    }
}
