From d5b30b523f5e3c5d0750556a95cb611d0bc7c7ec Mon Sep 17 00:00:00 2001 From: John Date: Thu, 20 Aug 2015 18:57:19 +0000 Subject: [PATCH] Global search fixes for hard spaces, symbols, bolded text, and transition search by step elements (B2014-056, B2014-057, B2014-102, B2015-055) --- PROMS/DataLoader/PROMSFixes.Sql | 116 ++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index 1ba7c1ed..83f74c4c 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -2925,6 +2925,60 @@ IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_ProcedureByProcID Succeeded ELSE PRINT 'TableFunction Creation: vefn_ProcedureByProcID Error on Creation' GO +/****** Object: StoredProcedure [vefn_FindContentText] ******/ +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_FindContentText]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1) + DROP FUNCTION [vefn_FindContentText]; +GO + +/* +SELECT * From vefn_FindContentText('1','%RCP%') +*/ +/***************************************************************************** + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + Copyright 2012 - Volian Enterprises, Inc. All rights reserved. +*****************************************************************************/ +CREATE FUNCTION [dbo].[vefn_FindContentText]( +@DocVersionList nvarchar(MAX) +,@SearchString varchar(MAX) +,@IncludeLinks as int +,@IncludeRtfFormatting as int +,@IncludeSpecialCharacters as int) +RETURNS @FoundContents TABLE +( + ContentID int PRIMARY KEY + ,Type int + ,Text varchar(max) +) +WITH EXECUTE AS OWNER +AS +BEGIN +IF(ISNULL(@DocVersionList,'')='') + BEGIN + INSERT INTO @FoundContents -- Do a case insensitive search + select ContentID,Type,Text from contents + where .dbo.vefn_RemoveExtraText(Replace([Text],'-','\u8209?'),@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS +-- where Replace([Text],'-','\u8209?') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS + --where Replace(Replace([Text],'-','\u8209?'),'\u160?',' ') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS + END +ELSE + BEGIN + INSERT INTO @FoundContents -- Do a case insensitive search + select ContentID,Type,Text from contents + where [ContentID] in (select [ContentID] from vefn_DVContent(@DocVersionList)) + -- bug fix B2014-056 and B2014-102 now use vefn_RemoveExtraText which fixes searching for hard spaces and finding procedure text when it is bolded (or italics or underlined etc) + AND .dbo.vefn_RemoveExtraText(Replace([Text],'-','\u8209?'),@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchString Collate SQL_Latin1_General_CP1_CI_AS + --AND Replace([Text],'-','\u8209?') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS + --AND Replace(Replace([Text],'-','\u8209?'),'\u160?',' ') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS + END + +RETURN +END +GO +-- Display the status of Proc creation +IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_FindContentText Succeeded' +ELSE PRINT 'TableFunction Creation: vefn_FindContentText Error on Creation' +GO + /****** Object: StoredProcedure [vefn_FindText] ******/ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_FindText]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1) DROP FUNCTION [vefn_FindText]; @@ -2972,7 +3026,7 @@ ELSE IF @CaseSensitive = 0 -- Not Case Sensitive BEGIN insert into @FoundContents - select C.ContentID from vefn_FindContentText(@DocVersionList,@SearchStringx) C + select C.ContentID from vefn_FindContentText(@DocVersionList,@SearchStringx,@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) C where (.dbo.vefn_RemoveExtraText(C.Text,@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchStringx Collate SQL_Latin1_General_CP1_CI_AS) AND ((isnull(@StepTypeList,'') = '' /*and dbo.vefn_AllSections(C.Type)>=10000*/) @@ -2992,7 +3046,7 @@ ELSE IF @CaseSensitive = 1 -- Case Sensitive BEGIN insert into @FoundContents - select C.ContentID from vefn_FindContentText(@DocVersionList,@SearchStringx) C + select C.ContentID from vefn_FindContentText(@DocVersionList,@SearchStringx,@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) C where (.dbo.vefn_RemoveExtraText(C.Text,@IncludeLinks, @IncludeRtfFormatting, @IncludeSpecialCharacters) like @SearchStringx Collate SQL_Latin1_General_CP1_CS_AS) AND ((isnull(@StepTypeList,'') = '' /*and dbo.vefn_AllSections(C.Type)>=10000*/) @@ -5843,8 +5897,9 @@ DECLARE @index2 int -- Replace Hard Hyphen with Hyphen SET @text = replace(@text,'\u8209?','-') -- Replace Hard Space with Space -SET @text = replace(@text,'\u160?',' ') -set @text = replace(@text,nchar(160),' ') +-- commenting out the bottom two lines will fix the global search for hard space bug (B2014-056) +--SET @text = replace(@text,'\u160?',' ') +--set @text = replace(@text,nchar(160),' ') -- Strip Links IF @includeLink = 0 -- Remove Links SET @text = [dbo].[vefn_RemoveRange](@text,'') @@ -6196,51 +6251,6 @@ IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_JustSiblingItems Succeeded' ELSE PRINT 'TableFunction Creation: vefn_JustSiblingItems Error on Creation' GO -/****** Object: StoredProcedure [vefn_FindContentText] ******/ -IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_FindContentText]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1) - DROP FUNCTION [vefn_FindContentText]; -GO - -/* -SELECT * From vefn_FindContentText('1','%RCP%') -*/ -/***************************************************************************** - Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE - Copyright 2012 - Volian Enterprises, Inc. All rights reserved. -*****************************************************************************/ -CREATE FUNCTION [dbo].[vefn_FindContentText]( -@DocVersionList nvarchar(MAX) -,@SearchString varchar(MAX)) -RETURNS @FoundContents TABLE -( - ContentID int PRIMARY KEY - ,Type int - ,Text varchar(max) -) -WITH EXECUTE AS OWNER -AS -BEGIN -IF(ISNULL(@DocVersionList,'')='') - BEGIN - INSERT INTO @FoundContents -- Do a case insensitive search - select ContentID,Type,Text from contents - where Replace(Replace([Text],'-','\u8209?'),'\u160?',' ') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS - END -ELSE - BEGIN - INSERT INTO @FoundContents -- Do a case insensitive search - select ContentID,Type,Text from contents - where [ContentID] in (select [ContentID] from vefn_DVContent(@DocVersionList)) - AND Replace(Replace([Text],'-','\u8209?'),'\u160?',' ') like @SearchString Collate SQL_Latin1_General_CP1_CI_AS - END - -RETURN -END -GO --- Display the status of Proc creation -IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_FindContentText Succeeded' -ELSE PRINT 'TableFunction Creation: vefn_FindContentText Error on Creation' -GO /****** Object: StoredProcedure [vesp_ResetFolderManualOrder] ******/ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_ResetFolderManualOrder]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) DROP PROCEDURE [vesp_ResetFolderManualOrder]; @@ -9233,7 +9243,9 @@ CREATE PROCEDURE [dbo].[vesp_SearchTransitions] ( @DocVersionList varchar(max), @TranType int, - @TranCategory varchar(20) + @TranCategory varchar(20), + -- added stepTypeList to fix bug B2015-055 - allows transition search in specified step elements + @StepTypeList varchar(MAX) ) WITH EXECUTE AS OWNER AS @@ -9386,6 +9398,10 @@ BEGIN join @ttmp tt on I.ItemID = tt.itemid join Contents C on C.ContentID = I.ContentID left join Parts P on i.ItemID = P.ItemID + -- Where clase added for bug fix B2015-055 to allow transition search within selected step elements + Where + ((isnull(@StepTypeList,'') = '' /*and dbo.vefn_AllSections(C.Type)>=10000*/) + or ((dbo.vefn_AllSections(C.Type) in (Select ID from vefn_SplitInt(@StepTypeList,','))))) OPTION (MAXRECURSION 10000) RETURN END