You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rya.apache.org by pu...@apache.org on 2015/10/28 20:24:11 UTC
[17/51] [partial] incubator-rya git commit: now including the actual
project
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/indexingSailExample/src/main/java/RyaDirectExample.java
----------------------------------------------------------------------
diff --git a/extras/indexingSailExample/src/main/java/RyaDirectExample.java b/extras/indexingSailExample/src/main/java/RyaDirectExample.java
new file mode 100644
index 0000000..947164c
--- /dev/null
+++ b/extras/indexingSailExample/src/main/java/RyaDirectExample.java
@@ -0,0 +1,681 @@
+
+import java.util.List;
+
+import mvm.rya.accumulo.AccumuloRdfConfiguration;
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.indexing.RyaSailFactory;
+import mvm.rya.indexing.accumulo.ConfigUtils;
+import mvm.rya.indexing.accumulo.geo.GeoConstants;
+import mvm.rya.indexing.external.tupleSet.AccumuloIndexSet;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.MutationsRejectedException;
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.commons.lang.Validate;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.log4j.Logger;
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.LiteralImpl;
+import org.openrdf.model.impl.URIImpl;
+import org.openrdf.model.vocabulary.RDF;
+import org.openrdf.model.vocabulary.RDFS;
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.MalformedQueryException;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.query.QueryResultHandlerException;
+import org.openrdf.query.TupleQuery;
+import org.openrdf.query.TupleQueryResultHandler;
+import org.openrdf.query.TupleQueryResultHandlerException;
+import org.openrdf.query.Update;
+import org.openrdf.query.UpdateExecutionException;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.repository.sail.SailRepositoryConnection;
+import org.openrdf.sail.Sail;
+import org.openrdf.sail.SailException;
+
+public class RyaDirectExample {
+ private static final Logger log = Logger.getLogger(RyaDirectExample.class);
+
+ //
+ // Connection configuration parameters
+ //
+
+ private static final boolean USE_MOCK_INSTANCE = true;
+ private static final boolean PRINT_QUERIES = true;
+ private static final String INSTANCE = "instance";
+ private static final String RYA_TABLE_PREFIX = "x_test_triplestore_";
+ private static final String AUTHS = "";
+
+
+
+ public static void main(String[] args) throws Exception {
+ Configuration conf = getConf();
+ conf.setBoolean(ConfigUtils.DISPLAY_QUERY_PLAN, PRINT_QUERIES);
+
+ log.info("Creating the tables as root.");
+// createTables(addRootConf(conf), conf);
+
+ SailRepository repository = null;
+ SailRepositoryConnection conn = null;
+
+ try {
+ log.info("Connecting to Indexing Sail Repository.");
+
+ Sail extSail = RyaSailFactory.getInstance(conf);
+ repository = new SailRepository(extSail);
+ repository.initialize();
+ conn = repository.getConnection();
+
+ createPCJ(conn);
+
+ long start = System.currentTimeMillis();
+ log.info("Running SPARQL Example: Add and Delete");
+ testAddAndDelete(conn);
+ log.info("Running SAIL/SPARQL Example: PCJ Search");
+ testPCJSearch(conn);
+ log.info("Running SAIL/SPARQL Example: Add and Temporal Search");
+ testAddAndTemporalSearchWithPCJ(conn);
+ log.info("Running SAIL/SPARQL Example: Add and Free Text Search with PCJ");
+ testAddAndFreeTextSearchWithPCJ(conn);
+ log.info("Running SPARQL Example: Add Point and Geo Search with PCJ");
+ testAddPointAndWithinSearchWithPCJ(conn);
+ log.info("Running SPARQL Example: Temporal, Freetext, and Geo Search");
+ testTemporalFreeGeoSearch(conn);
+ log.info("Running SPARQL Example: Geo, Freetext, and PCJ Search");
+ testGeoFreetextWithPCJSearch(conn);
+
+ log.info("TIME: " + (System.currentTimeMillis() - start) / 1000.);
+ } finally {
+ log.info("Shutting down");
+ closeQuietly(conn);
+ closeQuietly(repository);
+ }
+ }
+
+ private static void closeQuietly(SailRepository repository) {
+ if (repository != null) {
+ try {
+ repository.shutDown();
+ } catch (RepositoryException e) {
+ // quietly absorb this exception
+ }
+ }
+ }
+
+ private static void closeQuietly(SailRepositoryConnection conn) {
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (RepositoryException e) {
+ // quietly absorb this exception
+ }
+ }
+ }
+
+ private static Configuration getConf() {
+
+ AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
+
+ conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, USE_MOCK_INSTANCE);
+ conf.set(ConfigUtils.USE_PCJ, "true");
+ conf.set(ConfigUtils.USE_GEO, "true");
+ conf.set(ConfigUtils.USE_FREETEXT, "true");
+ conf.set(ConfigUtils.USE_TEMPORAL, "true");
+ conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, RYA_TABLE_PREFIX);
+ conf.set(ConfigUtils.CLOUDBASE_USER, "root");
+ conf.set(ConfigUtils.CLOUDBASE_PASSWORD, "");
+ conf.set(ConfigUtils.CLOUDBASE_INSTANCE, INSTANCE);
+ conf.setInt(ConfigUtils.NUM_PARTITIONS, 3);
+ conf.set(ConfigUtils.CLOUDBASE_AUTHS, AUTHS);
+
+ // only geo index statements with geo:asWKT predicates
+ conf.set(ConfigUtils.GEO_PREDICATES_LIST, GeoConstants.GEO_AS_WKT.stringValue());
+ return conf;
+ }
+
+ public static void testAddAndDelete(SailRepositoryConnection conn) throws MalformedQueryException,
+ RepositoryException, UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException,
+ AccumuloException, AccumuloSecurityException, TableNotFoundException {
+
+ // Add data
+ String query = "INSERT DATA\n"//
+ + "{ GRAPH <http://updated/test> {\n"//
+ + " <http://acme.com/people/Mike> " //
+ + " <http://acme.com/actions/likes> \"A new book\" ;\n"//
+ + " <http://acme.com/actions/likes> \"Avocados\" .\n" + "} }";
+
+ log.info("Performing Query");
+
+ Update update = conn.prepareUpdate(QueryLanguage.SPARQL, query);
+ update.execute();
+
+ query = "select ?p ?o { GRAPH <http://updated/test> {<http://acme.com/people/Mike> ?p ?o . }}";
+ CountingResultHandler resultHandler = new CountingResultHandler();
+ TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
+ tupleQuery.evaluate(resultHandler);
+ log.info("Result count : " + resultHandler.getCount());
+
+ Validate.isTrue(resultHandler.getCount() == 2);
+ resultHandler.resetCount();
+
+ // Delete Data
+ query = "DELETE DATA\n" //
+ + "{ GRAPH <http://updated/test> {\n"
+ + " <http://acme.com/people/Mike> <http://acme.com/actions/likes> \"A new book\" ;\n"
+ + " <http://acme.com/actions/likes> \"Avocados\" .\n" + "}}";
+
+ update = conn.prepareUpdate(QueryLanguage.SPARQL, query);
+ update.execute();
+
+ query = "select ?p ?o { GRAPH <http://updated/test> {<http://acme.com/people/Mike> ?p ?o . }}";
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
+ tupleQuery.evaluate(resultHandler);
+ log.info("Result count : " + resultHandler.getCount());
+
+ Validate.isTrue(resultHandler.getCount() == 0);
+ }
+
+
+ private static void testPCJSearch(SailRepositoryConnection conn) throws Exception {
+
+ String queryString;
+ TupleQuery tupleQuery;
+ CountingResultHandler tupleHandler;
+
+ // ///////////// search for bob
+ queryString = "SELECT ?e ?c ?l ?o " //
+ + "{" //
+ + " ?e a ?c . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + "}";//
+
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 1);
+
+ // ///////////// search for bob
+ queryString = "PREFIX fts: <http://rdf.useekm.com/fts#> "//
+ + "SELECT ?e ?c ?l ?o " //
+ + "{" //
+ + " ?c a ?e . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + "}";//
+
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 2);
+
+ }
+
+
+
+
+ private static void testAddAndTemporalSearchWithPCJ(SailRepositoryConnection conn) throws Exception {
+
+ // create some resources and literals to make statements out of
+
+ String sparqlInsert = "PREFIX time: <http://www.w3.org/2006/time#>\n"
+ + "INSERT DATA {\n" //
+ + "_:eventz a time:Instant ;\n"
+ + " time:inXSDDateTime '2001-01-01T01:01:01-08:00' ;\n" // one second
+ + " time:inXSDDateTime '2001-01-01T04:01:02.000-05:00'^^<http://www.w3.org/2001/XMLSchema#dateTime> ;\n" // 2 seconds
+ + " time:inXSDDateTime \"2001-01-01T01:01:03-08:00\" ;\n" // 3 seconds
+ + " time:inXSDDateTime '2001-01-01T01:01:04-08:00' ;\n" // 4 seconds
+ + " time:inXSDDateTime '2001-01-01T09:01:05Z' ;\n"
+ + " time:inXSDDateTime '2006-01-01' ;\n"
+ + " time:inXSDDateTime '2007-01-01' ;\n"
+ + " time:inXSDDateTime '2008-01-01' ; .\n"
+ + "}";
+
+ Update update = conn.prepareUpdate(QueryLanguage.SPARQL, sparqlInsert);
+ update.execute();
+
+ // Find all stored dates.
+ String queryString = "PREFIX time: <http://www.w3.org/2006/time#> \n"//
+ + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n"//
+ + "SELECT ?event ?time \n" //
+ + "WHERE { \n"
+ + " ?event time:inXSDDateTime ?time . \n"//
+ + " FILTER(tempo:after(?time, '2001-01-01T01:01:03-08:00') ) \n"// after 3 seconds
+ + "}";//
+
+
+
+ TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ CountingResultHandler tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 5);
+
+ // Find all stored dates.
+ queryString = "PREFIX time: <http://www.w3.org/2006/time#> \n"//
+ + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n"//
+ + "SELECT ?event ?time \n" //
+ + "WHERE { \n"
+ + " ?event time:inXSDDateTime ?time . \n"//
+ + " ?event a time:Instant . \n"//
+ + " FILTER(tempo:after(?time, '2001-01-01T01:01:03-08:00') ) \n"// after 3 seconds
+ + "}";//
+
+
+
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 5);
+
+
+ // Find all stored dates.
+ queryString = "PREFIX time: <http://www.w3.org/2006/time#> \n"//
+ + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n"//
+ + "SELECT ?event ?time ?e ?c ?l ?o \n" //
+ + "WHERE { \n"
+ + " ?e a ?c . \n"//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . \n"//
+ + " ?e <uri:talksTo> ?o . \n"//
+ + " ?event a time:Instant . \n"//
+ + " ?event time:inXSDDateTime ?time . \n"//
+ + " FILTER(tempo:after(?time, '2001-01-01T01:01:03-08:00') ) \n"// after 3 seconds
+ + "}";//
+
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 5);
+ }
+
+
+
+
+
+
+ private static void testAddAndFreeTextSearchWithPCJ(SailRepositoryConnection conn) throws Exception {
+ // add data to the repository using the SailRepository add methods
+ ValueFactory f = conn.getValueFactory();
+ URI person = f.createURI("http://example.org/ontology/Person");
+
+ String uuid;
+
+ uuid = "urn:people:alice";
+ conn.add(f.createURI(uuid), RDF.TYPE, person);
+ conn.add(f.createURI(uuid), RDFS.LABEL, f.createLiteral("Alice Palace Hose", f.createURI("xsd:string")));
+
+ uuid = "urn:people:bobss";
+ conn.add(f.createURI(uuid), RDF.TYPE, person);
+ conn.add(f.createURI(uuid), RDFS.LABEL, f.createLiteral("Bob Snob Hose", "en"));
+
+ String queryString;
+ TupleQuery tupleQuery;
+ CountingResultHandler tupleHandler;
+
+ // ///////////// search for alice
+ queryString = "PREFIX fts: <http://rdf.useekm.com/fts#> "//
+ + "SELECT ?person ?match ?e ?c ?l ?o " //
+ + "{" //
+ + " ?person <http://www.w3.org/2000/01/rdf-schema#label> ?match . "//
+ + " FILTER(fts:text(?match, \"pal*\")) " //
+ + "}";//
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 1);
+
+
+ // ///////////// search for alice and bob
+ queryString = "PREFIX fts: <http://rdf.useekm.com/fts#> "//
+ + "SELECT ?person ?match " //
+ + "{" //
+ + " ?person <http://www.w3.org/2000/01/rdf-schema#label> ?match . "//
+ + " ?person a <http://example.org/ontology/Person> . "//
+ + " FILTER(fts:text(?match, \"(alice | bob) *SE\")) " //
+ + "}";//
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 2);
+
+ // ///////////// search for alice and bob
+ queryString = "PREFIX fts: <http://rdf.useekm.com/fts#> "//
+ + "SELECT ?person ?match " //
+ + "{" //
+ + " ?person a <http://example.org/ontology/Person> . "//
+ + " ?person <http://www.w3.org/2000/01/rdf-schema#label> ?match . "//
+ + " FILTER(fts:text(?match, \"(alice | bob) *SE\")) " //
+ + " FILTER(fts:text(?match, \"pal*\")) " //
+ + "}";//
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 1);
+
+
+ // ///////////// search for bob
+ queryString = "PREFIX fts: <http://rdf.useekm.com/fts#> "//
+ + "SELECT ?person ?match ?e ?c ?l ?o " //
+ + "{" //
+ + " ?e a ?c . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + " ?person a <http://example.org/ontology/Person> . "//
+ + " ?person <http://www.w3.org/2000/01/rdf-schema#label> ?match . "//
+ + " FILTER(fts:text(?match, \"!alice & hose\")) " //
+ + "}";//
+
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 1);
+ }
+
+
+
+ private static void testAddPointAndWithinSearchWithPCJ(SailRepositoryConnection conn) throws Exception {
+
+ String update = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
+ + "INSERT DATA { " //
+ + " <urn:feature> a geo:Feature ; " //
+ + " geo:hasGeometry [ " //
+ + " a geo:Point ; " //
+ + " geo:asWKT \"Point(-77.03524 38.889468)\"^^geo:wktLiteral "//
+ + " ] . " //
+ + "}";
+
+ Update u = conn.prepareUpdate(QueryLanguage.SPARQL, update);
+ u.execute();
+
+ String queryString;
+ TupleQuery tupleQuery;
+ CountingResultHandler tupleHandler;
+
+ // point outside search ring
+ queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
+ + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
+ + "SELECT ?feature ?point ?wkt " //
+ + "{" //
+ + " ?feature a geo:Feature . "//
+ + " ?feature geo:hasGeometry ?point . "//
+ + " ?point a geo:Point . "//
+ + " ?point geo:asWKT ?wkt . "//
+ + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-77 39, -76 39, -76 38, -77 38, -77 39))\"^^geo:wktLiteral)) " //
+ + "}";//
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 0);
+
+ // point inside search ring
+ queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
+ + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
+ + "SELECT ?feature ?point ?wkt ?e ?l ?o" //
+ + "{" //
+ + " ?feature a ?e . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + " ?feature a geo:Feature . "//
+ + " ?feature geo:hasGeometry ?point . "//
+ + " ?point a geo:Point . "//
+ + " ?point geo:asWKT ?wkt . "//
+ + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " //
+ + "}";//
+
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 1);
+
+
+ // point inside search ring with Pre-Computed Join
+ queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
+ + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
+ + "SELECT ?feature ?point ?wkt ?e ?l ?o" //
+ + "{" //
+ + " ?feature a ?e . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + " ?feature a geo:Feature . "//
+ + " ?feature geo:hasGeometry ?point . "//
+ + " ?point a geo:Point . "//
+ + " ?point geo:asWKT ?wkt . "//
+ + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " //
+ + "}";//
+
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() >= 1); // may see points from during previous runs
+
+ // point outside search ring with PCJ
+ queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
+ + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
+ + "SELECT ?feature ?point ?wkt ?e ?l ?o " //
+ + "{" //
+ + " ?feature a ?e . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + " ?feature a geo:Feature . "//
+ + " ?feature geo:hasGeometry ?point . "//
+ + " ?point a geo:Point . "//
+ + " ?point geo:asWKT ?wkt . "//
+ + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-77 39, -76 39, -76 38, -77 38, -77 39))\"^^geo:wktLiteral)) " //
+ + "}";//
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 0);
+
+ // point inside search ring with different Pre-Computed Join
+ queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
+ + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
+ + "SELECT ?feature ?point ?wkt ?e ?c ?l ?o " //
+ + "{" //
+ + " ?e a ?c . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + " ?feature a geo:Feature . "//
+ + " ?feature geo:hasGeometry ?point . "//
+ + " ?point a geo:Point . "//
+ + " ?point geo:asWKT ?wkt . "//
+ + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " //
+ + "}";//
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 1);
+ }
+
+
+ private static void testTemporalFreeGeoSearch(SailRepositoryConnection conn) throws MalformedQueryException,
+ RepositoryException, UpdateExecutionException, TupleQueryResultHandlerException, QueryEvaluationException {
+
+
+ String queryString;
+ TupleQuery tupleQuery;
+ CountingResultHandler tupleHandler;
+
+ // ring containing point
+ queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
+ + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
+ + "PREFIX time: <http://www.w3.org/2006/time#> "//
+ + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> "//
+ + "PREFIX fts: <http://rdf.useekm.com/fts#> "//
+ + "SELECT ?feature ?point ?wkt ?event ?time ?person ?match" //
+ + "{" //
+ + " ?event a time:Instant . \n"//
+ + " ?event time:inXSDDateTime ?time . \n"//
+ + " FILTER(tempo:after(?time, '2001-01-01T01:01:03-08:00') ) \n"// after 3 seconds
+ + " ?feature a geo:Feature . "//
+ + " ?feature geo:hasGeometry ?point . "//
+ + " ?point a geo:Point . "//
+ + " ?point geo:asWKT ?wkt . "//
+ + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)). " //
+ + " ?person a <http://example.org/ontology/Person> . "//
+ + " ?person <http://www.w3.org/2000/01/rdf-schema#label> ?match . "//
+ + " FILTER(fts:text(?match, \"pal*\")) " //
+ + "}";//
+
+
+
+ tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+
+ tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 5);
+
+ }
+
+
+
+ private static void testGeoFreetextWithPCJSearch(SailRepositoryConnection conn) throws MalformedQueryException,
+ RepositoryException, TupleQueryResultHandlerException, QueryEvaluationException {
+ // ring outside point
+ String queryString = "PREFIX geo: <http://www.opengis.net/ont/geosparql#> "//
+ + "PREFIX fts: <http://rdf.useekm.com/fts#> "//
+ + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> "//
+ + "SELECT ?feature ?point ?wkt ?e ?c ?l ?o ?person ?match " //
+ + "{" //
+ + " ?person a <http://example.org/ontology/Person> . "//
+ + " ?person <http://www.w3.org/2000/01/rdf-schema#label> ?match . "//
+ + " FILTER(fts:text(?match, \"!alice & hose\")) " //
+ + " ?e a ?c . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + " ?feature a geo:Feature . "//
+ + " ?feature geo:hasGeometry ?point . "//
+ + " ?point a geo:Point . "//
+ + " ?point geo:asWKT ?wkt . "//
+ + " FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -77 39, -77 38, -78 38, -78 39))\"^^geo:wktLiteral)) " //
+ + "}";//
+ TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+ CountingResultHandler tupleHandler = new CountingResultHandler();
+ tupleQuery.evaluate(tupleHandler);
+ log.info("Result count : " + tupleHandler.getCount());
+ Validate.isTrue(tupleHandler.getCount() == 1);
+ }
+
+
+
+ private static void createPCJ(SailRepositoryConnection conn)
+ throws RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException {
+
+ String queryString1 = ""//
+ + "SELECT ?e ?c ?l ?o " //
+ + "{" //
+ + " ?c a ?e . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + "}";//
+
+ String queryString2 = ""//
+ + "SELECT ?e ?c ?l ?o " //
+ + "{" //
+ + " ?e a ?c . "//
+ + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
+ + " ?e <uri:talksTo> ?o . "//
+ + "}";//
+
+
+ URI obj,subclass,talksTo;
+ URI person = new URIImpl("urn:people:alice");
+ URI feature = new URIImpl("urn:feature");
+ URI sub = new URIImpl("uri:entity");
+ subclass = new URIImpl("uri:class");
+ obj = new URIImpl("uri:obj");
+ talksTo = new URIImpl("uri:talksTo");
+
+ conn.add(person, RDF.TYPE, sub);
+ conn.add(feature, RDF.TYPE, sub);
+ conn.add(sub, RDF.TYPE, subclass);
+ conn.add(sub, RDFS.LABEL, new LiteralImpl("label"));
+ conn.add(sub, talksTo, obj);
+
+ AccumuloIndexSet ais1 = null;
+ AccumuloIndexSet ais2 = null;
+ String tablename1 = RYA_TABLE_PREFIX + "INDEX_1";
+ String tablename2 = RYA_TABLE_PREFIX + "INDEX_2";
+
+ Connector accCon = new MockInstance(INSTANCE).getConnector("root", new PasswordToken("".getBytes()));
+ accCon.tableOperations().create(tablename1);
+ accCon.tableOperations().create(tablename2);
+
+ try {
+ ais1 = new AccumuloIndexSet(queryString1, conn, accCon, tablename1);
+ ais2 = new AccumuloIndexSet(queryString2, conn, accCon, tablename2);
+ } catch (MalformedQueryException e) {
+ e.printStackTrace();
+ } catch (SailException e) {
+ e.printStackTrace();
+ } catch (QueryEvaluationException e) {
+ e.printStackTrace();
+ } catch (MutationsRejectedException e) {
+ e.printStackTrace();
+ } catch (TableNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ private static class CountingResultHandler implements TupleQueryResultHandler {
+ private int count = 0;
+
+ public int getCount() {
+ return count;
+ }
+
+ public void resetCount() {
+ this.count = 0;
+ }
+
+ @Override
+ public void startQueryResult(List<String> arg0) throws TupleQueryResultHandlerException {
+ }
+
+ @Override
+ public void handleSolution(BindingSet arg0) throws TupleQueryResultHandlerException {
+ count++;
+ System.out.println(arg0);
+ }
+
+ @Override
+ public void endQueryResult() throws TupleQueryResultHandlerException {
+ }
+
+ @Override
+ public void handleBoolean(boolean arg0) throws QueryResultHandlerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void handleLinks(List<String> arg0) throws QueryResultHandlerException {
+ // TODO Auto-generated method stub
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/indexingSailExample/src/main/scripts/RunRyaDirectExample.bat
----------------------------------------------------------------------
diff --git a/extras/indexingSailExample/src/main/scripts/RunRyaDirectExample.bat b/extras/indexingSailExample/src/main/scripts/RunRyaDirectExample.bat
new file mode 100644
index 0000000..3a75f71
--- /dev/null
+++ b/extras/indexingSailExample/src/main/scripts/RunRyaDirectExample.bat
@@ -0,0 +1,25 @@
+@echo off
+SET CP=
+
+REM Check to see if javac is on the path
+where /Q javac
+IF %ERRORLEVEL% NEQ 0 goto :NO_JAVAC
+
+
+for /f %%f in ('DIR /b .\lib\*.jar') do call :append .\lib\%%f
+
+javac -cp "%CP%" RyaDirectExample.java
+java -cp "%CP%" RyaDirectExample
+
+goto :end
+
+:append
+@echo off
+SET CP=%CP%%1;
+goto :end
+
+:NO_JAVAC
+echo ERROR: Could not find javac
+goto :end
+
+:end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/pom.xml
----------------------------------------------------------------------
diff --git a/extras/pom.xml b/extras/pom.xml
new file mode 100644
index 0000000..eb7f652
--- /dev/null
+++ b/extras/pom.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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>
+ <parent>
+ <groupId>mvm.rya</groupId>
+ <artifactId>parent</artifactId>
+ <version>3.2.9</version>
+ </parent>
+ <artifactId>rya.extras</artifactId>
+ <packaging>pom</packaging>
+ <name>${project.groupId}.${project.artifactId}</name>
+ <modules>
+ <module>rya.prospector</module>
+ <module>rya.manual</module>
+ <module>tinkerpop.rya</module>
+ </modules>
+ <profiles>
+ <profile>
+ <id>indexing</id>
+ <modules>
+ <module>indexing</module>
+ <module>indexingSailExample</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.console/.gitignore
----------------------------------------------------------------------
diff --git a/extras/rya.console/.gitignore b/extras/rya.console/.gitignore
new file mode 100644
index 0000000..5d1172a
--- /dev/null
+++ b/extras/rya.console/.gitignore
@@ -0,0 +1,8 @@
+/.classpath
+/.project
+.settings/
+target/
+/log.roo
+*.log
+
+/bin/
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.console/pom.xml
----------------------------------------------------------------------
diff --git a/extras/rya.console/pom.xml b/extras/rya.console/pom.xml
new file mode 100644
index 0000000..adb4997
--- /dev/null
+++ b/extras/rya.console/pom.xml
@@ -0,0 +1,146 @@
+<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>
+
+ <parent>
+ <groupId>mvm.rya</groupId>
+ <artifactId>rya.extras</artifactId>
+ <version>3.2.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>rya.console</artifactId>
+ <packaging>jar</packaging>
+
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <spring.shell.version>1.0.0.M1</spring.shell.version>
+ <jar.mainclass>org.springframework.shell.Bootstrap</jar.mainclass>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>mvm.rya</groupId>
+ <artifactId>rya.api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>mvm.rya</groupId>
+ <artifactId>accumulo.rya</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.shell</groupId>
+ <artifactId>spring-shell</artifactId>
+ <version>${spring.shell.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <!--<useUniqueVersions>false</useUniqueVersions>-->
+ <classpathPrefix>lib/</classpathPrefix>
+ <mainClass>${jar.mainclass}</mainClass>
+ </manifest>
+ <manifestEntries>
+ <version>${project.version}</version>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <profiles>
+ <profile>
+ <id>accumulo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.accumulo</groupId>
+ <artifactId>accumulo-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>mvm.rya</groupId>
+ <artifactId>accumulo.iterators</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>cloudbase</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.texeltek</groupId>
+ <artifactId>accumulo-cloudbase-shim</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>mvm.rya</groupId>
+ <artifactId>cloudbase.iterators</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ </profiles>
+
+ <repositories>
+ <!-- jline 1.0.S2-B is here http://shrub.appspot.com/spring-roo-repository.springsource.org/release/net/sourceforge/jline/jline/1.0.S2-B/ -->
+ <repository>
+ <id>spring-roo-repository</id>
+ <name>Spring Roo Maven Repository</name>
+ <url>http://spring-roo-repository.springsource.org/release</url>
+ </repository>
+
+ <repository>
+ <id>spring-maven-snapshot</id>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <name>Springframework Maven SNAPSHOT Repository</name>
+ <url>http://repo.springsource.org/libs-snapshot</url>
+ </repository>
+ </repositories>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.console/src/main/java/mvm/rya/console/RyaBannerProvider.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/mvm/rya/console/RyaBannerProvider.java b/extras/rya.console/src/main/java/mvm/rya/console/RyaBannerProvider.java
new file mode 100644
index 0000000..23c028c
--- /dev/null
+++ b/extras/rya.console/src/main/java/mvm/rya/console/RyaBannerProvider.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package mvm.rya.console;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.shell.support.util.StringUtils;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.plugin.support.DefaultBannerProvider;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Jarred Li
+ */
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class RyaBannerProvider extends DefaultBannerProvider
+ implements CommandMarker {
+
+ @CliCommand(value = {"version"}, help = "Displays current CLI version")
+ public String getBanner() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("" +
+ "________ _________ ______ \n" +
+ "___ __ \\____ _______ _ __ ____/____________________________ /____ \n" +
+ "__ /_/ /_ / / / __ `/ _ / _ __ \\_ __ \\_ ___/ __ \\_ /_ _ \\\n" +
+ "_ _, _/_ /_/ // /_/ / / /___ / /_/ / / / /(__ )/ /_/ / / / __/\n" +
+ "/_/ |_| _\\__, / \\__,_/ \\____/ \\____//_/ /_//____/ \\____//_/ \\___/ \n" +
+ " /____/ " + StringUtils.LINE_SEPARATOR);
+ buf.append("Version:" + this.getVersion());
+ return buf.toString();
+
+ }
+
+ public String getVersion() {
+ return "3.0.0";
+ }
+
+ public String getWelcomeMessage() {
+ return "Welcome to the Rya Console";
+ }
+
+ @Override
+ public String name() {
+ return "rya";
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.console/src/main/java/mvm/rya/console/RyaConsoleCommands.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/mvm/rya/console/RyaConsoleCommands.java b/extras/rya.console/src/main/java/mvm/rya/console/RyaConsoleCommands.java
new file mode 100644
index 0000000..2882b21
--- /dev/null
+++ b/extras/rya.console/src/main/java/mvm/rya/console/RyaConsoleCommands.java
@@ -0,0 +1,211 @@
+package mvm.rya.console;
+
+
+import info.aduna.iteration.CloseableIteration;
+
+import java.io.FileInputStream;
+import java.io.StringReader;
+import java.util.Formatter;
+import java.util.Locale;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import mvm.rya.accumulo.AccumuloRdfConfiguration;
+import mvm.rya.accumulo.AccumuloRyaDAO;
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaURI;
+import mvm.rya.api.persist.RyaDAO;
+import mvm.rya.api.persist.RyaDAOException;
+import mvm.rya.api.persist.query.RyaQueryEngine;
+import mvm.rya.api.resolver.RdfToRyaConversions;
+import mvm.rya.api.resolver.RyaContext;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.ZooKeeperInstance;
+import org.apache.accumulo.core.client.mock.MockInstance;
+import org.openrdf.model.Statement;
+import org.openrdf.rio.RDFHandler;
+import org.openrdf.rio.RDFHandlerException;
+import org.openrdf.rio.RDFParser;
+import org.openrdf.rio.ntriples.NTriplesParserFactory;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RyaConsoleCommands implements CommandMarker {
+
+ private static final NTriplesParserFactory N_TRIPLES_PARSER_FACTORY = new NTriplesParserFactory();
+
+ protected final Logger LOG = Logger.getLogger(getClass().getName());
+
+ private RyaContext ryaContext = RyaContext.getInstance();
+ private RyaDAO ryaDAO;
+ private RDFParser ntrips_parser = null;
+
+ public RyaConsoleCommands() {
+ ntrips_parser = N_TRIPLES_PARSER_FACTORY.getParser();
+ ntrips_parser.setRDFHandler(new RDFHandler() {
+
+ public void startRDF() throws RDFHandlerException {
+
+ }
+
+ public void endRDF() throws RDFHandlerException {
+
+ }
+
+ public void handleNamespace(String s, String s1) throws RDFHandlerException {
+
+ }
+
+ public void handleStatement(Statement statement) throws RDFHandlerException {
+ try {
+ RyaStatement ryaStatement = RdfToRyaConversions.convertStatement(statement);
+ ryaDAO.add(ryaStatement);
+ } catch (Exception e) {
+ throw new RDFHandlerException(e);
+ }
+ }
+
+ public void handleComment(String s) throws RDFHandlerException {
+
+ }
+ });
+ }
+
+ /**
+ * commands:
+ * 1. connect(instance, user, password, zk)
+ * 1.a. disconnect
+ * 2. query
+ * 3. add
+ */
+
+ @CliAvailabilityIndicator({"connect"})
+ public boolean isConnectAvailable() {
+ return true;
+ }
+
+ @CliAvailabilityIndicator({"qt", "add", "load", "disconnect"})
+ public boolean isCommandAvailable() {
+ return ryaDAO != null;
+ }
+
+ @CliCommand(value = "qt", help = "Query with Triple Pattern")
+ public String queryTriple(
+ @CliOption(key = {"subject"}, mandatory = false, help = "Subject") final String subject,
+ @CliOption(key = {"predicate"}, mandatory = false, help = "Predicate") final String predicate,
+ @CliOption(key = {"object"}, mandatory = false, help = "Object") final String object,
+ @CliOption(key = {"context"}, mandatory = false, help = "Context") final String context,
+ @CliOption(key = {"maxResults"}, mandatory = false, help = "Maximum Number of Results", unspecifiedDefaultValue = "100") final String maxResults
+ ) {
+ try {
+ RdfCloudTripleStoreConfiguration conf = ryaDAO.getConf().clone();
+ if (maxResults != null) {
+ conf.setLimit(Long.parseLong(maxResults));
+ }
+ RyaQueryEngine queryEngine = ryaDAO.getQueryEngine();
+ CloseableIteration<RyaStatement, RyaDAOException> query =
+ queryEngine.query(new RyaStatement(
+ (subject != null) ? (new RyaURI(subject)) : null,
+ (predicate != null) ? (new RyaURI(predicate)) : null,
+ (object != null) ? (new RyaURI(object)) : null,
+ (context != null) ? (new RyaURI(context)) : null), conf);
+ StringBuilder sb = new StringBuilder();
+ Formatter formatter = new Formatter(sb, Locale.US);
+ String format = "%-40s %-40s %-40s %-40s\n";
+ formatter.format(format, "Subject", "Predicate",
+ "Object", "Context");
+ while (query.hasNext()) {
+ RyaStatement next = query.next();
+ formatter.format(format, next.getSubject().getData(), next.getPredicate().getData(),
+ next.getObject().getData(), (next.getContext() != null) ? (next.getContext().getData()) : (null));
+ sb.append("\n");
+ }
+ return sb.toString();
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "", e);
+ }
+ return "";
+ }
+
+ @CliCommand(value = "load", help = "Load file")
+ public void load(
+ @CliOption(key = {"", "file"}, mandatory = true, help = "File of ntriples rdf to load") final String file
+ ) {
+ //diff formats?
+ //diff types of urls
+ try {
+ ntrips_parser.parse(new FileInputStream(file), "");
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "", e);
+ }
+ }
+
+ @CliCommand(value = "add", help = "Add Statement")
+ public void add(
+ @CliOption(key = {"", "statement"}, mandatory = true, help = "Statement in NTriples format") final String statement) {
+ try {
+ ntrips_parser.parse(new StringReader(statement), "");
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "", e);
+ }
+ }
+
+ @CliCommand(value = "connect", help = "Connect to Rya Triple Store")
+ public String connect(
+ @CliOption(key = {"instance"}, mandatory = true, help = "Accumulo Instance") final String instance,
+ @CliOption(key = {"user"}, mandatory = true, help = "Accumulo User") final String user,
+ @CliOption(key = {"pwd"}, mandatory = true, help = "Accumulo Pwd") final String pwd,
+ @CliOption(key = {"zk"}, mandatory = true, help = "Accumulo Zk (zk=mock for the mock instance)") final String zk,
+ @CliOption(key = {"pre"}, mandatory = false, help = "Accumulo table prefix", unspecifiedDefaultValue = "rya_") final String pre) {
+ try {
+ //using Cloudbase
+ Connector connector = null;
+ AccumuloRyaDAO cryaDao = new AccumuloRyaDAO();
+ if ("mock".equals(zk)) {
+ //mock instance
+ connector = new MockInstance(instance).getConnector(user, pwd);
+ } else {
+ connector = new ZooKeeperInstance(instance, zk).getConnector(user, pwd);
+ }
+
+ cryaDao.setConnector(connector);
+ AccumuloRdfConfiguration configuration = new AccumuloRdfConfiguration();
+ configuration.setTablePrefix(pre);
+ cryaDao.setConf(configuration);
+ cryaDao.init();
+ this.ryaDAO = cryaDao;
+ return "Connected to Accumulo";
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "", e);
+ }
+ return "";
+ }
+
+ @CliCommand(value = "disconnect", help = "Disconnect from Rya Store")
+ public String disconnect() {
+ if (ryaDAO == null) {
+ return "Command is not available because Rya is not connected. Please 'connect' first.";
+ }
+ try {
+ this.ryaDAO.destroy();
+ this.ryaDAO = null;
+ } catch (RyaDAOException e) {
+ LOG.log(Level.SEVERE, "", e);
+ }
+ return "";
+ }
+
+ public RyaDAO getRyaDAO() {
+ return ryaDAO;
+ }
+
+ public void setRyaDAO(RyaDAO ryaDAO) {
+ this.ryaDAO = ryaDAO;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.console/src/main/java/mvm/rya/console/RyaHistoryFileNameProvider.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/mvm/rya/console/RyaHistoryFileNameProvider.java b/extras/rya.console/src/main/java/mvm/rya/console/RyaHistoryFileNameProvider.java
new file mode 100644
index 0000000..e09bda6
--- /dev/null
+++ b/extras/rya.console/src/main/java/mvm/rya/console/RyaHistoryFileNameProvider.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+package mvm.rya.console;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.shell.plugin.support.DefaultHistoryFileNameProvider;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * @author Jarred Li
+ *
+ */
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class RyaHistoryFileNameProvider extends DefaultHistoryFileNameProvider{
+
+ public String getHistoryFileName() {
+ return "ryaconsole.log";
+ }
+
+ @Override
+ public String name() {
+ return "Rya Console History Log";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.console/src/main/java/mvm/rya/console/RyaPromptProvider.java
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/java/mvm/rya/console/RyaPromptProvider.java b/extras/rya.console/src/main/java/mvm/rya/console/RyaPromptProvider.java
new file mode 100644
index 0000000..90c9199
--- /dev/null
+++ b/extras/rya.console/src/main/java/mvm/rya/console/RyaPromptProvider.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011-2012 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package mvm.rya.console;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.shell.plugin.support.DefaultPromptProvider;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Jarred Li
+ *
+ */
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class RyaPromptProvider extends DefaultPromptProvider {
+
+ @Override
+ public String getPrompt() {
+ return "rya>";
+ }
+
+
+ @Override
+ public String name() {
+ return "Rya Console Prompt";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.console/src/main/resources/META-INF/spring/spring-shell-plugin.xml
----------------------------------------------------------------------
diff --git a/extras/rya.console/src/main/resources/META-INF/spring/spring-shell-plugin.xml b/extras/rya.console/src/main/resources/META-INF/spring/spring-shell-plugin.xml
new file mode 100644
index 0000000..d21543d
--- /dev/null
+++ b/extras/rya.console/src/main/resources/META-INF/spring/spring-shell-plugin.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
+
+ <context:component-scan base-package="mvm.rya.console" />
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/pom.xml
----------------------------------------------------------------------
diff --git a/extras/rya.geo/pom.xml b/extras/rya.geo/pom.xml
new file mode 100644
index 0000000..8b36e7d
--- /dev/null
+++ b/extras/rya.geo/pom.xml
@@ -0,0 +1,25 @@
+<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>
+
+ <parent>
+ <groupId>mvm.rya</groupId>
+ <artifactId>rya.extras</artifactId>
+ <version>3.2.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>rya.geo</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>mvm.rya</groupId>
+ <artifactId>rya.api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-queryalgebra-evaluation</artifactId>
+ <version>${openrdf.sesame.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/main/java/mvm/rya/geo/GeoDistance.java
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/main/java/mvm/rya/geo/GeoDistance.java b/extras/rya.geo/src/main/java/mvm/rya/geo/GeoDistance.java
new file mode 100644
index 0000000..277d7f6
--- /dev/null
+++ b/extras/rya.geo/src/main/java/mvm/rya/geo/GeoDistance.java
@@ -0,0 +1,34 @@
+package mvm.rya.geo;
+
+/**
+ * Distance functions for geographic points
+ */
+public class GeoDistance
+{
+ private static final double EARTH_RADIUS_KM = 6366.0;
+ private static final double DEG2RAD = Math.PI / 180;
+
+ /**
+ * Calculates distance between two geographic points in km
+ *
+ * @param lat1
+ * @param lon1
+ * @param lat2
+ * @param lon2
+ * @return distance in kilometers
+ */
+ public static double calculate(double lat1, double lon1, double lat2, double lon2)
+ {
+ double a1 = lat1 * DEG2RAD;
+ double a2 = lon1 * DEG2RAD;
+ double b1 = lat2 * DEG2RAD;
+ double b2 = lon2 * DEG2RAD;
+
+ double t1 = Math.cos(a1) * Math.cos(a2) * Math.cos(b1) * Math.cos(b2);
+ double t2 = Math.cos(a1) * Math.sin(a2) * Math.cos(b1) * Math.sin(b2);
+ double t3 = Math.sin(a1) * Math.sin(b1);
+ double tt = Math.acos(t1 + t2 + t3);
+
+ return EARTH_RADIUS_KM * tt;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/main/java/mvm/rya/geo/GeoRyaTypeResolver.java
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/main/java/mvm/rya/geo/GeoRyaTypeResolver.java b/extras/rya.geo/src/main/java/mvm/rya/geo/GeoRyaTypeResolver.java
new file mode 100644
index 0000000..1d31c0b
--- /dev/null
+++ b/extras/rya.geo/src/main/java/mvm/rya/geo/GeoRyaTypeResolver.java
@@ -0,0 +1,16 @@
+package mvm.rya.geo;
+
+import mvm.rya.api.resolver.impl.RyaTypeResolverImpl;
+
+/**
+ * Type resolver for rya geo location type
+ */
+public class GeoRyaTypeResolver extends RyaTypeResolverImpl
+{
+ public static final int GEO_LITERAL_MARKER = 11;
+
+ public GeoRyaTypeResolver()
+ {
+ super((byte) GEO_LITERAL_MARKER, RyaGeoSchema.GEOPOINT);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/main/java/mvm/rya/geo/RyaGeoSchema.java
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/main/java/mvm/rya/geo/RyaGeoSchema.java b/extras/rya.geo/src/main/java/mvm/rya/geo/RyaGeoSchema.java
new file mode 100644
index 0000000..06befc2
--- /dev/null
+++ b/extras/rya.geo/src/main/java/mvm/rya/geo/RyaGeoSchema.java
@@ -0,0 +1,16 @@
+package mvm.rya.geo;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+
+/**
+ * Rya GEO RDF Constants
+ */
+public class RyaGeoSchema
+{
+ private static final ValueFactory VF = ValueFactoryImpl.getInstance();
+
+ public static final URI NAMESPACE = VF.createURI("urn:mvm.rya/geo#");
+ public static final URI GEOPOINT = VF.createURI(NAMESPACE.toString(), "geopoint");
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/main/java/mvm/rya/geo/Verify.java
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/main/java/mvm/rya/geo/Verify.java b/extras/rya.geo/src/main/java/mvm/rya/geo/Verify.java
new file mode 100644
index 0000000..752793e
--- /dev/null
+++ b/extras/rya.geo/src/main/java/mvm/rya/geo/Verify.java
@@ -0,0 +1,68 @@
+package mvm.rya.geo;
+
+import org.openrdf.model.Literal;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+
+/**
+ * Utility for verifying function arguments
+ */
+public class Verify
+{
+ private final Value[] args;
+
+ /**
+ * Entry point for creating a Verify
+ *
+ * @param args
+ * @return verify
+ */
+ public static Verify that(Value... args)
+ {
+ return new Verify(args);
+ }
+
+ private Verify(Value... args)
+ {
+ this.args = args;
+ }
+
+ /**
+ * verifies the number of arguments
+ *
+ * @param numArgs
+ * @throws ValueExprEvaluationException
+ */
+ public void hasLength(int numArgs) throws ValueExprEvaluationException
+ {
+ if (args.length != numArgs)
+ {
+ throw new ValueExprEvaluationException("expected " + numArgs + " but received " + args.length);
+ }
+ }
+
+ /**
+ * verifies the arguments are of the specified type
+ *
+ * @param type
+ * @throws ValueExprEvaluationException
+ */
+ public void isLiteralOfType(URI type) throws ValueExprEvaluationException
+ {
+ for (Value arg : args)
+ {
+ if (!(arg instanceof Literal))
+ {
+ throw new ValueExprEvaluationException(arg + " is not a literal");
+ }
+
+ Literal l = (Literal) arg;
+
+ if (!type.equals(l.getDatatype()))
+ {
+ throw new ValueExprEvaluationException("expected type " + type + " but received " + l.getDatatype());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/main/java/mvm/rya/geo/WithinRange.java
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/main/java/mvm/rya/geo/WithinRange.java b/extras/rya.geo/src/main/java/mvm/rya/geo/WithinRange.java
new file mode 100644
index 0000000..55bce4a
--- /dev/null
+++ b/extras/rya.geo/src/main/java/mvm/rya/geo/WithinRange.java
@@ -0,0 +1,69 @@
+package mvm.rya.geo;
+
+import java.util.Arrays;
+
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.Function;
+
+/**
+ * Custom function for check a lat/lon is ithin a certain range of another
+ *
+ * Example SPARQL Usage:
+ *
+ * <pre>
+ * # Give me all cities that are within 50 km of lat/lon 20.00,-30.00
+ *
+ * PREFIX geo: <urn:mvm.rya/geo#>
+ * SELECT ?city
+ * WHERE
+ * {
+ * ?city geo:locatedAt ?latLon .
+ * FILTER( geo:withinRange(?latLon, "20.00,-30.00"^^geo:geopoint, 50 )
+ * }
+ * </pre>
+ */
+public class WithinRange implements Function
+{
+ private static final String FUN_NAME = "withinRange";
+
+ @Override
+ public Value evaluate(ValueFactory vf, Value... args) throws ValueExprEvaluationException
+ {
+ System.out.println("running with args: " + Arrays.toString(args));
+
+ Verify.that(args).hasLength(3);
+ Verify.that(args[0], args[1]).isLiteralOfType(RyaGeoSchema.GEOPOINT);
+
+ GeoPoint testPt = new GeoPoint(args[0]);
+ GeoPoint targetPt = new GeoPoint(args[1]);
+ double radius = Double.parseDouble(args[2].stringValue());
+
+ double dist = GeoDistance.calculate(testPt.lat, testPt.lon, targetPt.lat, targetPt.lon);
+
+ System.out.println("distance from (" + testPt.lat + "," + testPt.lon + ") to (" + targetPt.lat + "," + targetPt.lon
+ + ") is " + dist);
+
+ return vf.createLiteral(dist <= radius);
+ }
+
+ @Override
+ public String getURI()
+ {
+ return RyaGeoSchema.NAMESPACE.toString() + FUN_NAME;
+ }
+
+ private class GeoPoint
+ {
+ public double lat;
+ public double lon;
+
+ public GeoPoint(Value val)
+ {
+ String[] tokens = val.stringValue().split(",");
+ lat = Double.parseDouble(tokens[0]);
+ lon = Double.parseDouble(tokens[1]);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/main/resources/META-INF/services/mvm.rya.api.resolver.RyaTypeResolver
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/main/resources/META-INF/services/mvm.rya.api.resolver.RyaTypeResolver b/extras/rya.geo/src/main/resources/META-INF/services/mvm.rya.api.resolver.RyaTypeResolver
new file mode 100644
index 0000000..028b525
--- /dev/null
+++ b/extras/rya.geo/src/main/resources/META-INF/services/mvm.rya.api.resolver.RyaTypeResolver
@@ -0,0 +1 @@
+mvm.rya.geo.GeoRyaTypeResolver
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function b/extras/rya.geo/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
new file mode 100644
index 0000000..5f853fe
--- /dev/null
+++ b/extras/rya.geo/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
@@ -0,0 +1 @@
+mvm.rya.geo.WithinRange
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/test/java/mvm/rya/geo/GeoRyaTypeResolverTest.java
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/test/java/mvm/rya/geo/GeoRyaTypeResolverTest.java b/extras/rya.geo/src/test/java/mvm/rya/geo/GeoRyaTypeResolverTest.java
new file mode 100644
index 0000000..c3284c7
--- /dev/null
+++ b/extras/rya.geo/src/test/java/mvm/rya/geo/GeoRyaTypeResolverTest.java
@@ -0,0 +1,25 @@
+package mvm.rya.geo;
+
+import mvm.rya.api.domain.RyaType;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class GeoRyaTypeResolverTest
+{
+ private final GeoRyaTypeResolver resolver = new GeoRyaTypeResolver();
+
+ @Test
+ public void testSerialization_andBack() throws Exception
+ {
+ String latLon = "20.00,30.00";
+ RyaType orig = new RyaType(RyaGeoSchema.GEOPOINT, latLon);
+
+ byte[] bytes = resolver.serialize(orig);
+ RyaType copy = resolver.deserialize(bytes);
+
+ Assert.assertEquals(latLon, copy.getData());
+ Assert.assertEquals(orig, copy);
+ Assert.assertEquals(RyaGeoSchema.GEOPOINT, copy.getDataType());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.geo/src/test/java/mvm/rya/geo/WithinRangeTest.java
----------------------------------------------------------------------
diff --git a/extras/rya.geo/src/test/java/mvm/rya/geo/WithinRangeTest.java b/extras/rya.geo/src/test/java/mvm/rya/geo/WithinRangeTest.java
new file mode 100644
index 0000000..2e1c2a7
--- /dev/null
+++ b/extras/rya.geo/src/test/java/mvm/rya/geo/WithinRangeTest.java
@@ -0,0 +1,43 @@
+package mvm.rya.geo;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+
+public class WithinRangeTest
+{
+ private static final double MI2KM = 1.60934;
+
+ private static final ValueFactory VF = ValueFactoryImpl.getInstance();
+ private static final Value TRUE = VF.createLiteral(true);
+ private static final Value FALSE = VF.createLiteral(false);
+
+ // Distance between Washington, DC and Atlanta is roughly 600 miles
+ private static final Value WASHINGTON_DC = VF.createLiteral("40.15999984741211,-80.25", RyaGeoSchema.GEOPOINT);
+ private static final Value ATLANTA = VF.createLiteral("33.75,-84.383", RyaGeoSchema.GEOPOINT);
+
+ private WithinRange fun = new WithinRange();
+
+ @Test
+ public void testWithinRange() throws ValueExprEvaluationException
+ {
+ double miles = 900;
+ Value distance = VF.createLiteral(miles * MI2KM);
+
+ Assert.assertEquals(TRUE, fun.evaluate(VF, ATLANTA, WASHINGTON_DC, distance));
+ Assert.assertEquals(TRUE, fun.evaluate(VF, WASHINGTON_DC, WASHINGTON_DC, distance));
+ }
+
+ @Test
+ public void testWithinRange_notWithinRange() throws ValueExprEvaluationException
+ {
+ double miles = 200;
+ Value distance = VF.createLiteral(miles * MI2KM);
+
+ Assert.assertEquals(FALSE, fun.evaluate(VF, ATLANTA, WASHINGTON_DC, distance));
+ Assert.assertEquals(TRUE, fun.evaluate(VF, WASHINGTON_DC, WASHINGTON_DC, distance));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.manual/pom.xml
----------------------------------------------------------------------
diff --git a/extras/rya.manual/pom.xml b/extras/rya.manual/pom.xml
new file mode 100644
index 0000000..1a6307b
--- /dev/null
+++ b/extras/rya.manual/pom.xml
@@ -0,0 +1,294 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>mvm.rya</groupId>
+ <artifactId>rya.extras</artifactId>
+ <version>3.2.9</version>
+ </parent>
+
+ <artifactId>rya.manual</artifactId>
+ <name>RYA Manual</name>
+ <packaging>war</packaging>
+
+ <properties>
+ <must-succeed>false</must-succeed>
+ <manual.dir>${project.build.directory}/${project.artifactId}</manual.dir>
+ <manual>${manual.dir}/${project.artifactId}-${project.version}</manual>
+ <netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server>
+ <jetty-port>8080</jetty-port>
+ <jetty-war-dir>${project.build.directory}/webapp/</jetty-war-dir>
+ <scalate.version>1.7.1</scalate.version>
+ <scala.version>2.11.1</scala.version>
+ <wikitext.version>1.3</wikitext.version>
+ <scalate.editor>${env.SCALATE_EDITOR}</scalate.editor>
+ <scalate.mode>production</scalate.mode>
+ <scalate.workdir>${project.build.directory}/scalateWorkDir</scalate.workdir>
+ <maven.wagon.version>1.0-beta-6</maven.wagon.version>
+ <remoteTomcatManager>http://10.40.190.248:8080/manager</remoteTomcatManager>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.scalatra.scalate</groupId>
+ <artifactId>scalate-wikitext_2.11</artifactId>
+ <version>${scalate.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>0.9.24</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>${scala.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-compiler</artifactId>
+ <version>${scala.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/webapp</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/webapp</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/webapp</source>
+ </sources>
+ </configuration>
+ </execution>
+ <!--execution>
+ <id>attach-artifacts</id>
+ <phase>install</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${manual}.html</file>
+ <type>html</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution-->
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.scalatra.scalate</groupId>
+ <artifactId>maven-scalate-plugin_2.11</artifactId>
+ <version>${scalate.version}</version>
+ <executions>
+ <execution>
+ <id>generate-htmls</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>sitegen</goal>
+ </goals>
+ <configuration>
+ <webappDirectory>${project.build.directory}/webapp</webappDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <target>${basedir}/src/main/webapp</target>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh</artifactId>
+ <version>${maven.wagon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.fusesource.wikitext</groupId>
+ <artifactId>confluence-core</artifactId>
+ <version>${wikitext.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webResources>
+ <resource>
+ <directory>${project.build.directory}/webapp/</directory>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <version>1.1</version>
+ <configuration>
+ <url>${remoteTomcatManager}</url>
+ </configuration>
+ <!--executions>
+ <execution>
+ <id>redeploy-war</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>redeploy</goal>
+ </goals>
+ </execution>
+ </executions-->
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>7.1.5.v20100705</version>
+ <configuration>
+ <!--webAppConfig>
+ <contextPath>${project.artifactId}</contextPath>
+ </webAppConfig-->
+ <!-- When editing the conf files, you can comment this line to run
+ mvn jetty:run
+ to have a live web site
+ -->
+ <webAppSourceDirectory>${jetty-war-dir}</webAppSourceDirectory>
+
+ <systemProperties>
+ <systemProperty>
+ <name>scalate.editor</name>
+ <value>${scalate.editor}</value>
+ </systemProperty>
+ <systemProperty>
+ <name>scalate.workdir</name>
+ <value>${scalate.workdir}</value>
+ </systemProperty>
+ <systemProperty>
+ <name>scalate.mode</name>
+ <value>${scalate.mode}</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.scalatra.scalate</groupId>
+ <artifactId>maven-scalate-plugin</artifactId>
+ <version>${scalate.version}</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <profiles>
+ <profile>
+ <id>live</id>
+ <properties>
+ <jetty-war-dir>${basedir}/src/main/webapp/</jetty-war-dir>
+ <scalate.mode>development</scalate.mode>
+ </properties>
+ </profile>
+ <profile>
+ <id>pdf-manual</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-manual</id>
+ <phase>install</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <mkdir dir="${manual.dir}" />
+ <move file="${project.build.directory}/sitegen/manual.html" tofile="${manual}.html" />
+ <echo message="Generating PDF using Prince XML (http://www.princexml.com/)" />
+ <exec executable="prince">
+ <arg value="${manual}.html" />
+ <arg value="${manual}.pdf" />
+ <arg value="--log" />
+ <arg value="${project.build.directory}/prince.log" />
+ </exec>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>install</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${manual}.pdf</file>
+ <type>pdf</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>release</id>
+ <properties>
+ <must-succeed>true</must-succeed>
+ </properties>
+ </profile>
+ </profiles>
+
+</project>
+
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.manual/src/main/java/temp/TempJ.java
----------------------------------------------------------------------
diff --git a/extras/rya.manual/src/main/java/temp/TempJ.java b/extras/rya.manual/src/main/java/temp/TempJ.java
new file mode 100644
index 0000000..be473e4
--- /dev/null
+++ b/extras/rya.manual/src/main/java/temp/TempJ.java
@@ -0,0 +1,29 @@
+package temp;
+
+/*
+ * #%L
+ * RYA Manual
+ * %%
+ * Copyright (C) 2014 Rya
+ * %%
+ * Licensed 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.
+ * #L%
+ */
+
+/**
+* Marker class so that target/classes directory gets generated
+* and the bundle plugin does not fail
+*/
+public class TempJ {
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.manual/src/main/webapp/.livereload
----------------------------------------------------------------------
diff --git a/extras/rya.manual/src/main/webapp/.livereload b/extras/rya.manual/src/main/webapp/.livereload
new file mode 100644
index 0000000..b185045
--- /dev/null
+++ b/extras/rya.manual/src/main/webapp/.livereload
@@ -0,0 +1,19 @@
+# Lines starting with pound sign (#) are ignored.
+
+# additional extensions to monitor
+#config.exts << 'haml'
+
+# exclude files with NAMES matching this mask
+#config.exclusions << '~*'
+# exclude files with PATHS matching this mask (if the mask contains a slash)
+#config.exclusions << '/excluded_dir/*'
+# exclude files with PATHS matching this REGEXP
+#config.exclusions << /somedir.*(ab){2,4}.(css|js)$/
+
+# reload the whole page when .js changes
+#config.apply_js_live = false
+# reload the whole page when .css changes
+#config.apply_css_live = false
+
+# wait 100ms for more changes before reloading a page
+#config.grace_period = 0.1
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/92ddfa59/extras/rya.manual/src/main/webapp/WEB-INF/scalate/layouts/default.scaml
----------------------------------------------------------------------
diff --git a/extras/rya.manual/src/main/webapp/WEB-INF/scalate/layouts/default.scaml b/extras/rya.manual/src/main/webapp/WEB-INF/scalate/layouts/default.scaml
new file mode 100644
index 0000000..8b27470
--- /dev/null
+++ b/extras/rya.manual/src/main/webapp/WEB-INF/scalate/layouts/default.scaml
@@ -0,0 +1,97 @@
+
+-@ var body: String
+-@ var title : String = "Rya Manual"
+- response.setContentType("text/html")
+
+-# Only include the console if it's available and the engine is in dev mode.
+- val include_console = engine.isDevelopmentMode && engine.resourceLoader.exists("/org/fusesource/scalate/console/console_head.scaml")
+
+!!! Basic
+%html(lang="en")
+ %head
+ %meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
+ %meta(name="description" content="description goes here")
+ %meta(name="keywords" content="keywords,goes,here")
+ %meta(name="author" content="The Team")
+
+ - if (include_console)
+ = include("/org/fusesource/scalate/console/console_head.scaml")
+
+ %link(href={uri("/css/style.css")} rel="stylesheet" type="text/css")
+ %link(href={uri("/css/pygmentize.css")} rel="stylesheet" type="text/css")
+
+ - if (include_console)
+ %link(href={uri("/css/scalate/console.css")} rel="stylesheet" type="text/css")
+
+ %title
+ = title
+
+ %body
+ %table{:width => "100%", :cellpadding => "0", :cellspacing => "0"}
+ %tr{:width => "100%"}
+ %td#cell-0-0{:colspan => "2"}
+
+ %td#cell-0-1
+
+ %td#cell-0-2{:colspan => "2"}
+
+ %tr{:width => "100%"}
+ %td#cell-1-0
+
+ %td#cell-1-1
+
+ %td#cell-1-2
+ %div{:style => "padding: 5px;"}
+ #banner
+ = include("/_banner.ssp")
+ #top-menu
+ %table{:border => "0", :cellpadding => "1", :cellspacing => "0", :width => "100%"}
+ %tr
+ %td
+ %div{:align => "left"}
+ %td
+ %div{:align => "right"}
+ = include("/_quicklinks.ssp")
+ %td#cell-1-3
+
+ %td#cell-1-4
+
+ %tr{:width => "100%"}
+ %td#cell-2-0{:colspan => "2"}
+
+ %td#cell-2-1
+ %table
+ %tr{:height => "100%", :valign => "top"}
+ %td{:height => "100%"}
+ #wrapper-menu-page-right
+ #wrapper-menu-page-top
+ #wrapper-menu-page-bottom
+ #menu-page
+ = include("_navigation.conf")
+ %td{:height =>"100%", :width => "100%"}
+ .wiki-content
+ !~~ body
+ %td#cell-2-2{:colspan => "2"}
+
+ %tr{:width => "100%"}
+ %td#cell-3-0
+
+ %td#cell-3-1
+
+ %td#cell-3-2
+ #footer
+ #site-footer
+ %br
+ %td#cell-3-3
+
+ %td#cell-3-4
+
+ %tr{:width => "100%"}
+ %td#cell-4-0{:colspan => "2"}
+
+ %td#cell-4-1
+
+ %td#cell-4-2{:colspan => "2"}
+
+ - if (include_console)
+ = include("/org/fusesource/scalate/console/console.scaml")