Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/storage/DrydockRepositoryOperation.php
Show All 19 Lines | final class DrydockRepositoryOperation extends DrydockDAO | ||||
protected $operationType; | protected $operationType; | ||||
protected $operationState; | protected $operationState; | ||||
protected $properties = array(); | protected $properties = array(); | ||||
protected $isDismissed; | protected $isDismissed; | ||||
private $repository = self::ATTACHABLE; | private $repository = self::ATTACHABLE; | ||||
private $object = self::ATTACHABLE; | private $object = self::ATTACHABLE; | ||||
private $implementation = self::ATTACHABLE; | private $implementation = self::ATTACHABLE; | ||||
private $workingCopyLease = self::ATTACHABLE; | |||||
public static function initializeNewOperation( | public static function initializeNewOperation( | ||||
DrydockRepositoryOperationType $op) { | DrydockRepositoryOperationType $op) { | ||||
return id(new DrydockRepositoryOperation()) | return id(new DrydockRepositoryOperation()) | ||||
->setOperationState(self::STATE_WAIT) | ->setOperationState(self::STATE_WAIT) | ||||
->setOperationType($op->getOperationConstant()) | ->setOperationType($op->getOperationConstant()) | ||||
->setIsDismissed(0); | ->setIsDismissed(0); | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | public function attachImplementation(DrydockRepositoryOperationType $impl) { | ||||
$this->implementation = $impl; | $this->implementation = $impl; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getImplementation() { | public function getImplementation() { | ||||
return $this->implementation; | return $this->implementation; | ||||
} | } | ||||
public function getWorkingCopyLease() { | |||||
return $this->assertAttached($this->workingCopyLease); | |||||
} | |||||
public function attachWorkingCopyLease(DrydockLease $lease) { | |||||
$this->workingCopyLease = $lease; | |||||
return $this; | |||||
} | |||||
public function hasWorkingCopyLease() { | |||||
return ($this->workingCopyLease !== self::ATTACHABLE); | |||||
} | |||||
public function getProperty($key, $default = null) { | public function getProperty($key, $default = null) { | ||||
return idx($this->properties, $key, $default); | return idx($this->properties, $key, $default); | ||||
} | } | ||||
public function setProperty($key, $value) { | public function setProperty($key, $value) { | ||||
$this->properties[$key] = $value; | $this->properties[$key] = $value; | ||||
return $this; | return $this; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | final class DrydockRepositoryOperation extends DrydockDAO | ||||
public function setCommandError(array $error) { | public function setCommandError(array $error) { | ||||
return $this->setProperty('exec.workingcopy.error', $error); | return $this->setProperty('exec.workingcopy.error', $error); | ||||
} | } | ||||
public function getCommandError() { | public function getCommandError() { | ||||
return $this->getProperty('exec.workingcopy.error'); | return $this->getProperty('exec.workingcopy.error'); | ||||
} | } | ||||
public function logEvent($type, array $data = array()) { | |||||
$log = id(new DrydockLog()) | |||||
->setEpoch(PhabricatorTime::getNow()) | |||||
->setType($type) | |||||
->setData($data); | |||||
$log->setOperationPHID($this->getPHID()); | |||||
if ($this->hasWorkingCopyLease()) { | |||||
$lease = $this->getWorkingCopyLease(); | |||||
$log->setLeasePHID($lease->getPHID()); | |||||
$resource_phid = $lease->getResourcePHID(); | |||||
if ($resource_phid) { | |||||
$resource = $lease->getResource(); | |||||
$log->setResourcePHID($resource->getPHID()); | |||||
$log->setBlueprintPHID($resource->getBlueprintPHID()); | |||||
} | |||||
} | |||||
return $log->save(); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
Show All 38 Lines |