![]() |
Telelogic SYNERGY (steve huntington) | ![]() |
Topic Title: trigger to move values from an IR to the parent SCR? Topic Summary: I need help on moving an attribute value from an IR to a parent SCR via triggers Created On: 13-Sep-2007 18:12 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: Hi Mark, The problem is that the ccm_relation attributes cannot be used like other text or string field attributes. You must query for the related objects instead of performing a getValue(). The queries use the functions is_relationname_of(subquery) or has_relationname(subquery). In this case you would use has_associated_ir to find the parent of the IR and is_associated_ir_of to find child IRs. The returned query results would have to be looped through. See below for an example.. | |
![]() |
|
I am using the DOORS to Change integration lifecyle, with some additions...
I have a value in the (child) IR that when set I want a trigger to fire and copy the value entered to the (parent) SCR. I am having issues getting from the IR to the SCR to set the value. # # # # # # use strict; #Make sure all variables are defined bef ore use. use ChangeSynergy::TriggerParser; #Used to parse the trigger XML file sent from ChangeSynergy. use ChangeSynergy::csapi; #Main module for the CS API. use ChangeSynergy::apiObjectData; use ChangeSynergy::apiObjectVector; #Create a new TriggerParser object, passing in the location of the trigger xml document. #The trigger xml document is always the last parameter. my $trigger = new ChangeSynergy::TriggerParser($ARGV[-1]); print "trigger: " . $trigger . " " . $@; #Get the problem number from the trigger. my $problem_number = $trigger->get_object_id(); #Create new csapi object print "problem: " . $problem_number . " " . $@; my $csapi = new ChangeSynergy::csapi(); my $problem; my $aUser; eval { #setup the connection $csapi->setUpConnection($trigger->get_protocol(), $trigger->get_host(),$trigger->get_port()); #create a user object $aUser = new ChangeSynergy::apiUser($trigger->get_user(), "password", $trigger->get_role(), $trigger->get_token(), $trigger->get_database()); #Do a show of the problem to get the available attributes. Resolver and Synopsis $problem = $csapi->AttributeModifyCRData($aUser, $problem_number); }; if($@) { print "Failed to show problem: " . $problem_number . " " . $@; exit 0; } my @scr; @scr = $problem->getDataObjectByName("has_associated_ir")->getValue(); print "scr = ", $scr, "\n"; my $dev_act_time; my $qa_act_time; my $doc_act_time; my $current_scr; my $ir_list; while (@scr) { $current_scr=process(shift @scr); $ir_list = $current_scr->getDataObjectByName("associated_ir"); my @current_ir; # reset values to 0 for this SCR $dev_act_time = 0; $qa_act_time = 0; $doc_act_time = 0; # walk ir list pulling values from actuals while (@ir_list) { $current_ir=process(shift @ir_list); $dev_act_time+=$current_ir->getDataObjectByName("ir_act_analysis_eff")->getValue(); $qa_act_time+=$current_ir->getDataObjectByName("ir_act_evaluation_eff")->getValue(); $doc_act_time+=$current_ir->getDataObjectByName("ir_act_resolution_eff")->getValue(); } # write act times to scr $current_scr->getDataObjectByName("act_analysis_eff")->setValue($dev_act_time); $current_scr->getDataObjectByName("act_evaluation_eff")->setValue($qa_act_time); $current_scr->getDataObjectByName("act_resolution_eff")->setValue($doc_act_time); my $modify = $csapi->ModifyCR($aUser, $current_scr); print "modify = ", $modify, "\n"; } |
|
![]() |
|
![]() |
|
Hi Mark,
The problem is that the ccm_relation attributes cannot be used like other text or string field attributes. You must query for the related objects instead of performing a getValue().
The queries use the functions is_relationname_of(subquery) or has_relationname(subquery). In this case you would use has_associated_ir to find the parent of the IR and is_associated_ir_of to find child IRs. The returned query results would have to be looped through. See below for an example..
Edited: 21-Sep-2007 at 17:21 by david dao |
|
![]() |
|
![]() |
|
Thanks,
That was just what I needed to know. Here is the script with the modifications for those that want a reference.... # # # # # # use strict; #Make sure all variables are defined before use. use ChangeSynergy::TriggerParser; #Used to parse the trigger XML file sent from ChangeSynergy. use ChangeSynergy::csapi; #Main module for the CS API. use ChangeSynergy::apiObjectData; use ChangeSynergy::apiObjectVector; #Create a new TriggerParser object, passing in the location of the trigger xml document. #The trigger xml document is always the last parameter. my $trigger = new ChangeSynergy::TriggerParser($ARGV[-1]); #print "trigger: " . $trigger . " " . $@; #Get the problem number from the trigger. my $problem_number = $trigger->get_object_id(); my $scrProblem_number; my $irProblem_number; #Create new csapi object #print "problem: " . $problem_number . " " . $@; my $csapi = new ChangeSynergy::csapi(); my $problem; my $aUser; eval { #setup the connection $csapi->setUpConnection($trigger->get_protocol(), $trigger->get_host(), $trigger->get_port()); #create a user object $aUser = new ChangeSynergy::apiUser($trigger->get_user(), "password", $trigger->get_role(), $trigger->get_token(), $trigger->get_database()); #Do a show of the problem to get the available attributes. Resolver and Synopsis $problem = $csapi->AttributeModifyCRData($aUser, $problem_number); }; if($@) { print "Failed to show problem: " . $problem_number . " " . $@; exit 0; } my $dev_act_time; my $qa_act_time; my $doc_act_time; #----------------------------- #Create a query string to find all has_associated_ir of the object that fired this trigger my $queryString = "(cvtype='problem') and (has_associated_ir(problem_number='$problem_number'))"; #print "\nproblem_number = ". $problem_number, "\n"; # call the api to get a querydata report results. my $data = $csapi->QueryData($aUser, "Basic Summary", $queryString, undef, undef, undef); #print "number of SCRs = ", $data->getDataSize(), "\n"; #For each returned object for(my $j = 0; $j < $data->getDataSize(); $j++) { #Get the object vector my $objVec = $data->getDataObject($j); #print "\nobjVec = ", $objVec, "\n"; # reset values to 0 for this SCR $dev_act_time = 0; $qa_act_time = 0; $doc_act_time = 0; my $scrChild = $objVec->getDataObjectByName("problem_number")->getValue( ); #print "\nscrChild = ", $scrChild, "\n"; my $modProblem = $csapi->AttributeModifyCRData($aUser, $scrChild); my $scrQueryString = "(cvtype='problem') and (is_associated_ir_of(proble m_number='$scrChild'))"; # call the api to get a querydata report results. my $scrData = $csapi->QueryData($aUser, "Basic Summary", $scrQueryString , undef, undef, undef); #print "scrData = ", $scrData, "\n"; #print "scrChild = ", $scrChild, "\n"; #print "number of IRs = ", $scrData->getDataSize(), "\n"; #For each returned object for(my $k = 0; $k < $scrData->getDataSize(); $k++) { my $irObjVec = $scrData->getDataObject($k); #Get the child's problem number my $irChild = $irObjVec->getDataObjectByName("problem_number")->getValue(); #print "irChild = ", $irChild, "\n"; my $irProblem = $csapi->AttributeModifyCRData($aUser, $irChild); $dev_act_time+=$irProblem->getDataObjectByName("ir_act_analysis_eff")->getValue(); #print "dev_act_time = ", $dev_act_time, "\n"; $qa_act_time+=$irProblem->getDataObjectByName("ir_act_evaluation_eff")->getValue(); #print "qa_act_time = ", $qa_act_time, "\n"; # $doc_act_time+=$irProblem->getDataObjectByName("ir_act_resolution_eff")->getValue(); #print "doc_act_time = ", $doc_act_time, "\n"; } # write act times to scr # print "modProblem = ", $modProblem. "\n"; $modProblem->getDataObjectByName("act_analysis_eff")->setValue($dev_act_time); $modProblem->getDataObjectByName("act_evaluation_eff")->setValue($qa_act_time); # $modProblem->getDataObjectByName("act_resolution_eff")->setValue($doc_act_time); my $modify = $csapi->ModifyCR($aUser, $modProblem); # print "modify = ", $modify, "\n"; } |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.