HP 质量中心中的查找字段

发布于 2024-12-21 08:17:11 字数 243 浏览 1 评论 0原文

我通过开放测试架构 API 与 Quality Center 连接。

我想确定链接到查找表的错误字段的允许值。

这些可以通过标准前端的下拉菜单获得。

谢谢

编辑:更详细的解释

我们有一些字段只允许在其中放置特定值。

例如: NextAction 可以是以下之一{“1.指定”,“2.分析”,“3.设计”}

但我一直无法找到一种方法来以编程方式确定这些允许的值。

I am interfacing with Quality Centre via Open Test Architecture API.

I would like to determined the allowed values of bug Fields that are linked to a lookup table.

These are available via drop downs in the standard frontend.

Thanks

Edit: A more Detailed explanation

We have some fields which will only allow specific values to placed in them.

For example:
NextAction can be one of the following { "1. Specify", "2. Analysis", "3. Design" }

But I have been unable to find a way to determine these allowed values programmatically.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

懒的傷心 2024-12-28 08:17:11

使用 BugFactory 对象,您可以访问字段及其属性。这是从 OTA API 参考帮助文件中直接复制/粘贴 Visual Basic 的内容。如果您需要更多帮助,请尝试提供更有针对性的问题,例如您想要完成什么任务、哪些字段以及您想要使用哪种语言进行访问。

Public Sub CheckValidValue(Optional TableName As String = "BUG")
    Dim BugFact As BugFactory 
    Dim BugList As list 
    Dim aField As TDField 
    Dim fieldList As list 
    Dim rc, ErrCode As Long 
    Dim aBug As Bug 
    Dim msg$ 
    Dim okCnt%, noNodeCnt%, errorCnt%, unknownCnt% 
    Dim dataType As Long 

'------------------------------------------------ 
' User BugFactory.Fields to get a list of TDField 
' objects in the bug table. 
' This example uses the BugFactory, but this can 
' be done with any class that implements IBaseFactory 
    'tdc is the global TDConnection object. 
    Set BugFact = tdc.BugFactory 
    Set fieldList = BugFact.Fields 

'------------------------------------------ 
' Use List.Count to check how many items. 
    Debug.Print: Debug.Print 
    Debug.Print "There are " & fieldList.Count & _
        " fields in this table." 
    Debug.Print "----------------------------------" 
'Get any bug. To look at field attributes we 
' need a valid object and since this example is 
' not interested in the particular values of the object, 
' it doesn't matter which bug. 
    Set BugList = BugFact.NewList("") 
    Set aBug = BugList(0) 

'Walk through the list 
    For Each aField In fieldList 

        With aField 
        'Quit when we have enough for this example 
        If InStr(aField.Name, "BG_USER_10") > 0 Then Exit For 

        ' For the DataTypeString() code, 
        ' see example "Convert data types to string" 
        Debug.Print .Name & ", " & .Property & ", Data type is " _
            & DataTypeString(.Type) 
        On Error Resume Next 
'---------------------------------------------------- 
'Use TDField.IsValidValue to confirm that a value can 
'be used for a field. 
' Get the correct data type and check validity of an 
' arbitrary value. 
' Save the error code immediately after IsValidValue call 
' before another call can change the err object. 
        dataType = aField.Type 
        Select Case dataType 
            Case TDOLE_LONG, TDOLE_ULONG 
                aField.IsValidValue 5, aBug 
                ErrCode = err.Number 
            Case TDOLE_FLOAT 
                aField.IsValidValue 5.5, aBug 
                ErrCode = err.Number 
            Case TDOLE_STRING 
                aField.IsValidValue "Joe", aBug 
                ErrCode = err.Number 
            Case Else 
            'These will be errors: 
                aField.IsValidValue _
                    "String to non-string value", aBug 
                ErrCode = err.Number 

        End Select 

'Output an error code message 
        If ErrCode = 0 Then 'S_OK 
            msg = "Valid Value" 
            okCnt = okCnt + 1 
        Else 
             rc = ErrCode - vbObjectError 
             Select Case rc 
                Case FIELD_E_VERIFIED 
                    msg = "Error: Invalid value for field" 
                    errorCnt = errorCnt + 1 
                Case TDOLE_NONODE 
                    msg = "Error: Field can not be set to this value" 
                    noNodeCnt = noNodeCnt + 1 
                Case Else 
                    msg = "Unrecognized error: " & rc _
                        & " , HRESULT = " & ErrCode 
                    unknownCnt = unknownCnt + 1 
            End Select 
        End If 
        Debug.Print vbTab & msg 
        ' 
        End With 'aField 
    Next aField 

    Debug.Print "----------------------------------" 
    Debug.Print "Number of fields with valid value = " & okCnt 
    Debug.Print "Number of fields with invalid type = " & errorCnt 
    Debug.Print "Number of fields with invalid value= " & noNodeCnt 
    Debug.Print "Number of fields with unknown error = " & unknownCnt 
    Debug.Print "----------------------------------" 
End Sub 

Using the BugFactory object you can access the fields and their attributes. This is a direct copy / paste of Visual Basic from the OTA API Reference help file. If you want more help, try providing a more focused question, such as what you're trying to accomplish, which fields, and which language you're trying to access with.

Public Sub CheckValidValue(Optional TableName As String = "BUG")
    Dim BugFact As BugFactory 
    Dim BugList As list 
    Dim aField As TDField 
    Dim fieldList As list 
    Dim rc, ErrCode As Long 
    Dim aBug As Bug 
    Dim msg$ 
    Dim okCnt%, noNodeCnt%, errorCnt%, unknownCnt% 
    Dim dataType As Long 

'------------------------------------------------ 
' User BugFactory.Fields to get a list of TDField 
' objects in the bug table. 
' This example uses the BugFactory, but this can 
' be done with any class that implements IBaseFactory 
    'tdc is the global TDConnection object. 
    Set BugFact = tdc.BugFactory 
    Set fieldList = BugFact.Fields 

'------------------------------------------ 
' Use List.Count to check how many items. 
    Debug.Print: Debug.Print 
    Debug.Print "There are " & fieldList.Count & _
        " fields in this table." 
    Debug.Print "----------------------------------" 
'Get any bug. To look at field attributes we 
' need a valid object and since this example is 
' not interested in the particular values of the object, 
' it doesn't matter which bug. 
    Set BugList = BugFact.NewList("") 
    Set aBug = BugList(0) 

'Walk through the list 
    For Each aField In fieldList 

        With aField 
        'Quit when we have enough for this example 
        If InStr(aField.Name, "BG_USER_10") > 0 Then Exit For 

        ' For the DataTypeString() code, 
        ' see example "Convert data types to string" 
        Debug.Print .Name & ", " & .Property & ", Data type is " _
            & DataTypeString(.Type) 
        On Error Resume Next 
'---------------------------------------------------- 
'Use TDField.IsValidValue to confirm that a value can 
'be used for a field. 
' Get the correct data type and check validity of an 
' arbitrary value. 
' Save the error code immediately after IsValidValue call 
' before another call can change the err object. 
        dataType = aField.Type 
        Select Case dataType 
            Case TDOLE_LONG, TDOLE_ULONG 
                aField.IsValidValue 5, aBug 
                ErrCode = err.Number 
            Case TDOLE_FLOAT 
                aField.IsValidValue 5.5, aBug 
                ErrCode = err.Number 
            Case TDOLE_STRING 
                aField.IsValidValue "Joe", aBug 
                ErrCode = err.Number 
            Case Else 
            'These will be errors: 
                aField.IsValidValue _
                    "String to non-string value", aBug 
                ErrCode = err.Number 

        End Select 

'Output an error code message 
        If ErrCode = 0 Then 'S_OK 
            msg = "Valid Value" 
            okCnt = okCnt + 1 
        Else 
             rc = ErrCode - vbObjectError 
             Select Case rc 
                Case FIELD_E_VERIFIED 
                    msg = "Error: Invalid value for field" 
                    errorCnt = errorCnt + 1 
                Case TDOLE_NONODE 
                    msg = "Error: Field can not be set to this value" 
                    noNodeCnt = noNodeCnt + 1 
                Case Else 
                    msg = "Unrecognized error: " & rc _
                        & " , HRESULT = " & ErrCode 
                    unknownCnt = unknownCnt + 1 
            End Select 
        End If 
        Debug.Print vbTab & msg 
        ' 
        End With 'aField 
    Next aField 

    Debug.Print "----------------------------------" 
    Debug.Print "Number of fields with valid value = " & okCnt 
    Debug.Print "Number of fields with invalid type = " & errorCnt 
    Debug.Print "Number of fields with invalid value= " & noNodeCnt 
    Debug.Print "Number of fields with unknown error = " & unknownCnt 
    Debug.Print "----------------------------------" 
End Sub 
晒暮凉 2024-12-28 08:17:11

您可以通过从“自定义”对象查找列表来完成此操作。这是我使用 ruby​​ 的方法:

qc = WIN32OLE.new('TDApiOle80.TDConnection')        
qcserver = 'http://testdirector/qcbin/'
qc.InitConnectionEx(qcserver)                      
qc.Login($username, $password)                       
qc.Connect("$domain", "$project")                  
customization = @qc.Customization
list = custom.Lists.List("NextAction")
node = list.RootNode
children = node.Children
children.each do |child| 
  puts "#{child.Name} \n"
end

You can do this by looking up the list from the 'Customization' object. Here's how I'd do it using ruby:

qc = WIN32OLE.new('TDApiOle80.TDConnection')        
qcserver = 'http://testdirector/qcbin/'
qc.InitConnectionEx(qcserver)                      
qc.Login($username, $password)                       
qc.Connect("$domain", "$project")                  
customization = @qc.Customization
list = custom.Lists.List("NextAction")
node = list.RootNode
children = node.Children
children.each do |child| 
  puts "#{child.Name} \n"
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文