bass.db
Class DB_Conn

java.lang.Object
  extended by bass.db.DB_Conn

public class DB_Conn
extends java.lang.Object

Provides several methods to fill the database

Version:
0.1
Author:
Fabian Winkhardt, Thomas Klein, Patrick Mai

Constructor Summary
DB_Conn()
           
 
Method Summary
static void deleteBand(int bandId)
          Deletes a band from the bands table
static void generateFriendsPerDayFile()
           
static void getActivityCurveData()
          Gets the registration dates for every band and the amount of bands registrated at those dates, writing them into a .txt file.
static org.jfree.data.time.TimeSeriesCollection getActivityCurveData(Gui theGui)
          Gets the data from both activity .txt files to creates 2 timelines.
static int getBandAmount()
          Deprecated.  
static int[] getBandIDs()
           
static java.lang.String getBandname(int id)
          Deprecated. not used anymore
static java.util.Hashtable<java.lang.Integer,DTO_BandWithPoints> getBandsOnFLists(DTO_Band[] ids, int points, java.util.Hashtable<java.lang.Integer,DTO_BandWithPoints> scoreList, Gui theGui)
          scans the friendlists of the specified bands for other bands and returns a hashtable with the new found bands, if you want to insert them in an existing hashtable use the param scorelist
static void getFriendData(BassNodeList friends)
          Get the additional data out of the db for the depth2 friends (friends of a friend in the mainbands friendlist)
static void getGenreFrequencyData()
          Getting the genre data (how many bands in each genre) out of the database and writing it into a .txt file for further use.
static org.jfree.data.category.DefaultCategoryDataset getGenreFrequencyData(Gui theGui, java.lang.String mode)
          Reading the genre Data out of two .txt files and generating a dataset with it.
static void getGenreGrowthData()
          Gets the registration dates for every band and groups them by genres (considering genre1-3).
static org.jfree.data.time.TimeSeriesCollection getGenreGrowthData(Gui theGui, java.lang.String[] genreArray)
          Reads the registrations dates for the genres given by the array from a .txt file and uses the data to generate a dataset
static void getHypeCurveData()
          Gets the registration dates for every band and and the amount of bands that registered on the particular date.
static org.jfree.data.time.TimeSeriesCollection getHypeCurveData(Gui theGui)
          Reads the registration dates and their amount of bands from a .txt file and generates a dataset
static void getLabelTypeData()
          Gets the label type from every band in the database, counts them and writes the data into a text file
static org.jfree.data.general.DefaultPieDataset getLabelTypeData(Gui theGui)
          Deprecated. not used, because the pie chart got kicked out of the label type chart
static void getLabelTypePerGenreData()
          Gets the percentages of the 3 different label types for every genre and the general percentages for all genres, Considering genre1-3.
static org.jfree.data.category.DefaultCategoryDataset getLabelTypePerGenreData(Gui theGui, java.lang.String mode)
          Gets the label type percentages from a .txt file and generates a DefaultCategoryDataset
static org.jfree.data.general.DefaultPieDataset getLongTailData(Gui theGui)
          Deprecated.  
static org.jfree.data.general.DefaultPieDataset getLongTailDataHardCoded(Gui theGui)
          Using the hardcoded values (amount of bands grouped by their amount of fans) to create the dataset for a standard pie chart.
static DTO_BandWithFPD[] getTopBands(Gui theGui, int rankMode, java.lang.String genre)
          Reads the Top 100 Bands (or less if there are not 100 bands for the specific ranking) for 1 of the 5 ranking methods (by fans, plays, views, membership and friends per day) and creates an array of DTO_BandWithFPD
static java.util.LinkedList<DTO_Band> searchBands(java.lang.String searchString, boolean exactSearch)
          searches the db for bandnames including the specified string
static java.util.LinkedList<DTO_BandnameWithFList> selectBandWithFriends1(java.lang.String mainBand, int minFriends, int depth, Gui theGui)
          Get the band out of the DB including the friends that are connected (first level friends only)
static void writeProfilesToDb(java.util.LinkedList<DTO_Profile> profiles)
          updates the band data with the data parsed from profiles
static void writeToDb(DTO_Band band)
          Generates a query and executes it to write the specific band data into the database (crawler usuage)
static void writeToDb(DTO_FList flist)
          writes the given friendlist to the db
static void writeToDb(java.util.LinkedList<DTO_Band> bands)
          Iterates the given list of DTOs and writes them to the db (crawler usuage)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DB_Conn

public DB_Conn()
Method Detail

writeToDb

public static void writeToDb(DTO_Band band)
Generates a query and executes it to write the specific band data into the database (crawler usuage)

Parameters:
band -

writeToDb

public static void writeToDb(java.util.LinkedList<DTO_Band> bands)
Iterates the given list of DTOs and writes them to the db (crawler usuage)

Parameters:
bands - the band list

getBandIDs

public static int[] getBandIDs()
Returns:
a bunch of band id's (this method is changed a few times while crawling, so there's no constant use) (crawler usuage)

writeToDb

public static void writeToDb(DTO_FList flist)
writes the given friendlist to the db

Parameters:
flist - the friendlist ... (crawler usuage)

writeProfilesToDb

public static void writeProfilesToDb(java.util.LinkedList<DTO_Profile> profiles)
updates the band data with the data parsed from profiles

Parameters:
profiles - a list of profile data DTO's (crawler usuage)

selectBandWithFriends1

public static java.util.LinkedList<DTO_BandnameWithFList> selectBandWithFriends1(java.lang.String mainBand,
                                                                                 int minFriends,
                                                                                 int depth,
                                                                                 Gui theGui)
Get the band out of the DB including the friends that are connected (first level friends only)

Parameters:
mainBand: - the band the user want to visualize
minFriends: - the user selected minimum amount of friends (included the nonbands) of the target band (and it's friends)
Returns:
a LinkedList of the type DTO_BandnameWithFList

getFriendData

public static void getFriendData(BassNodeList friends)
Get the additional data out of the db for the depth2 friends (friends of a friend in the mainbands friendlist)

Parameters:
mainBand: - the band the user want to visualize
minFriends: - the user selected minimum amount of friends (included the nonbands) of the target band (and it's friends)

getLongTailData

public static org.jfree.data.general.DefaultPieDataset getLongTailData(Gui theGui)
Deprecated. 

Getting the amount of bands from the DB and seperating them into several groups depending how many fans the bands have. This data is used to create the dataset for a standard pie chart. However this method is not used anymore, the time it took to get the data from our DB was way too long. The final values are hardcoded in getLongTailDataHardCoded

Parameters:
theGui - used for (re)setting the Gui's progress bar
Returns:
DefaultPieDataset the generated dataset to create a pie chart out of the gathered data

getLongTailDataHardCoded

public static org.jfree.data.general.DefaultPieDataset getLongTailDataHardCoded(Gui theGui)
Using the hardcoded values (amount of bands grouped by their amount of fans) to create the dataset for a standard pie chart.

Parameters:
theGui - used for (re)setting the Gui's progress bar
Returns:
DefaultPieDataset the generated dataset to create a pie chart out of the gathered data

getGenreFrequencyData

public static void getGenreFrequencyData()
Getting the genre data (how many bands in each genre) out of the database and writing it into a .txt file for further use.


getGenreFrequencyData

public static org.jfree.data.category.DefaultCategoryDataset getGenreFrequencyData(Gui theGui,
                                                                                   java.lang.String mode)
Reading the genre Data out of two .txt files and generating a dataset with it.

Parameters:
theGui - used for (re)setting the Gui's progress bar
mode - used to determine how the genres should be ordererd (which .txt files to use) "all" for all crawled bands or "used" for the bands we finally used for our project
Returns:
DefaultCategoryDataset the generated dataset to create a chart

searchBands

public static java.util.LinkedList<DTO_Band> searchBands(java.lang.String searchString,
                                                         boolean exactSearch)
searches the db for bandnames including the specified string

Parameters:
searchString - word(s) to search for
Returns:
a linked list with DTO_Bands(only id & name are filled) or an empty linked list if search has no result (method is using the embedded DB!)

getBandsOnFLists

public static java.util.Hashtable<java.lang.Integer,DTO_BandWithPoints> getBandsOnFLists(DTO_Band[] ids,
                                                                                         int points,
                                                                                         java.util.Hashtable<java.lang.Integer,DTO_BandWithPoints> scoreList,
                                                                                         Gui theGui)
scans the friendlists of the specified bands for other bands and returns a hashtable with the new found bands, if you want to insert them in an existing hashtable use the param scorelist

Parameters:
ids - ths list of bands id's whose friendlists should be scanned
points - points to give to the found bands
scoreList - if this param is not null new found bands will be inserted here, if you leave it null a new hashtable will be created
theGui - the refernce to the gui, so progressbar etc can be set
Returns:
a Hashtable of the new found bands, or your specified table with the new bands added (method is using the embedded db!)

getBandAmount

public static int getBandAmount()
Deprecated. 

Getting the amount of bands from the database (apparently not used anymore so -> deprecated)

Returns:
int - the amount of bands in the database

getGenreGrowthData

public static void getGenreGrowthData()
Gets the registration dates for every band and groups them by genres (considering genre1-3). Writing the gathered data to a .txt file for further usage.


getGenreGrowthData

public static org.jfree.data.time.TimeSeriesCollection getGenreGrowthData(Gui theGui,
                                                                          java.lang.String[] genreArray)
Reads the registrations dates for the genres given by the array from a .txt file and uses the data to generate a dataset

Parameters:
theGui - used for (re)setting the progress bar
genreArray - an array of genres for which the time data will be considered
Returns:
TimeSeriesCollection - the generated dataset to create a chart

getBandname

public static java.lang.String getBandname(int id)
Deprecated. not used anymore

finds the band name for the specified id

Parameters:
id - the band id
Returns:
the band name

getLabelTypeData

public static void getLabelTypeData()
Gets the label type from every band in the database, counts them and writes the data into a text file


getLabelTypeData

public static org.jfree.data.general.DefaultPieDataset getLabelTypeData(Gui theGui)
Deprecated. not used, because the pie chart got kicked out of the label type chart

Getting the label type data from statData.labelType.txt and generating a DefaultPieDataset out of this data

Parameters:
theGui -
Returns:
dataset generated from the data

getLabelTypePerGenreData

public static void getLabelTypePerGenreData()
Gets the percentages of the 3 different label types for every genre and the general percentages for all genres, Considering genre1-3. Writes the gathered data to a .txt file.


getLabelTypePerGenreData

public static org.jfree.data.category.DefaultCategoryDataset getLabelTypePerGenreData(Gui theGui,
                                                                                      java.lang.String mode)
Gets the label type percentages from a .txt file and generates a DefaultCategoryDataset

Parameters:
theGui - used for (re)setting the progress bar
mode - used to switch between 2 possible ways of sorting the genres ("alpha" -> alphabetical, "freq" -> popularity/frequency)
Returns:
DefaultCategoryDataset - the generated dataset to create a chart

getHypeCurveData

public static void getHypeCurveData()
Gets the registration dates for every band and and the amount of bands that registered on the particular date. Writing the data to a .txt file.


getHypeCurveData

public static org.jfree.data.time.TimeSeriesCollection getHypeCurveData(Gui theGui)
Reads the registration dates and their amount of bands from a .txt file and generates a dataset

Parameters:
theGui - used for (re)setting the progress bar
Returns:
TimeSeriesCollection - the generated dataset to create a chart

getActivityCurveData

public static void getActivityCurveData()
Gets the registration dates for every band and the amount of bands registrated at those dates, writing them into a .txt file. Also gets the last login dates for every band and the amount of bands that didn't login since that date and writing them into another .txt file. (only considering bands to be inactive if their last login date is more than 1 month before we gathered the data.)


getActivityCurveData

public static org.jfree.data.time.TimeSeriesCollection getActivityCurveData(Gui theGui)
Gets the data from both activity .txt files to creates 2 timelines. One for the amount of registered bands and another one for the amount of bands that we consider to be inactive (last login more than 1 month ago) Generates a dataset out of those 2 timelines.

Parameters:
theGui - used for (re)setting the progress bar
Returns:
TimeSeriesCollection - the generated dataset to create a chart

deleteBand

public static void deleteBand(int bandId)
Deletes a band from the bands table

Parameters:
bandId -

getTopBands

public static DTO_BandWithFPD[] getTopBands(Gui theGui,
                                            int rankMode,
                                            java.lang.String genre)
Reads the Top 100 Bands (or less if there are not 100 bands for the specific ranking) for 1 of the 5 ranking methods (by fans, plays, views, membership and friends per day) and creates an array of DTO_BandWithFPD

Parameters:
theGui - - used for (re)setting the progess abr
rankMode - - the kind of ranking used (fans,plays,views,membership,friends per day)
genre - - the selected genre
Returns:
DTO_BandWithFPD[] - an array of 100 (or less) DTOs

generateFriendsPerDayFile

public static void generateFriendsPerDayFile()