Exemple #1
0
        public void MakeAnXmlFile()
        {
            var record = imported.Single(r => r.Gemini.Title == @"Cruise report from Braemar Pockmarks (CEND 19x/12)");

            record.Gemini.ResourceLocator = String.Format("http://example.com/{0}", record.Id);
            var xml = new global::Catalogue.Gemini.Encoding.XmlEncoder().Create(record.Id, record.Gemini);
            //var ceh = new global::Catalogue.Gemini.Validation.Validator().Validate(xml);
            string filename = "topcat-record-" + record.Id.ToString().ToLower() + ".xml";

            xml.Save(Path.Combine(@"D:\workspace", filename));
        }
Exemple #2
0
        public void mung_doc()
        {
            var record = Db.Load<Record>(new Guid("90fe83ac-d3e4-4342-8eeb-5919b38bc670"));

            var onlineResources = record.Publication.OpenData.Resources
                .Select((r, i) => new OnlineResource
                {
                    Name = Path.GetFileName(r.Path),
                    Url = "http://example.com/blah/" + i
                }).ToList();

            var doc = new global::Catalogue.Gemini.Encoding.XmlEncoder().Create(record.Id, record.Gemini);

            global::Catalogue.Gemini.Encoding.XmlEncoder.ReplaceDigitalTransferOptions(doc, onlineResources);
        }
Exemple #3
0
        public void mung_doc()
        {
            var record = Db.Load <Record>(new Guid("90fe83ac-d3e4-4342-8eeb-5919b38bc670"));

            var onlineResources = record.Publication.OpenData.Resources
                                  .Select((r, i) => new OnlineResource
            {
                Name = Path.GetFileName(r.Path),
                Url  = "http://example.com/blah/" + i
            }).ToList();

            var doc = new global::Catalogue.Gemini.Encoding.XmlEncoder().Create(record.Id, record.Gemini);

            global::Catalogue.Gemini.Encoding.XmlEncoder.ReplaceDigitalTransferOptions(doc, onlineResources);
        }
        public void go()
        {
            var query = Db.Query <Record>().Where(r => r.Gemini.Title == "Broadscale remote survey and mapping of sublittoral habitats and their associated biota in the Firth of Lorn: biotopes");

            var record = query.First();

            record.Should().NotBeNull();

            record.Validation = Validation.Gemini;
            record.Gemini.LimitationsOnPublicAccess = "this is a test record so shouldn't be viewed by anyone ...";

            var validator = new RecordValidator();
            var result    = validator.Validate(record);

            var xml = new global::Catalogue.Gemini.Encoding.XmlEncoder().Create(new Guid("a92a3e00-2ff6-4270-b19e-377c7d542d7c"), Library.Example());
            var ceh = new global::Catalogue.Gemini.Validation.Validator().Validate(xml);

            xml.Save(@"c:\topcat-out.xml");
        }
        public void go()
        {
            var query = Db.Query<Record>().Where(r => r.Gemini.Title == "Broadscale remote survey and mapping of sublittoral habitats and their associated biota in the Firth of Lorn: biotopes");

            var record = query.First();

            record.Should().NotBeNull();

            record.Validation = Validation.Gemini;
            record.Gemini.LimitationsOnPublicAccess = "this is a test record so shouldn't be viewed by anyone ...";

            var validator = new RecordValidator();
            var result = validator.Validate(record);

            var xml = new global::Catalogue.Gemini.Encoding.XmlEncoder().Create(new Guid("a92a3e00-2ff6-4270-b19e-377c7d542d7c"), Library.Example());
            var ceh = new global::Catalogue.Gemini.Validation.Validator().Validate(xml);

            xml.Save(@"c:\topcat-out.xml");
        }
        void UploadTheMetadataDocument(Record record,  bool alternativeResources)
        {
            var doc = new global::Catalogue.Gemini.Encoding.XmlEncoder().Create(record.Id, record.Gemini);

            if (alternativeResources)
            {
                // mung (mutate) the metadata doc so data.gov.uk knows about the resources
                var onlineResources = record.Publication.OpenData.Resources
                    .Select(r => new OnlineResource
                    {
                        Name = WebificationUtility.ToUrlFriendlyString(Path.GetFileName(r.Path)),
                        Url = config.HttpRootUrl + "/" + GetUnrootedDataPath(record.Id, r.Path)
                    }).ToList();

                global::Catalogue.Gemini.Encoding.XmlEncoder.ReplaceDigitalTransferOptions(doc, onlineResources);
            }

            var s = new MemoryStream();
            doc.Save(s);
            var metaXmlDoc = s.ToArray();

            string metaPath = String.Format("waf/{0}.xml", record.Id);
            string metaFtpPath = config.FtpRootUrl + "/" + metaPath;

            ftpClient.UploadBytes(metaFtpPath, metaXmlDoc);
        }