8 namespace Fossology\Lib\Proxy;
19 const ARS_TABLE_SUFFIX =
"_ars";
26 private $successfulScanners = array();
34 $this->agentDao = $agentDao;
35 $this->uploadId = $uploadId;
38 public function getSuccessfulAgents()
40 $successfulAgents = array();
41 foreach ($this->successfulScanners as $scanAgents) {
42 $successfulAgents = array_merge($successfulAgents, $scanAgents);
44 return $successfulAgents;
47 public function getLatestSuccessfulAgentIds()
50 foreach ($this->successfulScanners as $agentName=>$scanAgents) {
51 $agentRef = $scanAgents[0];
52 $agentIds[$agentName] = $agentRef->getAgentId();
57 public function createAgentStatus($scannerAgents)
59 $scannerVars = array();
60 foreach ($scannerAgents as $agentName) {
61 $agentHasArsTable = $this->agentDao->arsTableExists($agentName);
62 if (empty($agentHasArsTable)) {
70 public function getAgentMap()
73 foreach ($this->getSuccessfulAgents() as $agent) {
74 $agentMap[$agent->getAgentId()] = $agent->getAgentName() .
" " . $agent->getAgentRevision();
86 $successfulAgents = $this->agentDao->getSuccessfulAgentEntries($agentName,$this->uploadId);
87 $vars[
'successfulAgents'] = $successfulAgents;
88 $vars[
'uploadId'] = $this->uploadId;
89 $vars[
'agentName'] = $agentName;
91 if (!count($successfulAgents)) {
92 $vars[
'isAgentRunning'] = count($this->agentDao->getRunningAgentIds($this->uploadId, $agentName)) > 0;
96 $latestSuccessfulAgent = $successfulAgents[0];
97 $currentAgentRef = $this->agentDao->getCurrentAgentRef($agentName);
98 $vars[
'currentAgentId'] = $currentAgentRef->getAgentId();
99 $vars[
'currentAgentRev'] = $currentAgentRef->getAgentRevision();
100 if ($currentAgentRef->getAgentId() != $latestSuccessfulAgent[
'agent_id']) {
101 $runningJobs = $this->agentDao->getRunningAgentIds($this->uploadId, $agentName);
102 $vars[
'isAgentRunning'] = in_array($currentAgentRef->getAgentId(), $runningJobs);
105 foreach ($successfulAgents as $agent) {
106 $this->successfulScanners[$agentName][] =
new AgentRef($agent[
'agent_id'], $agentName, $agent[
'agent_rev']);
scanAgentStatus($agentName)
get status var and store successfulAgents
__construct(AgentDao $agentDao, $uploadId)