BatchJob.php (3615B)
1 <?php 2 3 namespace PartKeepr\BatchJobBundle\Entity; 4 5 use Doctrine\Common\Collections\ArrayCollection; 6 use Doctrine\ORM\Mapping as ORM; 7 use PartKeepr\CoreBundle\Entity\BaseEntity; 8 use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; 9 use Symfony\Component\Serializer\Annotation\Groups; 10 11 /** 12 * @ORM\Entity 13 * @TargetService(uri="/api/batch_jobs") 14 */ 15 class BatchJob extends BaseEntity 16 { 17 /** 18 * Holds the batch job name. 19 * 20 * @ORM\Column(length=64,unique=true) 21 * @Groups({"default"}) 22 * 23 * @var string 24 */ 25 private $name; 26 27 /** 28 * Holds the batch job query fields. 29 * 30 * @ORM\OneToMany(targetEntity="PartKeepr\BatchJobBundle\Entity\BatchJobQueryField",mappedBy="batchJob",cascade={"persist", "remove"}, orphanRemoval=true) 31 * @Groups({"default"}) 32 * 33 * @var ArrayCollection 34 */ 35 private $batchJobQueryFields; 36 37 /** 38 * Batch Job Update Fields. 39 * 40 * @ORM\OneToMany(targetEntity="PartKeepr\BatchJobBundle\Entity\BatchJobUpdateField",mappedBy="batchJob",cascade={"persist", "remove"}, orphanRemoval=true) 41 * @Groups({"default"}) 42 * 43 * @var ArrayCollection 44 */ 45 private $batchJobUpdateFields; 46 47 /** 48 * Holds the base entity to query against. 49 * 50 * @ORM\Column() 51 * 52 * @Groups({"default"}) 53 * 54 * @var string 55 */ 56 private $baseEntity; 57 58 public function __construct() 59 { 60 $this->batchJobQueryFields = new ArrayCollection(); 61 $this->batchJobUpdateFields = new ArrayCollection(); 62 } 63 64 /** 65 * @return ArrayCollection 66 */ 67 public function getBatchJobUpdateFields() 68 { 69 return $this->batchJobUpdateFields->getValues(); 70 } 71 72 /** 73 * @return string 74 */ 75 public function getBaseEntity() 76 { 77 return $this->baseEntity; 78 } 79 80 /** 81 * @param string $baseEntity 82 */ 83 public function setBaseEntity($baseEntity) 84 { 85 $this->baseEntity = $baseEntity; 86 } 87 88 /** 89 * @return ArrayCollection 90 */ 91 public function getBatchJobQueryFields() 92 { 93 return $this->batchJobQueryFields->getValues(); 94 } 95 96 /** 97 * @param $batchJobQueryField BatchJobQueryField 98 */ 99 public function addBatchJobQueryField($batchJobQueryField) 100 { 101 if ($batchJobQueryField instanceof BatchJobQueryField) { 102 $batchJobQueryField->setBatchJob($this); 103 } 104 $this->batchJobQueryFields->add($batchJobQueryField); 105 } 106 107 public function removeBatchJobQueryField($batchJobQueryField) 108 { 109 if ($batchJobQueryField instanceof BatchJobQueryField) { 110 $batchJobQueryField->setBatchJob(null); 111 } 112 $this->batchJobQueryFields->removeElement($batchJobQueryField); 113 } 114 115 /** 116 * @param $batchJobUpdateField BatchJobUpdateField 117 */ 118 public function addBatchJobUpdateField($batchJobUpdateField) 119 { 120 if ($batchJobUpdateField instanceof BatchJobUpdateField) { 121 $batchJobUpdateField->setBatchJob($this); 122 } 123 $this->batchJobUpdateFields->add($batchJobUpdateField); 124 } 125 126 public function removeBatchJobUpdateField($batchJobUpdateField) 127 { 128 if ($batchJobUpdateField instanceof BatchJobUpdateField) { 129 $batchJobUpdateField->setBatchJob(null); 130 } 131 $this->batchJobUpdateFields->removeElement($batchJobUpdateField); 132 } 133 134 /** 135 * @return string 136 */ 137 public function getName() 138 { 139 return $this->name; 140 } 141 142 /** 143 * @param string $name 144 */ 145 public function setName($name) 146 { 147 $this->name = $name; 148 } 149 }