src/Entity/Node.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints\Json;
  6. /**
  7.  * Node
  8.  */
  9. #[ORM\Table(name'node'options: ['comment' => "Table with node''s definition. Each node in scenario correnspond to one row."])]
  10. #[ORM\Index(name'IDX_857FE845E04E49DF'columns: ['scenario_id'])]
  11. #[ORM\Entity]
  12. class Node
  13. {
  14.     #[ORM\Column(name'id'type'integer'options: ['comment' => 'ID'])]
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue(strategy'SEQUENCE')]
  17.     #[ORM\SequenceGenerator(sequenceName'seq_node_id'allocationSize1initialValue1)]
  18.     private int $id;
  19.     #[ORM\Column(name'title'type'string'length255nullablefalseoptions: ['comment' => 'Title'])]
  20.     private string $title;
  21.     #[ORM\Column(name'description'type'text'nullablefalseoptions: ['comment' => 'Description'])]
  22.     private string $description;
  23.     #[ORM\Column(name'additional_description'type'text'nullabletrueoptions: ['comment' => 'Additonal description'])]
  24.     private ?string $additionalDescription;
  25.     #[ORM\Column(name'question'type'text'nullablefalseoptions: ['default' => '''comment' => 'Question'])]
  26.     private string $question;
  27.     /**
  28.      * @var integer
  29.      */
  30.     #[ORM\Column(name'links_order'type'integer'nullablefalseoptions: ['default' => 0'comment' => 'Order of links (0 - default, 1 - random)'])]
  31.     private $linksOrder '0';
  32.     #[ORM\Column(name'parameters'type'json'nullablefalseoptions: ['comment' => 'Parameters of patient (json)'])]
  33.     private  $parameters;
  34.     /**
  35.      * @var integer
  36.      */
  37.     #[ORM\Column(name'node_order'type'integer'nullablefalseoptions: ['default' => 0'comment' => 'Order in scenario'])]
  38.     private $nodeOrder '0';
  39.     /**
  40.      * @var integer
  41.      */
  42.     #[ORM\Column(name'active'type'boolean'nullablefalseoptions: ['default' => false'comment' => 'Active'])]
  43.     private $active false;
  44.     #[ORM\Column(name'is_deleted'type'boolean'nullablefalseoptions: ['default' => false'comment' => 'Not deleted?'])]
  45.     private bool $isDeleted false;       //comment is only for Adminer, false is still not deleted a otherwise
  46.     #[ORM\Column(name'created_at'type'datetime'nullablefalseoptions: ['comment' => 'Created at''default' => 'now()'])]
  47.     private DateTime $createdAt;
  48.     #[ORM\Column(name'lastmod_at'type'datetime'nullabletrue)]
  49.     private ?DateTime $lastmodAt;
  50.     #[ORM\ManyToOne(targetEntity'App\Entity\Scenario')]
  51.     #[ORM\JoinColumn(name'scenario_id'referencedColumnName'id')]
  52.     private Scenario $scenario;
  53.     #[ORM\Column(name'scenario_id'type'integer'nullablefalseoptions: ['comment' => 'Scenario'])]
  54.     private int $scenarioId;
  55.     #[ORM\ManyToOne(targetEntity'App\Entity\Users')]
  56.     #[ORM\JoinColumn(name'users_id'referencedColumnName'id'nullablefalse)]
  57.     private Users $users;
  58.     #[ORM\Column(name'users_id'type'integer'nullablefalseoptions: ['comment' => 'Creating/editing user'])]
  59.     protected int $usersId;
  60.     /**
  61.      * Set title
  62.      *
  63.      * @param string $title
  64.      *
  65.      * @return Node
  66.      */
  67.     public function setTitle(string $title): Node
  68.     {
  69.         $this->title $title;
  70.         return $this;
  71.     }
  72.     /**
  73.      * Get title
  74.      *
  75.      * @return string
  76.      */
  77.     public function getTitle(): string
  78.     {
  79.         return $this->title;
  80.     }
  81.     /**
  82.      * Set additional description
  83.      *
  84.      * @param string $additionalDescription
  85.      * @return Node
  86.      */
  87.     public function setAdditionalDescription(string $additionalDescription): Node
  88.     {
  89.         $this->additionalDescription $additionalDescription;
  90.         return $this;
  91.     }
  92.     /**
  93.      * Get additional description
  94.      *
  95.      * @return string|null
  96.      */
  97.     public function getAdditionalDescription(): ?string
  98.     {
  99.         return $this->additionalDescription;
  100.     }
  101.     /**
  102.      * Set description
  103.      *
  104.      * @param string $description
  105.      *
  106.      * @return Node
  107.      */
  108.     public function setDescription(string $description): Node
  109.     {
  110.         $this->description $description;
  111.         return $this;
  112.     }
  113.     /**
  114.      * Get description
  115.      *
  116.      * @return string
  117.      */
  118.     public function getDescription(): string
  119.     {
  120.         return $this->description;
  121.     }
  122.     /**
  123.      * Set linksOrder
  124.      *
  125.      * @param integer $linksOrder
  126.      *
  127.      * @return Node
  128.      */
  129.     public function setLinksOrder(int $linksOrder): Node
  130.     {
  131.         $this->linksOrder $linksOrder;
  132.         return $this;
  133.     }
  134.     /**
  135.      * Get linksOrder
  136.      *
  137.      * @return integer
  138.      */
  139.     public function getLinksOrder()
  140.     {
  141.         return $this->linksOrder;
  142.     }
  143.     /**
  144.      * Set parameters
  145.      *
  146.      * @param array $parameters
  147.      *
  148.      * @return Node
  149.      */
  150.     public function setParameters($parameters)
  151.     {
  152.         $this->parameters $parameters;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get parameters
  157.      *
  158.      * @return array
  159.      */
  160.     public function getParameters()
  161.     {
  162.         return $this->parameters;
  163.     }
  164.     /**
  165.      * Set nodeOrder
  166.      *
  167.      * @param integer $nodeOrder
  168.      *
  169.      * @return Node
  170.      */
  171.     public function setNodeOrder(int $nodeOrder): Node
  172.     {
  173.         $this->nodeOrder $nodeOrder;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Get nodeOrder
  178.      *
  179.      * @return integer
  180.      */
  181.     public function getNodeOrder()
  182.     {
  183.         return $this->nodeOrder;
  184.     }
  185.     /**
  186.      * Set active
  187.      *
  188.      * @param boolean $active
  189.      *
  190.      * @return Node
  191.      */
  192.     public function setActive(bool $active): Node
  193.     {
  194.         $this->active $active;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get active
  199.      *
  200.      * @return boolean
  201.      */
  202.     public function getActive()
  203.     {
  204.         return $this->active;
  205.     }
  206.     /**
  207.      * Set isDeleted
  208.      *
  209.      * @param boolean $isDeleted
  210.      *
  211.      * @return Node
  212.      */
  213.     public function setIsDeleted(bool $isDeleted): Node
  214.     {
  215.         $this->isDeleted $isDeleted;
  216.         return $this;
  217.     }
  218.     /**
  219.      * Get isDeleted
  220.      *
  221.      * @return boolean
  222.      */
  223.     public function getIsDeleted(): bool
  224.     {
  225.         return $this->isDeleted;
  226.     }
  227.     /**
  228.      * Set createdAt
  229.      *
  230.      * @param DateTime $createdAt
  231.      *
  232.      * @return Node
  233.      */
  234.     public function setCreatedAt(DateTime $createdAt): Node
  235.     {
  236.         $this->createdAt $createdAt;
  237.         return $this;
  238.     }
  239.     /**
  240.      * Get createdAt
  241.      *
  242.      * @return DateTime
  243.      */
  244.     public function getCreatedAt(): DateTime
  245.     {
  246.         return $this->createdAt;
  247.     }
  248.     /**
  249.      * Set lastmodAt
  250.      *
  251.      * @param DateTime|null $lastmodAt
  252.      * @return Node
  253.      */
  254.     public function setLastmodAt(DateTime $lastmodAt null): Node
  255.     {
  256.         $this->lastmodAt $lastmodAt;
  257.         return $this;
  258.     }
  259.     /**
  260.      * Get lastmodAt
  261.      *
  262.      * @return DateTime|null
  263.      */
  264.     public function getLastmodAt(): ?DateTime
  265.     {
  266.         return $this->lastmodAt;
  267.     }
  268.     /**
  269.      * Get id
  270.      *
  271.      * @return integer
  272.      */
  273.     public function getId(): int
  274.     {
  275.         return $this->id;
  276.     }
  277.     /**
  278.      * Set scenario
  279.      *
  280.      * @param Scenario|null $scenario
  281.      *
  282.      * @return Node
  283.      */
  284.     public function setScenario(Scenario $scenario null): Node
  285.     {
  286.         $this->scenario $scenario;
  287.         return $this;
  288.     }
  289.     /**
  290.      * Get scenario
  291.      *
  292.      * @return Scenario
  293.      */
  294.     public function getScenario(): Scenario
  295.     {
  296.         return $this->scenario;
  297.     }
  298.     /**
  299.      * Set scenarioId
  300.      *
  301.      * @param integer $scenarioId
  302.      *
  303.      * @return Node
  304.      */
  305.     public function setScenarioId(int $scenarioId): Node
  306.     {
  307.         $this->scenarioId $scenarioId;
  308.         return $this;
  309.     }
  310.     /**
  311.      * Get scenarioId
  312.      *
  313.      * @return integer
  314.      */
  315.     public function getScenarioId(): int
  316.     {
  317.         return $this->scenarioId;
  318.     }
  319.     /**
  320.      * @return string
  321.      */
  322.     public function getQuestion(): string
  323.     {
  324.         return $this->question;
  325.     }
  326.     /**
  327.      * @param string $question
  328.      */
  329.     public function setQuestion(string $question)
  330.     {
  331.         $this->question $question;
  332.     }
  333.     /**
  334.      * Set users
  335.      *
  336.      * @param Users|null $users
  337.      *
  338.      * @return Node
  339.      */
  340.     public function setUsers(Users $users null): Node
  341.     {
  342.         $this->users $users;
  343.         $this->usersId $users->getId();
  344.         return $this;
  345.     }
  346.     /**
  347.      * Get users
  348.      *
  349.      * @return Users
  350.      */
  351.     public function getUsers(): Users
  352.     {
  353.         return $this->users;
  354.     }
  355.     /**
  356.      * Set usersId
  357.      *
  358.      * @param integer $usersId
  359.      *
  360.      * @return Node
  361.      */
  362.     public function setUsersId(int $usersId): Node
  363.     {
  364.         $this->usersId $usersId;
  365.         return $this;
  366.     }
  367.     /**
  368.      * Get usersId
  369.      *
  370.      * @return integer
  371.      */
  372.     public function getUsersId(): int
  373.     {
  374.         return $this->usersId;
  375.     }
  376.     /**
  377.      * @return string
  378.      */
  379.     public function encodeNodeId(): string
  380.     {
  381.         return base64_encode($this->getId());
  382.     }
  383.     /**
  384.      * @param $id
  385.      * @return false|string
  386.      */
  387.     public static function staticDecode($id){
  388.         return base64_decode($id);
  389.     }
  390. }