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 willFilterPage(array $operations) {
59 $implementations = DrydockRepositoryOperationType
::getAllOperationTypes();
61 $viewer = $this->getViewer();
63 foreach ($operations as $key => $operation) {
64 $impl = idx($implementations, $operation->getOperationType());
66 $this->didRejectResult($operation);
67 unset($operations[$key]);
70 $impl = id(clone $impl)
72 ->setOperation($operation);
74 $operation->attachImplementation($impl);
77 $repository_phids = mpull($operations, 'getRepositoryPHID');
78 if ($repository_phids) {
79 $repositories = id(new PhabricatorRepositoryQuery())
80 ->setViewer($this->getViewer())
81 ->setParentQuery($this)
82 ->withPHIDs($repository_phids)
84 $repositories = mpull($repositories, null, 'getPHID');
86 $repositories = array();
89 foreach ($operations as $key => $operation) {
90 $repository = idx($repositories, $operation->getRepositoryPHID());
92 $this->didRejectResult($operation);
93 unset($operations[$key]);
96 $operation->attachRepository($repository);
102 protected function didFilterPage(array $operations) {
103 $object_phids = mpull($operations, 'getObjectPHID');
105 $objects = id(new PhabricatorObjectQuery())
106 ->setViewer($this->getViewer())
107 ->setParentQuery($this)
108 ->withPHIDs($object_phids)
110 $objects = mpull($objects, null, 'getPHID');
115 foreach ($operations as $key => $operation) {
116 $object = idx($objects, $operation->getObjectPHID());
117 $operation->attachObject($object);
123 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
124 $where = parent
::buildWhereClauseParts($conn);
126 if ($this->ids
!== null) {
133 if ($this->phids
!== null) {
140 if ($this->objectPHIDs
!== null) {
143 'objectPHID IN (%Ls)',
147 if ($this->repositoryPHIDs
!== null) {
150 'repositoryPHID IN (%Ls)',
151 $this->repositoryPHIDs
);
154 if ($this->operationStates
!== null) {
157 'operationState IN (%Ls)',
158 $this->operationStates
);
161 if ($this->operationTypes
!== null) {
164 'operationType IN (%Ls)',
165 $this->operationTypes
);
168 if ($this->isDismissed
!== null) {
172 (int)$this->isDismissed
);
175 if ($this->authorPHIDs
!== null) {
178 'authorPHID IN (%Ls)',