diff --git a/resources/sql/autopatches/20150617.harbor.1.lint.sql b/resources/sql/autopatches/20150617.harbor.1.lint.sql new file mode 100644 index 0000000000..ff23386509 --- /dev/null +++ b/resources/sql/autopatches/20150617.harbor.1.lint.sql @@ -0,0 +1,14 @@ +CREATE TABLE {$NAMESPACE}_harbormaster.harbormaster_buildlintmessage ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + buildTargetPHID VARBINARY(64) NOT NULL, + path LONGTEXT NOT NULL, + line INT UNSIGNED, + characterOffset INT UNSIGNED, + code VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL, + severity VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL, + name VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL, + properties LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, + dateCreated INT UNSIGNED NOT NULL, + dateModified INT UNSIGNED NOT NULL, + KEY `key_target` (buildTargetPHID) +) ENGINE=INNODB, COLLATE {$COLLATE_TEXT}; diff --git a/resources/sql/autopatches/20150617.harbor.2.unit.sql b/resources/sql/autopatches/20150617.harbor.2.unit.sql new file mode 100644 index 0000000000..3140947652 --- /dev/null +++ b/resources/sql/autopatches/20150617.harbor.2.unit.sql @@ -0,0 +1,13 @@ +CREATE TABLE {$NAMESPACE}_harbormaster.harbormaster_buildunitmessage ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + buildTargetPHID VARBINARY(64) NOT NULL, + engine VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL, + namespace VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL, + name VARCHAR(255) COLLATE {$COLLATE_TEXT} NOT NULL, + result VARCHAR(32) COLLATE {$COLLATE_TEXT} NOT NULL, + duration DOUBLE, + properties LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL, + dateCreated INT UNSIGNED NOT NULL, + dateModified INT UNSIGNED NOT NULL, + KEY `key_target` (buildTargetPHID) +) ENGINE=INNODB, COLLATE {$COLLATE_TEXT}; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3454bae920..a449b84b28 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -833,9 +833,7 @@ phutil_register_library_map(array( 'HarbormasterBuildEngine' => 'applications/harbormaster/engine/HarbormasterBuildEngine.php', 'HarbormasterBuildFailureException' => 'applications/harbormaster/exception/HarbormasterBuildFailureException.php', 'HarbormasterBuildGraph' => 'applications/harbormaster/engine/HarbormasterBuildGraph.php', - 'HarbormasterBuildItem' => 'applications/harbormaster/storage/build/HarbormasterBuildItem.php', - 'HarbormasterBuildItemPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildItemPHIDType.php', - 'HarbormasterBuildItemQuery' => 'applications/harbormaster/query/HarbormasterBuildItemQuery.php', + 'HarbormasterBuildLintMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php', 'HarbormasterBuildLog' => 'applications/harbormaster/storage/build/HarbormasterBuildLog.php', 'HarbormasterBuildLogPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildLogPHIDType.php', 'HarbormasterBuildLogQuery' => 'applications/harbormaster/query/HarbormasterBuildLogQuery.php', @@ -867,6 +865,7 @@ phutil_register_library_map(array( 'HarbormasterBuildTransaction' => 'applications/harbormaster/storage/HarbormasterBuildTransaction.php', 'HarbormasterBuildTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php', 'HarbormasterBuildTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildTransactionQuery.php', + 'HarbormasterBuildUnitMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php', 'HarbormasterBuildViewController' => 'applications/harbormaster/controller/HarbormasterBuildViewController.php', 'HarbormasterBuildWorker' => 'applications/harbormaster/worker/HarbormasterBuildWorker.php', 'HarbormasterBuildable' => 'applications/harbormaster/storage/HarbormasterBuildable.php', @@ -4253,9 +4252,7 @@ phutil_register_library_map(array( 'HarbormasterBuildEngine' => 'Phobject', 'HarbormasterBuildFailureException' => 'Exception', 'HarbormasterBuildGraph' => 'AbstractDirectedGraph', - 'HarbormasterBuildItem' => 'HarbormasterDAO', - 'HarbormasterBuildItemPHIDType' => 'PhabricatorPHIDType', - 'HarbormasterBuildItemQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', + 'HarbormasterBuildLintMessage' => 'HarbormasterDAO', 'HarbormasterBuildLog' => array( 'HarbormasterDAO', 'PhabricatorPolicyInterface', @@ -4309,6 +4306,7 @@ phutil_register_library_map(array( 'HarbormasterBuildTransaction' => 'PhabricatorApplicationTransaction', 'HarbormasterBuildTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 'HarbormasterBuildTransactionQuery' => 'PhabricatorApplicationTransactionQuery', + 'HarbormasterBuildUnitMessage' => 'HarbormasterDAO', 'HarbormasterBuildViewController' => 'HarbormasterController', 'HarbormasterBuildWorker' => 'HarbormasterWorker', 'HarbormasterBuildable' => array( diff --git a/src/applications/harbormaster/phid/HarbormasterBuildItemPHIDType.php b/src/applications/harbormaster/phid/HarbormasterBuildItemPHIDType.php deleted file mode 100644 index 08c657fe56..0000000000 --- a/src/applications/harbormaster/phid/HarbormasterBuildItemPHIDType.php +++ /dev/null @@ -1,33 +0,0 @@ -withPHIDs($phids); - } - - public function loadHandles( - PhabricatorHandleQuery $query, - array $handles, - array $objects) { - - foreach ($handles as $phid => $handle) { - $build_item = $objects[$phid]; - } - } - -} diff --git a/src/applications/harbormaster/query/HarbormasterBuildItemQuery.php b/src/applications/harbormaster/query/HarbormasterBuildItemQuery.php deleted file mode 100644 index 1c54cf1fa7..0000000000 --- a/src/applications/harbormaster/query/HarbormasterBuildItemQuery.php +++ /dev/null @@ -1,60 +0,0 @@ -ids = $ids; - return $this; - } - - public function withPHIDs(array $phids) { - $this->phids = $phids; - return $this; - } - - protected function loadPage() { - $table = new HarbormasterBuildItem(); - $conn_r = $table->establishConnection('r'); - - $data = queryfx_all( - $conn_r, - 'SELECT * FROM %T %Q %Q %Q', - $table->getTableName(), - $this->buildWhereClause($conn_r), - $this->buildOrderClause($conn_r), - $this->buildLimitClause($conn_r)); - - return $table->loadAllFromArray($data); - } - - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { - $where = array(); - - if ($this->ids) { - $where[] = qsprintf( - $conn_r, - 'id IN (%Ld)', - $this->ids); - } - - if ($this->phids) { - $where[] = qsprintf( - $conn_r, - 'phid in (%Ls)', - $this->phids); - } - - $where[] = $this->buildPagingClause($conn_r); - - return $this->formatWhereClause($where); - } - - public function getQueryApplicationClass() { - return 'PhabricatorHarbormasterApplication'; - } - -} diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildItem.php b/src/applications/harbormaster/storage/build/HarbormasterBuildItem.php deleted file mode 100644 index 0d3ce7fcad..0000000000 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildItem.php +++ /dev/null @@ -1,19 +0,0 @@ - true, - self::CONFIG_NO_TABLE => true, - ) + parent::getConfiguration(); - } - - public function generatePHID() { - return PhabricatorPHID::generateNewPHID( - HarbormasterBuildItemPHIDType::TYPECONST); - } - -} diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php new file mode 100644 index 0000000000..27b0948af7 --- /dev/null +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php @@ -0,0 +1,98 @@ +setBuildTargetPHID($build_target->getPHID()); + } + + public static function newFromDictionary( + HarbormasterBuildTarget $build_target, + array $dict) { + + $obj = self::initializeNewLintMessage($build_target); + + $spec = array( + 'path' => 'string', + 'line' => 'optional int', + 'char' => 'optional int', + 'code' => 'string', + 'severity' => 'string', + 'name' => 'string', + 'description' => 'optional string', + ); + + // We're just going to ignore extra keys for now, to make it easier to + // add stuff here later on. + $dict = array_select_keys($dict, array_keys($spec)); + PhutilTypeSpec::checkMap($dict, $spec); + + $obj->setPath($dict['path']); + $obj->setLine(idx($dict, 'line')); + $obj->setCharacterOffset(idx($dict, 'char')); + $obj->setCode($dict['code']); + $obj->setSeverity($dict['severity']); + $obj->setName($dict['name']); + + $description = idx($dict, 'description'); + if (strlen($description)) { + $obj->setProperty('description', $description); + } + + return $obj; + } + + protected function getConfiguration() { + return array( + self::CONFIG_SERIALIZATION => array( + 'properties' => self::SERIALIZATION_JSON, + ), + self::CONFIG_COLUMN_SCHEMA => array( + 'path' => 'text', + 'line' => 'uint32?', + 'characterOffset' => 'uint32?', + 'code' => 'text32', + 'severity' => 'text32', + 'name' => 'text255', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_target' => array( + 'columns' => array('buildTargetPHID'), + ), + ), + ) + parent::getConfiguration(); + } + + public function attachBuildTarget(HarbormasterBuildTarget $build_target) { + $this->buildTarget = $build_target; + return $this; + } + + public function getBuildTarget() { + return $this->assertAttached($this->buildTarget); + } + + public function getProperty($key, $default = null) { + return idx($this->properties, $key, $default); + } + + public function setProperty($key, $value) { + $this->properties[$key] = $value; + return $this; + } + +} diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php b/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php new file mode 100644 index 0000000000..d21fc2f718 --- /dev/null +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php @@ -0,0 +1,100 @@ +setBuildTargetPHID($build_target->getPHID()); + } + + public static function newFromDictionary( + HarbormasterBuildTarget $build_target, + array $dict) { + + $obj = self::initializeNewUnitMessage($build_target); + + $spec = array( + 'engine' => 'optional string', + 'namespace' => 'optional string', + 'name' => 'string', + 'result' => 'string', + 'duration' => 'optional float', + 'path' => 'optional string', + 'coverage' => 'optional string', + ); + + // We're just going to ignore extra keys for now, to make it easier to + // add stuff here later on. + $dict = array_select_keys($dict, array_keys($spec)); + PhutilTypeSpec::checkMap($dict, $spec); + + $obj->setEngine(idx($dict, 'engine', '')); + $obj->setNamespace(idx($dict, 'namespace', '')); + $obj->setName($dict['name']); + $obj->setResult($dict['result']); + $obj->setDuration(idx($dict, 'duration')); + + $path = idx($dict, 'path'); + if (strlen($path)) { + $obj->setProperty('path', $path); + } + + $coverage = idx($dict, 'coverage'); + if (strlen($coverage)) { + $obj->setProperty('coverage', $coverage); + } + + return $obj; + } + + protected function getConfiguration() { + return array( + self::CONFIG_SERIALIZATION => array( + 'properties' => self::SERIALIZATION_JSON, + ), + self::CONFIG_COLUMN_SCHEMA => array( + 'engine' => 'text255', + 'namespace' => 'text255', + 'name' => 'text255', + 'result' => 'text32', + 'duration' => 'double?', + ), + self::CONFIG_KEY_SCHEMA => array( + 'key_target' => array( + 'columns' => array('buildTargetPHID'), + ), + ), + ) + parent::getConfiguration(); + } + + public function attachBuildTarget(HarbormasterBuildTarget $build_target) { + $this->buildTarget = $build_target; + return $this; + } + + public function getBuildTarget() { + return $this->assertAttached($this->buildTarget); + } + + public function getProperty($key, $default = null) { + return idx($this->properties, $key, $default); + } + + public function setProperty($key, $value) { + $this->properties[$key] = $value; + return $this; + } + +}