Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!! TASK: Add workspace content stream mapping to content graph projection #5096

Merged
merged 26 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2db672e
TASK: Add workspace content stream mapping to content graph projection
bwaidelich May 25, 2024
f3f9571
!!! TASK: Replace dedicated Workspace and ContentStream projections
bwaidelich May 25, 2024
fab9d2d
wip
bwaidelich Jun 2, 2024
a3e6414
wip
bwaidelich Jun 3, 2024
17e39a8
TASK: Post rebase phpstan adjustments
mhsdesign Oct 1, 2024
2a781d2
TASK: Reintroduce content graph / cr read model cache
mhsdesign Oct 1, 2024
80a302f
TASK: Fix `I expect the content stream "user-cs-identifier" to not ex…
mhsdesign Oct 1, 2024
d0839e4
TASK: Use `EmbedsContentStreamId` like previously to `updateContentSt…
mhsdesign Oct 2, 2024
468c80d
TASK: Remove obsolete import
mhsdesign Oct 2, 2024
4ea3bbe
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
mhsdesign Oct 9, 2024
db7861f
TASK: Fixup after merge of asset usage refactoring
mhsdesign Oct 10, 2024
c34456b
TASK: Adjust to `find*` vs `get*` convention
mhsdesign Oct 10, 2024
8348a1b
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
mhsdesign Oct 10, 2024
55a8e57
TASK: Adjust to `find*` vs `get*` convention (in `findContentStreams`)
mhsdesign Oct 10, 2024
e59a653
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
mhsdesign Oct 15, 2024
a0dd44c
Replace `WorkspaceFinder` usage in `UsageController`
bwaidelich Oct 15, 2024
25afe96
TASK: Php-stanize UsageController and fix php error
mhsdesign Oct 15, 2024
b41f5b5
Fix parameter name in content graph projection
bwaidelich Oct 15, 2024
2a8b490
Revert "TASK: Reintroduce content graph / cr read model cache"
mhsdesign Oct 15, 2024
041f239
TASK: Migrate findUnusedAndRemovedContentStreams from SQL to PHP
mhsdesign Oct 16, 2024
f604674
TASK: Use `Workspace->isRootWorkspace()`
mhsdesign Oct 16, 2024
acd3833
TASK: Prevent `default` arm to throw as we can handle possibly all ev…
mhsdesign Oct 16, 2024
c91f24f
TASK: Move `getContentGraph` again upwards
mhsdesign Oct 16, 2024
738b68b
Merge remote-tracking branch 'origin/9.0' into task/add-workspace-con…
mhsdesign Oct 16, 2024
4a652d2
BUGFIX: Fix logic of `Workspace::isRootWorkspace`
mhsdesign Oct 16, 2024
a18801b
TASK: Adjust casings of columns
mhsdesign Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public function referenceRelation(): string
return $this->tableNamePrefix . '_referencerelation';
}

public function workspace(): string
{
return $this->tableNamePrefix . '_workspace';
}

public function contentStream(): string
{
return $this->tableNamePrefix . '_contentstream';
}

public function checkpoint(): string
{
return $this->tableNamePrefix . '_checkpoint';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Neos.ContentGraph.DoctrineDbalAdapter package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ContentGraph;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory;
use Neos\ContentRepository\Core\ContentRepositoryReadModelAdapterInterface;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreams;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamStatus;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceStatus;
use Neos\EventStore\Model\Event\Version;

/**
* @internal only used inside the
* @see ContentRepositoryReadModel
*/
final readonly class ContentRepositoryReadModelAdapter implements ContentRepositoryReadModelAdapterInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 fyi (for other reviewers) while these namings are not perfect - they are not the final ones either :)
in #5272 we can discuss the final final final draft:)

{
public function __construct(
private Connection $dbal,
private NodeFactory $nodeFactory,
private ContentRepositoryId $contentRepositoryId,
private NodeTypeManager $nodeTypeManager,
private ContentGraphTableNames $tableNames
) {
}

public function buildContentGraph(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraph
{
return new ContentGraph($this->dbal, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNames, $workspaceName, $contentStreamId);
}

public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace
{
$workspaceByNameStatement = <<<SQL
SELECT
name, baseWorkspaceName, currentContentStreamId, status
FROM
{$this->tableNames->workspace()}
WHERE
name = :workspaceName
LIMIT 1
SQL;
try {
$row = $this->dbal->fetchAssociative($workspaceByNameStatement, [
'workspaceName' => $workspaceName->value,
]);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load workspace from database: %s', $e->getMessage()), 1716486077, $e);
}
if ($row === false) {
return null;
}
return self::workspaceFromDatabaseRow($row);
}

public function findWorkspaces(): Workspaces
{
$workspacesStatement = <<<SQL
SELECT
name, baseWorkspaceName, currentContentStreamId, status
FROM
{$this->tableNames->workspace()}
SQL;
try {
$rows = $this->dbal->fetchAllAssociative($workspacesStatement);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load workspaces from database: %s', $e->getMessage()), 1716902981, $e);
}
return Workspaces::fromArray(array_map(self::workspaceFromDatabaseRow(...), $rows));
}

public function findContentStreamById(ContentStreamId $contentStreamId): ?ContentStream
{
$contentStreamByIdStatement = <<<SQL
SELECT
id, sourceContentStreamId, status, version, removed
FROM
{$this->tableNames->contentStream()}
WHERE
id = :contentStreamId
LIMIT 1
SQL;
try {
$row = $this->dbal->fetchAssociative($contentStreamByIdStatement, [
'contentStreamId' => $contentStreamId->value,
]);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load content stream from database: %s', $e->getMessage()), 1716903166, $e);
}
if ($row === false) {
return null;
}
return self::contentStreamFromDatabaseRow($row);
}

public function findContentStreams(): ContentStreams
{
$contentStreamsStatement = <<<SQL
SELECT
id, sourceContentStreamId, status, version, removed
FROM
{$this->tableNames->contentStream()}
SQL;
try {
$rows = $this->dbal->fetchAllAssociative($contentStreamsStatement);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load content streams from database: %s', $e->getMessage()), 1716903042, $e);
}
return ContentStreams::fromArray(array_map(self::contentStreamFromDatabaseRow(...), $rows));
}

/**
* @param array<string, mixed> $row
*/
private static function workspaceFromDatabaseRow(array $row): Workspace
{
return new Workspace(
WorkspaceName::fromString($row['name']),
isset($row['baseWorkspaceName']) ? WorkspaceName::fromString($row['baseWorkspaceName']) : null,
ContentStreamId::fromString($row['currentContentStreamId']),
WorkspaceStatus::from($row['status']),
);
}

/**
* @param array<string, mixed> $row
*/
private static function contentStreamFromDatabaseRow(array $row): ContentStream
{
return new ContentStream(
ContentStreamId::fromString($row['id']),
isset($row['sourceContentStreamId']) ? ContentStreamId::fromString($row['sourceContentStreamId']) : null,
ContentStreamStatus::from($row['status']),
Version::fromInteger((int)$row['version']),
(bool)$row['removed']
);
}
}
Loading
Loading