summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/models/DbTable/Eventtype.php (renamed from application/models/DbTable/Runningtype.php)4
-rw-r--r--application/models/DbTable/Reporttype.php20
-rw-r--r--application/models/Eventtype.php (renamed from application/models/Reporttype.php)14
-rw-r--r--application/models/EventtypeMapper.php (renamed from application/models/RunningtypeMapper.php)46
-rw-r--r--application/models/ReporttypeMapper.php148
-rw-r--r--application/models/Runningtype.php111
-rw-r--r--setup/poolctrl.sql21
-rw-r--r--setup/poolctrl_data.sql17
8 files changed, 52 insertions, 329 deletions
diff --git a/application/models/DbTable/Runningtype.php b/application/models/DbTable/Eventtype.php
index 0ed5638..6c54913 100644
--- a/application/models/DbTable/Runningtype.php
+++ b/application/models/DbTable/Eventtype.php
@@ -10,10 +10,10 @@
* General information about OpenSLX can be found at http://openslx.org/
*/
-class Application_Model_DbTable_Runningtype extends Zend_Db_Table_Abstract
+class Application_Model_DbTable_Eventtype extends Zend_Db_Table_Abstract
{
- protected $_name = 'poolctrl_runningtype';
+ protected $_name = 'poolctrl_eventtype';
}
diff --git a/application/models/DbTable/Reporttype.php b/application/models/DbTable/Reporttype.php
deleted file mode 100644
index fe62330..0000000
--- a/application/models/DbTable/Reporttype.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-/*
- * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-
-class Application_Model_DbTable_Reporttype extends Zend_Db_Table_Abstract
-{
-
- protected $_name = 'poolctrl_reporttype';
-
-
-}
-
diff --git a/application/models/Reporttype.php b/application/models/Eventtype.php
index ad5d668..fe21eeb 100644
--- a/application/models/Reporttype.php
+++ b/application/models/Eventtype.php
@@ -10,9 +10,9 @@
* General information about OpenSLX can be found at http://openslx.org/
*/
-class Application_Model_Reporttype
+class Application_Model_Eventtype
{
- protected $_reporttypeID;
+ protected $_eventtypeID;
protected $_title;
public function __construct(array $options = null)
@@ -26,7 +26,7 @@ class Application_Model_Reporttype
{
$method = 'set' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
- throw new Exception('Invalid reporttype property');
+ throw new Exception('Invalid eventtype property');
}
$this->$method($value);
}
@@ -35,7 +35,7 @@ class Application_Model_Reporttype
{
$method = 'get' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
- throw new Exception('Invalid reporttype property');
+ throw new Exception('Invalid eventtype property');
}
return $this->$method();
}
@@ -89,11 +89,11 @@ class Application_Model_Reporttype
public function getID()
{
- return $this->_reporttypeID;
+ return $this->_eventtypeID;
}
- public function setID($_reporttypeID)
+ public function setID($_eventtypeID)
{
- $this->_reporttypeID = $_reporttypeID;
+ $this->_eventtypeID = $_eventtypeID;
return $this;
}
diff --git a/application/models/RunningtypeMapper.php b/application/models/EventtypeMapper.php
index e012490..d1e2740 100644
--- a/application/models/RunningtypeMapper.php
+++ b/application/models/EventtypeMapper.php
@@ -33,8 +33,8 @@ class Application_Model_RunningtypeMapper
$entries = array();
if(count($result) > 0) {
foreach ($result as $row) {
- $entry = new Application_Model_Runningtype($row);
- $entry->setID($row['runningtypeID']);
+ $entry = new Application_Model_Eventtype($row);
+ $entry->setID($row['eventtypeID']);
$entries[] = $entry;
}
}
@@ -66,46 +66,58 @@ class Application_Model_RunningtypeMapper
public function getDbTable()
{
if (null === $this->_dbTable) {
- $this->setDbTable('Application_Model_DbTable_Runningtype');
+ $this->setDbTable('Application_Model_DbTable_Eventtype');
}
return $this->_dbTable;
}
- public function save(Application_Model_Runningtype $runningtype)
+ public function save(Application_Model_Eventtype $eventtype)
{
- $data = array('runningtypeID'=> $runningtype->getRunningtypeID() ,'title'=> $runningtype->getTitle() );
+ $data = array('eventtypeID'=> $eventtype->getID() ,'title'=> $eventtype->getTitle() );
- if (null === ($id = $runningtype->getID()) ) {
- unset($data['runningtypeID']);
+ if (null === ($id = $eventtype->getID()) ) {
+ unset($data['eventtypeID']);
$this->getDbTable()->insert($data);
} else {
- $this->getDbTable()->update($data, array('runningtypeID = ?' => $id));
+ $this->getDbTable()->update($data, array('eventtypeID = ?' => $id));
}
}
- public function delete(Application_Model_Runningtype $runningtype)
+ public function delete(Application_Model_Eventtype $eventtype)
{
- if (null === ($id = $runningtype->getID()) ) {
+ if (null === ($id = $eventtype->getID()) ) {
return;
} else {
- $this->getDbTable()->delete(array('runningtypeID = ?' => $id));
+ $this->getDbTable()->delete(array('eventtypeID = ?' => $id));
}
}
- public function find($id, Application_Model_Runningtype $runningtype)
+ public function find($id, Application_Model_Eventtype $eventtype)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
}
+ if($eventtype == null) {
+ $return = true;
+ }
+
$row = $result->current();
- $runningtype
- ->setRunningtypeID($row->runningtypeID)
- ->setTitle($row->title);
+ if($return) {
+ $eventtype = new Application_Model_Eventtype();
+ $eventtype
+ ->setID($row->eventtypeID)
+ ->setTitle($row->title);
+ return $eventtype;
+ } else {
+ $eventtype
+ ->setID($row->eventtypeID)
+ ->setTitle($row->title);
+ }
}
public function fetchAll()
@@ -113,10 +125,10 @@ class Application_Model_RunningtypeMapper
$resultSet = $this->getDbTable()->fetchAll();
$entries = array();
foreach ($resultSet as $row) {
- $entry = new Application_Model_Runningtype();
+ $entry = new Application_Model_Eventtype();
$entry
- ->setRunningtypeID($row->runningtypeID)
+ ->setID($row->eventtypeID)
->setTitle($row->title);
$entries[] = $entry;
diff --git a/application/models/ReporttypeMapper.php b/application/models/ReporttypeMapper.php
deleted file mode 100644
index c760dbc..0000000
--- a/application/models/ReporttypeMapper.php
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php
-/*
- * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-
-class Application_Model_ReporttypeMapper
-{
-
- protected $_dbTable;
-
- public function findBy($where, $array=false, $order=false)
- {
- foreach($where as $k => $v){
- if($v != null)
- $where2[] = "$k = '$v'";
- else
- $where2[] = "$k IS NULL";
- }
- $where = implode(" AND " ,$where2);
-
- try{
- $db = Zend_Db_Table::getDefaultAdapter();
- $select = $this->getDbTable()->select()
- ->from($this->_dbTable)
- ->where($where);
-
- if(is_array($order)){
- foreach ($order as $k => $v)
- $a[] = "$k $v";
- $select->order($a);
- }
-
- $stmt = $select->query();
- $result = $stmt->fetchAll();
-
- if(!$array){
- $entries = array();
- if(count($result) > 0) {
- foreach ($result as $row) {
- $entry = new Application_Model_Reporttype($row);
- $entry->setID($row['reporttypeID']);
- $entries[] = $entry;
- }
- }
- return $entries;
- }else{
- return $result;
- }
-
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
-
- public function setDbTable($dbTable)
- {
- if (is_string($dbTable)) {
- $dbTable = new $dbTable();
- }
-
- if (!$dbTable instanceof Zend_Db_Table_Abstract) {
- throw new Exception('Invalid table data gateway provided');
- }
-
- $this->_dbTable = $dbTable;
-
- return $this;
- }
-
- public function getDbTable()
- {
- if (null === $this->_dbTable) {
- $this->setDbTable('Application_Model_DbTable_Reporttype');
- }
-
- return $this->_dbTable;
- }
-
- public function save(Application_Model_Reporttype $reporttype)
- {
- $data = array('reporttypeID'=> $reporttype->getID() ,'title'=> $reporttype->getTitle() );
- if (null === ($id = $reporttype->getID()) ) {
- unset($data['reporttypeID']);
- return $this->getDbTable(F)->insert($data);
- } else {
- $this->getDbTable()->update($data, array('reporttypeID = ?' => $id));
- }
- }
-
- public function delete(Application_Model_Reporttype $reporttype)
- {
- if (null === ($id = $reporttype->getID()) ) {
- return;
- } else {
- $this->getDbTable()->delete(array('reporttypeID = ?' => $id));
- }
- }
-
- public function find($id, Application_Model_Reporttype $reporttype = null)
- {
- $result = $this->getDbTable()->find($id);
- if (0 == count($result)) {
- return;
- }
-
- $row = $result->current();
-
- if($reporttype == null){
- $reporttype = new Application_Model_Reporttype();
- }
-
- $reporttype
- ->setID($row->reporttypeID)
- ->setTitle($row->title);
- }
-
- public function fetchAll()
- {
- $resultSet = $this->getDbTable()->fetchAll();
- $entries = array();
- foreach ($resultSet as $row) {
- $entry = new Application_Model_Reporttype();
-
- $entry
- ->setID($row->reporttypeID)
- ->setTitle($row->title);
-
- $entries[$row->reporttypeID] = $entry;
- }
- return $entries;
- }
-
- public function compare(Application_Model_Reporttype $v1,Application_Model_Reporttype $v2){
- $vv1 = $v1->toArray();
- $vv2 = $v2->toArray();
- return array_diff($vv1,$vv2);
- }
-
-
-
-} \ No newline at end of file
diff --git a/application/models/Runningtype.php b/application/models/Runningtype.php
deleted file mode 100644
index d08222d..0000000
--- a/application/models/Runningtype.php
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-/*
- * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-
-class Application_Model_Runningtype
-{
- protected $_runningtypeID;
- protected $_title;
-
- public function __construct(array $options = null)
- {
- if (is_array($options)) {
- $this->setOptions($options);
- }
- }
-
- public function __set($name, $value)
- {
- $method = 'set' . $name;
- if (('mapper' == $name) || !method_exists($this, $method)) {
- throw new Exception('Invalid runningtype property');
- }
- $this->$method($value);
- }
-
- public function __get($name)
- {
- $method = 'get' . $name;
- if (('mapper' == $name) || !method_exists($this, $method)) {
- throw new Exception('Invalid runningtype property');
- }
- return $this->$method();
- }
-
- public function setOptions(array $options)
- {
- $methods = get_class_methods($this);
- foreach ($options as $key => $value) {
- $method = 'set' . ucfirst($key);
- if (in_array($method, $methods)) {
- $this->$method($value);
- }
- }
- return $this;
- }
-
- /**
- * Returns current data as associative array using ReflectionClass
- *
- * @return array Returns associative array containing model data
- * If "get"-method not available (our primary keys) the function getID() is called
- */
- public function toArray()
- {
- $reflectionClass = new ReflectionClass($this);
- $properties = $reflectionClass->getProperties();
- $result = array();
- foreach ($properties as $property) {
- $key = $property->name;
- if (substr($key, 0, 1) != '_' && $this->$key !== null) {
- $method = 'get' . ucfirst($key);
- if ($reflectionClass->hasMethod($method)) {
- $result[$key] = $this->$method();
- } else {
- $result[$key] = $this->$key;
- }
- }
- elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
- $key = substr($key, 1);
- $method = 'get' . ucfirst($key);
- if ($reflectionClass->hasMethod($method)) {
- $result[$key] = $this->$method();
- }else{
- $result[$key] = $this->getID();
- }
-
- }
- }
- return $result;
- }
-
- public function getID()
- {
- return $this->_runningtypeID;
- }
- public function setID($_runningtypeID)
- {
- $this->_runningtypeID = $_runningtypeID;
- return $this;
- }
-
- public function getTitle()
- {
- return $this->_title;
- }
-
- public function setTitle($_title)
- {
- $this->_title = $_title;
- return $this;
- }
-}
-
diff --git a/setup/poolctrl.sql b/setup/poolctrl.sql
index 470716e..3580485 100644
--- a/setup/poolctrl.sql
+++ b/setup/poolctrl.sql
@@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `poolctrl_event` (
`repeat` bool NOT NULL DEFAULT false,
`immediate` bool NOT NULL DEFAULT false,
`running` bool NOT NULL DEFAULT false,
- `runningtype` int(11) NOT NULL DEFAULT '0',
+ `runningtype` int(11) DEFAULT NULL,
PRIMARY KEY (`eventID`),
KEY `pbs_poolID` (`pbs_poolID`),
KEY `pbs_membershipID` (`pbs_membershipID`),
@@ -31,10 +31,10 @@ CREATE TABLE IF NOT EXISTS `poolctrl_event` (
KEY `runningtype` (`runningtype`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
-CREATE TABLE IF NOT EXISTS `poolctrl_runningtype` (
- `runningtypeID` int(11) NOT NULL AUTO_INCREMENT,
+CREATE TABLE IF NOT EXISTS `poolctrl_eventtype` (
+ `eventtypeID` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(30) COLLATE utf8_unicode_ci NOT NULL UNIQUE,
- PRIMARY KEY (`runningTypID`)
+ PRIMARY KEY (`eventtypeID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
CREATE TABLE IF NOT EXISTS `poolctrl_eventcategory` (
@@ -45,7 +45,8 @@ CREATE TABLE IF NOT EXISTS `poolctrl_eventcategory` (
CREATE TABLE IF NOT EXISTS `poolctrl_eventreport` (
`reportID` int(11) NOT NULL AUTO_INCREMENT,
- `report` varchar(140) COLLATE utf8_unicode_ci DEFAULT 'success',
+ `result` varchar(140) COLLATE utf8_unicode_ci DEFAULT 'success',
+ `errors` varchar(140) COLLATE utf8_unicode_ci,
`type` int(11) NOT NULL,
`eventID` int(11) NOT NULL,
`timestamp` timestamp COLLATE utf8_unicode_ci NOT NULL DEFAULT CURRENT_TIMESTAMP(),
@@ -54,12 +55,6 @@ CREATE TABLE IF NOT EXISTS `poolctrl_eventreport` (
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
-CREATE TABLE IF NOT EXISTS `poolctrl_reporttype` (
- `reporttypeID` int(11) NOT NULL AUTO_INCREMENT,
- `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL UNIQUE,
- PRIMARY KEY (`reporttypeID`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
-
-- PBS2 Tabellen
-- TO DO: Tabellen an dieser Stelle nicht per Hand erzeugen sondern von der PBS2-Datenbank kopieren, sodass diese auf dem neusten Stand sind
CREATE TABLE IF NOT EXISTS `pbs_bootos` (
@@ -194,13 +189,13 @@ ALTER TABLE `pbs_membership`
ALTER TABLE `poolctrl_eventreport`
ADD CONSTRAINT `pbs_eventreport_eventidC` FOREIGN KEY (`eventID`) REFERENCES `poolctrl_event` (`eventID`) ON DELETE CASCADE,
- ADD CONSTRAINT `pbs_eventreport_typeidC` FOREIGN KEY (`type`) REFERENCES `poolctrl_reporttype` (`reporttypeID`) ON DELETE CASCADE;
+ ADD CONSTRAINT `pbs_eventreport_typeidC` FOREIGN KEY (`type`) REFERENCES `poolctrl_eventtype` (`eventtypeID`) ON DELETE CASCADE;
ALTER TABLE `poolctrl_event`
ADD CONSTRAINT `poolctrl_event_poolidC` FOREIGN KEY (`pbs_poolID`) REFERENCES `pbs_pool` (`poolID`) ON DELETE CASCADE,
ADD CONSTRAINT `poolctrl_event_bootosidC` FOREIGN KEY (`pbs_bootosID`) REFERENCES `pbs_bootos` (`bootosID`) ON DELETE CASCADE,
ADD CONSTRAINT `poolctrl_event_membershipidC` FOREIGN KEY (`pbs_membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE CASCADE,
ADD CONSTRAINT `poolctrl_event_categoryC` FOREIGN KEY (`category`) REFERENCES `poolctrl_eventcategory` (`eventcategoryID`) ON DELETE CASCADE,
- ADD CONSTRAINT `poolctrl_event_runningtypeC` FOREIGN KEY (`runningtype`) REFERENCES `poolctrl_runningtype` (`runningtype`) ON DELETE SET NULl,
+ ADD CONSTRAINT `poolctrl_event_runningtypeC` FOREIGN KEY (`runningtype`) REFERENCES `poolctrl_eventtype` (`eventtypeID`) ON DELETE SET NULL,
ADD CONSTRAINT `poolctrl_event_startC` CHECK (start > CURRENT_TIMESTAMP()),
ADD CONSTRAINT `poolctrl_event_endC` CHECK (end > start);
diff --git a/setup/poolctrl_data.sql b/setup/poolctrl_data.sql
index f22da32..57df655 100644
--- a/setup/poolctrl_data.sql
+++ b/setup/poolctrl_data.sql
@@ -90,8 +90,8 @@ INSERT INTO `poolctrl_eventcategory` (`eventcategoryID`, `title`) VALUES
(3, 'Boot'),
(4, 'Shutdown');
--- Adding runningtypes
-INSERT INTO `poolctrl_runningtype` (`runningtypeID`, `title`) VALUES
+-- Adding eventtypes
+INSERT INTO `poolctrl_eventtype` (`eventtypeID`, `title`) VALUES
(1, 'Boot'),
(2, 'Shutdown');
@@ -101,13 +101,8 @@ INSERT INTO `poolctrl_event` (`eventID`, `title`, `start`, `end`, `category`, `p
(2, 'Systeme II', '2011-06-24 14:10:00', '2011-06-24 16:00:00', '1', 1, 1, 1, 'Systeme II Vorlesung', 1, 1),
(3, 'Systeme III', '2011-06-24 16:10:00', '2011-06-24 18:00:00', '1', 1, 1, 1, 'Systeme III Vorlesung', 1, 1);
--- Adding reporttypes
-INSERT INTO `poolctrl_reporttype` (`reporttypeID`, `title`) VALUES
-(1, 'Boot'),
-(2, 'Shutdown');
-
-- Adding eventreports
-INSERT INTO `poolctrl_eventreport` (`reportID`, `report`, `type`, `eventID`) VALUES
-(1, DEFAULT, 1, 1),
-(2, DEFAULT, 1, 2),
-(3, 'wake-on-lan failed', 1, 3);
+INSERT INTO `poolctrl_eventreport` (`reportID`, `result`, `errors`, `type`, `eventID`) VALUES
+(1, DEFAULT, null, 1, 1),
+(2, DEFAULT, null, 1, 2),
+(3, 'failed', 'wake-on-lan failed', 1, 3);