Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common Data not able to be adapted into models Language Metadata. #14

Open
jkerbaugh opened this issue Apr 3, 2024 · 2 comments · Fixed by #15
Open

Common Data not able to be adapted into models Language Metadata. #14

jkerbaugh opened this issue Apr 3, 2024 · 2 comments · Fixed by #15
Assignees

Comments

@jkerbaugh
Copy link

Reusable fields applied to Content Items are not importable through ContentItemLanguageData.ContentItemData since the the column names for the actual content type do not contain those fields and they are contained in the ContentItemCommonData.

Using the example sample say you have a Reusable field schema withe a property name MetadataTitle shown below defined in the ContentItem dictionary. This will fail the check in the GenericAdapter for "Info doesn't contain column with name 'MetadataTitle' - _CustomProperties has invalid key, key SHALL have same name as column in target Info object" since this field exists in the ContentItemCommonData table and is not contained in the ColumnNames for the ContentItemModel loaded when adapting the
LanguageData.

ContentItemSimplifiedModel simplified = new()
    {
        ContentItemGUID = SampleArticleContentItemGuid,
        Name = "SimplifiedModelSample",
        IsSecured = false,
        ContentTypeName = DataClassSamples.ArticleClassSample.ClassName,
        IsReusable = true,
        // channel name is required only for web site content items
        ChannelName = ChannelSamples.SampleChannelForWebSiteChannel.ChannelName,
        // required when content item type is website content item
        PageData = new() {
            ParentGuid = null,
            TreePath = "/simplified-sample",
            PageUrls = [
                new()
                {
                    UrlPath = "en-us/simplified-sample",
                    PathIsDraft = true,
                    LanguageName = ContentLanguageSamples.SampleContentLanguageEnUs.ContentLanguageName!
                },
                new()
                {
                    UrlPath = "en-gb/simplified-sample",
                    PathIsDraft = true,
                    LanguageName = ContentLanguageSamples.SampleContentLanguageEnGb.ContentLanguageName!
                }
            ]
        },
        LanguageData =
        [
            new()
            {
                LanguageName = ContentLanguageSamples.SampleContentLanguageEnUs.ContentLanguageName!,
                DisplayName = "Simplified model sample - en-us",
                VersionStatus = VersionStatus.InitialDraft,
                UserGuid = UserSamples.SampleAdminGuid,
                ContentItemData = new Dictionary<string, object?>
                {
                    ["ArticleTitle"] = "en-US UMT simplified model creation",
                    ["ArticleText"] = "This article is only example of creation UMT simplified model for en-US language",
                    ["RelatedArticles"] = null,
                    ["RelatedFaq"] = null.
                    ["MetadataTitle"] = "Some Value"
                }
            },
            new()
            {
                LanguageName = ContentLanguageSamples.SampleContentLanguageEnGb.ContentLanguageName!,
                DisplayName = "Simplified model sample - en-gb",
                VersionStatus = VersionStatus.Published,
                UserGuid = UserSamples.SampleAdminGuid,
                ContentItemData = new Dictionary<string, object?>
                {
                    ["ArticleTitle"] = "en-GB UMT simplified model creation",
                    ["ArticleText"] = "This article is only example of creation UMT simplified model for en-GB language",
                    ["RelatedArticles"] = null,
                    ["RelatedFaq"] = null.
                    ["MetadataTitleCommon"] = "Some Value"
                }
            }
        ],

ContentItemSimplifiedModel.cs

public class ContentItemLanguageData
{
    [Required]
    public required string LanguageName { get; set; }
    
    [Required]
    public required string DisplayName { get; set; }
    
    public VersionStatus VersionStatus { get; set; } = VersionStatus.InitialDraft;
    
    [Required]
    public required Guid? UserGuid { get; set; }
    
    public Dictionary<string, object?>? ContentItemData { get; set; }
    
    public Dictionary<string, object?>? ContentItemCommonData { get; set; } // Added property to contain common data fields
}

ContentItemSimplifiedAdapter.cs line: 118

var contentItemCommonDataModel = new ContentItemCommonDataModel
            {
                ContentItemCommonDataGUID = contentItemCommonDataInfoGuid ?? Guid.NewGuid(),
                ContentItemCommonDataContentItemGuid = contentItemInfo.ContentItemGUID,
                ContentItemCommonDataContentLanguageGuid = contentLanguageInfo.ContentLanguageGUID,
                ContentItemCommonDataVersionStatus = languageData.VersionStatus,
                ContentItemCommonDataIsLatest = true,
                ContentItemCommonDataPageBuilderWidgets = null,
                ContentItemCommonDataPageTemplateConfiguration = null,
                CustomProperties = languageData?.ContentItemCommonData ?? [] // Allow custom properties to be adapted into the common data for things like metadata schema
            };
@liparova
Copy link

liparova commented Apr 8, 2024

Thank you for bringing this to our attention. We'll examine it internally and keep you updated on our progress.

@tkrch
Copy link
Collaborator

tkrch commented Apr 9, 2024

@jkerbaugh please check latest release (https://github.com/Kentico/xperience-by-kentico-universal-migration-toolkit/releases/tag/v1.0.3), this issue was fixed with PR #15. Let me know if issue is solved in latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants