Skip to content

Commit

Permalink
Revert "Merge pull request neos#4790 from kitsunet/task/split-dimensi…
Browse files Browse the repository at this point in the history
…onspacepoints"

This reverts commit c3a81af, reversing
changes made to 117c052.
  • Loading branch information
mhsdesign committed Apr 24, 2024
1 parent 47151a2 commit 399947e
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 229 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ private function transformDatasetToHierarchyRelationRecord(array $dataset): arra

return [
'contentstreamid' => $dataset['contentStreamId'],
'dimensionspacepoint' => $dimensionSpacePoint->toJson(),
'dimensionspacepointhash' => $dimensionSpacePoint->hash,
'parentnodeanchor' => $parentHierarchyRelation !== null ? $parentHierarchyRelation['childnodeanchor'] : 9999999,
'childnodeanchor' => $childHierarchyRelation !== null ? $childHierarchyRelation['childnodeanchor'] : 8888888,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\NodeRecord;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection\NodeRelationAnchorPoint;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ContentGraph;
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\DimensionSpace\DimensionSpacePoint;
Expand Down Expand Up @@ -92,7 +91,6 @@ public function __construct(
private readonly NodeTypeManager $nodeTypeManager,
private readonly ProjectionContentGraph $projectionContentGraph,
private readonly string $tableNamePrefix,
private readonly DimensionSpacePointsRepository $dimensionSpacePointsRepository
) {
$this->checkpointStorage = new DbalCheckpointStorage(
$this->dbalClient->getConnection(),
Expand Down Expand Up @@ -177,7 +175,6 @@ private function truncateDatabaseTables(): void
$connection->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_node');
$connection->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_hierarchyrelation');
$connection->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_referencerelation');
$connection->executeQuery('TRUNCATE table ' . $this->tableNamePrefix . '_dimensionspacepoints');
}

public function canHandle(EventInterface $event): bool
Expand Down Expand Up @@ -602,6 +599,7 @@ private function whenContentStreamWasForked(ContentStreamWasForked $event): void
childnodeanchor,
`name`,
position,
dimensionspacepoint,
dimensionspacepointhash,
subtreetags,
contentstreamid
Expand All @@ -611,6 +609,7 @@ private function whenContentStreamWasForked(ContentStreamWasForked $event): void
h.childnodeanchor,
h.name,
h.position,
h.dimensionspacepoint,
h.dimensionspacepointhash,
h.subtreetags,
"' . $event->newContentStreamId->value . '" AS contentstreamid
Expand Down Expand Up @@ -937,8 +936,6 @@ private function copyReferenceRelations(
private function whenDimensionSpacePointWasMoved(DimensionSpacePointWasMoved $event): void
{
$this->transactional(function () use ($event) {
$this->dimensionSpacePointsRepository->insertDimensionSpacePoint($event->target);

// the ordering is important - we first update the OriginDimensionSpacePoints, as we need the
// hierarchy relations for this query. Then, we update the Hierarchy Relations.

Expand Down Expand Up @@ -977,6 +974,7 @@ function (NodeRecord $nodeRecord) use ($event) {
'
UPDATE ' . $this->tableNamePrefix . '_hierarchyrelation h
SET
h.dimensionspacepoint = :newDimensionSpacePoint,
h.dimensionspacepointhash = :newDimensionSpacePointHash
WHERE
h.dimensionspacepointhash = :originalDimensionSpacePointHash
Expand All @@ -985,6 +983,7 @@ function (NodeRecord $nodeRecord) use ($event) {
[
'originalDimensionSpacePointHash' => $event->source->hash,
'newDimensionSpacePointHash' => $event->target->hash,
'newDimensionSpacePoint' => $event->target->toJson(),
'contentStreamId' => $event->contentStreamId->value
]
);
Expand All @@ -994,8 +993,6 @@ function (NodeRecord $nodeRecord) use ($event) {
private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded $event): void
{
$this->transactional(function () use ($event) {
$this->dimensionSpacePointsRepository->insertDimensionSpacePoint($event->target);

// 1) hierarchy relations
$this->getDatabaseConnection()->executeStatement(
'
Expand All @@ -1005,6 +1002,7 @@ private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded
`name`,
position,
subtreetags,
dimensionspacepoint,
dimensionspacepointhash,
contentstreamid
)
Expand All @@ -1014,6 +1012,7 @@ private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded
h.name,
h.position,
h.subtreetags,
:newDimensionSpacePoint AS dimensionspacepoint,
:newDimensionSpacePointHash AS dimensionspacepointhash,
h.contentstreamid
FROM
Expand All @@ -1024,6 +1023,7 @@ private function whenDimensionShineThroughWasAdded(DimensionShineThroughWasAdded
'contentStreamId' => $event->contentStreamId->value,
'sourceDimensionSpacePointHash' => $event->source->hash,
'newDimensionSpacePointHash' => $event->target->hash,
'newDimensionSpacePoint' => $event->target->toJson(),
]
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Neos\ContentGraph\DoctrineDbalAdapter;

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\Factory\ProjectionFactoryDependencies;
Expand Down Expand Up @@ -41,25 +40,21 @@ public function build(
$projectionFactoryDependencies->contentRepositoryId
);

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

return new ContentGraphProjection(
new DoctrineDbalContentGraphProjection(
$this->dbalClient,
new NodeFactory(
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
$projectionFactoryDependencies->propertyConverter,
$dimensionSpacePointsRepository
$projectionFactoryDependencies->propertyConverter
),
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
new ProjectionContentGraph(
$this->dbalClient,
$tableNamePrefix
),
$tableNamePrefix,
$dimensionSpacePointsRepository
$tableNamePrefix
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function buildSchema(AbstractSchemaManager $schemaManager): Schema
$this->createNodeTable(),
$this->createHierarchyRelationTable(),
$this->createReferenceRelationTable(),
$this->createDimensionSpacePointsTable()
]);
}

Expand All @@ -37,6 +36,7 @@ private function createNodeTable(): Table
$table = new Table($this->tableNamePrefix . '_node', [
DbalSchemaFactory::columnForNodeAnchorPoint('relationanchorpoint')->setAutoincrement(true),
DbalSchemaFactory::columnForNodeAggregateId('nodeaggregateid')->setNotnull(false),
DbalSchemaFactory::columnForDimensionSpacePoint('origindimensionspacepoint')->setNotnull(false),
DbalSchemaFactory::columnForDimensionSpacePointHash('origindimensionspacepointhash')->setNotnull(false),
DbalSchemaFactory::columnForNodeTypeName('nodetypename'),
(new Column('properties', Type::getType(Types::TEXT)))->setNotnull(true)->setCustomSchemaOption('collation', self::DEFAULT_TEXT_COLLATION),
Expand All @@ -56,31 +56,24 @@ private function createNodeTable(): Table
private function createHierarchyRelationTable(): Table
{
$table = new Table($this->tableNamePrefix . '_hierarchyrelation', [
(new Column('name', Type::getType(Types::STRING)))->setLength(255)->setNotnull(false)->setCustomSchemaOption('charset', 'ascii')->setCustomSchemaOption('collation', 'ascii_general_ci'),
(new Column('name', Type::getType(Types::STRING)))->setLength(255)->setNotnull(false)->setCustomSchemaOption('collation', self::DEFAULT_TEXT_COLLATION),
(new Column('position', Type::getType(Types::INTEGER)))->setNotnull(true),
DbalSchemaFactory::columnForContentStreamId('contentstreamid')->setNotnull(true),
DbalSchemaFactory::columnForDimensionSpacePoint('dimensionspacepoint')->setNotnull(true),
DbalSchemaFactory::columnForDimensionSpacePointHash('dimensionspacepointhash')->setNotnull(true),
DbalSchemaFactory::columnForNodeAnchorPoint('parentnodeanchor'),
DbalSchemaFactory::columnForNodeAnchorPoint('childnodeanchor'),
(new Column('subtreetags', Type::getType(Types::JSON)))->setDefault('{}'),
]);

return $table
->setPrimaryKey(['childnodeanchor', 'contentstreamid', 'dimensionspacepointhash', 'parentnodeanchor'])
->addIndex(['childnodeanchor'])
->addIndex(['contentstreamid'])
->addIndex(['parentnodeanchor'])
->addIndex(['contentstreamid', 'childnodeanchor', 'dimensionspacepointhash'])
->addIndex(['contentstreamid', 'dimensionspacepointhash']);
}

private function createDimensionSpacePointsTable(): Table
{
$table = new Table($this->tableNamePrefix . '_dimensionspacepoints', [
DbalSchemaFactory::columnForDimensionSpacePointHash('hash')->setNotnull(true),
DbalSchemaFactory::columnForDimensionSpacePoint('dimensionspacepoint')->setNotnull(true)
]);

return $table
->setPrimaryKey(['hash']);
}

private function createReferenceRelationTable(): Table
{
$table = new Table($this->tableNamePrefix . '_referencerelation', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Doctrine\DBAL\Connection;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\DimensionSpacePointsRepository;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTags;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
Expand Down Expand Up @@ -45,22 +44,16 @@ public function __construct(
*/
public function addToDatabase(Connection $databaseConnection, string $tableNamePrefix): void
{
$databaseConnection->transactional(function ($databaseConnection) use (
$tableNamePrefix
) {
$dimensionSpacePoints = new DimensionSpacePointsRepository($databaseConnection, $tableNamePrefix);
$dimensionSpacePoints->insertDimensionSpacePoint($this->dimensionSpacePoint);

$databaseConnection->insert($tableNamePrefix . '_hierarchyrelation', [
'parentnodeanchor' => $this->parentNodeAnchor->value,
'childnodeanchor' => $this->childNodeAnchor->value,
'name' => $this->name?->value,
'contentstreamid' => $this->contentStreamId->value,
'dimensionspacepointhash' => $this->dimensionSpacePointHash,
'position' => $this->position,
'subtreetags' => json_encode($this->subtreeTags, JSON_THROW_ON_ERROR | JSON_FORCE_OBJECT),
]);
});
$databaseConnection->insert($tableNamePrefix . '_hierarchyrelation', [
'parentnodeanchor' => $this->parentNodeAnchor->value,
'childnodeanchor' => $this->childNodeAnchor->value,
'name' => $this->name?->value,
'contentstreamid' => $this->contentStreamId->value,
'dimensionspacepoint' => $this->dimensionSpacePoint->toJson(),
'dimensionspacepointhash' => $this->dimensionSpacePointHash,
'position' => $this->position,
'subtreetags' => json_encode($this->subtreeTags, JSON_THROW_ON_ERROR | JSON_FORCE_OBJECT),
]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
namespace Neos\ContentGraph\DoctrineDbalAdapter\Domain\Projection;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Types\Types;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\DimensionSpacePointsRepository;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps;
Expand Down Expand Up @@ -57,6 +55,7 @@ public function updateToDatabase(Connection $databaseConnection, string $tableNa
$tableNamePrefix . '_node',
[
'nodeaggregateid' => $this->nodeAggregateId->value,
'origindimensionspacepoint' => json_encode($this->originDimensionSpacePoint),
'origindimensionspacepointhash' => $this->originDimensionSpacePointHash,
'properties' => json_encode($this->properties),
'nodetypename' => $this->nodeTypeName->value,
Expand Down Expand Up @@ -139,38 +138,25 @@ public static function createNewInDatabase(
?NodeName $nodeName,
Timestamps $timestamps,
): self {
$relationAnchorPoint = $databaseConnection->transactional(function ($databaseConnection) use (
$tableNamePrefix,
$nodeAggregateId,
$originDimensionSpacePoint,
$originDimensionSpacePointHash,
$properties,
$nodeTypeName,
$classification,
$timestamps
) {
$dimensionSpacePoints = new DimensionSpacePointsRepository($databaseConnection, $tableNamePrefix);
$dimensionSpacePoints->insertDimensionSpacePointByHashAndCoordinates($originDimensionSpacePointHash, $originDimensionSpacePoint);

$databaseConnection->insert($tableNamePrefix . '_node', [
'nodeaggregateid' => $nodeAggregateId->value,
'origindimensionspacepointhash' => $originDimensionSpacePointHash,
'properties' => json_encode($properties),
'nodetypename' => $nodeTypeName->value,
'classification' => $classification->value,
'created' => $timestamps->created,
'originalcreated' => $timestamps->originalCreated,
'lastmodified' => $timestamps->lastModified,
'originallastmodified' => $timestamps->originalLastModified,
], [
'created' => Types::DATETIME_IMMUTABLE,
'originalcreated' => Types::DATETIME_IMMUTABLE,
'lastmodified' => Types::DATETIME_IMMUTABLE,
'originallastmodified' => Types::DATETIME_IMMUTABLE,
]);
$databaseConnection->insert($tableNamePrefix . '_node', [
'nodeaggregateid' => $nodeAggregateId->value,
'origindimensionspacepoint' => json_encode($originDimensionSpacePoint),
'origindimensionspacepointhash' => $originDimensionSpacePointHash,
'properties' => json_encode($properties),
'nodetypename' => $nodeTypeName->value,
'classification' => $classification->value,
'created' => $timestamps->created,
'originalcreated' => $timestamps->originalCreated,
'lastmodified' => $timestamps->lastModified,
'originallastmodified' => $timestamps->originalLastModified,
], [
'created' => Types::DATETIME_IMMUTABLE,
'originalcreated' => Types::DATETIME_IMMUTABLE,
'lastmodified' => Types::DATETIME_IMMUTABLE,
'originallastmodified' => Types::DATETIME_IMMUTABLE,
]);

return NodeRelationAnchorPoint::fromInteger((int)$databaseConnection->lastInsertId());
});
$relationAnchorPoint = NodeRelationAnchorPoint::fromInteger((int)$databaseConnection->lastInsertId());

return new self(
$relationAnchorPoint,
Expand Down
Loading

0 comments on commit 399947e

Please sign in to comment.