Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • KmlBundle
      • Element
    • ManagerBundle
      • Controller
      • Form
        • DataTransformer
        • Type
    • MonitoringBundle
      • Command
      • Component
      • Controller
      • DependencyInjection
      • Entity
      • EventListener
      • Form
    • PrintBundle
      • Component
      • Controller
    • WmcBundle
      • Component
        • Exception
      • Element
        • Type
      • Entity
      • Form
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • MonitoringDefinitionController
  • MonitoringJobController
  • SchedulerProfileController
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: namespace Mapbender\MonitoringBundle\Controller;
  3: use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  5: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  6: use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7: use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  8: use Mapbender\MonitoringBundle\Entity\MonitoringJob;
  9: use Mapbender\MonitoringBundle\Entity\MonitoringDefinition;
 10: use Symfony\Component\HttpFoundation\Response;
 11: //use Mapbender\MonitoringBundle\Form\MonitoringJobType;
 12: 
 13: /**
 14:  * Description of MonitoringDefinitionController
 15:  *
 16:  * @author apour
 17:  */
 18: class MonitoringJobController extends Controller {
 19:     /**
 20:      * @Route("/jobs/")
 21:      * @Method("GET")
 22:      * @Template()
 23:      * @ParamConverter("monitoringJobList",class="Mapbender\MonitoringBundle\Entity\MonitoringJob")
 24:      */
 25:     public function indexAction(array $monitoringJobList) {
 26:         return array(
 27: 
 28:         );
 29:     }
 30:     
 31:     /**
 32:      * @Route("/exportcsv/")
 33:      * @Method("GET")
 34:      * @Template()
 35:      */
 36:     public function exportcsvAction() {
 37:         $mdid = $this->get('request')->get('mdid');
 38:         $jobs = array();
 39:         if($mdid !== null){
 40:             $query = $this->getDoctrine()->getEntityManager()->createQuery(
 41:                     "SELECT j From Mapbender\MonitoringBundle\Entity\MonitoringJob j"
 42:                     ." WHERE j.monitoringDefinition= :md"
 43:                     ." ORDER BY j.timestamp DESC")
 44:                     ->setParameter("md", $mdid);
 45:             $jobs = $query->getResult();
 46:         } else {
 47:             $query = $this->getDoctrine()->getEntityManager()->createQuery(
 48:                     "SELECT j From Mapbender\MonitoringBundle\Entity\MonitoringJob j"
 49:                     ." ORDER BY j.timestamp DESC");
 50:             $jobs = $query->getResult();
 51:         }
 52:         $lines = array();
 53:         $idx = 0;
 54:         $SEPARATOR_VALUE = "\t";
 55:         $SEPARATOR_ROW = "\n";
 56:         $content = "id"
 57:                 .$SEPARATOR_VALUE."monitoringdefinition_id"
 58:                 .$SEPARATOR_VALUE."result".$SEPARATOR_VALUE."latency"
 59:                 .$SEPARATOR_VALUE."changed".$SEPARATOR_VALUE."status".$SEPARATOR_ROW;
 60:         if($jobs !== null && count($jobs) > 0){
 61:             foreach($jobs as $job){
 62:                 $content .= $this->checkValue($job->getId())
 63:                         .$SEPARATOR_VALUE.$this->checkValue($job->getMonitoringDefinition()->getId())
 64:                         .$SEPARATOR_VALUE.$this->checkValue($job->getResult())
 65:                         .$SEPARATOR_VALUE.$this->checkValue($job->getLatency())
 66:                         .$SEPARATOR_VALUE.($job->getChanged() ? $this->checkValue("true") : $this->checkValue(null))
 67:                         .$SEPARATOR_VALUE.$this->checkValue($job->getStatus())
 68:                         .$SEPARATOR_ROW;
 69:             }
 70:         }
 71:         $response = new Response();
 72:         $response->setContent($content);
 73:         $response->headers->set("Content-Type", "text/csv; charset=UTF-8");
 74:         $response->headers->set("Content-Disposition", "attachment; filename=csv_export.csv");
 75:         $response->headers->set("Pragma", "no-cache");
 76:         $response->headers->set("Expires", "0");
 77:         return $response;
 78:     }
 79:     protected function checkValue($value){
 80:         if ($value == null || $value == ""){
 81:             return $value;
 82:         } else {
 83:             $value = str_replace('"', '""', $value);
 84:             return '"'.$value.'"';
 85:         }
 86:     }
 87:     
 88:     /**
 89:      * @Route("/delete/")
 90:      * @Method("POST")
 91:      * @Template()
 92:      */
 93:     public function deleteAction() {
 94:         $mdid = $this->get('request')->get('mdid');
 95:         if($mdid !== null){
 96:             $query = $this->getDoctrine()->getEntityManager()->createQuery(
 97:                     "DELETE From Mapbender\MonitoringBundle\Entity\MonitoringJob j"
 98:                     ." WHERE j.monitoringDefinition= :md")
 99:                     ->setParameter("md", $mdid);
100:             $jobs = $query->getResult();
101:         } else {
102:             $query = $this->getDoctrine()->getEntityManager()->createQuery(
103:                     "DELETE From Mapbender\MonitoringBundle\Entity\MonitoringJob j");
104:             $jobs = $query->getResult();
105:         }
106:         if($mdid !== null){
107:             return $this->redirect($this->generateUrl("mapbender_monitoring_monitoringdefinition_edit",array('mdId' => $mdid)));
108:         } else {
109:             return $this->redirect($this->generateUrl("mapbender_monitoring_monitoringdefinition_index"));
110:         }
111:     }
112:     /**
113:      * @Route("/delete/")
114:      * @Method("GET")
115:      * @Template()
116:      */
117:     public function confirmdeleteAction() {
118:         $mdid = $this->get('request')->get('mdid');
119:         $md = $this->getDoctrine()->getRepository("MapbenderMonitoringBundle:MonitoringDefinition")
120:                 ->findOneById($mdid);
121:         return array(
122:             "md" => $md
123:         );
124:     }   
125: }
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0