/**
  * Set Notification Commands
  *
  * @param string $type
  * @param int $contactId
  * @param string $commands
  * @throws CentreonClapiException
  */
 protected function setNotificationCmd($type, $contactId, $commands)
 {
     $cmds = explode("|", $commands);
     $cmdIds = array();
     $cmdObject = new Centreon_Object_Command();
     foreach ($cmds as $commandName) {
         $tmp = $cmdObject->getIdByParameter($cmdObject->getUniqueLabelField(), $commandName);
         if (count($tmp)) {
             $cmdIds[] = $tmp[0];
         } else {
             throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $commandName);
         }
     }
     if ($type == self::HOST_NOTIF_CMD) {
         $relObj = new Centreon_Object_Relation_Contact_Command_Host();
     } else {
         $relObj = new Centreon_Object_Relation_Contact_Command_Service();
     }
     $relObj->delete($contactId);
     foreach ($cmdIds as $cmdId) {
         $relObj->insert($contactId, $cmdId);
     }
 }
 /**
  * Set Parameters
  *
  * @param string $parameters
  * @return void
  * @throws Exception
  */
 public function setparam($parameters)
 {
     $params = explode($this->delim, $parameters);
     if (count($params) < self::NB_UPDATE_PARAMS) {
         throw new CentreonClapiException(self::MISSINGPARAMETER);
     }
     if (($objectId = $this->getObjectId($params[self::ORDER_UNIQUENAME])) != 0) {
         $commandColumns = array('global_host_event_handler', 'global_service_event_handler', 'host_perfdata_command', 'service_perfdata_command', 'host_perfdata_file_processing_command', 'service_perfdata_file_processing_command', 'ocsp_command', 'ochp_command');
         if ($params[1] == "instance" || $params[1] == "nagios_server_id") {
             $params[1] = "nagios_server_id";
             $params[2] = $this->instanceObj->getInstanceId($params[2]);
         } elseif ($params[1] == "broker_module") {
             $this->setBrokerModule($objectId, $params[2]);
         } elseif (preg_match('/(' . implode('|', $commandColumns) . ')/', $params[1], $matches)) {
             $commandName = $matches[1];
             if ($params[2]) {
                 $commandObj = new Centreon_Object_Command();
                 $res = $commandObj->getIdByParameter($commandObj->getUniqueLabelField(), $params[2]);
                 if (count($res)) {
                     $params[2] = $res[0];
                 } else {
                     throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[2]);
                 }
             } else {
                 $params[2] = NULL;
             }
         }
         if ($params[1] != "broker_module") {
             $p = strtolower($params[1]);
             if ($params[2] == "") {
                 if (isset($this->params[$p]) && $this->params[$p] == 2) {
                     $params[2] = $this->params[$p];
                 } else {
                     $params[2] = NULL;
                 }
             }
             $updateParams = array($params[1] => $params[2]);
             parent::setparam($objectId, $updateParams);
         }
     } else {
         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $params[self::ORDER_UNIQUENAME]);
     }
 }
 /**
  * Returns command id
  *
  * @param string $commandName
  * @return int
  * @throws CentreonClapiException
  */
 public function getId($commandName)
 {
     $obj = new Centreon_Object_Command();
     $tmp = $obj->getIdByParameter($obj->getUniqueLabelField(), $commandName);
     if (count($tmp)) {
         $id = $tmp[0];
     } else {
         throw new CentreonClapiException(self::OBJECT_NOT_FOUND . ":" . $commandName);
     }
     return $id;
 }