Added logic to only process RO value updates for the specified DocVersion.

This commit is contained in:
Rich
2013-04-08 19:26:16 +00:00
parent d650f1c98b
commit 55f918c150
4 changed files with 222 additions and 12 deletions

View File

@@ -6549,3 +6549,197 @@ GO
IF (@@Error = 0) PRINT 'Trigger alteration: tr_Documents_Delete Succeeded'
ELSE PRINT 'Trigger alteration: tr_Documents_Delete Error on Alteration'
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_GetVersionItems]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
DROP FUNCTION [vefn_GetVersionItems];
GO
/****** Object: UserDefinedFunction [dbo].[vefn_GetVersionItems] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
Select * from vefn_GetVersionItems('')
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2013 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE FUNCTION [dbo].[vefn_GetVersionItems](@DocVersionList varchar(MAX))
RETURNS @VersionItems TABLE
(
VersionID int,
ItemID int,
ContentID int primary key
)
WITH EXECUTE AS OWNER
AS
BEGIN
BEGIN
with Itemz([VersionID], [ItemID], [ContentID]) as
(Select DV.VersionID, [I].[ItemID], [I].[ContentID]
FROM [Items] I
JOIN vefn_DocVersionSplit(@DocVersionList) DV
ON I.[ItemID] = DV.[ItemID]
Union All
-- Children
select Z.VersionID, I.[ItemID], I.[ContentID]
from Itemz Z
join Parts P on P.ContentID = Z.ContentID
join Items I on I.ItemID = P.ItemID
Union All
-- Siblings
select Z.VersionID, I.[ItemID], I.[ContentID]
from Itemz Z
join Items I on I.PreviousID = Z.ItemID
)
insert into @VersionItems
select VersionID, [ItemID], [ContentID]
from ItemZ I
--Select * From rousages RU Where RU.ContentID in (Select ContentID from ItemZ)
OPTION (MAXRECURSION 10000)
END
RETURN
END
go
IF (@@Error = 0) PRINT 'TableFunction [vefn_GetVersionItems] Succeeded'
ELSE PRINT 'TableFunction [vefn_GetVersionItems] Error on Creation'
/****** Object: StoredProcedure [getAffectedRoUsages] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAffectedRoUsages]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getAffectedRoUsages];
GO
/*
getAffectedROUsages 1, '00010000019c0000', 'KBR Test', 'Changed', 'KBR'
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getAffectedRoUsages]
(
@RODbID int,
@ROID nvarchar(16),
@RODesc nvarchar(MAX),
@Command nvarchar(10),
@UserID nvarchar(100),
@VersionList nvarchar(MAX)
)
WITH EXECUTE AS OWNER
AS
BEGIN
DECLARE @JustThisVersion TABLE
(
ContentID int primary key
)
Insert INTO @JustThisVersion
SELECT Distinct ContentID From vefn_GetVersionItems(@VersionList)
DECLARE @typeID int
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
-- Add "Verification Required" Annotation for each ROUsage
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Referenced Object (' + @RODesc + ') ' + @Command,@UserID
FROM Items where CONTENTID in (SELECT ContentID FROM ROUSAGES
where RODbID = @RODbID AND ROID = @ROID AND ContentID in (select ContentID from @JustThisVersion))
SELECT
[RoUsages].[ROUsageID],
[RoUsages].[ContentID],
[RoUsages].[ROID],
[RoUsages].[Config],
[RoUsages].[DTS],
[RoUsages].[UserID],
[RoUsages].[LastChanged],
[RoUsages].[RODbID],
[Contents].[Number] [Content_Number],
[Contents].[Text] [Content_Text],
[Contents].[Type] [Content_Type],
[Contents].[FormatID] [Content_FormatID],
[Contents].[Config] [Content_Config],
[Contents].[DTS] [Content_DTS],
[Contents].[UserID] [Content_UserID]
FROM [RoUsages]
JOIN [Contents] ON
[Contents].[ContentID]=[RoUsages].[ContentID]
WHERE
[RoUsages].[RODbID]=@RODbID AND [RoUsages].[ROID]=@ROID
AND [Contents].ContentID in (select ContentID from @JustThisVersion)
END
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getAffectedRoUsages Succeeded'
ELSE PRINT 'Procedure Creation: getAffectedRoUsages Error on Creation'
GO
/****** Object: StoredProcedure [getAffectedDRoUsages] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAffectedDRoUsages]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getAffectedDRoUsages];
GO
/*
getAffectedDROUsages 1, '00010000019c0000', 'KBR Test', 'Changed', 'KBR'
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getAffectedDRoUsages]
(
@RODbID int,
@ROID nvarchar(16),
@RODesc nvarchar(MAX),
@Command nvarchar(10),
@UserID nvarchar(100),
@VersionList nvarchar(max)
)
WITH EXECUTE AS OWNER
AS
BEGIN
DECLARE @JustThisVersion TABLE
(
ContentID int primary key
)
Insert INTO @JustThisVersion
SELECT Distinct ContentID From vefn_GetVersionItems(@VersionList)
DECLARE @typeID int
SELECT @typeID = TypeID from AnnotationTypes where Name = 'Verification Required'
-- Add "Verification Required" Annotation for each ROUsage
INSERT INTO [Annotations] ([ItemID],[TypeID],[SearchText],[UserID])
SELECT ItemID, @typeID,'Referenced Object (' + @RODesc + ') ' + @Command,@UserID
FROM Items where CONTENTID in (SELECT ContentID
FROM DROUsages DR
JOIN Entries EE on EE.DocID = DR.DocID
where RODbID = @RODbID AND ROID = @ROID AND ContentID in (select ContentID from @JustThisVersion))
SELECT
[DROUsages].[DROUsageID],
[DROUsages].[DocID],
[DROUsages].[ROID],
[DROUsages].[Config],
[DROUsages].[DTS],
[DROUsages].[UserID],
[DROUsages].[LastChanged],
[DROUsages].[RODbID],
[Documents].[LibTitle] [Document_LibTitle],
[Documents].[DocContent] [Document_DocContent],
[Documents].[DocAscii] [Document_DocAscii],
[Documents].[Config] [Document_Config],
[Documents].[DTS] [Document_DTS],
[Documents].[UserID] [Document_UserID],
[Documents].[FileExtension] [Document_FileExtension]
FROM [DRoUsages]
JOIN [Documents] ON
[Documents].[DocID]=[DROUsages].[DocID]
WHERE
[DRoUsages].[RODbID]=@RODbID AND [DRoUsages].[ROID]=@ROID
AND [Documents].[DocID] in (select EE.DocID from Entries EE where ContentID in (select ContentID from @JustThisVersion))
RETURN
END
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getAffectedDRoUsages Succeeded'
ELSE PRINT 'Procedure Creation: getAffectedDRoUsages Error on Creation'
GO