From: Rob V. <rv...@do...> - 2011-09-19 15:17:55
|
Hi Marco I believe this was already fixed for the 0.5.0 release which came out just over a week ago, can you test your code with the latest release and let me know if that solves your issue? As a minor comment on your code I notice that you have ?doc and ?worker variables but then restrict these with a FILTER to just a single value for each. In that case it would make more sense just to make these parameters and substitute in the values with the SetUri() method as you've already done for the @Tagging parameter Regards, Rob Vesse ---------------------------------------- From: "Marco Cepparulo CRMPA" <cep...@mo...> Sent: 19 September 2011 15:56 To: dot...@li..., dot...@li... Subject: [dotNetRDF-Support] Sparql Update Help Hi,i'm using dotnetrdf for a research project. I have problems with SPARQL update, especially with the DELETE operation. I'm using Sesame2.3.3+Owlim3.5 as triplestore and dotnetrdf 0.4.1 (tested also on 0.2.1). My triples are stored in defaultGraph so there isn't any context associated to triples.The code throw an NullReferenceException in ConstructContext method GetNode case NodeType.Uri:IUriNode u = (IUriNode)n;temp = this._g.CreateUriNode(u.Uri);break;I resolve this problem changing ProcessDeleteCommand method in GenericUpdateProcessor. Dotnetrdf source uses ConstructContext context = new ConstructContext(null, s, true);I replace this code with the code below and the delete operation worksIGraph g = new Graph();g.BaseUri = cmd.GraphUri;ConstructContext context = new ConstructContext(g, s, true);I create a simple node which contain defaultGraphBelow is the code that performs the DELETE on triplestore: if (!defaultGraphUri.Equals("")) with="with <"+defaultGraphUri+">"; SparqlUpdateParser parser = new SparqlUpdateParser(); //Generate a Command SparqlParameterizedString cmdString = new SparqlParameterizedString(); cmdString.CommandText = "PREFIX km: <" + kmPrefix + ">"; cmdString.CommandText += "PREFIX tag: <" + tagPrefix + ">"; cmdString.CommandText += " " + with + " delete {?tagging tag:tag ?doc. ?tagging tag:taggedBy ?worker. ?tagging tag:associatedTag ?tag. ?tagging a @Tagging}"; cmdString.CommandText += " where {?tagging tag:tag ?doc."; cmdString.CommandText += " ?tagging tag:taggedBy ?worker."; cmdString.CommandText += " ?tagging tag:associatedTag ?tag."; cmdString.CommandText += " Filter(?doc=<" + docid + "> &&"; cmdString.CommandText += " ?worker=<" + workerid + ">) }"; cmdString.SetUri("Tagging", new Uri(tagPrefix + "RestrictedTagging")); //Parse the command into a SparqlUpdateCommandSet SparqlUpdateCommandSet cmds = parser.ParseFromString(cmdString); //Connect to Sesame (which does not support SPARQL Update itself) //and create a GenericUpdateProcessor to apply the update SesameHttpProtocolConnector sesame = new SesameHttpProtocolConnector(server, DB); GenericUpdateProcessor processor = new GenericUpdateProcessor(sesame); processor.ProcessCommandSet(cmds); The Delete command delete the relations (Tagging entity) between worker and document input.Can you help me to execute Delete command if I made a mistake on my code?Can you tell me if this is a bug, and if my change has impact on other dotnetrdf operation (i.e select)? |