Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic SYNERGY (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by david dao, on Tuesday, September 25, 2007 11:01 PM

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..
 13-Sep-2007 18:12
User is offline View Users Profile Print this message


Mark Meredith

Posts: 7
Joined: 23-Mar-2004

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.

#
# perl rollup_actual_to_scr.pl reportName attributeName
# 4.3_sp1
# When a IR actual LOE is modified we total all of the IR actual times and put them in the SCR actual time values.
#

#


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";
}
Report this to a Moderator Report this to a Moderator
 21-Sep-2007 17:17
User is offline View Users Profile Print this message


david dao

Posts: 2
Joined: 21-Sep-2007

Answer 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..

Edited: 21-Sep-2007 at 17:21 by david dao
Report this to a Moderator Report this to a Moderator
 25-Sep-2007 23:01
User is offline View Users Profile Print this message


Mark Meredith

Posts: 7
Joined: 23-Mar-2004

Thanks,
That was just what I needed to know.
Here is the script with the modifications for those that want a reference....

#
# perl rollup_actual_to_scr.pl reportName attributeName
# 4.3_sp1
# When a IR actual LOE is modified we total all of the IR actual times and put them in the SCR actual time values.
#

#


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";
}
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic SYNERGY forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 15:34.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.