org.openrdf.query.UpdateExecutionException Java Examples
The following examples show how to use
org.openrdf.query.UpdateExecutionException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectParserTest.java From anno4j with Apache License 2.0 | 6 votes |
@Test public void testMultipleInOneTurtle() throws UpdateExecutionException { try { URL url = new URL("http://example.com/"); ObjectParser objectParser = new ObjectParser(); List<Annotation> annotations = objectParser.parse(TURTLE_MULTIPLE, url, RDFFormat.TURTLE, true); assertEquals(3, annotations.size()); for(Annotation anno : annotations) { System.out.println(anno.toString()); } objectParser.shutdown(); } catch (IOException | RepositoryException | RepositoryConfigException e) { e.printStackTrace(); } }
Example #2
Source File: AnnotationTest.java From anno4j with Apache License 2.0 | 6 votes |
@Test public void testSingleTarget() throws RepositoryException, InstantiationException, IllegalAccessException, UpdateExecutionException, MalformedQueryException { // Create annotation Annotation annotation = anno4j.createObject(Annotation.class); // Create specific resource SpecificResource specificResource = anno4j.createObject(SpecificResource.class); ResourceObject resourceObject = anno4j.createObject(ResourceObject.class); resourceObject.setResourceAsString("http://www.somepage.org/resource1/"); specificResource.setSource(resourceObject); annotation.addTarget(specificResource); // Query annotation Annotation result = anno4j.findByID(Annotation.class, annotation.getResourceAsString()); // Tests assertEquals(1, result.getTargets().size()); assertEquals(("http://www.somepage.org/resource1/"), ((SpecificResource) result.getTargets().toArray()[0]).getSource().getResource().toString()); }
Example #3
Source File: SelectorFactoryTest.java From anno4j with Apache License 2.0 | 6 votes |
private void clear() throws RepositoryException, UpdateExecutionException { String deleteUpdate = "DELETE {?s ?p ?o}\n" + "WHERE {?s ?p ?o}"; ObjectConnection connection = this.anno4j.getObjectRepository().getConnection(); Update update; try { update = connection.prepareUpdate(deleteUpdate); } catch (MalformedQueryException e) { e.printStackTrace(); return; } update.execute(); }
Example #4
Source File: BigdataSPARQLUpdateTest2.java From database with GNU General Public License v2.0 | 6 votes |
/** * A correct rejection test which verifies that an exception is thrown if * the named solution set does not exist. */ public void test_clearSolutionSet_01() throws UpdateExecutionException, RepositoryException, MalformedQueryException { if (!isSolutionSetUpdateEnabled()) { /* * Test requires this feature. */ return; } try { con.prepareUpdate(QueryLanguage.SPARQL, "clear solutions %namedSet1") .execute(); fail("Excepting: " + UpdateExecutionException.class); } catch(UpdateExecutionException ex) { if(log.isInfoEnabled()) log.info("Ignoring expected exception: "+ex); } }
Example #5
Source File: ObjectParser.java From anno4j with Apache License 2.0 | 6 votes |
/** * Parses the given RDF-document and returns all resources of the specified type. * In contrary to {@link #parse(String, URL, RDFFormat, boolean)} the returned objects are duplicate free. * * @param type An {@link org.openrdf.annotations.Iri}-annotated type that all returned objects must have. * @param content The RDF-serialization to read from. This must be in the format specified by {@code format}. * @param documentURL The base URL used for namespaces. * @param format The format of the given RDF-serialization. * @param clear Determines, if the local Anno4j instance should be cleared or not in the beginning. * This can be set to increase performance. * @param <T> The type of the returned objects. * @return Returns all resources having the given type as their {@code rdf:type}. This result will also contain * all objects parsed since the underlying Anno4j instance was last cleared. * @throws RepositoryException Thrown if an error occurred accessing the connected triplestore of the underlying * Anno4j instance. * @throws RDFParseException Thrown if an error occurs while parsing the RDF-document. */ public <T extends ResourceObject> List<T> parse(Class<? extends T> type, String content, URL documentURL, RDFFormat format, boolean clear) throws RepositoryException, RDFParseException { // Clear all triples in the triplestore if requested: if (clear) { try { clear(); } catch (UpdateExecutionException e) { throw new RepositoryException(e); } } // Read the RDF-document and store triples in the repository of the anno4j instance: readRDF(content, documentURL, format); // Get the instances of the requested type: List<T> instances = getInstancesOfType(type); return instances; }
Example #6
Source File: AnnotationTest.java From anno4j with Apache License 2.0 | 6 votes |
@Test public void testGetTriples() throws RepositoryException, IllegalAccessException, InstantiationException, UpdateExecutionException, MalformedQueryException { Annotation annotation = this.anno4j.createObject(Annotation.class); // Create specific resource1 SpecificResource specificResource = anno4j.createObject(SpecificResource.class); ResourceObject resourceObject = anno4j.createObject(ResourceObject.class); resourceObject.setResourceAsString("http://www.somepage.org/resource1/"); specificResource.setSource(resourceObject); annotation.addTarget(specificResource); Motivation comment = MotivationFactory.getCommenting(this.anno4j); annotation.addTarget(specificResource); annotation.addMotivation(comment); System.out.println(annotation.getTriples(RDFFormat.RDFXML)); }
Example #7
Source File: ObjectParser.java From anno4j with Apache License 2.0 | 6 votes |
/** * Clears the Anno4j underlying triplestore. * This is required in order to prevent a drop in throughput while parsing. * * @throws RepositoryException Thrown if no connection to the object repository could be made. * @throws UpdateExecutionException Thrown if an error occurred while executing the clearing query. */ private void clear() throws RepositoryException, UpdateExecutionException { String deleteUpdate = "DELETE {?s ?p ?o}\n" + "WHERE {?s ?p ?o}"; ObjectConnection connection = anno4j.getObjectRepository().getConnection(); Update update; try { update = connection.prepareUpdate(deleteUpdate); } catch (MalformedQueryException e) { e.printStackTrace(); return; } update.execute(); }
Example #8
Source File: BigdataSPARQLUpdateTest2.java From database with GNU General Public License v2.0 | 6 votes |
/** * A correct rejection test which verifies that an exception is thrown if * the named solution set does not exist. */ public void test_dropSolutionSet_01() throws UpdateExecutionException, RepositoryException, MalformedQueryException { if (!isSolutionSetUpdateEnabled()) { /* * Test requires this feature. */ return; } try { con.prepareUpdate(QueryLanguage.SPARQL, "drop solutions %namedSet1") .execute(); fail("Excepting: " + UpdateExecutionException.class); } catch(UpdateExecutionException ex) { if(log.isInfoEnabled()) log.info("Ignoring expected exception: "+ex); } }
Example #9
Source File: ObjectParserTest.java From anno4j with Apache License 2.0 | 6 votes |
@Test public void testJSONLD() throws UpdateExecutionException { try { URL url = new URL("http://example.com/"); ObjectParser objectParser = new ObjectParser(); List<Annotation> annotations = objectParser.parse(JSONLD, url, RDFFormat.JSONLD, true); for(Annotation anno : annotations) { System.out.println(anno.toString()); } assertEquals(1, annotations.size()); objectParser.shutdown(); } catch (RepositoryException | MalformedURLException | RepositoryConfigException e) { e.printStackTrace(); } }
Example #10
Source File: ObjectParserTest.java From anno4j with Apache License 2.0 | 6 votes |
@Test public void testTurtle() throws UpdateExecutionException { try { URL url = new URL("http://example.com/"); ObjectParser objectParser = new ObjectParser(); List<Annotation> annotations = objectParser.parse(TURTLE, url, RDFFormat.TURTLE, true); for(Annotation anno : annotations) { System.out.println(anno.toString()); } assertEquals(1, annotations.size()); objectParser.shutdown(); } catch (IOException | RepositoryException | RepositoryConfigException e) { e.printStackTrace(); } }
Example #11
Source File: ObjectParserTest.java From anno4j with Apache License 2.0 | 6 votes |
@Test public void testMultipleTurtle() throws UpdateExecutionException { try { URL url = new URL("http://example.com/"); ObjectParser objectParser = new ObjectParser(); List<Annotation> annotations = new LinkedList<>(); annotations.addAll(objectParser.parse(TURTLE, url, RDFFormat.TURTLE, true)); annotations.addAll(objectParser.parse(TURTLE2, url, RDFFormat.TURTLE, true)); annotations.addAll(objectParser.parse(TURTLE3, url, RDFFormat.TURTLE, true)); assertEquals(3, annotations.size()); for(Annotation anno : annotations) { System.out.println(anno.toString()); } objectParser.shutdown(); } catch (IOException | RepositoryException | RepositoryConfigException e) { e.printStackTrace(); } }
Example #12
Source File: TestTicket1716.java From database with GNU General Public License v2.0 | 6 votes |
private void executeQuery(final BigdataSailRepository repo) throws UpdateExecutionException, RepositoryException, MalformedQueryException { try { repo.initialize(); final BigdataSailRepositoryConnection conn = repo.getConnection(); try { String update = "insert {" + "<http://dbpedia.org/resource/Jules_Verne> <http://dbpedia.org/property/period> \"\"^^<http://www.w3.org/2001/XMLSchema#int>\r\n" + "} where {}"; Update preparedUpdate = conn.prepareUpdate(QueryLanguage.SPARQL, update); preparedUpdate.execute(); // no exception should occur on execution, overwise test will fail } finally { conn.close(); } } finally { repo.shutDown(); } }
Example #13
Source File: OWLSchemaPersistingManager.java From anno4j with Apache License 2.0 | 6 votes |
/** * Persists inheritance information for the given concepts to the default graph of the connected * triplestore. * The inheritance is modelled using <code>rdfs:subClassOf</code> predicate. * @param concepts The {@link Iri} annotated concept types which inheritance structure should be persisted. * @throws RepositoryException Thrown if an error occurs while inserting into the connected triplestore. */ private void persistInheritance(Collection<Class<?>> concepts) throws RepositoryException { StringBuilder q = new StringBuilder(QUERY_PREFIX + "INSERT DATA {"); for (Class<?> concept : concepts) { Iri conceptIri = concept.getAnnotation(Iri.class); for (Class<?> superConcept : concept.getInterfaces()) { if(conceptIri != null && superConcept.isAnnotationPresent(Iri.class)) { Iri superConceptIri = superConcept.getAnnotation(Iri.class); q.append("<").append(conceptIri.value()).append("> rdfs:subClassOf <").append(superConceptIri.value()).append("> . "); } } } q.append("}"); try { getConnection().prepareUpdate(q.toString()).execute(); } catch (MalformedQueryException | UpdateExecutionException e) { throw new RepositoryException(e); } }
Example #14
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testCreateExistingGraph() throws Exception { logger.debug("executing testCreateExistingGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("CREATE GRAPH <" + graph1 + "> "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); try { operation.execute(); fail("creation of existing graph should have resulted in error."); } catch (UpdateExecutionException e) { // expected behavior con.rollback(); } }
Example #15
Source File: SchemaSanitizingObjectSupport.java From anno4j with Apache License 2.0 | 6 votes |
/** * Sets the resource as the value of the inverse property for any value of a property of this * resource that has an inverse property. * @throws RepositoryException Thrown if an error occurs while updating the repository. */ private void sanitizeInverseProperties() throws RepositoryException { ObjectConnection connection = getObjectConnection(); try { connection.prepareUpdate(QueryLanguage.SPARQL, "INSERT {" + " ?o ?inverse <" + getResourceAsString() + "> . " + "} WHERE {" + " <" + getResourceAsString() + "> ?p ?o . " + " ?p owl:inverseOf ?inverse . " + "}" ).execute(); } catch (MalformedQueryException | UpdateExecutionException e) { throw new RepositoryException(e); } }
Example #16
Source File: SchemaSanitizingObjectSupport.java From anno4j with Apache License 2.0 | 6 votes |
/** * Complements transitive edges for transitive properties ({@code owl:TransitiveProperty}). * @throws RepositoryException Thrown if an error occurs while updating the repository. */ private void sanitizeTransitivity() throws RepositoryException { ObjectConnection connection = getObjectConnection(); try { connection.prepareUpdate(QueryLanguage.SPARQL, "INSERT {" + " <" + getResourceAsString() + "> ?p ?z . " + "} WHERE {" + " <" + getResourceAsString() + "> ?p ?y . " + " ?y ?p ?z . " + " ?p a owl:TransitiveProperty . " + "}" ).execute(); } catch (MalformedQueryException | UpdateExecutionException e) { throw new RepositoryException(e); } }
Example #17
Source File: SchemaSanitizingObjectSupport.java From anno4j with Apache License 2.0 | 6 votes |
/** * Complements symmetric properties ({@code owl:SymmetricProperty}) in order to satisfy * symmetry. * @throws RepositoryException Thrown if an error occurs while updating the repository. */ private void sanitizeSymmetry() throws RepositoryException { ObjectConnection connection = getObjectConnection(); try { connection.prepareUpdate(QueryLanguage.SPARQL, "INSERT {" + " ?o ?p <" + getResourceAsString() + "> . " + "} WHERE {\n" + " <" + getResourceAsString() + "> ?p ?o . " + " ?p a owl:SymmetricProperty . " + "}" ).execute(); } catch (MalformedQueryException | UpdateExecutionException e) { throw new RepositoryException(e); } }
Example #18
Source File: BigdataSailUpdate.java From database with GNU General Public License v2.0 | 6 votes |
/** * Execute a SPARQL UPDATE request. * * @return The timestamp of the commit point for that UPDATE. * * @throws UpdateExecutionException */ public long execute2() throws UpdateExecutionException { // final QueryRoot originalQuery = astContainer.getOriginalAST(); // //// if (getMaxQueryTime() > 0) //// originalQuery.setTimeout(TimeUnit.SECONDS //// .toMillis(getMaxQueryTime())); // // originalQuery.setIncludeInferred(getIncludeInferred()); return ASTEvalHelper.executeUpdate( ((BigdataSailRepositoryConnection) getConnection()), astContainer,// dataset,// getIncludeInferred(),// new QueryBindingSet(getBindings()) ); }
Example #19
Source File: BigdataSPARQLUpdateTest2.java From database with GNU General Public License v2.0 | 5 votes |
/** * A test which verifies that an exception is NOT thrown if * the named solution set does not exist and SILENT is specified. */ public void test_clearSolutionSet_02() throws UpdateExecutionException, RepositoryException, MalformedQueryException { if (!isSolutionSetUpdateEnabled()) { /* * Test requires this feature. */ return; } con.prepareUpdate(QueryLanguage.SPARQL, "clear silent solutions %namedSet1").execute(); }
Example #20
Source File: BigdataSPARQLUpdateTest2.java From database with GNU General Public License v2.0 | 5 votes |
/** * Unit test of CREATE SILENT SOLUTIONS verifies that an error is reported * if SILENT is not specified and the solution set exists and that the error * is suppressed if the SILENT keyword is given. */ public void test_createSolutionSet_02() throws UpdateExecutionException, RepositoryException, MalformedQueryException { if (!isSolutionSetUpdateEnabled()) { /* * Test requires this feature. */ return; } // Should succeed. con.prepareUpdate(QueryLanguage.SPARQL, "create solutions %namedSet1") .execute(); // Should fail. try { con.prepareUpdate(QueryLanguage.SPARQL, "create solutions %namedSet1").execute(); fail("Excepting: " + UpdateExecutionException.class); } catch (UpdateExecutionException ex) { if (log.isInfoEnabled()) log.info("Ignoring expected exception: " + ex); } // Should succeed since SILENT. con.prepareUpdate(QueryLanguage.SPARQL, "create silent solutions %namedSet1").execute(); }
Example #21
Source File: BigdataSPARQLUpdateTest2.java From database with GNU General Public License v2.0 | 5 votes |
/** * Unit test of CREATE SOLUTIONS. * <p> * Note: If named solution sets which do not exist are equivalent to empty * named solution sets, then the only way to verify the post-condition is to * issue a DROP or CLEAR on the named solution set. The DROP/CLEAR should * throw an exception if the named solution set is not found. */ public void test_createSolutionSet_01() throws UpdateExecutionException, RepositoryException, MalformedQueryException { if (!isSolutionSetUpdateEnabled()) { /* * Test requires this feature. */ return; } // Should fail since solution set does not exist. try { con.prepareUpdate(QueryLanguage.SPARQL, "drop solutions %namedSet1") .execute(); fail("Excepting: " + UpdateExecutionException.class); } catch(UpdateExecutionException ex) { if(log.isInfoEnabled()) log.info("Ignoring expected exception: "+ex); } // Should succeed. con.prepareUpdate(QueryLanguage.SPARQL, "create solutions %namedSet1") .execute(); // Should succeed (and should fail if the solution set does not exist). con.prepareUpdate(QueryLanguage.SPARQL, "drop solutions %namedSet1") .execute(); }
Example #22
Source File: BigdataSPARQLUpdateTest.java From database with GNU General Public License v2.0 | 5 votes |
/** * Unit test for * * <pre> * DROP ALL; * INSERT DATA { * GRAPH <http://example.org/one> { * <a> <b> <c> . * <d> <e> <f> . * }}; * ADD SILENT GRAPH <http://example.org/one> TO GRAPH <http://example.org/two> ; * DROP SILENT GRAPH <http://example.org/one> ; * </pre> * * The IV cache was not not being propagated correctly with the result that * we were seeing mock IVs for "one" and "two". The UPDATE would work * correctly the 2nd time since the URIs had been entered into the * dictionary by then. * * @throws RepositoryException * @throws MalformedQueryException * @throws UpdateExecutionException * * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/567" > * Failure to set cached value on IV results in incorrect behavior for * complex UPDATE operation </a> */ public void testTicket567() throws RepositoryException, MalformedQueryException, UpdateExecutionException { // replace the standard dataset with one specific to this case. con.clear(); con.commit(); final StringBuilder update = new StringBuilder(); update.append("DROP ALL;\n"); update.append("INSERT DATA {\n"); update.append(" GRAPH <http://example.org/one> {\n"); update.append(" <http://example.org/a> <http://example.org/b> <http://example.org/c> .\n"); update.append(" <http://example.org/d> <http://example.org/e> <http://example.org/f> .\n"); update.append("}};\n"); update.append("ADD SILENT GRAPH <http://example.org/one> TO GRAPH <http://example.org/two> ;\n"); update.append("DROP SILENT GRAPH <http://example.org/one> ;\n"); final Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); final URI one = f.createURI("http://example.org/one"); final URI two = f.createURI("http://example.org/two"); String msg = "Nothing in graph <one>"; assertFalse(msg, con.hasStatement(null, null, null, true, one)); msg = "statements are in graph <two>"; assertTrue(msg, con.hasStatement(null, null, null, true, two)); }
Example #23
Source File: TestTicket1753.java From database with GNU General Public License v2.0 | 5 votes |
private void executeQuery(final BigdataSailRepository repo) throws UpdateExecutionException, RepositoryException, MalformedQueryException { try { repo.initialize(); final BigdataSailRepositoryConnection conn = repo.getConnection(); try { String update = "insert\r\n" + "{ <http://dbpedia.org/resource/Jules_Verne> <http://ll.com.br/related> ?ss}\r\n" + "where { {select distinct ?ss where { \r\n" + " ?b <http://ll.com.br/author> ?ss . ?ss <http://purl.org/dc/terms/subject> ?x . \r\n" + " filter(?ss != <http://dbpedia.org/resource/Jules_Verne>)\r\n" + " {select (count(distinct ?s) as ?c) ?x where\r\n" + " { <http://dbpedia.org/resource/Jules_Verne> <http://purl.org/dc/terms/subject> ?x . \r\n" + " ?s <http://purl.org/dc/terms/subject> ?x . \r\n" + " ?b <http://ll.com.br/author> ?s . \r\n" + " filter( !contains(str(?x),\"University\") \r\n" + " && !contains(str(?x),\"People\") \r\n" + " && !contains(str(?x),\"Convert\") \r\n" + " && !contains(str(?x),\"people\") )} \r\n" + " group by ?x having(?c < 500) } \r\n" + "}order by asc(?c) limit 20} }"; Update preparedUpdate = conn.prepareUpdate(QueryLanguage.SPARQL, update); preparedUpdate.execute(); // no exception should occur on execution, overwise test will fail } finally { conn.close(); } } finally { repo.shutDown(); } }
Example #24
Source File: AnnotationTest.java From anno4j with Apache License 2.0 | 5 votes |
@Test public void testMultipleTargets() throws RepositoryException, InstantiationException, IllegalAccessException, UpdateExecutionException, MalformedQueryException { // Create annotation Annotation annotation = anno4j.createObject(Annotation.class); // Create specific resource1 SpecificResource specificResource = anno4j.createObject(SpecificResource.class); ResourceObject resourceObject = anno4j.createObject(ResourceObject.class); resourceObject.setResourceAsString("http://www.somepage.org/resource1/"); specificResource.setSource(resourceObject); annotation.addTarget(specificResource); // Create specific resource2 SpecificResource specificResource2 = anno4j.createObject(SpecificResource.class); ResourceObject resourceObject2 = anno4j.createObject(ResourceObject.class); resourceObject2.setResourceAsString("http://www.somepage.org/resource2/"); specificResource2.setSource(resourceObject2); annotation.addTarget(specificResource2); // Query annotation Annotation result = anno4j.findByID(Annotation.class, annotation.getResourceAsString()); // Tests List<String> urls = new ArrayList<>(); for(Target target : result.getTargets()) { urls.add(((SpecificResource) target).getSource().getResource().toString()); } assertTrue(urls.contains("http://www.somepage.org/resource1/")); assertTrue(urls.contains("http://www.somepage.org/resource2/")); assertEquals(2, result.getTargets().size()); }
Example #25
Source File: TestTicket1889.java From database with GNU General Public License v2.0 | 5 votes |
/** * Prepares data containing blank nodes, loads it into triplestore, * then run an update, which creates additional statements with blank nodes * resulting number of statements loaded should be 2*n. * Total number of blank nodes will be n+k. * @param repo Repository to load data * @param n Number of statements to be loaded * @param k Number of subjects to be loaded */ protected void executeQuery(final BigdataSailRepository repo, final int n, final int k) throws RepositoryException, MalformedQueryException, QueryEvaluationException, RDFParseException, IOException, UpdateExecutionException { final BigdataSailRepositoryConnection conn = repo.getConnection(); conn.setAutoCommit(false); conn.clear(); try { StringBuilder data = new StringBuilder(); for (int i = 0; i < n; i++) { data.append("_:s").append(i%k).append(" <http://p> _:o").append(i).append(" <http://c> .\n"); } conn.add(new ByteArrayInputStream(data.toString().getBytes()), "", RDFFormat.NQUADS); conn.commit(); final String query = "prefix h: <http://>\r\n" + "\r\n" + "INSERT { \r\n" + " GRAPH h:c { ?s h:p1 ?o }\r\n" + "}\r\n" + "WHERE\r\n" + " { GRAPH h:c {?s h:p ?o }\r\n" + "}"; final Update q = conn.prepareUpdate(QueryLanguage.SPARQL, query); q.execute(); assertEquals(n * 2, conn.getTripleStore().getStatementCount(true)); } finally { conn.close(); } }
Example #26
Source File: BigdataSPARQLUpdateTest2.java From database with GNU General Public License v2.0 | 5 votes |
/** * A test which verifies that an exception is NOT thrown if * the named solution set does not exist and SILENT is specified. */ public void test_dropSolutionSet_02() throws UpdateExecutionException, RepositoryException, MalformedQueryException { if (!isSolutionSetUpdateEnabled()) { /* * Test requires this feature. */ return; } con.prepareUpdate(QueryLanguage.SPARQL, "drop silent solutions %namedSet1").execute(); }
Example #27
Source File: OWLSchemaPersistingManager.java From anno4j with Apache License 2.0 | 5 votes |
/** * Persists the information that a property is the inverse of another property to the default graph of the connected triplestore. * All properties with {@link InverseOf} annotation are considered. * @param annotatedObjects The {@link Iri} annotated objects that should be considered. * @throws RepositoryException Thrown on error regarding the connected triplestore. * @throws UpdateExecutionException Thrown if an error occurred while executing the update. */ private void persistInverseOf(Collection<AccessibleObject> annotatedObjects) throws RepositoryException, UpdateExecutionException { // Get those methods and fields that have the @InverseOf annotation: Collection<AccessibleObject> inverseOfObjects = filterObjectsWithAnnotation(annotatedObjects, InverseOf.class); for (AccessibleObject object : inverseOfObjects) { String iri = getIriFromObject(object); InverseOf inverseOfAnnotation = object.getAnnotation(InverseOf.class); StringBuilder query = new StringBuilder(QUERY_PREFIX) .append(" INSERT DATA { "); for (String inversePropertyIri : inverseOfAnnotation.value()) { query.append("<").append(iri).append("> owl:inverseOf ") .append("<").append(inversePropertyIri).append("> . ") .append("<").append(inversePropertyIri).append("> owl:inverseOf ") .append("<").append(iri).append("> . "); } query.append("}"); // Prepare the update query and execute it: try { Update update = getConnection().prepareUpdate(query.toString()); update.execute(); } catch (MalformedQueryException e) { throw new UpdateExecutionException(); } } }
Example #28
Source File: OWLSchemaPersistingManager.java From anno4j with Apache License 2.0 | 5 votes |
/** * Persists the information that a property is a subproperty of another to the default graph of the connected triplestore. * All properties with {@link SubPropertyOf} annotation are considered. * @param annotatedObjects The {@link Iri} annotated objects that should be considered. * @throws RepositoryException Thrown on error regarding the connected triplestore. * @throws UpdateExecutionException Thrown if an error occurred while executing the update. */ private void persistSubPropertyOf(Collection<AccessibleObject> annotatedObjects) throws RepositoryException, UpdateExecutionException { // Get those methods and fields that have the @Transitive annotation: Collection<AccessibleObject> subPropertyObjects = filterObjectsWithAnnotation(annotatedObjects, SubPropertyOf.class); for (AccessibleObject object : subPropertyObjects) { String iri = getIriFromObject(object); SubPropertyOf subPropertyAnnotation = object.getAnnotation(SubPropertyOf.class); StringBuilder query = new StringBuilder(QUERY_PREFIX) .append(" INSERT DATA { "); for (String superPropertyIri : subPropertyAnnotation.value()) { query.append("<").append(iri).append("> ") .append("<").append(RDFS.SUB_PROPERTY_OF).append("> ") .append("<").append(superPropertyIri).append("> . "); } query.append("}"); // Prepare the update query and execute it: try { Update update = getConnection().prepareUpdate(query.toString()); update.execute(); } catch (MalformedQueryException e) { throw new UpdateExecutionException(); } } }
Example #29
Source File: OWLSchemaPersistingManager.java From anno4j with Apache License 2.0 | 5 votes |
/** * Persists the information that a property is transitive to the default graph of the connected triplestore. * All properties with {@link com.github.anno4j.annotations.Transitive} annotation are considered. * @param annotatedObjects The {@link Iri} annotated objects that should be considered. * @throws RepositoryException Thrown on error regarding the connected triplestore. * @throws UpdateExecutionException Thrown if an error occurred while executing the update. */ private void persistTransitive(Collection<AccessibleObject> annotatedObjects) throws RepositoryException, UpdateExecutionException { // Get those methods and fields that have the @Transitive annotation: Collection<AccessibleObject> transitiveObjects = filterObjectsWithAnnotation(annotatedObjects, Transitive.class); // Prepare the update query and execute it: try { Update update = buildInstanceUpdate(getIrisFromObjects(transitiveObjects), OWL.TRANSITIVE_PROPERTY); update.execute(); } catch (MalformedQueryException e) { throw new UpdateExecutionException(); } }
Example #30
Source File: OWLSchemaPersistingManager.java From anno4j with Apache License 2.0 | 5 votes |
/** * Persists the information that a property is symmetric to the default graph of the connected triplestore. * All properties with {@link com.github.anno4j.annotations.Symmetric} annotation are considered. * @param annotatedObjects The {@link Iri} annotated objects that should be considered. * @throws RepositoryException Thrown on error regarding the connected triplestore. * @throws UpdateExecutionException Thrown if an error occurred while executing the update. */ private void persistSymmetric(Collection<AccessibleObject> annotatedObjects) throws RepositoryException, UpdateExecutionException { // Get those methods and fields that have the @Symmetric annotation: Collection<AccessibleObject> symmetricObjects = filterObjectsWithAnnotation(annotatedObjects, Symmetric.class); // Prepare the update query and execute it: try { Update update = buildInstanceUpdate(getIrisFromObjects(symmetricObjects), OWL.SYMMETRIC_PROPERTY); update.execute(); } catch (MalformedQueryException e) { throw new UpdateExecutionException(); } }