Skip to content

Commit

Permalink
Merge pull request #4626 from neos/task/removeContentGraphFindNodeByI…
Browse files Browse the repository at this point in the history
…dAndOriginDimensionSpacePoint

TASK: Remove internal `ContentGraph::findNodeByIdAndOriginDimensionSpacePoint`
  • Loading branch information
nezaniel authored Oct 19, 2023
2 parents a6613f9 + fb2dddc commit a6d265d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,40 +84,6 @@ final public function getSubgraph(
return $this->subgraphs[$index];
}

/**
* @throws DBALException
* @throws NodeTypeNotFoundException
*/
public function findNodeByIdAndOriginDimensionSpacePoint(
ContentStreamId $contentStreamId,
NodeAggregateId $nodeAggregateId,
OriginDimensionSpacePoint $originDimensionSpacePoint
): ?Node {
$connection = $this->client->getConnection();

// HINT: we check the ContentStreamId on the EDGE;
// as this is where we actually find out whether the node exists in the content stream
$nodeRow = $connection->executeQuery(
'SELECT n.*, h.contentstreamid, h.name FROM ' . $this->tableNamePrefix . '_node n
INNER JOIN ' . $this->tableNamePrefix . '_hierarchyrelation h
ON h.childnodeanchor = n.relationanchorpoint
WHERE n.nodeaggregateid = :nodeAggregateId
AND n.origindimensionspacepointhash = :originDimensionSpacePointHash
AND h.contentstreamid = :contentStreamId',
[
'nodeAggregateId' => $nodeAggregateId->value,
'originDimensionSpacePointHash' => $originDimensionSpacePoint->hash,
'contentStreamId' => $contentStreamId->value
]
)->fetchAssociative();

return $nodeRow ? $this->nodeFactory->mapNodeRowToNode(
$nodeRow,
$originDimensionSpacePoint->toDimensionSpacePoint(),
VisibilityConstraints::withoutRestrictions()
) : null;
}

/**
* @throws RootNodeAggregateDoesNotExist
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,6 @@ public function getSubgraph(
return $this->subhypergraphs[$index];
}

public function findNodeByIdAndOriginDimensionSpacePoint(
ContentStreamId $contentStreamId,
NodeAggregateId $nodeAggregateId,
OriginDimensionSpacePoint $originDimensionSpacePoint
): ?Node {
$query = HypergraphQuery::create($contentStreamId, $this->tableNamePrefix);
$query = $query->withOriginDimensionSpacePoint($originDimensionSpacePoint);
$query = $query->withNodeAggregateId($nodeAggregateId);

$nodeRow = $query->execute($this->getDatabaseConnection())->fetchAssociative();

return $nodeRow ? $this->nodeFactory->mapNodeRowToNode(
$nodeRow,
VisibilityConstraints::withoutRestrictions(),
$originDimensionSpacePoint->toDimensionSpacePoint()
) : null;
}

public function findRootNodeAggregateByType(
ContentStreamId $contentStreamId,
NodeTypeName $nodeTypeName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,6 @@ public function findNodeAggregateById(
*/
public function findUsedNodeTypeNames(): iterable;

/**
* @internal
*/
public function findNodeByIdAndOriginDimensionSpacePoint(
ContentStreamId $contentStreamId,
NodeAggregateId $nodeAggregateId,
OriginDimensionSpacePoint $originDimensionSpacePoint
): ?Node;

/**
* @internal only for consumption inside the Command Handler
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindSucceedingSiblingNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\References;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
Expand Down Expand Up @@ -80,19 +81,18 @@ public function iExpectANodeIdentifiedByXToExistInTheContentGraph(string $serial
{
$nodeDiscriminator = NodeDiscriminator::fromShorthand($serializedNodeDiscriminator);
$this->initializeCurrentNodeFromContentGraph(function (ContentGraphInterface $contentGraph) use ($nodeDiscriminator) {
$currentNode = $contentGraph->findNodeByIdAndOriginDimensionSpacePoint(
$currentNodeAggregate = $contentGraph->findNodeAggregateById(
$nodeDiscriminator->contentStreamId,
$nodeDiscriminator->nodeAggregateId,
$nodeDiscriminator->originDimensionSpacePoint
$nodeDiscriminator->nodeAggregateId
);
Assert::assertNotNull(
$currentNode,
Assert::assertTrue(
$currentNodeAggregate?->occupiesDimensionSpacePoint($nodeDiscriminator->originDimensionSpacePoint),
'Node with aggregate id "' . $nodeDiscriminator->nodeAggregateId->value
. '" and originating in dimension space point "' . $nodeDiscriminator->originDimensionSpacePoint->toJson()
. '" was not found in content stream "' . $nodeDiscriminator->contentStreamId->value . '"'
);

return $currentNode;
return $currentNodeAggregate->getNodeByOccupiedDimensionSpacePoint($nodeDiscriminator->originDimensionSpacePoint);
});
}

Expand Down

0 comments on commit a6d265d

Please sign in to comment.