Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/query/DrydockLogSearchEngine.php
<?php | <?php | ||||
final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine { | final class DrydockLogSearchEngine extends PhabricatorApplicationSearchEngine { | ||||
private $blueprint; | private $blueprint; | ||||
private $resource; | private $resource; | ||||
private $lease; | private $lease; | ||||
private $operation; | |||||
public function setBlueprint(DrydockBlueprint $blueprint) { | public function setBlueprint(DrydockBlueprint $blueprint) { | ||||
$this->blueprint = $blueprint; | $this->blueprint = $blueprint; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getBlueprint() { | public function getBlueprint() { | ||||
return $this->blueprint; | return $this->blueprint; | ||||
Show All 12 Lines | public function setLease(DrydockLease $lease) { | ||||
$this->lease = $lease; | $this->lease = $lease; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getLease() { | public function getLease() { | ||||
return $this->lease; | return $this->lease; | ||||
} | } | ||||
public function setOperation(DrydockRepositoryOperation $operation) { | |||||
$this->operation = $operation; | |||||
return $this; | |||||
} | |||||
public function getOperation() { | |||||
return $this->operation; | |||||
} | |||||
public function canUseInPanelContext() { | public function canUseInPanelContext() { | ||||
// Prevent use on Dashboard panels since all log queries currently need a | // Prevent use on Dashboard panels since all log queries currently need a | ||||
// parent object and these don't seem particularly useful in any case. | // parent object and these don't seem particularly useful in any case. | ||||
return false; | return false; | ||||
} | } | ||||
public function getResultTypeDescription() { | public function getResultTypeDescription() { | ||||
return pht('Drydock Logs'); | return pht('Drydock Logs'); | ||||
Show All 16 Lines | if ($resource) { | ||||
$query->withResourcePHIDs(array($resource->getPHID())); | $query->withResourcePHIDs(array($resource->getPHID())); | ||||
} | } | ||||
$lease = $this->getLease(); | $lease = $this->getLease(); | ||||
if ($lease) { | if ($lease) { | ||||
$query->withLeasePHIDs(array($lease->getPHID())); | $query->withLeasePHIDs(array($lease->getPHID())); | ||||
} | } | ||||
$operation = $this->getOperation(); | |||||
if ($operation) { | |||||
$query->withOperationPHIDs(array($operation->getPHID())); | |||||
} | |||||
return $query; | return $query; | ||||
} | } | ||||
protected function buildQueryFromParameters(array $map) { | protected function buildQueryFromParameters(array $map) { | ||||
$query = $this->newQuery(); | $query = $this->newQuery(); | ||||
return $query; | return $query; | ||||
} | } | ||||
Show All 16 Lines | protected function getURI($path) { | ||||
} | } | ||||
$lease = $this->getLease(); | $lease = $this->getLease(); | ||||
if ($lease) { | if ($lease) { | ||||
$id = $lease->getID(); | $id = $lease->getID(); | ||||
return "/drydock/lease/{$id}/logs/{$path}"; | return "/drydock/lease/{$id}/logs/{$path}"; | ||||
} | } | ||||
$operation = $this->getOperation(); | |||||
if ($operation) { | |||||
$id = $operation->getID(); | |||||
return "/drydock/operation/{$id}/logs/{$path}"; | |||||
} | |||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Search engine has no blueprint, resource, or lease.')); | 'Search engine has no blueprint, resource, lease, or operation.')); | ||||
} | } | ||||
protected function getBuiltinQueryNames() { | protected function getBuiltinQueryNames() { | ||||
return array( | return array( | ||||
'all' => pht('All Logs'), | 'all' => pht('All Logs'), | ||||
); | ); | ||||
} | } | ||||
Show All 28 Lines |