Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: joshsh/twitlogic
base: e1b8a64178
...
head fork: joshsh/twitlogic
compare: 3d2d5019ce
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
4 twitlogic-core/src/main/java/net/fortytwo/twitlogic/TwitLogicClientDemo.java
@@ -9,9 +9,9 @@
import net.fortytwo.twitlogic.persistence.TweetPersister;
import net.fortytwo.twitlogic.persistence.TweetStore;
import net.fortytwo.twitlogic.persistence.TweetStoreException;
-import net.fortytwo.twitlogic.services.twitter.CustomTwitterClient;
import net.fortytwo.twitlogic.services.twitter.TwitterClient;
import net.fortytwo.twitlogic.services.twitter.TwitterClientException;
+import net.fortytwo.twitlogic.services.twitter.twitter4j.Twitter4jClient;
import net.fortytwo.twitlogic.syntax.Matcher;
import net.fortytwo.twitlogic.syntax.MultiMatcher;
import net.fortytwo.twitlogic.syntax.TopicSniffer;
@@ -70,7 +70,7 @@ private static void runDemo() throws Exception {
try {
// Create a client for communication with Twitter.
//TwitterClient client = new Twitter4jClient();
- TwitterClient client = new CustomTwitterClient();
+ TwitterClient client = new Twitter4jClient();
Handler<Tweet> annotator
= createAnnotator(store, client);
View
45 twitlogic-core/src/main/java/net/fortytwo/twitlogic/persistence/TweetStore.java
@@ -27,7 +27,6 @@
import net.fortytwo.twitlogic.persistence.sail.Neo4jSailFactory;
import net.fortytwo.twitlogic.persistence.sail.NewAllegroSailFactory;
import net.fortytwo.twitlogic.util.Factory;
-import net.fortytwo.twitlogic.util.SparqlUpdateTools;
import net.fortytwo.twitlogic.util.properties.PropertyException;
import net.fortytwo.twitlogic.util.properties.TypedProperties;
import org.openrdf.concepts.owl.ObjectProperty;
@@ -53,7 +52,6 @@
import org.openrdf.sail.nativerdf.NativeStore;
import org.restlet.resource.Directory;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -76,11 +74,9 @@
private static final int DEFAULT_PORT = 8182;
private final Sail sail;
- private final TypedProperties configuration;
private boolean doNotRefreshCoreMetadata = false;
private Repository repository;
- private ElmoModule adminElmoModule;
private SesameManagerFactory elmoManagerFactory;
private boolean initialized = false;
private Factory<SailConnectionListener> sailConnectionListenerFactory;
@@ -89,14 +85,10 @@
/**
* The Sesame storage and inference layer (Sail) will be constructed according to configuration properties.
*
- * @throws TweetStoreException
+ * @throws TweetStoreException if construction fails
*/
public TweetStore() throws TweetStoreException {
- configuration = TwitLogic.getConfiguration();
-
- sail = createSail(configuration);
-
- openConnections = Collections.synchronizedSet(new HashSet<TweetStoreConnection>());
+ this(createSail());
}
/**
@@ -104,7 +96,6 @@ public TweetStore() throws TweetStoreException {
*/
public TweetStore(final Sail sail) {
this.sail = sail;
- this.configuration = TwitLogic.getConfiguration();
openConnections = Collections.synchronizedSet(new HashSet<TweetStoreConnection>());
}
@@ -122,7 +113,7 @@ public void initialize() throws TweetStoreException {
}
// Elmo setup.
- adminElmoModule = new ElmoModule();
+ ElmoModule adminElmoModule = new ElmoModule();
adminElmoModule.setGraph(null); // for TwitLogic.AUTHORITATIVE_GRAPH
adminElmoModule.addConcept(Thing.class);
adminElmoModule.addConcept(ObjectProperty.class); // Dunno why this is necessary, but Elmo logs warnings without it
@@ -217,14 +208,6 @@ public Repository getRepository() {
return repository;
}
- public ElmoModule getElmoModule() {
- if (!initialized) {
- throw new IllegalStateException("not yet initialized");
- }
-
- return adminElmoModule;
- }
-
public ElmoManagerFactory getElmoManagerFactory() {
return elmoManagerFactory;
}
@@ -307,24 +290,6 @@ public void dumpToCompressedFile(final File file,
}
}
- public void dumpToSparqlUpdateEndpoint(final String endpointURI) throws TweetStoreException {
- LOGGER.info("dumping triple store to SPARUL endpoint: " + endpointURI);
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
- try {
- SparqlUpdateTools.dumpTripleStore(this.getSail(), bos);
- } catch (SailException e) {
- throw new TweetStoreException(e);
- } catch (IOException e) {
- throw new TweetStoreException(e);
- }
-
- String data = bos.toString();
-
- // TODO
- }
-
public void clear() throws TweetStoreException {
try {
RepositoryConnection rc = repository.getConnection();
@@ -363,7 +328,9 @@ public void load(final File file,
////////////////////////////////////////////////////////////////////////////
- public static Sail createSail(final TypedProperties props) throws TweetStoreException {
+ public static Sail createSail() throws TweetStoreException {
+ TypedProperties props = TwitLogic.getConfiguration();
+
String sailType;
try {
sailType = props.getString(TwitLogic.SAIL_CLASS);
View
26 twitlogic-core/src/main/java/net/fortytwo/twitlogic/util/ExampleTweetHandler.java
@@ -60,19 +60,19 @@ public Resource anonymousNode() {
}
};
final List<Triple> results = new LinkedList<Triple>();
- Handler<Triple> handler = new Handler<Triple>() {
- public boolean handle(final Triple triple) throws HandlerException {
- results.add(triple);
- return true;
- }
- };
-
- /* try {
- matcher.match(tweet.getText(), handler, tweetContext);
- } catch (MatcherException e) {
- throw new HandlerException(e);
- }
- */
+ /* Handler<Triple> handler = new Handler<Triple>() {
+ public boolean handle(final Triple triple) throws HandlerException {
+ results.add(triple);
+ return true;
+ }
+ };
+
+ try {
+ matcher.match(tweet.getText(), handler, tweetContext);
+ } catch (MatcherException e) {
+ throw new HandlerException(e);
+ }
+ */
Comparator<Triple> cmp = new Comparator<Triple>() {
public int compare(final Triple first,
final Triple second) {
View
31 twitlogic-core/src/main/java/net/fortytwo/twitlogic/util/StoppableHandler.java
@@ -0,0 +1,31 @@
+package net.fortytwo.twitlogic.util;
+
+import net.fortytwo.twitlogic.flow.Handler;
+import net.fortytwo.twitlogic.services.twitter.HandlerException;
+
+/**
+ * A convenience object which can be stacked on top of another <code>Handler</code>,
+ * allowing input to that handler to be stopped.
+ *
+ * @author Joshua Shinavier (http://fortytwo.net)
+ */
+public class StoppableHandler<T> implements Handler<T> {
+ private final Handler<T> baseHandler;
+ private boolean stopped = false;
+
+ public StoppableHandler(Handler<T> baseHandler) {
+ this.baseHandler = baseHandler;
+ }
+
+ public boolean handle(T t) throws HandlerException {
+ return !stopped && baseHandler.handle(t);
+ }
+
+ public void stop() {
+ stopped = true;
+ }
+
+ public void reset() {
+ stopped = false;
+ }
+}
View
2  twitlogic-rdfagents/src/main/java/net/fortytwo/twitlogic/rdfagents/TwitLogicPubsubProvider.java
@@ -134,7 +134,7 @@ public void statementRemoved(Statement statement) {
}
};
- Sail baseSail = TweetStore.createSail(TwitLogic.getConfiguration());
+ Sail baseSail = TweetStore.createSail();
NotifyingSail b;
if (baseSail instanceof NotifyingSail) {
b = (NotifyingSail) baseSail;

No commit comments for this range

Something went wrong with that request. Please try again.