edu.iu.cnets.klatsch.feed
Class Buzz

java.lang.Object
  extended by edu.iu.cnets.klatsch.feed.Buzz
All Implemented Interfaces:
Feed

public class Buzz
extends java.lang.Object
implements Feed

This class handles all importation of data from the Buzz database into the Klatsch framework.


Nested Class Summary
(package private) static class Buzz.Query
          enumeration for our prepared statements
(package private)  class Buzz.SqlEventIterator
          Internal class for converting a ResultSet into a series of Event objects.
 
Field Summary
(package private)  java.sql.Connection cxn
          the connection
(package private)  java.lang.String db
          the database connection string
private static java.lang.String DEFAULT_DATABASE
           
private static java.lang.String DEFAULT_HOST
          hardwired defaults for the connection
private static java.lang.String DEFAULT_PASSWORD
           
private static int DEFAULT_PORT
           
private static java.lang.String DEFAULT_USERNAME
           
(package private)  java.lang.String password
          the password for connecting
(package private)  java.util.Map<Buzz.Query,java.sql.PreparedStatement> query
           
(package private)  java.lang.String username
          the username for connecting
 
Constructor Summary
Buzz(Value... ls)
          Creates a new object for connecting to the Buzz database.
 
Method Summary
 java.util.Iterator<Event> actorEvents(int actorId)
          Returns an iterator over all events for the given actor.
 java.util.Iterator<Event> actorEvents(int actorId, int startTime, int endTime)
          Returns an iterator over all events for the given actor in the given time interval.
 int actorId(java.lang.String actor)
          Maps from an actor's label to its ID.
 java.lang.String actorLabel(int actorId)
          Maps from an actor's ID to its label.
 boolean connect()
          Attempts to establish a connection to the database using our credentials.
 java.util.Iterator<Event> events(int startTime, int endTime)
          Returns an iterator over all events in the given time range.
protected  void finalize()
          Called to close the database connection during object finalization.
 java.util.Iterator<Event> memeEvents(int memeId)
          Returns an iterator over all events for the given meme.
 java.util.Iterator<Event> memeEvents(int memeId, int startTime, int endTime)
          Returns an iterator over all events for the given meme in the given time interval.
 int memeId(java.lang.String meme)
          Maps from a meme's label to its ID.
 java.lang.String memeLabel(int memeId)
          Maps from a meme's ID to its label.
 java.util.Iterator<java.lang.Integer> memeLinks(int memeId)
          Returns an iterator over all memes connected to the given meme.
 java.lang.String name()
          Returns the name of this feed.
 java.sql.ResultSet query(java.lang.String queryText)
          Takes care of actually submitting a query to the database and returning the results.
 void updateTrust(Graph g)
          Performs post-construction updating of the trusted weights in a graph derived from the Buzz feed.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HOST

private static final java.lang.String DEFAULT_HOST
hardwired defaults for the connection

See Also:
Constant Field Values

DEFAULT_PORT

private static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_DATABASE

private static final java.lang.String DEFAULT_DATABASE
See Also:
Constant Field Values

DEFAULT_USERNAME

private static final java.lang.String DEFAULT_USERNAME
See Also:
Constant Field Values

DEFAULT_PASSWORD

private static final java.lang.String DEFAULT_PASSWORD
See Also:
Constant Field Values

query

java.util.Map<Buzz.Query,java.sql.PreparedStatement> query

db

java.lang.String db
the database connection string


cxn

java.sql.Connection cxn
the connection


username

java.lang.String username
the username for connecting


password

java.lang.String password
the password for connecting

Constructor Detail

Buzz

public Buzz(Value... ls)
     throws EvaluationException
Creates a new object for connecting to the Buzz database. The single parameter should be a dictionary containing overrides for the default parameters, which are listed below: host (String) [default is 'carl.cs.indiana.edu'] port (Number) [default is 3306] database (String) [default is 'buzz'] username (String) [default is 'truthy'] password (String) [default is 'bananap33l'] Note that this does not try to establish the connection -- that must be done with connect().

Throws:
EvaluationException
Method Detail

actorEvents

public java.util.Iterator<Event> actorEvents(int actorId)
Returns an iterator over all events for the given actor.

Specified by:
actorEvents in interface Feed

actorEvents

public java.util.Iterator<Event> actorEvents(int actorId,
                                             int startTime,
                                             int endTime)
Returns an iterator over all events for the given actor in the given time interval.

Specified by:
actorEvents in interface Feed

actorId

public int actorId(java.lang.String actor)
            throws java.lang.IllegalArgumentException
Maps from an actor's label to its ID.

Specified by:
actorId in interface Feed
Throws:
java.lang.IllegalArgumentException

actorLabel

public java.lang.String actorLabel(int actorId)
                            throws java.lang.IllegalArgumentException
Maps from an actor's ID to its label.

Specified by:
actorLabel in interface Feed
Throws:
java.lang.IllegalArgumentException

connect

public boolean connect()
Attempts to establish a connection to the database using our credentials.

Specified by:
connect in interface Feed
Throws:
EvaluationException - if the connection failed

events

public java.util.Iterator<Event> events(int startTime,
                                        int endTime)
Returns an iterator over all events in the given time range.

Specified by:
events in interface Feed

finalize

protected void finalize()
                 throws java.lang.Throwable
Called to close the database connection during object finalization.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

memeEvents

public java.util.Iterator<Event> memeEvents(int memeId)
Returns an iterator over all events for the given meme.

Specified by:
memeEvents in interface Feed

memeEvents

public java.util.Iterator<Event> memeEvents(int memeId,
                                            int startTime,
                                            int endTime)
Returns an iterator over all events for the given meme in the given time interval.

Specified by:
memeEvents in interface Feed

memeId

public int memeId(java.lang.String meme)
           throws java.lang.IllegalArgumentException
Maps from a meme's label to its ID.

Specified by:
memeId in interface Feed
Throws:
java.lang.IllegalArgumentException

memeLabel

public java.lang.String memeLabel(int memeId)
                           throws java.lang.IllegalArgumentException
Maps from a meme's ID to its label.

Specified by:
memeLabel in interface Feed
Throws:
java.lang.IllegalArgumentException

memeLinks

public java.util.Iterator<java.lang.Integer> memeLinks(int memeId)
Returns an iterator over all memes connected to the given meme.

Specified by:
memeLinks in interface Feed

name

public java.lang.String name()
Returns the name of this feed.

Specified by:
name in interface Feed

query

public java.sql.ResultSet query(java.lang.String queryText)
                         throws java.lang.IllegalArgumentException
Takes care of actually submitting a query to the database and returning the results.

Throws:
java.lang.IllegalArgumentException

updateTrust

public void updateTrust(Graph g)
Performs post-construction updating of the trusted weights in a graph derived from the Buzz feed. This is a null operation.

Specified by:
updateTrust in interface Feed