예제 #1
0
        public static async Task <LocalEntity> ToData(CdmLocalEntityDeclarationDefinition instance, CdmManifestDefinition manifest, ResolveOptions resOpt, CopyOptions options)
        {
            var localEntity = await DocumentPersistence.ToData(instance.EntityPath, manifest, resOpt, options, instance.Ctx);

            if (localEntity != null)
            {
                var t2pm          = new TraitToPropertyMap(instance);
                var isHiddenTrait = t2pm.FetchTraitReference("is.hidden");

                if (localEntity.Description == null)
                {
                    localEntity.Description = instance.Explanation;
                }
                localEntity.LastChildFileModifiedTime = instance.LastChildFileModifiedTime;
                localEntity.LastFileModifiedTime      = instance.LastFileModifiedTime;
                localEntity.LastFileStatusCheckTime   = instance.LastFileStatusCheckTime;

                if (isHiddenTrait != null)
                {
                    localEntity.IsHidden = true;
                }

                if (t2pm.FetchPropertyValue("cdmSchemas") is List <string> schemas)
                {
                    localEntity.Schemas = schemas;
                }

                if (instance.DataPartitions != null && instance.DataPartitions.Count > 0)
                {
                    localEntity.Partitions = new List <Partition>();

                    foreach (var element in instance.DataPartitions)
                    {
                        var partition = await DataPartitionPersistence.ToData(element, resOpt, options);

                        if (partition != null)
                        {
                            localEntity.Partitions.Add(partition);
                        }
                        else
                        {
                            Logger.Error((ResolveContext)instance.Ctx, Tag, nameof(ToData), instance.AtCorpusPath, CdmLogCode.ErrPersistModelJsonEntityPartitionConversionError);
                            return(null);
                        }
                    }
                }
            }

            return(localEntity);
        }
        public static async Task <LocalEntity> ToData(CdmLocalEntityDeclarationDefinition instance, ResolveOptions resOpt, CopyOptions options)
        {
            var localEntity = await DocumentPersistence.ToData(instance.EntityPath, resOpt, options, instance.Ctx);

            if (localEntity != null)
            {
                var t2pm          = new TraitToPropertyMap(instance);
                var isHiddenTrait = t2pm.FetchTraitReference("is.hidden");

                localEntity.Description = instance.Explanation;
                localEntity.LastChildFileModifiedTime = instance.LastChildFileModifiedTime;
                localEntity.LastFileModifiedTime      = instance.LastFileModifiedTime;
                localEntity.LastFileStatusCheckTime   = instance.LastFileStatusCheckTime;

                if (isHiddenTrait != null)
                {
                    localEntity.IsHidden = true;
                }

                if (t2pm.FetchPropertyValue("cdmSchemas") is List <string> schemas)
                {
                    localEntity.Schemas = schemas;
                }

                if (instance.DataPartitions != null && instance.DataPartitions.Count > 0)
                {
                    localEntity.Partitions = new List <Partition>();

                    foreach (var element in instance.DataPartitions)
                    {
                        var partition = await DataPartitionPersistence.ToData(element, resOpt, options);

                        if (partition != null)
                        {
                            localEntity.Partitions.Add(partition);
                        }
                        else
                        {
                            Logger.Error(nameof(LocalEntityDeclarationPersistence), instance.Ctx, "There was an error while trying to convert cdm data partition to model.json partition.");
                            return(null);
                        }
                    }
                }
            }

            return(localEntity);
        }