0

I am trying to extract requirements from QC Requirement module. i could extract all requirements of a QC project but i would like to extract selected requirements only. So i need to give folder path and extract requirements accordingly. Currently i use ReqFactory to extract Reqs from QC. Could you please help me or give me idea to extract requirmeents from selected folder path.

I tried Req Path and father id, but still it does not fulfill my need as some may have multiple sub folders under parent folders.

GlennV
  • 3,471
  • 4
  • 26
  • 39
Srekk
  • 136
  • 5
  • 15

1 Answers1

2

I assume you like to get all the child requirements of a requirement using the OTA API? The only solution I can offer is a bit clumsy. First you have to get the requirement where you want to start, e.g. "Requirements\Projects\ProjectX". How to achieve that is described in the OTA API Reference as an example of the ReqFactory object ("Find a specified requirement in a specified folder"). Or it is posted in this forum. If you know the ID of the start-requirement you can simply get the requirement with req_factory.Item(id).

When you have your requirement where you want to start, you can use the Find-method of the ReqFactory to get all its children, resp. all Requirement objects starting with the same path as the start-requirement. Here is an example-method in Ruby:

def list_all_child_requirements(start_req)
  req_factory = @tdc.ReqFactory
  req_path_strange_format = start_req.Field("RQ_REQ_PATH")
  child_req_list = req_factory.Find(start_req.ID, "RQ_REQ_PATH", req_path_strange_format, 8)
  child_req_list.each do |list_req|
    puts list_req
  end
end

The req_path_strange_format contains a String in the strange Quality Center notation like "AAAAAB". The Find-method starts from the start-requirement and searches all requirements which path starts with the same path as the path of the start-requirement. The parameter 8 means "starts with pattern" (described in the API Reference, Enum tagTDAPI_REQMODE). I just don't know how to access the Enum using Ruby, thats why the magic 8 is used... The Find-method returns a list with format "ID,NAME". From there it should be no problem to extract the requirements.

Doing the same directly in QC with a VAPI-XP-TEST and VB looks like that:

TDOutput.Clear
Dim reqPathStrangeFormat
Set reqF = tdConnection.ReqFactory
Set startReq = reqF.Item(14) ' ID of parent requirement
reqPathStrangeFormat = startReq.Field("RQ_REQ_PATH")
TDOutput.Print reqPathStrangeFormat
Set childReqList = reqF.Find(startReq.ID, "RQ_REQ_PATH", reqPathStrangeFormat, TDREQMODE_FIND_START_WITH)
For Each childReq in childReqList
    TDOutput.Print childReq
Next

This code first prints some strange string "AAAAAB" or something similiar, then a list with "ID,NAME" of the requirements.

Roland
  • 1,220
  • 1
  • 14
  • 29
  • Hi Ronald, i see you answer most of my HP QC related questions. Thank you. When it comes to this question, i am using vbscript to extract requirements from QC. Since the example you provided is in Ruby, i am still analyzing it. – Srekk Mar 26 '14 at 06:22
  • I added some VB example code—maybe it is of some help. – Roland Mar 26 '14 at 12:10