/** * Import applications. */ protected function processApplications() { $allApplciations = $this->getFormattedApplications(); if (empty($allApplciations)) { return; } $applicationsToCreate = array(); foreach ($allApplciations as $host => $applications) { if (!$this->referencer->isProcessedHost($host)) { continue; } $hostid = $this->referencer->resolveHostOrTemplate($host); foreach ($applications as $application) { $application['hostid'] = $hostid; $appId = $this->referencer->resolveApplication($hostid, $application['name']); if (!$appId) { $applicationsToCreate[] = $application; } } } // create the applications and create a hash hostid->name->applicationid if (!empty($applicationsToCreate)) { $newApplicationsIds = API::Application()->create($applicationsToCreate); foreach ($newApplicationsIds['applicationids'] as $anum => $applicationId) { $application = $applicationsToCreate[$anum]; $this->referencer->addApplicationRef($application['hostid'], $application['name'], $applicationId); } } // refresh applications because templated ones can be inherited to host and used in items $this->referencer->refreshApplications(); }