Browse Source

fixed camera types

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
d4f50b0fae

+ 14
- 0
app/Http/Business/CameraTypesBusiness.php View File

@@ -0,0 +1,14 @@
1
+<?php
2
+
3
+namespace App\Http\Business;
4
+
5
+use Luticate\Utils\LuBusiness;
6
+use App\Http\DataAccess\CameraTypesDataAccess;
7
+use App\Http\DBO\CameraTypesDbo;
8
+
9
+class CameraTypesBusiness extends LuBusiness {
10
+    protected static function getDataAccess()
11
+    {
12
+        return new CameraTypesDataAccess();
13
+    }
14
+}

+ 1
- 5
app/Http/Business/CamerasBusiness.php View File

@@ -2,7 +2,6 @@
2 2
 
3 3
 namespace App\Http\Business;
4 4
 
5
-use App\Http\DataAccess\Models\EntityTypes;
6 5
 use Luticate\Utils\LuBusiness;
7 6
 use App\Http\DataAccess\CamerasDataAccess;
8 7
 use App\Http\DBO\CamerasDbo;
@@ -23,10 +22,7 @@ class CamerasBusiness extends LuBusiness {
23 22
             self::badInput("Missing camera name");
24 23
         }
25 24
         HostsBusiness::getById($camera->getHostId());
26
-        $type = EntityTypesBusiness::getById($camera->getEntityTypeId());
27
-        if ($type->getType() != EntityTypesBusiness::ENTITY_CAMERA) {
28
-            self::badInput("Bad camera type");
29
-        }
25
+        CameraTypesBusiness::getById($camera->getCameraTypeId());
30 26
         if (is_null($camera->getDescription())) {
31 27
             $camera->setDescription("");
32 28
         }

+ 0
- 21
app/Http/Business/EntityTypesBusiness.php View File

@@ -1,21 +0,0 @@
1
-<?php
2
-
3
-namespace App\Http\Business;
4
-
5
-use Luticate\Utils\LuBusiness;
6
-use App\Http\DataAccess\EntityTypesDataAccess;
7
-use App\Http\DBO\EntityTypesDbo;
8
-
9
-class EntityTypesBusiness extends LuBusiness {
10
-    const ENTITY_CAMERA = 1;
11
-
12
-    protected static function getDataAccess()
13
-    {
14
-        return new EntityTypesDataAccess();
15
-    }
16
-
17
-    public static function getAllForType($type)
18
-    {
19
-        return EntityTypesDataAccess::getAllForType($type);
20
-    }
21
-}

+ 14
- 0
app/Http/Business/SensorsBusiness.php View File

@@ -0,0 +1,14 @@
1
+<?php
2
+
3
+namespace App\Http\Business;
4
+
5
+use Luticate\Utils\LuBusiness;
6
+use App\Http\DataAccess\SensorsDataAccess;
7
+use App\Http\DBO\SensorsDbo;
8
+
9
+class SensorsBusiness extends LuBusiness {
10
+    protected static function getDataAccess()
11
+    {
12
+        return new SensorsDataAccess();
13
+    }
14
+}

+ 6
- 3
app/Http/Controller/CamerasController.php View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 namespace App\Http\Controller;
4 4
 
5
-use App\Http\Business\EntityTypesBusiness;
5
+use App\Http\Business\CameraTypesBusiness;
6 6
 use Luticate\Utils\LuController;
7 7
 use App\Http\Business\CamerasBusiness;
8 8
 use App\Http\DBO\CamerasDbo;
@@ -16,11 +16,14 @@ class CamerasController extends LuController {
16 16
 
17 17
     /**
18 18
      * Get all camera types
19
+     * @param int $page The page number, 0 based
20
+     * @param int $perPage The number of items per page
21
+     * @param string $query The filter query
19 22
      * @return LuMultipleDbo
20 23
      */
21
-    public function getAllTypes()
24
+    public function getAllTypes($page = 0, $perPage = PHP_INT_MAX, $query = "")
22 25
     {
23
-        return EntityTypesBusiness::getAllForType(EntityTypesBusiness::ENTITY_CAMERA);
26
+        return CameraTypesBusiness::getAll($page, $perPage, $query);
24 27
     }
25 28
 
26 29
     /**

+ 14
- 0
app/Http/Controller/SensorsController.php View File

@@ -0,0 +1,14 @@
1
+<?php
2
+
3
+namespace App\Http\Controller;
4
+
5
+use Luticate\Utils\LuController;
6
+use App\Http\Business\SensorsBusiness;
7
+use App\Http\DBO\SensorsDbo;
8
+
9
+class SensorsController extends LuController {
10
+    protected function getBusiness()
11
+    {
12
+        return new SensorsBusiness();
13
+    }
14
+}

app/Http/DBO/EntityTypesDbo.php → app/Http/DBO/CameraTypesDbo.php View File

@@ -9,7 +9,7 @@ namespace App\Http\DBO;
9 9
 
10 10
 use Luticate\Utils\LuDbo;
11 11
 
12
-class EntityTypesDbo extends LuDbo {
12
+class CameraTypesDbo extends LuDbo {
13 13
 
14 14
     public function jsonSerialize()
15 15
     {
@@ -17,14 +17,13 @@ class EntityTypesDbo extends LuDbo {
17 17
             "Id" => $this->_id,
18 18
             "Name" => $this->_name,
19 19
             "Class" => $this->_class,
20
-            "DefaultData" => $this->_defaultData,
21
-            "Type" => $this->_type
20
+            "DefaultData" => $this->_defaultData
22 21
         );
23 22
     }
24 23
 
25 24
     public static function jsonDeserialize($json)
26 25
     {
27
-        $dbo = new EntityTypesDbo();
26
+        $dbo = new CameraTypesDbo();
28 27
         if (isset($json["Id"])) {
29 28
             $dbo->setId($json["Id"]);
30 29
         }
@@ -37,20 +36,16 @@ class EntityTypesDbo extends LuDbo {
37 36
         if (isset($json["DefaultData"])) {
38 37
             $dbo->setDefaultData($json["DefaultData"]);
39 38
         }
40
-        if (isset($json["Type"])) {
41
-            $dbo->setType($json["Type"]);
42
-        }
43 39
         return $dbo;
44 40
     }
45 41
 
46 42
     public static function generateSample()
47 43
     {
48
-        $dbo = new EntityTypesDbo();
44
+        $dbo = new CameraTypesDbo();
49 45
         $dbo->setId(42);
50 46
         $dbo->setName("sample string");
51 47
         $dbo->setClass("sample string");
52 48
         $dbo->setDefaultData("sample string");
53
-        $dbo->setType(42);
54 49
         return $dbo;
55 50
     }
56 51
 
@@ -105,17 +100,4 @@ class EntityTypesDbo extends LuDbo {
105 100
     {
106 101
         $this->_defaultData = $value;
107 102
     }
108
-
109
-    /**
110
-     * @var integer
111
-     */
112
-    protected $_type;
113
-    public function getType()
114
-    {
115
-        return $this->_type;
116
-    }
117
-    public function setType($value)
118
-    {
119
-        $this->_type = $value;
120
-    }
121 103
 }

+ 9
- 9
app/Http/DBO/CamerasDbo.php View File

@@ -18,7 +18,7 @@ class CamerasDbo extends LuDbo {
18 18
             "Name" => $this->_name,
19 19
             "Description" => $this->_description,
20 20
             "HostId" => $this->_hostId,
21
-            "EntityTypeId" => $this->_entityTypeId,
21
+            "CameraTypeId" => $this->_cameraTypeId,
22 22
             "Data" => $this->_data
23 23
         );
24 24
     }
@@ -38,8 +38,8 @@ class CamerasDbo extends LuDbo {
38 38
         if (isset($json["HostId"])) {
39 39
             $dbo->setHostId($json["HostId"]);
40 40
         }
41
-        if (isset($json["EntityTypeId"])) {
42
-            $dbo->setEntityTypeId($json["EntityTypeId"]);
41
+        if (isset($json["CameraTypeId"])) {
42
+            $dbo->setCameraTypeId($json["CameraTypeId"]);
43 43
         }
44 44
         if (isset($json["Data"])) {
45 45
             $dbo->setData($json["Data"]);
@@ -54,7 +54,7 @@ class CamerasDbo extends LuDbo {
54 54
         $dbo->setName("sample string");
55 55
         $dbo->setDescription("sample string");
56 56
         $dbo->setHostId(42);
57
-        $dbo->setEntityTypeId(42);
57
+        $dbo->setCameraTypeId(42);
58 58
         $dbo->setData("sample string");
59 59
         return $dbo;
60 60
     }
@@ -114,14 +114,14 @@ class CamerasDbo extends LuDbo {
114 114
     /**
115 115
      * @var integer
116 116
      */
117
-    protected $_entityTypeId;
118
-    public function getEntityTypeId()
117
+    protected $_cameraTypeId;
118
+    public function getCameraTypeId()
119 119
     {
120
-        return $this->_entityTypeId;
120
+        return $this->_cameraTypeId;
121 121
     }
122
-    public function setEntityTypeId($value)
122
+    public function setCameraTypeId($value)
123 123
     {
124
-        $this->_entityTypeId = $value;
124
+        $this->_cameraTypeId = $value;
125 125
     }
126 126
 
127 127
     /**

+ 139
- 0
app/Http/DBO/SensorsDbo.php View File

@@ -0,0 +1,139 @@
1
+<?php
2
+
3
+/**
4
+ * AUTO GENERATED BY LUTICATE GENERATOR
5
+ * ANY CHANGES WILL BE OVERWRITTEN
6
+ */
7
+
8
+namespace App\Http\DBO;
9
+
10
+use Luticate\Utils\LuDbo;
11
+
12
+class SensorsDbo extends LuDbo {
13
+
14
+    public function jsonSerialize()
15
+    {
16
+        return array(
17
+            "Id" => $this->_id,
18
+            "Name" => $this->_name,
19
+            "Description" => $this->_description,
20
+            "HostId" => $this->_hostId,
21
+            "EntityTypeId" => $this->_entityTypeId,
22
+            "Data" => $this->_data
23
+        );
24
+    }
25
+
26
+    public static function jsonDeserialize($json)
27
+    {
28
+        $dbo = new SensorsDbo();
29
+        if (isset($json["Id"])) {
30
+            $dbo->setId($json["Id"]);
31
+        }
32
+        if (isset($json["Name"])) {
33
+            $dbo->setName($json["Name"]);
34
+        }
35
+        if (isset($json["Description"])) {
36
+            $dbo->setDescription($json["Description"]);
37
+        }
38
+        if (isset($json["HostId"])) {
39
+            $dbo->setHostId($json["HostId"]);
40
+        }
41
+        if (isset($json["EntityTypeId"])) {
42
+            $dbo->setEntityTypeId($json["EntityTypeId"]);
43
+        }
44
+        if (isset($json["Data"])) {
45
+            $dbo->setData($json["Data"]);
46
+        }
47
+        return $dbo;
48
+    }
49
+
50
+    public static function generateSample()
51
+    {
52
+        $dbo = new SensorsDbo();
53
+        $dbo->setId(42);
54
+        $dbo->setName("sample string");
55
+        $dbo->setDescription("sample string");
56
+        $dbo->setHostId(42);
57
+        $dbo->setEntityTypeId(42);
58
+        $dbo->setData("sample string");
59
+        return $dbo;
60
+    }
61
+
62
+    /**
63
+     * @var integer
64
+     */
65
+    protected $_id;
66
+    public function getId()
67
+    {
68
+        return $this->_id;
69
+    }
70
+    public function setId($value)
71
+    {
72
+        $this->_id = $value;
73
+    }
74
+
75
+    /**
76
+     * @var string
77
+     */
78
+    protected $_name;
79
+    public function getName()
80
+    {
81
+        return $this->_name;
82
+    }
83
+    public function setName($value)
84
+    {
85
+        $this->_name = $value;
86
+    }
87
+
88
+    /**
89
+     * @var string
90
+     */
91
+    protected $_description;
92
+    public function getDescription()
93
+    {
94
+        return $this->_description;
95
+    }
96
+    public function setDescription($value)
97
+    {
98
+        $this->_description = $value;
99
+    }
100
+
101
+    /**
102
+     * @var integer
103
+     */
104
+    protected $_hostId;
105
+    public function getHostId()
106
+    {
107
+        return $this->_hostId;
108
+    }
109
+    public function setHostId($value)
110
+    {
111
+        $this->_hostId = $value;
112
+    }
113
+
114
+    /**
115
+     * @var integer
116
+     */
117
+    protected $_entityTypeId;
118
+    public function getEntityTypeId()
119
+    {
120
+        return $this->_entityTypeId;
121
+    }
122
+    public function setEntityTypeId($value)
123
+    {
124
+        $this->_entityTypeId = $value;
125
+    }
126
+
127
+    /**
128
+     * @var text
129
+     */
130
+    protected $_data;
131
+    public function getData()
132
+    {
133
+        return $this->_data;
134
+    }
135
+    public function setData($value)
136
+    {
137
+        $this->_data = $value;
138
+    }
139
+}

+ 19
- 0
app/Http/DataAccess/CameraTypesDataAccess.php View File

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace App\Http\DataAccess;
4
+
5
+use Luticate\Utils\LuDataAccess;
6
+use App\Http\DataAccess\Models\CameraTypes;
7
+use App\Http\DBO\CameraTypesDbo;
8
+
9
+class CameraTypesDataAccess extends LuDataAccess {
10
+    protected static function getModel()
11
+    {
12
+        return new CameraTypes();
13
+    }
14
+
15
+    protected static function getOrderBy()
16
+    {
17
+        return array(array("name", "ASC"));
18
+    }
19
+}

+ 0
- 24
app/Http/DataAccess/EntityTypesDataAccess.php View File

@@ -1,24 +0,0 @@
1
-<?php
2
-
3
-namespace App\Http\DataAccess;
4
-
5
-use Luticate\Utils\LuDataAccess;
6
-use App\Http\DataAccess\Models\EntityTypes;
7
-use App\Http\DBO\EntityTypesDbo;
8
-
9
-class EntityTypesDataAccess extends LuDataAccess {
10
-    protected static function getModel()
11
-    {
12
-        return new EntityTypes();
13
-    }
14
-
15
-    protected static function getOrderBy()
16
-    {
17
-        return array(array("name", "ASC"));
18
-    }
19
-
20
-    public static function getAllForType($type)
21
-    {
22
-        return self::getMultiple(array(array("type", "=", $type)), self::getOrderBy());
23
-    }
24
-}

+ 9
- 0
app/Http/DataAccess/Models/CameraTypes.php View File

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+namespace App\Http\DataAccess\Models;
4
+
5
+use App\Http\DBO\CameraTypesDbo;
6
+
7
+class CameraTypes extends CameraTypesModel
8
+{
9
+}

app/Http/DataAccess/Models/EntityTypesModel.php → app/Http/DataAccess/Models/CameraTypesModel.php View File

@@ -4,16 +4,16 @@
4 4
  * AUTO GENERATED BY LUTICATE GENERATOR
5 5
  * ANY CHANGES WILL BE OVERWRITTEN
6 6
  * DO NOT DIRECTLY USE THIS FILE
7
- * USE EntityTypes.php
7
+ * USE CameraTypes.php
8 8
  * TO MAKE YOUR CHANGES AND DATABASE ACCESS
9 9
 */
10 10
 
11 11
 namespace App\Http\DataAccess\Models;
12 12
 
13 13
 use Luticate\Utils\LuModel;
14
-use App\Http\DBO\EntityTypesDbo;
14
+use App\Http\DBO\CameraTypesDbo;
15 15
 
16
-class EntityTypesModel extends LuModel
16
+class CameraTypesModel extends LuModel
17 17
 {
18 18
     function __construct()
19 19
     {
@@ -23,32 +23,30 @@ class EntityTypesModel extends LuModel
23 23
 
24 24
     public function toDbo()
25 25
     {
26
-        $dbo = new EntityTypesDbo();
26
+        $dbo = new CameraTypesDbo();
27 27
 
28 28
         $dbo->setId($this->id);
29 29
         $dbo->setName($this->name);
30 30
         $dbo->setClass($this->class);
31 31
         $dbo->setDefaultData($this->default_data);
32
-        $dbo->setType($this->type);
33 32
 
34 33
         return $dbo;
35 34
     }
36 35
 
37 36
     /**
38
-     * @param $dbo EntityTypesDbo
37
+     * @param $dbo CameraTypesDbo
39 38
      * @param $model LuModel|null
40
-     * @return EntityTypes
39
+     * @return CameraTypes
41 40
      */
42 41
     public function fromDbo($dbo, $model = null)
43 42
     {
44 43
         if (is_null($model))
45
-            $model = new EntityTypes();
44
+            $model = new CameraTypes();
46 45
 
47 46
         $model->id = $dbo->getId();
48 47
         $model->name = $dbo->getName();
49 48
         $model->class = $dbo->getClass();
50 49
         $model->default_data = $dbo->getDefaultData();
51
-        $model->type = $dbo->getType();
52 50
 
53 51
         return $model;
54 52
     }

+ 2
- 2
app/Http/DataAccess/Models/CamerasModel.php View File

@@ -29,7 +29,7 @@ class CamerasModel extends LuModel
29 29
         $dbo->setName($this->name);
30 30
         $dbo->setDescription($this->description);
31 31
         $dbo->setHostId($this->host_id);
32
-        $dbo->setEntityTypeId($this->entity_type_id);
32
+        $dbo->setCameraTypeId($this->camera_type_id);
33 33
         $dbo->setData($this->data);
34 34
 
35 35
         return $dbo;
@@ -49,7 +49,7 @@ class CamerasModel extends LuModel
49 49
         $model->name = $dbo->getName();
50 50
         $model->description = $dbo->getDescription();
51 51
         $model->host_id = $dbo->getHostId();
52
-        $model->entity_type_id = $dbo->getEntityTypeId();
52
+        $model->camera_type_id = $dbo->getCameraTypeId();
53 53
         $model->data = $dbo->getData();
54 54
 
55 55
         return $model;

+ 0
- 9
app/Http/DataAccess/Models/EntityTypes.php View File

@@ -1,9 +0,0 @@
1
-<?php
2
-
3
-namespace App\Http\DataAccess\Models;
4
-
5
-use App\Http\DBO\EntityTypesDbo;
6
-
7
-class EntityTypes extends EntityTypesModel
8
-{
9
-}

+ 9
- 0
app/Http/DataAccess/Models/Sensors.php View File

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+namespace App\Http\DataAccess\Models;
4
+
5
+use App\Http\DBO\SensorsDbo;
6
+
7
+class Sensors extends SensorsModel
8
+{
9
+}

+ 57
- 0
app/Http/DataAccess/Models/SensorsModel.php View File

@@ -0,0 +1,57 @@
1
+<?php
2
+
3
+/**
4
+ * AUTO GENERATED BY LUTICATE GENERATOR
5
+ * ANY CHANGES WILL BE OVERWRITTEN
6
+ * DO NOT DIRECTLY USE THIS FILE
7
+ * USE Sensors.php
8
+ * TO MAKE YOUR CHANGES AND DATABASE ACCESS
9
+*/
10
+
11
+namespace App\Http\DataAccess\Models;
12
+
13
+use Luticate\Utils\LuModel;
14
+use App\Http\DBO\SensorsDbo;
15
+
16
+class SensorsModel extends LuModel
17
+{
18
+    function __construct()
19
+    {
20
+        parent::__construct();
21
+        $this->timestamps = false;
22
+    }
23
+
24
+    public function toDbo()
25
+    {
26
+        $dbo = new SensorsDbo();
27
+
28
+        $dbo->setId($this->id);
29
+        $dbo->setName($this->name);
30
+        $dbo->setDescription($this->description);
31
+        $dbo->setHostId($this->host_id);
32
+        $dbo->setEntityTypeId($this->entity_type_id);
33
+        $dbo->setData($this->data);
34
+
35
+        return $dbo;
36
+    }
37
+
38
+    /**
39
+     * @param $dbo SensorsDbo
40
+     * @param $model LuModel|null
41
+     * @return Sensors
42
+     */
43
+    public function fromDbo($dbo, $model = null)
44
+    {
45
+        if (is_null($model))
46
+            $model = new Sensors();
47
+
48
+        $model->id = $dbo->getId();
49
+        $model->name = $dbo->getName();
50
+        $model->description = $dbo->getDescription();
51
+        $model->host_id = $dbo->getHostId();
52
+        $model->entity_type_id = $dbo->getEntityTypeId();
53
+        $model->data = $dbo->getData();
54
+
55
+        return $model;
56
+    }
57
+}

+ 14
- 0
app/Http/DataAccess/SensorsDataAccess.php View File

@@ -0,0 +1,14 @@
1
+<?php
2
+
3
+namespace App\Http\DataAccess;
4
+
5
+use Luticate\Utils\LuDataAccess;
6
+use App\Http\DataAccess\Models\Sensors;
7
+use App\Http\DBO\SensorsDbo;
8
+
9
+class SensorsDataAccess extends LuDataAccess {
10
+    protected static function getModel()
11
+    {
12
+        return new Sensors();
13
+    }
14
+}

+ 3
- 1
app/Http/routes.php View File

@@ -27,4 +27,6 @@ $route->get("/cameras", "Cameras", "getAll", CamotionPermissions::CAMERA_GET);
27 27
 $route->get("/cameras/$camera_id", "Cameras", "get", CamotionPermissions::CAMERA_GET);
28 28
 $route->post("/cameras/add", "Cameras", "add", array(CamotionPermissions::CAMERA_GET, CamotionPermissions::CAMERA_ADD));
29 29
 $route->post("/cameras/$camera_id/edit", "Cameras", "edit", array(CamotionPermissions::CAMERA_GET, CamotionPermissions::CAMERA_EDIT));
30
-$route->post("/cameras/$camera_id/del", "Cameras", "del", array(CamotionPermissions::CAMERA_GET, CamotionPermissions::CAMERA_DEL));
30
+$route->post("/cameras/$camera_id/del", "Cameras", "del", array(CamotionPermissions::CAMERA_GET, CamotionPermissions::CAMERA_DEL));
31
+
32
+//sleep(1);

+ 1
- 1
generate.php View File

@@ -47,7 +47,7 @@ $gen->setConfig(array("dbo" =>
47 47
             "/^sp_lu_.*/"
48 48
         ),
49 49
         "controllers" => array(
50
-            "/^EntityTypesController$/"
50
+            "/^CameraTypesController$/"
51 51
         )
52 52
     )
53 53
 ));

Loading…
Cancel
Save