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

TASK: Add workspaceName to nodeAggregate #5063

Merged
merged 3 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ public function mapNodeRowsToNodeAggregate(

// a nodeAggregate only exists if it at least contains one node
assert($nodesByOccupiedDimensionSpacePoint !== []);
$primaryNode = current($nodesByOccupiedDimensionSpacePoint);

return new NodeAggregate(
$primaryNode->subgraphIdentity->contentStreamId,
return NodeAggregate::create(
$this->contentRepositoryId,
$workspaceName,
NodeAggregateId::fromString($rawNodeAggregateId),
NodeAggregateClassification::from($rawNodeAggregateClassification),
NodeTypeName::fromString($rawNodeTypeName),
Expand All @@ -235,6 +235,7 @@ public function mapNodeRowsToNodeAggregate(
$nodesByCoveredDimensionSpacePoints,
OriginByCoverage::fromArray($occupationByCovering),
$dimensionSpacePointsBySubtreeTags,
$contentStreamId,
);
}

Expand Down Expand Up @@ -314,9 +315,9 @@ public function mapNodeRowsToNodeAggregates(

foreach ($nodesByOccupiedDimensionSpacePointsByNodeAggregate as $rawNodeAggregateId => $nodes) {
/** @var string $rawNodeAggregateId */
yield new NodeAggregate(
// this line is safe because a nodeAggregate only exists if it at least contains one node.
current($nodes)->subgraphIdentity->contentStreamId,
yield NodeAggregate::create(
$this->contentRepositoryId,
$workspaceName,
NodeAggregateId::fromString($rawNodeAggregateId),
$classificationByNodeAggregate[$rawNodeAggregateId],
$nodeTypeNames[$rawNodeAggregateId],
Expand All @@ -337,6 +338,7 @@ public function mapNodeRowsToNodeAggregates(
$occupationByCoveringByNodeAggregate[$rawNodeAggregateId]
),
$dimensionSpacePointsBySubtreeTagsByNodeAggregate[$rawNodeAggregateId],
$contentStreamId,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ public function mapNodeRowsToNodeAggregate(
}
}

return new NodeAggregate(
$contentStreamId,
return NodeAggregate::create(
$this->contentRepositoryId,
WorkspaceName::fromString('missing'), // todo
$nodeAggregateId,
$nodeAggregateClassification,
$nodeTypeName,
Expand All @@ -257,6 +258,7 @@ public function mapNodeRowsToNodeAggregate(
OriginByCoverage::fromArray($occupationByCovered),
// TODO implement (see \Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory::mapNodeRowsToNodeAggregate())
DimensionSpacePointsBySubtreeTags::create(),
$contentStreamId,
);
}

Expand Down Expand Up @@ -340,8 +342,9 @@ public function mapNodeRowsToNodeAggregates(array $nodeRows, VisibilityConstrain
}

foreach ($nodeAggregateIds as $key => $nodeAggregateId) {
yield new NodeAggregate(
$contentStreamId,
yield NodeAggregate::create(
$this->contentRepositoryId,
WorkspaceName::fromString('missing'), // todo
$nodeAggregateId,
$nodeAggregateClassifications[$key],
$nodeTypeNames[$key],
Expand All @@ -354,6 +357,7 @@ public function mapNodeRowsToNodeAggregates(array $nodeRows, VisibilityConstrain
OriginByCoverage::fromArray($occupationByCovered[$key]),
// TODO implement (see \Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory::mapNodeRowsToNodeAggregates())
DimensionSpacePointsBySubtreeTags::create(),
$contentStreamId,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTag;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateDoesCurrentlyNotCoverDimensionSpacePoint;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateDoesCurrentlyNotOccupyDimensionSpacePoint;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
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\WorkspaceName;

/**
* Node aggregate read model. Returned mainly from {@see ContentGraphInterface}.
Expand All @@ -47,28 +49,34 @@
* This interface is called *Readable* because it exposes read operations on the set of nodes inside
* a single NodeAggregate; often used for constraint checks (in command handlers).
*
* @api except its constructor.
* @api Note: The constructor is not part of the public API
*/
final readonly class NodeAggregate
{
/**
* @internal
* @param ContentStreamId $contentStreamId ID of the content stream of this node aggregate
* This was intermediate part of the node aggregate. Please use {@see $workspaceName} instead.
* @deprecated will be removed before the final 9.0 release
*/
public ContentStreamId $contentStreamId;

/**
* @param ContentRepositoryId $contentRepositoryId The content-repository this node aggregate belongs to
* @param WorkspaceName $workspaceName The workspace of this node aggregate
* @param NodeAggregateId $nodeAggregateId ID of this node aggregate
* @param NodeAggregateClassification $classification whether this aggregate represents a root, regular or tethered node
* @param NodeTypeName $nodeTypeName name of the node type of this aggregate
* @param NodeName|null $nodeName optional name of this aggregate
* @param OriginDimensionSpacePointSet $occupiedDimensionSpacePoints dimension space points this aggregate occupies
* @param NodeAggregateClassification $classification whether this node aggregate represents a root, regular or tethered node
* @param NodeTypeName $nodeTypeName name of the node type of this node aggregate
* @param NodeName|null $nodeName optional name of this node aggregate
* @param OriginDimensionSpacePointSet $occupiedDimensionSpacePoints dimension space points this node aggregate occupies
* @param non-empty-array<string,Node> $nodesByOccupiedDimensionSpacePoint At least one node will be occupied.
* @param CoverageByOrigin $coverageByOccupant
* @param DimensionSpacePointSet $coveredDimensionSpacePoints This node aggregate will cover at least one dimension space.
* @param non-empty-array<string,Node> $nodesByCoveredDimensionSpacePoint At least one node will be covered.
* @param OriginByCoverage $occupationByCovered
* @param DimensionSpacePointsBySubtreeTags $dimensionSpacePointsBySubtreeTags dimension space points for every subtree tag this aggregate is *explicitly* tagged with (excluding inherited tags)
* @param DimensionSpacePointsBySubtreeTags $dimensionSpacePointsBySubtreeTags dimension space points for every subtree tag this node aggregate is *explicitly* tagged with (excluding inherited tags)
*/
// todo add workspace name and content repository id and remove cs id
public function __construct(
public ContentStreamId $contentStreamId,
private function __construct(
public ContentRepositoryId $contentRepositoryId,
public WorkspaceName $workspaceName,
public NodeAggregateId $nodeAggregateId,
public NodeAggregateClassification $classification,
public NodeTypeName $nodeTypeName,
Expand All @@ -80,7 +88,48 @@ public function __construct(
private array $nodesByCoveredDimensionSpacePoint,
private OriginByCoverage $occupationByCovered,
private DimensionSpacePointsBySubtreeTags $dimensionSpacePointsBySubtreeTags,
ContentStreamId $contentStreamId,
) {
$this->contentStreamId = $contentStreamId;
}

/**
* @param non-empty-array<string,Node> $nodesByOccupiedDimensionSpacePoint
* @param non-empty-array<string,Node> $nodesByCoveredDimensionSpacePoint
* @internal The signature of this method can change in the future!
*/
public static function create(
ContentRepositoryId $contentRepositoryId,
WorkspaceName $workspaceName,
NodeAggregateId $nodeAggregateId,
NodeAggregateClassification $classification,
NodeTypeName $nodeTypeName,
?NodeName $nodeName,
OriginDimensionSpacePointSet $occupiedDimensionSpacePoints,
array $nodesByOccupiedDimensionSpacePoint,
CoverageByOrigin $coverageByOccupant,
DimensionSpacePointSet $coveredDimensionSpacePoints,
array $nodesByCoveredDimensionSpacePoint,
OriginByCoverage $occupationByCovered,
DimensionSpacePointsBySubtreeTags $dimensionSpacePointsBySubtreeTags,
ContentStreamId $contentStreamId,
): self {
return new self(
$contentRepositoryId,
$workspaceName,
$nodeAggregateId,
$classification,
$nodeTypeName,
$nodeName,
$occupiedDimensionSpacePoints,
$nodesByOccupiedDimensionSpacePoint,
$coverageByOccupant,
$coveredDimensionSpacePoints,
$nodesByCoveredDimensionSpacePoint,
$occupationByCovered,
$dimensionSpacePointsBySubtreeTags,
$contentStreamId,
);
}

public function occupiesDimensionSpacePoint(OriginDimensionSpacePoint $originDimensionSpacePoint): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\Error\Messages\Message;

final class StructureAdjustment extends Message
Expand Down Expand Up @@ -45,7 +45,7 @@ private function __construct(
}

public static function createForNodeIdentity(
ContentStreamId $contentStreamId,
WorkspaceName $workspaceName,
OriginDimensionSpacePoint $originDimensionSpacePoint,
NodeAggregateId $nodeAggregateId,
string $type,
Expand All @@ -57,7 +57,7 @@ public static function createForNodeIdentity(
. ($remediation ? '' : '!!!NOT AUTO-FIXABLE YET!!! ') . $errorMessage,
null,
[
'contentStream' => $contentStreamId->value,
'workspaceName' => $workspaceName->value,
'dimensionSpacePoint' => $originDimensionSpacePoint->toJson(),
'nodeAggregateId' => $nodeAggregateId->value,
'isAutoFixable' => ($remediation !== null)
Expand All @@ -74,9 +74,9 @@ public static function createForNode(
?\Closure $remediation = null
): self {
return self::createForNodeIdentity(
$node->subgraphIdentity->contentStreamId,
$node->workspaceName,
$node->originDimensionSpacePoint,
$node->nodeAggregateId,
$node->aggregateId,
$type,
$errorMessage,
$remediation
Expand All @@ -90,11 +90,11 @@ public static function createForNodeAggregate(
?\Closure $remediation = null
): self {
return new self(
'Content Stream: %s; Dimension Space Point: %s, Node Aggregate: %s --- '
'Workspace: %s; Dimension Space Point: %s, Node Aggregate: %s --- '
. ($remediation ? '' : '!!!NOT AUTO-FIXABLE YET!!! ') . $errorMessage,
null,
[
'contentStream' => $nodeAggregate->contentStreamId->value,
'workspaceName' => $nodeAggregate->workspaceName->value,
'nodeAggregateId' => $nodeAggregate->nodeAggregateId->value,
'isAutoFixable' => ($remediation !== null)
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Neos\ContentRepository\StructureAdjustment\Adjustment;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace;
use Neos\ContentRepository\Core\EventStore\Events;
use Neos\ContentRepository\Core\EventStore\EventsToPublish;
Expand All @@ -15,16 +14,12 @@
use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName;
use Neos\ContentRepository\Core\Feature\NodeMove\Event\NodeAggregateWasMoved;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\EventStream\ExpectedVersion;

class TetheredNodeAdjustments
Expand Down Expand Up @@ -74,7 +69,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat
// $nestedNode not found
// - so a tethered node is missing in the OriginDimensionSpacePoint of the $node
yield StructureAdjustment::createForNodeIdentity(
$nodeAggregate->contentStreamId,
$nodeAggregate->workspaceName,
$originDimensionSpacePoint,
$nodeAggregate->nodeAggregateId,
StructureAdjustment::TETHERED_NODE_MISSING,
Expand Down Expand Up @@ -140,7 +135,7 @@ function () use ($tetheredNodeAggregate) {
if (array_keys($actualTetheredChildNodes) !== array_keys($nodeType->tetheredNodeTypeDefinitions->toArray())) {
// we need to re-order: We go from the last to the first
yield StructureAdjustment::createForNodeIdentity(
$nodeAggregate->contentStreamId,
$nodeAggregate->workspaceName,
$originDimensionSpacePoint,
$nodeAggregate->nodeAggregateId,
StructureAdjustment::TETHERED_NODE_WRONGLY_ORDERED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ public function iExpectThisNodeAggregateToHaveTheParentNodeAggregates(string $se
$expectedNodeAggregateIds = NodeAggregateIds::fromJsonString($serializedExpectedNodeAggregateIds);
$this->assertOnCurrentNodeAggregate(function (NodeAggregate $nodeAggregate) use ($expectedNodeAggregateIds) {
$expectedDiscriminators = array_values(array_map(function (NodeAggregateId $nodeAggregateId) {
return $this->currentContentStreamId->value . ';' . $nodeAggregateId->value;
return $this->currentWorkspaceName->value . ';' . $nodeAggregateId->value;
}, iterator_to_array($expectedNodeAggregateIds)));
$actualDiscriminators = array_values(array_map(
fn (NodeAggregate $parentNodeAggregate): string
=> $parentNodeAggregate->contentStreamId->value . ';' . $parentNodeAggregate->nodeAggregateId->value,
=> $parentNodeAggregate->workspaceName->value . ';' . $parentNodeAggregate->nodeAggregateId->value,
iterator_to_array(
$this->currentContentRepository->getContentGraph($this->currentWorkspaceName)->findParentNodeAggregates(
$nodeAggregate->nodeAggregateId
Expand Down Expand Up @@ -218,12 +218,12 @@ public function iExpectThisNodeAggregateToHaveTheChildNodeAggregates(string $ser
$expectedNodeAggregateIds = NodeAggregateIds::fromJsonString($serializedExpectedNodeAggregateIds);
$this->assertOnCurrentNodeAggregate(function (NodeAggregate $nodeAggregate) use ($expectedNodeAggregateIds) {
$expectedDiscriminators = array_values(array_map(
fn (NodeAggregateId $nodeAggregateId): string => $this->currentContentStreamId->value . ':' . $nodeAggregateId->value,
fn (NodeAggregateId $nodeAggregateId): string => $this->currentWorkspaceName->value . ':' . $nodeAggregateId->value,
iterator_to_array($expectedNodeAggregateIds)
));
$actualDiscriminators = array_values(array_map(
fn (NodeAggregate $parentNodeAggregate): string
=> $parentNodeAggregate->contentStreamId->value . ':' . $parentNodeAggregate->nodeAggregateId->value,
=> $parentNodeAggregate->workspaceName->value . ':' . $parentNodeAggregate->nodeAggregateId->value,
iterator_to_array($this->currentContentRepository->getContentGraph($this->currentWorkspaceName)->findChildNodeAggregates(
$nodeAggregate->nodeAggregateId
))
Expand Down
Loading