Skip to content
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 @@ -543,6 +543,7 @@
<Build Include="Stored Procedures\Resources\GetScormContentServerDetailsForLHExternalReference.sql" />
<None Include="Scripts\Post-Deploy\Scripts\Content_Referencing_DataSetup.sql" />
<None Include="Scripts\Pre-Deploy\Scripts\Content Referencing Initialise.sql" />
<Build Include="Stored Procedures\Hierarchy\HierarchyNewNodePathForReferedCatalogue.sql" />
<Build Include="Stored Procedures\Hierarchy\CheckCatalogueHasExternalReference.sql" />
<Build Include="Stored Procedures\Hierarchy\HierarchyEditDeleteNodeReferenceDetails.sql" />
<Build Include="Stored Procedures\Hierarchy\HierarchyEditDeleteResourceReferenceDetails.sql" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-- 03-06-2024 DB Publish NodePathDisplayVersion records.
-- 13-06-2024 DB Publish ResourceReferenceDisplayVersion records.
-- 26-07-2024 SA Remove references to be implemented
-- 21-08-2024 SS Publishing catalogues needs to update referencing catalogues
-- 27-08-2024 SA Moving a folder into a referenced folder should affect all instances of the referenced folder.[added
-- condition to avoid duplicate entries in to NodeLink table]
-- 02-09-2024 DB Remove any deleted NodePathDisplayVersion anf ResourceReferenceDisplayVersion records.
Expand Down Expand Up @@ -560,7 +561,11 @@ BEGIN
AND np.CatalogueNodeId != np.NodeId
AND hed.NodeId IS NULL

----------------------------------------------------------
-- NodePath: generate new NodePath/s for refered Catalogues
----------------------------------------------------------

EXEC [hierarchy].[HierarchyNewNodePathForReferedCatalogue] @HierarchyEditId,@AmendUserId,@AmendDate
----------------------------------------------------------
-- NodePathNode
----------------------------------------------------------
Expand All @@ -576,7 +581,7 @@ BEGIN
SET @NodePathCursor = CURSOR FORWARD_ONLY FOR
SELECT NodePathId, NodeId, ParentNodeId, InitialNodePath, NewNodePath, HierarchyEditDetailOperationId
FROM hierarchy.HierarchyEditDetail
WHERE HierarchyEditId = 80
WHERE HierarchyEditId = @HierarchyEditId
AND ISNULL(InitialNodePath, '') != ISNULL(NewNodePath, InitialNodePath)
AND (
HierarchyEditDetailTypeId = 4 -- Node Link
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
-------------------------------------------------------------------------------
-- Author Sarathlal
-- Created 21-08-2024
-- Purpose Publishing catalogues needs to update referencing catalogues
--
-- Modification History
-- 21-08-2024 SS Initial version
-------------------------------------------------------------------------------
CREATE PROCEDURE [hierarchy].[HierarchyNewNodePathForReferedCatalogue]
(
@HierarchyEditId INT,
@AmendUserId INT,
@AmendDate datetimeoffset(7)
)

AS

BEGIN
BEGIN TRY

BEGIN TRAN
DECLARE @NodePathId int
DECLARE @PrimaryCatalogueNodeId int
DECLARE @NodeId int
DECLARE @ParentNodeId int
DECLARE @NewNodePath as NVARCHAR(256)
DECLARE @DisplayOrder int
DECLARE @NewNodePathCursor as CURSOR
SET @NewNodePathCursor = CURSOR FORWARD_ONLY FOR
SELECT
PrimaryCatalogueNodeId,
ParentNodeId,
NodeId,
hed.NewNodePath,
DisplayOrder,
NodePathId
FROM
hierarchy.HierarchyEditDetail hed
WHERE
HierarchyEditId = @HierarchyEditId
AND
(
HierarchyEditDetailTypeId = 4 -- Node Link
OR
HierarchyEditDetailTypeId = 3 -- Folder Node
)
AND (
HierarchyEditDetailOperationId = 1 -- Add
OR
HierarchyEditDetailOperationId = 2 -- Edit
)
AND NodeLinkId IS NULL
AND [Deleted] = 0
OPEN @NewNodePathCursor;
FETCH NEXT FROM @NewNodePathCursor INTO @PrimaryCatalogueNodeId,@ParentNodeId,@NodeId,@NewNodePath,@DisplayOrder,@NodePathId;
WHILE @@FETCH_STATUS = 0
BEGIN
IF NOT EXISTS (SELECT 1 FROM hierarchy.NodePath WHERE NodeId=@NodeId AND NodePath=NodePath+'\'+CAST(@NodeId AS VARCHAR(100)))
BEGIN
INSERT INTO hierarchy.NodePath (NodeId, NodePath, CatalogueNodeId, IsActive, Deleted, CreateUserId, CreateDate, AmendUserId, AmendDate)
SELECT @NodeId,NP.NodePath+'\'+CAST(@NodeId AS VARCHAR(100)),NP.CatalogueNodeId,1,0,@AmendUserId,@AmendDate,@AmendUserId,@AmendDate FROM
hub.[fn_Split](@NewNodePath, '\') nodeInPath
INNER JOIN hierarchy.NodePath NP ON NP.NodeId=nodeInPath.value AND CatalogueNodeId!=@PrimaryCatalogueNodeId
WHERE nodeInPath.value=@ParentNodeId

END


FETCH NEXT FROM @NewNodePathCursor INTO @PrimaryCatalogueNodeId,@ParentNodeId,@NodeId,@NewNodePath,@DisplayOrder,@NodePathId;

END

CLOSE @NewNodePathCursor;
DEALLOCATE @NewNodePathCursor;
COMMIT

END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;

SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();

IF @@TRANCOUNT > 0
ROLLBACK TRAN;

RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);

END CATCH
END
GO