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: ContentGraphAdapter for write side access #4979

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
148 changes: 148 additions & 0 deletions Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphAdapter.php
Copy link
Member

Choose a reason for hiding this comment

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

We should refine this naming

@@ -0,0 +1,148 @@
<?php
namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Doctrine\DBAL\Connection;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterInterface;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
use Neos\ContentRepository\Core\Projection\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamState;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\EventStream\MaybeVersion;

/**
*
*/
class ContentGraphAdapter implements ContentGraphAdapterInterface
{
private NodeFactory $nodeFactory;

public function __construct(
private readonly Connection $dbalConnection,
private readonly string $tableNamePrefix,
public readonly ContentStreamId $contentStreamId,
public readonly WorkspaceName $workspaceName
)
{
}

public function rootNodeAggregateWithTypeExists(ContentStreamId $contentStreamId, NodeTypeName $nodeTypeName): bool
{
// TODO: Implement rootNodeAggregateWithTypeExists() method.
}

public function findParentNodeAggregates(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $childNodeAggregateId): iterable
{
// TODO: Implement findParentNodeAggregates() method.
}

public function findNodeAggregateById(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $nodeAggregateId): ?NodeAggregate
{
// TODO: Implement findNodeAggregateById() method.
}

public function findParentNodeAggregateByChildOriginDimensionSpacePoint(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $childNodeAggregateId, OriginDimensionSpacePoint $childOriginDimensionSpacePoint): ?NodeAggregate
{
// TODO: Implement findParentNodeAggregateByChildOriginDimensionSpacePoint() method.
}

public function findChildNodeAggregates(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $parentNodeAggregateId): iterable
{
// TODO: Implement findChildNodeAggregates() method.
}

public function findTetheredChildNodeAggregates(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $parentNodeAggregateId): iterable
{
// TODO: Implement findTetheredChildNodeAggregates() method.
}

public function getDimensionSpacePointsOccupiedByChildNodeName(ContentStreamId $contentStreamId, NodeName $nodeName, NodeAggregateId $parentNodeAggregateId, OriginDimensionSpacePoint $parentNodeOriginDimensionSpacePoint, DimensionSpacePointSet $dimensionSpacePointsToCheck): DimensionSpacePointSet
{
// TODO: Implement getDimensionSpacePointsOccupiedByChildNodeName() method.
}

public function findChildNodeAggregatesByName(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $parentNodeAggregateId, NodeName $name): iterable
{
// TODO: Implement findChildNodeAggregatesByName() method.
}

public function subgraphContainsNodes(ContentStreamId $contentStreamId, DimensionSpacePoint $dimensionSpacePoint): bool
{
// TODO: Implement subgraphContainsNodes() method.
}

public function findNodeInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $nodeAggregateId): ?Node
{
// TODO: Implement findNodeInSubgraph() method.
}

public function findParentNodeInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $childNodeAggregateId): ?Node
{
// TODO: Implement findParentNodeInSubgraph() method.
}

public function findChildNodeByNameInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $parentNodeAggregateId, NodeName $nodeNamex): ?Node
{
// TODO: Implement findChildNodeByNameInSubgraph() method.
}

public function findPreceedingSiblingNodesInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $startingSiblingNodeAggregateId): Nodesy
{
// TODO: Implement findPreceedingSiblingNodesInSubgraph() method.
}

public function findSuceedingSiblingNodesInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $startingSiblingNodeAggregateId): Nodes
{
// TODO: Implement findSuceedingSiblingNodesInSubgraph() method.
}

public function hasContentStream(ContentStreamId $contentStreamId): bool
{
// TODO: Implement hasContentStream() method.
}

public function findStateForContentStream(ContentStreamId $contentStreamId): ?ContentStreamState
{
// TODO: Implement findStateForContentStream() method.
}

public function findVersionForContentStream(ContentStreamId $contentStreamId): MaybeVersion
{
// TODO: Implement findVersionForContentStream() method.
}

public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace
{
// TODO: Implement findWorkspaceByName() method.
}

public function findWorkspaceByCurrentContentStreamId(ContentStreamId $contentStreamId): ?Workspace
{
// TODO: Implement findWorkspaceByCurrentContentStreamId() method.
}

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

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

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


}
@@ -0,0 +1,36 @@
<?php
namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Doctrine\DBAL\Connection;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterInterface;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterProviderInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
* @api
*/
class ContentGraphAdapterProvider implements ContentGraphAdapterProviderInterface
{
public function __construct(
private readonly Connection $dbalConnection,
private readonly string $tableNamePrefix,
) {
}

public function resolveWorkspaceNameAndGet(ContentStreamId $contentStreamId): ContentGraphAdapterInterface
{
// TODO: Implement resolveWorkspaceNameAndGet() method.
}

public function resolveContentStreamIdAndGet(WorkspaceName $workspaceName): ContentGraphAdapterInterface
{
// TODO: Implement resolveContentStreamIdAndGet() method.
}

public function overrideContentStreamId(WorkspaceName $workspaceName, ContentStreamId $contentStreamId, \Closure $fn): void
{
// TODO: Implement overrideContentStreamId() method.
}

}
@@ -0,0 +1,26 @@
<?php
namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Doctrine\DBAL\Connection;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterProviderFactoryInterface;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterProviderInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;

/**
* This factory resolves low level dependencies for the ContentGraphAdapterProvider implementation
*/
class ContentGraphAdapterProviderFactory implements ContentGraphAdapterProviderFactoryInterface
{
public function __construct(
readonly Connection $dbalConnection
) {
}

public function build(ContentRepositoryId $contentRepositoryId, array $options): ContentGraphAdapterProviderInterface
{
$tableNamePrefix = DoctrineDbalContentGraphProjectionFactory::graphProjectionTableNamePrefix(
$contentRepositoryId
);
return new ContentGraphAdapterProvider($this->dbalConnection, $tableNamePrefix);
}
}
9 changes: 9 additions & 0 deletions Neos.ContentRepository.Core/Classes/ContentRepository.php
Expand Up @@ -29,6 +29,7 @@
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\CatchUp;
use Neos\ContentRepository\Core\Projection\CatchUpOptions;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentStream\ContentStreamFinder;
use Neos\ContentRepository\Core\Projection\ProjectionInterface;
Expand Down Expand Up @@ -258,4 +259,12 @@ public function getContentDimensionSource(): ContentDimensionSourceInterface
{
return $this->contentDimensionSource;
}

/**
* @internal
*/
public function getContentGraphAdapter(): ContentGraphAdapterInterface
{
return $this->getContentGraph();
}
}
Expand Up @@ -21,6 +21,7 @@
use Neos\ContentRepository\Core\DimensionSpace\InterDimensionalVariationGraph;
use Neos\ContentRepository\Core\EventStore\EventNormalizer;
use Neos\ContentRepository\Core\EventStore\EventPersister;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterProviderInterface;
use Neos\ContentRepository\Core\Feature\ContentStreamCommandHandler;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\DimensionSpaceCommandHandler;
use Neos\ContentRepository\Core\Feature\NodeAggregateCommandHandler;
Expand Down Expand Up @@ -56,6 +57,7 @@ public function __construct(
private readonly ProjectionCatchUpTriggerInterface $projectionCatchUpTrigger,
private readonly UserIdProviderInterface $userIdProvider,
private readonly ClockInterface $clock,
private readonly ContentGraphAdapterProviderInterface $contentGraphAdapterProvider,
) {
$contentDimensionZookeeper = new ContentDimensionZookeeper($contentDimensionSource);
$interDimensionalVariationGraph = new InterDimensionalVariationGraph(
Expand Down Expand Up @@ -125,6 +127,7 @@ public function buildService(
$this->getOrBuild(),
$this->buildEventPersister(),
$this->projectionsAndCatchUpHooks->projections,
$this->contentGraphAdapterProvider
);
return $serviceFactory->build($serviceFactoryDependencies);
}
Expand All @@ -134,26 +137,31 @@ private function buildCommandBus(): CommandBus
if (!$this->commandBus) {
$this->commandBus = new CommandBus(
new ContentStreamCommandHandler(
$this->contentGraphAdapterProvider
),
new WorkspaceCommandHandler(
$this->buildEventPersister(),
$this->projectionFactoryDependencies->eventStore,
$this->projectionFactoryDependencies->eventNormalizer,
$this->contentGraphAdapterProvider
),
new NodeAggregateCommandHandler(
$this->projectionFactoryDependencies->nodeTypeManager,
$this->projectionFactoryDependencies->contentDimensionZookeeper,
$this->projectionFactoryDependencies->interDimensionalVariationGraph,
$this->projectionFactoryDependencies->propertyConverter
$this->projectionFactoryDependencies->propertyConverter,
$this->contentGraphAdapterProvider
),
new DimensionSpaceCommandHandler(
$this->projectionFactoryDependencies->contentDimensionZookeeper,
$this->projectionFactoryDependencies->interDimensionalVariationGraph
$this->projectionFactoryDependencies->interDimensionalVariationGraph,
$this->contentGraphAdapterProvider
),
new NodeDuplicationCommandHandler(
$this->projectionFactoryDependencies->nodeTypeManager,
$this->projectionFactoryDependencies->contentDimensionZookeeper,
$this->projectionFactoryDependencies->interDimensionalVariationGraph
$this->projectionFactoryDependencies->interDimensionalVariationGraph,
$this->contentGraphAdapterProvider
)
);
}
Expand Down
Expand Up @@ -20,6 +20,7 @@
use Neos\ContentRepository\Core\DimensionSpace\InterDimensionalVariationGraph;
use Neos\ContentRepository\Core\EventStore\EventNormalizer;
use Neos\ContentRepository\Core\EventStore\EventPersister;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterProviderInterface;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\Projections;
Expand Down Expand Up @@ -47,6 +48,7 @@ private function __construct(
// we don't need CommandBus, because this is included in ContentRepository->handle()
public EventPersister $eventPersister,
public Projections $projections,
public ContentGraphAdapterProviderInterface $contentGraphAdapterProvider
) {
}

Expand All @@ -58,6 +60,7 @@ public static function create(
ContentRepository $contentRepository,
EventPersister $eventPersister,
Projections $projections,
ContentGraphAdapterProviderInterface $contentGraphAdapterProvider
): self {
return new self(
$projectionFactoryDependencies->contentRepositoryId,
Expand All @@ -71,6 +74,7 @@ public static function create(
$contentRepository,
$eventPersister,
$projections,
$contentGraphAdapterProvider
);
}
}