diff --git a/backend/lib/Controller/DataController.php b/backend/lib/Controller/DataController.php index 84ac0df..02e5f1b 100644 --- a/backend/lib/Controller/DataController.php +++ b/backend/lib/Controller/DataController.php @@ -48,18 +48,9 @@ class DataController extends Controller { /** * Log new readings with logger interfaces - * - * @todo authentification/indentification - * @todo reimplement */ public function add() { - $class = 'Volkszaehler\Logger\\' . ucfirst($this->view->request->getParameter('logger')) . 'Logger'; - if (!(Util\ClassLoader::classExists($class)) || !is_subclass_of($class, '\Volkszaehler\Logger\Logger')) { - throw new \Exception('Unkown logger: ' . $class); - } - $logger = new $class($this->view->request, $this->em); - $logger->log(); } } diff --git a/backend/lib/Logger/FluksoLogger.php b/backend/lib/Logger/FluksoLogger.php deleted file mode 100644 index 95f2f3e..0000000 --- a/backend/lib/Logger/FluksoLogger.php +++ /dev/null @@ -1,45 +0,0 @@ -. - */ - -namespace Volkszaehler\Logger; - -/** - * Logger for the Flukso.net API - * - * @package default - * @link http://www.flukso.net - * @link http://github.com/icarus75/flukso - * @author Steffen Vogel - * @todo to be implemented - */ -class FluksoLogger extends Logger { - /** - * @return array of Model\Data - */ - public function getData(); - - public function getVersion(); - -} - -?> \ No newline at end of file diff --git a/backend/lib/Logger/Logger.php b/backend/lib/Logger/Logger.php deleted file mode 100644 index d3ada4d..0000000 --- a/backend/lib/Logger/Logger.php +++ /dev/null @@ -1,83 +0,0 @@ -. - */ - -namespace Volkszaehler\Logger; - -use Volkszaehler\View\HTTP; -use Doctrine\ORM; -use Volkszaehler\Model; - -/** - * Interface for parsing diffrent logging APIs (google, flukso etc..) - * - * @author Steffen Vogel - * @package default - * @todo to be implemented - */ -interface LoggerInterface { - public function __construct(HTTP\Request $request, ORM\EntityManager $em); - - /** - * @return array of Model\Data - */ - public function getData(); - - public function getVersion(); -} - -/** - * - * @author Steffen Vogel - * @package default - * @todo to be implemented - */ -abstract class Logger implements LoggerInterface { - protected $request; - protected $em; - - /** - * Constructor - * - * @param HTTP\Request $request - * @param ORM\EntityManager $em - */ - public function __construct(HTTP\Request $request, ORM\EntityManager $em) { - $this->request = $request; - $this->em = $em; - } - - /** - * - */ - public function log() { - $data = $this->getData(); - - if (!is_array($data)) { - $data = array($data); - } - - $this->em->flush(); - } -} - -?> \ No newline at end of file diff --git a/backend/lib/Logger/PrototypeLogger.php b/backend/lib/Logger/PrototypeLogger.php deleted file mode 100644 index 1703514..0000000 --- a/backend/lib/Logger/PrototypeLogger.php +++ /dev/null @@ -1,79 +0,0 @@ -. - */ - -namespace Volkszaehler\Logger; - -use Volkszaehler\Model; -use Doctrine\ORM; - -/** - * Logger for the the original volkszaehler.org prototype based on ethersex's watchasync - * - * @package default - * @link http://github.com/ethersex/ethersex/blob/master/services/watchasync - * @author Steffen Vogel - * @todo to be implemented - */ -class PrototypeLogger extends Logger { - /** - * @return array of Model\Data - */ - public function getData() { - $uuid = $this->request->getParameter('uuid'); - $port = $this->request->getParameter('port'); - - $channel = $this->em->getRepository('Volkszaehler\Model\Channel')->findOneBy(array( - 'description' => $uuid, - 'name' => $port - )); - - if ($channel) { - if (!($time = $this->request->getParameter('time'))) { - $time = (int) (microtime(TRUE) * 1000); - } - return new Model\Data($channel, 1, $time); - } - else { - return FALSE; - } - } - - /** - * the prototyp protocol doesn't have a version - */ - public function getVersion() { - return FALSE; - } -} - -/* - * Just some documentation - * - * /httplog/httplog.php?port=&uuid=&time= - * - * = - * = timestamp in ms since 1970 - * - */ - -?> \ No newline at end of file diff --git a/backend/lib/Logger/VzLogger.php b/backend/lib/Logger/VzLogger.php deleted file mode 100644 index 7929c04..0000000 --- a/backend/lib/Logger/VzLogger.php +++ /dev/null @@ -1,62 +0,0 @@ -. - */ - -namespace Volkszaehler\Logger; - -use Volkszaehler\Model; - -use Doctrine\ORM; - -/** - * - * @author Steffen Vogel - * @package default - * - */ -class VzLogger extends Logger { - /** - * @return array of Model\Data - */ - public function getData() { - $ucid = $this->view->request->getParameter('ucid'); - $channel = $this->em->getRepository('Volkszaehler\Model\Channel\Channel')->findOneBy(array('uuid' => $ucid)); - - $value = (float) $this->view->request->getParameter('value'); - $ts = (int) $this->view->request->getParameter('timestamp'); - if ($ts == 0) { - $ts = microtime(TRUE) * 1000; - } - - $data = new Model\Data($channel, $value, $ts); - } - - /** - * @return string the version - */ - public function getVersion() { - return $this->request->getParameter('version'); - } -} - - -?> \ No newline at end of file diff --git a/backend/lib/Model/Entity.php b/backend/lib/Model/Entity.php index 130b256..da209bd 100644 --- a/backend/lib/Model/Entity.php +++ b/backend/lib/Model/Entity.php @@ -65,7 +65,7 @@ abstract class Entity { /** * @OneToMany(targetEntity="Property", mappedBy="entity", cascade={"remove", "persist"}) - * @OrderBy({"`key`" = "ASC"}) + * @OrderBy({"key" = "ASC"}) */ protected $properties = NULL; diff --git a/backend/lib/Model/Property.php b/backend/lib/Model/Property.php index fc72041..163ec82 100644 --- a/backend/lib/Model/Property.php +++ b/backend/lib/Model/Property.php @@ -109,7 +109,7 @@ class Property { */ public function checkRemove() { if (in_array($this->key, $this->entity->getDefinition()->getRequiredProperties())) { - throw new \Exception('"' . $this->key . '" is a required property for the "' . $this->entity->getType() . '" entity'); + throw new \Exception($this->key . ' is a required property for the entity: ' . $this->entity->getType()); } } @@ -118,7 +118,7 @@ class Property { */ public function checkPersist() { if (!in_array($this->key, $this->entity->getDefinition()->getValidProperties())) { - throw new \Exception('"' . $this->key . '" is not a valid property for the "' . $this->entity->getType() . '" entity'); + throw new \Exception($this->key . ' is not a valid property for the entity: ' . $this->entity->getType()); } }