30 const ARS_TABLE_SUFFIX =
"_ars";
37 private $successfulScanners = array();
45 $this->agentDao = $agentDao;
46 $this->uploadId = $uploadId;
49 public function getSuccessfulAgents()
51 $successfulAgents = array();
52 foreach ($this->successfulScanners as $scanAgents) {
53 $successfulAgents = array_merge($successfulAgents, $scanAgents);
55 return $successfulAgents;
58 public function getLatestSuccessfulAgentIds()
61 foreach ($this->successfulScanners as $agentName=>$scanAgents) {
62 $agentRef = $scanAgents[0];
63 $agentIds[$agentName] = $agentRef->getAgentId();
68 public function createAgentStatus($scannerAgents)
70 $scannerVars = array();
71 foreach ($scannerAgents as $agentName) {
72 $agentHasArsTable = $this->agentDao->arsTableExists($agentName);
73 if (empty($agentHasArsTable)) {
81 public function getAgentMap()
84 foreach ($this->getSuccessfulAgents() as $agent) {
85 $agentMap[$agent->getAgentId()] = $agent->getAgentName() .
" " . $agent->getAgentRevision();
97 $successfulAgents = $this->agentDao->getSuccessfulAgentEntries($agentName,$this->uploadId);
98 $vars[
'successfulAgents'] = $successfulAgents;
99 $vars[
'uploadId'] = $this->uploadId;
100 $vars[
'agentName'] = $agentName;
102 if (!count($successfulAgents)) {
103 $vars[
'isAgentRunning'] = count($this->agentDao->getRunningAgentIds($this->uploadId, $agentName)) > 0;
107 $latestSuccessfulAgent = $successfulAgents[0];
108 $currentAgentRef = $this->agentDao->getCurrentAgentRef($agentName);
109 $vars[
'currentAgentId'] = $currentAgentRef->getAgentId();
110 $vars[
'currentAgentRev'] = $currentAgentRef->getAgentRevision();
111 if ($currentAgentRef->getAgentId() != $latestSuccessfulAgent[
'agent_id']) {
112 $runningJobs = $this->agentDao->getRunningAgentIds($this->uploadId, $agentName);
113 $vars[
'isAgentRunning'] = in_array($currentAgentRef->getAgentId(), $runningJobs);
116 foreach ($successfulAgents as $agent) {
117 $this->successfulScanners[$agentName][] =
new AgentRef($agent[
'agent_id'], $agentName, $agent[
'agent_rev']);
__construct(AgentDao $agentDao, $uploadId)
scanAgentStatus($agentName)
get status var and store successfulAgents