Browse Source

a lot of work

master
Chris Cromer 2 years ago
parent
commit
3aaf811190
Signed by: cromer GPG Key ID: 39CC813FF3C8708A
  1. 1
      data/ui/main.window.ui
  2. 1
      data/ui/query.window.ui
  3. 22
      data/ui/tour.editor.ui
  4. 1
      data/ui/tour.gresource.xml
  5. 5
      data/ui/tour.list.ui
  6. 262
      data/ui/tour.places.ui
  7. 29
      lib/db.vala
  8. 12
      lib/db/arrienda.vala
  9. 77
      lib/db/asociado.vala
  10. 12
      lib/db/categoria.vala
  11. 22
      lib/db/ciudad.vala
  12. 12
      lib/db/contacto_emergencia.vala
  13. 12
      lib/db/descuento.vala
  14. 12
      lib/db/empresa.vala
  15. 12
      lib/db/enfermedad.vala
  16. 12
      lib/db/especialidad.vala
  17. 12
      lib/db/guia.vala
  18. 12
      lib/db/lugar.vala
  19. 12
      lib/db/participa.vala
  20. 12
      lib/db/posee.vala
  21. 12
      lib/db/realiza.vala
  22. 12
      lib/db/region.vala
  23. 12
      lib/db/regiones_sin_descuento.vala
  24. 12
      lib/db/requerir_auto.vala
  25. 12
      lib/db/tiene_enfermedad.vala
  26. 12
      lib/db/total_arriendos.vala
  27. 12
      lib/db/total_coordinadores.vala
  28. 12
      lib/db/total_turistas.vala
  29. 12
      lib/db/total_vehiculos.vala
  30. 61
      lib/db/tour.vala
  31. 12
      lib/db/turista.vala
  32. 12
      lib/db/valores_tours.vala
  33. 12
      lib/db/vehiculo.vala
  34. 60
      lib/db/views.vala
  35. 4
      lib/dbwrapper.vala
  36. 12
      lib/misc.vala
  37. 44
      lib/queries.vala
  38. 2
      po/LINGUAS
  39. 2
      po/POTFILES
  40. 142
      po/es.po
  41. 374
      po/es_CL.po
  42. 134
      po/sernatur.pot
  43. 7
      src/main_window.vala
  44. 1
      src/meson.build
  45. 22
      src/query_window.vala
  46. 11
      src/sernatur.vala
  47. 79
      src/tour_editor.vala
  48. 120
      src/tour_list.vala
  49. 551
      src/tour_places.vala
  50. 3
      test/meson.build

1
data/ui/main.window.ui

@ -20,7 +20,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="can_focus">False</property>
<property name="title">SERNATUR</property>
<property name="window_position">center</property>
<property name="icon_name">sernatur</property>
<signal name="configure-event" handler="on_configure_event" swapped="no"/>
<signal name="destroy" handler="on_destroy" swapped="no"/>
<signal name="window-state-event" handler="on_window_state_event" swapped="no"/>

1
data/ui/query.window.ui

@ -24,7 +24,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="default_width">800</property>
<property name="default_height">600</property>
<property name="destroy_with_parent">True</property>
<property name="icon_name">sernatur</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>

22
data/ui/tour.editor.ui

@ -30,7 +30,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="destroy_with_parent">True</property>
<property name="icon_name">sernatur</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
@ -301,6 +300,25 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="places">
<property name="label" translatable="yes">Places</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Add or edit places.</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="save">
<property name="label" translatable="yes">Save</property>
@ -317,7 +335,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>

1
data/ui/tour.gresource.xml

@ -16,5 +16,6 @@
<gresource prefix="/cl/cromer/ubb/sernatur">
<file preprocess="xml-stripblanks">tour.list.ui</file>
<file preprocess="xml-stripblanks">tour.editor.ui</file>
<file preprocess="xml-stripblanks">tour.places.ui</file>
</gresource>
</gresources>

5
data/ui/tour.list.ui

@ -25,7 +25,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="window_position">center-on-parent</property>
<property name="default_height">480</property>
<property name="destroy_with_parent">True</property>
<property name="icon_name">sernatur</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
@ -59,6 +58,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="enable_tree_lines">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="selection">
<property name="mode">multiple</property>
<signal name="changed" handler="on_changed_selection" swapped="no"/>
</object>
</child>
@ -198,10 +198,10 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<object class="GtkButton" id="delete_tour">
<property name="label" translatable="yes">Delete</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Delete selected tour.</property>
<property name="halign">baseline</property>
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
</object>
<packing>
@ -215,6 +215,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Close this window.</property>
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
</object>
<packing>

262
data/ui/tour.places.ui

@ -0,0 +1,262 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1
Copyright 2018-2019 Chris Cromer
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<interface domain="sernatur">
<requires lib="gtk+" version="3.20"/>
<object class="GtkListStore" id="liststore1"/>
<template class="SernaturTourPlaces" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="type">popup</property>
<property name="title" translatable="yes">Places</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="default_height">480</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
<property name="show_menubar">False</property>
<child type="titlebar">
<placeholder/>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="place_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="hscroll_policy">natural</property>
<property name="vscroll_policy">natural</property>
<property name="model">liststore1</property>
<property name="fixed_height_mode">True</property>
<property name="enable_grid_lines">both</property>
<property name="enable_tree_lines">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="selection">
<property name="mode">multiple</property>
<signal name="changed" handler="on_changed_selection" swapped="no"/>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="place_name">
<property name="sizing">fixed</property>
<property name="title" translatable="yes">Place Name</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="markup">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="ticket_price">
<property name="sizing">fixed</property>
<property name="title" translatable="yes">Ticket Price</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="markup">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="difficulty">
<property name="sizing">fixed</property>
<property name="title" translatable="yes">Difficulty</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="markup">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="arrival_date">
<property name="sizing">fixed</property>
<property name="title" translatable="yes">Arrival Date</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="markup">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="arrival_time">
<property name="sizing">fixed</property>
<property name="title" translatable="yes">Arrival Time</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="markup">4</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="departure_date">
<property name="sizing">fixed</property>
<property name="title" translatable="yes">Departure Date</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="markup">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="departure_time">
<property name="sizing">fixed</property>
<property name="title" translatable="yes">Departure Time</property>
<property name="clickable">True</property>
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="markup">6</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="hexpand">True</property>
<property name="column_spacing">25</property>
<property name="column_homogeneous">True</property>
<child>
<object class="GtkButton" id="edit_place">
<property name="label" translatable="yes">Edit</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Edit associated place.</property>
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="add_place">
<property name="label" translatable="yes">Add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Associate this tour with an existing place.</property>
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="delete_place">
<property name="label" translatable="yes">Delete</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Delete associated place.</property>
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="close_place">
<property name="label" translatable="yes">Close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Close this window.</property>
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="new_place">
<property name="label" translatable="yes">New</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Create a new place to associate.</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</template>
</interface>

29
lib/db.vala

@ -29,7 +29,11 @@ namespace LibSernatur {
/**
* Connection error
*/
CONNECT
CONNECT,
/**
* Escape error
*/
ESCAPE
}
/**
@ -49,7 +53,7 @@ namespace LibSernatur {
/**
* Class to handle database connections
*/
public class Connection : GLib.Object {
public class Connection : Object {
/**
* The database connection
*/
@ -71,7 +75,26 @@ namespace LibSernatur {
if (db.get_status () != Postgres.ConnectionStatus.OK) {
throw new PostgresError.CONNECT (db.get_error_message ());
}
GLib.print (dgettext (null, "Postgresql server version:") + " %d\n", db.get_server_version ());
GLib.print (_ ("Postgresql server version:") + " %d\n", db.get_server_version ());
}
/**
* Escape a string to be safe to use in Postgresql queries
* @param str The string to escape
* @return Returns the escaped string
* @throws PostgresError Thrown if there was some problem escaping the string
*/
public string escape (string str) throws PostgresError {
string* to = malloc ((sizeof (string) * str.length * 2) + 1); // to has to be double the size of str + 1
int error_code;
db.escape_string_conn (to, str, str.length, out error_code);
if (error_code != 0) {
throw new PostgresError.ESCAPE (db.get_error_message ());
}
string result = to;
free (to);
return result;
}
}
}

12
lib/db/arrienda.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Arrienda class based on the database table
*/
public class Arrienda : GLib.Object {
public class Arrienda : Object {
/**
* The price
*/
@ -54,11 +54,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Arrienda
*/
public static List<Arrienda> get_all_arriendas (Database conn) {
var res = conn.exec ("
public static List<Arrienda> get_all_arriendas (Connection conn) {
var res = conn.db.exec ("
SELECT A.precio, A.fecha_devolucion,
V.patente, V.ano_vehiculo, V.marca, V.capacidad,
E.rut_empresa, E.nombre_empresa, E.contacto, E.telefono
@ -68,9 +68,9 @@ JOIN empresa E ON (A.rut_empresa = E.rut_empresa)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Arrienda> ();
#endif
}

77
lib/db/asociado.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Asociado class based on the database table
*/
public class Asociado : GLib.Object {
public class Asociado : Object {
public string fecha_llegada { get; set; default = ""; }
public string hora_llegada { get; set; default = ""; }
public string fecha_salida { get; set; default = ""; }
@ -48,11 +48,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Asociado
*/
public static List<Asociado> get_all_asociados (Database conn) {
var res = conn.exec ("
public static List<Asociado> get_all_asociados (Connection conn) {
var res = conn.db.exec ("
SELECT A.fecha_llegada, A.hora_llegada, A.fecha_salida, A.hora_salida,
T.id_tour, T.nombre_tour, T.costo_indiv, T.costo_grupal, T.minima_personas,
C.id_ciudad, C.nombre_ciudad,
@ -70,9 +70,9 @@ JOIN region R2 ON (C2.id_region = R2.id_region)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Asociado> ();
#endif
}
@ -99,7 +99,72 @@ JOIN region R2 ON (C2.id_region = R2.id_region)
)
),
new Lugar (wra.get_int_n (i, "id_lugar"),
wra.get_string_n (i, "nombre_lugar"),
wra.get_int_n (i, "valor_entrada"),
wra.get_int_n (i, "nivel"),
new Ciudad (wra.get_int_n (i, "id_ciudad_lugar"),
wra.get_string_n (i, "nombre_ciudad_lugar"),
new Region (wra.get_int_n (i, "id_region_lugar"),
wra.get_string_n (i, "nombre_region_lugar")
)
)
)
);
list.append (asociado);
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return list;
}
/**
* Get all tuples and fields from database
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Asociado based off a tour id
*/
public static List<Asociado> get_all_asociados_by_tour (Connection conn, Tour tour) throws PostgresError, DBError {
if (tour.id_tour == 0) {
throw new DBError.INVALID_VALUE (dgettext (null, "The id of the tour is invalid!"));
}
var res = conn.db.exec (Query.get_query (conn, Query.Type.SELECT_ALL_ASSOCIATED_BY_TOUR, tour));
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.db.get_error_message ());
#else
warning (conn.db.get_error_message ());
return new List<Asociado> ();
#endif
}
var wra = new ResultWrapper (res);
List<Asociado> list = new List<Asociado> ();
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var asociado = new Asociado (wra.get_string_n (i, "fecha_llegada"),
wra.get_string_n (i, "hora_llegada"),
wra.get_string_n (i, "fecha_salida"),
wra.get_string_n (i, "hora_salida"),
new Tour (wra.get_int_n (i, "id_tour"),
wra.get_string_n (i, "nombre_tour"),
wra.get_int_n (i, "costo_indiv"),
wra.get_int_n (i, "costo_grupal"),
wra.get_int_n (i, "minima_personas"),
new Ciudad (wra.get_int_n (i, "id_ciudad"),
wra.get_string_n (i, "nombre_ciudad"),
new Region (wra.get_int_n (i, "id_region"),
wra.get_string_n (i, "nombre_region")
)
)
),
new Lugar (wra.get_int_n (i, "id_lugar"),
wra.get_string_n (i, "nombre_lugar"),
wra.get_int_n (i, "valor_entrada"),
wra.get_int_n (i, "nivel"),
new Ciudad (wra.get_int_n (i, "id_ciudad_lugar"),

12
lib/db/categoria.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Categoria class based on the database table
*/
public class Categoria : GLib.Object {
public class Categoria : Object {
/**
* The id of the category
*/
@ -42,18 +42,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Categoria
*/
public static List<Categoria> get_all_categorias (Database conn) {
var res = conn.exec ("
public static List<Categoria> get_all_categorias (Connection conn) {
var res = conn.db.exec ("
SELECT id_categoria, descripcion_categoria FROM categoria
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Categoria> ();
#endif
}

22
lib/db/ciudad.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Ciudad class based on the database table
*/
public class Ciudad : GLib.Object {
public class Ciudad : Object {
/**
* The id of the city
*/
@ -48,11 +48,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Ciudad
*/
public static List<Ciudad> get_all_ciudades (Database conn) {
var res = conn.exec ("
public static List<Ciudad> get_all_ciudades (Connection conn) {
var res = conn.db.exec ("
SELECT C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region
FROM ciudad C
@ -60,9 +60,9 @@ JOIN region R ON (C.id_region = R.id_region)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Ciudad> ();
#endif
}
@ -93,12 +93,12 @@ JOIN region R ON (C.id_region = R.id_region)
/**
* Get all tuples and fields from database that are within a certain region
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @param region_id The id of the region to filter that results
* @return Returns a list of Ciudad
*/
public static List<Ciudad> get_all_ciudades_in_region(Database conn, uint region_id) {
var res = conn.exec ("
public static List<Ciudad> get_all_ciudades_in_region(Connection conn, uint region_id) {
var res = conn.db.exec ("
SELECT C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region
FROM ciudad C
@ -107,9 +107,9 @@ WHERE (R.id_region = " + region_id.to_string () + ")
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Ciudad> ();
#endif
}

12
lib/db/contacto_emergencia.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The ContactoEmergencia class based on the database table
*/
public class ContactoEmergencia : GLib.Object {
public class ContactoEmergencia : Object {
/**
* The id of the contact
*/
@ -48,16 +48,16 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of ContactoEmergencia
*/
public static List<ContactoEmergencia> get_all_contactos (Database conn) {
var res = conn.exec ("SELECT id_contacto, telefono_emergencia, nombre_emergencia FROM contacto_emergencia");
public static List<ContactoEmergencia> get_all_contactos (Connection conn) {
var res = conn.db.exec ("SELECT id_contacto, telefono_emergencia, nombre_emergencia FROM contacto_emergencia");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<ContactoEmergencia> ();
#endif
}

12
lib/db/descuento.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Descuento class based on the database table
*/
public class Descuento : GLib.Object {
public class Descuento : Object {
/**
* The id of the discount
*/
@ -48,18 +48,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Descuento
*/
public static List<Descuento> get_all_descuentos (Database conn) {
var res = conn.exec ("
public static List<Descuento> get_all_descuentos (Connection conn) {
var res = conn.db.exec ("
SELECT id_descuento, descripcion_descuento, porcentaje FROM descuento
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Descuento> ();
#endif
}

12
lib/db/empresa.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Empresa class based on the database table
*/
public class Empresa : GLib.Object {
public class Empresa : Object {
/**
* The RUT of the company
*/
@ -54,18 +54,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Empresa
*/
public static List<Empresa> get_all_empresas (Database conn) {
var res = conn.exec ("
public static List<Empresa> get_all_empresas (Connection conn) {
var res = conn.db.exec ("
SELECT rut_empresa, nombre_empresa, contacto, telefono FROM empresa
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Empresa> ();
#endif
}

12
lib/db/enfermedad.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Enfermedad class based on the database table
*/
public class Enfermedad : GLib.Object {
public class Enfermedad : Object {
/**
* The id of the illness
*/
@ -42,18 +42,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Enfermedad
*/
public static List<Enfermedad> get_all_enfermedades (Database conn) {
var res = conn.exec ("
public static List<Enfermedad> get_all_enfermedades (Connection conn) {
var res = conn.db.exec ("
SELECT id_enfermedad, descripcion_enfermedad FROM enfermedad
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Enfermedad> ();
#endif
}

12
lib/db/especialidad.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Esepcialidad class based on the database table
*/
public class Especialidad : GLib.Object {
public class Especialidad : Object {
/**
* The id of the specialty
*/
@ -42,18 +42,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Especialidad
*/
public static List<Especialidad> get_all_especialidades (Database conn) {
var res = conn.exec ("
public static List<Especialidad> get_all_especialidades (Connection conn) {
var res = conn.db.exec ("
SELECT id_especialidad, descripcion_especialidad FROM especialidad
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Especialidad> ();
#endif
}

12
lib/db/guia.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Guia class based on the database table
*/
public class Guia : GLib.Object {
public class Guia : Object {
/**
* The RUT of the guide
*/
@ -60,11 +60,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Guia
*/
public static List<Guia> get_all_guias (Database conn) {
var res = conn.exec ("
public static List<Guia> get_all_guias (Connection conn) {
var res = conn.db.exec ("
SELECT G.rut_guia, G.nombre_guia, G.calle, G.numero,
C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region
@ -74,9 +74,9 @@ JOIN region R ON (C.id_region = R.id_region)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Guia> ();
#endif
}

12
lib/db/lugar.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Lugar class based on the database table
*/
public class Lugar : GLib.Object {
public class Lugar : Object {
/**
* The id of the place
*/
@ -60,11 +60,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Lugar
*/
public static List<Lugar> get_all_lugares (Database conn) {
var res = conn.exec ("
public static List<Lugar> get_all_lugares (Connection conn) {
var res = conn.db.exec ("
SELECT L.id_lugar, L.nombre_lugar, L.valor_entrada, L.nivel,
C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region
@ -74,9 +74,9 @@ JOIN region R ON (C.id_region = R.id_region)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Lugar> ();
#endif
}

12
lib/db/participa.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Participa class based on the database table
*/
public class Participa : GLib.Object {
public class Participa : Object {
/**
* The tour
*/
@ -48,11 +48,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Participa
*/
public static List<Participa> get_all_participas (Database conn) {
var res = conn.exec ("
public static List<Participa> get_all_participas (Connection conn) {
var res = conn.db.exec ("
SELECT T.id_tour, T.nombre_tour, T.costo_indiv, T.costo_grupal, T.minima_personas,
C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region,
@ -71,9 +71,9 @@ JOIN categoria C3 ON (P.id_categoria = C3.id_categoria)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Participa> ();
#endif
}

12
lib/db/posee.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Posee class based on the database table
*/
public class Posee : GLib.Object {
public class Posee : Object {
/**
* The specialty level
*/
@ -48,11 +48,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Posee
*/
public static List<Posee> get_all_posees (Database conn) {
var res = conn.exec ("
public static List<Posee> get_all_posees (Connection conn) {
var res = conn.db.exec ("
SELECT P.nivel_especialidad,
G.rut_guia, G.nombre_guia, G.calle, G.numero,
C.id_ciudad, C.nombre_ciudad,
@ -66,9 +66,9 @@ JOIN especialidad E ON (P.id_especialidad = E.id_especialidad)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Posee> ();
#endif
}

12
lib/db/realiza.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Realiza class based on the database table
*/
public class Realiza : GLib.Object {
public class Realiza : Object {
/**
* The tour
*/
@ -48,11 +48,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Realiza
*/
public static List<Realiza> get_all_realizas (Database conn) {
var res = conn.exec ("
public static List<Realiza> get_all_realizas (Connection conn) {
var res = conn.db.exec ("
SELECT T.id_tour, T.nombre_tour, T.costo_indiv, T.costo_grupal, T.minima_personas,
C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region,
@ -69,9 +69,9 @@ JOIN descuento D ON (RE.id_descuento = D.id_descuento)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Realiza> ();
#endif
}

12
lib/db/region.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Region class based on the database table
*/
public class Region : GLib.Object {
public class Region : Object {
/**
* The id of the region
*/
@ -42,18 +42,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Region
*/
public static List<Region> get_all_regiones (Database conn) {
var res = conn.exec ("
public static List<Region> get_all_regiones (Connection conn) {
var res = conn.db.exec ("
SELECT id_region, nombre_region FROM region
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Region> ();
#endif
}

12
lib/db/regiones_sin_descuento.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The RegionesSinDescuento class based on the database table
*/
public class RegionesSinDescuento : GLib.Object {
public class RegionesSinDescuento : Object {
/**
* The name of the region
*/
@ -41,18 +41,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of RegionesSinDescuento
*/
public static List<RegionesSinDescuento> get_all_regions_without_discount (Database conn) {
var res = conn.exec ("
public static List<RegionesSinDescuento> get_all_regions_without_discount (Connection conn) {
var res = conn.db.exec ("
SELECT nombreRegion, cantidad FROM REGIONES_SINDESCUENTO
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<RegionesSinDescuento> ();
#endif
}

12
lib/db/requerir_auto.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The RequerirAuto class based on the database table
*/
public class RequerirAuto : GLib.Object {
public class RequerirAuto : Object {
/**
* The chofer
*/
@ -48,11 +48,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of RequerirAuto
*/
public static List<RequerirAuto> get_all_requerir_autos (Database conn) {
var res = conn.exec ("
public static List<RequerirAuto> get_all_requerir_autos (Connection conn) {
var res = conn.db.exec ("
SELECT R.chofer,
T.id_tour, T.nombre_tour, T.costo_indiv, T.costo_grupal, T.minima_personas,
C.id_ciudad, C.nombre_ciudad,
@ -66,9 +66,9 @@ Join vehiculo V ON (R.patente = V.patente)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<RequerirAuto> ();
#endif
}

12
lib/db/tiene_enfermedad.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The TieneEnfermedad class based on the database table
*/
public class TieneEnfermedad : GLib.Object {
public class TieneEnfermedad : Object {
/**
* The tourist
*/
@ -42,11 +42,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of TieneEnfermedad
*/
public static List<TieneEnfermedad> get_all_tiene_enfermedades (Database conn) {
var res = conn.exec ("
public static List<TieneEnfermedad> get_all_tiene_enfermedades (Connection conn) {
var res = conn.db.exec ("
SELECT T.rut_turista, T.nombre_turista, T.fecha_nacimento,
C.id_contacto, C.telefono_emergencia, C.nombre_emergencia,
E.id_enfermedad, E.descripcion_enfermedad
@ -57,9 +57,9 @@ JOIN enfermedad E ON (TE.id_enfermedad = E.id_enfermedad)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<TieneEnfermedad> ();
#endif
}

12
lib/db/total_arriendos.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The TotalArriendos class based on the database table
*/
public class TotalArriendos : GLib.Object {
public class TotalArriendos : Object {
/**
* The total of rented vehicles
*/
@ -36,18 +36,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of TotalArriendos
*/
public static List<TotalArriendos> get_all_rent_totals (Database conn) {
var res = conn.exec ("
public static List<TotalArriendos> get_all_rent_totals (Connection conn) {
var res = conn.db.exec ("
SELECT TotalArriendo FROM TOTAL_ARRIENDOS
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<TotalArriendos> ();
#endif
}

12
lib/db/total_coordinadores.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The TotalCoordinadores class based on the database table
*/
public class TotalCoordinadores : GLib.Object {
public class TotalCoordinadores : Object {
/**
* The id of the region
*/
@ -48,18 +48,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of TotalCoordinadores
*/
public static List<TotalCoordinadores> get_all_coordinator_totals (Database conn) {
var res = conn.exec ("
public static List<TotalCoordinadores> get_all_coordinator_totals (Connection conn) {
var res = conn.db.exec ("
SELECT idT, nombreT, TotalCoordinadores FROM TOTAL_COORDINADORES
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<TotalCoordinadores> ();
#endif
}

12
lib/db/total_turistas.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The TotalTuristas class based on the database table
*/
public class TotalTuristas : GLib.Object {
public class TotalTuristas : Object {
/**
* The id of the tour
*/
@ -48,18 +48,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of TotalTuristas
*/
public static List<TotalTuristas> get_all_tourist_totals (Database conn) {
var res = conn.exec ("
public static List<TotalTuristas> get_all_tourist_totals (Connection conn) {
var res = conn.db.exec ("
SELECT idT, nombreT, TotalTuristas FROM TOTAL_TURISTAS
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<TotalTuristas> ();
#endif
}

12
lib/db/total_vehiculos.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The TotalVehiculos class based on the database table
*/
public class TotalVehiculos : GLib.Object {
public class TotalVehiculos : Object {
/**
* The total of vehicles
*/
@ -36,18 +36,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of TotalVehiculos
*/
public static List<TotalVehiculos> get_all_vehicle_totals (Database conn) {
var res = conn.exec ("
public static List<TotalVehiculos> get_all_vehicle_totals (Connection conn) {
var res = conn.db.exec ("
SELECT TotalVeh FROM TOTAL_VEHICULOS
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<TotalVehiculos> ();
#endif
}

61
lib/db/tour.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Tour class based on the database table
*/
public class Tour : GLib.Object {
public class Tour : Object {
/**
* The tour id
*/
@ -69,13 +69,13 @@ namespace LibSernatur {
* @param conn The database connection to use
* @return Returns a list of Tour
*/
public static List<Tour> get_all_tours (Database conn) {
var res = conn.exec (Query.get_query (Query.Type.SELECT_ALL_TOURS, null));
public static List<Tour> get_all_tours (Connection conn) throws PostgresError {
var res = conn.db.exec (Query.get_query (conn, Query.Type.SELECT_ALL_TOURS, null));
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Tour> ();
#endif
}
@ -116,16 +116,51 @@ namespace LibSernatur {
* @param tour The tour to update
* @throws DBError Thrown if the data in the object is invalid
*/
public static void update_tour (Database conn, Tour tour) throws DBError {
public static void update_tour (Connection conn, Tour tour) throws PostgresError, DBError {
if (tour.id_tour == 0) {
throw new DBError.INVALID_VALUE (dgettext (null, "The id of the tour is invalid!"));
}
var res = conn.exec (Query.get_query (Query.Type.UPDATE_TOUR, tour));
var res = conn.db.exec (Query.get_query (conn, Query.Type.UPDATE_TOUR, tour));
if (res.get_status () != ExecStatus.COMMAND_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
#endif
}
}
/**
* Insert a tour in the database
* @param conn The database connection
* @param tour The tour to insert
* @return Returns the id of the tuple inserted
* @throws DBError Thrown if the data in the object is invalid
*/
public static uint insert_tour (Connection conn, Tour tour) throws PostgresError, DBError {
if (tour.id_tour != 0) {
throw new DBError.INVALID_VALUE (dgettext (null, "The id of the tour is invalid!"));
}
var res = conn.db.exec (Query.get_query (conn, Query.Type.INSERT_TOUR, tour));
// This uses TUPLES_OK because it returns a result which is hte id of the inserted tour
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.db.get_error_message ());
#else
warning (conn.db.get_error_message ());
#endif
}
var wra = new ResultWrapper (res);
try {
return wra.get_int_n (0, "id_tour");
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
return 0;
#endif
}
}
@ -136,19 +171,19 @@ namespace LibSernatur {
* @param tour The tour to update
* @throws DBError Thrown if the data in the object is invalid
*/
public static void delete_tour (Database conn, Tour tour) throws DBError {
public static void delete_tour (Connection conn, Tour tour) throws PostgresError, DBError {
if (tour.id_tour == 0) {
throw new DBError.INVALID_VALUE (dgettext (null, "The id of the tour is invalid!"));
}
var res = conn.exec (Query.get_query (Query.Type.DELETE_TOUR, tour));
var res = conn.db.exec (Query.get_query (conn, Query.Type.DELETE_TOUR, tour));
if (res.get_status () != ExecStatus.COMMAND_OK) {
if (res.get_error_field (FieldCode.SQLSTATE) == "23503") {
throw new DBError.FOREIGN_KEY_CONSTAINT (res.get_error_field (FieldCode.MESSAGE_PRIMARY));
}
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
#endif
}
}

12
lib/db/turista.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Turista class based on the database table
*/
public class Turista : GLib.Object {
public class Turista : Object {
/**
* The RUT of the tourist
*/
@ -54,11 +54,11 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Turista
*/
public static List<Turista> get_all_turistas (Database conn) {
var res = conn.exec ("
public static List<Turista> get_all_turistas (Connection conn) {
var res = conn.db.exec ("
SELECT T.rut_turista, T.nombre_turista, T.fecha_nacimento,
C.id_contacto, C.telefono_emergencia, C.nombre_emergencia
FROM turista T
@ -66,9 +66,9 @@ JOIN contacto_emergencia C ON (T.id_contacto = C.id_contacto)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Turista> ();
#endif
}

12
lib/db/valores_tours.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The ValoresTours class based on the database table
*/
public class ValoresTours : GLib.Object {
public class ValoresTours : Object {
/**
* The id of the tour
*/
@ -48,18 +48,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of ValoresTours
*/
public static List<ValoresTours> get_all_tour_sales (Database conn) {
var res = conn.exec ("
public static List<ValoresTours> get_all_tour_sales (Connection conn) {
var res = conn.db.exec ("
SELECT idT, nombreT, TotalVentas FROM VALORES_TOURS
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<ValoresTours> ();
#endif
}

12
lib/db/vehiculo.vala

@ -20,7 +20,7 @@ namespace LibSernatur {
/**
* The Vehiculo class based on the database table
*/
public class Vehiculo : GLib.Object {
public class Vehiculo : Object {
/**
* The license plate
*/
@ -54,18 +54,18 @@ namespace LibSernatur {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of Vehiculo
*/
public static List<Vehiculo> get_all_vehiculos (Database conn) {
var res = conn.exec ("
public static List<Vehiculo> get_all_vehiculos (Connection conn) {
var res = conn.db.exec ("
SELECT patente, ano_vehiculo, marca, capacidad FROM vehiculo
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
error (conn.db.get_error_message ());
#else
warning (conn.get_error_message ());
warning (conn.db.get_error_message ());
return new List<Vehiculo> ();
#endif
}

60
lib/db/views.vala

@ -24,21 +24,21 @@ namespace LibSernatur {
/**
* The Q1 class based on the database table
*/
public class Q1 : GLib.Object {
public class Q1 : Object {
/**
* Get all tuples and fields from database
* @param conn The database connection to use
* @param conn.db.The database conn.db.ction to use
* @return Returns a list of RegionesSinDescuento
*/
public static List<RegionesSinDescuento> get_regions_without_discount (Database conn) {
var res = conn.exec ("
public static List<RegionesSinDescuento> get_regions_without_discount (Connection conn) {
var res = conn.db.exec ("