-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsourceTable.cpp
More file actions
106 lines (93 loc) · 2.62 KB
/
sourceTable.cpp
File metadata and controls
106 lines (93 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <stdlib.h>
#include <string>
#include <pqxx/pqxx>
#include "../structuredLogger/structuredLogger.h"
#include "sourceTable.h"
/**
** id big-serial
** source_spec var char
** collection_id int
** date_range date_range
**SELECT '[2012-03-28, 2012-04-02]'::daterange;
** host_id foreign key
** starting_time time
** ending_time time
**/
/// \version $Revision: $
/// \date $Date: $
/// \file sourceTable.cpp
/// \class sourceTable
///\fn sourceTable
///\arg none
///\arg pqxx::conection * dbc
///\arg std::string query
///\brief execute the provided query
///\brief could also be the result of a union ???
sourceTable::sourceTable()
{
//ctor
}
sourceTable::sourceTable(pqxx::connection *dbc) : genericTable(dbc)
{
std::string t("source");
retriveTableMetadata(t);
}
sourceTable::sourceTable(std::string & db_connection ) : genericTable(db_connection)
{
std::string t("source");
retriveTableMetadata(t);
}
sourceTable::~sourceTable()
{
//dtor
}
///\fn init
///\arg none
///\brief load field names
void sourceTable::init()
{
std::string t("source");
retriveTableMetadata(t);
}
///\fn fillrecord
///\arg std::string source spec
///\arg int collection_id
///\arg std::string date_range
///\arg std::string start_time
///\arg std::string end_time
///\brief load data string vector, but do not save to table as we may not have all values
void sourceTable::fillrecord(std::string &src,
long collect_id,
std::string &date_range,
std::string &start_time,
std::string &end_time)
{
if (! src.empty()) {
storeValue((int)stenum::spec,(void *)src.c_str());
}
if (collect_id != 0) {
storeValue((int)stenum::collection,(void*) &collect_id);
}
if (! start_time.empty()){
storeValue((int)stenum::startT,(void*)start_time.c_str());
}
if (! date_range.empty()){
storeValue((int)stenum::range,(void*)date_range.c_str());
}
if (! end_time.empty()) {
storeValue((int)stenum::endT,(void*)end_time.c_str());
}
}
bool sourceTable::store()
{
std::string b;
std::vector<std::string> fields{ m_fields[(int)stenum::spec],
m_fields[(int)stenum::collection],
m_fields[(int)stenum::range],
m_fields[(int)stenum::startT],
m_fields[(int)stenum::endT]
};
long prkey=genericTable::writeStored(mp_dbc,fields);
storeValue((int)stenum::id,(void*)&prkey);
return true;
}