public static async Task <CdmLocalEntityDeclarationDefinition> FromData(CdmCorpusContext ctx, CdmFolderDefinition documentFolder, LocalEntity obj, CdmCollection <CdmTraitDefinition> extensionTraitDefList)
        {
            var localEntity = ctx.Corpus.MakeObject <CdmLocalEntityDeclarationDefinition>(CdmObjectType.LocalEntityDeclarationDef, obj.Name);

            var entityDoc = await DocumentPersistence.FromData(ctx, obj, extensionTraitDefList);

            if (entityDoc == null)
            {
                Logger.Error(nameof(LocalEntityDeclarationPersistence), ctx, "There was an error while trying to fetch the entity doc from local entity declaration persistence.");
                return(null);
            }

            documentFolder.Documents.Add(entityDoc);

            // Entity schema path is the path to the doc containing the entity definition.
            localEntity.EntityPath  = ctx.Corpus.Storage.CreateRelativeCorpusPath($"{entityDoc.AtCorpusPath}/{obj.Name}", entityDoc);
            localEntity.Explanation = obj.Description;
            localEntity.LastChildFileModifiedTime = obj.LastChildFileModifiedTime;
            localEntity.LastFileModifiedTime      = obj.LastFileModifiedTime;
            localEntity.LastFileStatusCheckTime   = obj.LastFileStatusCheckTime;

            if (obj.IsHidden == true)
            {
                var isHiddenTrait = ctx.Corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "is.hidden", true);
                isHiddenTrait.IsFromProperty = true;
                localEntity.ExhibitsTraits.Add(isHiddenTrait);
            }

            // Add traits for schema entity info.
            if (obj.Schemas != null)
            {
                var t2pm = new TraitToPropertyMap(localEntity);
                t2pm.UpdatePropertyValue("cdmSchemas", obj.Schemas);
            }

            // Data partitions are part of the local entity, add them here.
            if (obj.Partitions != null)
            {
                foreach (var element in obj.Partitions)
                {
                    var cdmPartition = await DataPartitionPersistence.FromData(ctx, element, extensionTraitDefList);

                    if (cdmPartition != null)
                    {
                        localEntity.DataPartitions.Add(cdmPartition);
                    }
                    else
                    {
                        Logger.Error(nameof(LocalEntityDeclarationPersistence), ctx, "There was an error while trying to fetch the entity doc from local entity declaration persistence.");
                        return(null);
                    }
                }
            }

            return(localEntity);
        }
        public static async Task <CdmLocalEntityDeclarationDefinition> FromData(CdmCorpusContext ctx, CdmFolderDefinition documentFolder, LocalEntity obj, List <CdmTraitDefinition> extensionTraitDefList, CdmManifestDefinition manifest)
        {
            var localEntity = ctx.Corpus.MakeObject <CdmLocalEntityDeclarationDefinition>(CdmObjectType.LocalEntityDeclarationDef, obj.Name);

            var localExtensionTraitDefList = new List <CdmTraitDefinition>();

            var entityDoc = await DocumentPersistence.FromData(ctx, obj, extensionTraitDefList, localExtensionTraitDefList);

            documentFolder.Documents.Add(entityDoc);

            // Entity schema path is the path to the doc containing the entity definition.
            localEntity.EntityPath  = ctx.Corpus.Storage.CreateRelativeCorpusPath($"{entityDoc.AtCorpusPath}/{obj.Name}", manifest);
            localEntity.Explanation = obj.Description;
            localEntity.LastChildFileModifiedTime = obj.LastChildFileModifiedTime;
            localEntity.LastFileModifiedTime      = obj.LastFileModifiedTime;
            localEntity.LastFileStatusCheckTime   = obj.LastFileStatusCheckTime;

            if (obj.IsHidden == true)
            {
                var isHiddenTrait = ctx.Corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "is.hidden", true);
                isHiddenTrait.IsFromProperty = true;
                localEntity.ExhibitsTraits.Add(isHiddenTrait);
            }

            // Add traits for schema entity info.
            if (obj.Schemas != null)
            {
                var t2pm = new TraitToPropertyMap(localEntity);
                t2pm.UpdatePropertyValue("cdmSchemas", obj.Schemas);
            }

            // Data partitions are part of the local entity, add them here.
            if (obj.Partitions != null)
            {
                foreach (var element in obj.Partitions)
                {
                    var cdmPartition = await DataPartitionPersistence.FromData(ctx, element, extensionTraitDefList, localExtensionTraitDefList, documentFolder);

                    if (cdmPartition != null)
                    {
                        localEntity.DataPartitions.Add(cdmPartition);
                    }
                    else
                    {
                        Logger.Error((ResolveContext)ctx, Tag, nameof(FromData), null, CdmLogCode.ErrPersistModelJsonDocConversionError);
                        return(null);
                    }
                }
            }

            List <CdmImport> importDocs = await ExtensionHelper.StandardImportDetection(ctx, extensionTraitDefList, localExtensionTraitDefList);

            ExtensionHelper.AddImportDocsToManifest(ctx, importDocs, entityDoc);

            return(localEntity);
        }