Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v1.3.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
afaniuolo committed Nov 18, 2020
2 parents be3a8e6 + 6031449 commit 0c67b0f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public override List<SCItem> ConvertValueElementToItems(SCField scField, string
{
List<SCItem> convertedItems = new List<SCItem>();

var languages = sourceItem.Fields.Where(f => f.Language != null).Select(f => f.Language).Distinct();

var decodedElementValue = Uri.UnescapeDataString(elementValue).Replace("+", " ");

var queryElements = XmlHelper.GetXmlElementNodeList(decodedElementValue, "query");
Expand Down
45 changes: 45 additions & 0 deletions src/WFFM.ConversionTool.Library/Converters/ItemConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ private List<SCItem> ConvertFields(SCItem destItem, SCItem lastDescendantItem)
List<SCItem> convertedItems = converter?.ConvertValueElementToItems(filteredConvertedField,
XmlHelper.GetXmlElementValue(filteredConvertedField.Value, valueXmlElementMapping.sourceElementName),
listItemMetadataTemplate, lastDescendantItem ?? destItem);

if (convertedItems != null && convertedItems.Any())
{
destItems.AddRange(convertedItems);
Expand Down Expand Up @@ -246,6 +247,9 @@ private List<SCItem> ConvertFields(SCItem destItem, SCItem lastDescendantItem)
destItem.Fields = destFields;
destItems.Add(destItem);

// Merge multi-language List items with same value
destItems = MergeListItems(destItems);

// Reporting
var unmappedSourceFields = sourceFields?.Where(f => (_itemMetadataTemplate.fields.existingFields == null || !_itemMetadataTemplate.fields.existingFields.Select(mf => mf.fieldId).Contains(f.FieldId))
&& (_itemMetadataTemplate.fields.convertedFields == null || !_itemMetadataTemplate.fields.convertedFields.Select(mf => mf.sourceFieldId).Contains(f.FieldId)));
Expand All @@ -257,5 +261,46 @@ private List<SCItem> ConvertFields(SCItem destItem, SCItem lastDescendantItem)

return destItems;
}

private List<SCItem> MergeListItems(List<SCItem> convertedListItems)
{
List<SCItem> mergedListItems = new List<SCItem>();
foreach (var convertedListItem in convertedListItems)
{
if (convertedListItem.TemplateID == new Guid("{B3BDFE59-6667-4432-B261-05D0E3F7FDF6}"))
{
var existingListItem = mergedListItems.FirstOrDefault(i =>
string.Equals(
i.Fields.First(f => f.FieldId == new Guid("{3A07C171-9BCA-464D-8670-C5703C6D3F11}"))
.Value,
convertedListItem.Fields.First(f =>
f.FieldId == new Guid("{3A07C171-9BCA-464D-8670-C5703C6D3F11}"))
.Value, StringComparison.InvariantCultureIgnoreCase));

if (existingListItem != null)
{
foreach (var field in convertedListItem.Fields)
{
convertedListItem.Fields.ForEach(f => f.ItemId = existingListItem.ID);
}

mergedListItems.FirstOrDefault(i =>
string.Equals(
i.Fields.First(f => f.FieldId == new Guid("{3A07C171-9BCA-464D-8670-C5703C6D3F11}"))
.Value,
convertedListItem.Fields.First(f =>
f.FieldId == new Guid("{3A07C171-9BCA-464D-8670-C5703C6D3F11}"))
.Value, StringComparison.InvariantCultureIgnoreCase))?.Fields
.AddRange(convertedListItem.Fields);

continue;
}
}

mergedListItems.Add(convertedListItem);

}
return mergedListItems;
}
}
}
4 changes: 2 additions & 2 deletions src/WFFM.ConversionTool.Library/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
[assembly: AssemblyFileVersion("1.3.2.0")]
2 changes: 1 addition & 1 deletion src/WFFM.ConversionTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void Main(string[] args)
System.Console.WriteLine();
System.Console.WriteLine(" ***********************************************************************");
System.Console.WriteLine(" * *");
System.Console.WriteLine(" * WFFM Conversion Tool - v1.3.1 *");
System.Console.WriteLine(" * WFFM Conversion Tool - v1.3.2 *");
System.Console.WriteLine(" * *");
System.Console.WriteLine(" ***********************************************************************");
System.Console.WriteLine();
Expand Down
4 changes: 2 additions & 2 deletions src/WFFM.ConversionTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
[assembly: AssemblyFileVersion("1.3.2.0")]

0 comments on commit 0c67b0f

Please sign in to comment.