3 final class AlmanacDeviceQuery
11 private $isClusterDevice;
14 public function withIDs(array $ids) {
19 public function withPHIDs(array $phids) {
20 $this->phids
= $phids;
24 public function withNames(array $names) {
25 $this->names
= $names;
29 public function withNamePrefix($prefix) {
30 $this->namePrefix
= $prefix;
34 public function withNameSuffix($suffix) {
35 $this->nameSuffix
= $suffix;
39 public function withStatuses(array $statuses) {
40 $this->statuses
= $statuses;
44 public function withNameNgrams($ngrams) {
45 return $this->withNgramsConstraint(
46 new AlmanacDeviceNameNgrams(),
50 public function withIsClusterDevice($is_cluster_device) {
51 $this->isClusterDevice
= $is_cluster_device;
55 public function newResultObject() {
56 return new AlmanacDevice();
59 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
60 $where = parent
::buildWhereClauseParts($conn);
62 if ($this->ids
!== null) {
69 if ($this->phids
!== null) {
72 'device.phid IN (%Ls)',
76 if ($this->names
!== null) {
78 foreach ($this->names
as $name) {
79 $hashes[] = PhabricatorHash
::digestForIndex($name);
83 'device.nameIndex IN (%Ls)',
87 if ($this->namePrefix
!== null) {
90 'device.name LIKE %>',
94 if ($this->nameSuffix
!== null) {
97 'device.name LIKE %<',
101 if ($this->isClusterDevice
!== null) {
104 'device.isBoundToClusterService = %d',
105 (int)$this->isClusterDevice
);
108 if ($this->statuses
!== null) {
111 'device.status IN (%Ls)',
118 protected function getPrimaryTableAlias() {
122 public function getOrderableColumns() {
123 return parent
::getOrderableColumns() +
array(
125 'table' => $this->getPrimaryTableAlias(),
134 protected function newPagingMapFromPartialObject($object) {
136 'id' => (int)$object->getID(),
137 'name' => $object->getName(),
141 public function getBuiltinOrders() {
144 'vector' => array('name'),
145 'name' => pht('Device Name'),
147 ) + parent
::getBuiltinOrders();
150 public function getQueryApplicationClass() {
151 return 'PhabricatorAlmanacApplication';