1 #include <atm/AAerosolSQLManager.h>
2 #include <atm/AManagerRegister.h>
3 #include <det/Detector.h>
4 #include <utl/ErrorLogger.h>
5 #include <utl/TimeStamp.h>
6 #include <utl/AugerException.h>
7 #include <utl/StringCompare.h>
9 #include <boost/lexical_cast.hpp>
21 AAerosolSQLManager::AAerosolSQLManager() :
25 "aerosol",
"aerosol_zone",
"attenuation",
"attenuation_lambda",
"authors",
26 "db_header",
"phase_func",
"phase_func_lambda",
"software",
34 const string& columnName,
43 if (tableName ==
"aerosol") {
47 query <<
"SELECT aerosol_id "
49 "WHERE start_time <= \"" << detTime.
GetGPSSecond() <<
"\" "
51 "OR end_time IS NULL) ORDER BY last_modified DESC, start_time DESC LIMIT 1";
55 query <<
"SELECT aerosol_id "
56 "FROM aerosol, software "
57 "WHERE start_time <= \"" << detTime.
GetGPSSecond() <<
"\" "
59 "OR end_time IS NULL) "
60 "AND aerosol.software_id = software.software_id "
62 "ORDER BY aerosol.last_modified DESC, start_time DESC LIMIT 1";
65 }
else if (tableName ==
"zone") {
67 if (componentIndex.find(
"zone_id") == componentIndex.end()) {
68 ERROR(
"request for zone data called with no zone_id");
70 boost::lexical_cast<string>(Detector::GetInstance().GetTime()));
72 query <<
"SELECT " << columnName <<
" "
74 "WHERE zone_id = " << componentIndex.find(
"zone_id")->second;
86 query <<
"SELECT " << columnName <<
" "
87 "FROM " << tableName <<
" "
98 const string& columnName,
104 if (tableName ==
"zone") {
107 if (componentIndex.find(
"aerosol_id") == componentIndex.end()) {
108 DEBUGLOG(
"no aerosol_id specified when looking up zone names");
109 return VManager::eNotFound;
113 query <<
"SELECT zone." << columnName <<
" FROM zone,aerosol_zone "
114 "WHERE aerosol_id = " << componentIndex.find(
"aerosol_id")->second <<
" "
115 "AND aerosol_zone.zone_id = zone.zone_id;";
125 query <<
"SELECT " << columnName <<
" "
126 "FROM " << tableName <<
" "
Manager for aerosol portion of atmospheric monitoring database.
virtual Status GetDBResFundamental(const std::string &tableName, const std::string &columnName, const VManager::IndexMap &componentIndex) const
std::string fDatabaseSoftwareVersion
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.
virtual Status GenericGetData(VManager::Handle &returnData, const std::string &component, const std::string &property, const VManager::IndexMap &) const
#define REGISTER_A_MANAGER(_name_, _Type_)
static std::string QueryInfoMessage(const Handle &returnData, const std::string &component)
#define DEBUGLOG(message)
Macro for logging debugging messages.
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)
virtual Status GetDBResVector(const std::string &tableName, const std::string &columnName, const VManager::IndexMap &componentIndex) const
Status
Specifies success or (eventually) various possible failure modes.