Fixes packaging service up to export data type's properly, fixes legacy DataTypeDefinition to export data type's properly with the prop ed alias instead of id, obsoletes old content extension methods.

This commit is contained in:
Shannon
2013-10-28 11:02:04 +11:00
parent 757086b7bd
commit a915dff4a8
4 changed files with 27 additions and 23 deletions

View File

@@ -746,7 +746,8 @@ namespace Umbraco.Core.Services
var xml = new XElement("DataType", prevalues);
xml.Add(new XAttribute("Name", dataTypeDefinition.Name));
xml.Add(new XAttribute("Id", dataTypeDefinition.Id));
//The 'ID' when exporting is actually the property editor alias (in pre v7 it was the IDataType GUID id)
xml.Add(new XAttribute("Id", dataTypeDefinition.PropertyEditorAlias));
xml.Add(new XAttribute("Definition", dataTypeDefinition.Key));
xml.Add(new XAttribute("DatabaseType", dataTypeDefinition.DatabaseType.ToString()));

View File

@@ -368,15 +368,6 @@ namespace umbraco.presentation.developer.packages
packageFilesRepeater.DataBind();
}
private static string JoinList(List<string> list, char seperator) {
string retVal = "";
foreach (string str in list) {
retVal += str + seperator.ToString();
}
return retVal.Trim(seperator);
}
protected override void OnInit(EventArgs e)
{
// Tab setup

View File

@@ -22,6 +22,7 @@ namespace umbraco
/// <returns>
/// <c>true</c> if the specified content item has property; otherwise, <c>false</c>.
/// </returns>
[Obsolete("Use the new Services APIs instead")]
public static bool HasProperty(this Content item, string propertyAlias)
{
var property = item.getProperty(propertyAlias);
@@ -35,6 +36,7 @@ namespace umbraco
/// <param name="item">The content item.</param>
/// <param name="propertyAlias">alias of property to get</param>
/// <returns>default(T) or property value cast to (T)</returns>
[Obsolete("Use the new Services APIs instead")]
public static T GetProperty<T>(this Content item, string propertyAlias)
{
// check to see if return object handles it's own object hydration
@@ -106,6 +108,7 @@ namespace umbraco
/// <returns>
/// empty string, or property value as string
/// </returns>
[Obsolete("Use the new Services APIs instead")]
private static string GetPropertyAsString(this Content item, string propertyAlias)
{
var propertyValue = string.Empty;
@@ -127,6 +130,7 @@ namespace umbraco
/// <returns>
/// true if can cast value, else false for all other circumstances
/// </returns>
[Obsolete("Use the new Services APIs instead")]
private static bool GetPropertyAsBoolean(this Content item, string propertyAlias)
{
var propertyValue = false;
@@ -187,6 +191,7 @@ namespace umbraco
/// <param name="items">The items.</param>
/// <param name="propertyAlias">The property alias.</param>
/// <returns></returns>
[Obsolete("Use the new Services APIs instead")]
public static IEnumerable<Content> OrderByProperty<T>(this IEnumerable<Content> items, string propertyAlias)
{
return items.OrderBy(x => x.GetProperty<T>(propertyAlias));
@@ -213,6 +218,7 @@ namespace umbraco
/// <param name="items">The items.</param>
/// <param name="propertyAlias">The property alias.</param>
/// <returns></returns>
[Obsolete("Use the new Services APIs instead")]
public static IEnumerable<Content> OrderByPropertyDescending<T>(this IEnumerable<Content> items, string propertyAlias)
{
return items.OrderByDescending(x => x.GetProperty<T>(propertyAlias));
@@ -239,6 +245,7 @@ namespace umbraco
/// <returns>
/// The same content item on which this is an extension method.
/// </returns>
[Obsolete("Use the new Services APIs instead")]
public static Content SetProperty(this Content item, string propertyAlias, object value)
{
var property = item.getProperty(propertyAlias);

View File

@@ -152,15 +152,18 @@ namespace umbraco.cms.businesslogic.datatype
public XmlElement ToXml(XmlDocument xd)
{
//here we need to get the property editor alias from it's id
var alias = LegacyPropertyEditorIdToAliasConverter.GetAliasFromLegacyId(DataType.Id, true);
XmlElement dt = xd.CreateElement("DataType");
dt.Attributes.Append(xmlHelper.addAttribute(xd, "Name", Text));
dt.Attributes.Append(xmlHelper.addAttribute(xd, "Id", this.DataType.Id.ToString()));
dt.Attributes.Append(xmlHelper.addAttribute(xd, "Definition", this.UniqueId.ToString()));
dt.Attributes.Append(xmlHelper.addAttribute(xd, "DatabaseType", this.DbType));
dt.Attributes.Append(xmlHelper.addAttribute(xd, "Id", alias));
dt.Attributes.Append(xmlHelper.addAttribute(xd, "Definition", UniqueId.ToString()));
dt.Attributes.Append(xmlHelper.addAttribute(xd, "DatabaseType", DbType));
// templates
XmlElement prevalues = xd.CreateElement("PreValues");
foreach (DictionaryEntry item in PreValues.GetPreValues(this.Id))
foreach (DictionaryEntry item in PreValues.GetPreValues(Id))
{
XmlElement prevalue = xd.CreateElement("PreValue");
prevalue.Attributes.Append(xmlHelper.addAttribute(xd, "Id", ((PreValue)item.Value).Id.ToString()));
@@ -176,22 +179,24 @@ namespace umbraco.cms.businesslogic.datatype
#endregion
#region Static methods
[Obsolete("Do not use this method, it will not function correctly because legacy property editors are not supported in v7")]
public static DataTypeDefinition Import(XmlNode xmlData)
{
string _name = xmlData.Attributes["Name"].Value;
string _id = xmlData.Attributes["Id"].Value;
string _def = xmlData.Attributes["Definition"].Value;
var name = xmlData.Attributes["Name"].Value;
var id = xmlData.Attributes["Id"].Value;
var def = xmlData.Attributes["Definition"].Value;
//Make sure that the dtd is not already present
if (IsNode(new Guid(_def)) == false)
if (IsNode(new Guid(def)) == false)
{
var u = BusinessLogic.User.GetCurrent() ?? BusinessLogic.User.GetUser(0);
var dtd = MakeNew(u, _name, new Guid(_def));
var dataType = DataTypesResolver.Current.GetById(new Guid(_id));
var dtd = MakeNew(u, name, new Guid(def));
var dataType = DataTypesResolver.Current.GetById(new Guid(id));
if (dataType == null)
throw new NullReferenceException("Could not resolve a data type with id " + _id);
throw new NullReferenceException("Could not resolve a data type with id " + id);
dtd.DataType = dataType;
dtd.Save();
@@ -199,11 +204,11 @@ namespace umbraco.cms.businesslogic.datatype
//add prevalues
foreach (XmlNode xmlPv in xmlData.SelectNodes("PreValues/PreValue"))
{
XmlAttribute val = xmlPv.Attributes["Value"];
var val = xmlPv.Attributes["Value"];
if (val != null)
{
PreValue p = new PreValue(0, 0, val.Value);
var p = new PreValue(0, 0, val.Value);
p.DataTypeId = dtd.Id;
p.Save();
}