AOverallQualitySQLManager.cc
Go to the documentation of this file.
1 
9 #include <sstream>
10 
11 #include <atm/AOverallQualitySQLManager.h>
12 #include <fwk/CentralConfig.h>
13 #include <det/Detector.h>
14 #include <utl/ErrorLogger.h>
15 #include <utl/TimeStamp.h>
16 #include <utl/Reader.h>
17 #include <utl/StringCompare.h>
18 
19 using namespace std;
20 using namespace atm;
21 using namespace det;
22 
23 
24 REGISTER_A_MANAGER("AOverallQualitySQLManager", AOverallQualitySQLManager);
25 
26 
28 AOverallQualitySQLManager::GetDBResFundamental(const std::string& tableName,
29  const std::string& columnName,
30  const IndexMap&)
31  const
32 {
33  const utl::TimeStamp detTime = Detector::GetInstance().GetTime();
34 
35  ostringstream query;
36 
37  // aerosol table is a special case, as it requires checking software version
38  if (tableName == "overall_quality") {
39 
40  if (utl::StringEquivalent(fDatabaseSoftwareVersion, "default"))
41  // do NOT check software version
42 
43  query << "SELECT " << columnName << " "
44  "FROM overall_quality "
45  "WHERE start_time <= \"" << detTime.GetGPSSecond() << "\" "
46  "AND (end_time > \"" << detTime.GetGPSSecond() << "\" "
47  "OR end_time IS NULL) ORDER BY last_modified DESC, start_time DESC LIMIT 1";
48 
49  else // DO check software version
50 
51  query << "SELECT " << columnName << " "
52  "FROM overall_quality,software "
53  "WHERE start_time <= \"" << detTime.GetGPSSecond() << "\" "
54  "AND (end_time > \"" << detTime.GetGPSSecond() << "\" "
55  "OR end_time IS NULL) AND "
56  "overall_quality.software_id = software.software_id "
57  "AND software.software_version = \"" << fDatabaseSoftwareVersion << "\" "
58  "ORDER BY overall_quality.last_modified DESC, start_time DESC LIMIT 1";
59 
60  return Query(query, QueryInfoMessage(tableName, columnName));
61 
62  }
63 
64  return eNotFound;
65 
66 }
67 
68 
69 // Configure (x)emacs for this file ...
70 // Local Variables:
71 // mode: c++
72 // End:
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...
Definition: StringCompare.h:38
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
#define REGISTER_A_MANAGER(_name_, _Type_)
unsigned long GetGPSSecond() const
GPS second.
Definition: TimeStamp.h:124
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
Manager for aerosol portion of atmospheric monitoring database.
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127

, generated on Tue Sep 26 2023.