Merge remote-tracking branch 'origin/6.2.0' into 6.2.0-pubcontent

This commit is contained in:
Stephan
2013-10-02 11:14:08 +02:00
31 changed files with 315 additions and 239 deletions

View File

@@ -112,7 +112,7 @@ namespace Umbraco.Core
public void ConfigureEmbeddedDatabaseConnection()
{
const string providerName = "System.Data.SqlServerCe.4.0";
const string connectionString = @"Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1;File Access Retry Timeout=10";
const string connectionString = @"Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1;";
SaveConnectionString(connectionString, providerName);

View File

@@ -20,19 +20,26 @@ namespace Umbraco.Core.Models
private object _providerUserKey;
private Type _userTypeKey;
public Member(string name, int parentId, IMemberType contentType, PropertyCollection properties) : base(name, parentId, contentType, properties)
public Member(string name, string email, string username, string password, int parentId, IMemberType contentType)
: base(name, parentId, contentType, new PropertyCollection())
{
Mandate.ParameterNotNull(contentType, "contentType");
_contentType = contentType;
_email = email;
_username = username;
_password = password;
}
public Member(string name, IContentBase parent, IMemberType contentType, PropertyCollection properties)
: base(name, parent, contentType, properties)
public Member(string name, string email, string username, string password, IContentBase parent, IMemberType contentType)
: base(name, parent, contentType, new PropertyCollection())
{
Mandate.ParameterNotNull(contentType, "contentType");
_contentType = contentType;
_email = email;
_username = username;
_password = password;
}
private static readonly PropertyInfo DefaultContentTypeAliasSelector = ExpressionHelper.GetPropertyInfo<Member, string>(x => x.ContentTypeAlias);

View File

@@ -114,5 +114,26 @@ namespace Umbraco.Core.Models
MemberTypePropertyTypes.Add(propertyTypeAlias, tuple);
}
}
/// <summary>
/// Method to call when Entity is being saved
/// </summary>
/// <remarks>Created date is set and a Unique key is assigned</remarks>
internal override void AddingEntity()
{
base.AddingEntity();
if (Key == Guid.Empty)
Key = Guid.NewGuid();
}
/// <summary>
/// Method to call when Entity is being updated
/// </summary>
/// <remarks>Modified Date is set and a new Version guid is set</remarks>
internal override void UpdatingEntity()
{
base.UpdatingEntity();
}
}
}

View File

@@ -18,5 +18,8 @@ namespace Umbraco.Core.Models.Rdbms
[Column("PropertyGroupSortOrder")]
public int SortOrder { get; set; }
[Column("contenttypeNodeId")]
public int ContentTypeNodeId { get; set; }
}
}

View File

@@ -17,7 +17,7 @@ namespace Umbraco.Core.Models.Rdbms
[Column("contentTypeId")]
public int ContentTypeId { get; set; }
[Column("propertyTypeGroupId")]
[Column("PropertyTypesGroupId")]
public int? PropertyTypeGroupId { get; set; }
[Column("Alias")]

View File

@@ -18,17 +18,13 @@ namespace Umbraco.Core.Persistence.Factories
public IMember BuildEntity(MemberReadOnlyDto dto)
{
var properties = CreateProperties(_memberTypes[dto.ContentTypeAlias], dto.Properties, dto.CreateDate);
var propertyCollection = new PropertyCollection(properties);
var member = new Member(dto.Text, dto.ParentId, _memberTypes[dto.ContentTypeAlias], propertyCollection)
var member = new Member(dto.Text, dto.Email, dto.LoginName, dto.Password, dto.ParentId, _memberTypes[dto.ContentTypeAlias])
{
Id = dto.NodeId,
CreateDate = dto.CreateDate,
UpdateDate = dto.UpdateDate,
Name = dto.Text,
Email = dto.Email,
Username = dto.LoginName,
Password = dto.Password,
ProviderUserKey = dto.UniqueId,
Trashed = dto.Trashed,
Key = dto.UniqueId.Value,
@@ -37,7 +33,8 @@ namespace Umbraco.Core.Persistence.Factories
Path = dto.Path,
SortOrder = dto.SortOrder,
Version = dto.VersionId,
ContentTypeAlias = dto.ContentTypeAlias
ContentTypeAlias = dto.ContentTypeAlias,
Properties = new PropertyCollection(properties)
};
member.SetProviderUserKeyType(typeof(Guid));
@@ -61,7 +58,7 @@ namespace Umbraco.Core.Persistence.Factories
? propertyType.CreatePropertyFromValue(null)
: propertyType.CreatePropertyFromRawValue(propertyDataDto.GetValue,
propertyDataDto.VersionId,
propertyDataDto.Id);
propertyDataDto.PropertyDataId.Value);
//on initial construction we don't want to have dirty properties tracked
property.CreateDate = createDate;
property.UpdateDate = createDate;

View File

@@ -55,51 +55,73 @@ namespace Umbraco.Core.Persistence.Factories
private PropertyGroupCollection GetPropertyTypeGroupCollection(MemberTypeReadOnlyDto dto, MemberType memberType)
{
var propertyTypeGroupCollection = new PropertyGroupCollection();
foreach (var propertyTypeGroup in dto.PropertyTypeGroups.Where(x => x.Id.HasValue))
var propertyGroups = new PropertyGroupCollection();
foreach (var groupDto in dto.PropertyTypeGroups.Where(x => x.Id.HasValue))
{
//Find PropertyTypes that belong to the current PropertyTypeGroup
var groupId = propertyTypeGroup.Id.Value;
var propertyTypesByGroup =
dto.PropertyTypes.Where(
x => x.Id.HasValue && x.PropertyTypeGroupId.HasValue && x.PropertyTypeGroupId.Value.Equals(groupId));
//Create PropertyTypeCollection for passing into the PropertyTypeGroup, and loop through the above result to create PropertyTypes
var propertyTypeCollection = new PropertyTypeCollection();
foreach (var propTypeDto in propertyTypesByGroup)
var group = new PropertyGroup();
//Only assign an Id if the PropertyGroup belongs to this ContentType
if (groupDto.ContentTypeNodeId == memberType.Id)
{
//Internal dictionary for adding "MemberCanEdit" and "VisibleOnProfile" properties to each PropertyType
memberType.MemberTypePropertyTypes.Add(propTypeDto.Alias,
new Tuple<bool, bool, int>(propTypeDto.CanEdit, propTypeDto.ViewOnProfile, propTypeDto.Id.Value));
//PropertyType Collection
propertyTypeCollection.Add(new PropertyType(propTypeDto.ControlId,
propTypeDto.DbType.EnumParse<DataTypeDatabaseType>(true))
{
Alias = propTypeDto.Alias,
DataTypeDefinitionId = propTypeDto.DataTypeId,
Description = propTypeDto.Description,
HelpText = propTypeDto.HelpText,
Id = propTypeDto.Id.Value,
Mandatory = propTypeDto.Mandatory,
Name = propTypeDto.Name,
SortOrder = propTypeDto.SortOrder,
ValidationRegExp = propTypeDto.ValidationRegExp,
PropertyGroupId = new Lazy<int>(() => propTypeDto.PropertyTypeGroupId.Value),
CreateDate = dto.CreateDate,
UpdateDate = dto.CreateDate
});
group.Id = groupDto.Id.Value;
if (groupDto.ParentGroupId.HasValue)
group.ParentId = groupDto.ParentGroupId.Value;
}
else
{
//If the PropertyGroup is inherited, we add a reference to the group as a Parent.
group.ParentId = groupDto.Id;
}
var group = new PropertyGroup(propertyTypeCollection) {Id = groupId};
propertyTypeGroupCollection.Add(@group);
group.Name = groupDto.Text;
group.SortOrder = groupDto.SortOrder;
group.PropertyTypes = new PropertyTypeCollection();
//Because we are likely to have a group with no PropertyTypes we need to ensure that these are excluded
var localGroupDto = groupDto;
var typeDtos = dto.PropertyTypes.Where(x => x.Id.HasValue && x.Id > 0 && x.PropertyTypeGroupId.HasValue && x.PropertyTypeGroupId.Value == localGroupDto.Id.Value);
foreach (var typeDto in typeDtos)
{
//Internal dictionary for adding "MemberCanEdit" and "VisibleOnProfile" properties to each PropertyType
memberType.MemberTypePropertyTypes.Add(typeDto.Alias,
new Tuple<bool, bool, int>(typeDto.CanEdit, typeDto.ViewOnProfile, typeDto.Id.Value));
var tempGroupDto = groupDto;
var propertyType = new PropertyType(typeDto.ControlId,
typeDto.DbType.EnumParse<DataTypeDatabaseType>(true))
{
Alias = typeDto.Alias,
DataTypeDefinitionId = typeDto.DataTypeId,
Description = typeDto.Description,
Id = typeDto.Id.Value,
Name = typeDto.Name,
HelpText = typeDto.HelpText,
Mandatory = typeDto.Mandatory,
SortOrder = typeDto.SortOrder,
ValidationRegExp = typeDto.ValidationRegExp,
PropertyGroupId = new Lazy<int>(() => tempGroupDto.Id.Value),
CreateDate = memberType.CreateDate,
UpdateDate = memberType.UpdateDate
};
//on initial construction we don't want to have dirty properties tracked
// http://issues.umbraco.org/issue/U4-1946
propertyType.ResetDirtyProperties(false);
group.PropertyTypes.Add(propertyType);
}
//on initial construction we don't want to have dirty properties tracked
// http://issues.umbraco.org/issue/U4-1946
group.ResetDirtyProperties(false);
propertyGroups.Add(group);
}
return propertyTypeGroupCollection;
return propertyGroups;
}
private List<PropertyType> GetPropertyTypes(MemberTypeReadOnlyDto dto, MemberType memberType)
{
//Find PropertyTypes that does not belong to a PropertyTypeGroup
var propertyTypes = new List<PropertyType>();
foreach (var propertyType in dto.PropertyTypes.Where(x => x.PropertyTypeGroupId.HasValue == false && x.Id.HasValue))
foreach (var propertyType in dto.PropertyTypes.Where(x => (x.PropertyTypeGroupId.HasValue == false || x.PropertyTypeGroupId.Value == 0) && x.Id.HasValue))
{
//Internal dictionary for adding "MemberCanEdit" and "VisibleOnProfile" properties to each PropertyType
memberType.MemberTypePropertyTypes.Add(propertyType.Alias,

View File

@@ -15,6 +15,8 @@ namespace Umbraco.Core.Persistence.Relators
if (a == null)
return Current;
p.VersionId = a.VersionId;
// Is this the same MemberReadOnlyDto as the current one we're processing
if (Current != null && Current.UniqueId == a.UniqueId)
{

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models.Rdbms;
namespace Umbraco.Core.Persistence.Relators
@@ -21,7 +22,7 @@ namespace Umbraco.Core.Persistence.Relators
// Yes, just add this PropertyTypeReadOnlyDto to the current MemberTypeReadOnlyDto's collection
Current.PropertyTypes.Add(p);
if(g.Id.HasValue)
if (g.Id.HasValue && Current.PropertyTypeGroups != null && Current.PropertyTypeGroups.Any(x => x.Id == g.Id.Value) == false)
Current.PropertyTypeGroups.Add(g);
// Return null to indicate we're not done with this MemberTypeReadOnlyDto yet

View File

@@ -229,10 +229,8 @@ namespace Umbraco.Core.Persistence.Repositories
dto.NodeId = nodeDto.NodeId;
Database.Insert(dto);
//TODO ContentType for the Member entity
//Create the PropertyData for this version - cmsPropertyData
/*var propertyFactory = new PropertyFactory(entity.ContentType, entity.Version, entity.Id);
var propertyFactory = new PropertyFactory(entity.ContentType, entity.Version, entity.Id);
var propertyDataDtos = propertyFactory.BuildDto(((Member)entity).Properties);
var keyDictionary = new Dictionary<int, int>();
@@ -247,7 +245,7 @@ namespace Umbraco.Core.Persistence.Repositories
foreach (var property in ((Member)entity).Properties)
{
property.Id = keyDictionary[property.PropertyTypeId];
}*/
}
((Member)entity).ResetDirtyProperties();
}
@@ -300,7 +298,7 @@ namespace Umbraco.Core.Persistence.Repositories
//TODO ContentType for the Member entity
//Create the PropertyData for this version - cmsPropertyData
/*var propertyFactory = new PropertyFactory(entity.ContentType, entity.Version, entity.Id);
var propertyFactory = new PropertyFactory(entity.ContentType, entity.Version, entity.Id);
var propertyDataDtos = propertyFactory.BuildDto(((Member)entity).Properties);
var keyDictionary = new Dictionary<int, int>();
@@ -325,7 +323,7 @@ namespace Umbraco.Core.Persistence.Repositories
{
property.Id = keyDictionary[property.PropertyTypeId];
}
}*/
}
((ICanBeDirty)entity).ResetDirtyProperties();
}

View File

@@ -101,10 +101,10 @@ namespace Umbraco.Core.Persistence.Repositories
sql.Select("umbracoNode.*", "cmsContentType.*", "cmsPropertyType.id AS PropertyTypeId", "cmsPropertyType.Alias",
"cmsPropertyType.Name", "cmsPropertyType.Description", "cmsPropertyType.helpText", "cmsPropertyType.mandatory",
"cmsPropertyType.validationRegExp", "cmsPropertyType.dataTypeId", "cmsPropertyType.sortOrder AS PropertyTypeSortOrder",
"cmsPropertyType.propertyTypeGroupId", "cmsMemberType.memberCanEdit", "cmsMemberType.viewOnProfile",
"cmsPropertyType.propertyTypeGroupId AS PropertyTypesGroupId", "cmsMemberType.memberCanEdit", "cmsMemberType.viewOnProfile",
"cmsDataType.controlId", "cmsDataType.dbType", "cmsPropertyTypeGroup.id AS PropertyTypeGroupId",
"cmsPropertyTypeGroup.text AS PropertyGroupName", "cmsPropertyTypeGroup.parentGroupId",
"cmsPropertyTypeGroup.sortorder AS PropertyGroupSortOrder")
"cmsPropertyTypeGroup.text AS PropertyGroupName", "cmsPropertyTypeGroup.parentGroupId",
"cmsPropertyTypeGroup.sortorder AS PropertyGroupSortOrder", "cmsPropertyTypeGroup.contenttypeNodeId")
.From<NodeDto>()
.InnerJoin<ContentTypeDto>().On<ContentTypeDto, NodeDto>(left => left.NodeId, right => right.NodeId)
.LeftJoin<PropertyTypeDto>().On<PropertyTypeDto, NodeDto>(left => left.ContentTypeId, right => right.NodeId)

View File

@@ -200,13 +200,13 @@ namespace Umbraco.Core.Services
/// <summary>
/// Creates a new Member
/// </summary>
/// <param name="username"></param>
/// <param name="email"></param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <param name="memberTypeAlias"></param>
/// <param name="userId"></param>
/// <returns></returns>
public IMember CreateMember(string username, string email, string password, string memberTypeAlias, int userId = 0)
public IMember CreateMember(string email, string username, string password, string memberTypeAlias, int userId = 0)
{
var uow = _uowProvider.GetUnitOfWork();
IMemberType memberType;
@@ -220,14 +220,10 @@ namespace Umbraco.Core.Services
if (memberType == null)
throw new Exception(string.Format("No MemberType matching the passed in Alias: '{0}' was found", memberTypeAlias));
var member = new Member(email, -1, memberType, new PropertyCollection());
var member = new Member(email, email, username, password, -1, memberType);
using (var repository = _repositoryFactory.CreateMemberRepository(uow))
{
member.Username = username;
member.Email = email;
member.Password = password;
repository.AddOrUpdate(member);
uow.Commit();
}