From 2638410904c2f004c1fd0ec61cf64aff2924b20a Mon Sep 17 00:00:00 2001 From: Mikko Partio Date: Thu, 1 Apr 2021 07:59:08 +0300 Subject: [PATCH] Do not open database connections when in no-database mode fix #5 --- himan-lib/source/json_parser.cpp | 47 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/himan-lib/source/json_parser.cpp b/himan-lib/source/json_parser.cpp index 4cc367b00..89db37a2e 100644 --- a/himan-lib/source/json_parser.cpp +++ b/himan-lib/source/json_parser.cpp @@ -1346,36 +1346,39 @@ void TargetProducer(const boost::property_tree::ptree& pt, const shared_ptrRadonDB().GetProducerDefinition(static_cast(pid)); - - if (!prodInfo.empty()) + if (conf->DatabaseType() != kNoDatabase) { - if (prodInfo["ident_id"].empty() || prodInfo["model_id"].empty()) - { - itsLogger.Warning("Centre or ident information not found for producer " + prodInfo["ref_prod"]); - } - else + auto r = GET_PLUGIN(radon); + auto prodInfo = r->RadonDB().GetProducerDefinition(static_cast(pid)); + + if (!prodInfo.empty()) { - prod.Centre(stol(prodInfo["ident_id"])); - prod.Process(stol(prodInfo["model_id"])); - } + if (prodInfo["ident_id"].empty() || prodInfo["model_id"].empty()) + { + itsLogger.Warning("Centre or ident information not found for producer " + prodInfo["ref_prod"]); + } + else + { + prod.Centre(stol(prodInfo["ident_id"])); + prod.Process(stol(prodInfo["model_id"])); + } - prod.Name(prodInfo["ref_prod"]); + prod.Name(prodInfo["ref_prod"]); - if (prodInfo["producer_class"].empty()) - { - prod.Class(kGridClass); + if (prodInfo["producer_class"].empty()) + { + prod.Class(kGridClass); + } + else + { + prod.Class(static_cast(stoi(prodInfo["producer_class"]))); + } } - else + else if (conf->DatabaseType() != kNoDatabase) { - prod.Class(static_cast(stoi(prodInfo["producer_class"]))); + itsLogger.Warning("Unknown target producer: " + pt.get("target_producer")); } } - else if (conf->DatabaseType() != kNoDatabase) - { - itsLogger.Warning("Unknown target producer: " + pt.get("target_producer")); - } conf->TargetProducer(prod); } }