Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/storage/DrydockLog.php
<?php | <?php | ||||
final class DrydockLog extends DrydockDAO | final class DrydockLog extends DrydockDAO | ||||
implements PhabricatorPolicyInterface { | implements PhabricatorPolicyInterface { | ||||
protected $blueprintPHID; | protected $blueprintPHID; | ||||
protected $resourcePHID; | protected $resourcePHID; | ||||
protected $leasePHID; | protected $leasePHID; | ||||
protected $operationPHID; | |||||
protected $epoch; | protected $epoch; | ||||
protected $type; | protected $type; | ||||
protected $data = array(); | protected $data = array(); | ||||
private $blueprint = self::ATTACHABLE; | private $blueprint = self::ATTACHABLE; | ||||
private $resource = self::ATTACHABLE; | private $resource = self::ATTACHABLE; | ||||
private $lease = self::ATTACHABLE; | private $lease = self::ATTACHABLE; | ||||
private $operation = self::ATTACHABLE; | |||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_TIMESTAMPS => false, | self::CONFIG_TIMESTAMPS => false, | ||||
self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
'data' => self::SERIALIZATION_JSON, | 'data' => self::SERIALIZATION_JSON, | ||||
), | ), | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'blueprintPHID' => 'phid?', | 'blueprintPHID' => 'phid?', | ||||
'resourcePHID' => 'phid?', | 'resourcePHID' => 'phid?', | ||||
'leasePHID' => 'phid?', | 'leasePHID' => 'phid?', | ||||
'operationPHID' => 'phid?', | |||||
'type' => 'text64', | 'type' => 'text64', | ||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'key_blueprint' => array( | 'key_blueprint' => array( | ||||
'columns' => array('blueprintPHID', 'type'), | 'columns' => array('blueprintPHID', 'type'), | ||||
), | ), | ||||
'key_resource' => array( | 'key_resource' => array( | ||||
'columns' => array('resourcePHID', 'type'), | 'columns' => array('resourcePHID', 'type'), | ||||
), | ), | ||||
'key_lease' => array( | 'key_lease' => array( | ||||
'columns' => array('leasePHID', 'type'), | 'columns' => array('leasePHID', 'type'), | ||||
), | ), | ||||
'key_operation' => array( | |||||
'columns' => array('operationPHID', 'type'), | |||||
), | |||||
'epoch' => array( | 'epoch' => array( | ||||
'columns' => array('epoch'), | 'columns' => array('epoch'), | ||||
), | ), | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function attachBlueprint(DrydockBlueprint $blueprint = null) { | public function attachBlueprint(DrydockBlueprint $blueprint = null) { | ||||
Show All 18 Lines | public function attachLease(DrydockLease $lease = null) { | ||||
$this->lease = $lease; | $this->lease = $lease; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getLease() { | public function getLease() { | ||||
return $this->assertAttached($this->lease); | return $this->assertAttached($this->lease); | ||||
} | } | ||||
public function attachOperation( | |||||
DrydockRepositoryOperation $operation = null) { | |||||
$this->operation = $operation; | |||||
return $this; | |||||
} | |||||
public function getOperation() { | |||||
return $this->assertAttached($this->operation); | |||||
} | |||||
public function isComplete() { | public function isComplete() { | ||||
if ($this->getBlueprintPHID() && !$this->getBlueprint()) { | if ($this->getBlueprintPHID() && !$this->getBlueprint()) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($this->getResourcePHID() && !$this->getResource()) { | if ($this->getResourcePHID() && !$this->getResource()) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($this->getLeasePHID() && !$this->getLease()) { | if ($this->getLeasePHID() && !$this->getLease()) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($this->getOperationPHID() && !$this->getOperation()) { | |||||
return false; | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
Show All 9 Lines | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
} | } | ||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | ||||
return false; | return false; | ||||
} | } | ||||
public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
return pht( | return pht( | ||||
'To view log details, you must be able to view the associated '. | 'To view log details, you must be able to view all associated '. | ||||
'blueprint, resource and lease.'); | 'blueprints, resources, leases, and repository operations.'); | ||||
} | } | ||||
} | } |