start the 3rd assignment

This commit is contained in:
Chris Cromer 2019-01-03 19:47:43 -03:00
parent 21f57a86e7
commit 18dafc38e1
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A
63 changed files with 1818 additions and 233 deletions

View File

@ -15,6 +15,7 @@
<gresources>
<gresource prefix="/cl/cromer/ubb/sernatur">
<file preprocess="xml-stripblanks">sernatur.window.ui</file>
<file preprocess="xml-stripblanks">splash.ui</file>
<file preprocess="to-pixdata">pixdata/logo-sernatur.svg</file>
</gresource>
</gresources>

View File

@ -14,8 +14,8 @@ Redistribution and use in source and binary forms, with or without modification,
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>
<requires lib="gtk+" version="3.10"/>
<interface domain="sernatur">
<requires lib="gtk+" version="3.20"/>
<template class="SernaturMainWindow" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="title">SERNATUR</property>
@ -31,6 +31,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="baseline_position">top</property>
<child>
<object class="GtkMenuBar" id="menubar">
<property name="visible">True</property>
@ -39,46 +40,64 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_File</property>
<property name="label" translatable="yes">_Menu</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-new</property>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<property name="right_justified">True</property>
<property name="label" translatable="yes">Tours</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-open</property>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Guides and Staff</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save</property>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Tourists</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Illnesses</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Tour</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save-as</property>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Vehicles</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
@ -88,93 +107,12 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-quit</property>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Quit</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-cut</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="menu_quit" swapped="no"/>
</object>
</child>
</object>
@ -189,16 +127,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
</packing>
</child>
<child>
<object class="GtkImage" id="logo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="resource">/cl/cromer/ubb/sernatur/pixdata/logo-sernatur.svg</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
<placeholder/>
</child>
</object>
</child>

55
data/ui/splash.ui Normal file
View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1
Copyright 2018 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="GtkGrid" id="content_grid">
<property name="visible">True</property>
<property name="can_focus">False</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="column_homogeneous">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">end</property>
<property name="resource">/cl/cromer/ubb/sernatur/pixdata/logo-sernatur.svg</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Christopher Cromer</property>
<property name="justify">center</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</interface>

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 128 KiB

View File

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB

View File

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 185 KiB

View File

@ -1,6 +1,7 @@
docs_enabled = get_option('valadocs')
valadoc = find_program('valadoc', required: docs_enabled)
vala_doc_sources = vala_sources
vala_doc_sources += lib_sources
if docs_enabled
valadocs_deps = get_option('valadocs_deps')
docs_deps = ['--pkg=gtk+-3.0']
@ -29,10 +30,15 @@ if docs_enabled
)
endif
install_data('trabajoSemestral(E1).pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('trabajoSemestral(E2).pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Informe1.pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('MER.dia', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('MER.png', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Enunciados/trabajoSemestral(E1).pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Enunciados/trabajoSemestral(E2).pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Enunciados/trabajoSemestral(E3).pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Informes/Informe1.pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Informes/Informe1corregido.pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Informes/Informe2.pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Informes/MER.dia', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Informes/MER.png', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Informes/MERcorregido.dia', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('Informes/MERcorregido.png', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('../LICENSE', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('../README.md', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))

69
lib/db/arrienda.vala Normal file
View File

@ -0,0 +1,69 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Arrienda : GLib.Object {
public uint precio { get; set; default = 0; }
public string fecha_devolucion { get; set; default = ""; }
public Vehiculo vehiculo { get; set; default = null; }
public Empresa empresa { get; set; default = null; }
public Arrienda (uint precio = 0, string fecha_devolucion = "", Vehiculo? vehiculo = null, Empresa? empresa = null) {
this.precio = precio;
this.fecha_devolucion = fecha_devolucion;
this.vehiculo = vehiculo;
this.empresa = empresa;
}
public static Arrienda[]? get_all_arriendas(Database conn) {
var res = conn.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
FROM arrienda A
JOIN vehiculo V ON (A.patente = V.patente)
JOIN empresa E ON (A.rut_empresa = E.rut_empresa)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Arrienda[] arriendas = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var arrienda = new Arrienda (wra.get_int_n (i, "precio"),
wra.get_string_n (i, "fecha_devolucion"),
new Vehiculo (wra.get_string_n (i, "patente"),
wra.get_int_n (i, "ano_vehiculo"),
wra.get_string_n (i, "marca"),
wra.get_int_n (i, "capacidad")
),
new Empresa (wra.get_string_n (i, "rut_empresa"),
wra.get_string_n (i, "nombre_empresa"),
wra.get_string_n (i, "contacto"),
wra.get_int_n (i, "telefono")
)
);
arriendas += arrienda;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return arriendas;
}
}
}
}

94
lib/db/asociado.vala Normal file
View File

@ -0,0 +1,94 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Asociado : GLib.Object {
public string fecha_llegada { get; set; default = ""; }
public string hora_llegada { get; set; default = ""; }
public string fecha_salida { get; set; default = ""; }
public string hora_salida { get; set; default = ""; }
public Tour tour { get; set; default = null; }
public Lugar lugar { get; set; default = null; }
public Asociado (string fecha_llegada = "", string hora_llegada = "", string fecha_salida = "", string hora_salida = "", Tour? tour = null, Lugar? lugar = null) {
this.fecha_llegada = fecha_llegada;
this.hora_llegada = hora_llegada;
this.fecha_salida = fecha_salida;
this.hora_salida = hora_salida;
}
public static Asociado[]? get_all_asociados(Database conn) {
var res = conn.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,
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_cuidad = 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)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Asociado[] asociados = {};
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_tour"),
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")
)
)
)
);
asociados += asociado;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return asociados;
}
}
}
}

50
lib/db/categoria.vala Normal file
View File

@ -0,0 +1,50 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Categoria : GLib.Object {
public uint id_categoria { get; set; default = 0; }
public string descripcion_categoria { get; set; default = ""; }
public Categoria (uint id_categoria = 0, string descripcion_categoria = "") {
this.id_categoria = id_categoria;
this.descripcion_categoria = descripcion_categoria;
}
public static Categoria[]? get_all_categorias(Database conn) {
var res = conn.exec ("
SELECT id_categoria, descripcion_categoria FROM categoria
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Categoria[] categorias = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var categoria = new Categoria (wra.get_int_n (i, "id_categoria"),
wra.get_string_n (i, "descripcion_categoria")
);
categorias += categoria;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return categorias;
}
}
}
}

58
lib/db/ciudad.vala Normal file
View File

@ -0,0 +1,58 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Ciudad : GLib.Object {
public uint id_ciudad { get; set; default = 0; }
public string nombre_ciudad { get; set; default = ""; }
public Region region { get; set; default = null; }
public Ciudad (uint id_ciudad = 0, string nombre_ciudad = "", Region? region = null) {
this.id_ciudad = id_ciudad;
this.nombre_ciudad = nombre_ciudad;
this.region = region;
}
public static Ciudad[]? get_all_ciudades(Database conn) {
var res = conn.exec ("
SELECT C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region
FROM ciudad C
JOIN region R ON (C.id_region = R.id_region)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Ciudad[] ciudades = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var ciudad = 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")
)
);
ciudades += ciudad;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return ciudades;
}
}
}
}

View File

@ -0,0 +1,51 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class ContactoEmergencia : GLib.Object {
public uint id_contacto { get; set; default = 0; }
public uint telefono_emergencia { get; set; default = 0; }
public string nombre_emergencia { get; set; default = ""; }
public ContactoEmergencia (uint id_contacto = 0, uint telefono_emergencia = 0, string nombre_emergencia = "") {
this.id_contacto = id_contacto;
this.telefono_emergencia = telefono_emergencia;
this.nombre_emergencia = nombre_emergencia;
}
public static ContactoEmergencia[]? get_all_contactos(Database conn) {
var res = conn.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 ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
ContactoEmergencia[] contactos = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var contacto = new ContactoEmergencia (wra.get_int_n (i, "id_contacto"),
wra.get_int_n (i, "telefono_emergencia"),
wra.get_string_n (i, "nombre_emergencia")
);
contactos += contacto;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return contactos;
}
}
}
}

53
lib/db/descuento.vala Normal file
View File

@ -0,0 +1,53 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Descuento : GLib.Object {
public uint id_descuento { get; set; default = 0; }
public string descripcion_descuento { get; set; default = ""; }
public float porcentaje { get; set; default = 0; }
public Descuento (uint id_descuento = 0, string descripcion_descuento = "", float porcentaje = 0) {
this.id_descuento = id_descuento;
this.descripcion_descuento = descripcion_descuento;
this.porcentaje = porcentaje;
}
public static Descuento[]? get_all_descuentos(Database conn) {
var res = conn.exec ("
SELECT id_descuento, descripcion_descuento, porcentaje FROM descuento
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Descuento[] descuentos = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var descuento = new Descuento (wra.get_int_n (i, "id_descuento"),
wra.get_string_n (i, "descripcion_descuento"),
wra.get_float_n (i, "porcentaje")
);
descuentos += descuento;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return descuentos;
}
}
}
}

56
lib/db/empresa.vala Normal file
View File

@ -0,0 +1,56 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Empresa : GLib.Object {
public string rut_empresa { get; set; default = ""; }
public string nombre_empresa { get; set; default = ""; }
public string contacto { get; set; default = ""; }
public uint telefono { get; set; default = 0; }
public Empresa (string rut_empresa = "", string nombre_empresa = "", string contacto = "", uint telefono = 0) {
this.rut_empresa = rut_empresa;
this.nombre_empresa = nombre_empresa;
this.contacto = contacto;
this.telefono = telefono;
}
public static Empresa[]? get_all_empresas(Database conn) {
var res = conn.exec ("
SELECT rut_empresa, nombre_empresa, contacto, telefono FROM empresa
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Empresa[] empresas = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var empresa = new Empresa (wra.get_string_n (i, "rut_empresa"),
wra.get_string_n (i, "nombre_empresa"),
wra.get_string_n (i, "contacto"),
wra.get_int_n (i, "telefono")
);
empresas += empresa;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return empresas;
}
}
}
}

50
lib/db/enfermedad.vala Normal file
View File

@ -0,0 +1,50 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Enfermedad : GLib.Object {
public uint id_enfermedad { get; set; default = 0; }
public string descripcion_enfermedad { get; set; default = ""; }
public Enfermedad (uint id_enfermedad = 0, string descripcion_enfermedad = "") {
this.id_enfermedad = id_enfermedad;
this.descripcion_enfermedad = descripcion_enfermedad;
}
public static Enfermedad[]? get_all_enfermedades(Database conn) {
var res = conn.exec ("
SELECT id_enfermedad, descripcion_enfermedad FROM enfermedad
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Enfermedad[] enfermedades = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var enfermedad = new Enfermedad (wra.get_int_n (i, "id_enfermedad"),
wra.get_string_n (i, "descripcion_enfermedad")
);
enfermedades += enfermedad;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return enfermedades;
}
}
}
}

50
lib/db/especialidad.vala Normal file
View File

@ -0,0 +1,50 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Especialidad : GLib.Object {
public uint id_especialidad { get; set; default = 0; }
public string descripcion_especialidad { get; set; default = ""; }
public Especialidad (uint id_especialidad = 0, string descripcion_especialidad = "") {
this.id_especialidad = id_especialidad;
this.descripcion_especialidad = descripcion_especialidad;
}
public static Especialidad[]? get_all_especialidades(Database conn) {
var res = conn.exec ("
SELECT id_especialidad, descripcion_especialidad FROM especialidad
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Especialidad[] especialidades = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var especialidad = new Especialidad (wra.get_int_n (i, "id_especialidad"),
wra.get_string_n (i, "descripcion_especialidad")
);
especialidades += especialidad;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return especialidades;
}
}
}
}

69
lib/db/guia.vala Normal file
View File

@ -0,0 +1,69 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Guia : GLib.Object {
public string rut_guia { get; set; default = ""; }
public string nombre_guia { get; set; default = ""; }
public string calle { get; set; default = ""; }
public uint numero { get; set; default = 0; }
public Ciudad ciudad { get; set; default = null; }
public Guia (string rut_guia = "", string nombre_guia = "", string calle = "", uint numero = 0, Ciudad? ciudad = null) {
this.rut_guia = rut_guia;
this.nombre_guia = nombre_guia;
this.calle = calle;
this.numero = numero;
this.ciudad = ciudad;
}
public static Guia[]? get_all_guias(Database conn) {
var res = conn.exec ("
SELECT G.rut_guia, G.nombre_guia, G.calle, G.numero,
C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region
FROM guia G
JOIN ciudad C ON (G.id_ciudad = C.id_ciudad)
JOIN region R ON (C.id_region = R.id_region)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Guia[] guias = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var guia = new Guia (wra.get_string_n (i, "rut_guia"),
wra.get_string_n (i, "nombre_guia"),
wra.get_string_n (i, "calle"),
wra.get_int_n (i, "numero"),
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")
)
)
);
guias += guia;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return guias;
}
}
}
}

69
lib/db/lugar.vala Normal file
View File

@ -0,0 +1,69 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Lugar : GLib.Object {
public uint id_lugar { get; set; default = 0; }
public string nombre_lugar { get; set; default = ""; }
public uint valor_entrada { get; set; default = 0; }
public uint nivel { get; set; default = 0; }
public Ciudad ciudad { get; set; default = null; }
public Lugar (uint id_lugar = 0, string nombre_lugar = "", uint valor_entrada = 0, uint nivel = 0, Ciudad? ciudad = null) {
this.id_lugar = id_lugar;
this.nombre_lugar = nombre_lugar;
this.valor_entrada = valor_entrada;
this.nivel = nivel;
this.ciudad = ciudad;
}
public static Lugar[]? get_all_lugares(Database conn) {
var res = conn.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
FROM lugar L
JOIN ciudad C ON (L.id_ciudad = C.id_ciudad)
JOIN region R ON (C.id_region = R.id_region)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Lugar[] lugares = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var lugar = 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"),
wra.get_string_n (i, "nombre_ciudad"),
new Region(wra.get_int_n (i, "id_region"),
wra.get_string_n (i, "nombre_region")
)
)
);
lugares += lugar;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return lugares;
}
}
}
}

90
lib/db/participa.vala Normal file
View File

@ -0,0 +1,90 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Participa : GLib.Object {
public Tour tour { get; set; default = null; }
public Guia guia { get; set; default = null; }
public Categoria categoria { get; set; default = null; }
public Participa (Tour? tour = null, Guia? guia = null, Categoria? categoria = null) {
this.tour = tour;
this.guia = guia;
this.categoria = categoria;
}
public static Participa[]? get_all_participas(Database conn) {
var res = conn.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,
G.rut_guia, G.nombre_guia, G.calle, G.numero,
C2.id_ciudad AS id_ciudad_guia, C2.nombre_ciudad AS nombre_ciudad_guia,
R2.id_region AS id_region_guia, R2.nombre_region AS nombre_region_guia,
C3.id_categoria, C3.descripcion_categoria
FROM participa P
JOIN tour T ON (P.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 guia G on (P.rut_guia = G.rut_guia)
JOIN ciudad C2 ON (G.id_ciudad = C2.id_ciudad)
JOIN region R2 ON (C2.id_region = R2.id_region)
JOIN categoria C3 ON (P.id_categoria = C3.id_categoria)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper(res);
Participa[] participas = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var participa = new Participa (
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 Guia (wra.get_string_n (i, "rut_guia"),
wra.get_string_n (i, "nombre_guia"),
wra.get_string_n (i, "calle"),
wra.get_int_n (i, "numero"),
new Ciudad (wra.get_int_n (i, "id_ciudad_guia"),
wra.get_string_n (i, "id_region_guia"),
new Region (wra.get_int_n (i, "id_region_guia"),
wra.get_string_n (i, "nombre_region_guia"))
)
),
new Categoria (wra.get_int_n (i, "id_categoria"),
wra.get_string_n (i, "descripcion_categoria")
)
);
participas += participa;
}
catch (Error e) {
#if DEBUG
error (e.message);
#else
warning (e.message);
#endif
}
}
return participas;
}
}
}
}

74
lib/db/posee.vala Normal file
View File

@ -0,0 +1,74 @@
namespace Sernatur {
namespace DB {
using Postgres;
using Wrapper;
public class Posee : GLib.Object {
public uint nivel_especialidad { get; set; default = 0; }
public Guia guia { get; set; default = null; }
public Especialidad especialidad { get; set; default = null; }
public Posee (uint nivel_especialidad = 0, Guia? guia = null, Especialidad? especialidad = null) {
this.nivel_especialidad = nivel_especialidad;
this.guia = guia;
this.especialidad = especialidad;
}
public static Posee[]? get_all_posees(Database conn) {
var res = conn.exec ("
SELECT P.nivel_especialidad,
G.rut_guia, G.nombre_guia, G.calle, G.numero,
C.id_ciudad, C.nombre_ciudad,
R.id_region, R.nombre_region,
E.id_especialidad, E.descripcion_especialidad
FROM posee P
JOIN guia G on (P.rut_guia = G.rut_guia)
JOIN ciudad C ON (G.id_ciudad = C.id_ciudad)
JOIN region R ON (C.id_region = R.id_region)
JOIN especialidad E ON (P.id_especialidad = E.id_especialidad)
");
if (res.get_status () != ExecStatus.TUPLES_OK) {
#if DEBUG
error (conn.get_error_message ());
#else
warning (conn.get_error_message ());
return null;
#endif
}
var wra = new ResultWrapper (res);
Posee[] posees = {};
int n = res.get_n_tuples ();
for (int i = 0; i < n; i++) {
try {
var posee = new Posee (wra.get_int_n (i, "nivel_especialidad"),
new Guia (wra.get_string_n (i, "rut_guia"),
wra.get_string_n (i, "nombre_guia"),
wra.get_string_n (i, "calle"),
wra.get_int_n (i, "numero"),
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")
)
)
),