Browse Source

a lot of work

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

+ 0
- 1
data/ui/main.window.ui View File

@@ -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"/>

+ 0
- 1
data/ui/query.window.ui View File

@@ -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>

+ 20
- 2
data/ui/tour.editor.ui View File

@@ -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
- 0
data/ui/tour.gresource.xml View File

@@ -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>

+ 3
- 2
data/ui/tour.list.ui View File

@@ -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
- 0
data/ui/tour.places.ui View File

@@ -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>

+ 26
- 3
lib/db.vala View File

@@ -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;
}
}
}

+ 6
- 6
lib/db/arrienda.vala View File

@@ -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
}

+ 71
- 6
lib/db/asociado.vala View File

@@ -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"),

+ 6
- 6
lib/db/categoria.vala View File

@@ -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
}

+ 11
- 11
lib/db/ciudad.vala View File

@@ -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
}

+ 6
- 6
lib/db/contacto_emergencia.vala View File

@@ -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
}

+ 6
- 6
lib/db/descuento.vala View File

@@ -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
}

+ 6
- 6
lib/db/empresa.vala View File

@@ -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
}

+ 6
- 6
lib/db/enfermedad.vala View File

@@ -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
}

+ 6
- 6
lib/db/especialidad.vala View File

@@ -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
}

+ 6
- 6
lib/db/guia.vala View File

@@ -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
}

+ 6
- 6
lib/db/lugar.vala View File

@@ -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
}

+ 6
- 6
lib/db/participa.vala View File

@@ -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
}

+ 6
- 6
lib/db/posee.vala View File

@@ -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
}

+ 6
- 6
lib/db/realiza.vala View File

@@ -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
}

+ 6
- 6
lib/db/region.vala View File

@@ -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
}

+ 6
- 6
lib/db/regiones_sin_descuento.vala View File

@@ -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
}

+ 6
- 6
lib/db/requerir_auto.vala View File

@@ -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
}

+ 6
- 6
lib/db/tiene_enfermedad.vala View File

@@ -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
}

+ 6
- 6
lib/db/total_arriendos.vala View File

@@ -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
}

+ 6
- 6
lib/db/total_coordinadores.vala View File

@@ -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
}

+ 6
- 6
lib/db/total_turistas.vala View File

@@ -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
}

+ 6
- 6
lib/db/total_vehiculos.vala View File

@@ -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
}

+ 48
- 13
lib/db/tour.vala View File

@@ -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
}
}

+ 6
- 6
lib/db/turista.vala View File

@@ -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
}

+ 6
- 6
lib/db/valores_tours.vala View File

@@ -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
}

+ 6
- 6
lib/db/vehiculo.vala View File

@@ -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
}

+ 30
- 30
lib/db/views.vala View File

@@ -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 ("
SELECT nombreRegion, cantidad FROM REGIONES_SINDESCUENTO WHERE (cantidad = (SELECT MAX(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
}
@@ -68,7 +68,7 @@ SELECT nombreRegion, cantidad FROM REGIONES_SINDESCUENTO WHERE (cantidad = (SELE
/**
* The Q2 class based on the database table
*/
public class Q2 : GLib.Object {
public class Q2 : Object {
/**
* The name of the tour
*/
@@ -90,19 +90,19 @@ SELECT nombreRegion, cantidad FROM REGIONES_SINDESCUENTO WHERE (cantidad = (SELE

/**
* 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 Q2
*/
public static List<Q2> get_value_received (Database conn) {
var res = conn.exec ("
public static List<Q2> get_value_received (Connection conn) {
var res = conn.db.exec ("
SELECT V.nombreT, (V.TotalVentas - COALESCE(MAX(T.TotalDescuentos), 0)) AS ValorTotalRecibido
FROM VALORES_TOURS V FULL JOIN TOUR_DESCUENTOS T ON (T.idT = V.idT) GROUP BY (V.nombreT, V.TotalVentas)
");
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<Q2> ();
#endif
}
@@ -132,22 +132,22 @@ FROM VALORES_TOURS V FULL JOIN TOUR_DESCUENTOS T ON (T.idT = V.idT) GROUP BY (V.
/**
* The Q3 class based on the database table
*/
public class Q3 : GLib.Object {
public class Q3 : 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 TotalCoordinadores
*/
public static List<TotalCoordinadores> get_total_coordinators (Database conn) {
var res = conn.exec ("
public static List<TotalCoordinadores> get_total_coordinators (Connection conn) {
var res = conn.db.exec ("
SELECT nombreT, TotalCoordinadores
FROM TOTAL_COORDINADORES WHERE (TotalCoordinadores = (SELECT MAX(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
}
@@ -178,21 +178,21 @@ FROM TOTAL_COORDINADORES WHERE (TotalCoordinadores = (SELECT MAX(TotalCoordinado
/**
* The Q4 class based on the database table
*/
public class Q4 : GLib.Object {
public class Q4 : 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 TotalTuristas
*/
public static List<TotalTuristas> get_total_tourists (Database conn) {
var res = conn.exec ("
public static List<TotalTuristas> get_total_tourists (Connection conn) {
var res = conn.db.exec ("
SELECT nombreT, TotalTuristas FROM TOTAL_TURISTAS WHERE (TotalTuristas = (SELECT MAX(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
}
@@ -223,7 +223,7 @@ SELECT nombreT, TotalTuristas FROM TOTAL_TURISTAS WHERE (TotalTuristas = (SELECT
/**
* The Q5 class based on the database table
*/
public class Q5 : GLib.Object {
public class Q5 : Object {
/**
* The percentage of cars that were rented and used
*/
@@ -239,20 +239,20 @@ SELECT nombreT, TotalTuristas FROM TOTAL_TURISTAS WHERE (TotalTuristas = (SELECT

/**
* 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 Q5
*/
public static List<Q5> get_percentage (Database conn) {
var res = conn.exec ("
public static List<Q5> get_percentage (Connection conn) {
var res = conn.db.exec ("
SELECT
(cast(T1.totalarriendo AS DECIMAL(3,2)) / cast(T2.totalveh AS DECIMAL(3,2))) AS porcentaje
FROM total_arriendos AS T1, total_vehiculos AS T2
");
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<Q5> ();
#endif
}

+ 2
- 2
lib/dbwrapper.vala View File

@@ -33,7 +33,7 @@ namespace LibSernatur {
/**
* This is a wrapper for Postgresql results
*/
public class ResultWrapper : GLib.Object {
public class ResultWrapper : Object {
/**
* The result that this is wrapped around
*/
@@ -135,7 +135,7 @@ namespace LibSernatur {
*/
private int check_field_found (int field_num, string name) throws Field {
if (field_num == -1) {
throw new Field.NOTFOUND (dgettext (null, "The field %s was not found in the query results!"), name);
throw new Field.NOTFOUND (_ ("The field %s was not found in the query results!"), name);
}
return field_num;
}

+ 6
- 6
lib/misc.vala View File

@@ -39,7 +39,7 @@ namespace LibSernatur {
/**
* This class converts a float or double into a percentage string
*/
public class Percentage : GLib.Object {
public class Percentage : Object {
/**
* Format a float into a percentage string
* @param value The value to convert
@@ -63,7 +63,7 @@ namespace LibSernatur {
/**
* This class handles making money look pretty
*/
public class Money : GLib.Object {
public class Money : Object {
/**
* Format an int to look pretty
* @param value The value to format
@@ -131,7 +131,7 @@ namespace LibSernatur {
/**
* This class handles parsing and validation of RUTs
*/
public class Rut : GLib.Object {
public class Rut : Object {
/**
* The cleaned RUT
*/
@@ -177,7 +177,7 @@ namespace LibSernatur {
try {
var regex = new Regex ("^[ ]*([0-9.]{0,11}[\\-]?[0-9kK])?[ ]*$");
if (!regex.match (rut)) {
throw new InvalidRut.INVALID (dgettext (null, "The RUT %s has an invalid character!"), rut);
throw new InvalidRut.INVALID (_ ("The RUT %s has an invalid character!"), rut);
}
}
catch (Error e) {
@@ -193,12 +193,12 @@ namespace LibSernatur {
new_rut = new_rut.strip ();
rut = regex.replace (new_rut, new_rut.length, 0, "");
if (int.parse (rut.substring (0, rut.length - 1)) > 100000000) {
throw new InvalidRut.TOOLARGE (dgettext (null, "The RUT %s is too big!"), rut);
throw new InvalidRut.TOOLARGE (_ ("The RUT %s is too big!"), rut);
}
this.verifier = rut.get_char (rut.length - 1);
this.clean_rut = rut.substring (0, rut.length - 1);
if (generate_verfifier (this.clean_rut) != this.verifier) {
throw new InvalidRut.INVALIDVERIFIER (dgettext (null, "The verifier %C is invalid!"), this.verifier);
throw new InvalidRut.INVALIDVERIFIER (_ ("The verifier %C is invalid!"), this.verifier);
}
pretty();
}

+ 39
- 5
lib/queries.vala View File

@@ -17,15 +17,16 @@ namespace LibSernatur {
/**
* The queries to use to work in the database
*/
public class Query < T > : GLib.Object {
public class Query < T > : Object {
public enum Type {
SELECT_ALL_TOURS,
INSERT_TOUR,
UPDATE_TOUR,
DELETE_TOUR
DELETE_TOUR,
SELECT_ALL_ASSOCIATED_BY_TOUR
}

public static string get_query (Type type, T? t) {
public static string get_query (Connection conn, Type type, T? t) throws PostgresError {
switch (type) {
case SELECT_ALL_TOURS:
return "
@@ -39,16 +40,49 @@ JOIN region R ON (C.id_region = R.id_region)";
Tour tour = (Tour) t;
return "
UPDATE tour SET
nombre_tour = '" + tour.nombre_tour + "',
nombre_tour = '" + conn.escape (tour.nombre_tour) + "',
costo_indiv = " + tour.costo_indiv.to_string () + ",
costo_grupal = " + tour.costo_grupal.to_string () + ",
minima_personas = " + tour.minima_personas.to_string () + "
minima_personas = " + tour.minima_personas.to_string () + ",
id_ciudad = " + tour.ciudad.id_ciudad.to_string () + "
WHERE id_tour = " + tour.id_tour.to_string ();
case INSERT_TOUR:
Tour tour = (Tour) t;
return "
INSERT INTO tour
(nombre_tour, costo_indiv, costo_grupal, minima_personas, id_ciudad)
VALUES
(
'" + conn.escape (tour.nombre_tour) + "',
" + tour.costo_indiv.to_string () + ",
" + tour.costo_grupal.to_string () + ",
" + tour.minima_personas.to_string () + ",
" + tour.ciudad.id_ciudad.to_string () + "
)
RETURNING id_tour";
case DELETE_TOUR:
Tour tour = (Tour) t;
return "
DELETE FROM tour
WHERE id_tour = " + tour.id_tour.to_string ();
case SELECT_ALL_ASSOCIATED_BY_TOUR:
Tour tour = (Tour) t;
return "
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,
R.id_region, R.nombre_region,
L.id_lugar, L.nombre_lugar, L.valor_entrada, L.nivel,
C2.id_ciudad AS id_ciudad_lugar, C2.nombre_ciudad AS nombre_ciudad_lugar,
R2.id_region AS id_region_lugar, R2.nombre_region AS nombre_region_lugar
FROM asociado A
JOIN tour T ON (A.id_tour = T.id_tour)
JOIN ciudad C ON (T.id_ciudad = C.id_ciudad)
JOIN region R ON (C.id_region = R.id_region)
JOIN lugar L ON (A.id_lugar = L.id_lugar)
JOIN ciudad C2 ON (L.id_ciudad = C2.id_ciudad)
JOIN region R2 ON (C2.id_region = R2.id_region)
WHERE t.id_tour = " + tour.id_tour.to_string ();
default:
return "";
}

+ 1
- 1
po/LINGUAS View File

@@ -1 +1 @@
es
es es_CL

+ 2
- 0
po/POTFILES View File

@@ -5,11 +5,13 @@ src/sernatur.vala
src/main_window.vala
src/tour_list.vala
src/tour_editor.vala
src/tour_places.vala
src/query_window.vala
data/ui/main.window.ui
data/ui/main.splash.ui
data/ui/tour.list.ui
data/ui/tour.editor.ui
data/ui/tour.places.ui
data/ui/query.window.ui
data/ui/query.tree.ui
data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml

+ 102
- 40
po/es.po View File

@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: sernatur\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-17 09:59-0300\n"
"PO-Revision-Date: 2019-01-17 10:01-0300\n"
"POT-Creation-Date: 2019-01-18 17:59-0300\n"
"PO-Revision-Date: 2019-01-18 18:02-0300\n"
"Last-Translator: Chris Cromer <chris@cromer.cl>\n"
"Language-Team: none\n"
"Language: es\n"
@@ -47,7 +47,7 @@ msgstr "El verificador %C es invalido!"
#: src/sernatur.vala:88
#, c-format
msgid "Error: %s\n"
msgstr "Error %s\n"
msgstr "Error: %s\n"

#: src/sernatur.vala:89
#, c-format
@@ -65,39 +65,44 @@ msgstr "Versión de SERNATUR: "
msgid "Error: Could not connect to the database!"
msgstr "Error: No se puede conectar al base de datos!"

#: src/main_window.vala:228 src/tour_list.vala:205 src/tour_list.vala:220
#: src/main_window.vala:228 src/tour_list.vala:215 src/tour_list.vala:231
msgid "Error"
msgstr "Error"

#: src/tour_list.vala:181
#: src/tour_list.vala:185
msgid "Are you sure you wish to delete this tour?"
msgstr "¿Usted está seguro que quiere borrar este tour?"

#: src/tour_list.vala:201
#: src/tour_list.vala:192
msgid "Are you sure you wish to delete these tours?"
msgstr "¿Usted está seguro que quiere borrar estos tour?"

#: src/tour_list.vala:211
#, c-format
msgid ""
"Error: Could not delete tour because there are still associated arrival and "
"departure dates and times!"
"Error: Could not delete tour \"%s\" because either this tour has been taken "
"or is still associated with a place or vehicle!"
msgstr ""
"Error: No se puede borrar el tour porque todavía hay fechas y horas de "
"llegada y salida asociado al tour!"
"Error: No se puede borrar el tour \"%s\" porque este tour ya fue realizado "
"o todavía esta asociado con lugares ó vehículos!"

#: src/query_window.vala:290 data/ui/main.window.ui:143
#: src/query_window.vala:290 data/ui/main.window.ui:136
msgid "(Q1) Regions with discounts"
msgstr "(Q1) Regiones sin descuentos"

#: src/query_window.vala:303 data/ui/main.window.ui:151
#: src/query_window.vala:303 data/ui/main.window.ui:144
msgid "(Q2) Tour values"
msgstr "(Q2) Valores tour"

#: src/query_window.vala:316 data/ui/main.window.ui:159
#: src/query_window.vala:316 data/ui/main.window.ui:152
msgid "(Q3) Coordinator total"
msgstr "(Q3) Total de coordinadores"

#: src/query_window.vala:329 data/ui/main.window.ui:167
#: src/query_window.vala:329 data/ui/main.window.ui:160
msgid "(Q4) Tourist total"
msgstr "(Q4) Total de turistas"

#: src/query_window.vala:342 data/ui/main.window.ui:175
#: src/query_window.vala:342 data/ui/main.window.ui:168
msgid "(Q5) Vehicle total"
msgstr "(Q5) Total de vehículos"

@@ -110,34 +115,30 @@ msgid "Tours"
msgstr "Tours"

#: data/ui/main.window.ui:62
msgid "Places"
msgstr "Lugares"

#: data/ui/main.window.ui:69
msgid "Staff"
msgstr "Empleados"

#: data/ui/main.window.ui:77
#: data/ui/main.window.ui:70
msgid "Tourists"
msgstr "Turistas"

#: data/ui/main.window.ui:87
#: data/ui/main.window.ui:80
msgid "Illnesses"
msgstr "Enfermedades"

#: data/ui/main.window.ui:95
#: data/ui/main.window.ui:88
msgid "Participate"
msgstr "Participar"

#: data/ui/main.window.ui:107
#: data/ui/main.window.ui:100
msgid "Vehicles"
msgstr "Vehículos"

#: data/ui/main.window.ui:121
#: data/ui/main.window.ui:114
msgid "Quit"
msgstr "Salir"

#: data/ui/main.window.ui:133
#: data/ui/main.window.ui:126
msgid "_Views"
msgstr "_Vistas"

@@ -145,59 +146,64 @@ msgstr "_Vistas"
msgid "Christopher Cromer"
msgstr "Christopher Cromer"

#: data/ui/tour.list.ui:68 data/ui/tour.editor.ui:54 data/ui/query.tree.ui:80
#: data/ui/tour.list.ui:69 data/ui/tour.editor.ui:54 data/ui/query.tree.ui:80
#: data/ui/query.tree.ui:120 data/ui/query.tree.ui:160
msgid "Tour Name"
msgstr "Nombre del Tour"

#: data/ui/tour.list.ui:82 data/ui/tour.editor.ui:87
#: data/ui/tour.list.ui:83 data/ui/tour.editor.ui:87
msgid "Individual Cost"
msgstr "Costo Individual"

#: data/ui/tour.list.ui:96 data/ui/tour.editor.ui:103
#: data/ui/tour.list.ui:97 data/ui/tour.editor.ui:103
msgid "Group Cost"
msgstr "Costo Grupal"

#: data/ui/tour.list.ui:110 data/ui/tour.editor.ui:119
#: data/ui/tour.list.ui:111 data/ui/tour.editor.ui:119
msgid "Minimum People"
msgstr "Mínima Personas"

#: data/ui/tour.list.ui:124 data/ui/tour.editor.ui:187
#: data/ui/tour.list.ui:125 data/ui/tour.editor.ui:187
msgid "City"
msgstr "Ciudad"

#: data/ui/tour.list.ui:138 data/ui/tour.editor.ui:135
#: data/ui/tour.list.ui:139 data/ui/tour.editor.ui:135
msgid "Region"
msgstr "Región"

#: data/ui/tour.list.ui:170
#: data/ui/tour.list.ui:171 data/ui/tour.places.ui:185
msgid "Edit"
msgstr "Editar"

#: data/ui/tour.list.ui:175
#: data/ui/tour.list.ui:176