generated from Kentico/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,755 additions
and
1,755 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
1,438 changes: 719 additions & 719 deletions
1,438
KVA/Migration.Tool.Source/Handlers/MigratePagesCommandHandler.cs
Large diffs are not rendered by default.
Oops, something went wrong.
158 changes: 79 additions & 79 deletions
158
KVA/Migration.Tool.Source/Helpers/PageBuilderWidgetsPatcher.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 |
---|---|---|
@@ -1,79 +1,79 @@ | ||
using Migration.Tool.Common.Helpers; | ||
using Migration.Tool.Common.Model; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Migration.Tool.Source.Helpers; | ||
|
||
public static class PageBuilderWidgetsPatcher | ||
{ | ||
public static EditableAreasConfiguration DeferredPatchConfiguration(EditableAreasConfiguration configuration, TreePathConvertor convertor, out bool anythingChanged) | ||
{ | ||
anythingChanged = false; | ||
foreach (var configurationEditableArea in configuration.EditableAreas ?? []) | ||
{ | ||
foreach (var sectionConfiguration in configurationEditableArea.Sections ?? []) | ||
{ | ||
foreach (var sectionConfigurationZone in sectionConfiguration.Zones ?? []) | ||
{ | ||
foreach (var configurationZoneWidget in sectionConfigurationZone.Widgets ?? []) | ||
{ | ||
DeferredPatchWidget(configurationZoneWidget, convertor, out bool anythingChangedTmp); | ||
anythingChanged = anythingChanged || anythingChangedTmp; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return configuration; | ||
} | ||
|
||
private static void DeferredPatchWidget(WidgetConfiguration? configurationZoneWidget, TreePathConvertor convertor, out bool anythingChanged) | ||
{ | ||
anythingChanged = false; | ||
if (configurationZoneWidget == null) | ||
{ | ||
return; | ||
} | ||
|
||
var list = configurationZoneWidget.Variants ?? []; | ||
for (int i = 0; i < list.Count; i++) | ||
{ | ||
if (list[i] is { } variantJson) | ||
{ | ||
var variant = JObject.FromObject(variantJson); | ||
DeferredPatchProperties(variant, convertor, out bool anythingChangedTmp); | ||
|
||
list[i] = variant.ToObject<WidgetVariantConfiguration>(); | ||
anythingChanged = anythingChanged || anythingChangedTmp; | ||
} | ||
} | ||
} | ||
|
||
public static void DeferredPatchProperties(JObject propertyContainer, TreePathConvertor convertor, out bool anythingChanged) | ||
{ | ||
anythingChanged = false; | ||
if (propertyContainer?["properties"] is JObject { Count: 1 } properties) | ||
{ | ||
foreach ((string key, var value) in properties) | ||
{ | ||
switch (key) | ||
{ | ||
case "TreePath" when value?.Value<string>() is { } nodeAliasPath: | ||
{ | ||
string treePath = convertor.GetConvertedOrUnchangedAssumingChannel(nodeAliasPath); | ||
if (!TreePathConvertor.TreePathComparer.Equals(nodeAliasPath, treePath)) | ||
{ | ||
properties["TreePath"] = JToken.FromObject(treePath); | ||
anythingChanged = true; | ||
} | ||
|
||
break; | ||
} | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
using Migration.Tool.Common.Helpers; | ||
using Migration.Tool.Common.Model; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Migration.Tool.Source.Helpers; | ||
|
||
public static class PageBuilderWidgetsPatcher | ||
{ | ||
public static EditableAreasConfiguration DeferredPatchConfiguration(EditableAreasConfiguration configuration, TreePathConvertor convertor, out bool anythingChanged) | ||
{ | ||
anythingChanged = false; | ||
foreach (var configurationEditableArea in configuration.EditableAreas ?? []) | ||
{ | ||
foreach (var sectionConfiguration in configurationEditableArea.Sections ?? []) | ||
{ | ||
foreach (var sectionConfigurationZone in sectionConfiguration.Zones ?? []) | ||
{ | ||
foreach (var configurationZoneWidget in sectionConfigurationZone.Widgets ?? []) | ||
{ | ||
DeferredPatchWidget(configurationZoneWidget, convertor, out bool anythingChangedTmp); | ||
anythingChanged = anythingChanged || anythingChangedTmp; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return configuration; | ||
} | ||
|
||
private static void DeferredPatchWidget(WidgetConfiguration? configurationZoneWidget, TreePathConvertor convertor, out bool anythingChanged) | ||
{ | ||
anythingChanged = false; | ||
if (configurationZoneWidget == null) | ||
{ | ||
return; | ||
} | ||
|
||
var list = configurationZoneWidget.Variants ?? []; | ||
for (int i = 0; i < list.Count; i++) | ||
{ | ||
if (list[i] is { } variantJson) | ||
{ | ||
var variant = JObject.FromObject(variantJson); | ||
DeferredPatchProperties(variant, convertor, out bool anythingChangedTmp); | ||
|
||
list[i] = variant.ToObject<WidgetVariantConfiguration>(); | ||
anythingChanged = anythingChanged || anythingChangedTmp; | ||
} | ||
} | ||
} | ||
|
||
public static void DeferredPatchProperties(JObject propertyContainer, TreePathConvertor convertor, out bool anythingChanged) | ||
{ | ||
anythingChanged = false; | ||
if (propertyContainer?["properties"] is JObject { Count: 1 } properties) | ||
{ | ||
foreach ((string key, var value) in properties) | ||
{ | ||
switch (key) | ||
{ | ||
case "TreePath" when value?.Value<string>() is { } nodeAliasPath: | ||
{ | ||
string treePath = convertor.GetConvertedOrUnchangedAssumingChannel(nodeAliasPath); | ||
if (!TreePathConvertor.TreePathComparer.Equals(nodeAliasPath, treePath)) | ||
{ | ||
properties["TreePath"] = JToken.FromObject(treePath); | ||
anythingChanged = true; | ||
} | ||
|
||
break; | ||
} | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,109 +1,109 @@ | ||
using CMS.DataEngine; | ||
using CMS.FormEngine; | ||
using CMS.MediaLibrary; | ||
using CMS.Membership; | ||
using CMS.Modules; | ||
using CMS.OnlineForms; | ||
using CMS.Websites; | ||
|
||
using Kentico.Xperience.UMT; | ||
|
||
using MediatR; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
using Migration.Tool.Common; | ||
using Migration.Tool.Common.Abstractions; | ||
using Migration.Tool.Common.MigrationProtocol; | ||
using Migration.Tool.Common.Services; | ||
using Migration.Tool.Common.Services.BulkCopy; | ||
using Migration.Tool.Common.Services.Ipc; | ||
using Migration.Tool.KXP.Models; | ||
using Migration.Tool.Source.Auxiliary; | ||
using Migration.Tool.Source.Behaviors; | ||
using Migration.Tool.Source.Contexts; | ||
using Migration.Tool.Source.Helpers; | ||
using Migration.Tool.Source.Mappers; | ||
using Migration.Tool.Source.Model; | ||
using Migration.Tool.Source.Providers; | ||
using Migration.Tool.Source.Services; | ||
|
||
namespace Migration.Tool.Source; | ||
|
||
public static class KsCoreDiExtensions | ||
{ | ||
public static IServiceProvider ServiceProvider { get; private set; } = null!; | ||
public static void InitServiceProvider(IServiceProvider serviceProvider) => ServiceProvider = serviceProvider; | ||
|
||
public static IServiceCollection UseKsToolCore(this IServiceCollection services, bool? migrateMediaToMediaLibrary = false) | ||
{ | ||
var printService = new PrintService(); | ||
services.AddSingleton<IPrintService>(printService); | ||
HandbookReference.PrintService = printService; | ||
LogExtensions.PrintService = printService; | ||
|
||
services.AddTransient<IModuleLoader, ModuleLoader>(); | ||
|
||
services.AddSingleton<ModelFacade>(); | ||
services.AddSingleton<ISpoiledGuidContext, SpoiledGuidContext>(); | ||
services.AddSingleton(s => s.GetRequiredService<ISpoiledGuidContext>() as SpoiledGuidContext ?? throw new InvalidOperationException()); | ||
|
||
services.AddSingleton<ISourceGuidContext, SourceGuidContext>(); | ||
services.AddSingleton<EntityIdentityFacade>(); | ||
services.AddSingleton<IdentityLocator>(); | ||
services.AddSingleton<IAssetFacade, AssetFacade>(); | ||
services.AddSingleton<MediaLinkServiceFactory>(); | ||
services.AddSingleton<ClassMappingProvider>(); | ||
services.AddTransient<PageBuilderPatcher>(); | ||
|
||
services.AddTransient<BulkDataCopyService>(); | ||
services.AddTransient<CmsRelationshipService>(); | ||
services.AddTransient<CoupledDataService>(); | ||
if (migrateMediaToMediaLibrary ?? false) | ||
{ | ||
services.AddScoped<IAttachmentMigrator, AttachmentMigratorToMediaLibrary>(); | ||
services.AddScoped<IMediaFileMigrator, MediaFileMigrator>(); | ||
} | ||
else | ||
{ | ||
services.AddScoped<IAttachmentMigrator, AttachmentMigratorToContentItem>(); | ||
services.AddScoped<IMediaFileMigrator, MediaFileMigratorToContentItem>(); | ||
} | ||
services.AddScoped<PageTemplateMigrator>(); | ||
services.AddScoped<ClassService>(); | ||
|
||
services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(KsCoreDiExtensions).Assembly)); | ||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(RequestHandlingBehavior<,>)); | ||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CommandConstraintBehavior<,>)); | ||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(XbKApiContextBehavior<,>)); | ||
|
||
services.AddSingleton<SourceInstanceContext>(); | ||
services.AddSingleton<DeferredPathService>(); | ||
services.AddTransient<IpcService>(); | ||
services.AddTransient<ReusableSchemaService>(); | ||
|
||
services.AddScoped<PrimaryKeyMappingContext>(); | ||
services.AddScoped<IPrimaryKeyMappingContext, PrimaryKeyMappingContext>(s => s.GetRequiredService<PrimaryKeyMappingContext>()); | ||
services.AddScoped<IPrimaryKeyLocatorService, PrimaryKeyLocatorService>(); | ||
|
||
// umt mappers | ||
services.AddTransient<IUmtMapper<CmsTreeMapperSource>, ContentItemMapper>(); | ||
services.AddTransient<IUmtMapper<TagModelSource>, TagMapper>(); | ||
|
||
// mappers | ||
services.AddTransient<IEntityMapper<CmsAttachmentMapperSource, MediaFileInfo>, CmsAttachmentMapper>(); | ||
services.AddTransient<IEntityMapper<ICmsClass, DataClassInfo>, CmsClassMapper>(); | ||
services.AddTransient<IEntityMapper<ICmsForm, BizFormInfo>, CmsFormMapper>(); | ||
services.AddTransient<IEntityMapper<ICmsForm, CmsForm>, CmsFormMapperEf>(); | ||
services.AddTransient<IEntityMapper<ICmsResource, ResourceInfo>, ResourceMapper>(); | ||
services.AddTransient<IEntityMapper<AlternativeFormMapperSource, AlternativeFormInfo>, AlternativeFormMapper>(); | ||
services.AddTransient<IEntityMapper<MemberInfoMapperSource, MemberInfo>, MemberInfoMapper>(); | ||
services.AddTransient<IEntityMapper<ICmsPageTemplateConfiguration, PageTemplateConfigurationInfo>, PageTemplateConfigurationMapper>(); | ||
services.AddTransient<IEntityMapper<MediaLibraryInfoMapperSource, MediaLibraryInfo>, MediaLibraryInfoMapper>(); | ||
services.AddTransient<IEntityMapper<MediaFileInfoMapperSource, MediaFileInfo>, MediaFileInfoMapper>(); | ||
|
||
services.AddUniversalMigrationToolkit(); | ||
|
||
return services; | ||
} | ||
} | ||
using CMS.DataEngine; | ||
using CMS.FormEngine; | ||
using CMS.MediaLibrary; | ||
using CMS.Membership; | ||
using CMS.Modules; | ||
using CMS.OnlineForms; | ||
using CMS.Websites; | ||
|
||
using Kentico.Xperience.UMT; | ||
|
||
using MediatR; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
using Migration.Tool.Common; | ||
using Migration.Tool.Common.Abstractions; | ||
using Migration.Tool.Common.MigrationProtocol; | ||
using Migration.Tool.Common.Services; | ||
using Migration.Tool.Common.Services.BulkCopy; | ||
using Migration.Tool.Common.Services.Ipc; | ||
using Migration.Tool.KXP.Models; | ||
using Migration.Tool.Source.Auxiliary; | ||
using Migration.Tool.Source.Behaviors; | ||
using Migration.Tool.Source.Contexts; | ||
using Migration.Tool.Source.Helpers; | ||
using Migration.Tool.Source.Mappers; | ||
using Migration.Tool.Source.Model; | ||
using Migration.Tool.Source.Providers; | ||
using Migration.Tool.Source.Services; | ||
|
||
namespace Migration.Tool.Source; | ||
|
||
public static class KsCoreDiExtensions | ||
{ | ||
public static IServiceProvider ServiceProvider { get; private set; } = null!; | ||
public static void InitServiceProvider(IServiceProvider serviceProvider) => ServiceProvider = serviceProvider; | ||
|
||
public static IServiceCollection UseKsToolCore(this IServiceCollection services, bool? migrateMediaToMediaLibrary = false) | ||
{ | ||
var printService = new PrintService(); | ||
services.AddSingleton<IPrintService>(printService); | ||
HandbookReference.PrintService = printService; | ||
LogExtensions.PrintService = printService; | ||
|
||
services.AddTransient<IModuleLoader, ModuleLoader>(); | ||
|
||
services.AddSingleton<ModelFacade>(); | ||
services.AddSingleton<ISpoiledGuidContext, SpoiledGuidContext>(); | ||
services.AddSingleton(s => s.GetRequiredService<ISpoiledGuidContext>() as SpoiledGuidContext ?? throw new InvalidOperationException()); | ||
|
||
services.AddSingleton<ISourceGuidContext, SourceGuidContext>(); | ||
services.AddSingleton<EntityIdentityFacade>(); | ||
services.AddSingleton<IdentityLocator>(); | ||
services.AddSingleton<IAssetFacade, AssetFacade>(); | ||
services.AddSingleton<MediaLinkServiceFactory>(); | ||
services.AddSingleton<ClassMappingProvider>(); | ||
services.AddTransient<PageBuilderPatcher>(); | ||
|
||
services.AddTransient<BulkDataCopyService>(); | ||
services.AddTransient<CmsRelationshipService>(); | ||
services.AddTransient<CoupledDataService>(); | ||
if (migrateMediaToMediaLibrary ?? false) | ||
{ | ||
services.AddScoped<IAttachmentMigrator, AttachmentMigratorToMediaLibrary>(); | ||
services.AddScoped<IMediaFileMigrator, MediaFileMigrator>(); | ||
} | ||
else | ||
{ | ||
services.AddScoped<IAttachmentMigrator, AttachmentMigratorToContentItem>(); | ||
services.AddScoped<IMediaFileMigrator, MediaFileMigratorToContentItem>(); | ||
} | ||
services.AddScoped<PageTemplateMigrator>(); | ||
services.AddScoped<ClassService>(); | ||
|
||
services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(KsCoreDiExtensions).Assembly)); | ||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(RequestHandlingBehavior<,>)); | ||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CommandConstraintBehavior<,>)); | ||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(XbKApiContextBehavior<,>)); | ||
|
||
services.AddSingleton<SourceInstanceContext>(); | ||
services.AddSingleton<DeferredPathService>(); | ||
services.AddTransient<IpcService>(); | ||
services.AddTransient<ReusableSchemaService>(); | ||
|
||
services.AddScoped<PrimaryKeyMappingContext>(); | ||
services.AddScoped<IPrimaryKeyMappingContext, PrimaryKeyMappingContext>(s => s.GetRequiredService<PrimaryKeyMappingContext>()); | ||
services.AddScoped<IPrimaryKeyLocatorService, PrimaryKeyLocatorService>(); | ||
|
||
// umt mappers | ||
services.AddTransient<IUmtMapper<CmsTreeMapperSource>, ContentItemMapper>(); | ||
services.AddTransient<IUmtMapper<TagModelSource>, TagMapper>(); | ||
|
||
// mappers | ||
services.AddTransient<IEntityMapper<CmsAttachmentMapperSource, MediaFileInfo>, CmsAttachmentMapper>(); | ||
services.AddTransient<IEntityMapper<ICmsClass, DataClassInfo>, CmsClassMapper>(); | ||
services.AddTransient<IEntityMapper<ICmsForm, BizFormInfo>, CmsFormMapper>(); | ||
services.AddTransient<IEntityMapper<ICmsForm, CmsForm>, CmsFormMapperEf>(); | ||
services.AddTransient<IEntityMapper<ICmsResource, ResourceInfo>, ResourceMapper>(); | ||
services.AddTransient<IEntityMapper<AlternativeFormMapperSource, AlternativeFormInfo>, AlternativeFormMapper>(); | ||
services.AddTransient<IEntityMapper<MemberInfoMapperSource, MemberInfo>, MemberInfoMapper>(); | ||
services.AddTransient<IEntityMapper<ICmsPageTemplateConfiguration, PageTemplateConfigurationInfo>, PageTemplateConfigurationMapper>(); | ||
services.AddTransient<IEntityMapper<MediaLibraryInfoMapperSource, MediaLibraryInfo>, MediaLibraryInfoMapper>(); | ||
services.AddTransient<IEntityMapper<MediaFileInfoMapperSource, MediaFileInfo>, MediaFileInfoMapper>(); | ||
|
||
services.AddUniversalMigrationToolkit(); | ||
|
||
return services; | ||
} | ||
} |
Oops, something went wrong.