diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java index 8afcb426f..ee7cb614a 100644 --- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java +++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/AbstractMongoDBRdfConfigurationBuilder.java @@ -41,14 +41,12 @@ public abstract class AbstractMongoDBRdfConfigurationBuilder> getOptimizers() { - List> optimizers = super.getOptimizers(); + final List> optimizers = super.getOptimizers(); if (getUseAggregationPipeline()) { - Class cl = AggregationPipelineQueryOptimizer.class; + final Class cl = AggregationPipelineQueryOptimizer.class; @SuppressWarnings("unchecked") - Class optCl = (Class) cl; + final Class optCl = (Class) cl; optimizers.add(optCl); } return optimizers; diff --git a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfigurationBuilder.java b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfigurationBuilder.java index cbe8f455f..36e973a7e 100644 --- a/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfigurationBuilder.java +++ b/dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/MongoDBRdfConfigurationBuilder.java @@ -35,7 +35,7 @@ public class MongoDBRdfConfigurationBuilder * Creates a MongoRdfConfiguration object from a Properties file. This * method assumes that all values in the Properties file are Strings and * that the Properties file uses the keys below. - * + * *
*
    *
  • "mongo.auths" - String of Mongo authorizations. Empty auths used by @@ -59,16 +59,16 @@ public class MongoDBRdfConfigurationBuilder * by default. *
*
- * + * * @param props * - Properties file containing Mongo specific configuration * parameters * @return MongoRdfConfiguration with properties set */ - public static MongoDBRdfConfiguration fromProperties(Properties props) { + public static MongoDBRdfConfiguration fromProperties(final Properties props) { try { - MongoDBRdfConfigurationBuilder builder = new MongoDBRdfConfigurationBuilder() // + final MongoDBRdfConfigurationBuilder builder = new MongoDBRdfConfigurationBuilder() // .setAuths(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_AUTHS, "")) // .setRyaPrefix(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_RYA_PREFIX, "rya_"))// .setVisibilities(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_VISIBILITIES, "")) @@ -78,8 +78,6 @@ public static MongoDBRdfConfiguration fromProperties(Properties props) { props.getProperty(AbstractMongoDBRdfConfigurationBuilder.USE_DISPLAY_QUERY_PLAN, "true")))// .setMongoUser(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_USER)) // .setMongoPassword(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_PASSWORD))// - .setMongoCollectionPrefix( - props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_COLLECTION_PREFIX, "rya_"))// .setMongoDBName( props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_DB_NAME, "rya_triples"))// .setMongoHost(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_HOST, "localhost"))// @@ -89,7 +87,7 @@ public static MongoDBRdfConfiguration fromProperties(Properties props) { props.getProperty(AbstractMongoDBRdfConfigurationBuilder.USE_MOCK_MONGO, "false"))); return builder.build(); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException(e); } } diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java index c53c9f26d..01718dc05 100644 --- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java +++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRdfConfigurationTest.java @@ -33,7 +33,6 @@ public class MongoDBRdfConfigurationTest { @Test public void testBuilder() { - final String prefix = "prefix_"; final String auth = "U,V,W"; final String visibility = "U,W"; final String user = "user"; @@ -42,12 +41,12 @@ public void testBuilder() { final boolean useInference = true; final boolean displayPlan = false; - final MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration().getBuilder() + new MongoDBRdfConfiguration(); + final MongoDBRdfConfiguration conf = MongoDBRdfConfiguration.getBuilder() .setVisibilities(visibility) .setUseInference(useInference) .setDisplayQueryPlan(displayPlan) .setUseMockMongo(useMock) - .setMongoCollectionPrefix(prefix) .setMongoDBName("dbname") .setMongoHost("host") .setMongoPort("1000") @@ -55,7 +54,6 @@ public void testBuilder() { .setMongoUser(user) .setMongoPassword(password).build(); - assertEquals(conf.getTablePrefix(), prefix); assertTrue(Arrays.equals(conf.getAuths(), new String[] { "U", "V", "W" })); assertEquals(conf.getCv(), visibility); assertEquals(conf.isInfer(), useInference); @@ -64,7 +62,7 @@ public void testBuilder() { assertEquals(conf.getBoolean(".useMockInstance", false), useMock); assertEquals(conf.getMongoPort(), "1000"); assertEquals(conf.getMongoDBName(), "dbname"); - assertEquals(conf.getRyaInstanceName(), "prefix_"); + assertEquals(conf.getRyaInstanceName(), "dbname"); assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER), user); assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER_PASSWORD), password); @@ -72,7 +70,6 @@ public void testBuilder() { @Test public void testBuilderFromProperties() throws FileNotFoundException, IOException { - final String prefix = "prefix_"; final String auth = "U"; final String visibility = "U"; final String user = "user"; @@ -86,7 +83,6 @@ public void testBuilderFromProperties() throws FileNotFoundException, IOExceptio final MongoDBRdfConfiguration conf = MongoDBRdfConfiguration.fromProperties(props); - assertEquals(conf.getTablePrefix(), prefix); assertTrue(Arrays.equals(conf.getAuths(), new String[] { auth })); assertEquals(conf.getCv(), visibility); assertEquals(conf.isInfer(), useInference); @@ -95,7 +91,7 @@ public void testBuilderFromProperties() throws FileNotFoundException, IOExceptio assertEquals(conf.getBoolean(".useMockInstance", false), useMock); assertEquals(conf.getMongoPort(), "1000"); assertEquals(conf.getMongoDBName(), "dbname"); - assertEquals(conf.getRyaInstanceName(), "prefix_"); + assertEquals(conf.getRyaInstanceName(), "dbname"); assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER), user); assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER_PASSWORD), password); } diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java index 7f4a0bd57..6b3ffde65 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java @@ -59,7 +59,6 @@ public abstract class AbstractMongoIndexer implements MongoSecondaryIndex { private static final Logger LOG = Logger.getLogger(AbstractMongoIndexer.class); - private boolean isInit = false; private boolean flushEachUpdate = true; protected StatefulMongoDBRdfConfiguration conf; protected MongoDBRyaDAO dao; @@ -72,12 +71,12 @@ public abstract class AbstractMongoIndexer mongoDbBatchWriter; + protected String collectionName; protected void initCore() { dbName = conf.getMongoDBName(); this.mongoClient = conf.getMongoClient(); db = this.mongoClient.getDB(dbName); - final String collectionName = conf.get(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya") + getCollectionName(); collection = db.getCollection(collectionName); flushEachUpdate = ((MongoDBRdfConfiguration)conf).flushEachUpdate(); @@ -170,7 +169,7 @@ private DBObject prepareStatementForStorage(final RyaStatement ryaStatement) { try { final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement); final boolean isValidPredicate = predicates.isEmpty() || predicates.contains(statement.getPredicate()); - if (isValidPredicate && (statement.getObject() instanceof Literal)) { + if (isValidPredicate && statement.getObject() instanceof Literal) { final DBObject obj = storageStrategy.serialize(ryaStatement); return obj; } @@ -220,5 +219,7 @@ public void close() throws QueryEvaluationException { /** * @return The name of the {@link DBCollection} to use with the storage strategy. */ - public abstract String getCollectionName(); + public String getCollectionName() { + return collectionName; + } } diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java index 25bb0b859..75b3523b6 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java @@ -279,8 +279,6 @@ public static MongoIndexingConfiguration fromProperties(final Properties props) .getProperty(AbstractMongoDBRdfConfigurationBuilder.USE_DISPLAY_QUERY_PLAN, "true")))// .setMongoUser(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_USER)) // .setMongoPassword(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_PASSWORD))// - .setMongoCollectionPrefix(props - .getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_COLLECTION_PREFIX, "rya_"))// .setMongoDBName( props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_DB_NAME, "rya_triples"))// .setMongoHost(props.getProperty(AbstractMongoDBRdfConfigurationBuilder.MONGO_HOST, "localhost"))// @@ -312,7 +310,7 @@ public static MongoIndexingConfiguration fromProperties(final Properties props) * @return MongoIndexingConfigBuilder for chaining method invocations */ public MongoDBIndexingConfigBuilder setUseMongoFreetextIndex(final boolean useFreeText) { - this.useFreetext = useFreeText; + useFreetext = useFreeText; return this; } @@ -355,7 +353,7 @@ public MongoDBIndexingConfigBuilder setUseMongoEntityIndex(final boolean useEnti * @return MongoIndexingConfigBuilder for chaining method invocations */ public MongoDBIndexingConfigBuilder setMongoFreeTextPredicates(final String... predicates) { - this.freetextPredicates = predicates; + freetextPredicates = predicates; return this; } @@ -367,7 +365,7 @@ public MongoDBIndexingConfigBuilder setMongoFreeTextPredicates(final String... p * @return MongoIndexingConfigBuilder for chaining method invocations */ public MongoDBIndexingConfigBuilder setMongoTemporalPredicates(final String... predicates) { - this.temporalPredicates = predicates; + temporalPredicates = predicates; return this; } diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java index f13e4c151..10d4891c5 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java @@ -32,11 +32,12 @@ import com.mongodb.QueryBuilder; public class MongoFreeTextIndexer extends AbstractMongoIndexer implements FreeTextIndexer { - private static final String COLLECTION_SUFFIX = "freetext"; + private static final String COLLECTION_NAME = "freetext"; private static final Logger logger = Logger.getLogger(MongoFreeTextIndexer.class); - + @Override public void init() { + collectionName = COLLECTION_NAME; initCore(); predicates = ConfigUtils.getFreeTextPredicates(conf); if(predicates.size() == 0) { @@ -52,9 +53,4 @@ public CloseableIteration queryText( final QueryBuilder qb = QueryBuilder.start().text(query); return withConstraints(constraints, qb.get()); } - - @Override - public String getCollectionName() { - return ConfigUtils.getTablePrefix(conf) + COLLECTION_SUFFIX; - } } diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java index 653844f89..8fc72037b 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java @@ -41,11 +41,12 @@ * Indexes MongoDB based on time instants or intervals. */ public class MongoTemporalIndexer extends AbstractMongoIndexer implements TemporalIndexer { - private static final String COLLECTION_SUFFIX = "temporal"; + protected final String COLLECTION_NAME = "temporal"; private static final Logger LOG = Logger.getLogger(MongoTemporalIndexer.class); @Override public void init() { + collectionName = COLLECTION_NAME; initCore(); predicates = ConfigUtils.getTemporalPredicates(conf); if(predicates.size() == 0) { @@ -142,7 +143,7 @@ public CloseableIteration queryIntervalAfte @Override public String getCollectionName() { - return ConfigUtils.getTablePrefix(conf) + COLLECTION_SUFFIX; + return ConfigUtils.getTablePrefix(conf) + COLLECTION_NAME; } @VisibleForTesting diff --git a/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexingConfigurationTest.java b/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexingConfigurationTest.java index 708219ccf..50f301c0a 100644 --- a/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexingConfigurationTest.java +++ b/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoIndexingConfigurationTest.java @@ -35,21 +35,20 @@ public class MongoIndexingConfigurationTest { @Test public void testBuilder() { - String prefix = "prefix_"; - String auth = "U,V,W"; - String visibility = "U,W"; - String user = "user"; - String password = "password"; - boolean useMock = true; - boolean useInference = true; - boolean displayPlan = false; + final String prefix = "prefix_"; + final String auth = "U,V,W"; + final String visibility = "U,W"; + final String user = "user"; + final String password = "password"; + final boolean useMock = true; + final boolean useInference = true; + final boolean displayPlan = false; - MongoIndexingConfiguration conf = MongoIndexingConfiguration.builder() + final MongoIndexingConfiguration conf = MongoIndexingConfiguration.builder() .setVisibilities(visibility) .setUseInference(useInference) .setDisplayQueryPlan(displayPlan) .setUseMockMongo(useMock) - .setMongoCollectionPrefix(prefix) .setMongoDBName("dbname") .setMongoHost("host") .setMongoPort("1000") @@ -63,7 +62,6 @@ public void testBuilder() { .setMongoTemporalPredicates("http://pred3", "http://pred4") .build(); - assertEquals(conf.getTablePrefix(), prefix); assertTrue(Arrays.equals(conf.getAuths(), new String[] { "U", "V", "W" })); assertEquals(conf.getCv(), visibility); assertEquals(conf.isInfer(), useInference); @@ -72,7 +70,7 @@ public void testBuilder() { assertEquals(conf.getBoolean(".useMockInstance", false), useMock); assertEquals(conf.getMongoPort(), "1000"); assertEquals(conf.getMongoDBName(), "dbname"); - assertEquals(conf.getRyaInstanceName(), "prefix_"); + assertEquals(conf.getRyaInstanceName(), "dbname"); assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER), user); assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER_PASSWORD), password); assertTrue( @@ -84,21 +82,19 @@ public void testBuilder() { @Test public void testBuilderFromProperties() throws FileNotFoundException, IOException { - String prefix = "prefix_"; - String auth = "U"; - String visibility = "U"; - String user = "user"; - String password = "password"; - boolean useMock = true; - boolean useInference = true; - boolean displayPlan = false; + final String auth = "U"; + final String visibility = "U"; + final String user = "user"; + final String password = "password"; + final boolean useMock = true; + final boolean useInference = true; + final boolean displayPlan = false; - Properties props = new Properties(); + final Properties props = new Properties(); props.load(new FileInputStream("src/test/resources/mongo_rya_indexing.properties")); - MongoIndexingConfiguration conf = MongoIndexingConfiguration.fromProperties(props); + final MongoIndexingConfiguration conf = MongoIndexingConfiguration.fromProperties(props); - assertEquals(conf.getTablePrefix(), prefix); assertTrue(Arrays.equals(conf.getAuths(), new String[] { auth })); assertEquals(conf.getCv(), visibility); assertEquals(conf.isInfer(), useInference); @@ -107,7 +103,7 @@ public void testBuilderFromProperties() throws FileNotFoundException, IOExceptio assertEquals(conf.getBoolean(".useMockInstance", false), useMock); assertEquals(conf.getMongoPort(), "1000"); assertEquals(conf.getMongoDBName(), "dbname"); - assertEquals(conf.getRyaInstanceName(), "prefix_"); + assertEquals(conf.getRyaInstanceName(), "dbname"); assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER), user); assertEquals(conf.get(MongoDBRdfConfiguration.MONGO_USER_PASSWORD), password); assertTrue( diff --git a/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerIT.java b/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerIT.java index b9743eb9b..3b482fc17 100644 --- a/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerIT.java +++ b/extras/indexing/src/test/java/org/apache/rya/indexing/mongo/MongoTemporalIndexerIT.java @@ -232,7 +232,7 @@ public void testDelete() throws IOException, MongoException, TableNotFoundExcept final String dbName = conf.getMongoDBName(); final DB db = super.getMongoClient().getDB(dbName); - final DBCollection collection = db.getCollection(conf.get(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya") + tIndexer.getCollectionName()); + final DBCollection collection = db.getCollection(tIndexer.getCollectionName()); printTables(tIndexer, "junit testing: Temporal entities stored in testDelete before delete"); assertEquals("Number of rows stored.", 2, collection.count()); // 4 index entries per statement diff --git a/extras/indexingExample/src/main/java/InferenceExamples.java b/extras/indexingExample/src/main/java/InferenceExamples.java index 96e432143..367312cab 100644 --- a/extras/indexingExample/src/main/java/InferenceExamples.java +++ b/extras/indexingExample/src/main/java/InferenceExamples.java @@ -162,7 +162,6 @@ private static Configuration getConf() throws IOException { } return builder.setMongoDBName(MONGO_DB) - .setMongoCollectionPrefix(MONGO_COLL_PREFIX) .setUseMongoFreetextIndex(true) .setMongoFreeTextPredicates(RDFS.LABEL.stringValue()).build(); diff --git a/extras/indexingExample/src/main/java/MongoRyaDirectExample.java b/extras/indexingExample/src/main/java/MongoRyaDirectExample.java index d4a8f8c91..a7e90f6d1 100644 --- a/extras/indexingExample/src/main/java/MongoRyaDirectExample.java +++ b/extras/indexingExample/src/main/java/MongoRyaDirectExample.java @@ -402,7 +402,6 @@ private static Configuration getConf() throws IOException { } return builder.setMongoDBName(MONGO_DB) - .setMongoCollectionPrefix(MONGO_COLL_PREFIX) .setUseMongoFreetextIndex(true) .setMongoFreeTextPredicates(RDFS.LABEL.stringValue()).build(); diff --git a/extras/rya.export/export.integration/src/test/java/org/apache/rya/indexing/export/ITBase.java b/extras/rya.export/export.integration/src/test/java/org/apache/rya/indexing/export/ITBase.java index 4b7d3f9ad..55c7a732c 100644 --- a/extras/rya.export/export.integration/src/test/java/org/apache/rya/indexing/export/ITBase.java +++ b/extras/rya.export/export.integration/src/test/java/org/apache/rya/indexing/export/ITBase.java @@ -260,8 +260,6 @@ protected static MongoDBRdfConfiguration getConf(final String ryaInstanceName, conf.set(ConfigUtils.CLOUDBASE_PASSWORD, PASSWORD); conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test"); - conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_"); - conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_"); conf.setMongoPort(""+port); diff --git a/extras/rya.geoindexing/geo.mongo/src/main/java/org/apache/rya/indexing/geoExamples/RyaMongoGeoDirectExample.java b/extras/rya.geoindexing/geo.mongo/src/main/java/org/apache/rya/indexing/geoExamples/RyaMongoGeoDirectExample.java index 39ea3a8b1..4666a6967 100644 --- a/extras/rya.geoindexing/geo.mongo/src/main/java/org/apache/rya/indexing/geoExamples/RyaMongoGeoDirectExample.java +++ b/extras/rya.geoindexing/geo.mongo/src/main/java/org/apache/rya/indexing/geoExamples/RyaMongoGeoDirectExample.java @@ -7,9 +7,9 @@ * 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 @@ -61,21 +61,21 @@ public class RyaMongoGeoDirectExample { private static final String MONGO_INSTANCE_URL = "localhost"; private static final String MONGO_INSTANCE_PORT = "27017"; - public static void main(String[] args) throws Exception { - Configuration conf = getConf(); + public static void main(final String[] args) throws Exception { + final Configuration conf = getConf(); conf.setBoolean(ConfigUtils.DISPLAY_QUERY_PLAN, PRINT_QUERIES); conf.setBoolean(OptionalConfigUtils.USE_GEO, true); // Note also the use of "GeoRyaSailFactory" below. conf.setStrings(OptionalConfigUtils.GEO_PREDICATES_LIST, "http://www.opengis.net/ont/geosparql#asWKT"); // Note also the use of "GeoRyaSailFactory" below. - + SailRepository repository = null; SailRepositoryConnection conn = null; try { log.info("Connecting to Indexing Sail Repository."); - Sail sail = GeoRyaSailFactory.getInstance(conf); + final Sail sail = GeoRyaSailFactory.getInstance(conf); repository = new SailRepository(sail); conn = repository.getConnection(); - long start = System.currentTimeMillis(); + final long start = System.currentTimeMillis(); testAddPointAndWithinSearch(conn); // uses geospatial features log.info("TIME: " + (System.currentTimeMillis() - start) / 1000.); @@ -92,9 +92,9 @@ public static void main(String[] args) throws Exception { * Try out some geospatial data and queries * @param repository */ - private static void testAddPointAndWithinSearch(SailRepositoryConnection conn) throws Exception { + private static void testAddPointAndWithinSearch(final SailRepositoryConnection conn) throws Exception { - String update = "PREFIX geo: "// + final String update = "PREFIX geo: "// + "INSERT DATA { " // + " a geo:Feature ; " // + " geo:hasGeometry [ " // @@ -103,7 +103,7 @@ private static void testAddPointAndWithinSearch(SailRepositoryConnection conn) t + " ] . " // + "}"; - Update u = conn.prepareUpdate(QueryLanguage.SPARQL, update); + final Update u = conn.prepareUpdate(QueryLanguage.SPARQL, update); u.execute(); String queryString; @@ -147,21 +147,21 @@ private static void testAddPointAndWithinSearch(SailRepositoryConnection conn) t Validate.isTrue(tupleHandler.getCount() == 0); } - private static void closeQuietly(SailRepository repository) { + private static void closeQuietly(final SailRepository repository) { if (repository != null) { try { repository.shutDown(); - } catch (RepositoryException e) { + } catch (final RepositoryException e) { // quietly absorb this exception } } } - private static void closeQuietly(SailRepositoryConnection conn) { + private static void closeQuietly(final SailRepositoryConnection conn) { if (conn != null) { try { conn.close(); - } catch (RepositoryException e) { + } catch (final RepositoryException e) { // quietly absorb this exception } } @@ -175,10 +175,10 @@ private static Configuration getConf() throws IOException { if (USE_MOCK) { mock = EmbeddedMongoFactory.newFactory(); - MongoClient c = mock.newMongoClient(); - ServerAddress address = c.getAddress(); - String url = address.getHost(); - String port = Integer.toString(address.getPort()); + final MongoClient c = mock.newMongoClient(); + final ServerAddress address = c.getAddress(); + final String url = address.getHost(); + final String port = Integer.toString(address.getPort()); c.close(); builder.setMongoHost(url).setMongoPort(port); } else { @@ -188,12 +188,11 @@ private static Configuration getConf() throws IOException { .setMongoHost(MONGO_INSTANCE_URL) .setMongoPort(MONGO_INSTANCE_PORT); } - + return builder.setMongoDBName(MONGO_DB) - .setMongoCollectionPrefix(MONGO_COLL_PREFIX) .setUseMongoFreetextIndex(true) .setMongoFreeTextPredicates(RDFS.LABEL.stringValue()).build(); - + } @@ -205,11 +204,11 @@ public int getCount() { } @Override - public void startQueryResult(List arg0) throws TupleQueryResultHandlerException { + public void startQueryResult(final List arg0) throws TupleQueryResultHandlerException { } @Override - public void handleSolution(BindingSet arg0) throws TupleQueryResultHandlerException { + public void handleSolution(final BindingSet arg0) throws TupleQueryResultHandlerException { count++; System.out.println(arg0); } @@ -219,15 +218,15 @@ public void endQueryResult() throws TupleQueryResultHandlerException { } @Override - public void handleBoolean(boolean arg0) throws QueryResultHandlerException { + public void handleBoolean(final boolean arg0) throws QueryResultHandlerException { // TODO Auto-generated method stub - + } @Override - public void handleLinks(List arg0) throws QueryResultHandlerException { + public void handleLinks(final List arg0) throws QueryResultHandlerException { // TODO Auto-generated method stub - + } } }