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

!!! FEATURE: Bind ContentGraph to workspace #5028

Merged
merged 32 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7d691d8
TASK: ContentGraph bound to Workspace
kitsunet May 6, 2024
138abbd
Apply suggestions from code review
kitsunet May 6, 2024
baec4b8
Add comments to new ContentGraph methods
kitsunet May 6, 2024
4a4b7c1
Code cleanup and documentation
kitsunet May 6, 2024
2345e3d
Fix linter issue
kitsunet May 6, 2024
24cfa06
Tweak ContentGraphFinder runtime cache
bwaidelich May 8, 2024
752894a
Merge branch 'feature/content-graph-bound' of https://github.com/kits…
bwaidelich May 8, 2024
73baee0
Merge remote-tracking branch 'origin/9.0' into feature/content-graph-…
kitsunet May 8, 2024
d5257e7
Separate CommandHandlingDependencies
kitsunet May 8, 2024
f6d7cb1
Fix phpcs errors
kitsunet May 8, 2024
5c00770
Fix lint errors
kitsunet May 8, 2024
7b884b5
Apply suggestions from code review
kitsunet May 8, 2024
1ff403c
Some cosmetic fixes
kitsunet May 9, 2024
67516e6
TASK: Declare `ContentGraphFinder` as internal and pass whole CR arou…
mhsdesign May 9, 2024
f639bf5
TASK: Try to pass one `ContentGraphTableNames` instance along instead…
mhsdesign May 9, 2024
b74e010
TASK: Refactor `HierarchyRelation` active record to use `ContentGraph…
mhsdesign May 10, 2024
e130a86
TASK: Refactor `NodeRecord` active record to use `ContentGraphTableNa…
mhsdesign May 10, 2024
723bea3
TASK: Remove string based `tableNamePrefix` from `DoctrineDbalContent…
mhsdesign May 10, 2024
14331e6
TASK: Rename `$contentGraphTableNames` to `$tableNames`
mhsdesign May 10, 2024
a208d9f
TASK: Remove dead code from ProjectionContentGraph
mhsdesign May 10, 2024
f632cb6
TASK: Use `ContentGraphTableNames` in `ProjectionContentGraph`
mhsdesign May 10, 2024
fb31212
TASK: Fix typo in `ContentGraphTableNames::hierarchyRelation`
mhsdesign May 10, 2024
9e6fcf0
Remove unused and unuseful getContentGraph methods
kitsunet May 10, 2024
4f77596
Merge pull request #3 from mhsdesign/task/refactorFurtherToContentGra…
kitsunet May 10, 2024
e045cea
Use TableNames in ProjectionIntegrityViolationDetector
kitsunet May 10, 2024
cf56d8b
TASK: Throw `WorkspaceDoesNotExist` exception when calling `getConten…
mhsdesign May 10, 2024
19b5104
TASK: Adjust executed exception to `WorkspaceDoesNotExist` in tests
mhsdesign May 10, 2024
22c8249
TASK: Remove obsolete `getSubgraphs` method
mhsdesign May 10, 2024
aa52b35
Apply suggestions from code review
kitsunet May 10, 2024
c0b5579
Remove unnecessary empty line
kitsunet May 10, 2024
8d9de7a
Re-add content stream does not exist check
kitsunet May 10, 2024
0078b7b
Don't expose ContentGraphTableNames tableNamePrefix
bwaidelich May 11, 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
64 changes: 64 additions & 0 deletions Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ContentGraph;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory;
use Neos\ContentRepository\Core\ContentGraphFactoryInterface;
use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\Workspace\Workspace;
use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceStatus;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceDescription;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceTitle;

/**
* @internal only used inside the
* @see ContentGraphFinder
*/
readonly final class ContentGraphFactory implements ContentGraphFactoryInterface
kitsunet marked this conversation as resolved.
Show resolved Hide resolved
{
public function __construct(
private DbalClientInterface $client,
private NodeFactory $nodeFactory,
private ContentRepositoryId $contentRepositoryId,
private NodeTypeManager $nodeTypeManager,
private string $tableNamePrefix
) {
}

public function buildForWorkspace(WorkspaceName $workspaceName): ContentGraph
{
// FIXME: Should be part of this projection, this is forbidden
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
$tableName = strtolower(sprintf(
'cr_%s_p_%s',
$this->contentRepositoryId->value,
'Workspace'
kitsunet marked this conversation as resolved.
Show resolved Hide resolved
));

$row = $this->client->getConnection()->executeQuery(
'
SELECT * FROM ' . $tableName . '
WHERE workspaceName = :workspaceName
kitsunet marked this conversation as resolved.
Show resolved Hide resolved
',
[
'workspaceName' => $workspaceName->value,
]
)->fetchAssociative();

if ($row === false) {
throw new ContentStreamDoesNotExistYet('The workspace "' . $workspaceName->value . '" does not exist.', 1714839710);
}

return $this->buildForWorkspaceAndContentStream($workspaceName, ContentStreamId::fromString($row['currentcontentstreamid']));
}

public function buildForWorkspaceAndContentStream(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraph
{
return new ContentGraph($this->client, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNamePrefix, $workspaceName, $contentStreamId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Neos\ContentGraph\DoctrineDbalAdapter;

/**
* Encapsulates table name generation for content graph tables
* @internal
*/
final class ContentGraphTableNames
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
{
private function __construct(private readonly string $tableNamePrefix)
{
}

public static function withPrefix(string $tableNamePrefix): self
{
return new self($tableNamePrefix);
}

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

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

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

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

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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\DimensionSpacePointsRepository;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ProjectionContentGraph;
use Neos\ContentRepository\Core\ContentGraphFinder;
use Neos\ContentRepository\Core\Factory\ProjectionFactoryDependencies;
use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphProjection;
Expand Down Expand Up @@ -43,23 +44,31 @@ public function build(

$dimensionSpacePointsRepository = new DimensionSpacePointsRepository($this->dbalClient->getConnection(), $tableNamePrefix);

$nodeFactory = new NodeFactory(
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
$projectionFactoryDependencies->propertyConverter,
$dimensionSpacePointsRepository
);

$contentGraphFactory = new ContentGraphFactory(
$this->dbalClient,
$nodeFactory,
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
$tableNamePrefix
);

return new ContentGraphProjection(
new DoctrineDbalContentGraphProjection(
$this->dbalClient,
new NodeFactory(
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
$projectionFactoryDependencies->propertyConverter,
$dimensionSpacePointsRepository
),
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
new ProjectionContentGraph(
$this->dbalClient,
$tableNamePrefix
),
$tableNamePrefix,
$dimensionSpacePointsRepository
$dimensionSpacePointsRepository,
new ContentGraphFinder($contentGraphFactory)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ class DoctrineDbalContentGraphSchemaBuilder
{
private const DEFAULT_TEXT_COLLATION = 'utf8mb4_unicode_520_ci';

private readonly ContentGraphTableNames $contentGraphTableNames;

public function __construct(
private readonly string $tableNamePrefix
string $tableNamePrefix
) {
$this->contentGraphTableNames = ContentGraphTableNames::withPrefix($tableNamePrefix);
}

public function buildSchema(AbstractSchemaManager $schemaManager): Schema
Expand All @@ -34,7 +37,7 @@ public function buildSchema(AbstractSchemaManager $schemaManager): Schema

private function createNodeTable(): Table
{
$table = new Table($this->tableNamePrefix . '_node', [
$table = new Table($this->contentGraphTableNames->node(), [
DbalSchemaFactory::columnForNodeAnchorPoint('relationanchorpoint')->setAutoincrement(true),
DbalSchemaFactory::columnForNodeAggregateId('nodeaggregateid')->setNotnull(false),
DbalSchemaFactory::columnForDimensionSpacePointHash('origindimensionspacepointhash')->setNotnull(false),
Expand All @@ -55,7 +58,7 @@ private function createNodeTable(): Table

private function createHierarchyRelationTable(): Table
{
$table = new Table($this->tableNamePrefix . '_hierarchyrelation', [
$table = new Table($this->contentGraphTableNames->hierachyRelation(), [
(new Column('name', Type::getType(Types::STRING)))->setLength(255)->setNotnull(false)->setCustomSchemaOption('charset', 'ascii')->setCustomSchemaOption('collation', 'ascii_general_ci'),
(new Column('position', Type::getType(Types::INTEGER)))->setNotnull(true),
DbalSchemaFactory::columnForContentStreamId('contentstreamid')->setNotnull(true),
Expand All @@ -75,7 +78,7 @@ private function createHierarchyRelationTable(): Table

private function createDimensionSpacePointsTable(): Table
{
$table = new Table($this->tableNamePrefix . '_dimensionspacepoints', [
$table = new Table($this->contentGraphTableNames->dimensionSpacePoints(), [
DbalSchemaFactory::columnForDimensionSpacePointHash('hash')->setNotnull(true),
DbalSchemaFactory::columnForDimensionSpacePoint('dimensionspacepoint')->setNotnull(true)
]);
Expand All @@ -86,7 +89,7 @@ private function createDimensionSpacePointsTable(): Table

private function createReferenceRelationTable(): Table
{
$table = new Table($this->tableNamePrefix . '_referencerelation', [
$table = new Table($this->contentGraphTableNames->referenceRelation(), [
(new Column('name', Type::getType(Types::STRING)))->setLength(255)->setNotnull(true)->setCustomSchemaOption('charset', 'ascii')->setCustomSchemaOption('collation', 'ascii_general_ci'),
(new Column('position', Type::getType(Types::INTEGER)))->setNotnull(true),
DbalSchemaFactory::columnForNodeAnchorPoint('nodeanchorpoint'),
Expand Down
Loading
Loading