コード例 #1
0
        public void TestMetaDataFileNameCannotExceed100Chars()
        {
            var name = new string('x', 100);
            var filename = new CkanFileNamer(name).MetadataFileName;

            Assert.IsTrue(filename.EndsWith(".metadata.csv"));
            Assert.IsTrue(filename.Length < 100);
        }
コード例 #2
0
        public CkanResource GetUnsavedResource(string packageId, IndicatorMetadata indicatorMetadata,
            IList<CkanCoreDataSet> dataList)
        {
            IDictionary<string, string> descriptive = indicatorMetadata.Descriptive;
            var indicatorName = descriptive[IndicatorMetadataTextColumnNames.Name];

            // Add metadata resource
            var resource = new CkanResource();
            resource.PackageId = packageId;
            resource.Description = "Data for \"" + indicatorName + "\"";
            resource.Format = "CSV";
            resource.Name = "Data";

            // Add file to resource
            byte[] fileContents = GetCoreDataFileAsBytes(dataList);
            var fileNamer = new CkanFileNamer(indicatorName);
            resource.File = new CkanResourceFile
            {
                FileName = fileNamer.DataFileName,
                FileContents = fileContents
            };

            return resource;
        }
コード例 #3
0
        public CkanResource GetUnsavedResource(string packageId, IndicatorMetadata indicatorMetadata,
            IList<IndicatorMetadataTextProperty> properties)
        {
            var descriptive = indicatorMetadata.Descriptive;
            var indicatorName = descriptive[IndicatorMetadataTextColumnNames.Name];

            // Add metadata resource
            var resource = new CkanResource();
            resource.PackageId = packageId;
            resource.Description = "Metadata for \"" + indicatorName + "\"";
            resource.Format = "CSV";
            resource.Name = "Metadata";

            // Add file to resource
            var fileContents = GetMetadataFileAsBytes(indicatorMetadata, properties, descriptive);
            var fileNamer = new CkanFileNamer(indicatorName);
            resource.File = new CkanResourceFile
            {
                FileName = fileNamer.MetadataFileName,
                FileContents = fileContents
            };

            return resource;
        }