diff --git a/backend/lib/Controller/Channel.php b/backend/lib/Controller/Channel.php index 034bb2f..df6ddaa 100644 --- a/backend/lib/Controller/Channel.php +++ b/backend/lib/Controller/Channel.php @@ -27,19 +27,18 @@ class Channel extends Controller { // TODO authentification/indentification public function get() { - $dql = 'SELECT c FROM Volkszaehler\Model\Channel\Channel c JOIN WHERE'; + $dql = 'SELECT c FROM Volkszaehler\Model\Channel c'; - $conditions = array(); if ($this->view->request->getParameter('uuid')) { - $conditions['uuid'] = $this->view->request->getParameter('uuid'); + // TODO add conditions } if ($this->view->request->getParameter('ugid')) { - + // TODO add conditions } if ($this->view->request->getParameter('indicator')) { - + // TODO add conditions } $q = $this->em->createQuery($dql); diff --git a/backend/lib/Controller/Data.php b/backend/lib/Controller/Data.php index f650194..d781470 100644 --- a/backend/lib/Controller/Data.php +++ b/backend/lib/Controller/Data.php @@ -21,12 +21,15 @@ namespace Volkszaehler\Controller; +// TODO call as subcontroller from Controller\Channel::get()? class Data extends Controller { + + // TODO authentification/indentification public function get() { // TODO why not ucids? $ids = explode(',', trim($this->view->request->getParameter('ids'))); - $q = $this->em->createQuery('SELECT c FROM Volkszaehler\Model\Channel\Channel c WHERE c.id IN (' . implode(', ', $ids) . ')'); + $q = $this->em->createQuery('SELECT c FROM Volkszaehler\Model\Channel c WHERE c.id IN (' . implode(', ', $ids) . ')'); $channels = $q->execute(); $from = ($this->view->request->getParameter('from')) ? (int) $this->view->request->getParameter('from') : NULL; @@ -35,7 +38,7 @@ class Data extends Controller { foreach ($channels as $channel) { $interpreter = $channel->getInterpreter($this->em); - $this->view->add($interpreter->getValues($from, $to, $groupBy)); + $this->view->add($channel, $interpreter->getValues($from, $to, $groupBy)); } } diff --git a/backend/lib/Interpreter/Interpreter.php b/backend/lib/Interpreter/Interpreter.php index 7925caf..a332956 100644 --- a/backend/lib/Interpreter/Interpreter.php +++ b/backend/lib/Interpreter/Interpreter.php @@ -35,7 +35,7 @@ abstract class Interpreter implements InterpreterInterface { /* * constructor */ - public function __construct(\Volkszaehler\Model\Channel\Channel $channel, \Doctrine\ORM\EntityManager $em) { + public function __construct(\Volkszaehler\Model\Channel $channel, \Doctrine\ORM\EntityManager $em) { $this->channel = $channel; $this->em = $em; } diff --git a/backend/lib/Model/Channel.php b/backend/lib/Model/Channel.php index 689098a..894ebeb 100644 --- a/backend/lib/Model/Channel.php +++ b/backend/lib/Model/Channel.php @@ -29,7 +29,7 @@ use Doctrine\Common\Collections\ArrayCollection; * @Entity * @Table(name="channels") */ -abstract class Channel extends Entity { +class Channel extends Entity { /** @Column(type="string") */ protected $name; @@ -47,7 +47,7 @@ abstract class Channel extends Entity { /** @Column(type="integer") */ private $resolution; - /** @Column(type="decimal") */ + /** @Column(type="decimal", precision="5", scale="2") */ private $cost; /* diff --git a/backend/lib/Model/Proxies/VolkszaehlerModelChannelProxy.php b/backend/lib/Model/Proxies/VolkszaehlerModelChannelProxy.php new file mode 100644 index 0000000..24c63a7 --- /dev/null +++ b/backend/lib/Model/Proxies/VolkszaehlerModelChannelProxy.php @@ -0,0 +1,123 @@ +_entityPersister = $entityPersister; + $this->_identifier = $identifier; + } + private function _load() + { + if (!$this->__isInitialized__ && $this->_entityPersister) { + $this->__isInitialized__ = true; + if ($this->_entityPersister->load($this->_identifier, $this) === null) { + throw new \Doctrine\ORM\EntityNotFoundException(); + } + unset($this->_entityPersister); + unset($this->_identifier); + } + } + + + public function addData(\Volkszaehler\Model\Data $data) + { + $this->_load(); + return parent::addData($data); + } + + public function getInterpreter(\Doctrine\ORM\EntityManager $em) + { + $this->_load(); + return parent::getInterpreter($em); + } + + public function getName() + { + $this->_load(); + return parent::getName(); + } + + public function setName($name) + { + $this->_load(); + return parent::setName($name); + } + + public function getDescription() + { + $this->_load(); + return parent::getDescription(); + } + + public function setDescription($description) + { + $this->_load(); + return parent::setDescription($description); + } + + public function getUnit() + { + $this->_load(); + return parent::getUnit(); + } + + public function getIndicator() + { + $this->_load(); + return parent::getIndicator(); + } + + public function getResolution() + { + $this->_load(); + return parent::getResolution(); + } + + public function setResolution($resolution) + { + $this->_load(); + return parent::setResolution($resolution); + } + + public function getCost() + { + $this->_load(); + return parent::getCost(); + } + + public function setCost($cost) + { + $this->_load(); + return parent::setCost($cost); + } + + public function getId() + { + $this->_load(); + return parent::getId(); + } + + public function getUuid() + { + $this->_load(); + return parent::getUuid(); + } + + + public function __sleep() + { + if (!$this->__isInitialized__) { + throw new \RuntimeException("Not fully loaded proxy can not be serialized."); + } + return array('name', 'description', 'indicator', 'data', 'resolution', 'cost', 'id', 'uuid'); + } +} \ No newline at end of file