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

9.0 Working with NodeAggregate is not easy #4830

Open
mhsdesign opened this issue Jan 13, 2024 · 1 comment
Open

9.0 Working with NodeAggregate is not easy #4830

mhsdesign opened this issue Jan 13, 2024 · 1 comment
Labels

Comments

@mhsdesign
Copy link
Member

mhsdesign commented Jan 13, 2024

Sometimes there is the usecase of having a "global" across dimension identical node, and the closest thing to that is operating on the node aggregate. For example i experimented with replacing the site entity with the node aggregate of the siteNode. This experiment can be found here #4780.

But this practice doesnt seem to be intentioned and there are multiple stones in ones way on the php api and maybe even deeper in the concept.

I stumbled for example across:

  • NodeAggregate does not know it contentRepositoryId (can be achieved via return current($this->nodesByOccupiedDimensionSpacePoint)->subgraphIdentity->contentRepositoryId;)
  • node references (of scope aggregate) setting is not straight forward
  • node property (of scope aggregate) setting is not straight forward
  • node property of scope aggregate reading is not straight forward -> see pr and description WIP improve NodeAggregate scoped properties #4779
    • for the case one is interested in a single arbitrary node - for reading its aggregate scoped properties - one must retrieve it via a hack
  • creating a node aggregate in all dimensions is not straight forward -> as one needs an $arbitraryRootDimensionSpacePoint and use CreateNodeVariant?
    $rootDimensionSpacePoints = $this->interDimensionalVariationGraph->getRootGeneralizations();
    if (empty($rootDimensionSpacePoints)) {
    throw new \InvalidArgumentException(
    'The dimension space is empty, please check your configuration.',
    1651957153
    );
    }
    $arbitraryRootDimensionSpacePoint = array_shift($rootDimensionSpacePoints);
    $siteNodeAggregateId = NodeAggregateId::create();
    $this->contentRepository->handle(CreateNodeAggregateWithNode::create(
    $liveContentStreamId,
    $siteNodeAggregateId,
    NodeTypeName::fromString($nodeTypeName),
    OriginDimensionSpacePoint::fromDimensionSpacePoint($arbitraryRootDimensionSpacePoint),
    $sitesNodeIdentifier,
    null,
    $site->getNodeName()->toNodeName(),
    PropertyValuesToWrite::fromArray([
    'title' => $site->getName()
    ])
    ))->block();
    // Handle remaining root dimension space points by creating peer variants
    foreach ($rootDimensionSpacePoints as $rootDimensionSpacePoint) {
    $this->contentRepository->handle(CreateNodeVariant::create(
    $liveContentStreamId,
    $siteNodeAggregateId,
    OriginDimensionSpacePoint::fromDimensionSpacePoint($arbitraryRootDimensionSpacePoint),
    OriginDimensionSpacePoint::fromDimensionSpacePoint($rootDimensionSpacePoint),
    ))->block();
    }
    }
  • deleting the node across all dimensions is not straight forward -> as one needs an $arbitraryDimensionSpacePoint
    public function removeSiteNode(SiteNodeName $siteNodeName): void
    {
    $dimensionSpacePoints = $this->interDimensionalVariationGraph->getDimensionSpacePoints()->points;
    $arbitraryDimensionSpacePoint = reset($dimensionSpacePoints) ?: null;
    if (!$arbitraryDimensionSpacePoint instanceof DimensionSpacePoint) {
    throw new \InvalidArgumentException(
    'Cannot prune site "' . $siteNodeName->toNodeName()->value
    . '" due to the dimension space being empty',
    1651921482
    );
    }
    $contentGraph = $this->contentRepository->getContentGraph();
    foreach ($this->contentRepository->getContentStreamFinder()->findAllIds() as $contentStreamId) {
    $sitesNodeAggregate = $contentGraph->findRootNodeAggregateByType(
    $contentStreamId,
    NodeTypeNameFactory::forSites()
    );
    $siteNodeAggregates = $contentGraph->findChildNodeAggregatesByName(
    $contentStreamId,
    $sitesNodeAggregate->nodeAggregateId,
    $siteNodeName->toNodeName()
    );
    foreach ($siteNodeAggregates as $siteNodeAggregate) {
    assert($siteNodeAggregate instanceof NodeAggregate);
    $this->contentRepository->handle(RemoveNodeAggregate::create(
    $contentStreamId,
    $siteNodeAggregate->nodeAggregateId,
    $arbitraryDimensionSpacePoint,
    NodeVariantSelectionStrategy::STRATEGY_ALL_VARIANTS,
    ));
    }
    }
    }
@mhsdesign
Copy link
Member Author

Scoped properties:

We can possibly add new high level node set properties commands, that will only operate on scoped properties.
Because otherwise one needs to add a random dsp which will be ignored at the end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant