Skip to content

Commit

Permalink
added missing querybuilder code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudenw committed Oct 15, 2014
1 parent fccf055 commit 2fb788d
Show file tree
Hide file tree
Showing 2,277 changed files with 6,549 additions and 330,892 deletions.
1 change: 0 additions & 1 deletion jena-extras/jena-querybuilder
Submodule jena-querybuilder deleted from dc4dbd
8 changes: 4 additions & 4 deletions jena-sdb/LICENSE → jena-extras/jena-querybuilder/LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -179,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright {yyyy} {name of copyright owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -200,3 +199,4 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

49 changes: 49 additions & 0 deletions jena-extras/jena-querybuilder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
querybuilder
============

Query Builder for Jena. Implementations of Ask, Construct and Select builders that allow developers to create queries without resorting to StringBuilders or similar solutions.

Each of the builders has a series of methods to define the query. Each method returns the builder for easy chaing. The example:

```
SelectBuilder sb = new SelectBuilder()
.addVar( "*" )
.addWhere( "?s", "?o", "?p" );
Query q = sb.build();
```

produces `SELECT * WHERE { ?s ?o ?p . }`

Template Usage
==============

In addition to making it easier to build valid queries the QueryBuilder has a clone method. Using this a developer can create as "Template" query and add to it as necessary.

for example using the above query as the "template" the this code:

```
SelectBuilder sb2 = sb.clone();
sb2.addPrefix( "foaf", "http://xmlns.com/foaf/0.1/" ).addWhere( ?s, RDF.type, foaf:Person)
```

produces `PREFIX foaf: http://xmlns.com/foaf/0.1/ SELECT * WHERE { ?s ?o ?p . ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> foaf:person . }`

Prepared Statement Usage
========================

The query builders have the ability to replace variables with other values. This can be

```
SelectBuilder sb = new SelectBuilder()
.addVar( "*" )
.addWhere( "?s", "?o", "?p" );
sb.setVar( Var.alloc( "?p" ), NodeFactory.createURI( "http://xmlns.com/foaf/0.1/Person" )
Query q = sb.build();
```

produces `SELECT * WHERE { ?s ?o <http://xmlns.com/foaf/0.1/Person> . }`

14 changes: 14 additions & 0 deletions jena-extras/jena-querybuilder/license-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
48 changes: 48 additions & 0 deletions jena-extras/jena-querybuilder/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jena-querybuilder</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.xenei</groupId>
<artifactId>junit-contracts</artifactId>
</dependency>
</dependencies>
<name>Apache Jena Query Builder- jena-querybulder</name>
<inceptionYear>2014</inceptionYear>
<organization>
<name>The Apache Software Foundation</name>
<url>http://www.apache.org/</url>
</organization>
<properties>

</properties>
<scm>
<!-- <url>https://svn.apache.org/repos/asf/jena/Experimental/jena-common/</url>
<connection>scm:svn:https://svn.apache.org/repos/asf/jena/Experimental/jena-common/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/jena/Experimental/jena-common/</developerConnection>
-->
</scm>
<parent>
<groupId>org.apache.jena</groupId>
<artifactId>jena-extras</artifactId>
<relativePath>..</relativePath>
<version>2.12.2-SNAPSHOT</version>
</parent>
<description>A utility package to simplify the building of ARQ queries in code. Provides both a simple builder interface for queries as well as simple prepared statement processing.</description>
</project>
Loading

0 comments on commit 2fb788d

Please sign in to comment.