generated from Kentico/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#238 ability to extend Migration Tool
- Loading branch information
Showing
26 changed files
with
1,449 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using CMS.FormEngine; | ||
using Migration.Toolkit.KXP.Api.Services.CmsClass; | ||
using Migration.Toolkit.Source.Model; | ||
|
||
namespace Migration.Toolkit.Source.Contexts; | ||
|
||
public record DocumentSourceObjectContext(ICmsTree CmsTree, ICmsClass NodeClass, ICmsSite Site, FormInfo OldFormInfo, FormInfo NewFormInfo, int? DocumentId) : ISourceObjectContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
KVA/Migration.Toolkit.Source/Helpers/FormDefinitionHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using CMS.DataEngine; | ||
using CMS.FormEngine; | ||
using Microsoft.Extensions.Logging; | ||
using Migration.Toolkit.KXP.Api.Services.CmsClass; | ||
using Migration.Toolkit.Source.Model; | ||
|
||
namespace Migration.Toolkit.Source.Helpers; | ||
|
||
public static class FormDefinitionHelper | ||
{ | ||
public static void MapFormDefinitionFields(ILogger logger, IFieldMigrationService fieldMigrationService, ICmsClass source, DataClassInfo target, bool isCustomizableSystemClass, bool classIsCustom) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(source.ClassFormDefinition)) | ||
{ | ||
var patcher = new FormDefinitionPatcher( | ||
logger, | ||
source.ClassFormDefinition, | ||
fieldMigrationService, | ||
source.ClassIsForm.GetValueOrDefault(false), | ||
source.ClassIsDocumentType, | ||
isCustomizableSystemClass, | ||
classIsCustom | ||
); | ||
|
||
patcher.PatchFields(); | ||
patcher.RemoveCategories(); // TODO tk: 2022-10-11 remove when supported | ||
|
||
string? result = patcher.GetPatched(); | ||
if (isCustomizableSystemClass) | ||
{ | ||
result = FormHelper.MergeFormDefinitions(target.ClassFormDefinition, result); | ||
} | ||
|
||
var formInfo = new FormInfo(result); | ||
target.ClassFormDefinition = formInfo.GetXmlDefinition(); | ||
} | ||
else | ||
{ | ||
target.ClassFormDefinition = new FormInfo().GetXmlDefinition(); | ||
} | ||
} | ||
|
||
public static void MapFormDefinitionFields(ILogger logger, IFieldMigrationService fieldMigrationService, | ||
string sourceClassDefinition, bool? classIsForm, bool classIsDocumentType, | ||
DataClassInfo target, bool isCustomizableSystemClass, bool classIsCustom) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(sourceClassDefinition)) | ||
{ | ||
var patcher = new FormDefinitionPatcher( | ||
logger, | ||
sourceClassDefinition, | ||
fieldMigrationService, | ||
classIsForm.GetValueOrDefault(false), | ||
classIsDocumentType, | ||
isCustomizableSystemClass, | ||
classIsCustom | ||
); | ||
|
||
patcher.PatchFields(); | ||
patcher.RemoveCategories(); // TODO tk: 2022-10-11 remove when supported | ||
|
||
string? result = patcher.GetPatched(); | ||
if (isCustomizableSystemClass) | ||
{ | ||
result = FormHelper.MergeFormDefinitions(target.ClassFormDefinition, result); | ||
} | ||
|
||
var formInfo = new FormInfo(result); | ||
target.ClassFormDefinition = formInfo.GetXmlDefinition(); | ||
} | ||
else | ||
{ | ||
target.ClassFormDefinition = new FormInfo().GetXmlDefinition(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.