/// <summary> /// /// </summary> /// <returns></returns> static ConceptSchemeType createCommonConcepts() { ConceptSchemeType conceptScheme = new ConceptSchemeType(); conceptScheme.agencyID = "SDMX"; conceptScheme.id = "CROSS_DOMAIN_CONCEPTS"; conceptScheme.version = "1.0"; List <TextType> name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "SDMX Cross Domain Concept Scheme"; name.Add(enName); } conceptScheme.Name = name.ToArray(); List <ConceptType> schemeConcepts = new List <ConceptType>(); //BASE PERIOD { ConceptType concept = new ConceptType(); concept.id = "BASE_PER"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Base Period"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } //DECIMALS { ConceptType concept = new ConceptType(); concept.id = "DECIMALS"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Decimals"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } //FREQ { ConceptType concept = new ConceptType(); concept.id = "FREQ"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Frequency"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } //OBS_VALUE { ConceptType concept = new ConceptType(); concept.id = "OBS_VALUE"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Observation"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } //OBS_STATUS { ConceptType concept = new ConceptType(); concept.id = "OBS_STATUS"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Observation Status"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } //REF_PERIOD { ConceptType concept = new ConceptType(); concept.id = "REF_PERIOD"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Reference Period"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } //TIME_PERIOD { ConceptType concept = new ConceptType(); concept.id = "TIME_PERIOD"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Time Period"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } //UNIT_MEASURE { ConceptType concept = new ConceptType(); concept.id = "UNIT_MEASURE"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Unit of Measure"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } conceptScheme.Concept = schemeConcepts.ToArray(); return(conceptScheme); }
static StructureType createStructure(PXModel model) { // Create structure StructureType structure = new StructureType(); // Create concepts container ConceptsType concepts = new ConceptsType(); structure.Concepts = concepts; // Concept Schemes List <ConceptSchemeType> conceptSchemes = new List <ConceptSchemeType>(); //Create Common Concept Scheme conceptSchemes.Add(createCommonConcepts()); // Create instance concept scheme ConceptSchemeType conceptScheme = new ConceptSchemeType(); conceptScheme.agencyID = model.Meta.Agency().CleanID(); conceptScheme.id = "DEFAULT"; conceptScheme.version = "1.0"; List <TextType> name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Default Concept Scheme"; name.Add(enName); } conceptScheme.Name = name.ToArray(); List <ConceptType> schemeConcepts = new List <ConceptType>(); // Create fixed concepts (not contained in CDC) // Stock/flow/average indicator { ConceptType concept = new ConceptType(); concept.id = "SFA_INDICATOR"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Stock, flow, average indicator"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } // Seasonal adjustement { ConceptType concept = new ConceptType(); concept.id = "SEAS_ADJ"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Seasonally adjustement"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } // Daily adjustement { ConceptType concept = new ConceptType(); concept.id = "DAY_ADJ"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Daily adjustement"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } // Price basis { ConceptType concept = new ConceptType(); concept.id = "PRICE_BASIS"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = "Price basis"; name.Add(enName); } concept.Name = name.ToArray(); schemeConcepts.Add(concept); } // Create codelists container List <CodeListType> codeLists = new List <CodeListType>(); //Create Common Code Lists codeLists.AddRange(createCommonCodes(model)); // Create key family KeyFamilyType keyFamily = new KeyFamilyType(); keyFamily.agencyID = model.Meta.Agency().CleanID(); keyFamily.id = model.Meta.Matrix.CleanID(); keyFamily.version = "1.0"; name = new List <TextType>(); { TextType enName = new TextType(); enName.lang = "en"; enName.Value = model.Meta.Matrix; name.Add(enName); } keyFamily.Name = name.ToArray(); ComponentsType components = new ComponentsType(); keyFamily.Components = components; // Create attributes List <AttributeType> attributes = new List <AttributeType>(); if (model.Meta.ContentVariable == null) { //Any non-null key words will be data set level attributes //Unit of measure attributes.Add(createUnitsAttribute(false, model.Meta.Agency().CleanID())); if (model.Meta.ContentInfo != null) { // Stock, flow, average if (model.Meta.ContentInfo.StockFa != null) { attributes.Add(createStockFlowAttribute(false, model.Meta.Agency().CleanID())); } // Seasonal adjustement if (model.Meta.ContentInfo.SeasAdj != null) { attributes.Add(createSeasAdjAttribute(false, model.Meta.Agency().CleanID())); } // Daily adjustment if (model.Meta.ContentInfo.DayAdj != null) { attributes.Add(createDayAdjAttribute(false, model.Meta.Agency().CleanID())); } // Base period if (model.Meta.ContentInfo.Baseperiod != null) { attributes.Add(createBasePeriodAttribute(false)); } // Reference period if (model.Meta.ContentInfo.RefPeriod != null) { attributes.Add(createReferencePeriodAttribute(false)); } // Current / fixed prices if (model.Meta.ContentInfo.CFPrices != null) { attributes.Add(createPriceBasisAttribute(false, model.Meta.Agency().CleanID())); } } } else { //Any non-null key words will be series level attributes //Unit of measure attributes.Add(createUnitsAttribute(true, model.Meta.Agency().CleanID())); if (model.Meta.ContentInfo != null) { // Stock, flow, average if (model.Meta.ContentInfo.StockFa != null) { attributes.Add(createStockFlowAttribute(true, model.Meta.Agency().CleanID())); } // Seasonal adjustement if (model.Meta.ContentInfo.SeasAdj != null) { attributes.Add(createSeasAdjAttribute(true, model.Meta.Agency().CleanID())); } // Daily adjustment if (model.Meta.ContentInfo.DayAdj != null) { attributes.Add(createDayAdjAttribute(true, model.Meta.Agency().CleanID())); } // Base period if (model.Meta.ContentInfo.Baseperiod != null) { attributes.Add(createBasePeriodAttribute(true)); } // Reference period if (model.Meta.ContentInfo.RefPeriod != null) { attributes.Add(createReferencePeriodAttribute(true)); } // Current / fixed prices if (model.Meta.ContentInfo.CFPrices != null) { attributes.Add(createPriceBasisAttribute(true, model.Meta.Agency().CleanID())); } } } attributes.Add(createObsStatusAttribute()); attributes.Add(createDecimalsAttribute()); // Add attributes to key family components components.Attribute = attributes.ToArray(); // Create dimensions List <DimensionType> dimensions = new List <DimensionType>(); // Create frequency dimension DimensionType freq = new DimensionType(); freq.conceptAgency = "SDMX"; freq.conceptSchemeRef = "CROSS_DOMAIN_CONCEPTS"; freq.conceptRef = "FREQ"; freq.conceptVersion = "1.0"; freq.codelistAgency = "SDMX"; freq.codelist = "CL_FREQ"; freq.codelistVersion = "1.0"; freq.isFrequencyDimension = true; dimensions.Add(freq); // Loop through variables to create concepts, codelists, and dimensions foreach (Variable var in model.Meta.Variables) { if (!isStandardConcept(var)) { // Create concept schemeConcepts.Add(createConcept(var)); // Create codelist codeLists.Add(createCodelist(var)); // Create dimension dimensions.Add(createDimension(var, model.Meta.Agency().CleanID())); } } // Create time dimension TimeDimensionType time = new TimeDimensionType(); time.conceptAgency = "SDMX"; time.conceptSchemeRef = "CROSS_DOMAIN_CONCEPTS"; time.conceptRef = "TIME_PERIOD"; time.conceptVersion = "1.0"; TextFormatType timeFormat = new TextFormatType(); timeFormat.textType = TextTypeType.ObservationalTimePeriod; time.TextFormat = timeFormat; components.TimeDimension = time; // Add dimensions to key family components components.Dimension = dimensions.ToArray(); // Create primary measure PrimaryMeasureType obsValue = new PrimaryMeasureType(); obsValue.conceptSchemeAgency = "SDMX"; obsValue.conceptSchemeRef = "CROSS_DOMAIN_CONCEPTS"; obsValue.conceptRef = "OBS_VALUE"; obsValue.conceptVersion = "1.0"; TextFormatType obsFormat = new TextFormatType(); obsFormat.textType = TextTypeType.Decimal; obsValue.TextFormat = obsFormat; components.PrimaryMeasure = obsValue; // Add key family to structure List <KeyFamilyType> keyFamilies = new List <KeyFamilyType>(); keyFamilies.Add(keyFamily); structure.KeyFamilies = keyFamilies.ToArray(); // Add concepts to scheme conceptScheme.Concept = schemeConcepts.ToArray(); conceptSchemes.Add(conceptScheme); concepts.ConceptScheme = conceptSchemes.ToArray(); // Add codelists to structure structure.CodeLists = codeLists.ToArray(); structure.Header = createHeader(model, false); return(structure); }