예제 #1
0
 /**
  * Update value of Custom Field with scope='design' for a given Test case
  *
  * @param struct $args
  * @param string $args["devKey"]: used to check if operation can be done.
  *                                if devKey is not valid => abort.
  *
  * @param string $args["testcaseexternalid"]:  
  * @param string $args["version"]: version number  
  * @param string $args["testprojectid"]: 
  * @param string $args["customfields"] - optional
  *               contains an map with key:Custom Field Name, value: value for CF.
  *               VERY IMPORTANT: value must be formatted in the way it's written to db,
  *               this is important for types like:
  *
  *               DATE: strtotime()
  *               DATETIME: mktime()
  *               MULTISELECTION LIST / CHECKBOX / RADIO: se multipli selezione ! come separatore
  *
  *
  *               these custom fields must be configured to be writte during execution.
  *               If custom field do not meet condition value will not be written
  *
  * @return mixed null if everything ok, else array of IXR_Error objects
  *         
  * @access public
  */
 public function updateTestCaseCustomFieldDesignValue($args)
 {
     $msg_prefix = "(" . __FUNCTION__ . ") - ";
     $this->_setArgs($args);
     $checkFunctions = array('authenticate', 'checkTestProjectID', 'checkTestCaseIdentity', 'checkTestCaseVersionNumber');
     $status_ok = $this->_runChecks($checkFunctions, $msg_prefix);
     if ($status_ok) {
         if (!$this->_isParamPresent(self::$customFieldsParamName)) {
             $status_ok = false;
             $msg = sprintf(MISSING_REQUIRED_PARAMETER_STR, self::$customFieldsParamName);
             $this->errors[] = new IXR_Error(MISSING_REQUIRED_PARAMETER, $msg);
         }
     }
     if ($status_ok) {
         // now check if custom fields are ok
         // For each custom field need to check if:
         // 1. is linked to test project
         // 2. is available for test case at design time
         $cfieldMgr = new cfield_mgr($this->dbObj);
         // Just ENABLED
         $linkedSet = $cfieldMgr->get_linked_cfields_at_design($this->args[self::$testProjectIDParamName], cfield_mgr::ENABLED, null, 'testcase', null, 'name');
         if (is_null($linkedSet)) {
             $status_ok = false;
             $msg = NO_CUSTOMFIELDS_DT_LINKED_TO_TESTCASES_STR;
             $this->errors[] = new IXR_Error(NO_CUSTOMFIELDS_DT_LINKED_TO_TESTCASES, $msg);
         }
     }
     if ($status_ok) {
         $accessVersionBy['number'] = $this->args[self::$versionNumberParamName];
         $nodeInfo = $this->tcaseMgr->get_basic_info($this->args[self::$testCaseIDParamName], $accessVersionBy);
         $cfSet = $args[self::$customFieldsParamName];
         foreach ($cfSet as $cfName => $cfValue) {
             // $accessKey = "custom_field_" . $item['id'] . <field_type_id>_<cfield_id>
             //  design_values_to_db($hash,$node_id,$cf_map=null,$hash_type=null)
             $item = $linkedSet[$cfName];
             $accessKey = "custom_field_" . $item['type'] . '_' . $item['id'];
             $hash[$accessKey] = $cfValue;
             $cfieldMgr->design_values_to_db($hash, $nodeInfo[0]['tcversion_id']);
         }
     } else {
         return $this->errors;
     }
 }
 /**
  * Update value of Custom Field with scope='design' 
  * for a given Test Suite
  *
  * @param struct $args
  * @param string $args["devKey"]: used to check if operation can be done.
  *                                if devKey is not valid => abort.
  *
  * @param string $args["testsuiteid"]:  
  * @param string $args["testprojectid"]: 
  * @param string $args["customfields"]
  *               contains an map with key:Custom Field Name, value: value for CF.
  *               VERY IMPORTANT: value must be formatted in the way it's written to db,
  *               this is important for types like:
  *
  *               DATE: strtotime()
  *               DATETIME: mktime()
  *               MULTISELECTION LIST / CHECKBOX / RADIO: se multipli selezione ! come separatore
  *
  *
  *               these custom fields must be configured to be writte during execution.
  *               If custom field do not meet condition value will not be written
  *
  * @return mixed null if everything ok, else array of IXR_Error objects
  *         
  * @access public
  */
 public function updateTestSuiteCustomFieldDesignValue($args)
 {
     $msg_prefix = "(" . __FUNCTION__ . ") - ";
     $this->_setArgs($args);
     $checkFunctions = array('authenticate', 'checkTestProjectID', 'checkTestSuiteID');
     $status_ok = $this->_runChecks($checkFunctions, $msg_prefix);
     if ($status_ok) {
         if (!$this->_isParamPresent(self::$customFieldsParamName)) {
             $status_ok = false;
             $msg = sprintf(MISSING_REQUIRED_PARAMETER_STR, self::$customFieldsParamName);
             $this->errors[] = new IXR_Error(MISSING_REQUIRED_PARAMETER, $msg);
         }
     }
     if ($status_ok) {
         // now check if custom fields are ok
         // For each custom field need to check if:
         // 1. is linked to test project
         // 2. is available for Test Suite at design time
         $cfieldMgr = new cfield_mgr($this->dbObj);
         // Just ENABLED
         $linkedSet = $cfieldMgr->get_linked_cfields_at_design($this->args[self::$testProjectIDParamName], cfield_mgr::ENABLED, null, 'testsuite', null, 'name');
         if (is_null($linkedSet)) {
             $status_ok = false;
             $msg = NO_CUSTOMFIELDS_DT_LINKED_TO_TESTSUITES_STR;
             $this->errors[] = new IXR_Error(NO_CUSTOMFIELDS_DT_LINKED_TO_TESTSUITES, $msg);
         }
     }
     if ($status_ok) {
         $cfSet = $args[self::$customFieldsParamName];
         foreach ($cfSet as $cfName => $cfValue) {
             // $accessKey = "custom_field_" . $item['id'] . <field_type_id>_<cfield_id>
             //  design_values_to_db($hash,$node_id,$cf_map=null,$hash_type=null)
             //
             // Simple check: if name is not present on set => ignore
             if (isset($linkedSet[$cfName])) {
                 $item = $linkedSet[$cfName];
                 $accessKey = "custom_field_" . $item['type'] . '_' . $item['id'];
                 $hash[$accessKey] = $cfValue;
                 $cfieldMgr->design_values_to_db($hash, $itemID);
                 $ret[] = array('status' => 'ok', 'msg' => 'Custom Field:' . $cfName . ' processed ');
             } else {
                 $ret[] = array('status' => 'ko', 'msg' => 'Custom Field:' . $cfName . ' skipped ');
             }
             return $ret;
         }
     } else {
         return $this->errors;
     }
 }
예제 #3
0
function writeCustomFieldsToDB(&$db, $tprojectID, $tsuiteID, &$hash)
{
    $ENABLED = 1;
    $NO_FILTERS = null;
    $cfield_mgr = new cfield_mgr($db);
    $cf_map = $cfield_mgr->get_linked_cfields_at_design($tprojectID, $ENABLED, $NO_FILTERS, 'testsuite');
    $cfield_mgr->design_values_to_db($hash, $tsuiteID, $cf_map);
}
예제 #4
0
$glue_char = config_get('gui_title_separator_1');
$charset = config_get('charset');
$req_cfg = config_get('req_cfg');
$date_format_cfg = config_get('date_format');
$week_short = lang_get('calendar_week_short');
$time_format_cfg = config_get('timestamp_format');
$coverage_enabled = $req_cfg->expected_coverage_management;
$relations_enabled = $req_cfg->relations->enable;
$gui->reqIDs = $tproject_mgr->get_all_requirement_ids($args->tproject_id);
if (count($gui->reqIDs) > 0) {
    // get type and status labels
    $type_labels = init_labels($req_cfg->type_labels);
    $status_labels = init_labels($req_cfg->status_labels);
    $labels2get = array('no' => 'No', 'yes' => 'Yes', 'not_aplicable' => null, 'req_spec_short' => null, 'title' => null, 'version' => null, 'th_coverage' => null, 'frozen' => null, 'type' => null, 'status' => null, 'th_relations' => null, 'requirements' => null, 'number_of_reqs' => null, 'number_of_versions' => null);
    $labels = init_labels($labels2get);
    $gui->cfields4req = (array) $cfield_mgr->get_linked_cfields_at_design($args->tproject_id, 1, null, 'requirement', null, 'name');
    $version_option = $args->all_versions ? requirement_mgr::ALL_VERSIONS : requirement_mgr::LATEST_VERSION;
    // array to gather table data row per row
    $rows = array();
    foreach ($gui->reqIDs as $id) {
        // now get the rest of information for this requirement
        $req = $req_mgr->get_by_id($id, $version_option);
        // coverage data
        $tc_coverage = count($req_mgr->get_coverage($id));
        // number of relations, if feature is enabled
        if ($relations_enabled) {
            $relations = $req_mgr->count_relations($id);
            $relations = "<!-- " . sprintf("%010d", $relations) . " -->" . $relations;
        }
        // create the link to display
        $title = htmlentities($req[0]['req_doc_id'], ENT_QUOTES, $charset) . $glue_char . htmlentities($req[0]['title'], ENT_QUOTES, $charset);