cannot delete statements with datatypes in object

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

cannot delete statements with datatypes in object

Ivan Ricotti
Hello,

I'm trying to delete a statement using the RepositoryConnection object
in the Sesame API:

con = this.repository.getConnection();
for (Statement statement : statements) {
        con.remove(statement, context);
}

but some statements are not removed from the repository: statements
which contain an object that is a literal with datatype are not deleted. IE:

subject: "foo:bar#SITAT000002",
predicate: "http://www.hereandthere.com/sisrt/address",
object: "sesame street"^^<http://www.w3.org/2001/XMLSchema#string>"

I think that I'm not creating the right statement but I tried to create
the literal with and without the datatype parts and the result doesn't
change: the triple is still there.

This is the code I'm using now to create the statement:

public Statement toStatement(Triple triple) {
  ValueFactory factory = ValueFactoryImpl.getInstance();
  Resource subject = factory.createURI(triple.getSubject());
  URI predicate = factory.createURI(triple.getPredicate());
  Value object;
  if (triple.getObject().contains("^^")) {
    String objectString =
triple.getObject().substring(0,triple.getObject().indexOf("^^"));
    object = factory.createLiteral(objectString);
  } else {
    try {
      object = factory.createURI(triple.getObject());
    } catch (IllegalArgumentException e) {
      System.err.println(e);
      object = factory.createLiteral(triple.getObject());
    }
  }
  return factory.createStatement(subject, predicate, object);
}

(The Triple object contains just strings)
On the other hand statements withous datatype are deleted.

Any idea?
Thanks for your suggestion,
Ivan

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: cannot delete statements with datatypes in object

Peter Ansell-2
Hi Ivan,

See comments inline.

On 22 April 2014 22:02, Ivan Ricotti <[hidden email]> wrote:
> Hello,
>
> I'm trying to delete a statement using the RepositoryConnection object
> in the Sesame API:
>
> con = this.repository.getConnection();
> for (Statement statement : statements) {
>         con.remove(statement, context);
> }

Could you post a full class with a main method that demonstrates the
problem. It isn't clear where the "statements" variable comes from, or
where context comes from, or why the toStatement method below is
relevant, or whether it may be related to your Repository
implementation. :)

> but some statements are not removed from the repository: statements
> which contain an object that is a literal with datatype are not deleted. IE:
>
> subject: "foo:bar#SITAT000002",
> predicate: "http://www.hereandthere.com/sisrt/address",
> object: "sesame street"^^<http://www.w3.org/2001/XMLSchema#string>"
>
> I think that I'm not creating the right statement but I tried to create
> the literal with and without the datatype parts and the result doesn't
> change: the triple is still there.
>
> This is the code I'm using now to create the statement:
>
> public Statement toStatement(Triple triple) {
>   ValueFactory factory = ValueFactoryImpl.getInstance();
>   Resource subject = factory.createURI(triple.getSubject());
>   URI predicate = factory.createURI(triple.getPredicate());
>   Value object;
>   if (triple.getObject().contains("^^")) {
>     String objectString =
> triple.getObject().substring(0,triple.getObject().indexOf("^^"));
>     object = factory.createLiteral(objectString);

You are losing the datatype URI at this line, so the repository won't
get the datatype in this version.

>   } else {
>     try {
>       object = factory.createURI(triple.getObject());

Although this code may work in some circumstances, it is perfectly
fine to have a URI string in a Literal, in which case this won't
create what the actually intended. Do you have control over the Triple
object at all?

>     } catch (IllegalArgumentException e) {
>       System.err.println(e);
>       object = factory.createLiteral(triple.getObject());
>     }
>   }
>   return factory.createStatement(subject, predicate, object);
> }
>
> (The Triple object contains just strings)
> On the other hand statements withous datatype are deleted.
>
> Any idea?
> Thanks for your suggestion,
> Ivan
>
> ------------------------------------------------------------------------------
> Start Your Social Network Today - Download eXo Platform
> Build your Enterprise Intranet with eXo Platform Software
> Java Based Open Source Intranet - Social, Extensible, Cloud Ready
> Get Started Now And Turn Your Intranet Into A Collaboration Platform
> http://p.sf.net/sfu/ExoPlatform
> _______________________________________________
> Sesame-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/sesame-general

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Sesame-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sesame-general
Loading...