<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use JsonSerializable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Class ProjectData
* @package App\Entity
*
* @ORM\Entity
* @ORM\Table(name="project_data")
*
*/
class ProjectData implements JsonSerializable
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $key;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $keyLower;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $value;
/**
* @ORM\Column(type="string", length=8, nullable=true)
*/
private $dateYmd; // date format: Ymd | result: YYYYmmdd
/**
* @ORM\Column(type="string", length=6, nullable=true)
*/
private $dateHis; // date format: His | result: HHiiss
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private $dateAdded;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Facility", inversedBy="projectData", cascade={"persist"}, fetch="EXTRA_LAZY")
*/
private $facility;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\NetworkInstallation", inversedBy="projectData", cascade={"persist"}, fetch="EXTRA_LAZY")
*/
private $networkInstallation;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Project", inversedBy="projectData", cascade={"persist"}, fetch="EXTRA_LAZY")
*/
private $project;
public function __construct()
{
$this->dateAdded = new \DateTime();
$this->dateYmd = $this->dateAdded->format( 'Ymd' );
$this->dateHis = $this->dateAdded->format( 'His' );
}
public function jsonSerialize()
{
return array(
'id'=> $this->id,
'key' => $this->key,
'value' => $this->value,
'dateAdded' => $this->dateAdded,
'dateYmd' => $this->dateYmd,
'dateHis' => $this->dateHis,
'dateMjY' => $this->getDateMjY(),
'facilityId' => !is_null( $this->getFacility() ) ? $this->getFacility()->getId() : null,
'projectId' => !is_null( $this->getProject() ) ? $this->getProject()->getId() : null,
);
}
/**
* get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* get key
*
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* set key
*
* @param string $key
*
* @return ProjectData
*/
public function setKey($key)
{
$this->key = $key;
$this->keyLower = strtolower($key);
return $this;
}
/**
* get value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* set value
*
* @param string $value
*
* @return ProjectData
*/
public function setValue($value)
{
$this->value = strtolower($value);
return $this;
}
/**
* get dateYmd
*
* @return string
*/
public function getDateYmd()
{
return $this->dateYmd;
}
/**
* set dateYmd
*
* @param string $dateYmd
*
* @return ProjectData
*/
public function setDateYmd($dateYmd)
{
$this->dateYmd = $dateYmd;
return $this;
}
/**
* get dateHis
*
* @return string
*/
public function getDateGis()
{
return $this->dateHis;
}
/**
* set dateHis
*
* @param string $dateHis
*
* @return ProjectData
*/
public function setDateGis($dateHis)
{
$this->dateHis = $dateHis;
return $this;
}
/**
* get dateMjY
*
* @return string
*/
public function getDateMjY()
{
return $this->dateAdded->format( 'M j, Y' );
}
/**
* get date added
*
* @return \DateTime
*/
public function getDateAdded()
{
return $this->dateAdded;
}
/**
* set date added
*
* @param \DateTime $date
* @return \DateTime
*/
public function setDateAdded(\DateTime $date)
{
$this->dateAdded = $date;
$this->dateYmd = $this->dateAdded->format( 'Ymd' );
$this->dateHis = $this->dateAdded->format( 'His' );
return $this->dateAdded;
}
/**
* get facility
*
* @return Facility
*/
public function getFacility()
{
return $this->facility;
}
/**
* set facility
*
* @param Facility|null $facility
*
* @return ProjectData
*/
public function setFacility(Facility $facility = null)
{
if( !is_null( $facility ) ){
// update the inverse side
$facility->addProjectData( $this );
} else {
$facility->addProjectData( null );
}
$this->facility = $facility;
return $this;
}
/**
* get networkInstallation
*
* @return NetworkInstallation
*/
public function getNetworkInstallation()
{
return $this->networkInstallation;
}
/**
* set networkInstallation
*
* @param \App\Entity\NetworkInstallation $networkInstallation
*
* @return NetworkInstallationData
*/
public function setNetworkInstallation(\App\Entity\NetworkInstallation $networkInstallation)
{
$networkInstallation->addNetworkInstallationData( $this );
$this->networkInstallation = $networkInstallation;
return $this;
}
/**
* get project
*
* @return Project
*/
public function getProject()
{
return $this->project;
}
/**
* set project
*
* @param \App\Entity\Project $project
*
* @return ProjectData
*/
public function setProject(\App\Entity\Project $project)
{
$project->addProjectData( $this );
$this->project = $project;
return $this;
}
}