[icinga-checkins] icinga.org: icinga-web/jmosshammer/default2: * Updated icingaScheduler to work without AppKit bootstrap

git at icinga.org git at icinga.org
Wed May 26 11:54:17 CEST 2010


Module: icinga-web
Branch: jmosshammer/default2
Commit: 952b43ab6eee4cc577e3338118381ed89cd54a28
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=952b43ab6eee4cc577e3338118381ed89cd54a28

Author: jmosshammer <jmosshammer at ws-jmosshammer.(none)>
Date:   Wed May 26 11:53:58 2010 +0200

* Updated icingaScheduler to work without AppKit bootstrap

---

 lib/icingaScheduler/CronAgaviAdapter.class.php     |   11 ++++++++++-
 lib/icingaScheduler/CronJobDefinition.class.php    |    2 +-
 .../CronJobParser/CronDBParser.class.php           |   10 +++++++---
 lib/icingaScheduler/icingaCron.php                 |    2 +-
 lib/icingaScheduler/res/storage.dat                |    1 +
 5 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/lib/icingaScheduler/CronAgaviAdapter.class.php b/lib/icingaScheduler/CronAgaviAdapter.class.php
index 467600c..daec5c7 100755
--- a/lib/icingaScheduler/CronAgaviAdapter.class.php
+++ b/lib/icingaScheduler/CronAgaviAdapter.class.php
@@ -1,6 +1,8 @@
 <?php
 define("PATH_TO_AGAVI",dirname(__FILE__)."/../agavi/src/agavi.php");
 define("PATH_TO_CONFIG",dirname(__FILE__)."/../../app/config.php");
+define("PATH_TO_DOCTRINE",dirname(__FILE__)."/../../lib/doctrine/lib/Doctrine.php");
+define("PATH_TO_DOCTRINE_MODELS",dirname(__FILE__)."/../../app/modules/AppKit/lib/database/models");
 /**
  * Singleton class that will is used as a communication interface with agavi
  * Loads the bootstrap 
@@ -70,9 +72,16 @@ class CronAgaviAdapter {
 	private function bootstrap() {
 		require_once($this->agaviPath);
 		require_once($this->configPath);
+		
+		require_once(PATH_TO_DOCTRINE);
+		spl_autoload_register(array('Doctrine', 'autoload'));
+		Doctrine::loadModels(PATH_TO_DOCTRINE_MODELS."/generated");
+		Doctrine::loadModels(PATH_TO_DOCTRINE_MODELS);
+		
 		Agavi::bootstrap('development');
+		AgaviController::initializeModule('Web');
+		AgaviController::initializeModule('AppKit');
 		AgaviConfig::set('core.default_context', 'console');
-		AppKit::bootstrap();
 		
 	}
 	
diff --git a/lib/icingaScheduler/CronJobDefinition.class.php b/lib/icingaScheduler/CronJobDefinition.class.php
index 9f52eba..9f177a3 100755
--- a/lib/icingaScheduler/CronJobDefinition.class.php
+++ b/lib/icingaScheduler/CronJobDefinition.class.php
@@ -308,7 +308,7 @@ class CronJobDefinition {
 	 */
 	protected function isInFixedTime($lastExec) {
 		$interval = $this->getInterval();
-		$times = $interval["times"];
+		$times = @$interval["times"];
 		if(!$times) 
 			return false;
 			
diff --git a/lib/icingaScheduler/CronJobParser/CronDBParser.class.php b/lib/icingaScheduler/CronJobParser/CronDBParser.class.php
index d28c013..d1d4bae 100755
--- a/lib/icingaScheduler/CronJobParser/CronDBParser.class.php
+++ b/lib/icingaScheduler/CronJobParser/CronDBParser.class.php
@@ -27,7 +27,7 @@ class CronJobParser_CronDBParser extends CronJobParser {
 	protected $agavi = null;
 	protected $dbResult = array();
 	protected $fields = array('*');
-	
+	protected static $connected = false;
 	/**
 	 * Returns the doctrine database modelname 
 	 * @return String 
@@ -99,7 +99,10 @@ class CronJobParser_CronDBParser extends CronJobParser {
 		if($model) 
 			$this->setModel($model);			
 		$this->setAgavi(CronAgaviAdapter::getInstance());
-
+		if(!self::$connected)  {
+			AgaviContext::getInstance()->getDatabaseManager()->getDatabase()->connect();
+			self::$connected = true;
+		}
 		parent::__construct($model,$verbose,$logFile);
 	}	
 		
@@ -109,7 +112,8 @@ class CronJobParser_CronDBParser extends CronJobParser {
 	 */
 	protected function parse() {
 		$agavi = $this->getAgavi();
-		$query = Doctrine_Query::create()
+
+		$query = Doctrine_Query::create(null,'Doctrine_Query')
 			->select(implode(",",$this->getFields()))
 			->from($this->getModel());
 		$result = $query->fetchArray();
diff --git a/lib/icingaScheduler/icingaCron.php b/lib/icingaScheduler/icingaCron.php
index 1eef859..a72a067 100755
--- a/lib/icingaScheduler/icingaCron.php
+++ b/lib/icingaScheduler/icingaCron.php
@@ -87,7 +87,7 @@ class icingaCron implements IcingaCronJobInterface {
 	 */
 	public function __construct(array $params = array(),$verbose = false) {	
 		$this->setVerbose($verbose);
-		$this->setAction($params["action"]);
+		$this->setAction(@$params["action"]);
 		try {
 			switch($params["type"]) {
 				case 'XML':
diff --git a/lib/icingaScheduler/res/storage.dat b/lib/icingaScheduler/res/storage.dat
index e69de29..9c01b89 100755
--- a/lib/icingaScheduler/res/storage.dat
+++ b/lib/icingaScheduler/res/storage.dat
@@ -0,0 +1 @@
+a:2:{s:7:"Heatmap";a:2:{s:8:"lastExec";i:1274867403;s:6:"result";b:1;}s:10:"testtest_0";a:2:{s:8:"lastExec";i:1274867051;s:6:"result";b:1;}}
\ No newline at end of file





More information about the icinga-checkins mailing list