From 6f07a95cafaa4b7eb13d393f8e37c0fe0bdb0e40 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Date: Tue, 24 Aug 2010 11:20:04 -0300 Subject: [PATCH] Adicionado módulo {{{TransporteEscolar}}}: --- ieducar/misc/database/deltas/26_cria_tabela_modules_transporte_aluno.sql | 31 +++++++++++++++++++++++++++++++ ieducar/misc/database/ieducar.sql | 36 ++++++++++++++++++++++++++++++++++++ ieducar/modules/Transporte/Model/Aluno.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/modules/Transporte/Model/AlunoDataMapper.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/modules/Transporte/Model/Responsavel.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/modules/Transporte/_data/install.sql | 15 +++++++++++++++ ieducar/modules/Transporte/_tests/AlunoTest.php | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 353 insertions(+), 0 deletions(-) create mode 100644 ieducar/misc/database/deltas/26_cria_tabela_modules_transporte_aluno.sql create mode 100644 ieducar/modules/Transporte/Model/Aluno.php create mode 100644 ieducar/modules/Transporte/Model/AlunoDataMapper.php create mode 100644 ieducar/modules/Transporte/Model/Responsavel.php create mode 100644 ieducar/modules/Transporte/_data/install.sql create mode 100644 ieducar/modules/Transporte/_tests/AlunoTest.php diff --git a/ieducar/misc/database/deltas/26_cria_tabela_modules_transporte_aluno.sql b/ieducar/misc/database/deltas/26_cria_tabela_modules_transporte_aluno.sql new file mode 100644 index 0000000..bd1705a --- /dev/null +++ b/ieducar/misc/database/deltas/26_cria_tabela_modules_transporte_aluno.sql @@ -0,0 +1,31 @@ +-- // + +-- +-- Cria a tabela transporte_aluno no schema modules. +-- +-- @author Eriksen Costa Paixão +-- @license @@license@@ +-- @version $Id$ +-- + +CREATE TABLE modules.transporte_aluno +( + aluno_id integer NOT NULL, + responsavel integer NOT NULL, + user_id integer NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone, + CONSTRAINT transporte_aluno_pk PRIMARY KEY (aluno_id) +) WITH (OIDS=FALSE); + +ALTER TABLE modules.transporte_aluno ADD + CONSTRAINT transporte_aluno_aluno_fk + FOREIGN KEY (aluno_id) + REFERENCES pmieducar.aluno (cod_aluno) + ON UPDATE NO ACTION ON DELETE CASCADE; + +-- //@UNDO + +DROP TABLE modules.transporte_aluno; + +-- // \ No newline at end of file diff --git a/ieducar/misc/database/ieducar.sql b/ieducar/misc/database/ieducar.sql index 911ae64..73ca0ad 100644 --- a/ieducar/misc/database/ieducar.sql +++ b/ieducar/misc/database/ieducar.sql @@ -10831,6 +10831,19 @@ ALTER SEQUENCE tabela_arredondamento_valor_id_seq OWNED BY tabela_arredondamento SELECT pg_catalog.setval('tabela_arredondamento_valor_id_seq', 1, false); +-- +-- Name: transporte_aluno; Type: TABLE; Schema: modules; Owner: -; Tablespace: +-- + +CREATE TABLE transporte_aluno ( + aluno_id integer NOT NULL, + responsavel integer NOT NULL, + user_id integer NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone +); + + SET search_path = pmiacoes, pg_catalog; -- @@ -17816,6 +17829,12 @@ SET search_path = modules, pg_catalog; +-- +-- Data for Name: transporte_aluno; Type: TABLE DATA; Schema: modules; Owner: - +-- + + + SET search_path = pmiacoes, pg_catalog; -- @@ -20139,6 +20158,7 @@ INSERT INTO changelog VALUES (22, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '22_cria INSERT INTO changelog VALUES (23, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '23_cria_tabela_modules_componente_curricular_turma.sql'); INSERT INTO changelog VALUES (24, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '24_altera_tipo_campo_carga_horaria_pmieducar_servidor_alocacao.sql'); INSERT INTO changelog VALUES (25, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '25_adiciona_campo_zona_localizacao_tabelas_enderecamento.sql'); +INSERT INTO changelog VALUES (26, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '26_cria_tabela_modules_transporte_aluno.sql'); -- @@ -27152,6 +27172,14 @@ ALTER TABLE ONLY tabela_arredondamento_valor ADD CONSTRAINT tabela_arredondamento_valor_pkey PRIMARY KEY (id); +-- +-- Name: transporte_aluno_pk; Type: CONSTRAINT; Schema: modules; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY transporte_aluno + ADD CONSTRAINT transporte_aluno_pk PRIMARY KEY (aluno_id); + + SET search_path = pmiacoes, pg_catalog; -- @@ -32944,6 +32972,14 @@ ALTER TABLE ONLY tabela_arredondamento_valor ADD CONSTRAINT tabela_arredondamento_tabela_arredondamento_valor_fk FOREIGN KEY (tabela_arredondamento_id) REFERENCES tabela_arredondamento(id) ON UPDATE RESTRICT ON DELETE RESTRICT; +-- +-- Name: transporte_aluno_aluno_fk; Type: FK CONSTRAINT; Schema: modules; Owner: - +-- + +ALTER TABLE ONLY transporte_aluno + ADD CONSTRAINT transporte_aluno_aluno_fk FOREIGN KEY (aluno_id) REFERENCES pmieducar.aluno(cod_aluno) ON DELETE CASCADE; + + SET search_path = pmiacoes, pg_catalog; -- diff --git a/ieducar/modules/Transporte/Model/Aluno.php b/ieducar/modules/Transporte/Model/Aluno.php new file mode 100644 index 0000000..5afbd2a --- /dev/null +++ b/ieducar/modules/Transporte/Model/Aluno.php @@ -0,0 +1,82 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package Transporte + * @subpackage Modules + * @since Arquivo disponível desde a versão 1.2.0 + * @version $Id$ + */ + +require_once 'CoreExt/Entity.php'; + +/** + * Transporte_Model_Aluno class. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package Transporte + * @subpackage Modules + * @since Classe disponível desde a versão 1.2.0 + * @version @@package_version@@ + */ +class Transporte_Model_Aluno extends CoreExt_Entity +{ + protected $_data = array( + 'aluno' => NULL, + 'responsavel' => NULL, + 'user' => NULL, + 'created_at' => NULL, + 'updated_at' => NULL + ); + + protected $_references = array( + 'responsavel' => array( + 'value' => NULL, + 'class' => 'Transporte_Model_Responsavel', + 'file' => 'Transporte/Model/Responsavel.php' + ) + ); + + public function __construct($options = array()) + { + parent::__construct($options); + unset($this->_data['id']); + } + + public function getDefaultValidatorCollection() + { + require_once 'Transporte/Model/Responsavel.php'; + $responsavel = Transporte_Model_Responsavel::getInstance(); + + return array( + 'aluno' => new CoreExt_Validate_Numeric(), + 'responsavel' => new CoreExt_Validate_Choice(array( + 'choices' => $responsavel->getKeys()) + ), + 'user' => new CoreExt_Validate_Numeric() + ); + } +} \ No newline at end of file diff --git a/ieducar/modules/Transporte/Model/AlunoDataMapper.php b/ieducar/modules/Transporte/Model/AlunoDataMapper.php new file mode 100644 index 0000000..fe146d8 --- /dev/null +++ b/ieducar/modules/Transporte/Model/AlunoDataMapper.php @@ -0,0 +1,61 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package Transporte + * @subpackage Modules + * @since Arquivo disponível desde a versão 1.2.0 + * @version $Id$ + */ + +require_once 'CoreExt/DataMapper.php'; +require_once 'Transporte/Model/Aluno.php'; + +/** + * Transporte_Model_AlunoDataMapper class. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package Transporte + * @subpackage Modules + * @since Classe disponível desde a versão 1.2.0 + * @version @@package_version@@ + */ +class Transporte_Model_AlunoDataMapper extends CoreExt_DataMapper +{ + protected $_entityClass = 'Transporte_Model_Aluno'; + protected $_tableName = 'transporte_aluno'; + protected $_tableSchema = 'modules'; + + protected $_attributeMap = array( + 'aluno' => 'aluno_id', + 'responsavel' => 'responsavel', + 'user' => 'user_id', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at' + ); + + protected $_primaryKey = array('aluno'); +} \ No newline at end of file diff --git a/ieducar/modules/Transporte/Model/Responsavel.php b/ieducar/modules/Transporte/Model/Responsavel.php new file mode 100644 index 0000000..7fb906d --- /dev/null +++ b/ieducar/modules/Transporte/Model/Responsavel.php @@ -0,0 +1,59 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package Transporte + * @subpackage Modules + * @since Arquivo disponível desde a versão 1.2.0 + * @version $Id$ + */ + +require_once 'CoreExt/Enum.php'; + +/** + * Transporte_Model_Responsavel class. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package Transporte + * @subpackage Modules + * @since Classe disponível desde a versão 1.2.0 + * @version @@package_version@@ + */ +class Transporte_Model_Responsavel extends CoreExt_Enum +{ + const ESTADUAL = 1; + const MUNICIPAL = 2; + + protected $_data = array( + self::ESTADUAL => 'Estadual', + self::MUNICIPAL => 'Municipal' + ); + + public static function getInstance() + { + return self::_getInstance(__CLASS__); + } +} \ No newline at end of file diff --git a/ieducar/modules/Transporte/_data/install.sql b/ieducar/modules/Transporte/_data/install.sql new file mode 100644 index 0000000..542337b --- /dev/null +++ b/ieducar/modules/Transporte/_data/install.sql @@ -0,0 +1,15 @@ +CREATE TABLE modules.transporte_aluno +( + aluno_id integer NOT NULL, + responsavel integer NOT NULL, + user_id integer NOT NULL, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone, + CONSTRAINT transporte_aluno_pk PRIMARY KEY (aluno_id) +) WITH (OIDS=FALSE); + +ALTER TABLE modules.transporte_aluno ADD + CONSTRAINT transporte_aluno_aluno_fk + FOREIGN KEY (aluno_id) + REFERENCES pmieducar.aluno (cod_aluno) + ON UPDATE NO ACTION ON DELETE CASCADE; \ No newline at end of file diff --git a/ieducar/modules/Transporte/_tests/AlunoTest.php b/ieducar/modules/Transporte/_tests/AlunoTest.php new file mode 100644 index 0000000..e4385e1 --- /dev/null +++ b/ieducar/modules/Transporte/_tests/AlunoTest.php @@ -0,0 +1,69 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package Transporte + * @subpackage UnitTests + * @since Arquivo disponível desde a versão 1.2.0 + * @version $Id$ + */ + +require_once 'Transporte/Model/Aluno.php'; +require_once 'Transporte/Model/Responsavel.php'; + +/** + * Transporte_Model_AlunoTest class. + * + * @author Eriksen Costa Paixão + * @category i-Educar + * @license @@license@@ + * @package Transporte + * @subpackage UnitTests + * @since Classe disponível desde a versão 1.2.0 + * @version @@package_version@@ + */ +class Transporte_Model_AlunoTest extends UnitBaseTest +{ + protected $_entity = NULL; + + protected function setUp() + { + $this->_entity = new Transporte_Model_Aluno(); + } + + public function testEntityValidators() + { + // Recupera os objetos CoreExt_Validate + $validators = $this->_entity->getDefaultValidatorCollection(); + $this->assertType('CoreExt_Validate_Numeric', $validators['aluno']); + $this->assertType('CoreExt_Validate_Choice', $validators['responsavel']); + $this->assertType('CoreExt_Validate_Numeric', $validators['user']); + + // Verifica se a opção 'choices' corresponde aos valores do Enum Responsavel. + $responsavel = Transporte_Model_Responsavel::getInstance(); + $this->assertEquals( + $responsavel->getKeys(), $validators['responsavel']->getOption('choices') + ); + } +} \ No newline at end of file -- libgit2 0.21.2