Ejemplo n.º 1
0
const tissuestack::imaging::TissueStackLabelLookup * tissuestack::database::LabelLookupDataProvider::queryLookupValuesByFileName(
		const std::string file_name) {
	if (file_name.empty())
		return nullptr;

	const std::string sql =
			"SELECT * FROM dataset_values_lookup WHERE filename='"
			+ file_name + "';";

	tissuestack::imaging::TissueStackLabelLookup * ret = nullptr;

	const pqxx::result results =
			tissuestack::database::TissueStackPostgresConnector::instance()->executeNonTransactionalQuery(sql);

	if (results.size() == 0) return ret;
	if (results.size() > 1)
		THROW_TS_EXCEPTION(tissuestack::common::TissueStackApplicationException,
			"Unique key based search returned more than 1 record!");

	for (pqxx::result::const_iterator look = results.begin(); look != results.end(); ++look)
	{
		tissuestack::database::AtlasInfo * atlasInfo = nullptr;
		if (!look["atlas_association"].is_null())
		{
			// go query associated atlas info
			const std::string innerSql =
				"SELECT * FROM atlas_info WHERE id=" +
				std::to_string(look["atlas_association"].as<unsigned long long int>()) + ";";

			const pqxx::result innerResults =
					tissuestack::database::TissueStackPostgresConnector::instance()->executeNonTransactionalQuery(innerSql);

			if (innerResults.size() == 1)
			{
				for (pqxx::result::const_iterator atlas = innerResults.begin(); atlas != innerResults.end(); ++atlas)
				{
					atlasInfo = new tissuestack::database::AtlasInfo(
						atlas["id"].as<unsigned long long int>(),
						atlas["atlas_prefix"].as<std::string>(),
						atlas["atlas_description"].as<std::string>(),
						atlas["atlas_query_url"].is_null() ? "" :
							atlas["atlas_query_url"].as<std::string>());
					break;
				}
			}
		}

		// construct lookup label from db info
		ret = const_cast<tissuestack::imaging::TissueStackLabelLookup * >(
			tissuestack::imaging::TissueStackLabelLookup::fromDataBaseId(
				look["id"].as<unsigned long long int>(),
				look["filename"].as<std::string>(),
				look["content"].as<std::string>(),
				atlasInfo));

		break;
	}
	return ret;
}
ILandRecordShrPtr LandAccessorPostgresql::prepareResultGetRecord(
    pqxx::result const & a_result
) const
{
    if (a_result.size() > 0)
    {
        string login;
        string world_name;
        string land_name;
        int turns;
        bool granted;

        a_result[0]["login"].to(login);
        a_result[0]["world_name"].to(world_name);
        a_result[0]["land_name"].to(land_name);
        a_result[0]["turns"].to(turns);
        a_result[0]["granted"].to(granted);

        return ILandRecordShrPtr(new LandRecord(login, world_name, land_name, turns, granted));
    }
    else
    {
        return ILandRecordShrPtr();
    }
}
Ejemplo n.º 3
0
    std::vector< std::map<std::string, std::string> > PostgreAdapter::parseResponse(pqxx::result response_I)
    {
        std::vector< std::map<std::string, std::string> > result;
        std::map<std::string, std::string>* tmp;

        if (response_I.size() > 0) {
            for(auto it: response_I) {
                tmp = new std::map<std::string, std::string>();
                for(auto el: it) {
                    std::cout << el.name() << " = '" << el.c_str() << "'" << std::endl;
                    (*tmp)[el.name()] = el.c_str();
                }
                result.push_back( *tmp );
            }
        }

        return result;
    }
Ejemplo n.º 4
0
Archivo: zou.cpp Proyecto: yarlB/EE
//ligne résultat : (nom_programme, programme, nom_zone)
void Zou::processAll(pqxx::result const& result) {
  std::unordered_set<char const*> zones_names_tmp;

  for(pqxx::result::size_type i=0 ; i!=result.size() ; ++i) {
    field_raw_t progname_raw = result[i][0].c_str(), program_raw = result[i][1].c_str(),
      zonename_raw = result[i][2].c_str();
    zonename_t zonename(zonename_raw);
    zones_names_tmp.insert(zonename_raw);
    progset_t hmm;
    if(m_zones.count(zonename) == 0)
      hmm = m_zones.insert(zonename, progset_t());
    else
      hmm = m_zones.find(zonename);
    processProgram(hmm, program_raw);
  }

  //envoi ordre de gelement des zones de m_zones pas dans zones_names_tmp;
  //les zones gelées disparaissent (et tous leurs objets) au bout d'un certain temps
}