Re: Search for Resource is case-sensitive?
On Saturday, September 22, 2012 01:57:59 PM Paul Taylor wrote: Hello there again, I have a Jena model that is stored in an SDBStore backed by MySQL. I would like to know whether a particular Resource exists in the Model. I cannot use the model.getResource(uri) because according to javadoc this will always return a Resource since it will create a new one if it does not exist. The only way a Resource exists in a model is to appear as the subject, predicate, or object of some statement. getResource() will create a new Jena resource object, but it doesn't tinker with the statements in the model. Having got a Resource, call it R, you can then see if it has any properties or whether it appears as the object of any statement. [Also model.containsResource(RDFNode n) should work, assuming that SDB doesn't pessimise it.] Chris -- It does not need to take events in their correct order. /Hexwood/ Epimorphics Ltd, http://www.epimorphics.com Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20 6PT Epimorphics Ltd. is a limited company registered in England (number 7016688)
Re: Search for Resource is case-sensitive?
Hello, I have created a simple model in memory just to test that and it seems to do what I have been looking for, URIs are case-sensitive. Model model = ModelFactory.createDefaultModel(); Resource res = model.createResource(http://somewhere/Person;); res.addLiteral(RDFS.label, person); RDFNode node = model.getResource(http://somewhere/Person;); boolean exists = model.containsResource(node); System.out.println(Resource exists: + exists); Thank you both for your answers, Paul - Original Message - From: Chris Dollin chris.dol...@epimorphics.com To: users@jena.apache.org Cc: Sent: Monday, 24 September 2012, 8:49 Subject: Re: Search for Resource is case-sensitive? On Saturday, September 22, 2012 01:57:59 PM Paul Taylor wrote: Hello there again, I have a Jena model that is stored in an SDBStore backed by MySQL. I would like to know whether a particular Resource exists in the Model. I cannot use the model.getResource(uri) because according to javadoc this will always return a Resource since it will create a new one if it does not exist. The only way a Resource exists in a model is to appear as the subject, predicate, or object of some statement. getResource() will create a new Jena resource object, but it doesn't tinker with the statements in the model. Having got a Resource, call it R, you can then see if it has any properties or whether it appears as the object of any statement. [Also model.containsResource(RDFNode n) should work, assuming that SDB doesn't pessimise it.] Chris -- It does not need to take events in their correct order. /Hexwood/ Epimorphics Ltd, http://www.epimorphics.com Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20 6PT Epimorphics Ltd. is a limited company registered in England (number 7016688)
Re: Search for Resource is case-sensitive?
On 22/09/12 13:57, Paul Taylor wrote: Hello there again, I have a Jena model that is stored in an SDBStore backed by MySQL. I would like to know whether a particular Resource exists in the Model. I cannot use the model.getResource(uri) because according to javadoc this will always return a Resource since it will create a new one if it does not exist. Therefore, I use jena arq engine and a SPARQL ASK query: Q1: ASK WHERE {http://purl.org/ontology/mo/performance ?p ?o .} Q2: ASK WHERE {http://purl.org/ontology/mo/Performance ?p ?o .} Q1 returns false, and Q2 returns true. Notice that in Q2 the last word starts with a capital letter. Just want to know whether there is a way to make this case-insensitive. Or whether there is any other way to find out whether a particular Resource exists in the Model. I am using: jena-core-2.7.3, jena-sdb-1.3.5-SNAPSHOT, jena-arq-2.9.3. Thanks in advance for your help. In RDF, URIs are case sensitive. ASK WHERE {?s ?p ?o . FILTER(lcase(str(?s)) = 'http://purl.org/ontology/mo/performance') } (untested) will do (but with SDB will be slow). It is much faster in TDB. Andy