@@ -39,7 +39,6 @@ public record CmsTreeMapperSource(
3939 Guid SiteGuid ,
4040 Guid ? NodeParentGuid ,
4141 Dictionary < string , Guid > CultureToLanguageGuid ,
42- string ? TargetFormDefinition ,
4342 string SourceFormDefinition ,
4443 List < ICmsDocument > MigratedDocuments ,
4544 ICmsSite SourceSite ,
@@ -91,51 +90,46 @@ WorkspaceService workspaceService
9190
9291 protected override IEnumerable < IUmtModel > MapInternal ( CmsTreeMapperSource source )
9392 {
94- ( var cmsTree , string safeNodeName , var siteGuid , var nodeParentGuid , var cultureToLanguageGuid , string ? targetFormDefinition , string sourceFormDefinition , var migratedDocuments , var sourceSite , bool deferred ) = source ;
93+ ( var cmsTree , string safeNodeName , var siteGuid , var nodeParentGuid , var cultureToLanguageGuid , string sourceFormDefinition , var migratedDocuments , var sourceSite , bool deferred ) = source ;
9594 logger . LogTrace ( "Mapping {Value}" , new { cmsTree . NodeAliasPath , cmsTree . NodeName , cmsTree . NodeGUID , cmsTree . NodeSiteID } ) ;
9695
9796 var childNodes = modelFacade . Select < ICmsTree > ( "NodeParentID = @nodeID" , "NodeOrder" , new SqlParameter ( "nodeID" , cmsTree . NodeID ) ) ! . ToArray ( ) ;
9897
9998 var sourceNodeClass = modelFacade . SelectById < ICmsClass > ( cmsTree . NodeClassID ) ?? throw new InvalidOperationException ( $ "Fatal: node class is missing, class id '{ cmsTree . NodeClassID } '") ;
10099 var mapping = classMappingProvider . GetMapping ( sourceNodeClass . ClassName ) ;
101- var targetClassGuid = sourceNodeClass . ClassGUID ;
102- var targetClassInfo = DataClassInfoProvider . ProviderObject . Get ( sourceNodeClass . ClassName ) ;
103- if ( mapping is not null )
100+
101+ var formerUrlPaths = GetFormerUrlPaths ( cmsTree ) ;
102+ var directive = GetDirective ( new ContentItemSource ( cmsTree , sourceNodeClass . ClassName , mapping ? . TargetClassName ?? sourceNodeClass . ClassName , sourceSite , formerUrlPaths , childNodes ) ) ;
103+
104+ if ( directive is DropDirective )
104105 {
105- targetClassInfo = DataClassInfoProvider . ProviderObject . Get ( mapping . TargetClassName ) ?? throw new InvalidOperationException ( $ "Unable to find target class ' { mapping . TargetClassName } '" ) ;
106- targetClassGuid = targetClassInfo . ClassGUID ;
106+ logger . LogInformation ( "Content item skipped. Reason: {Reason} NodeGUID: {NodeGUID} NodeAliasPath: {NodeAliasPath}" , "Explicit drop directive" , cmsTree . NodeGUID , cmsTree . NodeAliasPath ) ;
107+ yield break ;
107108 }
108109
110+ string targetClassName = directive . TargetTypeOverride ?? mapping ? . TargetClassName ?? sourceNodeClass . ClassName ;
111+ var targetClassInfo = DataClassInfoProvider . ProviderObject . Get ( targetClassName ) ;
109112 bool migratedAsContentFolder = sourceNodeClass . ClassName . Equals ( "cms.folder" , StringComparison . InvariantCultureIgnoreCase ) && ! configuration . UseDeprecatedFolderPageType . GetValueOrDefault ( false ) ;
110113
111114 if ( targetClassInfo is null && ! migratedAsContentFolder )
112115 {
113- logger . LogError ( "Could not map content item . Target class DataClassInfo ClassGUID={ClassGUID} not found ." , targetClassGuid ) ;
116+ logger . LogError ( "Could not map source node NodeGUID={NodeGuid} . Target class with name {ClassName} was not identified in target instance ." , cmsTree . NodeGUID , targetClassName ) ;
114117 yield break ;
115118 }
116119
117120 var contentItemGuid = spoiledGuidContext . EnsureNodeGuid ( cmsTree . NodeGUID , cmsTree . NodeSiteID , cmsTree . NodeID ) ;
118121
119- var formerUrlPaths = GetFormerUrlPaths ( cmsTree ) ;
120-
121- var directive = GetDirective ( new ContentItemSource ( cmsTree , sourceNodeClass . ClassName , mapping ? . TargetClassName ?? sourceNodeClass . ClassName , sourceSite , formerUrlPaths , childNodes ) ) ;
122122 directive . ContentItemGuid = contentItemGuid ;
123123 directive . TargetClassInfo = targetClassInfo ;
124124 directive . Node = cmsTree ;
125125 yield return directive ;
126126
127- if ( directive is DropDirective )
128- {
129- logger . LogInformation ( "Content item skipped. Reason: {Explicit drop directive} NodeGUID: {NodeGUID} NodeAliasPath: {NodeAliasPath}" , "Explicit drop directive" , cmsTree . NodeGUID , cmsTree . NodeAliasPath ) ;
130- yield break ;
131- }
132- else if ( directive is ConvertToWidgetDirective && cmsTree . NodeHasChildren == true && ! deferred )
127+ if ( directive is ConvertToWidgetDirective && cmsTree . NodeHasChildren == true && ! deferred )
133128 {
134129 deferredTreeNodesService . AddNode ( cmsTree ) ;
135130 yield break ;
136131 }
137132
138-
139133 bool isMappedTypeReusable = targetClassInfo ? . ClassContentTypeType is ClassContentTypeType . REUSABLE || configuration . ClassNamesConvertToContentHub . Contains ( sourceNodeClass . ClassName ) ;
140134 if ( isMappedTypeReusable )
141135 {
@@ -153,7 +147,7 @@ protected override IEnumerable<IUmtModel> MapInternal(CmsTreeMapperSource source
153147 ContentItemName = safeNodeName ,
154148 ContentItemIsReusable = isMappedTypeReusable ,
155149 ContentItemIsSecured = cmsTree . IsSecuredNode ?? false ,
156- ContentItemDataClassGuid = migratedAsContentFolder ? null : targetClassGuid ,
150+ ContentItemDataClassGuid = migratedAsContentFolder ? null : targetClassInfo ! . ClassGUID ,
157151 ContentItemChannelGuid = isMappedTypeReusable ? null : siteGuid ,
158152 ContentItemContentFolderGUID = contentFolderGuid ,
159153 ContentItemWorkspaceGUID = workspaceGuid
@@ -200,7 +194,7 @@ protected override IEnumerable<IUmtModel> MapInternal(CmsTreeMapperSource source
200194 List < IUmtModel > ? migratedDraft = null ;
201195 try
202196 {
203- migratedDraft = MigrateDraft ( draftVersion , cmsTree , sourceFormDefinition , targetFormDefinition ! , contentItemGuid , languageGuid , sourceNodeClass , websiteChannelInfo , sourceSite , mapping ) . ToList ( ) ;
197+ migratedDraft = MigrateDraft ( draftVersion , cmsTree , sourceFormDefinition , targetClassInfo ! . ClassFormDefinition , contentItemGuid , languageGuid , sourceNodeClass , websiteChannelInfo , sourceSite , mapping ) . ToList ( ) ;
204198 draftMigrated = true ;
205199 }
206200 catch
@@ -325,9 +319,9 @@ protected override IEnumerable<IUmtModel> MapInternal(CmsTreeMapperSource source
325319
326320 if ( ! migratedAsContentFolder )
327321 {
328- var dataModel = new ContentItemDataModel { ContentItemDataGUID = commonDataModel . ContentItemCommonDataGUID , ContentItemDataCommonDataGuid = commonDataModel . ContentItemCommonDataGUID , ContentItemContentTypeName = mapping ? . TargetClassName ?? sourceNodeClass . ClassName } ;
322+ var dataModel = new ContentItemDataModel { ContentItemDataGUID = commonDataModel . ContentItemCommonDataGUID , ContentItemDataCommonDataGuid = commonDataModel . ContentItemCommonDataGUID , ContentItemContentTypeName = targetClassInfo ! . ClassName } ;
329323
330- var fi = new FormInfo ( targetFormDefinition ) ;
324+ var fi = new FormInfo ( targetClassInfo ! . ClassFormDefinition ) ;
331325
332326 var includedMetadata = configuration . IncludeExtendedMetadata . GetValueOrDefault ( false ) ? IncludedMetadata . Extended : IncludedMetadata . Basic ;
333327 FormFieldInfo [ ] commonFields = UnpackReusableFieldSchemas ( fi . GetFields < FormSchemaInfo > ( ) ) . ToArray ( ) ;
@@ -358,8 +352,6 @@ protected override IEnumerable<IUmtModel> MapInternal(CmsTreeMapperSource source
358352 }
359353 }
360354
361- string targetClassName = mapping ? . TargetClassName ?? sourceNodeClass . ClassName ;
362-
363355 // Map legacy metadata fields
364356 // Fields from custom class mapping
365357 if ( mapping is not null )
@@ -915,7 +907,7 @@ string targetClassName
915907 {
916908 // relation to other document
917909 var convertedRelation = relationshipService . GetNodeRelationships ( documentSourceObjectContext . CmsTree . NodeID , sourceNodeClass . ClassName , field . Guid )
918- . Select ( r => new WebPageRelatedItem { WebPageGuid = spoiledGuidContext . EnsureNodeGuid ( r . RightNode ! . NodeGUID , r . RightNode . NodeSiteID , r . RightNode . NodeID ) } ) ;
910+ . Select ( r => new { Identifier = spoiledGuidContext . EnsureNodeGuid ( r . RightNode ! . NodeGUID , r . RightNode . NodeSiteID , r . RightNode . NodeID ) } ) ;
919911
920912 target . SetValueAsJson ( targetFieldName , valueConvertor . Invoke ( convertedRelation , convertorContext ) ) ;
921913 }
0 commit comments