Skip to content

Commit

Permalink
Merge branch '9.0' into 4191-nodeTypeChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Schmitt committed Oct 23, 2024
2 parents 7ad90e7 + 288a7c5 commit 7e5a13b
Show file tree
Hide file tree
Showing 131 changed files with 486 additions and 1,349 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,10 @@ jobs:
# We enable the race condition tracker
presets:
'default':
projections:
'Neos.ContentRepository:ContentGraph':
catchUpHooks:
'Neos.ContentRepository.BehavioralTests:RaceConditionTracker':
factoryObjectName: Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\RaceTrackerCatchUpHookFactory
contentGraphProjection:
catchUpHooks:
'Neos.ContentRepository.BehavioralTests:RaceConditionTracker':
factoryObjectName: Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\RaceTrackerCatchUpHookFactory
ContentRepository:
BehavioralTests:
raceConditionTracker:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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\Projection\ContentGraph\ContentGraphReadModelInterface;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream;
Expand All @@ -32,10 +32,9 @@
use Neos\EventStore\Model\Event\Version;

/**
* @internal only used inside the
* @see ContentRepositoryReadModel
* @internal
*/
final readonly class ContentRepositoryReadModelAdapter implements ContentRepositoryReadModelAdapterInterface
final readonly class ContentGraphReadModelAdapter implements ContentGraphReadModelInterface
{
public function __construct(
private Connection $dbal,
Expand Down Expand Up @@ -131,6 +130,21 @@ public function findContentStreams(): ContentStreams
return ContentStreams::fromArray(array_map(self::contentStreamFromDatabaseRow(...), $rows));
}

public function countNodes(): int
{
$countNodesStatement = <<<SQL
SELECT
COUNT(*)
FROM
{$this->tableNames->node()}
SQL;
try {
return (int)$this->dbal->fetchOne($countNodesStatement);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to count rows in database: %s', $e->getMessage()), 1701444590, $e);
}
}

/**
* @param array<string, mixed> $row
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\NodeRelationAnchorPoint;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\DimensionSpacePointsRepository;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ProjectionContentGraph;
use Neos\ContentRepository\Core\ContentRepositoryReadModel;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphReadModelInterface;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
Expand Down Expand Up @@ -65,8 +65,8 @@
use Neos\ContentRepository\Core\Projection\CheckpointStorageStatusType;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTags;
use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps;
use Neos\ContentRepository\Core\Projection\ProjectionInterface;
use Neos\ContentRepository\Core\Projection\ProjectionStatus;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphProjectionInterface;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
Expand All @@ -76,10 +76,9 @@
use Neos\EventStore\Model\EventEnvelope;

/**
* @implements ProjectionInterface<ContentRepositoryReadModel>
* @internal but the graph projection is api
*/
final class DoctrineDbalContentGraphProjection implements ProjectionInterface
final class DoctrineDbalContentGraphProjection implements ContentGraphProjectionInterface
{
use ContentStream;
use NodeMove;
Expand All @@ -98,7 +97,7 @@ public function __construct(
private readonly ProjectionContentGraph $projectionContentGraph,
private readonly ContentGraphTableNames $tableNames,
private readonly DimensionSpacePointsRepository $dimensionSpacePointsRepository,
private readonly ContentRepositoryReadModel $contentRepositoryReadModel
private readonly ContentGraphReadModelInterface $contentGraphReadModel
) {
$this->checkpointStorage = new DbalCheckpointStorage(
$this->dbal,
Expand Down Expand Up @@ -177,9 +176,9 @@ public function getCheckpointStorage(): DbalCheckpointStorage
return $this->checkpointStorage;
}

public function getState(): ContentRepositoryReadModel
public function getState(): ContentGraphReadModelInterface
{
return $this->contentRepositoryReadModel;
return $this->contentGraphReadModel;
}

public function canHandle(EventInterface $event): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
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\ContentRepositoryReadModel;
use Neos\ContentRepository\Core\Factory\ProjectionFactoryDependencies;
use Neos\ContentRepository\Core\Projection\ProjectionFactoryInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphProjectionFactoryInterface;

/**
* Use this class as ProjectionFactory in your configuration to construct a content graph
*
* @implements ProjectionFactoryInterface<DoctrineDbalContentGraphProjection>
*
* @api
*/
final class DoctrineDbalContentGraphProjectionFactory implements ProjectionFactoryInterface
final class DoctrineDbalContentGraphProjectionFactory implements ContentGraphProjectionFactoryInterface
{
public function __construct(
private readonly Connection $dbal,
Expand All @@ -42,7 +39,7 @@ public function build(
$dimensionSpacePointsRepository
);

$contentRepositoryReadModelAdapter = new ContentRepositoryReadModelAdapter(
$contentGraphReadModel = new ContentGraphReadModelAdapter(
$this->dbal,
$nodeFactory,
$projectionFactoryDependencies->contentRepositoryId,
Expand All @@ -58,7 +55,7 @@ public function build(
),
$tableNames,
$dimensionSpacePointsRepository,
new ContentRepositoryReadModel($contentRepositoryReadModelAdapter)
$contentGraphReadModel
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,6 @@ public function getDimensionSpacePointsOccupiedByChildNodeName(NodeName $nodeNam
return new DimensionSpacePointSet($dimensionSpacePoints);
}

public function countNodes(): int
{
$queryBuilder = $this->createQueryBuilder()
->select('COUNT(*)')
->from($this->nodeQueryBuilder->tableNames->node());
try {
$result = $queryBuilder->executeQuery();
return (int)$result->fetchOne();
} catch (DBALException $e) {
throw new \RuntimeException(sprintf('Failed to count rows in database: %s', $e->getMessage()), 1701444590, $e);
}
}

public function findUsedNodeTypeNames(): NodeTypeNames
{
return NodeTypeNames::fromArray(array_map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use Doctrine\DBAL\Connection;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\ContentHypergraph;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\NodeFactory;
use Neos\ContentRepository\Core\ContentRepositoryReadModel;
use Neos\ContentRepository\Core\ContentRepositoryReadModelAdapterInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphReadModelInterface;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
Expand All @@ -20,10 +19,9 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces;

/**
* @internal only used within
* @see ContentRepositoryReadModel
* @internal
*/
final readonly class ContentHyperRepositoryReadModelAdapter implements ContentRepositoryReadModelAdapterInterface
final readonly class ContentHyperGraphReadModelAdapter implements ContentGraphReadModelInterface
{
public function __construct(
private Connection $dbal,
Expand Down Expand Up @@ -62,4 +60,10 @@ public function findContentStreams(): ContentStreams
// TODO: Implement getContentStreams() method.
return ContentStreams::createEmpty();
}

public function countNodes(): int
{
// TODO: Implement countNodes method.
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Feature\NodeVariation;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\Feature\SubtreeTagging;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\SchemaBuilder\HypergraphSchemaBuilder;
use Neos\ContentRepository\Core\ContentRepositoryReadModel;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphReadModelInterface;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\ContentStreamForking\Event\ContentStreamWasForked;
use Neos\ContentRepository\Core\Feature\NodeCreation\Event\NodeAggregateWithNodeWasCreated;
Expand All @@ -44,18 +44,17 @@
use Neos\ContentRepository\Core\Infrastructure\DbalCheckpointStorage;
use Neos\ContentRepository\Core\Infrastructure\DbalSchemaDiff;
use Neos\ContentRepository\Core\Projection\CheckpointStorageStatusType;
use Neos\ContentRepository\Core\Projection\ProjectionInterface;
use Neos\ContentRepository\Core\Projection\ProjectionStatus;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphProjectionInterface;
use Neos\EventStore\Model\Event\SequenceNumber;
use Neos\EventStore\Model\EventEnvelope;

/**
* The alternate reality-aware hypergraph projector for the PostgreSQL backend via Doctrine DBAL
*
* @implements ProjectionInterface<ContentRepositoryReadModel>
* @internal the parent Content Graph is public
*/
final class HypergraphProjection implements ProjectionInterface
final class HypergraphProjection implements ContentGraphProjectionInterface
{
use ContentStreamForking;
use NodeCreation;
Expand All @@ -73,7 +72,7 @@ final class HypergraphProjection implements ProjectionInterface
public function __construct(
private readonly Connection $dbal,
private readonly string $tableNamePrefix,
private readonly ContentRepositoryReadModel $contentRepositoryReadModel
private readonly ContentGraphReadModelInterface $contentGraphReadModel
) {
$this->projectionHypergraph = new ProjectionHypergraph($this->dbal, $this->tableNamePrefix);
$this->checkpointStorage = new DbalCheckpointStorage(
Expand Down Expand Up @@ -219,9 +218,9 @@ public function getCheckpointStorage(): DbalCheckpointStorage
return $this->checkpointStorage;
}

public function getState(): ContentRepositoryReadModel
public function getState(): ContentGraphReadModelInterface
{
return $this->contentRepositoryReadModel;
return $this->contentGraphReadModel;
}

protected function getProjectionHypergraph(): ProjectionHypergraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ public function isEmpty(): bool
return count($this->ids) === 0;
}

/**
* @return \Traversable<string,NodeAggregateId>
*/
public function getIterator(): \Traversable
{
yield from $this->ids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ public function remove(NodeRelationAnchorPoint $nodeRelationAnchorPoint): self
return new self(...$childNodeAnchors);
}

/**
* @return \Traversable<NodeRelationAnchorPoint>
*/
public function getIterator(): \Traversable
{
yield from $this->nodeRelationAnchorPoints;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,6 @@ public function getDimensionSpacePointsOccupiedByChildNodeName(
return new DimensionSpacePointSet($occupiedDimensionSpacePoints);
}

/**
* @throws \Doctrine\DBAL\Driver\Exception
* @throws \Doctrine\DBAL\Exception
*/
public function countNodes(): int
{
$query = 'SELECT COUNT(*) FROM ' . $this->tableNamePrefix . '_node';

return $this->dbal->executeQuery($query)->fetchOne();
}

public function findUsedNodeTypeNames(): NodeTypeNames
{
return NodeTypeNames::createEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
use Doctrine\DBAL\Connection;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Projection\HypergraphProjection;
use Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\NodeFactory;
use Neos\ContentRepository\Core\ContentRepositoryReadModel;
use Neos\ContentRepository\Core\Factory\ProjectionFactoryDependencies;
use Neos\ContentRepository\Core\Projection\ProjectionFactoryInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphProjectionFactoryInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;

/**
* @implements ProjectionFactoryInterface<HypergraphProjection>
* @api
*/
final class HypergraphProjectionFactory implements ProjectionFactoryInterface
final class HypergraphProjectionFactory implements ContentGraphProjectionFactoryInterface
{
public function __construct(
private readonly Connection $dbal,
Expand Down Expand Up @@ -45,7 +43,7 @@ public function build(
return new HypergraphProjection(
$this->dbal,
$tableNamePrefix,
new ContentRepositoryReadModel(new ContentHyperRepositoryReadModelAdapter($this->dbal, $nodeFactory, $projectionFactoryDependencies->contentRepositoryId, $projectionFactoryDependencies->nodeTypeManager, $tableNamePrefix))
new ContentHyperGraphReadModelAdapter($this->dbal, $nodeFactory, $projectionFactoryDependencies->contentRepositoryId, $projectionFactoryDependencies->nodeTypeManager, $tableNamePrefix)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function createNodesForPerformanceTest(int $nodesPerLevel, int $levels):
NodeAggregateClassification::CLASSIFICATION_ROOT,
);

$this->eventPersister->publishEvents(new EventsToPublish(
$this->eventPersister->publishEvents($this->contentRepository, new EventsToPublish(
$this->contentStreamEventStream->getEventStreamName(),
Events::with($rootNodeAggregateWasCreated),
ExpectedVersion::ANY()
Expand All @@ -102,7 +102,7 @@ public function createNodesForPerformanceTest(int $nodesPerLevel, int $levels):
$sumSoFar = 0;
$events = [];
$this->createHierarchy($rootNodeAggregateId, 1, $levels, $nodesPerLevel, $sumSoFar, $events);
$this->eventPersister->publishEvents(new EventsToPublish(
$this->eventPersister->publishEvents($this->contentRepository, new EventsToPublish(
$this->contentStreamEventStream->getEventStreamName(),
Events::fromArray($events),
ExpectedVersion::ANY()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\Dto\TraceEntryType;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Projection\CatchUpHookInterface;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\SubprocessProjectionCatchUpTrigger;
use Neos\EventStore\Model\EventEnvelope;
use Neos\Flow\Annotations as Flow;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Neos:
#ContentRepositoryRegistry:
# presets:
# 'default':
# projections:
# 'Neos.ContentRepository:ContentGraph':
# contentGraphProjection:
# catchUpHooks:
# 'Neos.ContentRepository.BehavioralTests:RaceConditionTracker':
# factoryObjectName: Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\RaceTrackerCatchUpHookFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Neos:
ContentRepositoryRegistry:
presets:
'default':
projections:
'Neos.ContentRepository:ContentGraph':
factoryObjectName: Neos\ContentGraph\PostgreSQLAdapter\HypergraphProjectionFactory
contentGraphProjection:
factoryObjectName: Neos\ContentGraph\PostgreSQLAdapter\HypergraphProjectionFactory

Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,4 @@ Feature: Create node aggregate with node
| nodeAggregateId | "nody-mc-nodeface" |
| nodeTypeName | "Neos.ContentRepository.Testing:NodeWithInvalidDefaultValue" |
| parentNodeAggregateId | "lady-eleonode-rootford" |
Then the last command should have thrown an exception of type "CallErrorException"
Then the last command should have thrown an exception of type "InvalidArgumentException"
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Feature: Properties
| nodeAggregateId | "sir-david-nodenborough" |
| originDimensionSpacePoint | {} |
| affectedDimensionSpacePoints | [{}] |
| propertyValues | {"myProp": {"value": "original value", "type": "My\\Non\\Existing\\Class"}} |
| propertyValues | {"myProp": {"value": "original value", "type": "My\\\\Non\\\\Existing\\\\Class"}} |
| propertiesToUnset | {} |
Then I expect the following structure adjustments for type "Neos.ContentRepository.Testing:Document":
| Type | nodeAggregateId |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Feature: Workspace rebasing - conflicting changes
| nodeAggregateId | "nody-mc-nodeface" |
| originDimensionSpacePoint | {} |
| propertyValues | {"text": "Original"} |
# we need to ensure that the projections are up to date now; otherwise a content stream is forked with an out-
# of-date base version. This means the content stream can never be merged back, but must always be rebased.
And the command CreateWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-test" |
Expand Down
Loading

0 comments on commit 7e5a13b

Please sign in to comment.