예제 #1
0
RegisterId terrama2::core::ProcessLogger::start(ProcessId processId) const
{
  if(!isValid_)
    throw terrama2::core::LogException() << ErrorDescription("Error on log!");

  // send start to database
  if(tableName_.empty())
  {
    QString errMsg = QObject::tr("Can not find log table name");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  boost::format query("INSERT INTO "+ tableName_ + " (process_id, status, start_timestamp, last_process_timestamp) VALUES(%1%, %2%, '%3%', '%4%')");

  query.bind_arg(1, processId);
  query.bind_arg(2, static_cast<int>(Status::START));
  query.bind_arg(3, TimeUtils::nowUTC()->toString());
  query.bind_arg(4, TimeUtils::nowUTC()->toString());

  std::shared_ptr< te::da::DataSourceTransactor > transactor = dataSource_->getTransactor();
  transactor->execute(query.str());

  transactor->commit();

  return transactor->getLastGeneratedId();
}
예제 #2
0
ProcessId terrama2::core::ProcessLogger::processID(const RegisterId registerId) const
{
  if(!isValid_)
    throw terrama2::core::LogException() << ErrorDescription("Error on log!");

  if(tableName_.empty())
  {
    QString errMsg = QObject::tr("Can not find log table name. Is it setted?");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  std::string sql = "SELECT process_id FROM "+ tableName_ + " WHERE id = " + QString::number(registerId).toStdString();

  std::shared_ptr< te::da::DataSourceTransactor > transactor = dataSource_->getTransactor();

  std::shared_ptr<te::da::DataSet> tempDataSet(transactor->query(sql));

  if(!tempDataSet)
  {
    QString errMsg = QObject::tr("Can not find log message table name!");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  if(!tempDataSet->moveNext())
  {
    QString errMsg = QObject::tr("Error to access log message table!");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  return tempDataSet->getInt32("process_id");
}
예제 #3
0
std::shared_ptr< te::dt::TimeInstantTZ > terrama2::core::ProcessLogger::getDataLastTimestamp(const ProcessId processId) const
{
  if(!isValid_)
    throw terrama2::core::LogException() << ErrorDescription("Error on log!");

  if(tableName_.empty())
  {
    QString errMsg = QObject::tr("Can not find log table name. Is it setted?");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  std::string sql = "SELECT MAX(data_timestamp) FROM "+ tableName_ + " WHERE process_id = " + std::to_string(processId);

  std::shared_ptr< te::da::DataSourceTransactor > transactor = dataSource_->getTransactor();

  std::unique_ptr<te::da::DataSet> tempDataSet(transactor->query(sql));

  if(!tempDataSet)
    return nullptr;

  size_t columnPos = te::da::GetPropertyPos(tempDataSet.get(), "max");

  if(!tempDataSet->moveNext() || tempDataSet->isNull(columnPos))
    return nullptr;

  return std::shared_ptr< te::dt::TimeInstantTZ >(dynamic_cast<te::dt::TimeInstantTZ*>(tempDataSet->getDateTime(columnPos).release()));
}
void terrama2::core::DataAccessorOccurrenceCSV::checkFields(DataSetPtr dataSet) const
{
  bool dateTime = false;
  bool geometry = false;

  QJsonArray array = getFields(dataSet);

  for(auto item : array)
  {
    const QJsonObject& obj = item.toObject();

    int type = dataTypes.at(obj.value("type").toString().toStdString());

    if(type == te::dt::DATETIME_TYPE)
      dateTime = true;

    if(type == te::dt::GEOMETRY_TYPE)
      geometry = true;
  }

  if(!dateTime)
  {
    QString errMsg = QObject::tr("Invalid fields: Missing dateTime field!");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::DataAccessorException() << ErrorDescription(errMsg);
  }

  if(!geometry)
  {
    QString errMsg = QObject::tr("Invalid fields: Missing geometry field!");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::DataAccessorException() << ErrorDescription(errMsg);
  }
}
예제 #5
0
void
terrama2::core::ProcessLogger::log(MessageType messageType, const std::string &description, RegisterId registerId) const
{
  if(!isValid_)
    throw terrama2::core::LogException() << ErrorDescription("Error on log!");

  if(tableName_.empty() || messagesTableName_.empty())
  {
    QString errMsg = QObject::tr("Can not find log tables names.");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  std::shared_ptr< te::dt::TimeInstantTZ> now(TimeUtils::nowUTC());

  std::string escapedDescription(description);
  // TODO: Remove it when terralib escape work properly
  std::replace(escapedDescription.begin(), escapedDescription.end(), '\'', ' ');

  boost::format queryMessages("INSERT INTO " + messagesTableName_ + " (log_id, type, description, timestamp) VALUES(" + QString::number(registerId).toStdString() + ", %1%, '%2%', '%3%')");
  queryMessages.bind_arg(1, static_cast<int>(messageType));
  queryMessages.bind_arg(2, escapedDescription);
  queryMessages.bind_arg(3, now->toString());

  std::shared_ptr< te::da::DataSourceTransactor > transactor = dataSource_->getTransactor();
  transactor->execute(transactor->escape(queryMessages.str()));

  transactor->commit();
}
예제 #6
0
terrama2::core::DataSetSeries terrama2::core::DataAccessorDcpToa5::getSeries(const std::string& uri,
        const terrama2::core::Filter& filter,
        terrama2::core::DataSetPtr dataSet) const

{
    std::string mask = getMask(dataSet);
    std::string folder = getFolder(dataSet);

    QTemporaryDir tempBaseDir;
    if(!tempBaseDir.isValid())
    {
        QString errMsg = QObject::tr("Can't create temporary folder.");
        TERRAMA2_LOG_ERROR() << errMsg;
        throw DataAccessException() << ErrorDescription(errMsg);
    }

    QDir tempDir(tempBaseDir.path());
    tempDir.mkdir(QString::fromStdString(folder));
    tempDir.cd(QString::fromStdString(folder));

    QUrl url((uri+"/"+folder+"/"+mask).c_str());
    QFileInfo originalInfo(url.path());

    QFile file(url.path());
    QFile tempFile(tempDir.path()+"/"+originalInfo.fileName());
    if(!file.open(QIODevice::ReadOnly))
    {
        QString errMsg = QObject::tr("Can't open file: dataset %1.").arg(dataSet->id);
        TERRAMA2_LOG_ERROR() << errMsg;
        throw DataAccessException() << ErrorDescription(errMsg);
    }

    if(!tempFile.open(QIODevice::ReadWrite))
    {
        QString errMsg = QObject::tr("Can't open temporary file: dataset %1.").arg(dataSet->id);
        TERRAMA2_LOG_ERROR() << errMsg;
        throw DataAccessException() << ErrorDescription(errMsg);
    }

    file.readLine();//ignore first line
    tempFile.write(file.readLine()); //headers line

    //ignore third and fourth lines
    file.readLine();
    file.readLine();

    //read all file
    tempFile.write(file.readAll()); //headers line

    //update file path
    std::string tempUri = "file://"+tempBaseDir.path().toStdString();

    file.close();
    tempFile.close();

    auto dataSeries = terrama2::core::DataAccessorFile::getSeries(tempUri, filter, dataSet);

    return dataSeries;
}
예제 #7
0
void terrama2::core::DataStoragerTiff::store(DataSetSeries series, DataSetPtr outputDataSet) const
{
  if(!outputDataSet.get() || !series.syncDataSet.get())
  {
    QString errMsg = QObject::tr("Mandatory parameters not provided.");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw DataStoragerException() << ErrorDescription(errMsg);
  }

  QUrl uri(QString::fromStdString(dataProvider_->uri));
  auto path = uri.path().toStdString();
  try
  {
    std::string mask = getMask(outputDataSet);

    auto dataset = series.syncDataSet->dataset();
    size_t rasterColumn = te::da::GetFirstPropertyPos(dataset.get(), te::dt::RASTER_TYPE);
    if(!isValidColumn(rasterColumn))
    {
      QString errMsg = QObject::tr("No raster attribute.");
      TERRAMA2_LOG_ERROR() << errMsg;
      throw DataStoragerException() << ErrorDescription(errMsg);
    }

    size_t timestampColumn = te::da::GetFirstPropertyPos(dataset.get(), te::dt::DATETIME_TYPE);

    dataset->moveBeforeFirst();
    while(dataset->moveNext())
    {
      std::shared_ptr<te::rst::Raster> raster(dataset->isNull(rasterColumn) ? nullptr : dataset->getRaster(rasterColumn).release());
      std::shared_ptr<te::dt::DateTime> timestamp;
      if(!isValidColumn(timestampColumn) || dataset->isNull(timestampColumn))
        timestamp = nullptr;
      else
        timestamp.reset(dataset->getDateTime(timestampColumn).release());

      if(!raster.get())
      {
        QString errMsg = QObject::tr("Null raster found.");
        TERRAMA2_LOG_ERROR() << errMsg;
        continue;
      }

      std::string filename = replaceMask(mask, timestamp, outputDataSet);

      std::string output = path + "/" + filename;
      te::rp::Copy2DiskRaster(*raster, output);
    }
  }
  catch(const DataStoragerException&)
  {
    throw;
  }
  catch(...)
  {
    //TODO: fix DataStoragerTiff catch
  }
}
예제 #8
0
std::vector<std::string> terrama2::core::CurlPtr::getListFiles(std::string url,
                                                               size_t(*write_vector)(void *ptr, size_t size, size_t nmemb, void *data),
                                                               std::string block)
{
  std::vector<std::string> vectorFiles;
  curl_easy_setopt(curl_, CURLOPT_URL, url.c_str());
  curl_easy_setopt(curl_, CURLOPT_DIRLISTONLY, 1);
  curl_easy_setopt(curl_, CURLOPT_WRITEFUNCTION, write_vector);
  curl_easy_setopt(curl_, CURLOPT_WRITEDATA, (void *)&block);

  CURLcode status = curl_easy_perform(curl_);

  if (status == CURLE_OK)
  {
    boost::split(vectorFiles, block, boost::is_any_of("\n"));

    if(!vectorFiles.empty() && vectorFiles.back().empty())
      vectorFiles.pop_back();
  }
  else
  {
    QString errMsg = QObject::tr("Could not list files in the FTP server. \n\n");
    errMsg.append(curl_easy_strerror(status));

    TERRAMA2_LOG_ERROR() << errMsg;
    throw DataRetrieverException() << ErrorDescription(errMsg);
  }

  return vectorFiles;
}
예제 #9
0
terrama2::core::DataSeriesSemantics terrama2::core::SemanticsManager::addSemantics(const std::string& code,
                                                                                   const std::string& name,
                                                                                   const DataSeriesType& dataSeriesType,
                                                                                   const DataSeriesTemporality& dataSeriesTemporality,
                                                                                   const DataFormat& format,
                                                                                   const std::vector<DataProviderType>& providersTypeList,
                                                                                   const std::unordered_map<std::string, std::string>& metadata)
{
  auto it = semanticsMap_.find(code);
  if(it != semanticsMap_.cend())
  {
    QString errMsg = QObject::tr("Semantics %1 already registered.").arg(name.c_str());
    TERRAMA2_LOG_ERROR() << errMsg.toStdString();
    throw terrama2::core::SemanticsException() << ErrorDescription(errMsg);
  }

  DataSeriesSemantics semantics;
  semantics.code = code;
  semantics.name = name;
  semantics.dataSeriesType = dataSeriesType;
  semantics.temporality = dataSeriesTemporality;
  semantics.dataFormat = format;
  semantics.providersTypeList = providersTypeList;
  semantics.metadata = metadata;

  semanticsMap_[code] = semantics;

  return semantics;
}
예제 #10
0
void terrama2::services::alert::core::AdditionalDataHelper::addAdditionalAttributesColumns(std::shared_ptr<te::da::DataSetType> alertDataSetType) const
{
  if(!isDataReady_)
  {
    throw AdditionalDataException() << ErrorDescription(QObject::tr("Data not loaded.\nCall AdditionalDataHelper::prepareData."));
  }

  for(const auto& data : dataMap_)
  {
    const auto& dataSet = data.first;
    const auto& dataSetSeries = data.second;

    for(const auto& attribute : additionalData_.attributes)
    {
      try
      {
        std::string name = dataSeries_->name+"_"+attribute+"_"+std::to_string(dataSet->id);
        auto teDataSetType = dataSetSeries.teDataSetType;
        auto property = teDataSetType->getProperty(attribute);
        auto newProperty = property->clone();
        newProperty->setName(name);
        alertDataSetType->add(newProperty);
      }
      catch(...)
      {
        TERRAMA2_LOG_WARNING() << QObject::tr("Attribute %1 not found in dataset %2").arg(QString::fromStdString(attribute)).arg(dataSet->id);
      }
    }
  }
}
예제 #11
0
void terrama2::services::alert::core::AdditionalDataHelper::addAdditionalValues(te::mem::DataSetItem* item, const std::string& fkValue) const
{
  if(!isDataReady_)
  {
    throw AdditionalDataException() << ErrorDescription(QObject::tr("Data not loaded.\nCall AdditionalDataHelper::prepareData."));
  }

  for(auto data : dataMap_)
  {
    const auto& dataSet = data.first;
    auto dataSetSeries = data.second;
    auto teDataSet = dataSetSeries.syncDataSet->dataset();

    auto mapper = mapperMap_.at(dataSet);


    for(const auto& attribute : additionalData_.attributes)
    {
      auto value = mapper->getValue(fkValue, attribute);

      std::string columnName = dataSeries_->name+"_"+attribute+"_"+std::to_string(dataSet->id);
      if(value.get())
        item->setValue(columnName, value->clone());
      else
        item->setValue(columnName, nullptr);
    }
  }
}
/* function: "write_png(bmp, path[, color_type, text_dict])\n
Writes the bitmap as a png at the given path.\n
Raises OSError on failure.\n
\n
Optional parameters:\n
 - color_type: A constant from the png-module (e.g. png.RGB_ALPHA)\n
 - text_dict: A dictionary of key-strings to value-strings\n
   for png tEXt meta-data."
name: "write_png" */
static void write_png_py(const FilePath& p,
  const Bitmap& bmp,
  const Optional<int>& rawColorType,
  const Optional<png_tEXt_map>& maybeTextChunks)
{
  const auto defaultType = static_cast<int>(PngColorType::RGB_ALPHA);

  const auto colorType =
    to_enum<PngColorType>(rawColorType.Or(defaultType)).Visit(
      [](const PngColorType t){
        return t;
      },
      []() -> PngColorType{
        throw ValueError("color_type out of range.");
      });

  auto r = maybeTextChunks.Visit(
    [&](const png_tEXt_map& textChunks){
      return write_png(p, bmp, colorType, textChunks);
    },
    [&](){
      return write_png(p, bmp, colorType);
    });

  if (!r.Successful()){
    throw OSError(r.ErrorDescription());
  }
}
// get generic socket error info string about last error
CTString CCommunicationInterface::GetSocketError(INDEX iError)
{
  CTString strError;
  strError.PrintF(TRANSV("Socket %d, Error %d (%s)"),
    cci_hSocket, iError, ErrorDescription(&SocketErrors, iError));
  return strError;
};
예제 #14
0
terrama2::core::DataRetrieverFTP::DataRetrieverFTP(DataProviderPtr dataprovider, CurlPtr&& curlwrapper)
  : DataRetriever(dataprovider),
    curlwrapper_(std::move(curlwrapper))
{
  temporaryFolder_ = "/tmp/terrama2-download/";
  scheme_ = "file://";

  // Create the directory where you will download the files.
  QDir dir(temporaryFolder_.c_str());
  if (!dir.exists())
    dir.mkpath(temporaryFolder_.c_str());

  CURLcode status;
  curlwrapper_.init();

  // Verifies that the FTP address is valid
  try
  {
    std::string url = dataprovider->uri.c_str();

    status = curlwrapper_.verifyURL(url);

    if (status != CURLE_OK)
    {
      QString errMsg = QObject::tr("FTP address is invalid. \n\n");
      errMsg.append(curl_easy_strerror(status));

      TERRAMA2_LOG_ERROR() << errMsg;
      throw DataRetrieverException() << ErrorDescription(errMsg);
    }
  }
  catch(const std::exception& e)
  {
    QString errMsg = QObject::tr("FTP address is invalid! \n\n Details: \n");
    errMsg.append(e.what());

    TERRAMA2_LOG_ERROR() << errMsg;
    throw DataRetrieverException() << ErrorDescription(errMsg);
  }
  catch(...)
  {
    throw DataRetrieverException() << ErrorDescription(QObject::tr("Unknown Error, FTP address is invalid!"));
  }

}
예제 #15
0
void terrama2::core::DataAccessorJsonCemaden::retrieveDataCallback(const DataRetrieverPtr /*dataRetriever*/,
                                                                    DataSetPtr /*dataSet*/,
                                                                    const Filter& /*filter*/,
                                                                    std::shared_ptr<FileRemover> /*remover*/,
                                                                    std::function<void(const std::string &, const std::string &)> /*processFile*/) const
{
  QString errMsg = QObject::tr("Invalid method call.");
  throw NotRetrivableException() << ErrorDescription(errMsg);
}
예제 #16
0
std::string terrama2::core::DataRetriever::retrieveData(const std::string& query,
                                                        const Filter& filter,
                                                        std::shared_ptr<terrama2::core::FileRemover> remover,
                                                        const std::string& temporaryFolder,
                                                        const std::string& folderPath)
{
  QString errMsg = QObject::tr("Non retrievable DataRetriever.");
  throw NotRetrivableException() << ErrorDescription(errMsg);
}
예제 #17
0
terrama2::core::DataRetriever::DataRetriever(DataProviderPtr dataProvider)
  : dataProvider_(dataProvider)
{
  if(!dataProvider_.get())
  {
    QString errMsg = QObject::tr("Mandatory parameters not provided.");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw DataRetrieverException() << ErrorDescription(errMsg);
  }
}
예제 #18
0
void terrama2::core::ProcessLogger::addValue(const std::string& tag, const std::string& value, RegisterId registerId) const
{
  if(!isValid_)
    throw terrama2::core::LogException() << ErrorDescription("Error on log!");

  if(tableName_.empty())
  {
    QString errMsg = QObject::tr("Can not find log table name. Is it setted?");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  std::string sql = "SELECT data FROM "+ tableName_ + " WHERE id = " + QString::number(registerId).toStdString();

  std::shared_ptr< te::da::DataSourceTransactor > transactor = dataSource_->getTransactor();

  std::shared_ptr<te::da::DataSet> tempDataSet(transactor->query(sql));

  if(!tempDataSet)
  {
    QString errMsg = QObject::tr("Can not find log message table name!");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  if(!tempDataSet->moveNext())
  {
    QString errMsg = QObject::tr("Error to access log message table!");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw terrama2::core::LogException() << ErrorDescription(errMsg);
  }

  QByteArray readJson = tempDataSet->getAsString("data").c_str();

  QJsonDocument docJson(QJsonDocument::fromJson(readJson));
  QJsonObject obj = docJson.object();
  QString qtag = QString::fromStdString(tag);
  QJsonArray array = obj[qtag].toArray();
  array.push_back(QString::fromStdString(value));
  obj.insert(qtag, array);

  updateData(registerId, obj);
}
terrama2::core::DataAccessorWildFireEvent::DataAccessorWildFireEvent(DataProviderPtr dataProvider, DataSeriesPtr dataSeries, const bool checkSemantics)
: DataAccessor(dataProvider, dataSeries),
  DataAccessorGeometricObjectOGR(dataProvider, dataSeries, false)
{
 if(checkSemantics && dataSeries->semantics.driver != dataAccessorType())
 {
   QString errMsg = QObject::tr("Wrong DataSeries semantics.");
   TERRAMA2_LOG_ERROR() << errMsg;
   throw WrongDataSeriesSemanticsException()  << ErrorDescription(errMsg);
 }
}
terrama2::core::DataAccessorStaticDataOGR::DataAccessorStaticDataOGR(DataProviderPtr dataProvider, DataSeriesPtr dataSeries, const Filter& filter)
: DataAccessor(dataProvider, dataSeries, filter),
  DataAccessorFile(dataProvider, dataSeries, filter)
{
 if(dataSeries->semantics.code != "STATIC_DATA-ogr")
 {
   QString errMsg = QObject::tr("Wrong DataSeries semantics.");
   TERRAMA2_LOG_ERROR() << errMsg;
   throw WrongDataSeriesSemanticsException()  << ErrorDescription(errMsg);
 }
}
예제 #21
0
terrama2::core::DataSeriesSemantics terrama2::core::SemanticsManager::getSemantics(const std::string& semanticsCode)
{
  auto it = semanticsMap_.find(semanticsCode);
  if(it == semanticsMap_.cend())
  {
    QString errMsg = QObject::tr("Semantics %1 not registered.").arg(semanticsCode.c_str());
    TERRAMA2_LOG_ERROR() << errMsg.toStdString();
    throw terrama2::core::SemanticsException() << ErrorDescription(errMsg);
  }

  return it->second;
}
terrama2::core::DataAccessorOccurrenceLightning::DataAccessorOccurrenceLightning(DataProviderPtr dataProvider, DataSeriesPtr dataSeries, const bool checkSemantics)
  : DataAccessor(dataProvider, dataSeries, false),
    DataAccessorOccurrence(dataProvider, dataSeries, false),
    DataAccessorFile(dataProvider, dataSeries, false)
{
  if(checkSemantics && dataSeries->semantics.code != dataAccessorType())
  {
    QString errMsg = QObject::tr("Wrong DataSeries semantics.");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw WrongDataSeriesSemanticsException() << ErrorDescription(errMsg);
  }
}
예제 #23
0
terrama2::core::DataAccessorGDAL::DataAccessorGDAL(DataProviderPtr dataProvider, DataSeriesPtr dataSeries, const bool checkSemantics)
 : DataAccessor(dataProvider, dataSeries),
   DataAccessorGrid(dataProvider, dataSeries),
   DataAccessorFile(dataProvider, dataSeries)
{
  if(checkSemantics && dataSeries->semantics.driver != dataAccessorType())
  {
    QString errMsg = QObject::tr("Wrong DataSeries semantics.");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw WrongDataSeriesSemanticsException()  << ErrorDescription(errMsg);
  }
}
예제 #24
0
void terrama2::services::alert::core::NotifierFactory::remove(const std::string& notifierCode)
{
  std::map<std::string, FactoryFnctType>::const_iterator it = factoriesMap_.find(notifierCode);
  if(it == factoriesMap_.end())
  {
    QString errMsg = QObject::tr("There is no registered notifier factory named : %1.").arg(QString::fromStdString(notifierCode));
    TERRAMA2_LOG_ERROR() << errMsg.toStdString();
    throw terrama2::services::alert::NotifierException() << ErrorDescription(errMsg);
  }

  factoriesMap_.erase(it);
}
예제 #25
0
void terrama2::services::alert::core::NotifierFactory::add(const std::string& notifierCode, FactoryFnctType f)
{
  auto it = factoriesMap_.find(notifierCode);
  if(it != factoriesMap_.end())
  {
    QString errMsg = QObject::tr("A notifier with this name already exists: %1.").arg(QString::fromStdString(notifierCode));
    TERRAMA2_LOG_ERROR() << errMsg.toStdString();
    throw terrama2::services::alert::NotifierException() << ErrorDescription(errMsg);
  }

  factoriesMap_[notifierCode] = f;
}
terrama2::core::DataAccessorStaticDataPostGIS::DataAccessorStaticDataPostGIS(DataProviderPtr dataProvider, DataSeriesPtr dataSeries, const bool checkSemantics)
 : DataAccessor(dataProvider, dataSeries, false),
   DataAccessorGeometricObject(dataProvider, dataSeries, false),
   DataAccessorPostGIS(dataProvider, dataSeries, false)
{
  if(checkSemantics && dataSeries->semantics.code != dataAccessorType())
  {
    QString errMsg = QObject::tr("Wrong DataSeries semantics.");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw WrongDataSeriesSemanticsException()  << ErrorDescription(errMsg);
  }
}
예제 #27
0
bool nifpga::HandleStatus(NiFpga_Status status) {
	lastStatus = status;
	if (status < 0) {
		std::cout << "[ERROR]: " << status << std::endl;
		std::cout << ErrorDescription(status) << std::endl;
		return false;
	}
	if (status > 0) {
		std::cout << "[WARNING]: " << status << std::endl;
	}
	return true;
}
예제 #28
0
파일: formatter.cpp 프로젝트: jklimke/logog
	LOGOG_STRING &FormatterGCC::Format( const Topic &topic )
	{

		TOPIC_FLAGS flags;
		flags = topic.GetTopicFlags();

		m_sMessageBuffer.clear();

		if ( flags & TOPIC_FILE_NAME_FLAG )
		{
			m_sMessageBuffer.append( topic.FileName() );
			m_sMessageBuffer.append( ':' );
		}

		if ( flags & TOPIC_LINE_NUMBER_FLAG )
		{
			m_sIntBuffer.assign( topic.LineNumber() );
			m_sMessageBuffer.append( m_sIntBuffer );

			m_sMessageBuffer.append( ": ");
		}

		if ( flags & TOPIC_LEVEL_FLAG )
		{
			m_sMessageBuffer.append( ErrorDescription( topic.Level()));
			m_sMessageBuffer.append( ": ");
		}

		if ( flags & TOPIC_GROUP_FLAG )
		{
			m_sMessageBuffer.append( "{");
			m_sMessageBuffer.append( topic.Group() );
			m_sMessageBuffer.append( "} ");
		}

		if ( flags & TOPIC_CATEGORY_FLAG )
		{
			m_sMessageBuffer.append( "[");
			m_sMessageBuffer.append( topic.Category() );
			m_sMessageBuffer.append( "] ");
		}

		if ( flags & TOPIC_MESSAGE_FLAG )
		{
			m_sMessageBuffer.append( topic.Message() );
			m_sMessageBuffer.append( '\n' );
		}

		m_sMessageBuffer.append( (char)NULL );

		return m_sMessageBuffer;
	}
예제 #29
0
파일: Utils.cpp 프로젝트: TerraMA2/terrama2
std::string terrama2::core::getTableNameProperty(terrama2::core::DataSetPtr dataSet)
{
  try
  {
    return dataSet->format.at("table_name");
  }
  catch(...)
  {
    QString errMsg = QObject::tr("Undefined table name in dataset: %1.").arg(dataSet->id);
    TERRAMA2_LOG_ERROR() << errMsg;
    throw UndefinedTagException() << ErrorDescription(errMsg);
  }
}
예제 #30
0
파일: Utils.cpp 프로젝트: TerraMA2/terrama2
std::string terrama2::core::getMask(DataSetPtr dataSet)
{
  try
  {
    return dataSet->format.at("mask");
  }
  catch(const std::out_of_range& /*e*/)
  {
    QString errMsg = QObject::tr("Undefined mask in dataset: %1.").arg(dataSet->id);
    TERRAMA2_LOG_ERROR() << errMsg;
    throw UndefinedTagException() << ErrorDescription(errMsg);
  }
}