@@ -7578,6 +7578,105 @@ public function updateTestSuiteCustomFieldDesignValue($args)
75787578 }
75797579 }
75807580
7581+ /**
7582+ * Update value of Custom Field with scope='design'
7583+ * for a given Build
7584+ *
7585+ * @param struct $args
7586+ * @param string $args["devKey"]: used to check if operation can be done.
7587+ * if devKey is not valid => abort.
7588+ *
7589+ * @param string $args["buildid"]:
7590+ * @param string $args["testprojectid"]:
7591+ * @param string $args["customfields"]
7592+ * contains an map with key:Custom Field Name, value: value for CF.
7593+ * VERY IMPORTANT: value must be formatted in the way it's written to db,
7594+ * this is important for types like:
7595+ *
7596+ * DATE: strtotime()
7597+ * DATETIME: mktime()
7598+ * MULTISELECTION LIST / CHECKBOX / RADIO: se multipli selezione ! come separatore
7599+ *
7600+ *
7601+ * these custom fields must be configured to be writte during execution.
7602+ * If custom field do not meet condition value will not be written
7603+ *
7604+ * @return mixed null if everything ok, else array of IXR_Error objects
7605+ *
7606+ * @access public
7607+ */
7608+ public function updateBuildCustomFieldsValues ($ args )
7609+ {
7610+ $ msg_prefix ="( " .__FUNCTION__ . ") - " ;
7611+ $ this ->_setArgs ($ args );
7612+
7613+ $ checkFunctions = array ('authenticate ' ,'checkTestProjectID ' , 'checkBuildID ' );
7614+ $ status_ok = $ this ->_runChecks ($ checkFunctions ,$ msg_prefix );
7615+
7616+ if ( $ status_ok )
7617+ {
7618+ if (!$ this ->_isParamPresent (self ::$ customFieldsParamName ) )
7619+ {
7620+ $ status_ok = false ;
7621+ $ msg = sprintf (MISSING_REQUIRED_PARAMETER_STR ,self ::$ customFieldsParamName );
7622+ $ this ->errors [] = new IXR_Error (MISSING_REQUIRED_PARAMETER , $ msg );
7623+ }
7624+ }
7625+
7626+ if ( $ status_ok )
7627+ {
7628+ // now check if custom fields are ok
7629+ // For each custom field need to check if:
7630+ // 1. is linked to test project
7631+ // 2. is available for Build at design time
7632+ $ cfieldMgr = new cfield_mgr ($ this ->dbObj );
7633+
7634+ // Just ENABLED
7635+ $ linkedSet = $ cfieldMgr ->get_linked_cfields_at_design ($ this ->args [self ::$ testProjectIDParamName ],
7636+ cfield_mgr::ENABLED ,null ,'build ' ,null ,'name ' );
7637+ if ( is_null ($ linkedSet ) )
7638+ {
7639+ $ status_ok = false ;
7640+ $ msg = NO_CUSTOMFIELDS_DT_LINKED_TO_BUILDS_STR ;
7641+ $ this ->errors [] = new IXR_Error (NO_CUSTOMFIELDS_DT_LINKED_TO_BUILDS , $ msg );
7642+ }
7643+ }
7644+
7645+ if ( $ status_ok )
7646+ {
7647+ $ cfSet = $ args [self ::$ customFieldsParamName ];
7648+ $ ret = array ();
7649+ foreach ($ cfSet as $ cfName => $ cfValue )
7650+ {
7651+ // $accessKey = "custom_field_" . $item['id'] . <field_type_id>_<cfield_id>
7652+ // design_values_to_db($hash,$node_id,$cf_map=null,$hash_type=null)
7653+ //
7654+ // Simple check: if name is not present on set => ignore
7655+ if ( isset ($ linkedSet [$ cfName ]) )
7656+ {
7657+ $ item = $ linkedSet [$ cfName ];
7658+ $ accessKey = "custom_field_ " . $ item ['type ' ] . '_ ' . $ item ['id ' ];
7659+ $ hash [$ accessKey ] = $ cfValue ;
7660+ $ cfieldMgr ->design_values_to_db ($ hash ,$ args [self ::$ buildIDParamName ],null ,null ,'build ' );
7661+ // Add the result for each custom field to the returned array
7662+ array_push ($ ret , array ('status ' => 'ok ' ,
7663+ 'msg ' => 'Custom Field: ' . $ cfName . ' processed ' ));
7664+ }
7665+ else
7666+ {
7667+ array_push ($ ret , array ('status ' => 'ko ' ,
7668+ 'msg ' => 'Custom Field: ' . $ cfName . ' skipped ' ));
7669+ }
7670+ }
7671+ // Return the result after all of the fields have been processed
7672+ return $ ret ;
7673+ }
7674+ else
7675+ {
7676+ return $ this ->errors ;
7677+ }
7678+ }
7679+
75817680 /**
75827681 * Returns all test suites inside target
75837682 * test project with target name
@@ -7815,6 +7914,7 @@ function initMethodYellowPages()
78157914 'tl.addTestCaseKeywords ' => 'this:addTestCaseKeywords ' ,
78167915 'tl.removeTestCaseKeywords ' => 'this:removeTestCaseKeywords ' ,
78177916 'tl.updateTestSuiteCustomFieldDesignValue ' => 'this:updateTestSuiteCustomFieldDesignValue ' ,
7917+ 'tl.updateBuildCustomFieldsValues ' => 'this:updateBuildCustomFieldsValues ' ,
78187918 'tl.getTestSuite ' => 'this:getTestSuite ' ,
78197919 'tl.updateTestSuite ' => 'this:updateTestSuite ' ,
78207920 'tl.checkDevKey ' => 'this:checkDevKey ' ,
0 commit comments