Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public async Task<CommandResult> Handle(MigrateCustomModulesCommand request, Can

private async Task MigrateClasses(EntityConfiguration entityConfiguration, CancellationToken cancellationToken)
{
var dataClassEntityConfiguration = toolConfiguration.EntityConfigurations.GetEntityConfiguration<DataClassInfo>();
var manualMappings = classMappingProvider.ExecuteMappings();

using var cmsClasses = EnumerableHelper.CreateDeferrableItemWrapper(
Expand Down Expand Up @@ -97,6 +98,12 @@ private async Task MigrateClasses(EntityConfiguration entityConfiguration, Cance
continue;
}

if (dataClassEntityConfiguration.ExcludeCodeNames.Contains(cmsClass.ClassName,
StringComparer.InvariantCultureIgnoreCase))
{
continue;
}

if (!remapped())
{
if (cmsClass.ClassInheritsFromClassID is { } classInheritsFromClassId && !primaryKeyMappingContext.HasMapping<ICmsClass>(c => c.ClassID, classInheritsFromClassId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class MigrateCustomTablesHandler(
IUmtMapper<CustomTableMapperSource> mapper,
IEntityMapper<ICmsClass, DataClassInfo> dataClassMapper,
PrimaryKeyMappingContext primaryKeyMappingContext,
ClassMappingProvider classMappingProvider
ClassMappingProvider classMappingProvider,
ToolConfiguration toolConfiguration
)
: IRequestHandler<MigrateCustomTablesCommand, CommandResult>
{
Expand Down Expand Up @@ -83,6 +84,8 @@ private async Task<ResourceInfo> EnsureCustomTablesResource()

private async Task MigrateCustomTables()
{
var dataClassEntityConfiguration = toolConfiguration.EntityConfigurations.GetEntityConfiguration<DataClassInfo>();

using var srcClassesDe = EnumerableHelper.CreateDeferrableItemWrapper(
modelFacade.Select<ICmsClass>("ClassIsCustomTable=1", "ClassID ASC")
);
Expand All @@ -105,6 +108,12 @@ private async Task MigrateCustomTables()
continue;
}

if (dataClassEntityConfiguration.ExcludeCodeNames.Contains(ksClass.ClassName,
StringComparer.InvariantCultureIgnoreCase))
{
continue;
}

if (ksClass.ClassInheritsFromClassID is { } classInheritsFromClassId && !primaryKeyMappingContext.HasMapping<ICmsClass>(c => c.ClassID, classInheritsFromClassId))
{
// defer migration to later stage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

using Migration.Tool.Common;
using Migration.Tool.Common.Abstractions;
using Migration.Tool.Common.Builders;
using Migration.Tool.Common.Helpers;
using Migration.Tool.Common.MigrationProtocol;
using Migration.Tool.KXP.Api;
Expand All @@ -31,7 +32,8 @@ public class MigratePageTypesCommandHandler(
PageTemplateMigrator pageTemplateMigrator,
ReusableSchemaService reusableSchemaService,
ClassMappingProvider classMappingProvider,
IImporter importer
IImporter importer,
IEnumerable<IReusableSchemaBuilder> reusableSchemaBuilders
)
: IRequestHandler<MigratePageTypesCommand, CommandResult>
{
Expand All @@ -50,6 +52,14 @@ public async Task<CommandResult> Handle(MigratePageTypesCommand request, Cancell
var manuallyMappedSourceClassIDs = new HashSet<int>();
var manuallyMappedSourceClassNames = manualMappings.Values.SelectMany(x => x.mappping.SourceClassNames).ToHashSet();

if (reusableSchemaBuilders.Any() && !string.IsNullOrWhiteSpace(toolConfiguration.CreateReusableFieldSchemaForClasses))
{
logger.LogError("Conversion to reusable field schema using appsettings configuration " +
"is not allowed when custom class mapping reusable schema builders are " +
"used. Use one option or the other. Terminating migration of page types.");
return new CommandFailureResult();
}

while (ksClasses.GetNext(out var di))
{
var (_, ksClass) = di;
Expand All @@ -64,6 +74,12 @@ public async Task<CommandResult> Handle(MigratePageTypesCommand request, Cancell
continue;
}

if (entityConfiguration.ExcludeCodeNames.Contains(ksClass.ClassName,
StringComparer.InvariantCultureIgnoreCase))
{
continue;
}

if (ksClass.ClassInheritsFromClassID is { } classInheritsFromClassId && !(primaryKeyMappingContext.HasMapping<ICmsClass>(c => c.ClassID, classInheritsFromClassId) || manuallyMappedSourceClassIDs.Contains(classInheritsFromClassId)))
{
// defer migration to later stage
Expand Down
Loading