CREATE PROCEDURE [MIG_SET_TOOLKIT_USER_PREFERENCE_Sp]
( 
	@TargetControlType NVARCHAR(MAX),
	@LegacyPropName NVARCHAR(MAX),
	@LegacyPropGuiType NVARCHAR(MAX),
	@InputPropValue NVARCHAR(MAX),
	@TargetPropValue NVARCHAR(MAX) OUTPUT
)
AS

BEGIN
			-- PROPGUITYPE

			-- 0 - Check-Box
			-- 1 - Dropdown list
			-- 2 - Textbox (directory etc.)
			-- 3 - (plain) Textbox --> to be treated like "Textbox (string mapping)"
			-- 4 - Mapping Rules (Template-ID) --> to be treated like "Textbox (string mapping)"
			-- 5 - Pane/Workarea --> not supported in "pd"
			-- 6 - Project (Reference) --> to be treated like "Textbox (string mapping)"

			IF @LegacyPropGuiType = '0' AND @TargetControlType = 'Check Box'
				SET @TargetPropValue = 
					CASE 
						WHEN @InputPropValue = '1' THEN 
							'1' --yes
						WHEN @InputPropValue = '0' THEN 
							'2' --no
						ELSE
							'2' --default (no)
					END
			ELSE IF @LegacyPropGuiType = '1' AND @TargetControlType = 'Combo Box' 
				BEGIN
					IF @LegacyPropName = 'LOCAL_RELEASE_SYNC'
					  BEGIN
						SET @TargetPropValue = CASE
									  WHEN @InputPropValue = 'YES' THEN 
											'10' --yes
									  WHEN @InputPropValue = 'IGNORE' THEN 
											'20' --ignore
									  WHEN @InputPropValue = 'AUTO_SELECT' THEN 
											'30' --auto.select
									  ELSE 
											'20' --ignore
									END
					  END

					ELSE IF @LegacyPropName = 'LOCAL_SINGLE_FILE_SYNC'
					  BEGIN
						SET @TargetPropValue = CASE
									  WHEN @InputPropValue = 'No auto select' THEN 
											'10' --no.auto.select
									  WHEN @InputPropValue = 'Auto select last effective released' THEN 
											'20' --last.eff.rel
									  WHEN @InputPropValue = 'Auto select current effective released' THEN 
											'30' --curr.eff.rel
									  WHEN @InputPropValue = 'Auto select work in progress' THEN 
											'40' --work.in.progres
									  WHEN @InputPropValue = 'Auto select latest created' THEN 
											'50' --lastc.created
									  ELSE 
											'10' --no.auto.select
									END
					  END

					ELSE IF @LegacyPropName = 'DEFAULT_TAB_FOR_SET_OBJECT_ATTRIBUTES_DIALOG'
					  BEGIN
						SET @TargetPropValue = CASE
									  WHEN @InputPropValue = 'FILE' THEN 
											'10' --file
									  WHEN @InputPropValue = 'DOC' THEN 
											'20' --doc
									  WHEN @InputPropValue = 'ITEM' THEN 
											'30' --item
									  ELSE 
											'10' --file
									END
					  END

					
				END
		
			ELSE
				SET @TargetPropValue = @InputPropValue

END		





