Skip to content

Commit

Permalink
Merge pull request #2787 from irontec/PROVIDER-2053-adds-schema-relat…
Browse files Browse the repository at this point in the history
…ions-between-entities

Adds schema relations between AplicationServerSet-Brand and MediaRelaySet-Brand
  • Loading branch information
danigargar authored Oct 23, 2024
2 parents 09309dc + 5ec744e commit af12efc
Show file tree
Hide file tree
Showing 89 changed files with 2,747 additions and 239 deletions.
2 changes: 2 additions & 0 deletions library/DataFixtures/ORM/ProviderCarrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function load(ObjectManager $manager)
$this->setBrand($fixture->getReference('_reference_ProviderBrand1'));
$this->setTransformationRuleSet($fixture->getReference('_reference_ProviderTransformationRuleSet70'));
$this->setProxyTrunk($fixture->getReference('_reference_ProviderProxyTrunk1'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));

$this->sanitizeValues();
$this->setCalculateCost(true);
Expand All @@ -45,6 +46,7 @@ public function load(ObjectManager $manager)
$this->setBrand($fixture->getReference('_reference_ProviderBrand1'));
$this->setTransformationRuleSet($fixture->getReference('_reference_ProviderTransformationRuleSet70'));
$this->setProxyTrunk($fixture->getReference('_reference_ProviderProxyTrunk2'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));
})->call($item2);

$this->addReference('_reference_ProviderCarrier2', $item2);
Expand Down
28 changes: 21 additions & 7 deletions library/DataFixtures/ORM/ProviderCompany.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function load(ObjectManager $manager)
);
$this->invoicing = $invoicing;
$this->setLanguage($fixture->getReference('_reference_ProviderLanguage1'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet0'));
$this->setDefaultTimezone($fixture->getReference('_reference_ProviderTimezone145'));
$this->setBrand($fixture->getReference('_reference_ProviderBrand1'));
$this->setDomain($fixture->getReference('_reference_ProviderDomain3'));
Expand All @@ -64,6 +64,8 @@ public function load(ObjectManager $manager)
$this->setVoicemailNotificationTemplate($fixture->getReference('_reference_ProviderNotificationTemplate1'));
$this->setAccessCredentialNotificationTemplate($fixture->getReference('_reference_ProviderNotificationTemplate5'));
$this->setCorporation($fixture->getReference('_reference_Corporation1'));
$this->setApplicationServerSet($fixture->getReference('_reference_ProviderApplicationServerSet1'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));
})->call($item1);

$this->addReference('_reference_ProviderCompany1', $item1);
Expand Down Expand Up @@ -92,14 +94,16 @@ public function load(ObjectManager $manager)
$this->setOnDemandRecordCode("");
$this->invoicing = $invoicing;
$this->setLanguage($fixture->getReference('_reference_ProviderLanguage1'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet0'));
$this->setDefaultTimezone($fixture->getReference('_reference_ProviderTimezone145'));
$this->setBrand($fixture->getReference('_reference_ProviderBrand1'));
$this->setDomain($fixture->getReference('_reference_ProviderDomain5'));
$this->setCountry($fixture->getReference('_reference_ProviderCountry70'));
$this->setTransformationRuleSet($fixture->getReference('_reference_ProviderTransformationRuleSet70'));
$this->setVoicemailNotificationTemplate($fixture->getReference('_reference_ProviderNotificationTemplate1'));
$this->setCorporation($fixture->getReference('_reference_Corporation1'));
$this->setApplicationServerSet($fixture->getReference('_reference_ProviderApplicationServerSet1'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));
})->call($item2);

$this->addReference('_reference_ProviderCompany2', $item2);
Expand All @@ -123,12 +127,14 @@ public function load(ObjectManager $manager)
$this->setShowInvoices(true);
$this->invoicing = $invoicing;
$this->setLanguage($fixture->getReference('_reference_ProviderLanguage1'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet0'));
$this->setDefaultTimezone($fixture->getReference('_reference_ProviderTimezone145'));
$this->setBrand($fixture->getReference('_reference_ProviderBrand1'));
$this->setCountry($fixture->getReference('_reference_ProviderCountry70'));
$this->setTransformationRuleSet($fixture->getReference('_reference_ProviderTransformationRuleSet70'));
$this->setVoicemailNotificationTemplate($fixture->getReference('_reference_ProviderNotificationTemplate1'));
$this->setApplicationServerSet($fixture->getReference('_reference_ProviderApplicationServerSet1'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));
})->call($item3);

$this->addReference('_reference_ProviderCompany3', $item3);
Expand All @@ -153,12 +159,14 @@ public function load(ObjectManager $manager)
$this->invoicing = $invoicing;
$this->setApplicationServer($fixture->getReference('_reference_ProviderApplicationServer1'));
$this->setLanguage($fixture->getReference('_reference_ProviderLanguage1'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet0'));
$this->setDefaultTimezone($fixture->getReference('_reference_ProviderTimezone145'));
$this->setBrand($fixture->getReference('_reference_ProviderBrand1'));
$this->setCountry($fixture->getReference('_reference_ProviderCountry70'));
$this->setTransformationRuleSet($fixture->getReference('_reference_ProviderTransformationRuleSet70'));
$this->setVoicemailNotificationTemplate($fixture->getReference('_reference_ProviderNotificationTemplate1'));
$this->setApplicationServerSet($fixture->getReference('_reference_ProviderApplicationServerSet1'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));
})->call($item4);

$this->addReference('_reference_ProviderCompany4', $item4);
Expand All @@ -181,12 +189,14 @@ public function load(ObjectManager $manager)
$this->setOnDemandRecordCode("");
$this->invoicing = $invoicing;
$this->setLanguage($fixture->getReference('_reference_ProviderLanguage1'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet0'));
$this->setDefaultTimezone($fixture->getReference('_reference_ProviderTimezone145'));
$this->setBrand($fixture->getReference('_reference_ProviderBrand1'));
$this->setCountry($fixture->getReference('_reference_ProviderCountry70'));
$this->setTransformationRuleSet($fixture->getReference('_reference_ProviderTransformationRuleSet70'));
$this->setVoicemailNotificationTemplate($fixture->getReference('_reference_ProviderNotificationTemplate1'));
$this->setApplicationServerSet($fixture->getReference('_reference_ProviderApplicationServerSet1'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));
})->call($item5);

$this->addReference('_reference_ProviderCompany5', $item5);
Expand All @@ -211,12 +221,14 @@ public function load(ObjectManager $manager)
$this->setOnDemandRecordCode("");
$this->invoicing = $invoicing;
$this->setLanguage($fixture->getReference('_reference_ProviderLanguage1'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet'));
$this->setMediaRelaySets($fixture->getReference('_reference_ProviderMediaRelaySet0'));
$this->setDefaultTimezone($fixture->getReference('_reference_ProviderTimezone18'));
$this->setBrand($fixture->getReference('_reference_ProviderBrand2'));
$this->setCountry($fixture->getReference('_reference_ProviderCountry10'));
$this->setTransformationRuleSet($fixture->getReference('_reference_ProviderTransformationRuleSet70'));
$this->setVoicemailNotificationTemplate($fixture->getReference('_reference_ProviderNotificationTemplate4'));
$this->setApplicationServerSet($fixture->getReference('_reference_ProviderApplicationServerSet0'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));
})->call($item6);

$this->addReference('_reference_ProviderCompany6', $item6);
Expand All @@ -237,7 +249,9 @@ public function getDependencies()
ProviderCountry::class,
ProviderTransformationRuleSet::class,
ProviderNotificationTemplate::class,
ProviderCorporation::class
ProviderCorporation::class,
ProviderApplicationServerSet::class,
ProviderMediaRelaySet::class
);
}
}
2 changes: 2 additions & 0 deletions library/DataFixtures/ORM/ProviderDdiProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function load(ObjectManager $manager)
$this->setBrand($fixture->getReference('_reference_ProviderBrand1'));
$this->setTransformationRuleSet($fixture->getReference('_reference_ProviderTransformationRuleSet70'));
$this->setProxyTrunk($fixture->getReference('_reference_ProviderProxyTrunk1'));
$this->setMediaRelaySet($fixture->getReference('_reference_ProviderMediaRelaySet0'));
})->call($item1);

$this->addReference('_reference_ProviderDdiProvider1', $item1);
Expand All @@ -43,6 +44,7 @@ public function getDependencies()
ProviderBrand::class,
ProviderTransformationRuleSet::class,
ProviderProxyTrunk::class,
ProviderMediaRelaySet::class,
);
}
}
11 changes: 10 additions & 1 deletion library/DataFixtures/ORM/ProviderMediaRelaySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function load(ObjectManager $manager)
);

$item0 = $manager->find(MediaRelaySet::class, 0);
$this->addReference('_reference_ProviderMediaRelaySet', $item0);
$this->addReference('_reference_ProviderMediaRelaySet0', $item0);

$item1 = $this->createEntityInstance(MediaRelaySet::class);
(function () use ($fixture) {
Expand All @@ -37,6 +37,15 @@ public function load(ObjectManager $manager)
$this->sanitizeEntityValues($item1);
$manager->persist($item1);

$item2 = $this->createEntityInstance(MediaRelaySet::class);
(function () use ($fixture) {
$this->setName("Test 2");
$this->setDescription("Not related with Brand 1");
})->call($item2);

$this->addReference('_reference_ProviderMediaRelaySet2', $item2);
$this->sanitizeEntityValues($item2);
$manager->persist($item2);

$manager->flush();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Ivoz\Provider\Domain\Model\ApplicationServerSet;

use Ivoz\Core\Domain\Assert\Assertion;
use Ivoz\Provider\Domain\Model\ApplicationServer\ApplicationServerInterface;
use Ivoz\Provider\Domain\Model\ApplicationServerSetRelApplicationServer\ApplicationServerSetRelApplicationServerInterface;

/**
* ApplicationServerSet
Expand All @@ -13,6 +11,8 @@ class ApplicationServerSet extends ApplicationServerSetAbstract implements Appli
{
use ApplicationServerSetTrait;

public const DEFAULT_APPLICATION_SERVER_SET = 0;

/**
* @codeCoverageIgnore
* @return array<string, mixed>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Ivoz\Provider\Domain\Model\ApplicationServerSetsRelBrand;

use Ivoz\Core\Domain\Service\Repository\RepositoryInterface;
use Ivoz\Provider\Domain\Model\Administrator\AdministratorInterface;

/**
* @extends RepositoryInterface<ApplicationServerSetsRelBrandInterface, ApplicationServerSetsRelBrandDto>
Expand All @@ -13,4 +14,9 @@ interface ApplicationServerSetsRelBrandRepository extends RepositoryInterface
* @return ApplicationServerSetsRelBrandInterface[]
*/
public function findByBrandId(int $brandId): array;

/**
* @return int[]
*/
public function getApplicationServerSetIdsByBrandAdmin(AdministratorInterface $admin): array;
}
33 changes: 29 additions & 4 deletions library/Ivoz/Provider/Domain/Model/Carrier/CarrierAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ abstract class CarrierAbstract
*/
protected $mediaRelaySets = null;

/**
* @var MediaRelaySetInterface
*/
protected $mediaRelaySet;

/**
* Constructor
*/
Expand Down Expand Up @@ -151,6 +156,8 @@ public static function fromDto(
Assertion::notNull($name, 'getName value is null, but non null value was expected.');
$brand = $dto->getBrand();
Assertion::notNull($brand, 'getBrand value is null, but non null value was expected.');
$mediaRelaySet = $dto->getMediaRelaySet();
Assertion::notNull($mediaRelaySet, 'getMediaRelaySet value is null, but non null value was expected.');

$self = new static(
$description,
Expand All @@ -164,7 +171,8 @@ public static function fromDto(
->setTransformationRuleSet($fkTransformer->transform($dto->getTransformationRuleSet()))
->setCurrency($fkTransformer->transform($dto->getCurrency()))
->setProxyTrunk($fkTransformer->transform($dto->getProxyTrunk()))
->setMediaRelaySets($fkTransformer->transform($dto->getMediaRelaySets()));
->setMediaRelaySets($fkTransformer->transform($dto->getMediaRelaySets()))
->setMediaRelaySet($fkTransformer->transform($mediaRelaySet));

$self->initChangelog();

Expand All @@ -187,6 +195,8 @@ public function updateFromDto(
Assertion::notNull($name, 'getName value is null, but non null value was expected.');
$brand = $dto->getBrand();
Assertion::notNull($brand, 'getBrand value is null, but non null value was expected.');
$mediaRelaySet = $dto->getMediaRelaySet();
Assertion::notNull($mediaRelaySet, 'getMediaRelaySet value is null, but non null value was expected.');

$this
->setDescription($description)
Expand All @@ -197,7 +207,8 @@ public function updateFromDto(
->setTransformationRuleSet($fkTransformer->transform($dto->getTransformationRuleSet()))
->setCurrency($fkTransformer->transform($dto->getCurrency()))
->setProxyTrunk($fkTransformer->transform($dto->getProxyTrunk()))
->setMediaRelaySets($fkTransformer->transform($dto->getMediaRelaySets()));
->setMediaRelaySets($fkTransformer->transform($dto->getMediaRelaySets()))
->setMediaRelaySet($fkTransformer->transform($mediaRelaySet));

return $this;
}
Expand All @@ -216,7 +227,8 @@ public function toDto(int $depth = 0): CarrierDto
->setTransformationRuleSet(TransformationRuleSet::entityToDto(self::getTransformationRuleSet(), $depth))
->setCurrency(Currency::entityToDto(self::getCurrency(), $depth))
->setProxyTrunk(ProxyTrunk::entityToDto(self::getProxyTrunk(), $depth))
->setMediaRelaySets(MediaRelaySet::entityToDto(self::getMediaRelaySets(), $depth));
->setMediaRelaySets(MediaRelaySet::entityToDto(self::getMediaRelaySets(), $depth))
->setMediaRelaySet(MediaRelaySet::entityToDto(self::getMediaRelaySet(), $depth));
}

/**
Expand All @@ -233,7 +245,8 @@ protected function __toArray(): array
'transformationRuleSetId' => self::getTransformationRuleSet()?->getId(),
'currencyId' => self::getCurrency()?->getId(),
'proxyTrunkId' => self::getProxyTrunk()?->getId(),
'mediaRelaySetsId' => self::getMediaRelaySets()?->getId()
'mediaRelaySetsId' => self::getMediaRelaySets()?->getId(),
'mediaRelaySetId' => self::getMediaRelaySet()->getId()
];
}

Expand Down Expand Up @@ -352,4 +365,16 @@ public function getMediaRelaySets(): ?MediaRelaySetInterface
{
return $this->mediaRelaySets;
}

protected function setMediaRelaySet(MediaRelaySetInterface $mediaRelaySet): static
{
$this->mediaRelaySet = $mediaRelaySet;

return $this;
}

public function getMediaRelaySet(): MediaRelaySetInterface
{
return $this->mediaRelaySet;
}
}
1 change: 1 addition & 0 deletions library/Ivoz/Provider/Domain/Model/Carrier/CarrierDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Ivoz\Provider\Domain\Model\Carrier;

use Ivoz\Api\Core\Annotation\AttributeDefinition;
use Ivoz\Provider\Domain\Model\MediaRelaySet\MediaRelaySet;

class CarrierDto extends CarrierDtoAbstract
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ abstract class CarrierDtoAbstract implements DataTransferObjectInterface
*/
private $mediaRelaySets = null;

/**
* @var MediaRelaySetDto | null
*/
private $mediaRelaySet = null;

/**
* @var OutgoingRoutingDto[] | null
*/
Expand Down Expand Up @@ -122,7 +127,8 @@ public static function getPropertyMap(string $context = '', string $role = null)
'transformationRuleSetId' => 'transformationRuleSet',
'currencyId' => 'currency',
'proxyTrunkId' => 'proxyTrunk',
'mediaRelaySetsId' => 'mediaRelaySets'
'mediaRelaySetsId' => 'mediaRelaySets',
'mediaRelaySetId' => 'mediaRelaySet'
];
}

Expand All @@ -142,6 +148,7 @@ public function toArray(bool $hideSensitiveData = false): array
'currency' => $this->getCurrency(),
'proxyTrunk' => $this->getProxyTrunk(),
'mediaRelaySets' => $this->getMediaRelaySets(),
'mediaRelaySet' => $this->getMediaRelaySet(),
'outgoingRoutings' => $this->getOutgoingRoutings(),
'outgoingRoutingsRelCarriers' => $this->getOutgoingRoutingsRelCarriers(),
'servers' => $this->getServers(),
Expand Down Expand Up @@ -376,6 +383,36 @@ public function getMediaRelaySetsId(): ?int
return null;
}

public function setMediaRelaySet(?MediaRelaySetDto $mediaRelaySet): static
{
$this->mediaRelaySet = $mediaRelaySet;

return $this;
}

public function getMediaRelaySet(): ?MediaRelaySetDto
{
return $this->mediaRelaySet;
}

public function setMediaRelaySetId(?int $id): static
{
$value = !is_null($id)
? new MediaRelaySetDto($id)
: null;

return $this->setMediaRelaySet($value);
}

public function getMediaRelaySetId(): ?int
{
if ($dto = $this->getMediaRelaySet()) {
return $dto->getId();
}

return null;
}

/**
* @param OutgoingRoutingDto[] | null $outgoingRoutings
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public function getProxyTrunk(): ?ProxyTrunkInterface;

public function getMediaRelaySets(): ?MediaRelaySetInterface;

public function getMediaRelaySet(): MediaRelaySetInterface;

public function addOutgoingRouting(OutgoingRoutingInterface $outgoingRouting): CarrierInterface;

public function removeOutgoingRouting(OutgoingRoutingInterface $outgoingRouting): CarrierInterface;
Expand Down
Loading

0 comments on commit af12efc

Please sign in to comment.