CatalogsDB::SqlStatements

CatalogsDB::SqlStatements Namespace Reference

Functions

QString all_catalog_view_body (const QString &fields, const QString &cat_prefix, int id)
 
const QString create_catalog_registry (const QString &name)
 
QString create_catalog_table (int id)
 
template<typename input_iterator >
QString create_field_list (input_iterator begin, input_iterator end)
 
template<typename input_iterator >
QString create_field_list (input_iterator begin, input_iterator end, const QString &prefix)
 
template<typename input_iterator >
QString create_update_list (input_iterator begin, input_iterator end)
 
const QString drop_catalog (int id)
 
const QString dso_by_catalog (int catalog_id)
 
const QString dso_by_name_and_catalog (const int id)
 
const QString dso_by_oid_and_catalog (const int id)
 
const QString dso_by_wildcard ()
 
const QString dso_count_by_type (int catalog_id)
 
const QString dso_general_query (const QString &where, const QString &order_by="")
 
const QString dso_in_catalog_by_maglim (const int id)
 
template<typename input_iterator >
QStringList from_it (input_iterator begin, input_iterator end)
 
const QString insert_dso (int catalog_id)
 
const QString insert_into_catalog_registry (const QString &name)
 
const QString move_objects (const int id_1, const int id_2)
 
const QString remove_dso (const int id)
 
const QString set_catalog_all_objects (const int id)
 

Variables

const QString _all_catalog_view_body
 
constexpr std::array< const char *, 8 > _catalog_meta_fields
 
const QString _create_catalog_list_table
 
const QString _create_catalog_table
 
const QString _create_master
 
const QString _drop_catalog = "DROP TABLE cat_%1"
 
const QString _dso_by_catalog = QString("SELECT %1 FROM cat_%2").arg(catalog_fields)
 
const QString _dso_by_maglim
 
const QString _dso_by_maglim_and_type
 
const QString _dso_by_name
 
const QString _dso_by_name_exact = "SELECT %1 FROM master WHERE name = :name LIMIT 1"
 
const QString _dso_by_oid = "SELECT %1 FROM master WHERE oid = :id LIMIT 1"
 
const QString _dso_by_trixel
 
const QString _dso_by_trixel_no_nulls
 
const QString _dso_by_trixel_null_mag
 
const QString _dso_by_wildcard
 
const QString _dso_count_by_type = "SELECT type, COUNT(*) FROM %1 GROUP BY type"
 
const QString _insert_catalog
 
const QString _insert_dso
 
const QString _insert_dso_template = "INSERT OR REPLACE INTO cat_%3 (%1) VALUES (%2)"
 
const QString _remove_dso { "DELETE FROM cat_%1 WHERE oid = :oid" }
 
const QString all_catalog_view = "all_catalogs"
 
constexpr std::array< const char *, 15 > catalog_collumns
 
const auto catalog_fields
 
const QString catalog_prefix = "cat_"
 
const QString colors_table = "catalog_colors"
 
const QString create_catalog_list_table = create_catalog_registry("catalogs")
 
const QString create_colors_table
 
const QString create_master = QString(_create_master).arg(master_catalog_fields)
 
const QString create_master_mag_index
 
const QString create_master_name_index
 
const QString create_master_trixel_index
 
const QString create_master_type_index
 
const QString create_meta_table
 
constexpr int current_db_version = 3
 
constexpr int default_htmesh_level = 3
 
const QString drop_master = "DROP TABLE IF EXISTS master"
 
const QString dso_by_maglim = QString(_dso_by_maglim).arg(object_fields).arg(mag_asc)
 
const QString dso_by_maglim_and_type
 
const QString dso_by_name = QString(_dso_by_name).arg(object_fields).arg(mag_asc)
 
const QString dso_by_name_exact = QString(_dso_by_name_exact).arg(object_fields)
 
const QString dso_by_oid = QString(_dso_by_oid).arg(object_fields)
 
const QString dso_by_trixel = QString(_dso_by_trixel).arg(object_fields).arg(mag_desc)
 
const QString dso_by_trixel_no_nulls = QString(_dso_by_trixel_no_nulls).arg(object_fields)
 
const QString dso_by_trixel_null_mag = QString(_dso_by_trixel_null_mag).arg(object_fields)
 
const QString dso_count_by_type_master = _dso_count_by_type.arg("master")
 
constexpr std::array< const char *, 13 > dso_query_fields
 
const QString empty_view = "SELECT NULL WHERE FALSE"
 
const QString enable_disable_catalog
 
const QString exists_catalog_by_id = "SELECT 1 FROM catalogs WHERE id = :id"
 
const QString exists_master
 
const QString get_all_catalog_ids = "SELECT id FROM catalogs ORDER BY id ASC"
 
const QString get_catalog_by_id
 
const QString get_catalog_ids
 
const QString get_colors
 
const QString get_first_catalog
 
const QString get_meta = "SELECT version, htmesh_level, init FROM meta LIMIT 1"
 
const QString insert_catalog = insert_into_catalog_registry("catalogs")
 
const QString insert_color
 
const QString mag_asc = "magnitude IS NOT NULL, magnitude ASC"
 
const QString mag_desc = "magnitude IS NULL, magnitude DESC"
 
const QString master_catalog = "master"
 
constexpr std::array< const char *, 14 > master_catalog_collumns
 
const auto master_catalog_fields
 
const auto object_fields
 
const QString remove_catalog = "DELETE FROM catalogs WHERE id = :id"
 
const QString set_meta
 
const QString update_catalog_meta
 
const QString update_version = "UPDATE meta SET version = :version"
 
constexpr int user_catalog_id = 0
 
const QString user_catalog_name = "user"
 

Detailed Description

Holds a collection of hardcoded sql statements.

Variable Documentation

◆ _all_catalog_view_body

const QString CatalogsDB::SqlStatements::_all_catalog_view_body
Initial value:
=
"SELECT %1, cl.precedence FROM %2%3 c INNER JOIN catalogs cl ON cl.id = "
"c.catalog"

Definition at line 169 of file catalogsdb/sqlstatements.cpp.

◆ _catalog_meta_fields

constexpr std::array< const char *, 8 > CatalogsDB::SqlStatements::_catalog_meta_fields
constexpr
Initial value:
=
{
"name", "author", "source", "description",
"color", "license", "maintainer", "timestamp"
}

Definition at line 230 of file catalogsdb/sqlstatements.cpp.

◆ _create_catalog_list_table

const QString CatalogsDB::SqlStatements::_create_catalog_list_table
Initial value:
= "CREATE TABLE IF NOT EXISTS %1 ("
"id INTEGER PRIMARY KEY,"
"name TEXT NOT NULL,"
"precedence REAL NOT NULL,"
"author TEXT DEFAULT NULL,"
"source TEXT DEFAULT NULL,"
"description TEXT DEFAULT NULL,"
"mut INTEGER DEFAULT 0,"
"version INTEGER DEFAULT -1,"
"enabled INTEGER DEFAULT 1,"
"color TEXT DEFAULT NULL,"
"license TEXT DEFAULT NULL,"
"maintainer TEXT DEFAULT NULL,"
"timestamp DATETIME DEFAULT NULL)"

Definition at line 182 of file catalogsdb/sqlstatements.cpp.

◆ _create_catalog_table

const QString CatalogsDB::SqlStatements::_create_catalog_table
Initial value:
= "CREATE TABLE IF NOT EXISTS %1 ("
"hash BLOB PRIMARY KEY,"
"oid BLOB NOT NULL,"
"type INTEGER NOT NULL,"
"ra REAL NOT NULL,"
"dec REAL NOT NULL,"
"magnitude REAL DEFAULT NULL,"
"name TEXT NOT NULL,"
"long_name TEXT DEFAULT NULL,"
"catalog_identifier TEXT DEFAULT NULL,"
"major_axis REAL DEFAULT NULL,"
"minor_axis REAL DEFAULT NULL,"
"position_angle REAL DEFAULT NULL,"
"flux REAL DEFAULT NULL,"
"trixel INTEGER DEFAULT -1,"
"res_1 BLOB DEFAULT NULL,"
"res_2 BLOB DEFAULT NULL,"
"res_3 BLOB DEFAULT NULL,"
"res_4 BLOB DEFAULT NULL,"
"catalog INTEGER NOT NULL,"
"FOREIGN KEY (catalog) REFERENCES catalogs (id) "
"ON DELETE CASCADE "
"ON UPDATE CASCADE)"

Definition at line 249 of file catalogsdb/sqlstatements.cpp.

◆ _create_master

const QString CatalogsDB::SqlStatements::_create_master
Initial value:
= "CREATE TABLE master AS "
"SELECT %1 FROM "
"all_catalogs "
"GROUP BY oid "
"ORDER BY MAX(precedence)"

Definition at line 281 of file catalogsdb/sqlstatements.cpp.

◆ _dso_by_maglim

const QString CatalogsDB::SqlStatements::_dso_by_maglim
Initial value:
= "SELECT %1 FROM master WHERE magnitude < :maglim "
"ORDER BY %2 LIMIT :limit"

Definition at line 391 of file catalogsdb/sqlstatements.cpp.

◆ _dso_by_maglim_and_type

const QString CatalogsDB::SqlStatements::_dso_by_maglim_and_type
Initial value:
=
"SELECT %1 FROM master WHERE type = :type AND magnitude < :maglim "
"ORDER BY %2 LIMIT :limit"

Definition at line 405 of file catalogsdb/sqlstatements.cpp.

◆ _dso_by_name

const QString CatalogsDB::SqlStatements::_dso_by_name
Initial value:
=
"SELECT %1, name like \"%\" || :name || \"%\" AS in_name, long_name like "
"\"%\" || :name || \"%\" AS in_lname FROM master WHERE in_name "
"OR in_lname "
"ORDER BY name, long_name, "
"%2 LIMIT :limit"

Definition at line 349 of file catalogsdb/sqlstatements.cpp.

◆ _dso_by_trixel

const QString CatalogsDB::SqlStatements::_dso_by_trixel
Initial value:
= "SELECT %1 FROM master WHERE trixel = "
":trixel ORDER BY %2"

Definition at line 324 of file catalogsdb/sqlstatements.cpp.

◆ _dso_by_trixel_no_nulls

const QString CatalogsDB::SqlStatements::_dso_by_trixel_no_nulls
Initial value:
= "SELECT %1 FROM master WHERE trixel = "
":trixel AND magnitude IS NOT NULL ORDER"
" BY magnitude DESC"

Definition at line 333 of file catalogsdb/sqlstatements.cpp.

◆ _dso_by_trixel_null_mag

const QString CatalogsDB::SqlStatements::_dso_by_trixel_null_mag
Initial value:
= "SELECT %1 FROM master WHERE trixel = "
":trixel AND magnitude IS NULL"

Definition at line 329 of file catalogsdb/sqlstatements.cpp.

◆ _dso_by_wildcard

const QString CatalogsDB::SqlStatements::_dso_by_wildcard
Initial value:
= "SELECT %1 FROM master WHERE name LIKE :wildcard LIMIT "
":limit ORDER BY CAST(name AS INTEGER)"

Definition at line 371 of file catalogsdb/sqlstatements.cpp.

◆ _insert_catalog

const QString CatalogsDB::SqlStatements::_insert_catalog
Initial value:
=
"INSERT OR IGNORE INTO %1 (id, name, mut, enabled, precedence, author, source, "
"description, version, color, license, maintainer, timestamp) "
"VALUES (:id, :name, :mut, :enabled, :precedence, :author, :source, :description, "
":version, :color, :license, :maintainer, :timestamp)"

Definition at line 204 of file catalogsdb/sqlstatements.cpp.

◆ _insert_dso

const QString CatalogsDB::SqlStatements::_insert_dso
Initial value:
=
QString(_insert_dso_template)
.arg(catalog_fields)
.arg(create_field_list(catalog_collumns.begin(), catalog_collumns.end(), ":"))

Definition at line 421 of file catalogsdb/sqlstatements.cpp.

◆ catalog_collumns

constexpr std::array< const char *, 15 > CatalogsDB::SqlStatements::catalog_collumns
constexpr
Initial value:
=
{
"hash", "oid", "type",
"ra", "dec", "magnitude",
"name", "long_name", "catalog_identifier",
"major_axis", "minor_axis", "position_angle",
"flux", "trixel", "catalog"
}

Definition at line 98 of file catalogsdb/sqlstatements.cpp.

◆ catalog_fields

const auto CatalogsDB::SqlStatements::catalog_fields
Initial value:
=
create_field_list(catalog_collumns.begin(), catalog_collumns.end())

Definition at line 107 of file catalogsdb/sqlstatements.cpp.

◆ create_colors_table

const QString CatalogsDB::SqlStatements::create_colors_table
Initial value:
=
QString("CREATE TABLE IF NOT EXISTS %1 (catalog INTEGER NOT "
"NULL, scheme TEXT NOT NULL, color TEXT NOT NULL, UNIQUE(catalog, scheme, "
"color))")
.arg(colors_table)

Definition at line 49 of file catalogsdb/sqlstatements.cpp.

◆ create_master_mag_index

const QString CatalogsDB::SqlStatements::create_master_mag_index
Initial value:
=
"CREATE INDEX master_mag ON master(magnitude ASC)"

Definition at line 293 of file catalogsdb/sqlstatements.cpp.

◆ create_master_name_index

const QString CatalogsDB::SqlStatements::create_master_name_index
Initial value:
=
"CREATE INDEX master_name ON master(name "
"COLLATE NOCASE ASC, long_name COLLATE NOCASE ASC, "
"magnitude ASC)"

Definition at line 297 of file catalogsdb/sqlstatements.cpp.

◆ create_master_trixel_index

const QString CatalogsDB::SqlStatements::create_master_trixel_index
Initial value:
=
"CREATE INDEX master_trixel_mag ON master(trixel ASC, magnitude DESC, major_axis "
"ASC)"

Definition at line 289 of file catalogsdb/sqlstatements.cpp.

◆ create_master_type_index

const QString CatalogsDB::SqlStatements::create_master_type_index
Initial value:
=
"CREATE INDEX master_mag_type ON master(type, magnitude ASC)"

Definition at line 295 of file catalogsdb/sqlstatements.cpp.

◆ create_meta_table

const QString CatalogsDB::SqlStatements::create_meta_table
Initial value:
=
"CREATE TABLE IF NOT EXISTS meta (version INTEGER NOT "
"NULL, htmesh_level INTEGER NOT NULL, init INTEGER NOT NULL)"

Definition at line 39 of file catalogsdb/sqlstatements.cpp.

◆ dso_by_maglim_and_type

const QString CatalogsDB::SqlStatements::dso_by_maglim_and_type
Initial value:
=
QString(_dso_by_maglim_and_type).arg(object_fields).arg(mag_asc)

Definition at line 409 of file catalogsdb/sqlstatements.cpp.

◆ dso_query_fields

constexpr std::array< const char *, 13 > CatalogsDB::SqlStatements::dso_query_fields
constexpr
Initial value:
= { "oid",
"type",
"ra",
"dec",
"magnitude",
"name",
"long_name",
"catalog_identifier",
"major_axis",
"minor_axis",
"position_angle",
"flux",
"catalog"
}

The standard fields to query when loading objects from the db into kstars.

Definition at line 133 of file catalogsdb/sqlstatements.cpp.

◆ enable_disable_catalog

const QString CatalogsDB::SqlStatements::enable_disable_catalog
Initial value:
=
"UPDATE catalogs SET enabled = :enabled WHERE id = :id"

Definition at line 155 of file catalogsdb/sqlstatements.cpp.

◆ exists_master

const QString CatalogsDB::SqlStatements::exists_master
Initial value:
=
"SELECT name FROM sqlite_master WHERE type='table' AND name='master';"

Definition at line 312 of file catalogsdb/sqlstatements.cpp.

◆ get_catalog_by_id

const QString CatalogsDB::SqlStatements::get_catalog_by_id
Initial value:
= "SELECT id, name, precedence, author, source, "
"description, mut, enabled, version, color, license, "
"maintainer, timestamp FROM catalogs WHERE id = :id"

Definition at line 306 of file catalogsdb/sqlstatements.cpp.

◆ get_catalog_ids

const QString CatalogsDB::SqlStatements::get_catalog_ids
Initial value:
=
"SELECT id FROM catalogs WHERE enabled = 1 ORDER BY id ASC"

Definition at line 152 of file catalogsdb/sqlstatements.cpp.

◆ get_colors

const QString CatalogsDB::SqlStatements::get_colors
Initial value:
=
QString("SELECT catalog, scheme, color FROM %1").arg(colors_table)

Definition at line 55 of file catalogsdb/sqlstatements.cpp.

◆ get_first_catalog

const QString CatalogsDB::SqlStatements::get_first_catalog
Initial value:
= "SELECT id, name, precedence, author, source, "
"description, mut, enabled, version, color, license, "
"maintainer, timestamp FROM catalogs LIMIT 1"

Definition at line 302 of file catalogsdb/sqlstatements.cpp.

◆ insert_color

const QString CatalogsDB::SqlStatements::insert_color
Initial value:
=
QString("INSERT INTO %1 (catalog, scheme, color) VALUES (:catalog, :scheme, :color) "
"ON CONFLICT(catalog, scheme, color) DO UPDATE SET color = :color")
.arg(colors_table)

Definition at line 58 of file catalogsdb/sqlstatements.cpp.

◆ master_catalog_collumns

constexpr std::array< const char *, 14 > CatalogsDB::SqlStatements::master_catalog_collumns
constexpr
Initial value:
= { "oid",
"type",
"ra",
"dec",
"magnitude",
"name",
"long_name",
"catalog_identifier",
"major_axis",
"minor_axis",
"position_angle",
"flux",
"trixel",
"catalog"
}

Definition at line 110 of file catalogsdb/sqlstatements.cpp.

◆ master_catalog_fields

const auto CatalogsDB::SqlStatements::master_catalog_fields
Initial value:
=
create_field_list(master_catalog_collumns.begin(), master_catalog_collumns.end())

Definition at line 126 of file catalogsdb/sqlstatements.cpp.

◆ object_fields

const auto CatalogsDB::SqlStatements::object_fields
Initial value:
=
create_field_list(dso_query_fields.begin(), dso_query_fields.end())

Definition at line 148 of file catalogsdb/sqlstatements.cpp.

◆ set_meta

const QString CatalogsDB::SqlStatements::set_meta
Initial value:
= "INSERT INTO meta (version, htmesh_level, init) VALUES "
"(:version, :htmesh_level, :init)"

Definition at line 45 of file catalogsdb/sqlstatements.cpp.

◆ update_catalog_meta

const QString CatalogsDB::SqlStatements::update_catalog_meta
Initial value:
=
QString("UPDATE catalogs SET %1 WHERE id = :id")
.arg(create_update_list(_catalog_meta_fields.cbegin(),
_catalog_meta_fields.cend()))

Definition at line 236 of file catalogsdb/sqlstatements.cpp.

constexpr std::array< const char *, 13 > dso_query_fields
The standard fields to query when loading objects from the db into kstars.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Aug 9 2022 04:06:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.