Skip to content

Commit

Permalink
Merge pull request #1614 from janosimas/b4.0.7
Browse files Browse the repository at this point in the history
fix updating project data
  • Loading branch information
janosimas authored Aug 24, 2018
2 parents bea6210 + 2edb5aa commit cb357a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/terrama2/core/data-model/DataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ terrama2::core::DataProviderPtr terrama2::core::DataManager::findDataProvider(co
return it->second;
}

bool terrama2::core::DataManager::hasProject(ProjectId id) const
{
std::lock_guard<std::recursive_mutex> lock(mtx_);

const auto& it = projects_.find(id);
return it != projects_.cend();
}

bool terrama2::core::DataManager::hasDataProvider(DataProviderId id) const
{
std::lock_guard<std::recursive_mutex> lock(mtx_);
Expand Down Expand Up @@ -470,7 +478,7 @@ void terrama2::core::DataManager::addJSon(const QJsonObject& obj)
for(auto json : projects)
{
auto dataPtr = terrama2::core::fromProjectJson(json.toObject());
if(hasDataProvider(dataPtr->id))
if(hasProject(dataPtr->id))
update(dataPtr);
else
add(dataPtr);
Expand Down
11 changes: 11 additions & 0 deletions src/terrama2/core/data-model/DataManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ namespace terrama2
*/
virtual DataProviderPtr findDataProvider(const DataProviderId id) const;

/*!
\brief Verify if a given DataProvider exist
\param id ID of the DataProvider
\pre The DataProvider must not have a terrama2::core::InvalidId.
\note Thread-safe.
*/
virtual bool hasProject(ProjectId id) const;

/*!
\brief Verify if a given DataProvider exist
Expand Down

0 comments on commit cb357a3

Please sign in to comment.