Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

EventDatabase.C File Reference

#include <stdlib.h>
#include <string>
#include <sstream>
#include "EventDatabase.H"
#include "Event.H"
#include <postgresql/libpq-fe.h>
#include <iostream>

Defines

#define CONNINFO   "hostaddr=138.16.41.179 dbname=geoevents user=ychatura password=ychatura"
 define the arguments needed to connect to the geoevents database

Functions

void openConnection (char *cinfo)
void closeConnection ()
void processQuery (PGconn *connection, string query_text)
string makeValidString (string name)
string d2String (double val, int count)
string catToString (Event::EventCategory cat)
string getCategoriesString (list< Event::EventCategory > cat_list)
string time2timeString (string date_time_str)
string time2dateString (string date_time_str)
string testgetOid (string table_name)
string getDuplicateOid (bool &is_dup, string table, Event ev)
string getOid (bool &is_dup, string table_name, Event ev)
void mergeEvents (string oid, Event ev)
bool singlePut (Event ev)

Variables

PGconn * conn
 a connection to database server

Detailed Description

Author:
ychatura
Date:
05-05-06

Function Documentation

string catToString Event::EventCategory  cat  ) 
 

convert from EventCategory type to string

Parameters:
cat the category type to be turned into string
Returns:
categories as string

void closeConnection  ) 
 

close connection to database

string d2String double  val,
int  count
 

convert from type double of length count to string

Parameters:
val a double to be turned into string
count the length of double to be turned into string
Returns:
string representation of double

string getCategoriesString list< Event::EventCategory cat_list  ) 
 

convert the list of catagories into string

Returns:
string in the form {cat1,cat2,...}
Parameters:
cat_list list of event categories to be converted into string

string getDuplicateOid bool &  is_dup,
string  table,
Event  ev
 

the event to be put in is a duplicate so need to find it's id by querying for the same event in the database

Parameters:
is_dup reference to boolean, it will be set to true if the info of ev exist in ttable
table name of table to search for event info
ev event that we want to check if it is a duplicate
Returns:
string represent id of the event

string getOid bool &  is_dup,
string  table_name,
Event  ev
 

find the id for an event

string makeValidString string  name  ) 
 

Any string that has apostrophe can't be query into database directly without braking it. So need to add change them by adding another ' so the query works

Parameters:
name string to be used in sql query
Returns:
sql query string

void mergeEvents string  oid,
Event  ev
 

merge info of the same event if either the catagories aren't match, the url is missing or the description is missing.

Parameters:
oid id of the event already the database to be merged with
ev new event to be merged

void openConnection char *  cinfo  ) 
 

open connection to database with connection arguments passed in as char*

Parameters:
cinfo char* of connection info

void processQuery PGconn *  connection,
string  query_text
 

execute a query

Parameters:
connection PQconn that is connected to the database
query_text string that represents the sql query

bool singlePut Event  ev  ) 
 

put a single tuple into corresponding table

Parameters:
ev event to be put in database
Returns:
true if ev is successfully stored and false otherwise

string testgetOid string  table_name  ) 
 

get id for the tuple to be put into table The id must be unique and starts at 0. The id the number of the tuples already in the database (unless some other events already assigned that number

Parameters:
table_name (event or location or time)
Returns:
string representing id

string time2dateString string  date_time_str  ) 
 

get just the date portion(yyyy-mm-dd) of the date/time string of time_t

Parameters:
date_time_str string representation of time_t
Returns:
string representing date (yyyy-mm-dd)

string time2timeString string  date_time_str  ) 
 

get just the time portion(hh:mm:ss) from the date/time string of time_t

Parameters:
date_time_str string representation of time_t
Returns:
string representing time (hh:mm:ss)


Generated on Wed May 17 22:28:20 2006 for GeoEvents by  doxygen 1.4.2