示例#1
0
 /**
  * @cmdForm /centreon-bam/indicator/update map
  * @cmdObject string ba the ba
  * @cmdObject string indicator-ba the indicator-ba kpi
  * @cmdObject string service the service kpi
  * @cmdObject string boolean the boolean kpi 
  */
 public function showAction($object)
 {
     IndicatorRepository::transco($object);
     $kpi = Indicator::getKpi($this->parseObjectParams($object));
     $this->normalizeSingleSet($kpi);
     $result = '';
     foreach ($kpi as $key => $value) {
         $result .= $key . ': ' . $value . "\n";
     }
     echo $result;
 }
示例#2
0
 public static function updateIndicatorConsole($object, $givenParameters, $origin = "", $route = "", $validateMandatory = true)
 {
     self::validateForm($givenParameters, $origin, $route, $validateMandatory);
     $class = static::$objectClass;
     $db = Di::getDefault()->get('db_centreon');
     $kpi = Indicator::getKpi($object);
     $id = $kpi['kpi_id'];
     $columns = $class::getColumns();
     $updateValues = array();
     foreach ($givenParameters as $key => $value) {
         if (in_array($key, $columns)) {
             if (is_string($value)) {
                 $updateValues[$key] = trim($value);
             } else {
                 $updateValues[$key] = $value;
             }
         }
     }
     $relBooleanIndicator = '\\CentreonBam\\Models\\BooleanIndicator';
     if ($kpi['kpi_type'] === '0') {
         $serviceHostId = explode('_', $updateValues['service_id']);
         $updateValues['service_id'] = $serviceHostId[0];
         $updateValues['host_id'] = $serviceHostId[1];
         $updateValues['boolean_id'] = null;
         $updateValues['id_indicator_ba'] = null;
         $updateValues['meta_id'] = null;
     } elseif ($kpi['kpi_type'] === '1') {
         $updateValues['host_id'] = null;
         $updateValues['service_id'] = null;
         $updateValues['boolean_id'] = null;
         $updateValues['id_indicator_ba'] = null;
     } elseif ($kpi['kpi_type'] === '2') {
         $updateValues['host_id'] = null;
         $updateValues['service_id'] = null;
         $updateValues['boolean_id'] = null;
         $updateValues['meta_id'] = null;
     } elseif ($kpi['kpi_type'] === '3') {
         $updateValues['host_id'] = null;
         $updateValues['service_id'] = null;
         $updateValues['meta_id'] = null;
         $updateValues['id_indicator_ba'] = null;
         $updateValuesBoolean = array();
         $updateValuesBoolean['expression'] = $givenParameters['boolean_expression'];
         $updateValuesBoolean['name'] = $givenParameters['boolean_name'];
         $updateValuesBoolean['bool_state'] = $givenParameters['bool_state'];
         $resultBoolean = BooleanIndicator::getIdByParameter('name', $updateValuesBoolean['name']);
         if (count($resultBoolean) > 0) {
             $iIdBoolean = $resultBoolean[0];
         }
         if (!isset($iIdBoolean) || isset($iIdBoolean) && empty($iIdBoolean)) {
             $updateValues['boolean_id'] = $relBooleanIndicator::insert($updateValuesBoolean);
         } else {
             $updateValues['boolean_id'] = $iIdBoolean;
             $relBooleanIndicator::update($updateValues['boolean_id'], $updateValuesBoolean);
         }
     }
     if ($kpi['kpi_type'] !== '3') {
         $booleanId = $class::getParameters($kpi['kpi_id'], 'boolean_id');
         $class::update($id, $updateValues);
         if (isset($booleanId['boolean_id'])) {
             $relBooleanIndicator::delete($booleanId['boolean_id']);
         }
     } else {
         $class::update($id, $updateValues);
     }
     if (method_exists(get_called_class(), 'postSave')) {
         static::postSave($id, 'update', $givenParameters);
     }
 }
示例#3
0
 /**
  * Used for inserting relation into database
  *
  * @param int $fkey
  * @param int $skey
  * @return void
  */
 public static function insert($fkey, $skey = null)
 {
     IndicatorSimpleModel::update($fkey, array('id_ba' => $skey));
 }