Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Started ImportBills

  • Loading branch information...
commit 06cc708a732bfe83e16e20257dd9729b559ff522 1 parent 13c5853
Javier L. Matias-Cabrera authored
View
18 src/controllers/ImportBills.php
@@ -0,0 +1,18 @@
+<?php
+
+require_once(dirname(__FILE__).'/../../config/config.php');
+require_once 'src/service/BillSubjectService.php';
+require_once 'src/service/BillSubjectService.php';
+
+
+/**
+ * Description of ImportBills
+ *
+ * @author Javier L. Matías-Cabrera
+ */
+class ImportBills
+{
+ $billService
+}
+
+?>
View
6 src/dao/BillSubjectMongoDAO.php
@@ -20,6 +20,12 @@ public function addBill($bill)
return $this->add("bills", $bill);
}
+ public function saveBill($bill)
+ {
+ BillModel::checkBill($bill);
+ return $this->save("bills", $bill);
+ }
+
public function updateBill($bill)
{
BillModel::checkBill($bill);
View
4 src/dao/MongoDatabaseDAO.php
@@ -33,7 +33,11 @@ protected function update($collection, $item)
protected function add($collection, $item)
{
return $this->mongoDB->selectCollection($collection)->insert($item);
+ }
+ protected function save($collection, $item)
+ {
+ return $this->mongoDB->selectCollection($collection)->insert($item);
}
protected function find($collection, $query)
View
51 src/service/BillImportService.php
@@ -0,0 +1,51 @@
+<?php
+
+require_once('src/util/ParameterCheck.php');
+require_once('src/model/ModelCheck.php');
+require_once 'src/util/Object.php';
+
+/**
+ * Description of BillSubjectService
+ *
+ * @author Javier L. Matías-Cabrera
+ */
+class BillImportService extends Object
+{
+ /**
+ *
+ * @var BillSubjectMongoDAO
+ */
+ private $billDAO;
+
+ /**
+ *
+ * @var BillyAPIService
+ */
+ private $billyAPI;
+
+
+ public function __construct($billDAO, $billyAPI)
+ {
+ ParamCheck::checkParamClass($billDAO,'BillSubjectMongoDatabaseDAO' , 'billDAO');
+ ParamCheck::checkParamClass($billyAPI,'BillyAPI_DAO' , 'billyAPI');
+ $this->billDAO = $billDAO;
+ $this->billyAPI = $billyAPI;
+ }
+
+ public function importBills($state)
+ {
+ ParamCheck::checkStringParam($state, 'state');
+ $bills = $this->billyAPI->findLowerChamberBillsWithoutSubject($state);
+ foreach($bills as $bill)
+ {
+ $this->billDAO->saveBill($bill);
+ }
+
+ }
+
+
+
+
+}
+
+?>
View
29 src/service/BillSubjectService.php
@@ -1,29 +0,0 @@
-<?php
-
-require_once('src/util/ParameterCheck.php');
-require_once('src/model/ModelCheck.php');
-require_once 'src/util/Object.php';
-
-/**
- * Description of BillSubjectService
- *
- * @author Javier L. Matías-Cabrera
- */
-class BillSubjectService extends Object
-{
- /**
- *
- * @var Mongo
- */
- private $mongo;
-
- public function __construct($mongo)
- {
- ParamCheck::checkParamClass($mongo,'BillSubjectMongoDatabaseDAO' , 'mongo');
- $this->mongo = $mongo;
- }
-
-
-}
-
-?>
View
4 src/service/BillyAPIService.php
@@ -39,12 +39,12 @@ public function findAllLowerChamberBills($state, $offset=0, $limit=25)
return array_slice($bills, $offset,$limit);
}
- public function findLowerChamberBillsWithoutSubject($state, $offset=0, $limit=25)
+ public function findLowerChamberBillsWithoutSubject($state)
{
}
- public function findUpperChamberBillsWithoutSubject($state, $offset=0, $limit=25)
+ public function findUpperChamberBillsWithoutSubject($state)
{
}
View
32 unittest/service/BillImportServiceTest.php
@@ -0,0 +1,32 @@
+<?php
+
+require_once(dirname(__FILE__).'/../../config/config.php');
+require_once 'unittest/TestCaseBase.php';
+require_once 'src/service/BillyImportService.php';
+
+/**
+ * Description of BillyAPIServiceTest
+ *
+ * @author Javier L. Matías-Cabrera
+ */
+class BillImportServiceTest extends TestCaseBase
+{
+
+ public function __construct($name = NULL, array $data = array(), $dataName = '')
+ {
+ parent::__construct($name, $data, $dataName);
+
+ }
+
+ protected function setUp()
+ {
+ }
+
+ protected function tearDown()
+ {
+ }
+
+
+}
+
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.