Skip to content
Permalink
Browse files

feature: 0008728: Build - add attributes specific for Versioning Systems

  • Loading branch information...
fmancardi committed Jul 27, 2019
1 parent 4f46d40 commit eaff21b8f7a5d5b2ed3b56c9efc0e1c3e2c73166
@@ -12,7 +12,7 @@ Purpose: smarty template - Add new build and show existing
s="warning,warning_empty_build_name,enter_build,enter_build_notes,active,
open,builds_description,cancel,release_date,closure_date,closed_on_date,
copy_tester_assignments, assignment_source_build,show_event_history,
show_calender,clear_date,with_exec_status"}
show_calender,clear_date,with_exec_status,commit_id,branch,tag,release_candidate"}

{include file="inc_head.tpl" openHead="yes" jsValidate="yes" editorType=$gui->editorType}
{include file="inc_ext_js.tpl" bResetEXTCss=1}
@@ -110,7 +110,38 @@ function validateForm(f)
</td>
</tr>

<tr>
<th style="background:none;">{$labels.commit_id}</th>
<td><input type="text" name="commit_id" id="commit_id"
maxlength="64"
value="{$gui->commit_id|escape}" size="64"/>
</td>
</tr>

<tr>
<th style="background:none;">{$labels.tag}</th>
<td><input type="text" name="tag" id="tag"
maxlength="64"
value="{$gui->tag|escape}" size="64"/>
</td>
</tr>

<tr>
<th style="background:none;">{$labels.branch}</th>
<td><input type="text" name="branch" id="branch"
maxlength="64"
value="{$gui->branch|escape}" size="64"/>
</td>
</tr>

<tr>
<th style="background:none;">{$labels.release_candidate}</th>
<td><input type="text"
name="release_candidate" id="release_candidate"
maxlength="100"
value="{$gui->release_candidate|escape}" size="100"/>
</td>
</tr>

{* show this only if we create a new build and there are other builds to copy from *}
{if !$gui->build_id && $gui->source_build.build_count}
@@ -10,6 +10,13 @@
-- since 1.9.20
INSERT INTO /*prefix*/rights (id,description) VALUES (55,'testproject_add_remove_keywords_executed_tcversions');

--
ALTER TABLE /*prefix*/builds ADD COLUMN commit_id varchar(64) NULL;
ALTER TABLE /*prefix*/builds ADD COLUMN tag varchar(64) NULL;
ALTER TABLE /*prefix*/builds ADD COLUMN branch varchar(64) NULL;
ALTER TABLE /*prefix*/builds ADD COLUMN release_candidate varchar(100) NULL;


CREATE TABLE /*prefix*/testcase_platforms (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
testcase_id int(10) unsigned NOT NULL DEFAULT '0',
@@ -85,6 +85,10 @@ CREATE TABLE /*prefix*/builds (
`creation_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`release_date` date NULL,
`closed_on_date` date NULL,
`commit_id` varchar(64) NULL,
`tag` varchar(64) NULL,
`branch` varchar(64) NULL,
`release_candidate` varchar(100)
PRIMARY KEY (`id`),
UNIQUE KEY /*prefix*/name (`testplan_id`,`name`),
KEY /*prefix*/testplan_id (`testplan_id`)
@@ -745,9 +745,11 @@ public function createBuild() {
// Default Right
$request = $this->app->request();
$item = json_decode($request->getBody());
$statusOK = true;
if( null == $item ) {
$this->byeHTTP500();
}
// Get mandatory inputs
$statusOK = true;
$build = new stdClass();
$reqProps = array('testplan','name');
@@ -772,6 +774,7 @@ public function createBuild() {
$statusOK = false;
$op['details'][] =
sprintf($this->l10n['API_TESTPLAN_ID_DOES_NOT_EXIST'],$item->testplan);
$this->app->status(404);
}
} else {
$tplanAPIKey = trim($item->testplan);
@@ -780,6 +783,7 @@ public function createBuild() {
$statusOK = false;
$op['details'][] =
sprintf($this->l10n['API_TESTPLAN_APIKEY_DOES_NOT_EXIST'],$item->testplan);
$this->app->status(404);
}
}
}
@@ -819,14 +823,40 @@ public function createBuild() {
// Step 2 - Finally Create It!!
if( $statusOK ) {
// key 2 check with default value is parameter is missing
$k2check = array('active' => 1, 'is_open' => 1,
'releasedate' => null, 'notes' => null,
$k2check = array('is_open' => 1,
'release_candidate' => null,
'notes' => null,
'commit_id' => null, 'tag' => null,
'branch' => null,
'is_active' => 1,'active' => 1,
'releasedate' => null,'release_date' => null,
'copy_testers_from_build' => null,
'copytestersfrombuild' => null);
$buildProp = array('tplan_id' => 'tplan_id',
'release_date' => 'release_date',
'releasedate' => 'release_date',
'active' => 'is_active',
'is_active' => 'is_active',
'notes' => 'notes',
'commit_id' => 'commit_id',
'tag' => 'tag', 'branch' => 'branch',
'release_candidate' =>'release_candidate',
'is_open' => 'is_open',
'copytestersfrombuild' =>
'copytestersfrombuild',
'copy_testers_from_build' =>
'copytestersfrombuild');
$skipKey = array();
foreach( $k2check as $key => $value ) {
$build->$key = $value;
if( property_exists($item, $key) ) {
$build->$key = $item->$key;
$translate = $buildProp[$key];
if( !isset($skipKey[$translate]) ) {
$build->$translate = $value;
if( property_exists($item, $key) ) {
$build->$translate = $item->$key;
$skipKey[$translate] = true;
}
}
}
@@ -1153,9 +1183,12 @@ public function updateBuild($id) {
// Default Right
$request = $this->app->request();
$item = json_decode($request->getBody());
$statusOK = true;
if( null == $item ) {
$this->byeHTTP500();
}
// Get mandatory inputs
$statusOK = true;
if( intval($id) <= 0 ) {
$op['details'][] = $this->l10n['API_MISSING_REQUIRED_PROP'] .
'id - the build ID';
@@ -1208,10 +1241,59 @@ public function updateBuild($id) {
// Step 2 - Finally Update It!!
if( $statusOK ) {
$k2check = array('is_open', 'name',
'release_candidate',
'notes','commit_id','tag',
'branch','is_active','active',
'releasedate','release_date',
'copy_testers_from_build',
'copytestersfrombuild');
$buildProp = array('name' => 'name',
'tplan_id' => 'tplan_id',
'release_date' => 'release_date',
'releasedate' => 'release_date',
'active' => 'is_active',
'is_active' => 'is_active',
'notes' => 'notes',
'commit_id' => 'commit_id',
'tag' => 'tag', 'branch' => 'branch',
'release_candidate' =>'release_candidate',
'is_open' => 'is_open',
'copytestersfrombuild' =>
'copytestersfrombuild',
'copy_testers_from_build' =>
'copytestersfrombuild');
$skipKey = array();
$buildObj = new stdClass();
$attr = array();
foreach( $k2check as $key ) {
$translate = $buildProp[$key];
if( !isset($skipKey[$translate]) ) {
// init with value got from DB.
if( isset($build[$translate]) ) {
$buildObj->$translate = $build[$translate];
}
if( property_exists($item, $key) ) {
$buildObj->$translate = $item->$key;
$skipKey[$translate] = true;
}
if( property_exists($buildObj, $translate) ) {
$attr[$translate] = $buildObj->$translate;
}
}
}
// key 2 check
// $id,$name,$notes,$active=null,$open=null,
// $release_date='',$closed_on_date='') {
/*
$k2check = array('name','notes','active','is_open',
'release_date');
@@ -1222,8 +1304,13 @@ public function updateBuild($id) {
$$key = $build[$key];
}
}
$ox = $this->buildMgr->update($id,$name,
$notes,$active,$is_open,$release_date);
*/
$ox = $this->buildMgr->update($build['id'],
$buildObj->name,$buildObj->notes,$attr);
if( $ox ) {
$op = array('status' => 'ok', 'message' => 'ok',
'details' => array(), 'id' => $id);
@@ -1249,5 +1336,18 @@ public function updateBuild($id) {
echo json_encode($op);
}
/**
*
*/
function byeHTTP500($msg=null) {
$op = array();
if( null == $msg ) {
$msg = 'TestLink Fatal Error - Malformed Request Body - ' .
' json_decode() issue';
}
$op['details'][] = sprintf($msg);
$this->app->status(500);
echo json_encode($op);
exit(); // Bye!
}
} // class end

0 comments on commit eaff21b

Please sign in to comment.
You can’t perform that action at this time.