diff --git a/src/applications/almanac/query/AlmanacServiceSearchEngine.php b/src/applications/almanac/query/AlmanacServiceSearchEngine.php index 1a9509a2c2..a2fd9c23b7 100644 --- a/src/applications/almanac/query/AlmanacServiceSearchEngine.php +++ b/src/applications/almanac/query/AlmanacServiceSearchEngine.php @@ -1,122 +1,118 @@ newQuery(); if ($map['match'] !== null) { $query->withNameNgrams($map['match']); } if ($map['names']) { $query->withNames($map['names']); } if ($map['devicePHIDs']) { $query->withDevicePHIDs($map['devicePHIDs']); } if ($map['serviceTypes']) { $query->withServiceTypes($map['serviceTypes']); } return $query; } protected function buildCustomSearchFields() { return array( id(new PhabricatorSearchTextField()) ->setLabel(pht('Name Contains')) ->setKey('match') ->setDescription(pht('Search for services by name substring.')), id(new PhabricatorSearchStringListField()) ->setLabel(pht('Exact Names')) ->setKey('names') ->setDescription(pht('Search for services with specific names.')), id(new PhabricatorSearchDatasourceField()) ->setLabel(pht('Service Types')) ->setKey('serviceTypes') ->setDescription(pht('Find services by type.')) ->setDatasource(id(new AlmanacServiceTypeDatasource())), id(new PhabricatorPHIDsSearchField()) ->setLabel(pht('Devices')) ->setKey('devicePHIDs') ->setDescription( pht('Search for services bound to particular devices.')), ); } protected function getURI($path) { return '/almanac/service/'.$path; } protected function getBuiltinQueryNames() { $names = array( 'all' => pht('All Services'), ); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $services, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($services, 'AlmanacService'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); $list->setUser($viewer); foreach ($services as $service) { $item = id(new PHUIObjectItemView()) ->setObjectName(pht('Service %d', $service->getID())) ->setHeader($service->getName()) ->setHref($service->getURI()) ->setObject($service) ->addIcon( $service->getServiceImplementation()->getServiceTypeIcon(), $service->getServiceImplementation()->getServiceTypeShortName()); $list->addItem($item); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No Almanac Services found.')); return $result; } } diff --git a/src/applications/nuance/query/NuanceQueueQuery.php b/src/applications/nuance/query/NuanceQueueQuery.php index d50e393667..10f761d189 100644 --- a/src/applications/nuance/query/NuanceQueueQuery.php +++ b/src/applications/nuance/query/NuanceQueueQuery.php @@ -1,55 +1,47 @@ ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } + public function newResultObject() { + return new NuanceQueue(); + } + protected function loadPage() { - $table = new NuanceQueue(); - $conn = $table->establishConnection('r'); - - $data = queryfx_all( - $conn, - '%Q FROM %T %Q %Q %Q', - $this->buildSelectClause($conn), - $table->getTableName(), - $this->buildWhereClause($conn), - $this->buildOrderClause($conn), - $this->buildLimitClause($conn)); - - return $table->loadAllFromArray($data); + return $this->loadStandardPage($this->newResultObject()); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'phid IN (%Ls)', $this->phids); } return $where; } } diff --git a/src/applications/nuance/query/NuanceQueueSearchEngine.php b/src/applications/nuance/query/NuanceQueueSearchEngine.php index 12259982f1..2f794c2a9c 100644 --- a/src/applications/nuance/query/NuanceQueueSearchEngine.php +++ b/src/applications/nuance/query/NuanceQueueSearchEngine.php @@ -1,79 +1,77 @@ newQuery(); return $query; } - public function buildSearchForm( - AphrontFormView $form, - PhabricatorSavedQuery $saved_query) {} + protected function buildCustomSearchFields() { + return array(); + } protected function getURI($path) { return '/nuance/queue/'.$path; } protected function getBuiltinQueryNames() { $names = array( 'all' => pht('All Queues'), ); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $queues, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($queues, 'NuanceQueue'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); $list->setUser($viewer); foreach ($queues as $queue) { $item = id(new PHUIObjectItemView()) ->setObjectName(pht('Queue %d', $queue->getID())) ->setHeader($queue->getName()) ->setHref($queue->getURI()); $list->addItem($item); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No queues found.')); return $result; } } diff --git a/src/applications/nuance/query/NuanceSourceQuery.php b/src/applications/nuance/query/NuanceSourceQuery.php index ee4b964ee3..6fbc4d3ddf 100644 --- a/src/applications/nuance/query/NuanceSourceQuery.php +++ b/src/applications/nuance/query/NuanceSourceQuery.php @@ -1,68 +1,60 @@ ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } public function withTypes($types) { $this->types = $types; return $this; } - protected function loadPage() { - $table = new NuanceSource(); - $conn = $table->establishConnection('r'); - - $data = queryfx_all( - $conn, - '%Q FROM %T %Q %Q %Q', - $this->buildSelectClause($conn), - $table->getTableName(), - $this->buildWhereClause($conn), - $this->buildOrderClause($conn), - $this->buildLimitClause($conn)); + public function newResultObject() { + return new NuanceSource(); + } - return $table->loadAllFromArray($data); + protected function loadPage() { + return $this->loadStandardPage($this->newResultObject()); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->types !== null) { $where[] = qsprintf( $conn, 'type IN (%Ls)', $this->types); } if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'phid IN (%Ls)', $this->phids); } return $where; } } diff --git a/src/applications/nuance/query/NuanceSourceSearchEngine.php b/src/applications/nuance/query/NuanceSourceSearchEngine.php index 02a8b502fb..2991c69c5f 100644 --- a/src/applications/nuance/query/NuanceSourceSearchEngine.php +++ b/src/applications/nuance/query/NuanceSourceSearchEngine.php @@ -1,82 +1,80 @@ newQuery(); return $query; } - public function buildSearchForm( - AphrontFormView $form, - PhabricatorSavedQuery $saved_query) {} + protected function buildCustomSearchFields() { + return array(); + } protected function getURI($path) { return '/nuance/source/'.$path; } protected function getBuiltinQueryNames() { $names = array( 'all' => pht('All Sources'), ); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $sources, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($sources, 'NuanceSource'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); $list->setUser($viewer); foreach ($sources as $source) { $item = id(new PHUIObjectItemView()) ->setObjectName(pht('Source %d', $source->getID())) ->setHeader($source->getName()) ->setHref($source->getURI()); $item->addIcon('none', $source->getType()); $list->addItem($item); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No sources found.')); return $result; } }