eu.dicodeproject.analysis.restapi
Class TwitterController

java.lang.Object
  extended by eu.dicodeproject.analysis.restapi.TwitterController

@Controller
@RequestMapping(value="/twitter/")
public class TwitterController
extends Object


Constructor Summary
TwitterController()
           
 
Method Summary
 void creationDates(String dateType, String callback, String start, String stop, boolean addZeros, javax.servlet.http.HttpServletResponse response)
          Takes a date type as parameter.
 void export(String topic, String minSupport, javax.servlet.http.HttpServletResponse response)
          Deprecated. 
 void hashtag(String topic, String day, javax.servlet.http.HttpServletResponse response)
          Returns hashtags for a certain topic and day if available This method was implemented to demonstrate the workflow and will be replaced by the generic method "metadata"
 void metadata(String type, String day, String callback, javax.servlet.http.HttpServletResponse response)
          Generic method which returns Twitter meta-data from HBase http://localhost:9889/restapi/twitter/metadata/lang.json?
 void setExportService(TwitterVectorExporter exportService)
           
 void setHBaseColumn(String hbaseColumn)
           
 void setHBaseColumnFamily(String hbaseColumnFamily)
           
 void setHBaseTablename(String hbaseTablename)
           
 void setHTablePoolHandler(HTablePoolHandler handler)
           
 void setTwitterstreamTablename(String twitterstreamTablename)
           
 void termFreqs(String terms, String callback, String start, String stop, boolean addZeros, javax.servlet.http.HttpServletResponse response)
          Takes terms as input.
 void vectors(String start, String stop, String language, String regex, String callback, javax.servlet.http.HttpServletResponse response)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TwitterController

public TwitterController()
Method Detail

hashtag

@RequestMapping(value="hashtag/{topic}_{day}",
                method=GET)
public void hashtag(@PathVariable
                                   String topic,
                                   @PathVariable
                                   String day,
                                   javax.servlet.http.HttpServletResponse response)
             throws IOException
Returns hashtags for a certain topic and day if available This method was implemented to demonstrate the workflow and will be replaced by the generic method "metadata"

Parameters:
topic -
day -
response -
Throws:
IOException

metadata

@RequestMapping(value="metadata/{type}.json",
                method=GET)
public void metadata(@PathVariable
                                    String type,
                                    @RequestParam
                                    String day,
                                    @RequestParam
                                    String callback,
                                    javax.servlet.http.HttpServletResponse response)
              throws IOException
Generic method which returns Twitter meta-data from HBase http://localhost:9889/restapi/twitter/metadata/lang.json?day=20110824

Parameters:
type -
day -
response -
Throws:
IOException

vectors

@RequestMapping(value="vectors",
                method=GET)
public void vectors(@RequestParam(required=false)
                                   String start,
                                   @RequestParam(required=false)
                                   String stop,
                                   @RequestParam(required=false)
                                   String language,
                                   @RequestParam(required=false)
                                   String regex,
                                   @RequestParam
                                   String callback,
                                   javax.servlet.http.HttpServletResponse response)
             throws IOException,
                    twitter4j.internal.org.json.JSONException
Throws:
IOException
twitter4j.internal.org.json.JSONException

export

@Deprecated
@RequestMapping(value="export/{topic}_{minSupport}",
                method=GET)
public void export(@PathVariable
                                             String topic,
                                             @PathVariable
                                             String minSupport,
                                             javax.servlet.http.HttpServletResponse response)
Deprecated. 

Parameters:
topic -
minSupport -
response -
Throws:
IOException

creationDates

@RequestMapping(value="creationDates/{dateType}",
                method=GET)
public void creationDates(@PathVariable
                                         String dateType,
                                         @RequestParam
                                         String callback,
                                         @RequestParam(required=false)
                                         String start,
                                         @RequestParam(required=false)
                                         String stop,
                                         @RequestParam(required=false,defaultValue="false")
                                         boolean addZeros,
                                         javax.servlet.http.HttpServletResponse response)
                   throws IOException,
                          twitter4j.internal.org.json.JSONException
Takes a date type as parameter. Returns a JSON that consists of {"result": MAP}, with MAP containing dates (years, months and days) with their frequencies with respect to Tweet creation dates.

Parameters:
dateType - one of {"year", "yearMonth", "yearMonthDay", "hour"} Returns a JSON that consists of {"categoriesLabel": String, "categories": Array, "chartData": Map}, with Map containing "creationDates" as key and a map with (date, frequency) as value. Array contains all date values in the required range, and categoriesLabel is the label for these values e.g. { "categoriesLabel": "yearMonth", "categories": ["2011-01", "2011-02"], "chartData": { "creationDates": { "2011-01": 54, "2011-02": 21 } } }
callback - arbitrary callback parameter
start - earliest date in the result
stop - EXCLUSIVE latest date in the result
addZeros - flag to specify if missing values should be represented by zero entries
response - to write the answer to
Throws:
IOException - inherited from HBase Scan and HttpServletResponse.write
twitter4j.internal.org.json.JSONException - inherited from JSONObject constructor

termFreqs

@RequestMapping(value="termFreqs",
                method=GET)
public void termFreqs(@RequestParam
                                     String terms,
                                     @RequestParam
                                     String callback,
                                     @RequestParam(required=false)
                                     String start,
                                     @RequestParam(required=false)
                                     String stop,
                                     @RequestParam(required=false,defaultValue="false")
                                     boolean addZeros,
                                     javax.servlet.http.HttpServletResponse response)
               throws IOException,
                      twitter4j.internal.org.json.JSONException
Takes terms as input. Returns a JSON that consists of {"categoriesLabel": String, "categories": Array, "chartData": Map}, with Map containing terms as keys and maps with (date, frequency) as values. Array contains all date values in the required range, and categoriesLabel is the label for these values e.g. { "categoriesLabel": "date", "categories": ["2011-01-01", "2011-01-02"], "chartData": { "google": { "2011-01-01": 54, "2011-01-02": 21 } "microsoft": { "2011-01-01": 43 } } }

Parameters:
terms - list of terms separated by commas
callback - arbitrary callback parameter
start - earliest date in the result
stop - EXCLUSIVE latest date in the result
addZeros - flag to specify if missing values should be represented by zero entries
response - to write the answer to
Throws:
IOException - inherited from HBase Scan and HttpServletResponse.write
twitter4j.internal.org.json.JSONException - inherited JSONObject

setHBaseTablename

public void setHBaseTablename(String hbaseTablename)
Parameters:
hbaseTablename -

setHBaseColumnFamily

public void setHBaseColumnFamily(String hbaseColumnFamily)
Parameters:
hbaseColumnFamily -

setHBaseColumn

public void setHBaseColumn(String hbaseColumn)
Parameters:
hbaseColumn -

setTwitterstreamTablename

public void setTwitterstreamTablename(String twitterstreamTablename)
Parameters:
twitterstreamTablename -

setHTablePoolHandler

public void setHTablePoolHandler(HTablePoolHandler handler)
Parameters:
handler -

setExportService

public void setExportService(TwitterVectorExporter exportService)
Parameters:
exportService -


Copyright © 2011. All Rights Reserved.