diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8b8c873e33..54056d757d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -668,6 +668,8 @@ phutil_register_library_map(array( 'DrydockManagementWaitForLeaseWorkflow' => 'applications/drydock/management/DrydockManagementWaitForLeaseWorkflow.php', 'DrydockManagementWorkflow' => 'applications/drydock/management/DrydockManagementWorkflow.php', 'DrydockPHIDTypeBlueprint' => 'applications/drydock/phid/DrydockPHIDTypeBlueprint.php', + 'DrydockPHIDTypeLease' => 'applications/drydock/phid/DrydockPHIDTypeLease.php', + 'DrydockPHIDTypeResource' => 'applications/drydock/phid/DrydockPHIDTypeResource.php', 'DrydockPreallocatedHostBlueprintImplementation' => 'applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php', 'DrydockResource' => 'applications/drydock/storage/DrydockResource.php', 'DrydockResourceCloseController' => 'applications/drydock/controller/DrydockResourceCloseController.php', @@ -3074,6 +3076,8 @@ phutil_register_library_map(array( 'DrydockManagementWaitForLeaseWorkflow' => 'DrydockManagementWorkflow', 'DrydockManagementWorkflow' => 'PhutilArgumentWorkflow', 'DrydockPHIDTypeBlueprint' => 'PhabricatorPHIDType', + 'DrydockPHIDTypeLease' => 'PhabricatorPHIDType', + 'DrydockPHIDTypeResource' => 'PhabricatorPHIDType', 'DrydockPreallocatedHostBlueprintImplementation' => 'DrydockBlueprintImplementation', 'DrydockResource' => array( diff --git a/src/applications/drydock/phid/DrydockPHIDTypeBlueprint.php b/src/applications/drydock/phid/DrydockPHIDTypeBlueprint.php index f9c5dc1559..22b074285e 100644 --- a/src/applications/drydock/phid/DrydockPHIDTypeBlueprint.php +++ b/src/applications/drydock/phid/DrydockPHIDTypeBlueprint.php @@ -29,6 +29,12 @@ final class DrydockPHIDTypeBlueprint extends PhabricatorPHIDType { array $handles, array $objects) { + foreach ($handles as $phid => $handle) { + $blueprint = $objects[$phid]; + $id = $blueprint->getID(); + + $handle->setURI("/drydock/blueprint/{$id}/"); + } } } diff --git a/src/applications/drydock/phid/DrydockPHIDTypeLease.php b/src/applications/drydock/phid/DrydockPHIDTypeLease.php new file mode 100644 index 0000000000..f3f34be0c7 --- /dev/null +++ b/src/applications/drydock/phid/DrydockPHIDTypeLease.php @@ -0,0 +1,40 @@ +withPHIDs($phids); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + + foreach ($handles as $phid => $handle) { + $lease = $objects[$phid]; + $id = $lease->getID(); + + $handle->setURI("/drydock/lease/{$id}/"); + } + } + +} diff --git a/src/applications/drydock/phid/DrydockPHIDTypeResource.php b/src/applications/drydock/phid/DrydockPHIDTypeResource.php new file mode 100644 index 0000000000..f6bc00f689 --- /dev/null +++ b/src/applications/drydock/phid/DrydockPHIDTypeResource.php @@ -0,0 +1,40 @@ +withPHIDs($phids); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + + foreach ($handles as $phid => $handle) { + $resource = $objects[$phid]; + $id = $resource->getID(); + + $handle->setURI("/drydock/resource/{$id}/"); + } + } + +} diff --git a/src/applications/drydock/query/DrydockBlueprintQuery.php b/src/applications/drydock/query/DrydockBlueprintQuery.php index 95eb935bc8..066677f6bf 100644 --- a/src/applications/drydock/query/DrydockBlueprintQuery.php +++ b/src/applications/drydock/query/DrydockBlueprintQuery.php @@ -34,7 +34,7 @@ final class DrydockBlueprintQuery DrydockBlueprintImplementation::getAllBlueprintImplementations(); foreach ($blueprints as $blueprint) { - if (array_key_exists($implementations, $blueprint->getClassName())) { + if (array_key_exists($blueprint->getClassName(), $implementations)) { $blueprint->attachImplementation( $implementations[$blueprint->getClassName()]); } diff --git a/src/applications/drydock/query/DrydockLeaseQuery.php b/src/applications/drydock/query/DrydockLeaseQuery.php index bec50630ee..4220fa0547 100644 --- a/src/applications/drydock/query/DrydockLeaseQuery.php +++ b/src/applications/drydock/query/DrydockLeaseQuery.php @@ -4,6 +4,7 @@ final class DrydockLeaseQuery extends PhabricatorCursorPagedPolicyAwareQuery { private $ids; + private $phids; private $resourceIDs; private $statuses; @@ -12,6 +13,11 @@ final class DrydockLeaseQuery return $this; } + public function withPHIDs(array $phids) { + $this->phids = $phids; + return $this; + } + public function withResourceIDs(array $ids) { $this->resourceIDs = $ids; return $this; @@ -73,6 +79,13 @@ final class DrydockLeaseQuery $this->ids); } + if ($this->phids) { + $where[] = qsprintf( + $conn_r, + 'phid IN (%Ls)', + $this->phids); + } + if ($this->statuses) { $where[] = qsprintf( $conn_r, diff --git a/src/applications/drydock/query/DrydockResourceQuery.php b/src/applications/drydock/query/DrydockResourceQuery.php index e5f57c8024..c3c5a280fb 100644 --- a/src/applications/drydock/query/DrydockResourceQuery.php +++ b/src/applications/drydock/query/DrydockResourceQuery.php @@ -4,6 +4,7 @@ final class DrydockResourceQuery extends PhabricatorCursorPagedPolicyAwareQuery { private $ids; + private $phids; private $statuses; private $types; private $blueprintPHIDs; @@ -13,6 +14,11 @@ final class DrydockResourceQuery return $this; } + public function withPHIDs(array $phids) { + $this->phids = $phids; + return $this; + } + public function withTypes(array $types) { $this->types = $types; return $this; @@ -55,6 +61,13 @@ final class DrydockResourceQuery $this->ids); } + if ($this->phids) { + $where[] = qsprintf( + $conn_r, + 'phid IN (%Ls)', + $this->phids); + } + if ($this->types) { $where[] = qsprintf( $conn_r, diff --git a/src/applications/drydock/storage/DrydockBlueprint.php b/src/applications/drydock/storage/DrydockBlueprint.php index 3649f25c95..06f2375563 100644 --- a/src/applications/drydock/storage/DrydockBlueprint.php +++ b/src/applications/drydock/storage/DrydockBlueprint.php @@ -9,6 +9,8 @@ final class DrydockBlueprint extends DrydockDAO protected $editPolicy; protected $details; + private $implementation = self::ATTACHABLE; + public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, @@ -34,6 +36,12 @@ final class DrydockBlueprint extends DrydockDAO return id(new $class())->attachInstance($this); } + public function attachImplementation(DrydockBlueprintImplementation $impl) { + $this->implementation = $impl; + return $this; + } + + /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/drydock/storage/DrydockLease.php b/src/applications/drydock/storage/DrydockLease.php index fdaac35e9f..b984dd07a6 100644 --- a/src/applications/drydock/storage/DrydockLease.php +++ b/src/applications/drydock/storage/DrydockLease.php @@ -56,8 +56,7 @@ final class DrydockLease extends DrydockDAO } public function generatePHID() { - return PhabricatorPHID::generateNewPHID( - PhabricatorPHIDConstants::PHID_TYPE_DRYL); + return PhabricatorPHID::generateNewPHID(DrydockPHIDTypeLease::TYPECONST); } public function getInterface($type) { diff --git a/src/applications/drydock/storage/DrydockResource.php b/src/applications/drydock/storage/DrydockResource.php index 87e7f7dc9a..bb9b9ebdb5 100644 --- a/src/applications/drydock/storage/DrydockResource.php +++ b/src/applications/drydock/storage/DrydockResource.php @@ -27,8 +27,7 @@ final class DrydockResource extends DrydockDAO } public function generatePHID() { - return PhabricatorPHID::generateNewPHID( - PhabricatorPHIDConstants::PHID_TYPE_DRYR); + return PhabricatorPHID::generateNewPHID(DrydockPHIDTypeResource::TYPECONST); } public function getAttribute($key, $default = null) { diff --git a/src/applications/phid/PhabricatorPHIDConstants.php b/src/applications/phid/PhabricatorPHIDConstants.php index 4acb6d7562..ca53e365b9 100644 --- a/src/applications/phid/PhabricatorPHIDConstants.php +++ b/src/applications/phid/PhabricatorPHIDConstants.php @@ -7,8 +7,6 @@ final class PhabricatorPHIDConstants { const PHID_TYPE_MAGIC = '!!!!'; const PHID_TYPE_STRY = 'STRY'; const PHID_TYPE_ACMT = 'ACMT'; - const PHID_TYPE_DRYR = 'DRYR'; - const PHID_TYPE_DRYL = 'DRYL'; const PHID_TYPE_OASC = 'OASC'; const PHID_TYPE_OASA = 'OASA'; const PHID_TYPE_TOBJ = 'TOBJ';