Skip to content

Commit

Permalink
Do not open database connections when in no-database mode
Browse files Browse the repository at this point in the history
fix #5
  • Loading branch information
mpartio committed Apr 1, 2021
1 parent 2f3247b commit 2638410
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions himan-lib/source/json_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,36 +1346,39 @@ void TargetProducer(const boost::property_tree::ptree& pt, const shared_ptr<conf
long pid = stol(tp.get());
producer prod(pid);

auto r = GET_PLUGIN(radon);
auto prodInfo = r->RadonDB().GetProducerDefinition(static_cast<unsigned long>(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<unsigned long>(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<HPProducerClass>(stoi(prodInfo["producer_class"])));
}
}
else
else if (conf->DatabaseType() != kNoDatabase)
{
prod.Class(static_cast<HPProducerClass>(stoi(prodInfo["producer_class"])));
itsLogger.Warning("Unknown target producer: " + pt.get<string>("target_producer"));
}
}
else if (conf->DatabaseType() != kNoDatabase)
{
itsLogger.Warning("Unknown target producer: " + pt.get<string>("target_producer"));
}
conf->TargetProducer(prod);
}
}
Expand Down

0 comments on commit 2638410

Please sign in to comment.