Skip to content
Permalink
Browse files

TICKET 7545: Requirement Monitoring - Bulk Operations (from Req Spec …

…View Screen)
  • Loading branch information...
fmancardi committed May 14, 2016
1 parent e8c8cd2 commit f35102cd69a1b87206d38f1b19f0f6feffc665e2
@@ -9,7 +9,7 @@ TestLink Open Source Project - http://testlink.sourceforge.net/
req_select_create_tc,btn_import_req_spec,btn_import_reqs,
btn_export_reqs,btn_edit_spec,btn_delete_spec,btn_print_view,
btn_show_direct_link,btn_copy_requirements,btn_copy_req_spec,
req_spec_operations, req_operations, btn_freeze_req_spec,btn_new_revision,btn_view_history'}
req_spec_operations, req_operations, btn_freeze_req_spec,btn_new_revision,btn_view_history,btn_bulk_mon'}

{$cfg_section=$smarty.template|basename|replace:".tpl":"" }
{config_load file="input_dimensions.conf" section=$cfg_section}
@@ -91,11 +91,15 @@ TestLink Open Source Project - http://testlink.sourceforge.net/
onclick="location='{$req_create_from_issue_xml_url}'" />

{if $gui->requirements_count > 0}
<input type="button" name="create_tcases" value="{$labels.req_select_create_tc}"
onclick="location='{$req_create_tc_url}'" />
<input type="button" name="create_tcases"
value="{$labels.req_select_create_tc}" onclick="location='{$req_create_tc_url}'" />

<input type="button" name="copy_req" value="{$labels.btn_copy_requirements}"
onclick="location='{$req_spec_copy_req_url}'" />
<input type="button" name="copy_req" value="{$labels.btn_copy_requirements}"
onclick="location='{$req_spec_copy_req_url}'" />

<input type="button" name="bulk_mon" value="{$labels.btn_bulk_mon}"
onclick="location='{$req_spec_bulk_req_mon_url}'" />

{/if}
{/if}

@@ -55,6 +55,9 @@ Purpose: view a requirement specification
{$url_args="reqCreateFromIssueMantisXML.php?scope=branch&req_spec_id="}
{$req_create_from_issue_xml_url="$basehref$req_module$url_args$reqSpecID"}

{$url_args="reqSpecEdit.php?doAction=bulkReqMon&req_spec_id="}
{$req_spec_bulk_req_mon_url="$basehref$req_module$url_args$reqSpecID"}


{* used on inc_btn_reqSpecView.tpl *}
{lang_get s='warning_delete_req_spec' var="warning_msg" }
@@ -156,7 +156,8 @@ function get_by_id($id,$version_id=self::ALL_VERSIONS,$version_number=1,$options
$my['options'] = array('order_by' => " ORDER BY REQV.version DESC ",
'output_format' => 'array', 'renderImageInline' => false);
'output_format' => 'array', 'renderImageInline' => false,
'decodeUsers' => true, 'outputLevel' => 'std');
$my['options'] = array_merge($my['options'], (array)$options);
@@ -210,7 +211,8 @@ function get_by_id($id,$version_id=self::ALL_VERSIONS,$version_number=1,$options
}
// added -1 AS revision_id to make some process easier
$sql = " /* $debugMsg */ SELECT REQ.id,REQ.srs_id,REQ.req_doc_id," .
/*
$sql = " SELECT REQ.id,REQ.srs_id,REQ.req_doc_id," .
" REQV.scope,REQV.status,REQV.type,REQV.active," .
" REQV.is_open,REQV.author_id,REQV.version,REQV.id AS version_id," .
" REQV.expected_coverage,REQV.creation_ts,REQV.modifier_id," .
@@ -224,9 +226,36 @@ function get_by_id($id,$version_id=self::ALL_VERSIONS,$version_number=1,$options
" JOIN {$this->tables['req_specs']} REQ_SPEC ON REQ_SPEC.id = REQ.srs_id " .
" JOIN {$this->tables['nodes_hierarchy']} NH_RSPEC ON NH_RSPEC.id = REQ_SPEC.id " .
$where_clause . $filter_clause . $my['options']['order_by'];
*/
switch($my['options']['outputLevel'])
{
case 'minimal':
$outf = " /* $debugMsg */ SELECT REQ.id,REQ.req_doc_id,NH_REQ.name AS title ";
break;
case 'std':
default:
$outf = " /* $debugMsg */ SELECT REQ.id,REQ.srs_id,REQ.req_doc_id," .
" REQV.scope,REQV.status,REQV.type,REQV.active," .
" REQV.is_open,REQV.author_id,REQV.version,REQV.id AS version_id," .
" REQV.expected_coverage,REQV.creation_ts,REQV.modifier_id," .
" REQV.modification_ts,REQV.revision, -1 AS revision_id, " .
" NH_REQ.name AS title, REQ_SPEC.testproject_id, " .
" NH_RSPEC.name AS req_spec_title, REQ_SPEC.doc_id AS req_spec_doc_id, NH_REQ.node_order ";
break;
}
// added -1 AS revision_id to make some process easier
$sql = $outf .
" FROM {$this->object_table} REQ " .
" JOIN {$this->tables['nodes_hierarchy']} NH_REQ ON NH_REQ.id = REQ.id " .
" JOIN {$this->tables['nodes_hierarchy']} NH_REQV ON NH_REQV.parent_id = NH_REQ.id ".
" JOIN {$this->tables['req_versions']} REQV ON REQV.id = NH_REQV.id " .
" JOIN {$this->tables['req_specs']} REQ_SPEC ON REQ_SPEC.id = REQ.srs_id " .
" JOIN {$this->tables['nodes_hierarchy']} NH_RSPEC ON NH_RSPEC.id = REQ_SPEC.id " .
$where_clause . $filter_clause . $my['options']['order_by'];
// echo $sql;
$decodeUserMode = 'simple';
if ($version_id != self::LATEST_VERSION)
{
@@ -265,11 +294,6 @@ function get_by_id($id,$version_id=self::ALL_VERSIONS,$version_number=1,$options
}
$rs = null;
// echo 'IN::' . __FUNCTION__ . '<br>';
// new dBug($recordset);
// 20141130 - inline images
if(!is_null($recordset) && $my['options']['renderImageInline'])
{
$k2l = array_keys($recordset);
@@ -280,12 +304,9 @@ function get_by_id($id,$version_id=self::ALL_VERSIONS,$version_number=1,$options
reset($recordset);
}
if(!is_null($recordset))
$rs = $recordset;
if(!is_null($recordset) && $my['options']['decodeUsers'])
{
// Decode users
$rs = $recordset;
switch ($decodeUserMode)
{
case 'complex':
@@ -4172,10 +4193,16 @@ function monitorOff($req_id,$user_id=null,$tproject_id=null)
/**
*
*/
function getMonitoredByUser($user_id,$tproject_id)
function getMonitoredByUser($user_id,$tproject_id,$opt=null,$filters=null)
{
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
$my['opt'] = array('reqSpecID' => null);
$my['filters'] = array();
$my['opt'] = array_merge($my['opt'],(array)$opt);
$my['filters'] = array_merge($my['opt'],(array)$filters);
// simple checks
$safe = array();
$safe['user_id'] = intval($user_id);
@@ -4190,18 +4217,36 @@ function getMonitoredByUser($user_id,$tproject_id)
}
$rs = null;
try
if( is_null($my['opt']['reqSpecID']) )
{
$sql = "/* $debugMsg */ " .
" SELECT * FROM {$this->tables['req_monitor']} " .
" WHERE user_id = {$safe['user_id']} " .
" AND testproject_id = {$safe['tproject_id']}";
" SELECT RQM.* FROM {$this->tables['req_monitor']} RQM " .
" WHERE RQM.user_id = {$safe['user_id']} " .
" AND RQM.testproject_id = {$safe['tproject_id']}";
}
else
{
$sql = "/* $debugMsg */ " .
" SELECT RQM.* FROM {$this->tables['req_monitor']} RQM " .
" JOIN {$this->tables['nodes_hierarchy']} NH_REQ " .
" ON NH_REQ.id = RQM.req_id " .
" WHERE RQM.user_id = {$safe['user_id']} " .
" AND RQM.testproject_id = {$safe['tproject_id']} " .
" AND NH_REQ.parent_id = " . intval($my['opt']['reqSpecID']);
}
try
{
$rs = $this->db->fetchRowsIntoMap($sql,'req_id');
}
catch (Exception $e)
{
echo $e->getMessage();
}
return $rs;
}
@@ -4217,8 +4262,6 @@ function getReqMonitors($req_id,$opt=null)
$options = array('tproject_id' => 0, 'output' => 'map');
$options = array_merge($options,(array)$opt);
//\Kint::dump($options);
// simple checks
$safe = array();
$safe['req_id'] = intval($req_id);
@@ -4265,8 +4308,6 @@ function notifyMonitors($req_id,$action,$user_id,$log_msg=null)
// who is monitoring?
$iuSet = $this->getReqMonitors($safe['req_id']);
// \Kint::dump($iuSet);
if( is_null($iuSet) )
{
return;
@@ -4277,8 +4318,6 @@ function notifyMonitors($req_id,$action,$user_id,$log_msg=null)
$user = new tlUser($this->db);
}
//\Kint::dump($iuSet);
//die();
$author = $user->getNames($this->db,$user_id);
$author = $author[$user_id];
$idCard = $author['login'] .
@@ -4315,8 +4354,6 @@ function notifyMonitors($req_id,$action,$user_id,$log_msg=null)
$subj['target'] = array_keys($trf);
$subj['values'] = array_values($trf);
// \Kint::dump($iuSet);
foreach($iuSet as $ue)
{
if( !isset($mailBodyCache[$ue['locale']]) )
@@ -597,7 +597,8 @@ function get_requirements($id, $range = 'all', $testcase_id = null, $options=nul
{
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
$my['options'] = array( 'order_by' => " ORDER BY NH_REQ.node_order,NH_REQ.name,REQ.req_doc_id",
'output' => 'standard');
'output' => 'standard', 'outputLevel' => 'std', 'decodeUsers' => true);
$my['options'] = array_merge($my['options'], (array)$options);
// null => do not filter
@@ -655,11 +656,18 @@ function get_requirements($id, $range = 'all', $testcase_id = null, $options=nul
$latestVersionSet = $this->db->fetchRowsIntoMap($sql,'version_id');
$reqVersionSet = array_keys($latestVersionSet);
/*
$getOptions = null;
if( !is_null($my['options']['order_by']) )
{
$getOptions = array('order_by' => $my['options']['order_by']);
}
*/
$getOptions['order_by'] = $my['options']['order_by'];
$getOptions['outputLevel'] = $my['options']['outputLevel'];
$getOptions['decodeUsers'] = $my['options']['decodeUsers'];
$rs = $this->req_mgr->get_by_id($reqSet,$reqVersionSet,null,$getOptions,$my['filters']);
switch($my['options']['output'])

0 comments on commit f35102c

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