<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Entity\File;
use App\Entity\Config;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProjectRepository")
* @UniqueEntity(fields="botname", message="Botname is already taken.")
*/
class Project
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $botname;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Repo", mappedBy="project", orphanRemoval=true, cascade={"persist"})
*/
private $repos;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Environment", mappedBy="project", orphanRemoval=true)
*/
private $environment;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Job", mappedBy="project", orphanRemoval=true, cascade={"persist"})
*/
private $jobs;
/**
* @ORM\Column(type="array", nullable=true)
*/
private $builds = [];
/**
* @ORM\OneToMany(targetEntity="App\Entity\DeployTag", mappedBy="project", orphanRemoval=true, cascade={"persist"})
* @ORM\OrderBy({"name" = "DESC"})
*/
private $deployTags;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Config")
*/
private $tempoTeam;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Config")
* @ORM\JoinColumn(nullable=false)
*/
private $type;
/**
* @ORM\OneToMany(targetEntity="App\Entity\DbImpExp", mappedBy="project", orphanRemoval=true, cascade={"persist"})
* @ORM\OrderBy({"date" = "DESC"})
*/
private $dbImpExps;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $containerRegistryUsername;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $containerRegistryPassword;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Config")
* @ORM\JoinColumn(nullable=false)
*/
private $sla;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SLAChange", mappedBy="project", orphanRemoval=true)
*/
private $slaChanges;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $slasecret;
/**
* @ORM\OneToMany(targetEntity=CHEQContract::class, mappedBy="project", orphanRemoval=true)
*/
private $CHEQContracts;
/**
* @ORM\OneToMany(targetEntity=File::class, mappedBy="Project", orphanRemoval=true, cascade={"persist"})
*/
private $files;
/**
* @ORM\ManyToOne(targetEntity=Config::class)
* @ORM\JoinColumn(nullable=false)
*/
private $devCompany;
/**
* @ORM\OneToOne(targetEntity=AzureMarketplace::class, mappedBy="project", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $azureMarketplace;
/**
* @ORM\OneToOne(targetEntity=ApiUsers::class, mappedBy="project", cascade={"persist", "remove"})
*/
private $apiUsers;
/**
* @var \DateTime $created
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="datetime")
*/
private $created;
/**
* @var \DateTime $updated
*
* @Gedmo\Timestampable(on="update")
* @ORM\Column(type="datetime")
*/
private $updated;
/**
* @ORM\OneToMany(targetEntity=IOSCode::class, mappedBy="project", orphanRemoval=true)
*/
private $iOSCodes;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $mobileappDescription;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $mobileappIntro;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $botIdentityName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $iosLink;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $androidLink;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $viberLink;
/**
* @ORM\OneToMany(targetEntity=Secret::class, mappedBy="project")
*/
private $secrets;
public function __construct()
{
$this->repos = new ArrayCollection();
$this->environment = new ArrayCollection();
$this->jobs = new ArrayCollection();
$this->deployTags = new ArrayCollection();
$this->dbImpExps = new ArrayCollection();
$this->slaChanges = new ArrayCollection();
$this->CHEQContracts = new ArrayCollection();
$this->files = new ArrayCollection();
$this->iOSCodes = new ArrayCollection();
$this->secrets = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getBotname(): ?string
{
return $this->botname;
}
public function setBotname(string $botname): self
{
$this->botname = strtolower($botname);
return $this;
}
/**
* @return Collection|Repo[]
*/
public function getRepos(): Collection
{
return $this->repos;
}
public function addRepo(Repo $repo): self
{
if (!$this->repos->contains($repo)) {
$this->repos[] = $repo;
$repo->setProject($this);
}
return $this;
}
public function removeRepo(Repo $repo): self
{
if ($this->repos->contains($repo)) {
$this->repos->removeElement($repo);
// set the owning side to null (unless already changed)
if ($repo->getProject() === $this) {
$repo->setProject(null);
}
}
return $this;
}
public function __toString() {
return $this->name." (".$this->botname.")";
}
/**
* @return Collection|Environment[]
*/
public function getEnvironment(): Collection
{
return $this->environment;
}
public function addEnvironment(Environment $environment): self
{
if (!$this->environment->contains($environment)) {
$this->environment[] = $environment;
$environment->setProjectId($this);
}
return $this;
}
public function removeEnvironment(Environment $environment): self
{
if ($this->environment->contains($environment)) {
$this->environment->removeElement($environment);
// set the owning side to null (unless already changed)
if ($environment->getProjectId() === $this) {
$environment->setProjectId(null);
}
}
return $this;
}
/**
* @return Collection|Job[]
*/
public function getJobs(): Collection
{
return $this->jobs;
}
public function addJob(Job $job): self
{
if (!$this->jobs->contains($job)) {
$this->jobs[] = $job;
$job->setProject($this);
}
return $this;
}
public function removeJob(Job $job): self
{
if ($this->jobs->contains($job)) {
$this->jobs->removeElement($job);
// set the owning side to null (unless already changed)
if ($job->getProject() === $this) {
$job->setProject(null);
}
}
return $this;
}
public function getBuilds(): ?array
{
if(!empty($this->builds)) {
return array_reverse($this->builds);
} else {
return array("0" => "Buildelj előbb!");
}
}
public function setBuilds(array $builds): self
{
$this->builds = $builds;
return $this;
}
/**
* @return Collection|DeployTag[]
*/
public function getDeployTags(): Collection
{
return $this->deployTags;
}
public function addDeployTag(DeployTag $deployTag): self
{
if (!$this->deployTags->contains($deployTag)) {
$this->deployTags[] = $deployTag;
$deployTag->setProject($this);
}
return $this;
}
public function removeDeployTag(DeployTag $deployTag): self
{
if ($this->deployTags->contains($deployTag)) {
$this->deployTags->removeElement($deployTag);
// set the owning side to null (unless already changed)
if ($deployTag->getProject() === $this) {
$deployTag->setProject(null);
}
}
return $this;
}
public function getTempoTeam(): ?Config
{
return $this->tempoTeam;
}
public function setTempoTeam(?Config $tempoTeam): self
{
$this->tempoTeam = $tempoTeam;
return $this;
}
public function getType(): ?Config
{
return $this->type;
}
public function setType(?Config $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection|DbImpExp[]
*/
public function getDbImpExps(): Collection
{
return $this->dbImpExps;
}
public function addDbImpExp(DbImpExp $dbImpExp): self
{
if (!$this->dbImpExps->contains($dbImpExp)) {
$this->dbImpExps[] = $dbImpExp;
$dbImpExp->setProject($this);
}
return $this;
}
public function removeDbImpExp(DbImpExp $dbImpExp): self
{
if ($this->dbImpExps->contains($dbImpExp)) {
$this->dbImpExps->removeElement($dbImpExp);
// set the owning side to null (unless already changed)
if ($dbImpExp->getProject() === $this) {
$dbImpExp->setProject(null);
}
}
return $this;
}
public function getContainerRegistryUsername(): ?string
{
return $this->containerRegistryUsername;
}
public function setContainerRegistryUsername(?string $containerRegistryUsername): self
{
$this->containerRegistryUsername = $containerRegistryUsername;
return $this;
}
public function getContainerRegistryPassword(): ?string
{
return $this->containerRegistryPassword;
}
public function setContainerRegistryPassword(?string $containerRegistryPassword): self
{
$this->containerRegistryPassword = $containerRegistryPassword;
return $this;
}
public function getSla(): ?Config
{
return $this->sla;
}
public function setSla(?Config $sla): self
{
$this->sla = $sla;
return $this;
}
/**
* @return Collection|SLAChange[]
*/
public function getSlaChanges(): Collection
{
return $this->slaChanges;
}
public function addSlaChange(SLAChange $slaChange): self
{
if (!$this->slaChanges->contains($slaChange)) {
$this->slaChanges[] = $slaChange;
$slaChange->setProject($this);
}
return $this;
}
public function removeSlaChange(SLAChange $slaChange): self
{
if ($this->slaChanges->contains($slaChange)) {
$this->slaChanges->removeElement($slaChange);
// set the owning side to null (unless already changed)
if ($slaChange->getProject() === $this) {
$slaChange->setProject(null);
}
}
return $this;
}
public function getSlasecret(): ?string
{
return $this->slasecret;
}
public function setSlasecret(?string $slasecret): self
{
$this->slasecret = $slasecret;
return $this;
}
/**
* @return Collection|CHEQContract[]
*/
public function getCHEQContracts(): Collection
{
return $this->CHEQContracts;
}
public function addCHEQContract(CHEQContract $cHEQContract): self
{
if (!$this->CHEQContracts->contains($cHEQContract)) {
$this->CHEQContracts[] = $cHEQContract;
$cHEQContract->setProject($this);
}
return $this;
}
public function removeCHEQContract(CHEQContract $cHEQContract): self
{
if ($this->CHEQContracts->removeElement($cHEQContract)) {
// set the owning side to null (unless already changed)
if ($cHEQContract->getProject() === $this) {
$cHEQContract->setProject(null);
}
}
return $this;
}
/**
* @return Collection|File[]
*/
public function getFiles(): Collection
{
return $this->files;
}
/**
* @return File
*/
public function getLogo(): ?File
{
$ret = null;
foreach($this->files AS $file) {
$fileType = $file->getType();
if($fileType->getValue() == "logo") {
if($ret != null) {
if($ret->getUpdated() <= $file->getUpdated()) {
$ret = $file;
}
} else {
$ret = $file;
}
}
}
return $ret;
}
/**
* @return File
*/
public function getMobileAppBackground(): ?File
{
$ret = null;
foreach($this->files AS $file) {
$fileType = $file->getType();
if($fileType->getValue() == "mobileapp.background") {
if($ret != null) {
if($ret->getUpdated() <= $file->getUpdated()) {
$ret = $file;
}
} else {
$ret = $file;
}
}
}
return $ret;
}
/**
* @return File
*/
public function getCompanyLogo(): ?File
{
$ret = null;
foreach($this->files AS $file) {
$fileType = $file->getType();
if($fileType->getValue() == "companylogo") {
if($ret != null) {
if($ret->getUpdated() <= $file->getUpdated()) {
$ret = $file;
}
} else {
$ret = $file;
}
}
}
return $ret;
}
public function addFile(File $file): self
{
if (!$this->files->contains($file)) {
$this->files[] = $file;
$file->setProject($this);
}
return $this;
}
public function removeFile(File $file): self
{
if ($this->files->removeElement($file)) {
// set the owning side to null (unless already changed)
if ($file->getProject() === $this) {
$file->setProject(null);
}
}
return $this;
}
public function getDevCompany(): ?Config
{
return $this->devCompany;
}
public function setDevCompany(?Config $devCompany): self
{
$this->devCompany = $devCompany;
return $this;
}
public function getAzureMarketplace(): ?AzureMarketplace
{
return $this->azureMarketplace;
}
public function setAzureMarketplace(AzureMarketplace $azureMarketplace): self
{
$this->azureMarketplace = $azureMarketplace;
// set the owning side of the relation if necessary
if ($azureMarketplace->getProject() !== $this) {
$azureMarketplace->setProject($this);
}
return $this;
}
public function getApiUsers(): ?ApiUsers
{
return $this->apiUsers;
}
public function setApiUsers(?ApiUsers $apiUsers): self
{
// unset the owning side of the relation if necessary
if ($apiUsers === null && $this->apiUsers !== null) {
$this->apiUsers->setProject(null);
}
// set the owning side of the relation if necessary
if ($apiUsers !== null && $apiUsers->getProject() !== $this) {
$apiUsers->setProject($this);
}
$this->apiUsers = $apiUsers;
return $this;
}
public function getCreated()
{
return $this->created;
}
public function getUpdated()
{
return $this->updated;
}
/**
* @return Collection|IOSCode[]
*/
public function getIOSCodes(): Collection
{
return $this->iOSCodes;
}
public function addIOSCode(IOSCode $iOSCode): self
{
if (!$this->iOSCodes->contains($iOSCode)) {
$this->iOSCodes[] = $iOSCode;
$iOSCode->setProject($this);
}
return $this;
}
public function removeIOSCode(IOSCode $iOSCode): self
{
if ($this->iOSCodes->removeElement($iOSCode)) {
// set the owning side to null (unless already changed)
if ($iOSCode->getProject() === $this) {
$iOSCode->setProject(null);
}
}
return $this;
}
public function getMobileappDescription(): ?string
{
return $this->mobileappDescription;
}
public function setMobileappDescription(?string $mobileappDescription): self
{
$this->mobileappDescription = $mobileappDescription;
return $this;
}
public function getMobileappIntro(): ?string
{
return $this->mobileappIntro;
}
public function setMobileappIntro(?string $mobileappIntro): self
{
$this->mobileappIntro = $mobileappIntro;
return $this;
}
public function getBotIdentityName(): ?string
{
return $this->botIdentityName;
}
public function setBotIdentityName(?string $botIdentityName): self
{
$this->botIdentityName = $botIdentityName;
return $this;
}
public function getIosLink(): ?string
{
return $this->iosLink;
}
public function setIosLink(?string $iosLink): self
{
$this->iosLink = $iosLink;
return $this;
}
public function getAndroidLink(): ?string
{
return $this->androidLink;
}
public function setAndroidLink(?string $androidLink): self
{
$this->androidLink = $androidLink;
return $this;
}
public function getViberLink(): ?string
{
return $this->viberLink;
}
public function setViberLink(?string $viberLink): self
{
$this->viberLink = $viberLink;
return $this;
}
/**
* @return Collection|Secret[]
*/
public function getSecrets(): Collection
{
return $this->secrets;
}
/**
* @return Array|Secret[]
*/
public function getSecretsByEnvTypeAndModule($environmentType, $module): Array
{
$secrets = [];
foreach($this->secrets AS $secret) {
if($secret->getEnvironmentType() == $environmentType && $secret->getModule() == $module) {
$secrets[] = $secret;
}
}
return $secrets;
}
public function addSecret(Secret $secret): self
{
if (!$this->secrets->contains($secret)) {
$this->secrets[] = $secret;
$secret->setProject($this);
}
return $this;
}
public function removeSecret(Secret $secret): self
{
if ($this->secrets->removeElement($secret)) {
// set the owning side to null (unless already changed)
if ($secret->getProject() === $this) {
$secret->setProject(null);
}
}
return $this;
}
}