Browse Source

excute command; dummy command

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
1109973581

+ 29
- 0
app/Http/Business/Commands/AbstractCommand.php View File

@@ -0,0 +1,29 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 11/24/15
6
+ * Time: 12:03 AM
7
+ */
8
+
9
+namespace App\Http\Business\Commands;
10
+
11
+use App\Http\DBO\CommandsDbo;
12
+
13
+abstract class AbstractCommand
14
+{
15
+    /**
16
+     * @var CommandsDbo
17
+     */
18
+    protected $_command;
19
+
20
+    public function __construct(CommandsDbo $command)
21
+    {
22
+        $this->_command = $command;
23
+    }
24
+
25
+    /**
26
+     * @return bool
27
+     */
28
+    public abstract function exec();
29
+}

+ 26
- 0
app/Http/Business/Commands/DummyCommand.php View File

@@ -0,0 +1,26 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 11/24/15
6
+ * Time: 12:15 AM
7
+ */
8
+
9
+namespace App\Http\Business\Commands;
10
+
11
+
12
+class DummyCommand extends AbstractCommand
13
+{
14
+
15
+    /**
16
+     * @return bool
17
+     */
18
+    public function exec()
19
+    {
20
+        $data = $this->_command->getData();
21
+        if (isset($data["Success"]) && !$data["Success"]) {
22
+            abort(500, "Failed to execute command");
23
+        }
24
+        return true;
25
+    }
26
+}

+ 25
- 0
app/Http/Business/CommandsBusiness.php View File

@@ -0,0 +1,25 @@
1
+<?php
2
+
3
+namespace App\Http\Business;
4
+use App\Http\Business\Commands\AbstractCommand;
5
+use App\Http\DBO\CommandsDbo;
6
+use App\Http\DBO\CommandTypesDbo;
7
+
8
+/**
9
+ * Created by PhpStorm.
10
+ * User: robin
11
+ * Date: 11/23/15
12
+ * Time: 11:59 PM
13
+ */
14
+class CommandsBusiness
15
+{
16
+    public static function exec(CommandsDbo $command, CommandTypesDbo $type)
17
+    {
18
+        /**
19
+         * @var $cmd AbstractCommand
20
+         */
21
+        $class = $type->getClass();
22
+        $cmd = new $class($command);
23
+        return $cmd->exec();
24
+    }
25
+}

+ 22
- 0
app/Http/Controller/CommandsController.php View File

@@ -0,0 +1,22 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 11/23/15
6
+ * Time: 11:44 PM
7
+ */
8
+
9
+namespace App\Http\Controller;
10
+
11
+use App\Http\Business\CommandsBusiness;
12
+use App\Http\DBO\CommandsDbo;
13
+use App\Http\DBO\CommandTypesDbo;
14
+use Laravel\Lumen\Routing\Controller as BaseController;
15
+
16
+class CommandsController extends BaseController
17
+{
18
+    public function exec(CommandsDbo $command, CommandTypesDbo $type)
19
+    {
20
+        return CommandsBusiness::exec($command, $type);
21
+    }
22
+}

+ 103
- 0
app/Http/DBO/CameraTypesDbo.php View File

@@ -0,0 +1,103 @@
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 CameraTypesDbo extends LuDbo {
13
+
14
+    public function jsonSerialize()
15
+    {
16
+        return array(
17
+            "Id" => $this->_id,
18
+            "Name" => $this->_name,
19
+            "Class" => $this->_class,
20
+            "DefaultData" => $this->_defaultData
21
+        );
22
+    }
23
+
24
+    public static function jsonDeserialize($json)
25
+    {
26
+        $dbo = new CameraTypesDbo();
27
+        if (isset($json["Id"])) {
28
+            $dbo->setId($json["Id"]);
29
+        }
30
+        if (isset($json["Name"])) {
31
+            $dbo->setName($json["Name"]);
32
+        }
33
+        if (isset($json["Class"])) {
34
+            $dbo->setClass($json["Class"]);
35
+        }
36
+        if (isset($json["DefaultData"])) {
37
+            $dbo->setDefaultData($json["DefaultData"]);
38
+        }
39
+        return $dbo;
40
+    }
41
+
42
+    public static function generateSample()
43
+    {
44
+        $dbo = new CameraTypesDbo();
45
+        $dbo->setId(42);
46
+        $dbo->setName("sample string");
47
+        $dbo->setClass("sample string");
48
+        $dbo->setDefaultData("sample string");
49
+        return $dbo;
50
+    }
51
+
52
+    /**
53
+     * @var integer
54
+     */
55
+    protected $_id;
56
+    public function getId()
57
+    {
58
+        return $this->_id;
59
+    }
60
+    public function setId($value)
61
+    {
62
+        $this->_id = $value;
63
+    }
64
+
65
+    /**
66
+     * @var string
67
+     */
68
+    protected $_name;
69
+    public function getName()
70
+    {
71
+        return $this->_name;
72
+    }
73
+    public function setName($value)
74
+    {
75
+        $this->_name = $value;
76
+    }
77
+
78
+    /**
79
+     * @var string
80
+     */
81
+    protected $_class;
82
+    public function getClass()
83
+    {
84
+        return $this->_class;
85
+    }
86
+    public function setClass($value)
87
+    {
88
+        $this->_class = $value;
89
+    }
90
+
91
+    /**
92
+     * @var text
93
+     */
94
+    protected $_defaultData;
95
+    public function getDefaultData()
96
+    {
97
+        return $this->_defaultData;
98
+    }
99
+    public function setDefaultData($value)
100
+    {
101
+        $this->_defaultData = $value;
102
+    }
103
+}

+ 139
- 0
app/Http/DBO/CamerasDbo.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 CamerasDbo 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
+            "CameraTypeId" => $this->_cameraTypeId,
22
+            "Data" => $this->_data
23
+        );
24
+    }
25
+
26
+    public static function jsonDeserialize($json)
27
+    {
28
+        $dbo = new CamerasDbo();
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["CameraTypeId"])) {
42
+            $dbo->setCameraTypeId($json["CameraTypeId"]);
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 CamerasDbo();
53
+        $dbo->setId(42);
54
+        $dbo->setName("sample string");
55
+        $dbo->setDescription("sample string");
56
+        $dbo->setHostId(42);
57
+        $dbo->setCameraTypeId(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 $_cameraTypeId;
118
+    public function getCameraTypeId()
119
+    {
120
+        return $this->_cameraTypeId;
121
+    }
122
+    public function setCameraTypeId($value)
123
+    {
124
+        $this->_cameraTypeId = $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
+}

+ 103
- 0
app/Http/DBO/CommandTypesDbo.php View File

@@ -0,0 +1,103 @@
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 CommandTypesDbo extends LuDbo {
13
+
14
+    public function jsonSerialize()
15
+    {
16
+        return array(
17
+            "Id" => $this->_id,
18
+            "Name" => $this->_name,
19
+            "Class" => $this->_class,
20
+            "DefaultData" => $this->_defaultData
21
+        );
22
+    }
23
+
24
+    public static function jsonDeserialize($json)
25
+    {
26
+        $dbo = new CommandTypesDbo();
27
+        if (isset($json["Id"])) {
28
+            $dbo->setId($json["Id"]);
29
+        }
30
+        if (isset($json["Name"])) {
31
+            $dbo->setName($json["Name"]);
32
+        }
33
+        if (isset($json["Class"])) {
34
+            $dbo->setClass($json["Class"]);
35
+        }
36
+        if (isset($json["DefaultData"])) {
37
+            $dbo->setDefaultData($json["DefaultData"]);
38
+        }
39
+        return $dbo;
40
+    }
41
+
42
+    public static function generateSample()
43
+    {
44
+        $dbo = new CommandTypesDbo();
45
+        $dbo->setId(42);
46
+        $dbo->setName("sample string");
47
+        $dbo->setClass("sample string");
48
+        $dbo->setDefaultData("sample string");
49
+        return $dbo;
50
+    }
51
+
52
+    /**
53
+     * @var integer
54
+     */
55
+    protected $_id;
56
+    public function getId()
57
+    {
58
+        return $this->_id;
59
+    }
60
+    public function setId($value)
61
+    {
62
+        $this->_id = $value;
63
+    }
64
+
65
+    /**
66
+     * @var string
67
+     */
68
+    protected $_name;
69
+    public function getName()
70
+    {
71
+        return $this->_name;
72
+    }
73
+    public function setName($value)
74
+    {
75
+        $this->_name = $value;
76
+    }
77
+
78
+    /**
79
+     * @var string
80
+     */
81
+    protected $_class;
82
+    public function getClass()
83
+    {
84
+        return $this->_class;
85
+    }
86
+    public function setClass($value)
87
+    {
88
+        $this->_class = $value;
89
+    }
90
+
91
+    /**
92
+     * @var text
93
+     */
94
+    protected $_defaultData;
95
+    public function getDefaultData()
96
+    {
97
+        return $this->_defaultData;
98
+    }
99
+    public function setDefaultData($value)
100
+    {
101
+        $this->_defaultData = $value;
102
+    }
103
+}

+ 139
- 0
app/Http/DBO/CommandsDbo.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 CommandsDbo 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
+            "CommandTypeId" => $this->_commandTypeId,
22
+            "Data" => $this->_data
23
+        );
24
+    }
25
+
26
+    public static function jsonDeserialize($json)
27
+    {
28
+        $dbo = new CommandsDbo();
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["CommandTypeId"])) {
42
+            $dbo->setCommandTypeId($json["CommandTypeId"]);
43
+        }
44
+        if (isset($json["Data"])) {
45
+            $dbo->setData(json_decode($json["Data"], true));
46
+        }
47
+        return $dbo;
48
+    }
49
+
50
+    public static function generateSample()
51
+    {
52
+        $dbo = new CommandsDbo();
53
+        $dbo->setId(42);
54
+        $dbo->setName("sample string");
55
+        $dbo->setDescription("sample string");
56
+        $dbo->setHostId(42);
57
+        $dbo->setCommandTypeId(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 $_commandTypeId;
118
+    public function getCommandTypeId()
119
+    {
120
+        return $this->_commandTypeId;
121
+    }
122
+    public function setCommandTypeId($value)
123
+    {
124
+        $this->_commandTypeId = $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
+}

+ 103
- 0
app/Http/DBO/SensorTypesDbo.php View File

@@ -0,0 +1,103 @@
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 SensorTypesDbo extends LuDbo {
13
+
14
+    public function jsonSerialize()
15
+    {
16
+        return array(
17
+            "Id" => $this->_id,
18
+            "Name" => $this->_name,
19
+            "Class" => $this->_class,
20
+            "DefaultData" => $this->_defaultData
21
+        );
22
+    }
23
+
24
+    public static function jsonDeserialize($json)
25
+    {
26
+        $dbo = new SensorTypesDbo();
27
+        if (isset($json["Id"])) {
28
+            $dbo->setId($json["Id"]);
29
+        }
30
+        if (isset($json["Name"])) {
31
+            $dbo->setName($json["Name"]);
32
+        }
33
+        if (isset($json["Class"])) {
34
+            $dbo->setClass($json["Class"]);
35
+        }
36
+        if (isset($json["DefaultData"])) {
37
+            $dbo->setDefaultData($json["DefaultData"]);
38
+        }
39
+        return $dbo;
40
+    }
41
+
42
+    public static function generateSample()
43
+    {
44
+        $dbo = new SensorTypesDbo();
45
+        $dbo->setId(42);
46
+        $dbo->setName("sample string");
47
+        $dbo->setClass("sample string");
48
+        $dbo->setDefaultData("sample string");
49
+        return $dbo;
50
+    }
51
+
52
+    /**
53
+     * @var integer
54
+     */
55
+    protected $_id;
56
+    public function getId()
57
+    {
58
+        return $this->_id;
59
+    }
60
+    public function setId($value)
61
+    {
62
+        $this->_id = $value;
63
+    }
64
+
65
+    /**
66
+     * @var string
67
+     */
68
+    protected $_name;
69
+    public function getName()
70
+    {
71
+        return $this->_name;
72
+    }
73
+    public function setName($value)
74
+    {
75
+        $this->_name = $value;
76
+    }
77
+
78
+    /**
79
+     * @var string
80
+     */
81
+    protected $_class;
82
+    public function getClass()
83
+    {
84
+        return $this->_class;
85
+    }
86
+    public function setClass($value)
87
+    {
88
+        $this->_class = $value;
89
+    }
90
+
91
+    /**
92
+     * @var text
93
+     */
94
+    protected $_defaultData;
95
+    public function getDefaultData()
96
+    {
97
+        return $this->_defaultData;
98
+    }
99
+    public function setDefaultData($value)
100
+    {
101
+        $this->_defaultData = $value;
102
+    }
103
+}

+ 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
+            "SensorTypeId" => $this->_sensorTypeId,
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["SensorTypeId"])) {
42
+            $dbo->setSensorTypeId($json["SensorTypeId"]);
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->setSensorTypeId(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 $_sensorTypeId;
118
+    public function getSensorTypeId()
119
+    {
120
+        return $this->_sensorTypeId;
121
+    }
122
+    public function setSensorTypeId($value)
123
+    {
124
+        $this->_sensorTypeId = $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
+}

+ 4
- 2
app/Http/routes.php View File

@@ -11,6 +11,8 @@
11 11
 |
12 12
 */
13 13
 
14
-use Luticate\Doc\Business\LuDocBusiness;
14
+use Luticate\Utils\LuRoute;
15 15
 
16
-LuDocBusiness::setupRoutes();
16
+$route = LuRoute::getInstance();
17
+
18
+$route->post("/commands/exec", "Commands", "exec");

+ 1
- 5
composer.json View File

@@ -7,9 +7,6 @@
7 7
     "repositories": [{
8 8
         "type": "vcs",
9 9
         "url":  "https://git.rthoni.com/luticate/utils.git"
10
-    },{
11
-        "type": "vcs",
12
-        "url":  "https://git.rthoni.com/luticate/doc.git"
13 10
     }],
14 11
     "require": {
15 12
         "php": ">=5.5.9",
@@ -19,8 +16,7 @@
19 16
     },
20 17
     "require-dev": {
21 18
         "phpunit/phpunit": "~4.0",
22
-        "fzaninotto/faker": "~1.0",
23
-        "luticate/doc": "0.1.x"
19
+        "fzaninotto/faker": "~1.0"
24 20
     },
25 21
     "autoload": {
26 22
         "psr-4": {

Loading…
Cancel
Save