static void ListProperties(CdmEntityDefinition entity, CdmEntityDeclarationDefinition entityDec) { Console.WriteLine($"\nList of all properties for the entity {entity.EntityName}:"); // Entity's name. PrintProperty("EntityName", entityDec.EntityName); // Entity that this entity extends from. if (entity.ExtendsEntity != null) { PrintProperty("ExtendsEntity", entity.ExtendsEntity.FetchObjectDefinitionName()); } // Entity's display name. PrintProperty("DisplayName", entity.DisplayName); // Entity's description. PrintProperty("Description", entity.Description); // Version. PrintProperty("Version", entity.Version); if (entity.CdmSchemas != null) { // Cdm schemas. Console.WriteLine(" CdmSchemas:"); foreach (var schema in entity.CdmSchemas) { Console.WriteLine(" " + schema); } } // Entity's source name. PrintProperty("SourceName", entity.SourceName); // Last file modified time. PrintProperty("LastFileModifiedTime", entityDec.LastFileModifiedTime.ToString()); // Last file status check time. PrintProperty("LastFileStatusCheckTime", entityDec.LastFileStatusCheckTime.ToString()); }
/// <summary> /// Get the text version of all the resolved entities. /// </summary> /// <param name="cdmCorpus"> The CDM corpus. </param> /// <param name="directives"> The directives to use while getting the resolved entities. </param> /// <param name="manifest"> The manifest to be resolved. </param> /// <param name="spew"> The object used to store the text to be returned. </param> /// <returns> The text version of the resolved entities. (it's in a form that facilitates debugging) </returns> internal static async Task <string> ListAllResolved(CdmCorpusDefinition cdmCorpus, AttributeResolutionDirectiveSet directives, CdmManifestDefinition manifest, StringSpewCatcher spew = null) { var seen = new HashSet <string>(); Func <CdmManifestDefinition, Task> seekEntities = null; seekEntities = async(CdmManifestDefinition f) => { if (f.Entities != null) { if (spew != null) { spew.SpewLine(f.FolderPath); } foreach (CdmEntityDeclarationDefinition entity in f.Entities) { string corpusPath; CdmEntityDeclarationDefinition ent = entity; CdmObject currentFile = f; while (ent is CdmReferencedEntityDeclarationDefinition) { corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(ent.EntityPath, currentFile); ent = await cdmCorpus.FetchObjectAsync <CdmReferencedEntityDeclarationDefinition>(corpusPath); currentFile = ent; } corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(((CdmLocalEntityDeclarationDefinition)ent).EntityPath, currentFile); ResolveOptions resOpt = new ResolveOptions() { StrictValidation = true }; CdmEntityDefinition newEnt = await cdmCorpus.FetchObjectAsync <CdmEntityDefinition>(corpusPath, null, resOpt); resOpt.WrtDoc = newEnt.InDocument; resOpt.Directives = directives; ResolvedEntity resEnt = new ResolvedEntity(resOpt, newEnt); if (spew != null) { resEnt.Spew(resOpt, spew, " ", true); } } } if (f.SubManifests != null) { // folder.SubManifests.ForEach(async f => foreach (CdmManifestDeclarationDefinition subManifest in f.SubManifests) { string corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(subManifest.Definition, f); await seekEntities(await cdmCorpus.FetchObjectAsync <CdmManifestDefinition>(corpusPath)); } } }; await seekEntities(manifest); if (spew != null) { return(spew.GetContent()); } return(""); }
public async static Task ListAllResolved(CdmCorpusDefinition cdmCorpus, AttributeResolutionDirectiveSet directives, CdmManifestDefinition manifest, StringSpewCatcher spew = null) { ISet <string> seen = new HashSet <string>(); Func <CdmManifestDefinition, Task> seekEntities = null; seekEntities = async(CdmManifestDefinition f) => { if (f.Entities != null) { if (spew != null) { spew.SpewLine(f.FolderPath); } // manifest.Entities.ForEach(async entity => foreach (CdmEntityDeclarationDefinition entity in f.Entities) { string corpusPath; CdmEntityDeclarationDefinition ent = entity; CdmObject currentFile = f; while (ent is CdmReferencedEntityDeclarationDefinition) { corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(ent.EntityPath, currentFile); ent = await cdmCorpus.FetchObjectAsync <CdmReferencedEntityDeclarationDefinition>(corpusPath); currentFile = (CdmObject)ent; } corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(((CdmLocalEntityDeclarationDefinition)ent).EntityPath, currentFile); var newEnt = await cdmCorpus.FetchObjectAsync <CdmEntityDefinition>(corpusPath); ResolveOptions resOpt = new ResolveOptions() { WrtDoc = newEnt.InDocument, Directives = directives }; ResolvedEntity resEnt = new ResolvedEntity(resOpt, newEnt); if (spew != null) { resEnt.Spew(resOpt, spew, " ", true); } } } if (f.SubManifests != null) { // folder.SubManifests.ForEach(async f => foreach (CdmManifestDeclarationDefinition subManifest in f.SubManifests) { string corpusPath = cdmCorpus.Storage.CreateAbsoluteCorpusPath(subManifest.Definition, f); await seekEntities(await cdmCorpus.FetchObjectAsync <CdmManifestDefinition>(corpusPath)); } } }; await seekEntities(manifest); if (spew != null) { File.WriteAllText(@"c:\temp\allResolved.txt", spew.GetContent(), Encoding.UTF8); } }
static void ListDataPartitionLocations(CdmEntityDeclarationDefinition entityDec) { Console.WriteLine($"\nList of all data partition locations for the entity {entityDec.EntityName}:"); foreach (CdmDataPartitionDefinition dataPartition in entityDec.DataPartitions) { // The data partition location. Console.WriteLine(" " + dataPartition.Location); } }
/// <summary> /// finds and returns an entity object from an EntityDeclaration object that probably comes from a manifest /// </summary> /// <param name="entity"></param> /// <param name="manifest"></param> /// <returns></returns> internal async Task <CdmEntityDefinition> GetEntityFromReference(CdmEntityDeclarationDefinition entity, CdmManifestDefinition manifest) { string entityPath = await this.GetEntityPathFromDeclaration(entity, manifest); CdmEntityDefinition result = await this.Ctx.Corpus.FetchObjectAsync <CdmEntityDefinition>(entityPath); if (result == null) { Logger.Error(this.Ctx, Tag, nameof(GetEntityFromReference), this.AtCorpusPath, CdmLogCode.ErrResolveEntityFailure, entityPath); } return(result); }
// finds and returns an entity object from an EntityDeclaration object that probably comes from a manifest internal async Task <CdmEntityDefinition> GetEntityFromReference(CdmEntityDeclarationDefinition entity, CdmManifestDefinition manifest) { string entityPath = await this.GetEntityPathFromDeclaration(entity, manifest); CdmEntityDefinition result = await this.Ctx.Corpus.FetchObjectAsync <CdmEntityDefinition>(entityPath); if (result == null) { Logger.Error(nameof(CdmManifestDefinition), this.Ctx, $"failed to resolve entity {entityPath}", "GetEntityFromReference"); } return(result); }
internal async Task <string> GetEntityPathFromDeclaration(CdmEntityDeclarationDefinition entityDec, CdmObject obj = null) { // keep following referenceEntityDeclaration paths until a LocalentityDeclaration is hit while (entityDec is CdmReferencedEntityDeclarationDefinition) { string currCorpusPath = this.Ctx.Corpus.Storage.CreateAbsoluteCorpusPath(entityDec.EntityPath, obj); entityDec = await this.Ctx.Corpus.FetchObjectAsync <CdmEntityDeclarationDefinition>(currCorpusPath); obj = entityDec.InDocument; } return(entityDec != null?this.Ctx.Corpus.Storage.CreateAbsoluteCorpusPath(entityDec.EntityPath, obj) : null); }
static void ListDataPartitionLocations(CdmCorpusDefinition cdmCorpus, CdmEntityDeclarationDefinition entityDec) { Console.WriteLine($"\nList of all data partition locations for the entity {entityDec.EntityName}:"); foreach (CdmDataPartitionDefinition dataPartition in entityDec.DataPartitions) { // The data partition location. Console.WriteLine(" " + dataPartition.Location); if (!string.IsNullOrEmpty(dataPartition.Location)) { Console.WriteLine(" " + cdmCorpus.Storage.CorpusPathToAdapterPath(dataPartition.Location)); } } }
public CdmEntityDefinition CreateCdmEntityDefinition(CdmEntityDeclarationDefinition entityDefinition) { var cdmEntity = this.cdmCorpus.MakeObject <CdmEntityDefinition>(CdmObjectType.EntityDef, entityDefinition.EntityName, simpleNameRef: false); cdmEntity.EntityName = entityDefinition.EntityName; cdmEntity.DisplayName = entityDefinition.EntityName; var entSelected = entityDefinition.Ctx.Corpus.FetchObjectAsync <CdmEntityDefinition>(entityDefinition.EntityPath).Result; var attributes = entSelected.Attributes; foreach (var a in attributes) { // Add type attributes to the entity instance cdmEntity.Attributes.Add(a); } return(cdmEntity); }
/// <summary> /// finds any relative corpus paths that are held within this document and makes them relative to the new folder instead /// </summary> internal bool LocalizeCorpusPaths(CdmFolderDefinition newFolder) { bool allWentWell = true; bool wasBlocking = this.Ctx.Corpus.blockDeclaredPathChanges; this.Ctx.Corpus.blockDeclaredPathChanges = true; // shout into the void Logger.Info(nameof(CdmDocumentDefinition), (ResolveContext)this.Ctx, $"Localizing corpus paths in document '{this.Name}'", nameof(LocalizeCorpusPaths)); // find anything in the document that is a corpus path this.Visit("", new VisitCallback { Invoke = (iObject, path) => { // i don't like that document needs to know a little about these objects // in theory, we could create a virtual function on cdmObject that localizes properties // but then every object would need to know about the documents and paths and such ... // also, i already wrote this code. switch (iObject.ObjectType) { case CdmObjectType.Import: { CdmImport typeObj = iObject as CdmImport; typeObj.CorpusPath = LocalizeCorpusPath(typeObj.CorpusPath, newFolder, ref allWentWell) ?? typeObj.CorpusPath; break; } case CdmObjectType.LocalEntityDeclarationDef: case CdmObjectType.ReferencedEntityDeclarationDef: { CdmEntityDeclarationDefinition typeObj = iObject as CdmEntityDeclarationDefinition; typeObj.EntityPath = LocalizeCorpusPath(typeObj.EntityPath, newFolder, ref allWentWell) ?? typeObj.EntityPath; break; } case CdmObjectType.DataPartitionDef: { CdmDataPartitionDefinition typeObj = iObject as CdmDataPartitionDefinition; typeObj.Location = LocalizeCorpusPath(typeObj.Location, newFolder, ref allWentWell) ?? typeObj.Location; typeObj.SpecializedSchema = LocalizeCorpusPath(typeObj.SpecializedSchema, newFolder, ref allWentWell) ?? typeObj.SpecializedSchema; break; } case CdmObjectType.DataPartitionPatternDef: { CdmDataPartitionPatternDefinition typeObj = iObject as CdmDataPartitionPatternDefinition; typeObj.RootLocation = LocalizeCorpusPath(typeObj.RootLocation, newFolder, ref allWentWell) ?? typeObj.RootLocation; typeObj.SpecializedSchema = LocalizeCorpusPath(typeObj.SpecializedSchema, newFolder, ref allWentWell) ?? typeObj.SpecializedSchema; break; } case CdmObjectType.E2ERelationshipDef: { CdmE2ERelationship typeObj = iObject as CdmE2ERelationship; typeObj.ToEntity = LocalizeCorpusPath(typeObj.ToEntity, newFolder, ref allWentWell) ?? typeObj.ToEntity; typeObj.FromEntity = LocalizeCorpusPath(typeObj.FromEntity, newFolder, ref allWentWell) ?? typeObj.FromEntity; break; } case CdmObjectType.ManifestDeclarationDef: { CdmManifestDeclarationDefinition typeObj = iObject as CdmManifestDeclarationDefinition; typeObj.Definition = LocalizeCorpusPath(typeObj.Definition, newFolder, ref allWentWell) ?? typeObj.Definition; break; } } return(false); } }, null); this.Ctx.Corpus.blockDeclaredPathChanges = wasBlocking; return(allWentWell); }
public static CdmManifestDefinition FromObject(CdmCorpusContext ctx, string name, string nameSpace, string path, ManifestContent dataObj) { // Determine name of the manifest var manifestName = !StringUtils.IsBlankByCdmStandard(dataObj.ManifestName) ? dataObj.ManifestName : dataObj.FolioName; // We haven't found the name in the file, use one provided in the call but without the suffixes if (StringUtils.IsBlankByCdmStandard(manifestName)) { manifestName = name.Replace(PersistenceLayer.ManifestExtension, "").Replace(PersistenceLayer.FolioExtension, ""); } var manifest = ctx.Corpus.MakeObject <CdmManifestDefinition>(CdmObjectType.ManifestDef, manifestName); manifest.Name = name; // this is the document name which is assumed by constructor to be related to the the manifestName, but may not be manifest.FolderPath = path; manifest.Namespace = nameSpace; manifest.Explanation = dataObj.Explanation; if (!StringUtils.IsBlankByCdmStandard(dataObj.Schema)) { manifest.Schema = dataObj.Schema; } if (DynamicObjectExtensions.HasProperty(dataObj, "JsonSchemaSemanticVersion") && !StringUtils.IsBlankByCdmStandard(dataObj.JsonSchemaSemanticVersion)) { manifest.JsonSchemaSemanticVersion = dataObj.JsonSchemaSemanticVersion; } if (!StringUtils.IsBlankByCdmStandard(dataObj.DocumentVersion)) { manifest.DocumentVersion = dataObj.DocumentVersion; } if (!StringUtils.IsBlankByCdmStandard(dataObj.ManifestName)) { manifest.ManifestName = dataObj.ManifestName; } else if (!StringUtils.IsBlankByCdmStandard(dataObj.FolioName)) { // Might be populated in the case of folio.cdm.json or manifest.cdm.json file. manifest.ManifestName = dataObj.FolioName; } Utils.AddListToCdmCollection(manifest.ExhibitsTraits, Utils.CreateTraitReferenceList(ctx, dataObj.ExhibitsTraits)); if (dataObj.Imports != null) { foreach (var importObj in dataObj.Imports) { manifest.Imports.Add(ImportPersistence.FromData(ctx, importObj)); } } if (dataObj.Definitions != null) { for (int i = 0; i < dataObj.Definitions.Count; i++) { dynamic d = dataObj.Definitions[i]; if (d["dataTypeName"] != null) { manifest.Definitions.Add(DataTypePersistence.FromData(ctx, d)); } else if (d["purposeName"] != null) { manifest.Definitions.Add(PurposePersistence.FromData(ctx, d)); } else if (d["attributeGroupName"] != null) { manifest.Definitions.Add(AttributeGroupPersistence.FromData(ctx, d)); } else if (d["traitName"] != null) { manifest.Definitions.Add(TraitPersistence.FromData(ctx, d)); } else if (d["entityShape"] != null) { manifest.Definitions.Add(ConstantEntityPersistence.FromData(ctx, d)); } else if (d["entityName"] != null) { manifest.Definitions.Add(EntityPersistence.FromData(ctx, d)); } } } if (dataObj.LastFileStatusCheckTime != null) { manifest.LastFileStatusCheckTime = DateTimeOffset.Parse(dataObj.LastFileStatusCheckTime); } if (dataObj.LastFileModifiedTime != null) { manifest.LastFileModifiedTime = DateTimeOffset.Parse(dataObj.LastFileModifiedTime); } if (dataObj.LastChildFileModifiedTime != null) { manifest.LastChildFileModifiedTime = DateTimeOffset.Parse(dataObj.LastChildFileModifiedTime); } if (dataObj.Entities != null) { var fullPath = !StringUtils.IsBlankByCdmStandard(nameSpace) ? $"{nameSpace}:{path}" : path; foreach (var entityObj in dataObj.Entities) { CdmEntityDeclarationDefinition entity = null; if (entityObj["type"] != null) { if (entityObj["type"].ToString() == EntityDeclarationDefinitionType.LocalEntity) { entity = LocalEntityDeclarationPersistence.FromData(ctx, fullPath, entityObj); } else if (entityObj["type"].ToString() == EntityDeclarationDefinitionType.ReferencedEntity) { entity = ReferencedEntityDeclarationPersistence.FromData(ctx, fullPath, entityObj); } else { Logger.Error(ctx, Tag, nameof(FromObject), null, CdmLogCode.ErrPersistEntityDeclarationMissing, (string)entityObj["entityName"]); } } else { // We see old structure of entity declaration, check for entity schema/declaration. if (entityObj["entitySchema"] != null) { // Local entity declaration used to use entity schema. entity = LocalEntityDeclarationPersistence.FromData(ctx, fullPath, entityObj); } else { // While referenced entity declaration used to use entity declaration. entity = ReferencedEntityDeclarationPersistence.FromData(ctx, fullPath, entityObj); } } manifest.Entities.Add(entity); } // Checks if incremental trait is needed from foundations.cdm.json ImportFoundationsIfIncrementalPartitionTraitExist(manifest); } if (dataObj.Relationships != null) { foreach (var rel in dataObj.Relationships) { manifest.Relationships.Add(E2ERelationshipPersistence.FromData(ctx, rel)); } } if (dataObj.SubManifests != null) { foreach (var subManifest in dataObj.SubManifests) { manifest.SubManifests.Add(ManifestDeclarationPersistence.FromData(ctx, subManifest)); } } // Might be populated in the case of folio.cdm.json or manifest.cdm.json file. else if (dataObj.SubFolios != null) { foreach (var subFolio in dataObj.SubFolios) { manifest.SubManifests.Add(ManifestDeclarationPersistence.FromData(ctx, subFolio)); } } return(manifest); }
public static async Task <CdmManifestDefinition> FromObject(CdmCorpusContext ctx, Model obj, CdmFolderDefinition folder) { #region Prepare extensionDoc List <CdmTraitDefinition> extensionTraitDefList = new List <CdmTraitDefinition>(); #endregion #region Set manifest fields CdmManifestDefinition manifest = ctx.Corpus.MakeObject <CdmManifestDefinition>(CdmObjectType.ManifestDef, obj.Name); // We need to set up folder path and namespace of a manifest to be able to retrieve that object. folder.Documents.Add(manifest); if (obj.Imports != null) { foreach (var element in obj.Imports) { manifest.Imports.Add(CdmFolder.ImportPersistence.FromData(ctx, element)); } } if (!manifest.Imports.Any((CdmImport importPresent) => importPresent.CorpusPath == "cdm:/foundations.cdm.json")) { manifest.Imports.Add("cdm:/foundations.cdm.json"); } manifest.Explanation = obj.Description; manifest.LastFileModifiedTime = obj.ModifiedTime; manifest.LastChildFileModifiedTime = obj.LastChildFileModifiedTime; manifest.LastFileStatusCheckTime = obj.LastFileStatusCheckTime; if (!string.IsNullOrEmpty(obj.DocumentVersion)) { manifest.DocumentVersion = obj.DocumentVersion; } if (obj.Application != null) { var applicationTrait = ctx.Corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "is.managedBy", false); applicationTrait.IsFromProperty = true; var arg = ctx.Corpus.MakeObject <CdmArgumentDefinition>(CdmObjectType.ArgumentDef, "application"); arg.Value = obj.Application; applicationTrait.Arguments.Add(arg); manifest.ExhibitsTraits.Add(applicationTrait); } if (obj.Version != null) { var versionTrait = ctx.Corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "is.modelConversion.modelVersion", false); var arg = ctx.Corpus.MakeObject <CdmArgumentDefinition>(CdmObjectType.ArgumentDef, "version"); arg.Value = obj.Version; versionTrait.Arguments.Add(arg); manifest.ExhibitsTraits.Add(versionTrait); } if (obj.Culture != null) { var cultureTrait = ctx.Corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "is.partition.culture", false); cultureTrait.IsFromProperty = true; var arg = ctx.Corpus.MakeObject <CdmArgumentDefinition>(CdmObjectType.ArgumentDef, "culture"); arg.Value = obj.Culture; cultureTrait.Arguments.Add(arg); manifest.ExhibitsTraits.Add(cultureTrait); } if (obj.IsHidden == true) { var isHiddenTrait = ctx.Corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "is.hidden", true); isHiddenTrait.IsFromProperty = true; manifest.ExhibitsTraits.Add(isHiddenTrait); } var referenceModels = new Dictionary <string, string>(); if (obj.ReferenceModels != null) { var referenceModelsTrait = ctx.Corpus.MakeRef <CdmTraitReference>(CdmObjectType.TraitRef, "is.modelConversion.referenceModelMap", false); var arg = ctx.Corpus.MakeObject <CdmArgumentDefinition>(CdmObjectType.ArgumentDef, "referenceModelMap"); arg.Value = JToken.FromObject(obj.ReferenceModels); referenceModelsTrait.Arguments.Add(arg); manifest.ExhibitsTraits.Add(referenceModelsTrait); foreach (var referenceModel in obj.ReferenceModels) { referenceModels.Add(referenceModel.Id, referenceModel.Location); } } var entitySchemaByName = new Dictionary <string, string>(); if (obj.Entities != null && obj.Entities.Count > 0) { foreach (var element in obj.Entities) { CdmEntityDeclarationDefinition entity = null; if ((string)element["$type"] == "LocalEntity") { entity = await LocalEntityDeclarationPersistence.FromData(ctx, folder, element.ToObject <LocalEntity>(), extensionTraitDefList, manifest); } else if ((string)element["$type"] == "ReferenceEntity") { var referenceEntity = element.ToObject <ReferenceEntity>(); if (!referenceModels.ContainsKey(referenceEntity.ModelId)) { Logger.Error(nameof(ManifestPersistence), ctx, $"Model Id {referenceEntity.ModelId} from {referenceEntity.Name} not found in referenceModels."); return(null); } entity = await ReferencedEntityDeclarationPersistence.FromData(ctx, referenceEntity, referenceModels[referenceEntity.ModelId]); } else { Logger.Error(nameof(ManifestPersistence), ctx, "There was an error while trying to parse entity type."); } if (entity != null) { manifest.Entities.Add(entity); entitySchemaByName.Add(entity.EntityName, entity.EntityPath); } else { Logger.Error(nameof(ManifestPersistence), ctx, "There was an error while trying to parse entity type."); } } } if (obj.Relationships != null && obj.Relationships.Count > 0) { foreach (var element in obj.Relationships) { var relationship = await RelationshipPersistence.FromData(ctx, element, entitySchemaByName); if (relationship != null) { manifest.Relationships.Add(relationship); } else { Logger.Warning(nameof(ManifestPersistence), ctx, "There was an issue while trying to read relationships from the model.json file."); } } } await Utils.ProcessAnnotationsFromData(ctx, obj, manifest.ExhibitsTraits); var localExtensionTraitDefList = new List <CdmTraitDefinition>(); ExtensionHelper.ProcessExtensionFromJson(ctx, obj, manifest.ExhibitsTraits, extensionTraitDefList, localExtensionTraitDefList); #endregion #region Use extensionDoc, finalize importDocs List <CdmImport> importDocs = await ExtensionHelper.StandardImportDetection(ctx, extensionTraitDefList, localExtensionTraitDefList); ExtensionHelper.AddImportDocsToManifest(ctx, importDocs, manifest); CreateExtensionDocAndAddToFolderAndImports(ctx, extensionTraitDefList, folder); #endregion return(manifest); }
public async Task <bool> manifestToModelJson(AdlsContext adlsContext, string manifestName, string localRoot, CdmManifestDefinition modelJson = null, bool root = true) { ManifestHandler manifestHandler = new ManifestHandler(adlsContext, localRoot); CdmManifestDefinition manifest; if (root) { // Add to root folder. var cdmFolderDefinition = manifestHandler.cdmCorpus.Storage.FetchRootFolder("adls"); // Read if model.json exists. modelJson = await manifestHandler.cdmCorpus.FetchObjectAsync <CdmManifestDefinition>("model.json"); if (modelJson == null) { // Make the temp manifest and add it to the root of the local documents in the corpus modelJson = manifestHandler.cdmCorpus.MakeObject <CdmManifestDefinition>(CdmObjectType.ManifestDef, "model.json"); // Add an import to the foundations doc so the traits about partitons will resolve nicely modelJson.Imports.Add(FoundationJsonPath); // Add to root folder. cdmFolderDefinition.Documents.Add(modelJson, $"model.json"); } } manifest = await manifestHandler.cdmCorpus.FetchObjectAsync <CdmManifestDefinition>(manifestName + ".manifest.cdm.json"); Console.WriteLine($"Reading Manifest : {manifest.Name}"); foreach (var submanifest in manifest.SubManifests) { string subManifestName = submanifest.ManifestName; await this.manifestToModelJson(adlsContext, subManifestName, localRoot + '/' + subManifestName, modelJson, false); } foreach (CdmEntityDeclarationDefinition eDef in manifest.Entities.ToList()) { Console.WriteLine($"Adding Entity : {eDef.EntityName}"); var cdmEntityDefinition = this.CreateCdmEntityDefinition(eDef); var cdmEntityDocument = this.CreateDocumentDefinition(cdmEntityDefinition); // Add Imports to the entity document. cdmEntityDocument.Imports.Add(FoundationJsonPath); // Add the document to the root of the local documents in the corpus. var cdmFolderDefinition = modelJson.Ctx.Corpus.Storage.FetchRootFolder("adls"); cdmFolderDefinition.Documents.Add(cdmEntityDocument, cdmEntityDocument.Name); // Add the entity to the manifest. modelJson.Entities.Add(cdmEntityDefinition); CdmEntityDeclarationDefinition modelJsonEdef = modelJson.Entities.Item(eDef.EntityName); if (eDef.DataPartitions.Count > 0) { var dataPartition = eDef.DataPartitions.First(); dataPartition.Location = manifestName + "/" + dataPartition.Location; modelJsonEdef.DataPartitions.Add(dataPartition); } if (eDef.DataPartitionPatterns.Count > 0) { var DataPartitionPatterns = eDef.DataPartitionPatterns.First(); DataPartitionPatterns.RootLocation = manifestName + "/" + DataPartitionPatterns.RootLocation; modelJsonEdef.DataPartitionPatterns.Add(DataPartitionPatterns); } } bool created = false; if (root) { await modelJson.FileStatusCheckAsync(); created = await modelJson.SaveAsAsync("model.json", true); } return(created); }