Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/storage/NuanceItemCommand.php
<?php | <?php | ||||
final class NuanceItemCommand | final class NuanceItemCommand | ||||
extends NuanceDAO | extends NuanceDAO | ||||
implements PhabricatorPolicyInterface { | implements PhabricatorPolicyInterface { | ||||
const STATUS_ISSUED = 'issued'; | |||||
const STATUS_EXECUTING = 'executing'; | |||||
const STATUS_DONE = 'done'; | |||||
const STATUS_FAILED = 'failed'; | |||||
protected $itemPHID; | protected $itemPHID; | ||||
protected $authorPHID; | protected $authorPHID; | ||||
protected $queuePHID; | |||||
protected $command; | protected $command; | ||||
protected $parameters; | protected $status; | ||||
protected $parameters = array(); | |||||
public static function initializeNewCommand() { | public static function initializeNewCommand() { | ||||
return new self(); | return id(new self()) | ||||
->setStatus(self::STATUS_ISSUED); | |||||
} | } | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_TIMESTAMPS => false, | |||||
self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
'parameters' => self::SERIALIZATION_JSON, | 'parameters' => self::SERIALIZATION_JSON, | ||||
), | ), | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'command' => 'text64', | 'command' => 'text64', | ||||
'status' => 'text64', | |||||
'queuePHID' => 'phid?', | |||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'key_item' => array( | 'key_pending' => array( | ||||
'columns' => array('itemPHID'), | 'columns' => array('itemPHID', 'status'), | ||||
), | ), | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public static function getStatusMap() { | |||||
return array( | |||||
self::STATUS_ISSUED => array( | |||||
'name' => pht('Issued'), | |||||
'icon' => 'fa-clock-o', | |||||
'color' => 'bluegrey', | |||||
), | |||||
self::STATUS_EXECUTING => array( | |||||
'name' => pht('Executing'), | |||||
'icon' => 'fa-play', | |||||
'color' => 'green', | |||||
), | |||||
self::STATUS_DONE => array( | |||||
'name' => pht('Done'), | |||||
'icon' => 'fa-check', | |||||
'color' => 'blue', | |||||
), | |||||
self::STATUS_FAILED => array( | |||||
'name' => pht('Failed'), | |||||
'icon' => 'fa-times', | |||||
'color' => 'red', | |||||
), | |||||
); | |||||
} | |||||
private function getStatusSpec() { | |||||
$map = self::getStatusMap(); | |||||
return idx($map, $this->getStatus(), array()); | |||||
} | |||||
public function getStatusIcon() { | |||||
$spec = $this->getStatusSpec(); | |||||
return idx($spec, 'icon', 'fa-question'); | |||||
} | |||||
public function getStatusColor() { | |||||
$spec = $this->getStatusSpec(); | |||||
return idx($spec, 'color', 'indigo'); | |||||
} | |||||
public function getStatusName() { | |||||
$spec = $this->getStatusSpec(); | |||||
return idx($spec, 'name', $this->getStatus()); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
); | ); | ||||
Show All 11 Lines |