10 #include <boost/lexical_cast.hpp>
12 #include <atm/ALidarSQLManager.h>
13 #include <det/Detector.h>
14 #include <utl/ErrorLogger.h>
15 #include <utl/TimeStamp.h>
16 #include <utl/AugerException.h>
17 #include <utl/StringCompare.h>
27 ALidarSQLManager::ALidarSQLManager() :
30 const char*
const tables[] = {
31 "VAOD",
"authors",
"cloud",
"lidar",
"lidar_zone",
"software",
34 const int n =
sizeof(tables) /
sizeof(tables[0]);
41 const std::string& columnName,
50 if (tableName ==
"lidar") {
55 query <<
"SELECT lidar_id "
57 "WHERE start_time <= \"" << detTime.
GetGPSSecond() <<
"\" "
59 "OR end_time IS NULL) ORDER BY last_modified DESC, start_time DESC LIMIT 1";
63 query <<
"SELECT lidar_id "
64 "FROM lidar, software "
65 "WHERE start_time <= \"" << detTime.
GetGPSSecond() <<
"\" "
67 "OR end_time IS NULL) "
68 "AND lidar.software_id = software.software_id "
70 "ORDER BY lidar.last_modified DESC, start_time DESC LIMIT 1";
73 }
else if (tableName ==
"zone") {
75 if (componentIndex.find(
"zone_id") == componentIndex.end()) {
76 ERROR(
"request for zone data called with no zone_id");
78 boost::lexical_cast<string>(Detector::GetInstance().GetTime()));
80 query <<
"SELECT " << columnName <<
" "
82 "WHERE zone_id = " << componentIndex.find(
"zone_id")->second;
95 query <<
"SELECT " << columnName <<
" "
96 "FROM " << tableName <<
" "
106 const std::string& columnName,
110 if (tableName ==
"zone") {
113 if (componentIndex.find(
"lidar_id") == componentIndex.end()) {
114 DEBUGLOG(
"no lidar_id specified when looking up zone names");
115 return VManager::eNotFound;
119 query <<
"SELECT zone." << columnName <<
" FROM zone,lidar_zone "
120 "WHERE lidar_id = " << componentIndex.find(
"lidar_id")->second <<
" "
121 "AND lidar_zone.zone_id = zone.zone_id;";
131 query <<
"SELECT " << columnName <<
" "
132 "FROM " << tableName <<
" "
std::string fDatabaseSoftwareVersion
virtual Status GetDBResFundamental(const std::string &tableName, const std::string &columnName, const IndexMap &componentIndex) const
overload this in all derived managers that need it
bool StringEquivalent(const std::string &a, const std::string &b, Predicate p)
Utility to compare strings for equivalence. It takes a predicate to determine the equivalence of indi...
A TimeStamp holds GPS second and nanosecond for some event.
std::set< std::string > fAvailableComponents
Interface for detector managers that use MySQL.
Exception to use in case requested data not found in the database with detailed printout.
#define REGISTER_A_MANAGER(_name_, _Type_)
#define DEBUGLOG(message)
Macro for logging debugging messages.
virtual Status GetDBResVector(const std::string &tableName, const std::string &columnName, const IndexMap &componentIndex) const
overload this in all derived managers that need it
Manager for lidar portion of atmospheric monitoring database.
unsigned long GetGPSSecond() const
GPS second.
std::map< std::string, std::string > IndexMap
Status Query(const std::ostringstream &os, const std::string &what="") const
query MySQL
static std::string MergeIndexMap(const IndexMap &componentIndex)
Status
Specifies success or (eventually) various possible failure modes.