3 final class DrydockRepositoryOperationQuery
extends DrydockQuery
{
8 private $repositoryPHIDs;
9 private $operationStates;
10 private $operationTypes;
14 public function withIDs(array $ids) {
19 public function withPHIDs(array $phids) {
20 $this->phids
= $phids;
24 public function withObjectPHIDs(array $object_phids) {
25 $this->objectPHIDs
= $object_phids;
29 public function withRepositoryPHIDs(array $repository_phids) {
30 $this->repositoryPHIDs
= $repository_phids;
34 public function withOperationStates(array $states) {
35 $this->operationStates
= $states;
39 public function withOperationTypes(array $types) {
40 $this->operationTypes
= $types;
44 public function withIsDismissed($dismissed) {
45 $this->isDismissed
= $dismissed;
49 public function withAuthorPHIDs(array $phids) {
50 $this->authorPHIDs
= $phids;
54 public function newResultObject() {
55 return new DrydockRepositoryOperation();
58 protected function loadPage() {
59 return $this->loadStandardPage($this->newResultObject());
62 protected function willFilterPage(array $operations) {
63 $implementations = DrydockRepositoryOperationType
::getAllOperationTypes();
65 $viewer = $this->getViewer();
67 foreach ($operations as $key => $operation) {
68 $impl = idx($implementations, $operation->getOperationType());
70 $this->didRejectResult($operation);
71 unset($operations[$key]);
74 $impl = id(clone $impl)
76 ->setOperation($operation);
78 $operation->attachImplementation($impl);
81 $repository_phids = mpull($operations, 'getRepositoryPHID');
82 if ($repository_phids) {
83 $repositories = id(new PhabricatorRepositoryQuery())
84 ->setViewer($this->getViewer())
85 ->setParentQuery($this)
86 ->withPHIDs($repository_phids)
88 $repositories = mpull($repositories, null, 'getPHID');
90 $repositories = array();
93 foreach ($operations as $key => $operation) {
94 $repository = idx($repositories, $operation->getRepositoryPHID());
96 $this->didRejectResult($operation);
97 unset($operations[$key]);
100 $operation->attachRepository($repository);
106 protected function didFilterPage(array $operations) {
107 $object_phids = mpull($operations, 'getObjectPHID');
109 $objects = id(new PhabricatorObjectQuery())
110 ->setViewer($this->getViewer())
111 ->setParentQuery($this)
112 ->withPHIDs($object_phids)
114 $objects = mpull($objects, null, 'getPHID');
119 foreach ($operations as $key => $operation) {
120 $object = idx($objects, $operation->getObjectPHID());
121 $operation->attachObject($object);
127 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
128 $where = parent
::buildWhereClauseParts($conn);
130 if ($this->ids
!== null) {
137 if ($this->phids
!== null) {
144 if ($this->objectPHIDs
!== null) {
147 'objectPHID IN (%Ls)',
151 if ($this->repositoryPHIDs
!== null) {
154 'repositoryPHID IN (%Ls)',
155 $this->repositoryPHIDs
);
158 if ($this->operationStates
!== null) {
161 'operationState IN (%Ls)',
162 $this->operationStates
);
165 if ($this->operationTypes
!== null) {
168 'operationType IN (%Ls)',
169 $this->operationTypes
);
172 if ($this->isDismissed
!== null) {
176 (int)$this->isDismissed
);
179 if ($this->authorPHIDs
!== null) {
182 'authorPHID IN (%Ls)',