public string RenameKeyword(string keyword, string newValue)
        {
            var query = new RecordQueryInputModel
            {
                F = new FilterOptions{Keywords = new[] { keyword }},
                N = 1024,
            };

            int count = recordQueryer.Query(query).Count();

            var records = recordQueryer.Query(query).ToList();

            if (records.Count != count)
                throw new Exception("Too many records.");

            foreach (var record in records)
            {
                var kword = ParameterHelper.ParseMetadataKeywords(new [] { keyword }).Single();
                var keywordToChange = record.Gemini.Keywords.Single(k => k.Vocab == kword.Vocab && k.Value == kword.Value);
                keywordToChange.Value = newValue;
            }

            db.SaveChanges();

            return String.Format("{0} records updated.", count);
        }
Beispiel #2
0
        public HttpResponseMessage FixUpKeywords()
        {
            // protected sites
            var query2 = new RecordQueryInputModel
            {
                F = new FilterOptions {
                    Keywords = new[] { "vocab.jncc.gov.uk/jncc-broad-category/Marine Protected Sites" }
                },
                P = 0,
                N = 1024,
            };

            var records2 = _queryer.Query(query2).ToList();

            foreach (var record in records2)
            {
                var existing = record.Gemini.Keywords.Single(k => k.Vocab == "http://vocab.jncc.gov.uk/jncc-broad-category" && k.Value == "Marine Protected Sites");
                record.Gemini.Keywords.Remove(existing);

                var domain = new MetadataKeyword {
                    Vocab = "http://vocab.jncc.gov.uk/jncc-domain", Value = "Marine"
                };
                var category = new MetadataKeyword {
                    Vocab = "http://vocab.jncc.gov.uk/jncc-category", Value = "Protected Areas"
                };

                record.Gemini.Keywords.Insert(0, domain);
                record.Gemini.Keywords.Insert(1, category);
            }


            db.SaveChanges();

            return(new HttpResponseMessage());
        }
        public HttpResponseMessage Xml([FromUri] RecordQueryInputModel input)
        {
            RemovePagingParametersFromRecordQuery(input);

            var records = recordQueryer.Query(input).ToList();

            // encode the records as iso xml elements
            var elements = from record in records
                           let doc = new XmlEncoder().Create(record.Id, record.Gemini, Helpers.GetOnlineResourcesFromDataResources(record))
                                     select new XElement("topcat-record", new XAttribute("id", record.Id), new XAttribute("path", record.Path), doc.Root);

            var output = new XDocument(new XElement("topcat-export", elements)).ToString();

            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(output)
            };

            return(result);
        }
Beispiel #4
0
        public List <string> SeabedHabitatMapsWithNoGui()
        {
            var query = new RecordQueryInputModel
            {
                N = 1000,
                F = new FilterOptions {
                    Keywords = new[] { "vocab.jncc.gov.uk/jncc-category/Seabed Habitat Maps" }
                }
            };

            var records = recordQueryer.Query(query).ToList();

            var q = from r in records
                    where !(from k in r.Gemini.Keywords
                            where k.Vocab == "http://vocab.jncc.gov.uk/mesh-gui"
                            select k.Value).Any()
                    select r.Id.ToString();

            return(q.ToList());
        }