Преглед изворни кода

Updated the ticket creation web service (still known bugs)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@586 a333f486-631f-4898-b8df-5754b55c2be0
romainq пре 15 година
родитељ
комит
b56d09135a
4 измењених фајлова са 109 додато и 67 уклоњено
  1. 54 31
      pages/testlist.inc.php
  2. 6 4
      webservices/itop.wsdl.tpl
  3. 15 13
      webservices/itopsoap.examples.php
  4. 34 19
      webservices/webservices.class.inc.php

+ 54 - 31
pages/testlist.inc.php

@@ -1285,31 +1285,33 @@ $aWebServices = array(
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
-			'Server', /* sType */
 			'desc of ticket', /* sDescription */
 			'initial situation blah blah blah', /* sInitialSituation */
-			'very grave', /* sImpact */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			array(
 				new SOAPLinkCreationSpec(
-					'logInfra',
+					'InfrastructureCI',
 					array(new SOAPSearchCondition('id', 108)),
 					array(new SOAPAttributeValue('impacting', 'very critical'))
 				),
 				new SOAPLinkCreationSpec(
-					'bizDevice',
+					'NetworkDevice',
 					array(new SOAPSearchCondition('name', 'Router03')),
 					array(new SOAPAttributeValue('impact', 'who cares'))
 				),
 				new SOAPLinkCreationSpec(
-					'bizDevice',
+					'Device',
 					array(new SOAPSearchCondition('name', 'thisone')),
 					array(new SOAPAttributeValue('impact', 'our lives'))
 				),
 			), /* aImpact */
-			'low' /* sSeverity */
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 	array(
@@ -1319,16 +1321,23 @@ $aWebServices = array(
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
-			'Desktop', /* sType */
 			'PC burning', /* sDescription */
 			'The power supply suddenly started to warm up', /* sInitialSituation */
-			'The agent could not do his job', /* sImpact */
 			null, /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			array(
-			), /* aImpact */
-			'low' /* sSeverity */
+				new SOAPLinkCreationSpec(
+					'InfrastructureCI',
+					array(new SOAPSearchCondition('id', 1)),
+					array()
+				), /* aImpact */
+			),
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 	array(
@@ -1338,12 +1347,13 @@ $aWebServices = array(
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
-			'Desktop', /* sType */
 			'PC burning', /* sDescription */
 			'The power supply suddenly started to warm up', /* sInitialSituation */
-			'The agent could not do his job', /* sImpact */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			array(
 				new SOAPLinkCreationSpec(
@@ -1352,7 +1362,8 @@ $aWebServices = array(
 					array(new SOAPAttributeValue('impact', 'very critical'))
 				),
 			), /* aImpact */
-			'low' /* sSeverity */
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 	array(
@@ -1362,16 +1373,18 @@ $aWebServices = array(
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
-			'Network', /* sType */
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
-			'Could not talk to my wife', /* sImpact */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
-			'low' /* sSeverity */
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 	array(
@@ -1381,15 +1394,17 @@ $aWebServices = array(
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
-			'Network', /* sType */
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
-			'Could not talk to my wife', /* sImpact */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			null, /* aImpact */
-			'low' /* sSeverity */
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 	array(
@@ -1399,16 +1414,18 @@ $aWebServices = array(
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
-			'Network', /* sType */
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
-			'Could not talk to my wife', /* sImpact */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1000))), /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
-			'low' /* sSeverity */
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 	array(
@@ -1418,16 +1435,18 @@ $aWebServices = array(
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
-			'my type', /* sType */
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
-			'Could not talk to my wife', /* sImpact */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
-			'my severity' /* sSeverity */
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 	array(
@@ -1437,16 +1456,18 @@ $aWebServices = array(
 		'args' => array(
 			'admin', /* sLogin */
 			'xxxxx', /* sPassword */
-			'Network', /* sType */
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
-			'Could not talk to my wife', /* sImpact */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
-			'low' /* sSeverity */
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 	array(
@@ -1456,16 +1477,18 @@ $aWebServices = array(
 		'args' => array(
 			'xxxxx', /* sLogin */
 			'yyyyy', /* sPassword */
-			'Network', /* sType */
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
-			'Could not talk to my wife', /* sImpact */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
-			'low' /* sSeverity */
+			'1', /* sImpact */
+			'1', /* sUrgency */
 		),
 	),
 );

+ 6 - 4
webservices/itop.wsdl.tpl

@@ -146,15 +146,17 @@
 	<message name="CreateIncidentTicket">
 		<part name="login" type="xsd:string"/>
 		<part name="password" type="xsd:string"/>
-		<part name="type" type="xsd:string"/>
+		<part name="title" type="xsd:string"/>
 		<part name="description" type="xsd:string"/>
-		<part name="initialsituation" type="xsd:string"/>
-		<part name="impact" type="xsd:string"/>
 		<part name="caller" type="typens:ExternalKeySearch"/>
 		<part name="customer" type="typens:ExternalKeySearch"/>
+		<part name="service" type="typens:ExternalKeySearch"/>
+		<part name="service_subcategory" type="typens:ExternalKeySearch"/>
+		<part name="product" type="xsd:string"/>
 		<part name="workgroup" type="typens:ExternalKeySearch"/>
 		<part name="impacted_cis" type="typens:ArrayOfLinkCreationSpec"/>
-		<part name="severity" type="xsd:string"/>
+		<part name="impact" type="xsd:string"/>
+		<part name="urgency" type="xsd:string"/>
 	</message>
 	<message name="CreateIncidentTicketResponse">
 		<part name="CreateIncidentTicketReturn" type="typens:Result"/>

+ 15 - 13
webservices/itopsoap.examples.php

@@ -52,26 +52,28 @@ try
 	(
 		'admin', /* login */
 		'admin', /* password */
-		'Server', /* type */
-		'Email server down', /* description */
-		'HW found shutdown', /* initial situation */
-		'Email not working', /* impact */
+		'Email server down', /* title */
+		'HW found shutdown', /* description */
 		null, /* caller */
 		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* customer */
-		new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* workgroup */
+		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW Mgmt'))), /* service */
+		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Troubleshooting'))), /* service subcategory */
+		'', /* product */
+		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW support'))), /* workgroup */
 		array(
 			new SOAPLinkCreationSpec(
-				'bizDevice',
-				array(new SOAPSearchCondition('name', 'Router03')),
-				array(new SOAPAttributeValue('impact', 'root cause'))
+				'Device',
+				array(new SOAPSearchCondition('name', 'switch01')),
+				array()
 			),
 			new SOAPLinkCreationSpec(
-				'bizServer',
-				array(new SOAPSearchCondition('name', 'Server01')),
-				array(new SOAPAttributeValue('impact', ''))
+				'Server',
+				array(new SOAPSearchCondition('name', 'dbserver1.demo.com')),
+				array()
 			),
-		), /* impact */
-		'high' /* severity */
+		), /* impacted cis */
+		'1', /* impact */
+		'1', /* urgency */
 	);
 
 	echo "<p>CreateIncidentTicket() returned:\n";

+ 34 - 19
webservices/webservices.class.inc.php

@@ -543,7 +543,7 @@ class WebServices
 		return "0.8";
 	}
 
-	public function CreateIncidentTicket($sLogin, $sPassword, $sType, $sDescription, $sInitialSituation, $sImpact, $oCallerDesc, $oCustomerDesc, $oWorkgroupDesc, $aSOAPImpactedCIs, $sSeverity)
+	public function CreateIncidentTicket($sLogin, $sPassword, $sTitle, $sDescription, $oCallerDesc, $oCustomerDesc, $oServiceDesc, $oServiceSubcategoryDesc, $sProduct, $oWorkgroupDesc, $aSOAPImpactedCIs, $sImpact, $sUrgency)
 	{
 		if (!UserRights::Login($sLogin, $sPassword))
 		{
@@ -555,6 +555,8 @@ class WebServices
 
 		$aCallerDesc = self::SoapStructToExternalKeySearch($oCallerDesc);
 		$aCustomerDesc = self::SoapStructToExternalKeySearch($oCustomerDesc);
+		$aServiceDesc = self::SoapStructToExternalKeySearch($oServiceDesc);
+		$aServiceSubcategoryDesc = self::SoapStructToExternalKeySearch($oServiceSubcategoryDesc);
 		$aWorkgroupDesc = self::SoapStructToExternalKeySearch($oWorkgroupDesc);
 		$aImpactedCIs = array();
 		foreach($aSOAPImpactedCIs as $oImpactedCIs)
@@ -564,15 +566,17 @@ class WebServices
 
 		$oRes = $this->_CreateIncidentTicket
 		(
-			$sType,
+			$sTitle,
 			$sDescription,
-			$sInitialSituation,
-			$sImpact,
 			$aCallerDesc,
 			$aCustomerDesc,
+			$aServiceDesc,
+			$aServiceSubcategoryDesc,
+			$sProduct,
 			$aWorkgroupDesc,
 			$aImpactedCIs,
-			$sSeverity
+			$sImpact,
+			$sUrgency
 		);
 		return $oRes->ToSoapStructure();
 	}
@@ -581,17 +585,21 @@ class WebServices
 	 * Create an incident ticket from a monitoring system
 	 * Some CIs might be specified (by their name/IP)
 	 *	 
-	 * @param string sDecription
-	 * @param string sInitialSituation
+	 * @param string sTitle
+	 * @param string sDescription
 	 * @param array aCallerDesc
 	 * @param array aCustomerDesc
+	 * @param array aServiceDesc
+	 * @param array aServiceSubcategoryDesc
+	 * @param string sProduct
 	 * @param array aWorkgroupDesc
 	 * @param array aImpactedCIs
-	 * @param string sSeverity
+	 * @param string sImpact
+	 * @param string sUrgency
 	 *
 	 * @return WebServiceResult
 	 */
-	protected function _CreateIncidentTicket($sType, $sDescription, $sInitialSituation, $sImpact, $aCallerDesc, $aCustomerDesc, $aWorkgroupDesc, $aImpactedCIs, $sSeverity)
+	protected function _CreateIncidentTicket($sTitle, $sDescription, $aCallerDesc, $aCustomerDesc, $aServiceDesc, $aServiceSubcategoryDesc, $sProduct, $aWorkgroupDesc, $aImpactedCIs, $sImpact, $sUrgency)
 	{
 
 		$oRes = new WebServiceResult();
@@ -603,26 +611,33 @@ class WebServices
 			$oMyChange->Set("userinfo", "Administrator");
 			$iChangeId = $oMyChange->DBInsertNoReload();
 	
-			$oNewTicket = MetaModel::NewObject('bizIncidentTicket');
-			$this->MyObjectSetScalar('type', 'type', $sType, $oNewTicket, $oRes);
-			$this->MyObjectSetScalar('title', 'title', $sDescription, $oNewTicket, $oRes);
-			$this->MyObjectSetScalar('initial_situation', 'initialsituation', $sInitialSituation, $oNewTicket, $oRes);
-			$this->MyObjectSetScalar('severity', 'severity', $sSeverity, $oNewTicket, $oRes);
-	
+			$oNewTicket = MetaModel::NewObject('Incident');
+			$this->MyObjectSetScalar('title', 'title', $sTitle, $oNewTicket, $oRes);
+			$this->MyObjectSetScalar('description', 'description', $sDescription, $oNewTicket, $oRes);
+
 			$this->MyObjectSetExternalKey('org_id', 'customer', $aCustomerDesc, $oNewTicket, $oRes);
 			$this->MyObjectSetExternalKey('caller_id', 'caller', $aCallerDesc, $oNewTicket, $oRes);
-			$this->MyObjectSetExternalKey('workgroup_id', 'workgroup', $aWorkgroupDesc, $oNewTicket, $oRes);
 	
-			$aDevicesNotFound = $this->AddLinkedObjects('impacted_infra_manual', 'impacted_cis', 'logInfra', $aImpactedCIs, $oNewTicket, $oRes);
+			$this->MyObjectSetExternalKey('service_id', 'service', $aServiceDesc, $oNewTicket, $oRes);
+			$this->MyObjectSetExternalKey('servicesubcategory_id', 'servicesubcategory', $aServiceSubcategoryDesc, $oNewTicket, $oRes);
+			$this->MyObjectSetScalar('product', 'product', $sProduct, $oNewTicket, $oRes);
+
+			$this->MyObjectSetExternalKey('workgroup_id', 'workgroup', $aWorkgroupDesc, $oNewTicket, $oRes);
+
+
+			$aDevicesNotFound = $this->AddLinkedObjects('ci_list', 'impacted_cis', 'FunctionalCI', $aImpactedCIs, $oNewTicket, $oRes);
 			if (count($aDevicesNotFound) > 0)
 			{
-				$this->MyObjectSetScalar('impact', 'n/a', $sImpact.' - Related CIs: '.implode(', ', $aDevicesNotFound), $oNewTicket, $oRes);
+				$this->MyObjectSetScalar('description', 'n/a', $sDescription.' - Related CIs: '.implode(', ', $aDevicesNotFound), $oNewTicket, $oRes);
 			}
 			else
 			{
-				$this->MyObjectSetScalar('impact', 'n/a', $sImpact, $oNewTicket, $oRes);
+				$this->MyObjectSetScalar('description', 'n/a', $sDescription, $oNewTicket, $oRes);
 			}
 
+			$this->MyObjectSetScalar('impact', 'impact', $sImpact, $oNewTicket, $oRes);
+			$this->MyObjectSetScalar('urgency', 'urgency', $sUrgency, $oNewTicket, $oRes);
+
 			$this->MyObjectInsert($oNewTicket, 'created', $oMyChange, $oRes);
 		}
 		catch (CoreException $e)