Skip to content

Commit

Permalink
!!! TASK: rename contentStreamIdentifier to contentStreamId (changes …
Browse files Browse the repository at this point in the history
…DB schemata - projection update needed)
  • Loading branch information
skurfuerst committed Mar 18, 2023
1 parent 17cf419 commit d9c374a
Show file tree
Hide file tree
Showing 49 changed files with 329 additions and 328 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ private function whenContentStreamWasForked(ContentStreamWasForked $event): void
{
$this->transactional(function () use ($event) {
$parameters = [
'sourceContentStreamIdentifier' => (string)$event->sourceContentStreamId,
'targetContentStreamIdentifier' => (string)$event->newContentStreamId
'sourceContentStreamId' => (string)$event->sourceContentStreamId,
'targetContentStreamId' => (string)$event->newContentStreamId
];

$this->getDatabaseConnection()->executeQuery(/** @lang PostgreSQL */
'INSERT INTO ' . $this->tableNamePrefix . '_hierarchyhyperrelation
(contentstreamidentifier, parentnodeanchor,
(contentstreamid, parentnodeanchor,
dimensionspacepoint, dimensionspacepointhash, childnodeanchors)
SELECT :targetContentStreamIdentifier, parentnodeanchor,
SELECT :targetContentStreamId, parentnodeanchor,
dimensionspacepoint, dimensionspacepointhash, childnodeanchors
FROM ' . $this->tableNamePrefix . '_hierarchyhyperrelation source
WHERE source.contentstreamidentifier = :sourceContentStreamIdentifier',
WHERE source.contentstreamid = :sourceContentStreamId',
$parameters
);

$this->getDatabaseConnection()->executeQuery(/** @lang PostgreSQL */
'INSERT INTO ' . $this->tableNamePrefix . '_restrictionhyperrelation
(contentstreamidentifier, dimensionspacepointhash,
(contentstreamid, dimensionspacepointhash,
originnodeaggregateidentifier, affectednodeaggregateidentifiers)
SELECT :targetContentStreamIdentifier, dimensionspacepointhash,
SELECT :targetContentStreamId, dimensionspacepointhash,
originnodeaggregateidentifier, affectednodeaggregateidentifiers
FROM ' . $this->tableNamePrefix . '_restrictionhyperrelation source
WHERE source.contentstreamidentifier = :sourceContentStreamIdentifier',
WHERE source.contentstreamid = :sourceContentStreamId',
$parameters
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait CopyOnWrite
* @throws \Throwable
*/
public function copyOnWrite(
ContentStreamId $originContentStreamIdentifier,
ContentStreamId $originContentStreamId,
NodeRecord $originNode,
callable $preprocessor
): NodeRelationAnchorPoint {
Expand All @@ -46,13 +46,13 @@ public function copyOnWrite(
$copiedNode->addToDatabase($this->getDatabaseConnection(), $this->tableNamePrefix);

$this->reassignIngoingHierarchyRelations(
$originContentStreamIdentifier,
$originContentStreamId,
$originNode->relationAnchorPoint,
$copiedNodeRelationAnchorPoint
);

$this->reassignOutgoingHierarchyRelations(
$originContentStreamIdentifier,
$originContentStreamId,
$originNode->relationAnchorPoint,
$copiedNodeRelationAnchorPoint
);
Expand All @@ -76,13 +76,13 @@ public function copyOnWrite(
* @throws \Doctrine\DBAL\Exception
*/
private function reassignIngoingHierarchyRelations(
ContentStreamId $originContentStreamIdentifier,
ContentStreamId $originContentStreamId,
NodeRelationAnchorPoint $originRelationAnchorPoint,
NodeRelationAnchorPoint $targetRelationAnchorPoint
): void {
foreach (
$this->getProjectionHypergraph()->findIngoingHierarchyHyperrelationRecords(
$originContentStreamIdentifier,
$originContentStreamId,
$originRelationAnchorPoint
) as $ingoingHierarchyRelation
) {
Expand All @@ -99,13 +99,13 @@ private function reassignIngoingHierarchyRelations(
* @throws \Doctrine\DBAL\Exception
*/
private function reassignOutgoingHierarchyRelations(
ContentStreamId $originContentStreamIdentifier,
ContentStreamId $originContentStreamId,
NodeRelationAnchorPoint $originRelationAnchorPoint,
NodeRelationAnchorPoint $targetRelationAnchorPoint
): void {
foreach (
$this->getProjectionHypergraph()->findOutgoingHierarchyHyperrelationRecords(
$originContentStreamIdentifier,
$originContentStreamId,
$originRelationAnchorPoint
) as $outgoingHierarchyRelation
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ public function whenNodeAggregateWithNodeWasCreated(NodeAggregateWithNodeWasCrea
* @throws \Doctrine\DBAL\Driver\Exception
*/
protected function connectToHierarchy(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
NodeRelationAnchorPoint $parentNodeAnchor,
NodeRelationAnchorPoint $childNodeAnchor,
DimensionSpacePointSet $dimensionSpacePointSet,
?NodeRelationAnchorPoint $succeedingSiblingNodeAnchor
): void {
foreach ($dimensionSpacePointSet as $dimensionSpacePoint) {
$hierarchyRelation = $this->getProjectionHypergraph()->findHierarchyHyperrelationRecordByParentNodeAnchor(
$contentStreamIdentifier,
$contentStreamId,
$dimensionSpacePoint,
$parentNodeAnchor
);
Expand All @@ -168,7 +168,7 @@ protected function connectToHierarchy(
);
} else {
$hierarchyRelation = new HierarchyHyperrelationRecord(
$contentStreamIdentifier,
$contentStreamId,
$parentNodeAnchor,
$dimensionSpacePoint,
NodeRelationAnchorPoints::fromArray([$childNodeAnchor])
Expand All @@ -183,14 +183,14 @@ protected function connectToHierarchy(
* @throws \Doctrine\DBAL\Driver\Exception
*/
protected function connectToRestrictionRelations(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
DimensionSpacePoint $dimensionSpacePoint,
NodeAggregateId $parentNodeAggregateIdentifier,
NodeAggregateId $affectedNodeAggregateIdentifier
): void {
foreach (
$this->getProjectionHypergraph()->findIngoingRestrictionRelations(
$contentStreamIdentifier,
$contentStreamId,
$dimensionSpacePoint,
$parentNodeAggregateIdentifier
) as $ingoingRestrictionRelation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private function whenNodeAggregateWasRemoved(NodeAggregateWasRemoved $event): vo
LEFT JOIN ' . $this->tableNamePrefix . '_hierarchyhyperrelation h
ON n.relationanchorpoint = ANY(h.childnodeanchors)
WHERE n.relationanchorpoint IN (:affectedRelationAnchorPoints)
AND h.contentstreamidentifier IS NULL
AND h.contentstreamid IS NULL
)
RETURNING relationanchorpoint
)
Expand All @@ -113,13 +113,13 @@ private function whenNodeAggregateWasRemoved(NodeAggregateWasRemoved $event): vo
* @param array<int,NodeRelationAnchorPoint> &$affectedRelationAnchorPoints
*/
private function cascadeHierarchy(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
DimensionSpacePoint $dimensionSpacePoint,
NodeRelationAnchorPoint $nodeRelationAnchorPoint,
array &$affectedRelationAnchorPoints
): void {
$childHierarchyRelation = $this->getProjectionHypergraph()->findHierarchyHyperrelationRecordByParentNodeAnchor(
$contentStreamIdentifier,
$contentStreamId,
$dimensionSpacePoint,
$nodeRelationAnchorPoint
);
Expand All @@ -141,12 +141,12 @@ private function cascadeHierarchy(
$affectedRelationAnchorPoints[] = $nodeRecord->relationAnchorPoint;
}
$this->removeFromRestrictions(
$contentStreamIdentifier,
$contentStreamId,
$dimensionSpacePoint,
$nodeRecord->nodeAggregateIdentifier
);
$this->cascadeHierarchy(
$contentStreamIdentifier,
$contentStreamId,
$dimensionSpacePoint,
$nodeRecord->relationAnchorPoint,
$affectedRelationAnchorPoints
Expand All @@ -156,20 +156,20 @@ private function cascadeHierarchy(
}

/**
* @param ContentStreamId $contentStreamIdentifier
* @param ContentStreamId $contentStreamId
* @param DimensionSpacePoint $dimensionSpacePoint
* @param NodeAggregateId $nodeAggregateIdentifier
* @throws \Doctrine\DBAL\Driver\Exception
* @throws \Doctrine\DBAL\Exception
*/
private function removeFromRestrictions(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
DimensionSpacePoint $dimensionSpacePoint,
NodeAggregateId $nodeAggregateIdentifier
): void {
foreach (
$this->getProjectionHypergraph()->findIngoingRestrictionRelations(
$contentStreamIdentifier,
$contentStreamId,
$dimensionSpacePoint,
$nodeAggregateIdentifier
) as $restrictionRelation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected function copyNodeToOriginDimensionSpacePoint(
* @throws \Doctrine\DBAL\Exception
*/
protected function replaceNodeRelationAnchorPoint(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
NodeAggregateId $affectedNodeAggregateIdentifier,
DimensionSpacePointSet $affectedDimensionSpacePointSet,
NodeRelationAnchorPoint $newNodeRelationAnchorPoint
Expand All @@ -241,12 +241,12 @@ protected function replaceNodeRelationAnchorPoint(
SELECT relationanchorpoint FROM ' . $this->tableNamePrefix . '_node n
JOIN ' . $this->tableNamePrefix . '_hierarchyhyperrelation p
ON n.relationanchorpoint = ANY(p.childnodeanchors)
WHERE p.contentstreamidentifier = :contentStreamIdentifier
WHERE p.contentstreamid = :contentStreamId
AND p.dimensionspacepointhash = :affectedDimensionSpacePointHash
AND n.nodeaggregateidentifier = :affectedNodeAggregateIdentifier
)';
$parameters = [
'contentStreamIdentifier' => (string)$contentStreamIdentifier,
'contentStreamId' => (string)$contentStreamId,
'newNodeRelationAnchorPoint' => (string)$newNodeRelationAnchorPoint,
'affectedNodeAggregateIdentifier' => (string)$affectedNodeAggregateIdentifier
];
Expand All @@ -255,7 +255,7 @@ protected function replaceNodeRelationAnchorPoint(
$currentNodeAnchorPointStatement . '
UPDATE ' . $this->tableNamePrefix . '_hierarchyhyperrelation
SET parentnodeanchor = :newNodeRelationAnchorPoint
WHERE contentstreamidentifier = :contentStreamIdentifier
WHERE contentstreamid = :contentStreamId
AND dimensionspacepointhash = :affectedDimensionSpacePointHash
AND parentnodeanchor = (SELECT relationanchorpoint FROM currentNodeAnchorPoint)
';
Expand All @@ -267,7 +267,7 @@ protected function replaceNodeRelationAnchorPoint(
(SELECT relationanchorpoint FROM currentNodeAnchorPoint),
:newNodeRelationAnchorPoint
)
WHERE contentstreamidentifier = :contentStreamIdentifier
WHERE contentstreamid = :contentStreamId
AND dimensionspacepointhash = :affectedDimensionSpacePointHash
AND (SELECT relationanchorpoint FROM currentNodeAnchorPoint) = ANY(childnodeanchors)
';
Expand All @@ -278,7 +278,7 @@ protected function replaceNodeRelationAnchorPoint(
}

protected function addMissingHierarchyRelations(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
NodeAggregateId $nodeAggregateIdentifier,
OriginDimensionSpacePoint $sourceOrigin,
NodeRelationAnchorPoint $targetRelationAnchor,
Expand All @@ -287,13 +287,13 @@ protected function addMissingHierarchyRelations(
): void {
$missingCoverage = $coverage->getDifference(
$this->getProjectionHyperGraph()->findCoverageByNodeAggregateIdentifier(
$contentStreamIdentifier,
$contentStreamId,
$nodeAggregateIdentifier
)
);
if ($missingCoverage->count() > 0) {
$sourceParentNode = $this->getProjectionHyperGraph()->findParentNodeRecordByOrigin(
$contentStreamIdentifier,
$contentStreamId,
$sourceOrigin,
$nodeAggregateIdentifier
);
Expand All @@ -302,7 +302,7 @@ protected function addMissingHierarchyRelations(
}
$parentNodeAggregateIdentifier = $sourceParentNode->nodeAggregateIdentifier;
$sourceSucceedingSiblingNode = $this->getProjectionHyperGraph()->findParentNodeRecordByOrigin(
$contentStreamIdentifier,
$contentStreamId,
$sourceOrigin,
$nodeAggregateIdentifier
);
Expand All @@ -312,15 +312,15 @@ protected function addMissingHierarchyRelations(

// First we check for an already existing hyperrelation
$hierarchyRelation = $this->getProjectionHyperGraph()->findChildHierarchyHyperrelationRecord(
$contentStreamIdentifier,
$contentStreamId,
$uncoveredDimensionSpacePoint,
$parentNodeAggregateIdentifier
);

if ($hierarchyRelation && $sourceSucceedingSiblingNode) {
// If it exists, we need to look for a succeeding sibling to keep some order of nodes
$targetSucceedingSibling = $this->getProjectionHyperGraph()->findNodeRecordByCoverage(
$contentStreamIdentifier,
$contentStreamId,
$uncoveredDimensionSpacePoint,
$sourceSucceedingSiblingNode->nodeAggregateIdentifier
);
Expand All @@ -333,7 +333,7 @@ protected function addMissingHierarchyRelations(
);
} else {
$targetParentNode = $this->getProjectionHyperGraph()->findNodeRecordByCoverage(
$contentStreamIdentifier,
$contentStreamId,
$uncoveredDimensionSpacePoint,
$parentNodeAggregateIdentifier
);
Expand All @@ -343,7 +343,7 @@ protected function addMissingHierarchyRelations(
);
}
$hierarchyRelation = new HierarchyHyperrelationRecord(
$contentStreamIdentifier,
$contentStreamId,
$targetParentNode->relationAnchorPoint,
$uncoveredDimensionSpacePoint,
NodeRelationAnchorPoints::fromArray([$targetRelationAnchor])
Expand All @@ -358,14 +358,14 @@ protected function addMissingHierarchyRelations(
* @throws \Doctrine\DBAL\Exception
*/
protected function assignNewChildNodeToAffectedHierarchyRelations(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
NodeRelationAnchorPoint $oldChildAnchor,
NodeRelationAnchorPoint $newChildAnchor,
DimensionSpacePointSet $affectedDimensionSpacePoints
): void {
foreach (
$this->getProjectionHyperGraph()->findIngoingHierarchyHyperrelationRecords(
$contentStreamIdentifier,
$contentStreamId,
$oldChildAnchor,
$affectedDimensionSpacePoints
) as $ingoingHierarchyHyperrelationRecord
Expand All @@ -383,14 +383,14 @@ protected function assignNewChildNodeToAffectedHierarchyRelations(
* @throws \Doctrine\DBAL\Exception
*/
protected function assignNewParentNodeToAffectedHierarchyRelations(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
NodeRelationAnchorPoint $oldParentAnchor,
NodeRelationAnchorPoint $newParentAnchor,
DimensionSpacePointSet $affectedDimensionSpacePoints
): void {
foreach (
$this->getProjectionHyperGraph()->findOutgoingHierarchyHyperrelationRecords(
$contentStreamIdentifier,
$contentStreamId,
$oldParentAnchor,
$affectedDimensionSpacePoints
) as $outgoingHierarchyHyperrelationRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
final class HierarchyHyperrelationRecord
{
public ContentStreamId $contentStreamIdentifier;
public ContentStreamId $contentStreamId;

public DimensionSpacePoint $dimensionSpacePoint;

Expand All @@ -38,12 +38,12 @@ final class HierarchyHyperrelationRecord
public NodeRelationAnchorPoints $childNodeAnchors;

public function __construct(
ContentStreamId $contentStreamIdentifier,
ContentStreamId $contentStreamId,
NodeRelationAnchorPoint $parentNodeAnchor,
DimensionSpacePoint $dimensionSpacePoint,
NodeRelationAnchorPoints $childNodeAnchorPoints
) {
$this->contentStreamIdentifier = $contentStreamIdentifier;
$this->contentStreamId = $contentStreamId;
$this->parentNodeAnchor = $parentNodeAnchor;
$this->dimensionSpacePoint = $dimensionSpacePoint;
$this->childNodeAnchors = $childNodeAnchorPoints;
Expand All @@ -55,7 +55,7 @@ public function __construct(
public static function fromDatabaseRow(array $databaseRow): self
{
return new self(
ContentStreamId::fromString($databaseRow['contentstreamidentifier']),
ContentStreamId::fromString($databaseRow['contentstreamid']),
NodeRelationAnchorPoint::fromString($databaseRow['parentnodeanchor']),
DimensionSpacePoint::fromJsonString($databaseRow['dimensionspacepoint']),
NodeRelationAnchorPoints::fromDatabaseString(
Expand Down Expand Up @@ -145,7 +145,7 @@ public function addToDatabase(Connection $databaseConnection, string $tableNameP
$databaseConnection->insert(
$tableNamePrefix . '_hierarchyhyperrelation',
[
'contentstreamidentifier' => $this->contentStreamIdentifier,
'contentstreamid' => $this->contentStreamId,
'parentnodeanchor' => $this->parentNodeAnchor,
'dimensionspacepoint' => \json_encode($this->dimensionSpacePoint),
'dimensionspacepointhash' => $this->dimensionSpacePoint->hash,
Expand All @@ -168,7 +168,7 @@ public function removeFromDatabase(Connection $databaseConnection, string $table
public function getDatabaseIdentifier(): array
{
return [
'contentstreamidentifier' => (string)$this->contentStreamIdentifier,
'contentstreamid' => (string)$this->contentStreamId,
'parentnodeanchor' => (string)$this->parentNodeAnchor,
'dimensionspacepointhash' => $this->dimensionSpacePoint->hash
];
Expand Down
Loading

0 comments on commit d9c374a

Please sign in to comment.