mirror of
https://github.com/nextcloud/tables.git
synced 2025-08-16 15:17:20 +00:00
rename row to row2 to avoid overlapping namespaces specially within the update process
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
namespace OCA\Tables\Command;
|
||||
|
||||
use OCA\Tables\Db\LegacyRowMapper;
|
||||
use OCA\Tables\Db\RowMapper;
|
||||
use OCA\Tables\Db\Row2Mapper;
|
||||
use OCA\Tables\Db\Table;
|
||||
use OCA\Tables\Errors\InternalError;
|
||||
use OCA\Tables\Errors\NotFoundError;
|
||||
@ -43,10 +43,10 @@ class TransferLegacyRows extends Command {
|
||||
protected TableService $tableService;
|
||||
protected LoggerInterface $logger;
|
||||
protected LegacyRowMapper $legacyRowMapper;
|
||||
protected RowMapper $rowMapper;
|
||||
protected Row2Mapper $rowMapper;
|
||||
protected ColumnService $columnService;
|
||||
|
||||
public function __construct(TableService $tableService, LoggerInterface $logger, LegacyRowMapper $legacyRowMapper, RowMapper $rowMapper, ColumnService $columnService) {
|
||||
public function __construct(TableService $tableService, LoggerInterface $logger, LegacyRowMapper $legacyRowMapper, Row2Mapper $rowMapper, ColumnService $columnService) {
|
||||
parent::__construct();
|
||||
$this->tableService = $tableService;
|
||||
$this->logger = $logger;
|
||||
|
@ -33,11 +33,11 @@ class LegacyRowMapper extends QBMapper {
|
||||
protected ColumnMapper $columnMapper;
|
||||
protected LoggerInterface $logger;
|
||||
protected UserHelper $userHelper;
|
||||
protected RowMapper $rowMapper;
|
||||
protected Row2Mapper $rowMapper;
|
||||
|
||||
protected int $platform;
|
||||
|
||||
public function __construct(IDBConnection $db, LoggerInterface $logger, TextColumnQB $textColumnQB, SelectionColumnQB $selectionColumnQB, NumberColumnQB $numberColumnQB, DatetimeColumnQB $datetimeColumnQB, SuperColumnQB $columnQB, ColumnMapper $columnMapper, UserHelper $userHelper, RowMapper $rowMapper) {
|
||||
public function __construct(IDBConnection $db, LoggerInterface $logger, TextColumnQB $textColumnQB, SelectionColumnQB $selectionColumnQB, NumberColumnQB $numberColumnQB, DatetimeColumnQB $datetimeColumnQB, SuperColumnQB $columnQB, ColumnMapper $columnMapper, UserHelper $userHelper, Row2Mapper $rowMapper) {
|
||||
parent::__construct($db, $this->table, LegacyRow::class);
|
||||
$this->logger = $logger;
|
||||
$this->textColumnQB = $textColumnQB;
|
||||
@ -435,7 +435,7 @@ class LegacyRowMapper extends QBMapper {
|
||||
* @throws InternalError
|
||||
*/
|
||||
public function transferLegacyRow(LegacyRow $legacyRow, array $columns) {
|
||||
$row = new Row();
|
||||
$row = new Row2();
|
||||
$row->setId($legacyRow->getId());
|
||||
$row->setTableId($legacyRow->getTableId());
|
||||
$row->setCreatedBy($legacyRow->getCreatedBy());
|
||||
|
@ -8,7 +8,7 @@ use OCA\Tables\ResponseDefinitions;
|
||||
/**
|
||||
* @psalm-import-type TablesRow from ResponseDefinitions
|
||||
*/
|
||||
class Row implements JsonSerializable {
|
||||
class Row2 implements JsonSerializable {
|
||||
private ?int $id = null;
|
||||
private ?int $tableId = null;
|
||||
private ?string $createdBy = null;
|
@ -20,7 +20,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
|
||||
class RowMapper {
|
||||
class Row2Mapper {
|
||||
private RowSleeveMapper $rowSleeveMapper;
|
||||
private ?string $userId = null;
|
||||
private IDBConnection $db;
|
||||
@ -42,11 +42,11 @@ class RowMapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Row $row
|
||||
* @return Row
|
||||
* @param Row2 $row
|
||||
* @return Row2
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete(Row $row): Row {
|
||||
public function delete(Row2 $row): Row2 {
|
||||
$this->db->beginTransaction();
|
||||
try {
|
||||
foreach ($this->columnsHelper->get(['name']) as $columnType) {
|
||||
@ -74,11 +74,11 @@ class RowMapper {
|
||||
/**
|
||||
* @param int $id
|
||||
* @param Column[] $columns
|
||||
* @return Row
|
||||
* @return Row2
|
||||
* @throws InternalError
|
||||
* @throws NotFoundError
|
||||
*/
|
||||
public function find(int $id, array $columns): Row {
|
||||
public function find(int $id, array $columns): Row2 {
|
||||
$this->setColumns($columns);
|
||||
$columnIdsArray = array_map(fn (Column $column) => $column->getId(), $columns);
|
||||
$rows = $this->getRows([$id], $columnIdsArray);
|
||||
@ -148,7 +148,7 @@ class RowMapper {
|
||||
* @param array|null $filter
|
||||
* @param array|null $sort
|
||||
* @param string|null $userId
|
||||
* @return Row[]
|
||||
* @return Row2[]
|
||||
* @throws InternalError
|
||||
*/
|
||||
public function findAll(array $columns, int $tableId, int $limit = null, int $offset = null, array $filter = null, array $sort = null, string $userId = null): array {
|
||||
@ -165,7 +165,7 @@ class RowMapper {
|
||||
/**
|
||||
* @param array $rowIds
|
||||
* @param array $columnIds
|
||||
* @return Row[]
|
||||
* @return Row2[]
|
||||
* @throws InternalError
|
||||
*/
|
||||
private function getRows(array $rowIds, array $columnIds): array {
|
||||
@ -335,7 +335,7 @@ class RowMapper {
|
||||
/**
|
||||
* @param IResult $result
|
||||
* @param RowSleeve[] $sleeves
|
||||
* @return Row[]
|
||||
* @return Row2[]
|
||||
* @throws InternalError
|
||||
*/
|
||||
private function parseEntities(IResult $result, array $sleeves): array {
|
||||
@ -343,7 +343,7 @@ class RowMapper {
|
||||
|
||||
$rows = [];
|
||||
foreach ($sleeves as $sleeve) {
|
||||
$rows[$sleeve->getId()] = new Row();
|
||||
$rows[$sleeve->getId()] = new Row2();
|
||||
$rows[$sleeve->getId()]->setId($sleeve->getId());
|
||||
$rows[$sleeve->getId()]->setCreatedBy($sleeve->getCreatedBy());
|
||||
$rows[$sleeve->getId()]->setCreatedAt($sleeve->getCreatedAt());
|
||||
@ -377,13 +377,13 @@ class RowMapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Row $row
|
||||
* @param Row2 $row
|
||||
* @param Column[] $columns
|
||||
* @return Row
|
||||
* @return Row2
|
||||
* @throws InternalError
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insert(Row $row, array $columns): Row {
|
||||
public function insert(Row2 $row, array $columns): Row2 {
|
||||
if(!$columns) {
|
||||
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': columns are missing');
|
||||
}
|
||||
@ -409,7 +409,7 @@ class RowMapper {
|
||||
/**
|
||||
* @throws InternalError
|
||||
*/
|
||||
public function update(Row $row, array $columns): Row {
|
||||
public function update(Row2 $row, array $columns): Row2 {
|
||||
if(!$columns) {
|
||||
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': columns are missing');
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
namespace OCA\Tables\Migration;
|
||||
|
||||
use OCA\Tables\Db\LegacyRowMapper;
|
||||
use OCA\Tables\Db\RowMapper;
|
||||
use OCA\Tables\Db\Row2Mapper;
|
||||
use OCA\Tables\Db\Table;
|
||||
use OCA\Tables\Errors\InternalError;
|
||||
use OCA\Tables\Errors\PermissionError;
|
||||
@ -20,11 +20,11 @@ class NewDbStructureRepairStep implements IRepairStep {
|
||||
protected LoggerInterface $logger;
|
||||
protected TableService $tableService;
|
||||
protected LegacyRowMapper $legacyRowMapper;
|
||||
protected RowMapper $rowMapper;
|
||||
protected Row2Mapper $rowMapper;
|
||||
protected ColumnService $columnService;
|
||||
protected IConfig $config;
|
||||
|
||||
public function __construct(LoggerInterface $logger, TableService $tableService, ColumnService $columnService, LegacyRowMapper $legacyRowMapper, RowMapper $rowMapper, IConfig $config) {
|
||||
public function __construct(LoggerInterface $logger, TableService $tableService, ColumnService $columnService, LegacyRowMapper $legacyRowMapper, Row2Mapper $rowMapper, IConfig $config) {
|
||||
$this->logger = $logger;
|
||||
$this->tableService = $tableService;
|
||||
$this->columnService = $columnService;
|
||||
|
@ -5,8 +5,8 @@ namespace OCA\Tables\Service;
|
||||
use OCA\Tables\Db\Column;
|
||||
use OCA\Tables\Db\ColumnMapper;
|
||||
use OCA\Tables\Db\LegacyRowMapper;
|
||||
use OCA\Tables\Db\Row;
|
||||
use OCA\Tables\Db\RowMapper;
|
||||
use OCA\Tables\Db\Row2;
|
||||
use OCA\Tables\Db\Row2Mapper;
|
||||
use OCA\Tables\Db\Table;
|
||||
use OCA\Tables\Db\TableMapper;
|
||||
use OCA\Tables\Db\View;
|
||||
@ -32,11 +32,11 @@ class RowService extends SuperService {
|
||||
private ColumnMapper $columnMapper;
|
||||
private ViewMapper $viewMapper;
|
||||
private TableMapper $tableMapper;
|
||||
private RowMapper $row2Mapper;
|
||||
private Row2Mapper $row2Mapper;
|
||||
private array $tmpRows = []; // holds already loaded rows as a small cache
|
||||
|
||||
public function __construct(PermissionsService $permissionsService, LoggerInterface $logger, ?string $userId,
|
||||
LegacyRowMapper $mapper, ColumnMapper $columnMapper, ViewMapper $viewMapper, TableMapper $tableMapper, RowMapper $row2Mapper) {
|
||||
LegacyRowMapper $mapper, ColumnMapper $columnMapper, ViewMapper $viewMapper, TableMapper $tableMapper, Row2Mapper $row2Mapper) {
|
||||
parent::__construct($logger, $userId, $permissionsService);
|
||||
$this->mapper = $mapper;
|
||||
$this->columnMapper = $columnMapper;
|
||||
@ -46,11 +46,11 @@ class RowService extends SuperService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Row[] $rows
|
||||
* @param Row2[] $rows
|
||||
* @psalm-return TablesRow[]
|
||||
*/
|
||||
public function formatRows(array $rows): array {
|
||||
return array_map(fn (Row $row) => $row->jsonSerialize(), $rows);
|
||||
return array_map(fn (Row2 $row) => $row->jsonSerialize(), $rows);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +58,7 @@ class RowService extends SuperService {
|
||||
* @param string $userId
|
||||
* @param ?int $limit
|
||||
* @param ?int $offset
|
||||
* @return Row[]
|
||||
* @return Row2[]
|
||||
* @throws InternalError
|
||||
* @throws PermissionError
|
||||
*/
|
||||
@ -82,7 +82,7 @@ class RowService extends SuperService {
|
||||
* @param string $userId
|
||||
* @param int|null $limit
|
||||
* @param int|null $offset
|
||||
* @return Row[]
|
||||
* @return Row2[]
|
||||
* @throws DoesNotExistException
|
||||
* @throws InternalError
|
||||
* @throws MultipleObjectsReturnedException
|
||||
@ -109,12 +109,12 @@ class RowService extends SuperService {
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Row
|
||||
* @return Row2
|
||||
* @throws InternalError
|
||||
* @throws NotFoundError
|
||||
* @throws PermissionError
|
||||
*/
|
||||
public function find(int $id): Row {
|
||||
public function find(int $id): Row2 {
|
||||
try {
|
||||
$columns = $this->columnMapper->findAllByTable($id);
|
||||
} catch (Exception $e) {
|
||||
@ -144,14 +144,14 @@ class RowService extends SuperService {
|
||||
* @param int|null $tableId
|
||||
* @param int|null $viewId
|
||||
* @param list<array{columnId: int, value: mixed}> $data
|
||||
* @return Row
|
||||
* @return Row2
|
||||
*
|
||||
* @throws NotFoundError
|
||||
* @throws PermissionError
|
||||
* @throws Exception
|
||||
* @throws InternalError
|
||||
*/
|
||||
public function create(?int $tableId, ?int $viewId, array $data): Row {
|
||||
public function create(?int $tableId, ?int $viewId, array $data): Row2 {
|
||||
if ($this->userId === null || $this->userId === '') {
|
||||
$e = new \Exception('No user id in context, but needed.');
|
||||
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||
@ -199,7 +199,7 @@ class RowService extends SuperService {
|
||||
$data = $this->cleanupData($data, $columns, $tableId, $viewId);
|
||||
|
||||
// perf
|
||||
$row2 = new Row();
|
||||
$row2 = new Row2();
|
||||
$row2->setTableId($tableId);
|
||||
$row2->setData($data);
|
||||
try {
|
||||
@ -295,7 +295,7 @@ class RowService extends SuperService {
|
||||
* @throws NotFoundError
|
||||
* @throws InternalError
|
||||
*/
|
||||
private function getRowById(int $rowId): Row {
|
||||
private function getRowById(int $rowId): Row2 {
|
||||
if (isset($this->tmpRows[$rowId])) {
|
||||
return $this->tmpRows[$rowId];
|
||||
}
|
||||
@ -326,7 +326,7 @@ class RowService extends SuperService {
|
||||
* @param int|null $viewId
|
||||
* @param list<array{columnId: string|int, value: mixed}> $data
|
||||
* @param string $userId
|
||||
* @return Row
|
||||
* @return Row2
|
||||
*
|
||||
* @throws InternalError
|
||||
* @throws NotFoundError
|
||||
@ -337,7 +337,7 @@ class RowService extends SuperService {
|
||||
?int $viewId,
|
||||
array $data,
|
||||
string $userId
|
||||
): Row {
|
||||
): Row2 {
|
||||
try {
|
||||
$item = $this->getRowById($id);
|
||||
} catch (InternalError $e) {
|
||||
@ -417,14 +417,14 @@ class RowService extends SuperService {
|
||||
* @param int $id
|
||||
* @param int|null $viewId
|
||||
* @param string $userId
|
||||
* @return Row
|
||||
* @return Row2
|
||||
*
|
||||
* @throws InternalError
|
||||
* @throws NotFoundError
|
||||
* @throws PermissionError
|
||||
* @noinspection DuplicatedCode
|
||||
*/
|
||||
public function delete(int $id, ?int $viewId, string $userId): Row {
|
||||
public function delete(int $id, ?int $viewId, string $userId): Row2 {
|
||||
try {
|
||||
$item = $this->getRowById($id);
|
||||
} catch (InternalError $e) {
|
||||
|
Reference in New Issue
Block a user