private void ShowTurtleEditor()
        {
            var    w    = new Notation3Writer();
            string data = StringWriter.Write(G, w);

            textBoxTurtleEditor.Text = data;
        }
 public void ThenResultingDatasetShouldContainTriples(int expectedCount)
 {
     Assert.That(
         result.Triples.Count(),
         Is.EqualTo(expectedCount),
         "Actual triples were: {0}",
         StringWriter.Write(result, new TriGWriter()));
 }
Exemplo n.º 3
0
        public void RoundtripsDatetimeLiteralsInDiff(string dateTimeValue, string datatype)
        {
            using (var original = new TripleStore())
            {
                original.LoadFromString($@"<http://example.com/1> <http://example.com/1> ""{dateTimeValue}""^^<{datatype}>.");

                using (var target = new TripleStore())
                {
                    target.LoadFromString(StringWriter.Write(original, new JsonLdWriter()), new JsonLdParser());

                    Assert.True(original.Graphs.Single().Difference(target.Graphs.Single()).AreEqual);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updates the underlying store with this as the new representation of the identified resource
        /// </summary>
        /// <param name="resourceUri">The resource for whom this is the representation</param>
        /// <param name="resourceDescription">The rdf xml document that describes the resource</param>
        public override void ApplyFragment(string resourceUri, XDocument resourceDescription)
        {
            try
            {
                var g            = new Graph();
                var rdfXmlParser = new RdfXmlParser();
                rdfXmlParser.Load(g, new StringReader(resourceDescription.ToString()));
                var ntWriter = new NTriplesWriter();
                var data     = StringWriter.Write(g, ntWriter);

                var sparqlUpdate = "";
                sparqlUpdate += "DELETE { GRAPH <" + GraphUri + "> { <" + resourceUri + ">  ?x  ?y }}";
                sparqlUpdate += "USING <" + GraphUri + "> WHERE {<" + resourceUri + "> ?x ?y } ;";
                sparqlUpdate += "INSERT DATA { GRAPH <" + GraphUri + "> {  ";
                sparqlUpdate += data;
                sparqlUpdate += " }};";

                // execute update
                var wr = WebRequest.Create(SparqlEndpoint) as HttpWebRequest;
                wr.ContentType = "application/sparql-update";
                wr.Method      = "POST";
                var ds    = wr.GetRequestStream();
                var bytes = Encoding.ASCII.GetBytes(sparqlUpdate);
                ds.Write(bytes, 0, bytes.Length);
                var resp = wr.GetResponse() as HttpWebResponse;

                if (resp.StatusCode == HttpStatusCode.OK)
                {
                    Logging.LogDebug("Update successful");
                }
                else
                {
                    Logging.LogDebug("Not a 200");
                }
                resp.Close();
            } catch (Exception ex)
            {
                Logging.LogError(1, "Unable to apply fragment for resourceUri {0} {1}", ex.Message, ex.StackTrace);
            }
        }
        public void ThenResultingDatasetShouldNotMatchQuery(string query)
        {
            var querySuccess = ExecuteAsk(query);

            Assert.That(querySuccess, Is.False, "Actual triples were: {0}", StringWriter.Write(result, new TriGWriter()));
        }