[icinga-checkins] icinga.org: icinga-api/master: * Added getAffectedColumns() to and some getter functions

git at icinga.org git at icinga.org
Wed May 19 14:51:37 CEST 2010


Module: icinga-api
Branch: master
Commit: c19de50dd4c7e618a0cae0debb6d012396e57837
URL:    https://git.icinga.org/?p=icinga-api.git;a=commit;h=c19de50dd4c7e618a0cae0debb6d012396e57837

Author: jmosshammer <jannis.mosshammer at netways.de>
Date:   Wed May 19 10:41:36 2010 +0200

* Added getAffectedColumns() to and some getter functions

---

 objects/search/IcingaApiSearch.php    |   63 +++++++++++++++++++++++++++++++-
 objects/search/IcingaApiSearchIdo.php |   52 +++++++++++++++++++++++++++
 2 files changed, 113 insertions(+), 2 deletions(-)

diff --git a/objects/search/IcingaApiSearch.php b/objects/search/IcingaApiSearch.php
index f51fb50..8f8b243 100644
--- a/objects/search/IcingaApiSearch.php
+++ b/objects/search/IcingaApiSearch.php
@@ -60,7 +60,16 @@ abstract class IcingaApiSearch
 			$this->debugData = $debugData;
 		}
 	}
-
+	
+	/**
+	 * returns whether debugging is enabled
+	 * @return boolean
+	 * @author Jannis Mosshammer <jannis.mosshammer at netways.de>
+	 */
+	public function getDebug() {
+		return $this->debug;
+	}
+	
 	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setConnectionObject()
@@ -71,6 +80,16 @@ abstract class IcingaApiSearch
 	}
 
 	/**
+	 * returns the connection object 
+	 * @return IcingaApiConnectionInterface
+	 * @author Jannis Mosshammer <jannis.mosshammer at netways.de>
+	 */
+	public function getConnectionObject() {
+		return $this->connectionObject;
+	}
+	
+	
+	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setResultType()
 	 */
@@ -89,6 +108,15 @@ abstract class IcingaApiSearch
 	}
 
 	/**
+	 * Returns the current result type or false if none set
+	 * @return string
+	 * @author Jannis Mosshammer <jannis.mosshammer at netways.de>
+	 */
+	public function getResultType() {
+		return $this->resultType;
+	}
+	
+	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setSearchType()
 	 */
@@ -104,7 +132,16 @@ abstract class IcingaApiSearch
 		}
 		return $this;
 	}
-
+	
+	/**
+	 * returns the current search type or false if none is set
+	 * @return string
+	 * @author Jannis Mosshammer <jannis.mosshammer at netways.de>
+	 */
+	public function getSearchType() {
+		return $this->searchType;
+	}
+	
 	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setSearchTarget()
@@ -119,6 +156,15 @@ abstract class IcingaApiSearch
 	}
 
 	/**
+	 * returns the current search target or false if none is set
+	 * @return string
+	 * @author Jannis Mosshammer <jannis.mosshammer at netways.de>
+	 */
+	public function getSearchTarget() {
+		return $this->searchTarget;
+	}
+	
+	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setSearchFilter()
 	 */
@@ -181,6 +227,7 @@ abstract class IcingaApiSearch
 		return $this;
 	}
 
+	
 	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setSearchFilterAppend($statement, $searchAggregator)
@@ -212,6 +259,15 @@ abstract class IcingaApiSearch
 	}
 
 	/**
+	 * returns an array of the columns the result be grouped with
+	 * @return array
+	 * @author Jannis Mosshammer <jannis.mosshammer at netways.de>
+	 */
+	public function getSearchGroup() {
+		return $this->searchGroup;
+	}
+	
+	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setSearchOrder()
 	 */
@@ -228,6 +284,7 @@ abstract class IcingaApiSearch
 		return $this;
 	}
 
+	
 	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setSearchLimit()
@@ -264,6 +321,8 @@ abstract class IcingaApiSearch
 		}
 	}
 
+	
+	
 	/**
 	 * (non-PHPdoc)
 	 * @see objects/search/IcingaApiSearchInterface#setContact()
diff --git a/objects/search/IcingaApiSearchIdo.php b/objects/search/IcingaApiSearchIdo.php
index 15a65eb..d90bab0 100644
--- a/objects/search/IcingaApiSearchIdo.php
+++ b/objects/search/IcingaApiSearchIdo.php
@@ -219,6 +219,15 @@ class IcingaApiSearchIdo
 
 		return $this;
 	}
+	/**
+	 * Returns an array containing the columns of the result
+	 * 
+	 * @return array
+	 * @author Jannis Mosshammer <jannis.mosshammer at netways.de>
+	 */
+	public function getResultColumns() {
+		return $this->resultColumnKeys;
+	}
 
 	/**
 	 * replaces query variables by corresponding data
@@ -471,6 +480,49 @@ class IcingaApiSearchIdo
 		return $object;
 	}
 
+	/**
+	 * Map defining which table (shortcuts) will be fetched by which targets
+	 */
+	public $tableMap = array(
+		self::TARGET_HOST => array('h','oh','i','hcg','cg','ocg','cgm','hg','hgm','ohg','cvsh'),
+		self::TARGET_SERVICE => array('os','s','i','scg','cg','oc','ss','ocg','hs','sgm','sg','hs','oh','hgm','hg','ohg','cvsh','cvss','cvsc'),
+		self::TARGET_HOSTGROUP => array('hg','ohg','hgm','oh'),
+		self::TARGET_SERVICEGROUP => array('sg','osg','sgm','os'),
+		self::TARGET_CONTACTGROUP => array('cg','ocg','cgm','oc','cvsc'),
+		self::TARGET_TIMEPERIOD => array('otp','tp','otp'),
+		self::TARGET_CUSTOMVARIABLE => array('cv','cvs'),
+		self::TARGET_CONFIG => array('cfv'),
+		self::TARGET_PROGRAM => array('pe'),
+		self::TARGET_LOG => array('le'),
+		self::TARGET_HOST_STATUS_SUMMARY => array('hs','oh','h','i','hcg','cg','cgm','oc','hgm','cvsh','cvsc'),
+		self::TARGET_SERVICE_STATUS_SUMMARY => array('os','ss','s','i','scg','cg','cgm','oc','ocg','hs','oh','hgm','ohg','hg','cvsh','cvss','cvsc'),
+		self::TARGET_HOST_STATUS_HISTORY => array('oh','sh','h','hcg','cg','ocg','cgm','hgm','hg','cvsh'),
+		self::TARGET_SERVICE_STATUS_HISTORY => array('sh','os','s','oh','scg','cg','cgm','hgm','hg','ohg','cvsh','cvss'),
+		self::TARGET_HOST_PARENTS => array('ohp','hph','h','oh'),
+		self::TARGET_NOTIFICATIONS => array('n','on','s','h','oh','os'),
+		self::TARGET_HOSTGROUP_SUMMARY => array('hg','ohg','hgm','oh','hs'),
+		self::TARGET_SERVICEGROUP_SUMMARY => array('sg','osg','sgm','ss','os')
+	);
+	
+	/**
+	 * returns an array containing the names of all affected columns
+	 * @return array
+	 * @author Jannis Moßhammer <jannis.mosshammer at netways.de>
+	 */
+	public function getAffectedColumns() {
+		$map = $this->tableMap[$this->getSearchTarget()];
+		$affected = array();
+		$columns = $this->ifSettings->columns;
+		foreach($map as $table) {
+			foreach($columns as $name=>$column) {
+				if($column[0] == $table)
+					$affected[] = $name;
+			}
+		}
+		return $affected;
+	}
+	
+	
 }
 
 // extend exceptions





More information about the icinga-checkins mailing list