C2025-022-Remove-UCF-2
This commit is contained in:
@@ -14765,36 +14765,11 @@ IF (@@Error = 0) PRINT 'StoredProcedure [getJustFormat] Succeeded'
|
||||
ELSE PRINT 'StoredProcedure [getJustFormat] Error on Creation'
|
||||
go
|
||||
|
||||
|
||||
-- Remove getFormatNoUCF from DB (UCF) no longer used.
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getFormatNoUCF]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getFormatNoUCF];
|
||||
GO
|
||||
CREATE PROCEDURE [dbo].[getFormatNoUCF]
|
||||
(
|
||||
@FormatID int
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[FormatID],
|
||||
[ParentID],
|
||||
[Name],
|
||||
[Description],
|
||||
[Data],
|
||||
[Config],
|
||||
[GenMac],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(*) FROM [Contents] WHERE [Contents].[FormatID]=[Formats].[FormatID]) [ContentCount],
|
||||
(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[FormatID]=[Formats].[FormatID]) [DocVersionCount],
|
||||
(SELECT COUNT(*) FROM [Folders] WHERE [Folders].[FormatID]=[Formats].[FormatID]) [FolderCount],
|
||||
(SELECT COUNT(*) FROM [Formats] [Children] WHERE [Children].[ParentID]=[Formats].[FormatID]) [ChildCount]
|
||||
FROM [Formats]
|
||||
WHERE [FormatID]=@FormatID
|
||||
|
||||
RETURN
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'StoredProcedure [getFormatNoUCF] Succeeded'
|
||||
ELSE PRINT 'StoredProcedure [getFormatNoUCF] Error on Creation'
|
||||
@@ -14981,100 +14956,10 @@ IF (@@Error = 0) PRINT 'StoredProcedure [vefn_GetFolderMatchingFormatItems] Succ
|
||||
ELSE PRINT 'StoredProcedure [vefn_GetFolderMatchingFormatItems] Error on Creation'
|
||||
go
|
||||
|
||||
-- Remove vesp_ClearOverrideFormatsByFolder (UCF) from DB. No longer used.
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_ClearOverrideFormatsByFolder]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [vesp_ClearOverrideFormatsByFolder];
|
||||
GO
|
||||
CREATE PROCEDURE [dbo].[vesp_ClearOverrideFormatsByFolder](@FolderID int, @FormatID int, @NewFormatID int)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @ClearedContents TABLE
|
||||
(
|
||||
ContentID int
|
||||
)
|
||||
DECLARE @ClearedFolders TABLE
|
||||
(
|
||||
FolderID int
|
||||
)
|
||||
DECLARE @ClearedDocVersions TABLE
|
||||
(
|
||||
VersionID int
|
||||
)
|
||||
|
||||
insert into @ClearedContents
|
||||
select cc.ContentID from (select contentid from contents where formatid is not null) cc
|
||||
join vefn_GetFolderMatchingFormatItems(@FolderID, @FormatID, @NewFormatID) vi on vi.ContentID = cc.ContentID
|
||||
|
||||
-- update any folders & docversions that are using that formatid to clear them, i.e. so they inherit. To do this
|
||||
-- get lists of folders & docversions that have non-null format ids that should be null.
|
||||
|
||||
BEGIN
|
||||
With Folderz([FolderID], [FormatID]) as
|
||||
(
|
||||
select FF.FolderID, FF.FormatID from Folders FF
|
||||
Where FF.FolderID = @FolderID
|
||||
UNION ALL
|
||||
select FF.FolderID, FF.FormatID from Folders FF
|
||||
Join Folderz ZZ on FF.ParentID = ZZ.FolderID
|
||||
Where FF.FolderID != @FolderID and (FF.FormatID is null or FF.FormatID = @FormatID or FF.FormatID = @NewFormatID)
|
||||
)
|
||||
insert into @ClearedFolders
|
||||
select ZZ.FolderID
|
||||
from Folderz ZZ
|
||||
where ZZ.FormatID is not null and ZZ.FolderID != @FolderID -- don't include folder passed in, only do children (folder is done in code)
|
||||
OPTION (MAXRECURSION 10000)
|
||||
END
|
||||
|
||||
BEGIN
|
||||
With Folderz([FolderID]) as
|
||||
(
|
||||
select FF.FolderID from Folders FF
|
||||
Where FF.FolderID = @FolderID
|
||||
UNION ALL
|
||||
select FF.FolderID from Folders FF
|
||||
Join Folderz ZZ on FF.ParentID = ZZ.FolderID
|
||||
Where FF.FolderID != @FolderID and (FF.FormatID is null or FF.FormatID = @FormatID or FF.FormatID = @NewFormatID)
|
||||
)
|
||||
insert into @ClearedDocVersions
|
||||
select DV.VersionID
|
||||
from Folderz ZZ
|
||||
Left Join DocVersions DV ON DV.FolderID = ZZ.FolderID
|
||||
where VersionID is not null and DV.FormatID is not null and (DV.FormatID = @FormatID or DV.FormatID = @NewFormatID)
|
||||
OPTION (MAXRECURSION 10000)
|
||||
END
|
||||
update Folders set formatid = null where FolderID in (select FolderID from @ClearedFolders)
|
||||
update DocVersions set formatid = null where VersionID in (select VersionID from @ClearedDocVersions)
|
||||
|
||||
-- now update all of the contents that were found
|
||||
update contents set formatid = null where contentID in (select contentid from @ClearedContents)
|
||||
|
||||
select [ContentID],
|
||||
[Number],
|
||||
[Text],
|
||||
[Type],
|
||||
[FormatID],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[Contents].[ContentID]) [DetailCount],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[Contents].[ContentID]) [EntryCount],
|
||||
(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[Contents].[ContentID]) [GridCount],
|
||||
(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[Contents].[ContentID]) [ImageCount],
|
||||
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[Contents].[ContentID]) [ItemCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[Contents].[ContentID]) [PartCount],
|
||||
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[Contents].[ContentID]) [RoUsageCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[Contents].[ContentID]) [TransitionCount],
|
||||
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[Contents].[ContentID]) [ZContentCount]
|
||||
FROM contents where contentid in (select ContentID from @ClearedContents)
|
||||
RETURN
|
||||
END
|
||||
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_ClearOverrideFormatsByFolder Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: vesp_ClearOverrideFormatsByFolder Error on Creation'
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_ClearOverrideFormatsByDocVersion]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [vesp_ClearOverrideFormatsByDocVersion];
|
||||
|
Reference in New Issue
Block a user