<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use Doctrine\ORM\PersistentCollection;
use JsonSerializable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* collectionOperations={"get", "post"},
* itemOperations={
* "get"={
* "normalization_context"={"groups"={"shape_point:read", "shape_point:item:get", "shape:item:get"}},
* },
* "put",
* },
* shortName="shape_points",
* normalizationContext={ "groups"={"shape_point:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"shape_point:write"}, "swagger_definition_name"="Write"},
* attributes={
* "pagination_items_per_page"=50,
* "formats"={"jsonld", "json", "html", "csv"}
* }
* )
* @ApiFilter(PropertyFilter::class)
* @ApiFilter(SearchFilter::class, properties={"networkInstallation.id": "exact", "shape.id": "exact"})
* Class ShapePoint
* @package App\Entity
*
* @ORM\Entity(repositoryClass="App\Repository\ShapePointRepository")
* @ORM\Table(name="shape_points")
*/
class ShapePoint implements JsonSerializable
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
* @Groups({"shape_point:read", "shape:item:get", "point:read", "point:item:get", "shape:item:get"})
*/
private $id;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get", "point:read", "point:item:get"})
*/
private $htmlId;
/**
* @ORM\Column(type="string", length=128, nullable=true)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $shaCss;
/**
* @ORM\Column(type="string", length=16, nullable=true)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $addressFlag;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $parameter;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $pointname;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $pointnameLower;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $isDynamicallyAssigned;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $isTemplatePoint;
// currently unused
private $top;
private $left;
/**
* @ORM\Column(type="datetime", nullable=false)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $dateAdded;
/**
* @ORM\Column(type="datetime", nullable=false)
* @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
*/
private $dateModified;
/* ~~~~~~~~~~~~~~~~ OneToOne ~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~ ManyToOne ~~~~~~~~~~~~~~~~ */
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Facility", inversedBy="shapePoints", cascade={"persist"}, fetch="EXTRA_LAZY")
* @Groups({"shape_point:read"})
*/
private $facility;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\NetworkInstallation", inversedBy="shapePoints", cascade={"persist"}, fetch="EXTRA_LAZY")
* @Groups({"shape_point:read"})
*/
private $networkInstallation;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Shape", inversedBy="shapePoints", cascade={"persist"}, fetch="EXTRA_LAZY")
* @Groups({"shape_point:read", "shape_point:item:get", "point:read", "point:item:get"})
*/
private $shape;
/*
* @ORM\ManyToOne(targetEntity="App\Entity\DynamicScreen", cascade={"persist"}, inversedBy="shapePoints")
*/
// private $dynamicScreen;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Point", inversedBy="shapePoints", cascade={"persist"}, fetch="EAGER")
* @Groups({"shape_point:read", "shape:item:get"})
*/
private $point;
/* ~~~~~~~~~~~~~~~~ OneToMany ~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~ ManyToMany ~~~~~~~~~~~~~~~~ */
public function __construct()
{
$this->dateAdded = new \DateTime();
$this->setDateModified();
}
public function __toString()
{
return (string) $this->getId();
}
public function jsonSerialize()
{
return array(
'id'=> $this->id,
'htmlId' => $this->htmlId,
'shaCss' => $this->shaCss,
'addressFlag' => $this->addressFlag,
'parameter' => $this->parameter,
'pointname' => $this->pointname,
'isDynamicallyAssigned' => $this->isDynamicallyAssigned,
'isTemplatePoint' => $this->isTemplatePoint,
'top' => $this->top,
'left' => $this->left,
'dateAdded' => $this->dateAdded,
'dateModified' => $this->dateModified,
);
}
/**
* @param string $property
* @return mixed
*/
public function __get(string $property)
{
// attempt to use the method
$methodName = 'get' . ucfirst( $property );
if( method_exists( $this, $methodName ) ){
return $this->{$methodName}( $property );
}
// attempt to use the method
if (property_exists($this, $property)) {
return $this->$property;
}
return null;
}
/**
* @param string $property
* @param mixed $value
* @return bool
*/
public function __set(string $property, $value) {
// attempt to use the method
$methodName = 'set' . ucfirst( $property );
if( method_exists( $this, $methodName ) ){
$this->{$methodName}( $property, $value );
return true;
}
// attempt to use the method
if (property_exists($this, $property)) {
$this->$property = $value;
return true;
}
return false;
}
/**
* get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* get date added
*
* @return DateTime
*/
public function getDateAdded()
{
return $this->dateAdded;
}
/**
* get date modified
*
* @return DateTime
*/
public function getDateModified()
{
return $this->dateModified;
}
/**
* set date modified
*
* @return DateTime
*/
public function setDateModified()
{
$this->dateModified = new \DateTime("now");
}
/**
* get html id
*
* @return string
*/
public function getHtmlId()
{
return $this->htmlId;
}
/**
* set html id
*
* @param string $htmlId
*
* @return ShapePoint
*/
public function setHtmlId($htmlId)
{
$this->htmlId = $htmlId;
return $this;
}
/**
* get css class
*
* @return string
*/
public function getShaCss()
{
return $this->shaCss;
}
/**
* set css class
*
* @param string $shaCss
*
* @return ShapePoint
*/
public function setShaCss($shaCss)
{
$this->shaCss = $shaCss;
return $this;
}
public function getCss(){
$shaCss = explode( ' ', $this->getShaCss() );
$css = implode( ', ', $shaCss );
return $css;
}
/**
* get address flag
*
* @return string
*/
public function getAddressFlag()
{
return $this->addressFlag;
}
/**
* set address flag
*
* @param string $addressFlag
*
* @return ShapePoint
*/
public function setAddressFlag($addressFlag)
{
$this->addressFlag = $addressFlag;
return $this;
}
/**
* get parameter
*
* @return string
*/
public function getParameter()
{
return $this->parameter;
}
/**
* set parameter
*
* @param string $parameter
*
* @return ShapePoint
*/
public function setParameter($parameter)
{
$this->parameter = $parameter;
return $this;
}
/**
* get pointname
*
* @return string
*/
public function getPointname()
{
return $this->pointname;
}
/**
* set pointname
*
* @param string $pointname
*
* @return ShapePoint
*/
public function setPointname($pointname)
{
$this->pointname = $pointname;
$this->pointnameLower = strtolower($pointname);
return $this;
}
/**
* get pointnameLower
*
* @return string
*/
public function getPointnameLower()
{
return $this->pointnameLower;
}
/**
* set pointnameLower
*
* @param string $pointnameLower
*
* @return ShapePoint
*/
public function setPointnameLower($pointnameLower)
{
$this->pointnameLower = strtolower($pointnameLower);
return $this;
}
/**
* get isTemplate
*
* @return boolean
*/
public function getIsTemplate()
{
return $this->isTemplate;
}
/**
* set isTemplate
*
* @param boolean $isTemplate
*
* @return ShapePoint
*/
public function setIsTemplate($isTemplate)
{
$this->isTemplate = $isTemplate;
return $this;
}
public function getBindingId(){
return 'NA';
}
public function getDatasourceId()
{
return 'NA';
}
public function isScreenOrShapePoint(){
return 'shape';
}
/**
* get isDynamicallyAssigned
*
* @return boolean isDynamicallyAssigned
*/
public function getIsDynamicallyAssigned()
{
return $this->isDynamicallyAssigned;
}
/**
* set isDynamicallyAssigned
*
* @param boolean isDynamicallyAssigned
*
* @return ShapePoint
*/
public function setIsDynamicallyAssigned( $isDynamicallyAssigned )
{
$this->isDynamicallyAssigned = $isDynamicallyAssigned;
return $this;
}
/* ~~~~~~~~~~~~~~~~ OneToOne ~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~ OneToMany ~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~ ManyToOne ~~~~~~~~~~~~~~~~ */
/**
* get facility
*
* @return Facility
*/
public function getFacility()
{
return $this->facility;
}
/**
* set facility
*
* @param \App\Entity\Facility $facility
*
* @return ShapePoint
*/
public function setFacility(\App\Entity\Facility $facility)
{
$this->facility = $facility;
return $this;
}
/**
* get networkInstallation
*
* @return NetworkInstallation
*/
public function getNetworkInstallation()
{
return $this->networkInstallation;
}
/**
* set networkInstallation
*
* @param \App\Entity\NetworkInstallation $networkInstallation
*
* @return ShapePoint
*/
public function setNetworkInstallation(\App\Entity\NetworkInstallation $networkInstallation)
{
$this->networkInstallation = $networkInstallation;
return $this;
}
/**
* set point
*
* @param \App\Entity\Point $point
*
* @return ShapePoint
*/
public function getPoint()
{
return $this->point;
}
public function setPoint(\App\Entity\Point $point)
{
$this->point = $point;
$point->addShapePoint($this);
$point->setIsAssigned(true);
return $this;
}
public function removePoint(){
$point = $this->point;
$point->removeShapePoint($this);
$point->setIsAssigned(false);
$this->point = null;
}
public function getShape()
{
return $this->shape;
}
/**
* set shape
*
* @param \App\Entity\Shape $shape
*
* @return ShapePoint
*/
public function setShape(\App\Entity\Shape $shape)
{
$this->shape = $shape;
$shape->addShapePoint($this);
return $this;
}
/**
* unset shape
*
* @param \App\Entity\Shape $shape
*
* @return ShapePoint
*/
public function unsetShape(\App\Entity\Shape $shape)
{
$shape->removeShapePoint($this);
$this->shape = null;
return $this;
}
/* ~~~~~~~~~~~~~~~~ ManyToMany ~~~~~~~~~~~~~~~~ */
}