Lots of work on U4-2722 Change Property Editors over to use unique alias instead of GUID

it compiles but i haven't had time to test anything yet, will start all unit testing/fixing tomorrow, just needed to save this work somewhere.
This commit is contained in:
Shannon
2013-09-05 18:38:54 +10:00
parent e4cb079ae1
commit 45dabd6293
41 changed files with 716 additions and 331 deletions

View File

@@ -1,191 +1,392 @@
namespace Umbraco.Core
using System;
namespace Umbraco.Core
{
public static partial class Constants
{
/// <summary>
/// Defines the identifiers for Umbraco Property Editors as constants for easy centralized access/management.
/// </summary>
public static class PropertyEditors
{
/// <summary>
/// Used to prefix generic properties that are internal content properties
/// </summary>
public const string InternalGenericPropertiesPrefix = "_umb_";
{
/// <summary>
/// Defines the identifiers for Umbraco Property Editors as constants for easy centralized access/management.
/// </summary>
public static class PropertyEditors
{
/// <summary>
/// Used to prefix generic properties that are internal content properties
/// </summary>
public const string InternalGenericPropertiesPrefix = "_umb_";
/// <summary>
/// Guid for the Checkbox list datatype.
/// </summary>
public const string CheckBoxList = "B4471851-82B6-4C75-AFA4-39FA9C6A75E9";
/// <summary>
/// Guid for the Checkbox list datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string CheckBoxList = "B4471851-82B6-4C75-AFA4-39FA9C6A75E9";
/// <summary>
/// Guid for the Color Picker datatype.
/// </summary>
public const string ColorPicker = "F8D60F68-EC59-4974-B43B-C46EB5677985";
/// <summary>
/// Alias for Checkbox list datatype.
/// </summary>
public const string CheckBoxListAlias = "Umbraco.CheckBoxList";
/// <summary>
/// Guid for the Content Picker datatype.
/// </summary>
public const string ContentPicker = "158AA029-24ED-4948-939E-C3DA209E5FBA";
/// <summary>
/// Guid for the Color Picker datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string ColorPicker = "F8D60F68-EC59-4974-B43B-C46EB5677985";
/// <summary>
/// Guid for the Date datatype.
/// </summary>
public const string Date = "23E93522-3200-44E2-9F29-E61A6FCBB79A";
/// <summary>
/// Alias for the Color Picker datatype.
/// </summary>
public const string ColorPickerAlias = "Umbraco.ColorPickerAlias";
/// <summary>
/// Guid for the Date/Time datatype.
/// </summary>
public const string DateTime = "B6FB1622-AFA5-4BBF-A3CC-D9672A442222";
/// <summary>
/// Guid for the Content Picker datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string ContentPicker = "158AA029-24ED-4948-939E-C3DA209E5FBA";
/// <summary>
/// Guid for the Dictionary Picker datatype.
/// </summary>
public const string DictionaryPicker = "17B70066-F764-407D-AB05-3717F1E1C513";
/// <summary>
/// Alias for the Content Picker datatype.
/// </summary>
public const string ContentPickerAlias = "Umbraco.ContentPickerAlias";
/// <summary>
/// Guid for the Dropdown list datatype.
/// </summary>
public const string DropDownList = "A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6";
/// <summary>
/// Guid for the Date datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string Date = "23E93522-3200-44E2-9F29-E61A6FCBB79A";
/// <summary>
/// Guid for the Dropdown list multiple datatype.
/// </summary>
public const string DropDownListMultiple = "928639ED-9C73-4028-920C-1E55DBB68783";
/// <summary>
/// Alias for the Date datatype.
/// </summary>
public const string DateAlias = "Umbraco.Date";
/// <summary>
/// Guid for the Dropdown list multiple, publish keys datatype.
/// </summary>
public const string DropdownlistMultiplePublishKeys = "928639AA-9C73-4028-920C-1E55DBB68783";
/// <summary>
/// Guid for the Date/Time datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string DateTime = "B6FB1622-AFA5-4BBF-A3CC-D9672A442222";
/// <summary>
/// Guid for the Dropdown list, publishing keys datatype.
/// </summary>
public const string DropdownlistPublishingKeys = "A74EA9E1-8E18-4D2A-8CF6-73C6206C5DA6";
/// <summary>
/// Alias for the Date/Time datatype.
/// </summary>
public const string DateTimeAlias = "Umbraco.DateTime";
/// <summary>
/// Guid for the Folder browser datatype.
/// </summary>
public const string FolderBrowser = "CCCD4AE9-F399-4ED2-8038-2E88D19E810C";
/// <summary>
/// Guid for the Dictionary Picker datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string DictionaryPicker = "17B70066-F764-407D-AB05-3717F1E1C513";
/// <summary>
/// Guid for the Image Cropper datatype.
/// </summary>
public const string ImageCropper = "7A2D436C-34C2-410F-898F-4A23B3D79F54";
/// <summary>
/// Alias for the Dictionary Picker datatype.
/// </summary>
public const string DictionaryPickerAlias = "Umbraco.DictionaryPicker";
/// <summary>
/// Guid for the Integer datatype.
/// </summary>
public const string Integer = "1413AFCB-D19A-4173-8E9A-68288D2A73B8";
/// <summary>
/// Guid for the Dropdown list datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string DropDownList = "A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6";
/// <summary>
/// Guid for the Macro Container datatype.
/// </summary>
public const string MacroContainer = "474FCFF8-9D2D-11DE-ABC6-AD7A56D89593";
/// <summary>
/// Alias for the Dropdown list datatype.
/// </summary>
public const string DropDownListAlias = "Umbraco.DropDown";
/// <summary>
/// Guid for the Media Picker datatype.
/// </summary>
public const string MediaPicker = "EAD69342-F06D-4253-83AC-28000225583B";
/// <summary>
/// Guid for the Dropdown list multiple datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string DropDownListMultiple = "928639ED-9C73-4028-920C-1E55DBB68783";
/// <summary>
/// Guid for the Member Picker datatype.
/// </summary>
public const string MemberPicker = "39F533E4-0551-4505-A64B-E0425C5CE775";
/// <summary>
/// Alias for the Dropdown list multiple datatype.
/// </summary>
public const string DropDownListMultipleAlias = "Umbraco.DropDownMultiple";
/// <summary>
/// Guid for the Multi-Node Tree Picker datatype
/// </summary>
public const string MultiNodeTreePicker = "7E062C13-7C41-4AD9-B389-41D88AEEF87C";
/// <summary>
/// Guid for the Dropdown list multiple, publish keys datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string DropdownlistMultiplePublishKeys = "928639AA-9C73-4028-920C-1E55DBB68783";
/// <summary>
/// Guid for the Multiple Textstring datatype.
/// </summary>
public const string MultipleTextstring = "5359AD0B-06CC-4182-92BD-0A9117448D3F";
/// <summary>
/// Alias for the Dropdown list multiple, publish keys datatype.
/// </summary>
public const string DropdownlistMultiplePublishKeysAlias = "Umbraco.DropdownlistMultiplePublishKeys";
/// <summary>
/// Guid for the No edit datatype.
/// </summary>
public const string NoEdit = "6C738306-4C17-4D88-B9BD-6546F3771597";
/// <summary>
/// Guid for the Dropdown list, publishing keys datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string DropdownlistPublishingKeys = "A74EA9E1-8E18-4D2A-8CF6-73C6206C5DA6";
/// <summary>
/// Guid for the Picker Relations datatype.
/// </summary>
public const string PickerRelations = "83396FF2-2E39-4A90-9066-17F5F3989374";
/// <summary>
/// Alias for the Dropdown list, publishing keys datatype.
/// </summary>
public const string DropdownlistPublishingKeysAlias = "Umbraco.DropdownlistPublishingKeys";
/// <summary>
/// Guid for the Radiobutton list datatype.
/// </summary>
public const string RadioButtonList = "A52C7C1C-C330-476E-8605-D63D3B84B6A6";
/// <summary>
/// Guid for the Folder browser datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string FolderBrowser = "CCCD4AE9-F399-4ED2-8038-2E88D19E810C";
/// <summary>
/// Guid for the Related Links datatype.
/// </summary>
public const string RelatedLinks = "71B8AD1A-8DC2-425C-B6B8-FAA158075E63";
/// <summary>
/// Alias for the Folder browser datatype.
/// </summary>
public const string FolderBrowserAlias = "Umbraco.FolderBrowser";
/// <summary>
/// Guid for the Slider datatype.
/// </summary>
public const string Slider = "29E790E6-26B3-438A-B21F-908663A0B19E";
/// <summary>
/// Guid for the Image Cropper datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string ImageCropper = "7A2D436C-34C2-410F-898F-4A23B3D79F54";
/// <summary>
/// Guid for the Tags datatype.
/// </summary>
public const string Tags = "4023E540-92F5-11DD-AD8B-0800200C9A66";
/// <summary>
/// Alias for the Image Cropper datatype.
/// </summary>
public const string ImageCropperAlias = "Umbraco.ImageCropper";
/// <summary>
/// Guid for the Textbox datatype.
/// </summary>
public const string Textbox = "EC15C1E5-9D90-422A-AA52-4F7622C63BEA";
/// <summary>
/// Guid for the Integer datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string Integer = "1413AFCB-D19A-4173-8E9A-68288D2A73B8";
/// <summary>
/// Guid for the Textbox multiple datatype.
/// </summary>
public const string TextboxMultiple = "67DB8357-EF57-493E-91AC-936D305E0F2A";
/// <summary>
/// Alias for the Integer datatype.
/// </summary>
public const string IntegerAlias = "Umbraco.Integer";
/// <summary>
/// Guid for the TinyMCE v3 wysiwyg datatype.
/// </summary>
public const string TinyMCEv3 = "5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83";
/// <summary>
/// Guid for the Macro Container datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string MacroContainer = "474FCFF8-9D2D-11DE-ABC6-AD7A56D89593";
/// <summary>
/// Guid for the TinyMCE wysiwyg (deprecated, upgrade to tinymce v3!) datatype.
/// </summary>
public const string TinyMCE = "83722133-F80C-4273-BDB6-1BEFAA04A612";
/// <summary>
/// Alias for the Macro Container datatype.
/// </summary>
public const string MacroContainerAlias = "Umbraco.MacroContainer";
/// <summary>
/// Guid for the True/False (Ja/Nej) datatype.
/// </summary>
public const string TrueFalse = "38B352C1-E9F8-4FD8-9324-9A2EAB06D97A";
/// <summary>
/// Guid for the Media Picker datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string MediaPicker = "EAD69342-F06D-4253-83AC-28000225583B";
/// <summary>
/// Guid for the Ultimate Picker datatype.
/// </summary>
public const string UltimatePicker = "CDBF0B5D-5CB2-445F-BC12-FCAAEC07CF2C";
/// <summary>
/// Alias for the Media Picker datatype.
/// </summary>
public const string MediaPickerAlias = "Umbraco.MediaPicker";
/// <summary>
/// Guid for the UltraSimpleEditor datatype.
/// </summary>
public const string UltraSimpleEditor = "60B7DABF-99CD-41EB-B8E9-4D2E669BBDE9";
/// <summary>
/// Guid for the Member Picker datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string MemberPicker = "39F533E4-0551-4505-A64B-E0425C5CE775";
/// <summary>
/// Guid for the Umbraco Usercontrol Wrapper datatype.
/// </summary>
public const string UmbracoUserControlWrapper = "D15E1281-E456-4B24-AA86-1DDA3E4299D5";
/// <summary>
/// Alias for the Member Picker datatype.
/// </summary>
public const string MemberPickerAlias = "Umbraco.MemberPicker";
/// <summary>
/// Guid for the Upload field datatype.
/// </summary>
public const string UploadField = "5032A6E6-69E3-491D-BB28-CD31CD11086C";
/// <summary>
/// Guid for the Multi-Node Tree Picker datatype
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string MultiNodeTreePicker = "7E062C13-7C41-4AD9-B389-41D88AEEF87C";
/// <summary>
/// Guid for the XPath CheckBoxList datatype.
/// </summary>
public const string XPathCheckBoxList = "34451D92-D270-49BA-8C7F-EE55BFEEE1CB";
/// <summary>
/// Alias for the Multi-Node Tree Picker datatype
/// </summary>
public const string MultiNodeTreePickerAlias = "Umbraco.MultiNodeTreePicker";
/// <summary>
/// Guid for the XPath DropDownList datatype.
/// </summary>
public const string XPathDropDownList = "173A96AE-00ED-4A7C-9F76-4B53D4A0A1B9";
}
/// <summary>
/// Guid for the Multiple Textstring datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string MultipleTextstring = "5359AD0B-06CC-4182-92BD-0A9117448D3F";
/// <summary>
/// Alias for the Multiple Textstring datatype.
/// </summary>
public const string MultipleTextstringAlias = "Umbraco.MultipleTextstring";
/// <summary>
/// Guid for the No edit datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string NoEdit = "6C738306-4C17-4D88-B9BD-6546F3771597";
/// <summary>
/// Alias for the No edit datatype.
/// </summary>
public const string NoEditAlias = "Umbraco.NoEdit";
/// <summary>
/// Guid for the Picker Relations datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string PickerRelations = "83396FF2-2E39-4A90-9066-17F5F3989374";
/// <summary>
/// Alias for the Picker Relations datatype.
/// </summary>
public const string PickerRelationsAlias = "Umbraco.PickerRelations";
/// <summary>
/// Guid for the Radiobutton list datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string RadioButtonList = "A52C7C1C-C330-476E-8605-D63D3B84B6A6";
/// <summary>
/// Alias for the Radiobutton list datatype.
/// </summary>
public const string RadioButtonListAlias = "Umbraco.RadioButtonList";
/// <summary>
/// Guid for the Related Links datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string RelatedLinks = "71B8AD1A-8DC2-425C-B6B8-FAA158075E63";
/// <summary>
/// Alias for the Related Links datatype.
/// </summary>
public const string RelatedLinksAlias = "Umbraco.RelatedLinks";
/// <summary>
/// Guid for the Slider datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string Slider = "29E790E6-26B3-438A-B21F-908663A0B19E";
/// <summary>
/// Alias for the Slider datatype.
/// </summary>
public const string SliderAlias = "Umbraco.Slider";
/// <summary>
/// Guid for the Tags datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string Tags = "4023E540-92F5-11DD-AD8B-0800200C9A66";
/// <summary>
/// Alias for the Tags datatype.
/// </summary>
public const string TagsAlias = "Umbraco.Tags";
/// <summary>
/// Guid for the Textbox datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string Textbox = "EC15C1E5-9D90-422A-AA52-4F7622C63BEA";
/// <summary>
/// Alias for the Textbox datatype.
/// </summary>
public const string TextboxAlias = "Umbraco.Textbox";
/// <summary>
/// Guid for the Textbox multiple datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string TextboxMultiple = "67DB8357-EF57-493E-91AC-936D305E0F2A";
/// <summary>
/// Alias for the Textbox multiple datatype.
/// </summary>
public const string TextboxMultipleAlias = "Umbraco.TextboxMultiple";
/// <summary>
/// Guid for the TinyMCE v3 wysiwyg datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string TinyMCEv3 = "5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83";
/// <summary>
/// Alias for the TinyMCE v3 wysiwyg datatype.
/// </summary>
public const string TinyMCEv3Alias = "Umbraco.TinyMCEv3";
/// <summary>
/// Guid for the True/False (Ja/Nej) datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string TrueFalse = "38B352C1-E9F8-4FD8-9324-9A2EAB06D97A";
/// <summary>
/// Alias for the True/False (Ja/Nej) datatype.
/// </summary>
public const string TrueFalseAlias = "Umbraco.TrueFalse";
/// <summary>
/// Guid for the Ultimate Picker datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string UltimatePicker = "CDBF0B5D-5CB2-445F-BC12-FCAAEC07CF2C";
/// <summary>
/// Alias for the Ultimate Picker datatype.
/// </summary>
public const string UltimatePickerAlias = "Umbraco.UltimatePicker";
/// <summary>
/// Guid for the UltraSimpleEditor datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string UltraSimpleEditor = "60B7DABF-99CD-41EB-B8E9-4D2E669BBDE9";
/// <summary>
/// Alias for the UltraSimpleEditor datatype.
/// </summary>
public const string UltraSimpleEditorAlias = "Umbraco.UltraSimpleEditor";
/// <summary>
/// Guid for the Umbraco Usercontrol Wrapper datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string UmbracoUserControlWrapper = "D15E1281-E456-4B24-AA86-1DDA3E4299D5";
/// <summary>
/// Alias for the Umbraco Usercontrol Wrapper datatype.
/// </summary>
public const string UmbracoUserControlWrapperAlias = "Umbraco.UmbracoUserControlWrapper";
/// <summary>
/// Guid for the Upload field datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string UploadField = "5032A6E6-69E3-491D-BB28-CD31CD11086C";
/// <summary>
/// Alias for the Upload field datatype.
/// </summary>
public const string UploadFieldAlias = "Umbraco.UploadField";
/// <summary>
/// Guid for the XPath CheckBoxList datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string XPathCheckBoxList = "34451D92-D270-49BA-8C7F-EE55BFEEE1CB";
/// <summary>
/// Alias for the XPath CheckBoxList datatype.
/// </summary>
public const string XPathCheckBoxListAlias = "Umbraco.XPathCheckBoxList";
/// <summary>
/// Guid for the XPath DropDownList datatype.
/// </summary>
[Obsolete("GUIDs are no longer used to reference Property Editors, use the Alias constant instead. This will be removed in future versions")]
public const string XPathDropDownList = "173A96AE-00ED-4A7C-9F76-4B53D4A0A1B9";
/// <summary>
/// Alias for the XPath DropDownList datatype.
/// </summary>
public const string XPathDropDownListAlias = "Umbraco.XPathDropDownList";
}
}
}

View File

@@ -438,8 +438,7 @@ namespace Umbraco.Core.Models
Resize(fs, fileName, extension, 100, "thumb", originalImage);
//Look up Prevalues for this upload datatype - if it is an upload datatype
var uploadFieldId = new Guid(Constants.PropertyEditors.UploadField);
if (property.PropertyType.DataTypeId == uploadFieldId)
if (property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias)
{
//Get Prevalues by the DataType's Id: property.PropertyType.DataTypeId
var values = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(property.PropertyType.DataTypeDefinitionId);

View File

@@ -2,7 +2,7 @@
using System.Reflection;
using System.Runtime.Serialization;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Persistence;
namespace Umbraco.Core.Models
{
@@ -24,13 +24,20 @@ namespace Umbraco.Core.Models
private string _path;
private int _creatorId;
private bool _trashed;
private Guid _controlId;
private string _propertyEditorAlias;
private DataTypeDatabaseType _databaseType;
[Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the alternative contructor that specifies an alias")]
public DataTypeDefinition(int parentId, Guid controlId)
{
_parentId = parentId;
_controlId = controlId;
_propertyEditorAlias = LegacyPropertyEditorIdToAliasConverter.GetAliasFromLegacyId(controlId, true);
}
public DataTypeDefinition(int parentId, string propertyEditorAlias)
{
_parentId = parentId;
_propertyEditorAlias = propertyEditorAlias;
}
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo<DataTypeDefinition, string>(x => x.Name);
@@ -40,7 +47,7 @@ namespace Umbraco.Core.Models
private static readonly PropertyInfo PathSelector = ExpressionHelper.GetPropertyInfo<DataTypeDefinition, string>(x => x.Path);
private static readonly PropertyInfo UserIdSelector = ExpressionHelper.GetPropertyInfo<DataTypeDefinition, int>(x => x.CreatorId);
private static readonly PropertyInfo TrashedSelector = ExpressionHelper.GetPropertyInfo<DataTypeDefinition, bool>(x => x.Trashed);
private static readonly PropertyInfo ControlIdSelector = ExpressionHelper.GetPropertyInfo<DataTypeDefinition, Guid>(x => x.ControlId);
private static readonly PropertyInfo PropertyEditorAliasSelector = ExpressionHelper.GetPropertyInfo<DataTypeDefinition, string>(x => x.PropertyEditorAlias);
private static readonly PropertyInfo DatabaseTypeSelector = ExpressionHelper.GetPropertyInfo<DataTypeDefinition, DataTypeDatabaseType>(x => x.DatabaseType);
/// <summary>
@@ -165,20 +172,32 @@ namespace Umbraco.Core.Models
}
}
[DataMember]
public string PropertyEditorAlias
{
get { return _propertyEditorAlias; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
_propertyEditorAlias = value;
return _propertyEditorAlias;
}, _propertyEditorAlias, PropertyEditorAliasSelector);
}
}
/// <summary>
/// Id of the DataType control
/// </summary>
[DataMember]
[Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the PropertyEditorAlias property instead")]
public Guid ControlId
{
get { return _controlId; }
set
get { return LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(_propertyEditorAlias, true).Value; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
_controlId = value;
return _controlId;
}, _controlId, ControlIdSelector);
var alias = LegacyPropertyEditorIdToAliasConverter.GetAliasFromLegacyId(value, true);
PropertyEditorAlias = alias;
}
}

View File

@@ -5,9 +5,15 @@ namespace Umbraco.Core.Models
{
public interface IDataTypeDefinition : IUmbracoEntity
{
/// <summary>
/// The Property editor alias assigned to the data type
/// </summary>
string PropertyEditorAlias { get; set; }
/// <summary>
/// Id of the DataType control
/// </summary>
[Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the PropertyEditorAlias property instead")]
Guid ControlId { get; set; }
/// <summary>

View File

@@ -3,7 +3,7 @@ using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Persistence;
namespace Umbraco.Core.Models
{
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Models
private string _description;
private int _dataTypeDefinitionId;
private Lazy<int> _propertyGroupId;
private Guid _dataTypeId;
private string _propertyEditorAlias;
private DataTypeDatabaseType _dataTypeDatabaseType;
private bool _mandatory;
private string _helpText;
@@ -31,13 +31,13 @@ namespace Umbraco.Core.Models
if(dataTypeDefinition.HasIdentity)
DataTypeDefinitionId = dataTypeDefinition.Id;
DataTypeId = dataTypeDefinition.ControlId;
PropertyEditorAlias = dataTypeDefinition.PropertyEditorAlias;
DataTypeDatabaseType = dataTypeDefinition.DatabaseType;
}
internal PropertyType(Guid dataTypeControlId, DataTypeDatabaseType dataTypeDatabaseType)
internal PropertyType(string propertyEditorAlias, DataTypeDatabaseType dataTypeDatabaseType)
{
DataTypeId = dataTypeControlId;
PropertyEditorAlias = propertyEditorAlias;
DataTypeDatabaseType = dataTypeDatabaseType;
}
@@ -45,7 +45,7 @@ namespace Umbraco.Core.Models
private static readonly PropertyInfo AliasSelector = ExpressionHelper.GetPropertyInfo<PropertyType, string>(x => x.Alias);
private static readonly PropertyInfo DescriptionSelector = ExpressionHelper.GetPropertyInfo<PropertyType, string>(x => x.Description);
private static readonly PropertyInfo DataTypeDefinitionIdSelector = ExpressionHelper.GetPropertyInfo<PropertyType, int>(x => x.DataTypeDefinitionId);
private static readonly PropertyInfo DataTypeControlIdSelector = ExpressionHelper.GetPropertyInfo<PropertyType, Guid>(x => x.DataTypeId);
private static readonly PropertyInfo PropertyEditorAliasSelector = ExpressionHelper.GetPropertyInfo<PropertyType, string>(x => x.PropertyEditorAlias);
private static readonly PropertyInfo DataTypeDatabaseTypeSelector = ExpressionHelper.GetPropertyInfo<PropertyType, DataTypeDatabaseType>(x => x.DataTypeDatabaseType);
private static readonly PropertyInfo MandatorySelector = ExpressionHelper.GetPropertyInfo<PropertyType, bool>(x => x.Mandatory);
private static readonly PropertyInfo HelpTextSelector = ExpressionHelper.GetPropertyInfo<PropertyType, string>(x => x.HelpText);
@@ -122,21 +122,33 @@ namespace Umbraco.Core.Models
}
}
[DataMember]
public string PropertyEditorAlias
{
get { return _propertyEditorAlias; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
_propertyEditorAlias = value;
return _propertyEditorAlias;
}, _propertyEditorAlias, PropertyEditorAliasSelector);
}
}
/// <summary>
/// Gets of Sets the Id of the DataType control
/// </summary>
/// <remarks>This is the Id of the actual DataType control</remarks>
[DataMember]
[Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the PropertyEditorAlias property instead")]
public Guid DataTypeId
{
get { return _dataTypeId; }
internal set
get { return LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(_propertyEditorAlias, true).Value; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
_dataTypeId = value;
return _dataTypeId;
}, _dataTypeId, DataTypeControlIdSelector);
var alias = LegacyPropertyEditorIdToAliasConverter.GetAliasFromLegacyId(value, true);
PropertyEditorAlias = alias;
}
}
@@ -319,7 +331,7 @@ namespace Umbraco.Core.Models
return argument == type;
}*/
if (DataTypeId != Guid.Empty)
if (PropertyEditorAlias.IsNullOrWhiteSpace() == false)
{
//Find DataType by Id
//IDataType dataType = DataTypesResolver.Current.GetById(DataTypeControlId);
@@ -380,7 +392,7 @@ namespace Umbraco.Core.Models
internal PropertyType Clone()
{
var clone = (PropertyType) this.MemberwiseClone();
var clone = (PropertyType) MemberwiseClone();
clone.ResetIdentity();
clone.ResetDirtyProperties(false);
return clone;
@@ -389,10 +401,10 @@ namespace Umbraco.Core.Models
public bool Equals(PropertyType other)
{
//Check whether the compared object is null.
if (Object.ReferenceEquals(other, null)) return false;
if (ReferenceEquals(other, null)) return false;
//Check whether the compared object references the same data.
if (Object.ReferenceEquals(this, other)) return true;
if (ReferenceEquals(this, other)) return true;
//Check whether the PropertyType's properties are equal.
return Alias.Equals(other.Alias) && Name.Equals(other.Name);

View File

@@ -18,8 +18,8 @@ namespace Umbraco.Core.Models.Rdbms
[Index(IndexTypes.UniqueNonClustered)]
public int DataTypeId { get; set; }
[Column("controlId")]
public Guid ControlId { get; set; }
[Column("propertyEditorAlias")]
public string PropertyEditorAlias { get; set; }
[Column("dbType")]
[Length(50)]

View File

@@ -59,7 +59,7 @@ namespace Umbraco.Core.Models.Rdbms
public string Description { get; set; }
/* cmsDataType */
[Column("controlId")]
public Guid ControlId { get; set; }
[Column("propertyEditorAlias")]
public string PropertyEditorAlias { get; set; }
}
}

View File

@@ -250,7 +250,7 @@ namespace Umbraco.Core.Models
internal class UmbracoProperty
{
public Guid DataTypeControlId { get; set; }
public string PropertyEditorAlias { get; set; }
public string Value { get; set; }
}
}

View File

@@ -19,7 +19,7 @@ namespace Umbraco.Core.Persistence.Factories
public IDataTypeDefinition BuildEntity(DataTypeDto dto)
{
var dataTypeDefinition = new DataTypeDefinition(dto.NodeDto.ParentId, dto.ControlId)
var dataTypeDefinition = new DataTypeDefinition(dto.NodeDto.ParentId, dto.PropertyEditorAlias)
{
CreateDate = dto.NodeDto.CreateDate,
DatabaseType = dto.DbType.EnumParse<DataTypeDatabaseType>(true),
@@ -47,7 +47,7 @@ namespace Umbraco.Core.Persistence.Factories
{
var dataTypeDto = new DataTypeDto
{
ControlId = entity.ControlId,
PropertyEditorAlias = entity.PropertyEditorAlias,
DataTypeId = entity.Id,
DbType = entity.DatabaseType.ToString(),
NodeDto = BuildNodeDto(entity)

View File

@@ -55,7 +55,7 @@ namespace Umbraco.Core.Persistence.Factories
foreach (var typeDto in typeDtos)
{
var tempGroupDto = groupDto;
var propertyType = new PropertyType(typeDto.DataTypeDto.ControlId,
var propertyType = new PropertyType(typeDto.DataTypeDto.PropertyEditorAlias,
typeDto.DataTypeDto.DbType.EnumParse<DataTypeDatabaseType>(true))
{
Alias = typeDto.Alias,

View File

@@ -39,8 +39,8 @@ namespace Umbraco.Core.Persistence.Factories
{
entity.UmbracoProperties.Add(new UmbracoEntity.UmbracoProperty
{
DataTypeControlId =
propertyDto.DataTypeControlId,
PropertyEditorAlias =
propertyDto.PropertyEditorAlias,
Value = propertyDto.UmbracoFile
});
}

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Umbraco.Core.Persistence
{
/// <summary>
/// This is used to map old legacy property editor GUID's to the new Property Editor alias (string) format.
/// </summary>
/// <remarks>
/// This can be used by developers on application startup to register a mapping from their old ids to their new aliases and vice-versa.
/// </remarks>
public static class LegacyPropertyEditorIdToAliasConverter
{
/// <summary>
/// The map consists of a key which is always the GUID (lowercase, no hyphens + alias (trimmed))
/// </summary>
private static readonly ConcurrentDictionary<string, Tuple<Guid, string>> Map = new ConcurrentDictionary<string, Tuple<Guid, string>>();
/// <summary>
/// Creates a map for the specified legacy id and property editor alias
/// </summary>
/// <param name="legacyId"></param>
/// <param name="alias"></param>
/// <returns>true if the map was created or false if it was already created</returns>
public static bool CreateMap(Guid legacyId, string alias)
{
var key = legacyId.ToString("N").ToLowerInvariant() + alias.Trim();
return Map.TryAdd(key, new Tuple<Guid, string>(legacyId, alias));
}
/// <summary>
/// Gets an alias based on the legacy ID
/// </summary>
/// <param name="legacyId"></param>
/// <param name="throwIfNotFound">if set to true will throw an exception if the map isn't found</param>
/// <returns>Returns the alias if found otherwise null if not found</returns>
public static string GetAliasFromLegacyId(Guid legacyId, bool throwIfNotFound = false)
{
var found = Map.SingleOrDefault(x => x.Value.Item1 == legacyId);
if (found.Equals(default(KeyValuePair<string, Tuple<Guid, string>>)))
{
if (throwIfNotFound)
{
throw new ObjectNotFoundException("Could not find a map for a property editor with a legacy id of " + legacyId);
}
return null;
}
return found.Value.Item2;
}
/// <summary>
/// Gets a legacy Id based on the alias
/// </summary>
/// <param name="alias"></param>
/// <param name="throwIfNotFound">if set to true will throw an exception if the map isn't found</param>
/// <returns>Returns the legacy GUID of a property editor if found, otherwise returns null</returns>
public static Guid? GetLegacyIdFromAlias(string alias, bool throwIfNotFound = false)
{
var found = Map.SingleOrDefault(x => x.Value.Item2 == alias);
if (found.Equals(default(KeyValuePair<string, Tuple<Guid, string>>)))
{
if (throwIfNotFound)
{
throw new ObjectNotFoundException("Could not find a map for a property editor with an alias of " + alias);
}
return null;
}
return found.Value.Item1;
}
}
}

View File

@@ -42,7 +42,7 @@ namespace Umbraco.Core.Persistence.Mappers
CacheMap<DataTypeDefinition, NodeDto>(src => src.Trashed, dto => dto.Trashed);
CacheMap<DataTypeDefinition, NodeDto>(src => src.Key, dto => dto.UniqueId);
CacheMap<DataTypeDefinition, NodeDto>(src => src.CreatorId, dto => dto.UserId);
CacheMap<DataTypeDefinition, DataTypeDto>(src => src.ControlId, dto => dto.ControlId);
CacheMap<DataTypeDefinition, DataTypeDto>(src => src.PropertyEditorAlias, dto => dto.PropertyEditorAlias);
CacheMap<DataTypeDefinition, DataTypeDto>(src => src.DatabaseType, dto => dto.DbType);
}

View File

@@ -42,7 +42,7 @@ namespace Umbraco.Core.Persistence.Mappers
CacheMap<PropertyType, PropertyTypeDto>(src => src.Name, dto => dto.Name);
CacheMap<PropertyType, PropertyTypeDto>(src => src.SortOrder, dto => dto.SortOrder);
CacheMap<PropertyType, PropertyTypeDto>(src => src.ValidationRegExp, dto => dto.ValidationRegExp);
CacheMap<PropertyType, DataTypeDto>(src => src.DataTypeId, dto => dto.ControlId);
CacheMap<PropertyType, DataTypeDto>(src => src.PropertyEditorAlias, dto => dto.PropertyEditorAlias);
CacheMap<PropertyType, DataTypeDto>(src => src.DataTypeDatabaseType, dto => dto.DbType);
}
}

View File

@@ -219,30 +219,30 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
private void CreateCmsDataTypeData()
{
//TODO Check which of the DataTypeIds below doesn't exist in umbracoNode, which results in a foreign key constraint errors.
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 1, DataTypeId = -49, ControlId = new Guid(Constants.PropertyEditors.TrueFalse), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 2, DataTypeId = -51, ControlId = new Guid(Constants.PropertyEditors.Integer), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 3, DataTypeId = -87, ControlId = new Guid(Constants.PropertyEditors.TinyMCEv3), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 4, DataTypeId = -88, ControlId = new Guid(Constants.PropertyEditors.Textbox), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 5, DataTypeId = -89, ControlId = new Guid(Constants.PropertyEditors.TextboxMultiple), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 6, DataTypeId = -90, ControlId = new Guid(Constants.PropertyEditors.UploadField), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 7, DataTypeId = -92, ControlId = new Guid(Constants.PropertyEditors.NoEdit), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 8, DataTypeId = -36, ControlId = new Guid(Constants.PropertyEditors.DateTime), DbType = "Date" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 9, DataTypeId = -37, ControlId = new Guid(Constants.PropertyEditors.ColorPicker), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 10, DataTypeId = -38, ControlId = new Guid(Constants.PropertyEditors.FolderBrowser), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 11, DataTypeId = -39, ControlId = new Guid(Constants.PropertyEditors.DropDownListMultiple), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 12, DataTypeId = -40, ControlId = new Guid(Constants.PropertyEditors.RadioButtonList), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 13, DataTypeId = -41, ControlId = new Guid(Constants.PropertyEditors.Date), DbType = "Date" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 14, DataTypeId = -42, ControlId = new Guid(Constants.PropertyEditors.DropDownList), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 15, DataTypeId = -43, ControlId = new Guid(Constants.PropertyEditors.CheckBoxList), DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 16, DataTypeId = 1034, ControlId = new Guid(Constants.PropertyEditors.ContentPicker), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 17, DataTypeId = 1035, ControlId = new Guid(Constants.PropertyEditors.MediaPicker), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 18, DataTypeId = 1036, ControlId = new Guid(Constants.PropertyEditors.MemberPicker), DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 19, DataTypeId = 1038, ControlId = new Guid(Constants.PropertyEditors.UltraSimpleEditor), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 20, DataTypeId = 1039, ControlId = new Guid(Constants.PropertyEditors.UltimatePicker), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 21, DataTypeId = 1040, ControlId = new Guid(Constants.PropertyEditors.RelatedLinks), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 22, DataTypeId = 1041, ControlId = new Guid(Constants.PropertyEditors.Tags), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 23, DataTypeId = 1042, ControlId = new Guid(Constants.PropertyEditors.MacroContainer), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 24, DataTypeId = 1043, ControlId = new Guid(Constants.PropertyEditors.ImageCropper), DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 1, DataTypeId = -49, PropertyEditorAlias = Constants.PropertyEditors.TrueFalseAlias, DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 2, DataTypeId = -51, PropertyEditorAlias = Constants.PropertyEditors.IntegerAlias, DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 3, DataTypeId = -87, PropertyEditorAlias = Constants.PropertyEditors.TinyMCEv3Alias, DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 4, DataTypeId = -88, PropertyEditorAlias = Constants.PropertyEditors.TextboxAlias, DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 5, DataTypeId = -89, PropertyEditorAlias = Constants.PropertyEditors.TextboxMultipleAlias, DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 6, DataTypeId = -90, PropertyEditorAlias = Constants.PropertyEditors.UploadFieldAlias, DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 7, DataTypeId = -92, PropertyEditorAlias = Constants.PropertyEditors.NoEditAlias, DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 8, DataTypeId = -36, PropertyEditorAlias = Constants.PropertyEditors.DateTimeAlias, DbType = "Date" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 9, DataTypeId = -37, PropertyEditorAlias = Constants.PropertyEditors.ColorPickerAlias, DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 10, DataTypeId = -38, PropertyEditorAlias = Constants.PropertyEditors.FolderBrowserAlias, DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 11, DataTypeId = -39, PropertyEditorAlias = Constants.PropertyEditors.DropDownListMultipleAlias, DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 12, DataTypeId = -40, PropertyEditorAlias = Constants.PropertyEditors.RadioButtonListAlias, DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 13, DataTypeId = -41, PropertyEditorAlias = Constants.PropertyEditors.DateAlias, DbType = "Date" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 14, DataTypeId = -42, PropertyEditorAlias = Constants.PropertyEditors.DropDownListAlias, DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 15, DataTypeId = -43, PropertyEditorAlias = Constants.PropertyEditors.CheckBoxListAlias, DbType = "Nvarchar" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 16, DataTypeId = 1034, PropertyEditorAlias = Constants.PropertyEditors.ContentPickerAlias, DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 17, DataTypeId = 1035, PropertyEditorAlias = Constants.PropertyEditors.MediaPickerAlias, DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 18, DataTypeId = 1036, PropertyEditorAlias = Constants.PropertyEditors.MemberPickerAlias, DbType = "Integer" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 19, DataTypeId = 1038, PropertyEditorAlias = Constants.PropertyEditors.UltraSimpleEditorAlias, DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 20, DataTypeId = 1039, PropertyEditorAlias = Constants.PropertyEditors.UltimatePickerAlias, DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 21, DataTypeId = 1040, PropertyEditorAlias = Constants.PropertyEditors.RelatedLinksAlias, DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 22, DataTypeId = 1041, PropertyEditorAlias = Constants.PropertyEditors.TagsAlias, DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 23, DataTypeId = 1042, PropertyEditorAlias = Constants.PropertyEditors.MacroContainerAlias, DbType = "Ntext" });
_database.Insert("cmsDataType", "pk", false, new DataTypeDto { PrimaryKey = 24, DataTypeId = 1043, PropertyEditorAlias = Constants.PropertyEditors.ImageCropperAlias, DbType = "Ntext" });
}
private void CreateCmsDataTypePreValuesData()

View File

@@ -0,0 +1,20 @@
using System;
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
{
[Migration("7.0.0", 0, GlobalSettings.UmbracoMigrationName)]
public class ChangeControlIdColumn : MigrationBase
{
public override void Up()
{
Rename.Column("controlId").OnTable("cmsDataType").To("propertyEditorAlias");
Alter.Column("controlId").OnTable("cmsDataType").AsString(255);
}
public override void Down()
{
throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
}
}
}

View File

@@ -429,11 +429,11 @@ namespace Umbraco.Core.Persistence.Repositories
protected override void PersistDeletedItem(IContent entity)
{
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
var uploadFieldId = new Guid(Constants.PropertyEditors.UploadField);
//Loop through properties to check if the content contains images/files that should be deleted
foreach (var property in entity.Properties)
{
if (property.PropertyType.DataTypeId == uploadFieldId && property.Value != null &&
if (property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias && property.Value != null &&
string.IsNullOrEmpty(property.Value.ToString()) == false
&& fs.FileExists(IOHelper.MapPath(property.Value.ToString())))
{

View File

@@ -161,7 +161,7 @@ namespace Umbraco.Core.Persistence.Repositories
//Update the current PropertyType with correct ControlId and DatabaseType
var dataTypeDto = Database.FirstOrDefault<DataTypeDto>("WHERE nodeId = @Id", new { Id = propertyTypeDto.DataTypeId });
propertyType.DataTypeId = dataTypeDto.ControlId;
propertyType.PropertyEditorAlias = dataTypeDto.PropertyEditorAlias;
propertyType.DataTypeDatabaseType = dataTypeDto.DbType.EnumParse<DataTypeDatabaseType>(true);
}
}
@@ -362,7 +362,7 @@ namespace Umbraco.Core.Persistence.Repositories
var list = (from dto in dtos
where (dto.PropertyTypeGroupId > 0) == false
select
new PropertyType(dto.DataTypeDto.ControlId,
new PropertyType(dto.DataTypeDto.PropertyEditorAlias,
dto.DataTypeDto.DbType.EnumParse<DataTypeDatabaseType>(true))
{
Alias = dto.Alias,

View File

@@ -169,7 +169,7 @@ namespace Umbraco.Core.Persistence.Repositories
if (isMedia)
{
columns.Add("property.dataNvarchar as umbracoFile");
columns.Add("property.controlId");
columns.Add("property.propertyEditorAlias");
}
var sql = new Sql()
@@ -193,7 +193,7 @@ namespace Umbraco.Core.Persistence.Repositories
if (isMedia)
{
sql.LeftJoin(
"(SELECT contentNodeId, versionId, dataNvarchar, controlId FROM cmsPropertyData " +
"(SELECT contentNodeId, versionId, dataNvarchar, propertyEditorAlias FROM cmsPropertyData " +
"INNER JOIN umbracoNode ON cmsPropertyData.contentNodeId = umbracoNode.id " +
"INNER JOIN cmsPropertyType ON cmsPropertyType.id = cmsPropertyData.propertytypeid " +
"INNER JOIN cmsDataType ON cmsPropertyType.dataTypeId = cmsDataType.nodeId "+
@@ -256,7 +256,7 @@ namespace Umbraco.Core.Persistence.Repositories
if (isMedia)
{
columns.Add("property.dataNvarchar");
columns.Add("property.controlId");
columns.Add("property.propertyEditorAlias");
}
var sql = new Sql()
@@ -309,8 +309,8 @@ namespace Umbraco.Core.Persistence.Repositories
[ExplicitColumns]
internal class UmbracoPropertyDto
{
[Column("controlId")]
public Guid DataTypeControlId { get; set; }
[Column("propertyEditorAlias")]
public string PropertyEditorAlias { get; set; }
[Column("umbracoFile")]
public string UmbracoFile { get; set; }

View File

@@ -327,11 +327,11 @@ namespace Umbraco.Core.Persistence.Repositories
protected override void PersistDeletedItem(IMedia entity)
{
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
var uploadFieldId = new Guid(Constants.PropertyEditors.UploadField);
//Loop through properties to check if the media item contains images/file that should be deleted
foreach (var property in entity.Properties)
{
if (property.PropertyType.DataTypeId == uploadFieldId &&
if (property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias &&
string.IsNullOrEmpty(property.Value.ToString()) == false
&& fs.FileExists(IOHelper.MapPath(property.Value.ToString())))
{

View File

@@ -72,7 +72,7 @@ namespace Umbraco.Core.Persistence.Repositories
"cmsPropertyData.propertytypeid", "cmsPropertyType.Alias", "cmsPropertyType.Description",
"cmsPropertyType.Name", "cmsPropertyType.mandatory", "cmsPropertyType.validationRegExp",
"cmsPropertyType.helpText", "cmsPropertyType.propertyTypeGroupId", "cmsPropertyType.dataTypeId",
"cmsDataType.controlId")
"cmsDataType.propertyEditorAlias")
.From<NodeDto>()
.InnerJoin<ContentDto>().On<ContentDto, NodeDto>(left => left.NodeId, right => right.NodeId)
.InnerJoin<ContentTypeDto>().On<ContentTypeDto, ContentDto>(left => left.NodeId, right => right.ContentTypeId)

View File

@@ -35,15 +35,15 @@ namespace Umbraco.Core.Persistence.Repositories
//Issue query to get all trashed content or media that has the Upload field as a property
//The value for each field is stored in a list: FilesToDelete<string>()
//Alias: Constants.Conventions.Media.File and ControlId: Constants.PropertyEditors.UploadField
//Alias: Constants.Conventions.Media.File and PropertyEditorAlias: Constants.PropertyEditors.UploadField
var sql = new Sql();
sql.Select("DISTINCT(dataNvarchar)")
.From<PropertyDataDto>()
.InnerJoin<NodeDto>().On<PropertyDataDto, NodeDto>(left => left.NodeId, right => right.NodeId)
.InnerJoin<PropertyTypeDto>().On<PropertyDataDto, PropertyTypeDto>(left => left.PropertyTypeId, right => right.Id)
.InnerJoin<DataTypeDto>().On<PropertyTypeDto, DataTypeDto>(left => left.DataTypeId, right => right.DataTypeId)
.Where("umbracoNode.trashed = '1' AND umbracoNode.nodeObjectType = @NodeObjectType AND dataNvarchar IS NOT NULL AND (cmsPropertyType.Alias = @FileAlias OR cmsDataType.controlId = @ControlId)",
new { FileAlias = Constants.Conventions.Media.File, NodeObjectType = nodeObjectType, ControlId = Constants.PropertyEditors.UploadField });
.Where("umbracoNode.trashed = '1' AND umbracoNode.nodeObjectType = @NodeObjectType AND dataNvarchar IS NOT NULL AND (cmsPropertyType.Alias = @FileAlias OR cmsDataType.propertyEditorAlias = @PropertyEditorAlias)",
new { FileAlias = Constants.Conventions.Media.File, NodeObjectType = nodeObjectType, PropertyEditorAlias = Constants.PropertyEditors.UploadFieldAlias });
var files = db.Fetch<string>(sql);
return files;

View File

@@ -3,6 +3,18 @@ using Umbraco.Core.Dynamics;
namespace Umbraco.Core.PropertyEditors
{
public abstract class PropertyValueConverter
{
/// <summary>
/// Returns the alias of the PropertyEditor that this converter is for
/// </summary>
public abstract string AssociatedPropertyEditorAlias { get; }
public abstract object ConvertSourceToObject(object valueToConvert, bool isPreviewing);
}
[Obsolete("Use PropertyConverter instead since we no longer reference property editors by a GUID and instead by a string alias")]
public interface IPropertyEditorValueConverter
{
@@ -13,7 +25,7 @@ namespace Umbraco.Core.PropertyEditors
/// <param name="docTypeAlias"> </param>
/// <param name="propertyTypeAlias"> </param>
/// <returns></returns>
bool IsConverterFor(Guid propertyEditorId, string docTypeAlias, string propertyTypeAlias);
bool IsConverterFor(Guid propertyEditorId, string docTypeAlias, string propertyTypeAlias);
/// <summary>
/// Attempts to convert the value specified into a useable value on the front-end

View File

@@ -1088,14 +1088,14 @@ namespace Umbraco.Core.Services
//Special case for the Upload DataType
//TODO: Should we handle this with events?
var uploadDataTypeId = new Guid(Constants.PropertyEditors.UploadField);
if (content.Properties.Any(x => x.PropertyType.DataTypeId == uploadDataTypeId))
if (content.Properties.Any(x => x.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias))
{
bool isUpdated = false;
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
//Loop through properties to check if the content contains media that should be deleted
foreach (var property in content.Properties.Where(x => x.PropertyType.DataTypeId == uploadDataTypeId
foreach (var property in content.Properties.Where(x => x.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.UploadFieldAlias
&& string.IsNullOrEmpty(x.Value.ToString()) == false))
{
if (fs.FileExists(IOHelper.MapPath(property.Value.ToString())))
@@ -1125,8 +1125,7 @@ namespace Umbraco.Core.Services
}
//Special case for the Tags DataType
var tagsDataTypeId = new Guid(Constants.PropertyEditors.Tags);
if (content.Properties.Any(x => x.PropertyType.DataTypeId == tagsDataTypeId))
if (content.Properties.Any(x => x.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.TagsAlias))
{
var tags = uow.Database.Fetch<TagRelationshipDto>("WHERE nodeId = @Id", new { Id = content.Id });
foreach (var tag in tags)

View File

@@ -76,11 +76,23 @@ namespace Umbraco.Core.Services
/// </summary>
/// <param name="id">Id of the DataType control</param>
/// <returns>Collection of <see cref="IDataTypeDefinition"/> objects with a matching contorl id</returns>
[Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the overload GetDataTypeDefinitionByPropertyEditorAlias instead")]
public IEnumerable<IDataTypeDefinition> GetDataTypeDefinitionByControlId(Guid id)
{
var alias = LegacyPropertyEditorIdToAliasConverter.GetAliasFromLegacyId(id, true);
return GetDataTypeDefinitionByPropertyEditorAlias(alias);
}
/// <summary>
/// Gets a <see cref="IDataTypeDefinition"/> by its control Id
/// </summary>
/// <param name="propertyEditorAlias">Alias of the property editor</param>
/// <returns>Collection of <see cref="IDataTypeDefinition"/> objects with a matching contorl id</returns>
public IEnumerable<IDataTypeDefinition> GetDataTypeDefinitionByPropertyEditorAlias(string propertyEditorAlias)
{
using (var repository = _repositoryFactory.CreateDataTypeDefinitionRepository(_uowProvider.GetUnitOfWork()))
{
var query = Query<IDataTypeDefinition>.Builder.Where(x => x.ControlId == id);
var query = Query<IDataTypeDefinition>.Builder.Where(x => x.PropertyEditorAlias == propertyEditorAlias);
var definitions = repository.GetByQuery(query);
return definitions;

View File

@@ -61,12 +61,14 @@ namespace Umbraco.Core.Services
/// </summary>
/// <param name="id">Id of the DataType, which corresponds to the Guid Id of the control</param>
/// <returns><see cref="IDataType"/> object</returns>
[Obsolete("IDataType is obsolete and is no longer used, it will be removed from the codebase in future versions")]
IDataType GetDataTypeById(Guid id);
/// <summary>
/// Gets a complete list of all registered <see cref="IDataType"/>'s
/// </summary>
/// <returns>An enumerable list of <see cref="IDataType"/> objects</returns>
[Obsolete("IDataType is obsolete and is no longer used, it will be removed from the codebase in future versions")]
IEnumerable<IDataType> GetAllDataTypes();
/// <summary>
@@ -74,8 +76,16 @@ namespace Umbraco.Core.Services
/// </summary>
/// <param name="id">Id of the DataType control</param>
/// <returns><see cref="IDataTypeDefinition"/></returns>
[Obsolete("Property editor's are defined by a string alias from version 7 onwards, use the overload GetDataTypeDefinitionByPropertyEditorAlias instead")]
IEnumerable<IDataTypeDefinition> GetDataTypeDefinitionByControlId(Guid id);
/// <summary>
/// Gets a <see cref="IDataTypeDefinition"/> by its control Id
/// </summary>
/// <param name="propertyEditorAlias">Alias of the property editor</param>
/// <returns>Collection of <see cref="IDataTypeDefinition"/> objects with a matching contorl id</returns>
IEnumerable<IDataTypeDefinition> GetDataTypeDefinitionByPropertyEditorAlias(string propertyEditorAlias);
/// <summary>
/// Gets all values for an <see cref="IDataTypeDefinition"/>
/// </summary>

View File

@@ -308,7 +308,7 @@ namespace Umbraco.Core.Services
var propertyValue = property.Value;
var propertyType = contentType.PropertyTypes.FirstOrDefault(pt => pt.Alias == propertyTypeAlias);
if (propertyType != null && propertyType.DataTypeId == new Guid(Constants.PropertyEditors.CheckBoxList))
if (propertyType != null && propertyType.PropertyEditorAlias == Constants.PropertyEditors.CheckBoxListAlias)
{
var database = ApplicationContext.Current.DatabaseContext.Database;
var dtos = database.Fetch<DataTypePreValueDto>("WHERE datatypeNo" + "deId = @Id", new { Id = propertyType.DataTypeDefinitionId });
@@ -591,6 +591,8 @@ namespace Umbraco.Core.Services
var properties = genericPropertiesElement.Elements("GenericProperty");
foreach (var property in properties)
{
//TODO: Need to update this whole service to support the PropertyEditorAlias change, but somehow still support the old GUID package format.
var dataTypeId = new Guid(property.Element("Type").Value);//The DataType's Control Id
var dataTypeDefinitionId = new Guid(property.Element("Definition").Value);//Unique Id for a DataTypeDefinition

View File

@@ -349,6 +349,7 @@
<Compile Include="Persistence\FaultHandling\Strategies\NetworkConnectivityErrorDetectionStrategy.cs" />
<Compile Include="Persistence\FaultHandling\Strategies\SqlAzureTransientErrorDetectionStrategy.cs" />
<Compile Include="Persistence\FaultHandling\ThrottlingCondition.cs" />
<Compile Include="Persistence\LegacyPropertyEditorIdToAliasConverter.cs" />
<Compile Include="Persistence\Mappers\MapperForAttribute.cs" />
<Compile Include="Persistence\Mappers\PetaPocoMapper.cs" />
<Compile Include="Persistence\DatabaseAnnotations\ConstraintAttribute.cs" />
@@ -534,6 +535,7 @@
<Compile Include="Persistence\Migrations\Syntax\Update\UpdateBuilder.cs" />
<Compile Include="Persistence\Migrations\Syntax\Update\UpdateDataBuilder.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionFourNineZero\RemoveUmbracoAppConstraints.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSeven\ChangeControlIdColumn.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixOneZero\CreateServerRegistryTable.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\AddChangeDocumentTypePermission.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixZeroOne\UpdatePropertyTypesAndGroups.cs" />