src/Entity/ShapePoint.php line 169

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  7. use Doctrine\ORM\PersistentCollection;
  8. use JsonSerializable;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. /**
  14.  * @ApiResource(
  15.  *     collectionOperations={"get", "post"},
  16.  *     itemOperations={
  17.  *          "get"={
  18.  *              "normalization_context"={"groups"={"shape_point:read", "shape_point:item:get", "shape:item:get"}},
  19.  *          },
  20.  *          "put",
  21.  *     },
  22.  *     shortName="shape_points",
  23.  *     normalizationContext={  "groups"={"shape_point:read"},  "swagger_definition_name"="Read"},
  24.  *     denormalizationContext={"groups"={"shape_point:write"}, "swagger_definition_name"="Write"},
  25.  *     attributes={
  26.  *          "pagination_items_per_page"=50,
  27.  *          "formats"={"jsonld", "json", "html", "csv"}
  28.  *     }
  29.  * )
  30.  * @ApiFilter(PropertyFilter::class)
  31.  * @ApiFilter(SearchFilter::class, properties={"networkInstallation.id": "exact", "shape.id": "exact"})
  32. * Class ShapePoint
  33. * @package App\Entity
  34. *
  35. * @ORM\Entity(repositoryClass="App\Repository\ShapePointRepository")
  36. * @ORM\Table(name="shape_points")
  37. */
  38. class ShapePoint implements JsonSerializable
  39. {
  40.     /**
  41.      * @ORM\Id()
  42.      * @ORM\GeneratedValue()
  43.      * @ORM\Column(type="integer")
  44.      * @Groups({"shape_point:read", "shape:item:get", "point:read", "point:item:get", "shape:item:get"})
  45.      */
  46.     private $id;
  47.     /**
  48.      * @ORM\Column(type="string", length=64, nullable=true)
  49.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get", "point:read", "point:item:get"})
  50.      */
  51.     private $htmlId;
  52.     /**
  53.      * @ORM\Column(type="string", length=128, nullable=true)
  54.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  55.      */
  56.     private $shaCss;
  57.     /**
  58.     * @ORM\Column(type="string", length=16, nullable=true)
  59.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  60.      */
  61.     private $addressFlag;
  62.     /**
  63.      * @ORM\Column(type="string", length=64, nullable=true)
  64.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  65.      */
  66.     private $parameter;
  67.     /**
  68.      * @ORM\Column(type="string", length=64, nullable=true)
  69.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  70.      */
  71.     private $pointname;
  72.     /**
  73.      * @ORM\Column(type="string", length=64, nullable=true)
  74.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  75.      */
  76.     private $pointnameLower;
  77.     /**
  78.      * @ORM\Column(type="boolean", nullable=true)
  79.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  80.      */
  81.     private $isDynamicallyAssigned;
  82.     /**
  83.      * @ORM\Column(type="boolean", nullable=true)
  84.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  85.      */
  86.     private $isTemplatePoint;
  87.     // currently unused
  88.     private $top;
  89.     private $left;
  90.     /**
  91.      * @ORM\Column(type="datetime", nullable=false)
  92.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  93.      */
  94.     private $dateAdded;
  95.     /**
  96.      * @ORM\Column(type="datetime", nullable=false)
  97.      * @Groups({"shape_point:read", "shape_point:write", "shape:item:get"})
  98.      */
  99.     private $dateModified;
  100.     /* ~~~~~~~~~~~~~~~~ OneToOne ~~~~~~~~~~~~~~~~ */
  101.     /* ~~~~~~~~~~~~~~~~ ManyToOne ~~~~~~~~~~~~~~~~ */
  102.     /**
  103.      * @ORM\ManyToOne(targetEntity="App\Entity\Facility", inversedBy="shapePoints", cascade={"persist"}, fetch="EXTRA_LAZY")
  104.      * @Groups({"shape_point:read"})
  105.      */
  106.     private $facility;
  107.     /**
  108.      * @ORM\ManyToOne(targetEntity="App\Entity\NetworkInstallation", inversedBy="shapePoints", cascade={"persist"}, fetch="EXTRA_LAZY")
  109.      * @Groups({"shape_point:read"})
  110.      */
  111.     private $networkInstallation;
  112.     /**
  113.      * @ORM\ManyToOne(targetEntity="App\Entity\Shape", inversedBy="shapePoints", cascade={"persist"}, fetch="EXTRA_LAZY")
  114.      * @Groups({"shape_point:read", "shape_point:item:get", "point:read", "point:item:get"})
  115.      */
  116.     private $shape;
  117.     /*
  118.      * @ORM\ManyToOne(targetEntity="App\Entity\DynamicScreen", cascade={"persist"}, inversedBy="shapePoints")
  119.      */
  120.     // private $dynamicScreen;
  121.     /**
  122.      * @ORM\ManyToOne(targetEntity="App\Entity\Point", inversedBy="shapePoints", cascade={"persist"}, fetch="EAGER")
  123.      * @Groups({"shape_point:read", "shape:item:get"})
  124.      */
  125.     private $point;
  126.     
  127.     /* ~~~~~~~~~~~~~~~~ OneToMany ~~~~~~~~~~~~~~~~ */
  128.     /* ~~~~~~~~~~~~~~~~ ManyToMany ~~~~~~~~~~~~~~~~ */
  129.     public function __construct()
  130.     {
  131.         $this->dateAdded = new \DateTime();
  132.         $this->setDateModified();
  133.     }
  134.     public function __toString()
  135.     {
  136.         return (string) $this->getId();
  137.     }
  138.     public function jsonSerialize()
  139.     {
  140.         return array(
  141.             'id'=> $this->id,
  142.             'htmlId' => $this->htmlId,
  143.             'shaCss' => $this->shaCss,
  144.             'addressFlag' => $this->addressFlag,
  145.             'parameter' => $this->parameter,
  146.             'pointname' => $this->pointname,
  147.             'isDynamicallyAssigned' => $this->isDynamicallyAssigned,
  148.             'isTemplatePoint' => $this->isTemplatePoint,
  149.             'top' => $this->top,
  150.             'left' => $this->left,
  151.             'dateAdded' => $this->dateAdded,
  152.             'dateModified' => $this->dateModified,
  153.         );
  154.     }
  155.     /**
  156.      * @param string $property
  157.      * @return mixed
  158.      */
  159.     public function __get(string $property)
  160.     {
  161.         // attempt to use the method
  162.         $methodName 'get' ucfirst$property );
  163.         if( method_exists$this$methodName ) ){
  164.             return $this->{$methodName}( $property );
  165.         }
  166.         // attempt to use the method
  167.         if (property_exists($this$property)) {
  168.             return $this->$property;
  169.         }
  170.         return null;
  171.     }
  172.     /**
  173.      * @param string $property
  174.      * @param mixed $value
  175.      * @return bool
  176.      */
  177.     public function __set(string $property$value) {
  178.         // attempt to use the method
  179.         $methodName 'set' ucfirst$property );
  180.         if( method_exists$this$methodName ) ){
  181.             $this->{$methodName}( $property$value );
  182.             return true;
  183.         }
  184.         // attempt to use the method
  185.         if (property_exists($this$property)) {
  186.             $this->$property $value;
  187.             return true;
  188.         }
  189.         return false;
  190.     }
  191.     /**
  192.      * get id
  193.      *
  194.      * @return integer
  195.      */
  196.     public function getId()
  197.     {
  198.         return $this->id;
  199.     }
  200.     /**
  201.      * get date added
  202.      *
  203.      * @return DateTime
  204.      */
  205.     public function getDateAdded()
  206.     {
  207.         return $this->dateAdded;
  208.     }
  209.     /**
  210.      * get date modified
  211.      *
  212.      * @return DateTime
  213.      */
  214.     public function getDateModified()
  215.     {
  216.         return $this->dateModified;
  217.     }
  218.     /**
  219.      * set date modified
  220.      *
  221.      * @return DateTime
  222.      */
  223.     public function setDateModified()
  224.      {
  225.          $this->dateModified = new \DateTime("now");
  226.      }
  227.     /**
  228.      * get html id
  229.      *
  230.      * @return string
  231.      */
  232.     public function getHtmlId()
  233.     {
  234.         return $this->htmlId;
  235.     }
  236.     /**
  237.      * set html id
  238.      *
  239.      * @param string $htmlId
  240.      *
  241.      * @return ShapePoint
  242.      */
  243.     public function setHtmlId($htmlId)
  244.     {
  245.         $this->htmlId $htmlId;
  246.         return $this;
  247.     }
  248.     /**
  249.      * get css class
  250.      *
  251.      * @return string
  252.      */
  253.     public function getShaCss()
  254.     {
  255.         return $this->shaCss;
  256.     }
  257.     /**
  258.      * set css class
  259.      *
  260.      * @param string $shaCss
  261.      *
  262.      * @return ShapePoint
  263.      */
  264.     public function setShaCss($shaCss)
  265.     {
  266.         $this->shaCss $shaCss;
  267.         return $this;
  268.     }
  269.     public function getCss(){
  270.         $shaCss explode' '$this->getShaCss() );
  271.         $css implode', '$shaCss );
  272.         return $css;
  273.     }
  274.     /**
  275.      * get address flag
  276.      *
  277.      * @return string
  278.      */
  279.     public function getAddressFlag()
  280.     {
  281.         return $this->addressFlag;
  282.     }
  283.     /**
  284.      * set address flag
  285.      *
  286.      * @param string $addressFlag
  287.      *
  288.      * @return ShapePoint
  289.      */
  290.     public function setAddressFlag($addressFlag)
  291.     {
  292.         $this->addressFlag $addressFlag;
  293.         return $this;
  294.     }
  295.     /**
  296.      * get parameter
  297.      *
  298.      * @return string
  299.      */
  300.     public function getParameter()
  301.     {
  302.         return $this->parameter;
  303.     }
  304.     /**
  305.      * set parameter
  306.      *
  307.      * @param string $parameter
  308.      *
  309.      * @return ShapePoint
  310.      */
  311.     public function setParameter($parameter)
  312.     {
  313.         $this->parameter $parameter;
  314.         return $this;
  315.     }
  316.     /**
  317.      * get pointname
  318.      *
  319.      * @return string
  320.      */
  321.     public function getPointname()
  322.     {
  323.         return $this->pointname;
  324.     }
  325.     /**
  326.      * set pointname
  327.      *
  328.      * @param string $pointname
  329.      *
  330.      * @return ShapePoint
  331.      */
  332.     public function setPointname($pointname)
  333.     {
  334.         $this->pointname $pointname;
  335.         $this->pointnameLower strtolower($pointname);
  336.         return $this;
  337.     }
  338.     /**
  339.      * get pointnameLower
  340.      *
  341.      * @return string
  342.      */
  343.     public function getPointnameLower()
  344.     {
  345.         return $this->pointnameLower;
  346.     }
  347.     /**
  348.      * set pointnameLower
  349.      *
  350.      * @param string $pointnameLower
  351.      *
  352.      * @return ShapePoint
  353.      */
  354.     public function setPointnameLower($pointnameLower)
  355.     {
  356.         $this->pointnameLower strtolower($pointnameLower);
  357.         return $this;
  358.     }
  359.     /**
  360.      * get isTemplate
  361.      *
  362.      * @return boolean
  363.      */
  364.     public function getIsTemplate()
  365.     {
  366.         return $this->isTemplate;
  367.     }
  368.     /**
  369.      * set isTemplate
  370.      *
  371.      * @param boolean $isTemplate
  372.      *
  373.      * @return ShapePoint
  374.      */
  375.     public function setIsTemplate($isTemplate)
  376.     {
  377.         $this->isTemplate $isTemplate;
  378.         return $this;
  379.     }
  380.     public function getBindingId(){
  381.         return 'NA';
  382.     }
  383.     public function getDatasourceId()
  384.     {
  385.         return 'NA';
  386.     }
  387.     public function isScreenOrShapePoint(){
  388.         return 'shape';
  389.     }
  390.     /**
  391.      * get isDynamicallyAssigned
  392.      *
  393.      * @return boolean isDynamicallyAssigned
  394.      */
  395.     public function getIsDynamicallyAssigned()
  396.     {
  397.         return $this->isDynamicallyAssigned;
  398.     }
  399.     /**
  400.      * set isDynamicallyAssigned
  401.      *
  402.      * @param boolean isDynamicallyAssigned
  403.      *
  404.      * @return ShapePoint
  405.      */
  406.     public function setIsDynamicallyAssigned$isDynamicallyAssigned )
  407.     {
  408.         $this->isDynamicallyAssigned $isDynamicallyAssigned;
  409.         return $this;
  410.     }
  411.     /* ~~~~~~~~~~~~~~~~ OneToOne ~~~~~~~~~~~~~~~~ */
  412.     /* ~~~~~~~~~~~~~~~~ OneToMany ~~~~~~~~~~~~~~~~ */
  413.     /* ~~~~~~~~~~~~~~~~ ManyToOne ~~~~~~~~~~~~~~~~ */
  414.     /**
  415.      * get facility
  416.      *
  417.      * @return Facility
  418.      */
  419.     public function getFacility()
  420.     {
  421.         return $this->facility;
  422.     }
  423.     /**
  424.      * set facility
  425.      *
  426.      * @param \App\Entity\Facility $facility
  427.      *
  428.      * @return ShapePoint
  429.      */
  430.     public function setFacility(\App\Entity\Facility $facility)
  431.     {
  432.         $this->facility $facility;
  433.         return $this;
  434.     }
  435.     /**
  436.      * get networkInstallation
  437.      *
  438.      * @return NetworkInstallation
  439.      */
  440.     public function getNetworkInstallation()
  441.     {
  442.         return $this->networkInstallation;
  443.     }
  444.     /**
  445.      * set networkInstallation
  446.      *
  447.      * @param \App\Entity\NetworkInstallation $networkInstallation
  448.      *
  449.      * @return ShapePoint
  450.      */
  451.     public function setNetworkInstallation(\App\Entity\NetworkInstallation $networkInstallation)
  452.     {
  453.         $this->networkInstallation $networkInstallation;
  454.         return $this;
  455.     }
  456.     /**
  457.      * set point
  458.      *
  459.      * @param \App\Entity\Point $point
  460.      *
  461.      * @return ShapePoint
  462.      */
  463.     public function getPoint()
  464.     {
  465.         return $this->point;
  466.     }
  467.     public function setPoint(\App\Entity\Point $point)
  468.     {
  469.         $this->point $point;
  470.         $point->addShapePoint($this);
  471.         $point->setIsAssigned(true);
  472.         return $this;
  473.     }
  474.     public function removePoint(){
  475.         $point $this->point;
  476.         $point->removeShapePoint($this);
  477.         $point->setIsAssigned(false);
  478.         $this->point null;
  479.     }
  480.     public function getShape()
  481.     {
  482.         return $this->shape;
  483.     }
  484.     /**
  485.      * set shape
  486.      *
  487.      * @param \App\Entity\Shape $shape
  488.      *
  489.      * @return ShapePoint
  490.      */
  491.     public function setShape(\App\Entity\Shape $shape)
  492.     {
  493.         $this->shape $shape;
  494.         $shape->addShapePoint($this);
  495.         return $this;
  496.     }
  497.     /**
  498.      * unset shape
  499.      *
  500.      * @param \App\Entity\Shape $shape
  501.      *
  502.      * @return ShapePoint
  503.      */
  504.     public function unsetShape(\App\Entity\Shape $shape)
  505.     {
  506.         $shape->removeShapePoint($this);
  507.         $this->shape null;
  508.         return $this;
  509.     }
  510.     /* ~~~~~~~~~~~~~~~~ ManyToMany ~~~~~~~~~~~~~~~~ */
  511. }