Skip to content

Commit

Permalink
OXDEV-805 Prepaid data collectors for all tables in application layer
Browse files Browse the repository at this point in the history
  • Loading branch information
RahatHameed committed Sep 19, 2024
1 parent 2abbb50 commit f9bd87f
Show file tree
Hide file tree
Showing 51 changed files with 1,466 additions and 23 deletions.
54 changes: 54 additions & 0 deletions src/UserData/Application/AbstractAggregateTableDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

use OxidEsales\GdprOptinModule\UserData\Infrastructure\UserDataRepositoryInterface;

abstract class AbstractAggregateTableDataCollector implements TableDataCollectorInterface
{
public function __construct(
protected readonly UserDataRepositoryInterface $repository,
protected array $collectors
) {
}

abstract public function getTableName(): string;

abstract protected function getColumnName(): string;

public function collect(string $id): array
{
$orderData = $this->repository->getDataFromTable(
table: $this->getTableName(),
columnName: $this->getColumnName(),
columnValue: $id
);

$relatedData = [];
if ($orderData) {
foreach ($this->collectors as $collector) {
if ($collector instanceof RelatedTableDataCollectorInterface) {
$relatedData[$collector->getTableName()] =
$collector->collectRelatedData(
primaryTable: $this->getTableName(),
primaryKey: $this->getColumnName(),
primaryConditionColumn: $this->getColumnName(),
primaryConditionValue: $id
);
}
}
}

return [
$this->getTableName() => $orderData,
'related_data' => $relatedData,
];
}
}
40 changes: 40 additions & 0 deletions src/UserData/Application/AbstractRelatedTableDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

use OxidEsales\GdprOptinModule\UserData\Infrastructure\UserDataRepositoryInterface;

abstract class AbstractRelatedTableDataCollector implements RelatedTableDataCollectorInterface
{
public function __construct(
protected readonly UserDataRepositoryInterface $repository
) {
}

abstract public function getTableName(): string;

abstract protected function getColumnName(): string;

public function collectRelatedData(
string $primaryTable,
string $primaryKey,
string $primaryConditionColumn,
string $primaryConditionValue
): array {
return $this->repository->getJoinedData(
$primaryTable,
$primaryKey,
$this->getTableName(),
$this->getColumnName(),
$primaryConditionColumn,
$primaryConditionValue
);
}
}
29 changes: 29 additions & 0 deletions src/UserData/Application/AbstractTableDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

use OxidEsales\GdprOptinModule\UserData\Infrastructure\UserDataRepositoryInterface;

abstract class AbstractTableDataCollector implements TableDataCollectorInterface
{
public function __construct(
protected readonly UserDataRepositoryInterface $repository
) {
}

abstract public function getTableName(): string;

abstract protected function getColumnName(): string;

public function collect(string $id): array
{
return $this->repository->getDataFromTable($this->getTableName(), $this->getColumnName(), $id);
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/AddressDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class AddressDataCollector extends AbstractTableDataCollector
{
public function getTableName(): string
{
return 'oxaddress';
}

protected function getColumnName(): string
{
return 'OXUSERID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/BasketDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class BasketDataCollector extends AbstractAggregateTableDataCollector
{
public function getTableName(): string
{
return 'oxuserbaskets';
}

protected function getColumnName(): string
{
return 'OXUSERID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/BasketItemsDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class BasketItemsDataCollector extends AbstractRelatedTableDataCollector
{
public function getTableName(): string
{
return 'oxuserbasketitems';
}

protected function getColumnName(): string
{
return 'OXBASKETID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/NewsSubscribedDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class NewsSubscribedDataCollector extends AbstractTableDataCollector
{
public function getTableName(): string
{
return 'oxnewssubscribed';
}

protected function getColumnName(): string
{
return 'OXUSERID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/OrderArticlesDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class OrderArticlesDataCollector extends AbstractRelatedTableDataCollector
{
public function getTableName(): string
{
return 'oxorderarticles';
}

protected function getColumnName(): string
{
return 'OXORDERID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/OrderDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class OrderDataCollector extends AbstractAggregateTableDataCollector
{
public function getTableName(): string
{
return 'oxorder';
}

protected function getColumnName(): string
{
return 'OXUSERID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/OrderFilesDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class OrderFilesDataCollector extends AbstractRelatedTableDataCollector
{
public function getTableName(): string
{
return 'oxorderfiles';
}

protected function getColumnName(): string
{
return 'OXORDERID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/PriceAlarmDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class PriceAlarmDataCollector extends AbstractTableDataCollector
{
public function getTableName(): string
{
return 'oxpricealarm';
}

protected function getColumnName(): string
{
return 'OXUSERID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/RatingDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class RatingDataCollector extends AbstractTableDataCollector
{
public function getTableName(): string
{
return 'oxratings';
}

protected function getColumnName(): string
{
return 'OXUSERID';
}
}
23 changes: 23 additions & 0 deletions src/UserData/Application/RecommListDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

class RecommListDataCollector extends AbstractTableDataCollector
{
public function getTableName(): string
{
return 'oxrecommlists';
}

protected function getColumnName(): string
{
return 'OXUSERID';
}
}
22 changes: 22 additions & 0 deletions src/UserData/Application/RelatedTableDataCollectorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GdprOptinModule\UserData\Application;

interface RelatedTableDataCollectorInterface
{
public function collectRelatedData(
string $primaryTable,
string $primaryKey,
string $primaryConditionColumn,
string $primaryConditionValue
): array;

public function getTableName(): string;
}
Loading

0 comments on commit f9bd87f

Please sign in to comment.