Skip to content

Commit

Permalink
Merge pull request #1659 from raphaelrpl/fix_grid_analysis_reprocessing
Browse files Browse the repository at this point in the history
Fix grid analysis reprocessing
  • Loading branch information
raphaelrpl authored Feb 26, 2019
2 parents ee76c50 + bfe1a5c commit c4cd1f7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/terrama2/core/data-model/Filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ namespace terrama2
std::string joinableTable; //! Table to perform inner join. Used when both monitored identifier and additional identififer supplied.
std::string monitoredIdentifier; //! Monitored attribute name to execute SQL JOIN while performing operation
std::string additionalIdentifier; //! Additional attribute name to execute SQL join while performing operation
bool isReprocessingHistoricalData = false;

//operator bool() const { return dataSetId != 0; }
};
Expand Down
25 changes: 21 additions & 4 deletions src/terrama2/core/utility/FilterUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,31 @@ bool terrama2::core::isValidTimestamp(const Filter& filter, const std::shared_pt
{
if(filter.discardBefore)
{
if(*fileTimestamp < *filter.discardBefore)
return false;
// For reprocessing historical data
if (filter.isReprocessingHistoricalData)
{
if(*fileTimestamp < *filter.discardBefore)
return false;
}
else
{
if(!(*fileTimestamp > *filter.discardBefore))
return false;
}
}

if(filter.discardAfter)
{
if(*fileTimestamp > *filter.discardAfter)
return false;
if (filter.isReprocessingHistoricalData)
{
if(*fileTimestamp > *filter.discardAfter)
return false;
}
else
{
if(!(*fileTimestamp < *filter.discardAfter))
return false;
}
}

return true;
Expand Down
23 changes: 21 additions & 2 deletions src/terrama2/impl/DataAccessorGrADS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void terrama2::core::DataAccessorGrADS::retrieveDataCallback(const terrama2::cor
remover,
temporaryDirectoryURI.toString(QUrl::NormalizePathSegments).toStdString(),
folderMatched,
[processFile](const std::string& uri, const std::string& filename){
[processFile, controlFileFolderMask](const std::string& uri, const std::string& filename){
processFile(uri, filename);
QUrl url(QString::fromStdString(uri));
// remove file on finish processing
Expand All @@ -286,7 +286,26 @@ void terrama2::core::DataAccessorGrADS::retrieveDataCallback(const terrama2::cor
if (info.isDir())
{
QDir directoryToRemove(filePath);
directoryToRemove.removeRecursively();

if (controlFileFolderMask.find("%DD") != std::string::npos ||
controlFileFolderMask.find("%MM") != std::string::npos ||
controlFileFolderMask.find("%YYYY") != std::string::npos ||
controlFileFolderMask.find("%YY") != std::string::npos ||
controlFileFolderMask.find("%JJJ") != std::string::npos)
{
directoryToRemove.removeRecursively();
}
else
{
for(const auto& entity: directoryToRemove.entryInfoList(QDir::Files | QDir::NoDotAndDotDot))
{
if (!(entity.absoluteFilePath().endsWith(".ctl")))
{
QFile removeFile(entity.absoluteFilePath());
removeFile.remove();
}
}
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/terrama2/services/analysis/core/GridContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ std::map<std::string, double> terrama2::services::analysis::core::GridContext::g
{
auto reprocessingHistoricalData = analysis_->schedule.reprocessingHistoricalData;

filter.isReprocessingHistoricalData = true;
filter.discardBefore = reprocessingHistoricalData->startDate;
filter.discardAfter = reprocessingHistoricalData->endDate;
}
Expand Down
1 change: 1 addition & 0 deletions src/terrama2/services/analysis/core/grid/Operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ double terrama2::services::analysis::core::grid::sample(const std::string& dataS

filter.discardAfter = startTime;
filter.lastValues = std::make_shared<std::size_t>(1);
filter.isReprocessingHistoricalData = true;
}

auto datasets = dataSeries->datasetList;
Expand Down
2 changes: 1 addition & 1 deletion webapp/config/sample_instances/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"basePath": "/",
"port": 36000,
"defaultFilePathList": ["/home/<USER>/terrama2"],
"defaultExecutablePath": "/opt/terrama2/4.0.8/bin",
"defaultExecutablePath": "/opt/terrama2/4.0.9/bin",
"defaultExecutableName": "terrama2_service",
"disablePDF": true,
"debug": true,
Expand Down
4 changes: 2 additions & 2 deletions webapp/public/javascripts/angular/datetimepicker/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ define([
$scope.optionsTo = this.optionsTo;
$scope.optionsFrom = this.optionsFrom;
this.update = function (dateFrom, dateTo) {
this.optionsFrom.maxDate = dateTo;
this.optionsTo.minDate = dateFrom;
this.optionsFrom.maxDate = dateTo.set({ 'second': 0 });
this.optionsTo.minDate = dateFrom.set({ 'second': 0 });
};
// change datatimepicker locale when change plataform language
$scope.$on("LOCALE_UPDATED", function(event, args){
Expand Down

0 comments on commit c4cd1f7

Please sign in to comment.