/// <summary> /// Create a simple entity called 'TestSource' with a single attribute /// </summary> /// <param name="entityName"></param> /// <param name="attributesParams"></param> /// <returns></returns> public CdmEntityDefinition CreateBasicEntity(string entityName, List <TypeAttributeParam> attributesParams) { CdmEntityDefinition entity = Corpus.MakeObject <CdmEntityDefinition>(CdmObjectType.EntityDef, entityName); foreach (TypeAttributeParam attributesParam in attributesParams) { CdmTypeAttributeDefinition attribute = Corpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, nameOrRef: attributesParam.AttributeName, simpleNameRef: false); attribute.DataType = Corpus.MakeRef <CdmDataTypeReference>(CdmObjectType.DataTypeRef, refObj: attributesParam.AttributeDataType, simpleNameRef: true); attribute.Purpose = Corpus.MakeRef <CdmPurposeReference>(CdmObjectType.PurposeRef, refObj: attributesParam.AttributePurpose, simpleNameRef: true); attribute.DisplayName = attributesParam.AttributeName; entity.Attributes.Add(attribute); } CdmDocumentDefinition entityDoc = Corpus.MakeObject <CdmDocumentDefinition>(CdmObjectType.DocumentDef, $"{entityName}.cdm.json", false); entityDoc.Imports.Add(AllImportsDocName); entityDoc.Definitions.Add(entity); LocalStorageRoot.Documents.Add(entityDoc, entityDoc.Name); DefaultManifest.Entities.Add(entity); AllImports.Imports.Add(entity.InDocument.Name); return(entity); }
/// <summary> /// Create a Type Attribute /// </summary> /// <returns></returns> public CdmTypeAttributeDefinition CreateTypeAttribute(string attributeName, string dataType, string purpose) { CdmDataTypeReference dataTypeRef = Corpus.MakeRef <CdmDataTypeReference>(CdmObjectType.DataTypeRef, dataType, simpleNameRef: false); CdmPurposeReference purposeRef = Corpus.MakeRef <CdmPurposeReference>(CdmObjectType.PurposeRef, purpose, simpleNameRef: false); CdmTypeAttributeDefinition attribute = Corpus.MakeObject <CdmTypeAttributeDefinition>(CdmObjectType.TypeAttributeDef, nameOrRef: attributeName, simpleNameRef: false); attribute.DataType = dataTypeRef; attribute.Purpose = purposeRef; return(attribute); }