asfsd 发表于 2017-5-26 11:11:22

使用 IBM Rational RequisitePro 进行项目执行管理

学习如何使用 IBM® Rational RequisitePro® APIs 的项目执行管理特性。这些
API 的绝大多数都被包含在本文所描述的产品版本以及今后的版本中。  IBM Rational RequisitePro 帮助您管理您储存的项目。您可以使用本地客户端或者 Web 客户端提供的用户界面,并且可以通过所提供的
Rational RequisitePro API 来执行程序产生的任务。


对项目的独占访问

  项目管理人员必须获得对一个项目的独占访问(Exclusive Access)来执行项目结构的一些修正。项目管理人员必须获得对一个项目的独占访问来执行项目的这些行为:


[*]更改需求类型的前缀
[*]更改需求类型颜色和风格
[*]删除一个需求类型
[*]从一个需求类型中删除一个属性
[*]删除一个文档类型
  独占访问是一种安全条件,通过它一个项目和它的文档的更改权限可以只对打开这个项目的用户开放。当这个项目和它的文档没有对其它人开放时,您可以使用独占模式打开这个项目和它的文档。
  
列表 1. 创建一个项目


 




               

Dim a_sName As String

Dim a_sPath As String

Dim a_sDescription As String

Dim a_sTemplateName As String

Dim a_oProject As ReqPro40.Project

Dim a_oRPX As ReqPro40.Application


' Get an instance of the RPX object

Set a_oRPX = New ReqPro40.Application

' Name of the project

a_sName = "Project1"

' Path of the project

a_sPath = "C:\program files\rational\requisitepro\projects\"

& a_sName

' Description of the project

a_sDescription = "This is a new project. "

' Use the blank template

a_sTemplateName = vbNullString


' Create a new Project

a_oRPX.CreateProject _

a_sPath, _ ' Project Path

a_sName, _' Project name

a_sDescription, _' Project Description

a_sTemplateName, _' Project Template

eDBType_Access, _' Database Type

, _' User ID for Database

, _' Password for Database

, _' Database schema

, _' DSN for Oracle/SQL servers only

, _' For DB2 servers only               

' above five parameters are used for enterprise database

, True' flag to create directory if it

' doesn't exist


' Open the newly created Project

Set a_oProject = a_oRPX.OpenProject(a_sPath & "\" & a_sName &

".rqs", eOpenProjOpt_RQSFile, "admin", "")



  使用独占访问打开一个项目

  通过以下访问模式项目可以被打开:



模式
编码


使用独占访问打开项目
eProjFlag_Exclusive


使用正常访问打开项目
eProjFlag_Normal


用只读存取打开项目
eProjFlag_ReadOnly

  这些标志和 ReqPro40.Application.OpenProject
API 一起被当作参数使用。如果没有提供选项,默认的选项是正常存取。
  列表 2 显示了当这个项目已经被打开时如何转换它的存取类型。
  
列表 2. 将一个的项目转换为独占或者正常存取模式


 




               

Set a_oProject = a_oRPX.OpenProject(a_sPath & "\" & a_sName &

".rqs", eOpenProjOpt_RQSFile, "admin", "",

eProjFlag_Exclusive)


  只要没有其他人使用独占或者正常模式打开这个项目,管理人员就可以获取独占访问权。


项目结构

  项目管理人员拥有下面小节所描述的项目结构执行管理能力。
  项目属性

  项目管理人员可以查看项目属性和修改名称,前缀,以及项目的描述。当这个项目被当作外部的项目引用或者当进行跨项目跟踪时,这个前缀就可以当作项目需求和需求类型的标识符来使用(请参见列表
3)。
  
列表 3. 最大宽幅的代码清单样本


 




               

Dim a_oProject As ReqPro40.Project

Dim a_sPath As String

Dim a_oApp As ReqPro40.Application


a_sPath =

"C:\Program Files\Rational\RequisitePro\samples\Learning_Project-Use_Cases\LEARNING -

USE CASES.RQS"


Set a_oApp = New ReqPro40.Application

If Not a_oApp Is Nothing Then

Set a_oProject = a_oApp.OpenProject _

(a_sPath, eOpenProjOpt_RQSFile, "admin", "")

If Not a_oProject Is Nothing Then


  查看项目的属性

  主要属性:


[*]
名称:
a_oProject.Name
[*]
前缀:
a_oProject.Prefix
[*]
创建者:
a_oProject.AuthorID (可以将 AuthorID 作为钥匙在用户对象中搜索创建者的名称。)
[*]
目录:
a_oProject.RQSFilepath
[*]
描述:
a_oProject.Description
  修改名称,前缀,以及项目的描述

  为这个目的列表 4 显示了样本代码。
  
列表 4. 修改名称 ,前缀,以及这个项目的描述


 




               

a_oProject.Name = "NewProjectName"

a_oProject.Prefix = "newProj"

a_oProject.Description = "Project containing agile requirements"



项目修订历史

  这个修订历史是有行为创建的,比如激活项目的安全性或者使之失效,更改项目的结构,等等行为。
  查看或者修改项目修订历史

  您可以任何修订历史的更新中查看这些细节:


[*]
VersionNumber:
此版本号码
[*]
VersionLabel:
此版本更新的标签
[*]
VersionUser:
更新此版本的的用户
[*]
VersionUserKey:
进行版本更新的用户唯一码
[*]
VersionDateTime:
版本更新的电子时间戳
[*]
VersionReason:
版本更新的描述
  正如列表 5 中所显示的样本代码,您可以从 Requirement 对象或者像安全修改这样对项目的变更历史中,从 Project
对象中获取任何需求的修订历史。
  
列表 5. 取回修订历史


 




               

' Gets the Project VersionDateTime of last modification.

a_oProject.VersionDateTime


' Gets the Project VersionLabel

a_oProject.VersionLabel


' The Project VersionLabel can also be set programmatically

a_oProject.VersionLabel = "Label 1"


' Gets the Project VersionNumber

a_oProject.VersionNumber


' Modify the Project VersionNumber

' The new revision number is validated to make sure it is in a

' correct form, i.e. higher or equal to the current revision

' number.


a_oProject.VersionNumber = "1.1"


' Gets the description of the revision entry

a_oProject.VersionReason


' Give the description of the revision entry when

' programmatically adding an revision history

a_oProject.VersionReason = "Security is disabled for the project"


' Gets the name or key of the last user to perform a

' Project modification.

a_oProject.VersionUser

a_oProject.VersionUserKey



需求类型

  根据您的需求,需求类型可以当作模版来使用。项目管理人员可以创建,查看,以及修改需求类型。例如 (也可以在列表 6 中看到):



Dim a_sPath As String

Dim a_oProject As ReqPro40.Project

Dim a_oReqType As ReqPro40.ReqType

Dim a_oReqTypes As ReqPro40.ReqTypes


  

列表 6. 修改一个需求类型


 




               

Dim a_oReqType = a_oProject.ReqTypes.Add

("Test", _

"TEST", _

eReqStyles_Normal, _ eReqColors_Magenta, _2)

  Tip:


您可以传递可选的参数到 ReqPro40.ReqTypes
API ,从而提供以下的属性:


[*]对 ReqType 的描述
[*]ReqType 的一个需求必须包含的字符串
[*]无论 ReqType 需求是否有外部的参考
  
列表 7. 修改请求类型属性


 




               

Set a_oReqType = a_oProject.ReqType("TEST", eReqTypesLookups_Prefix)


' Reqtype's name is a textual value that uniquely identifies the

' reqtype

a_oReqType.Name = "Feature"

' Set the number that was associated with the first requirement

' that is created of this reqtype.

a_oReqType.InitReqNumber = 4

' Requirement type's ReqPrefix value

a_oReqType.ReqPrefix = "FEAT"

' Requirement type's ReqColor value.

' Document based requirements of this reqtype will

' be shown in this color in their document.

' ReqPro40.enumReqColors would provide all the supported colors

a_oReqType.ReqColor = eReqColors_White

' Requirement type's ReqStyle value.

' Document based requirements of this reqtype will

' be shown in this style in their document.

' ReqPro40.enumReqStyles would provide all the supported colors

a_oReqType.ReqStyle = eReqStyles_SmallCapitals


a_oProject.Save


  注意:


下面的特性被 Rational RequisitePro Version 7.0.1 版本或者更新版本所包含。
  
列表 8. 更改需求类型


 




               

Dim a_sNewReqType As String

Dim a_sOldReqType As String

Dim a_sName As String


a_sOldReqType = "FEAT"

a_sNewReqType = "TERM"

a_sName = "NewReqType"


' Create a requirement

Set a_oReq = a_oProject.CreateRequirement( _

a_sName, a_sName, a_sOldReqType, eReqTypesLookups_Prefix)


a_oReq.Save


Set a_oReq = a_oProject.GetRequirement(a_sName, eReqLookup_Name)

' Change the requirement type

a_oReq.ChangeReqType a_sNewReqType, eReqTypesLookups_Prefix


a_oReq.Save


  查看需求类型属性

  需求类型属性,比如 Name,InitReqNumber,ReqPrefix,ReqColor,以及ReqStyle 可以从
ReqType 对象中查询。
  需求属性


项目管理人员可以添加,修改,以及删除需求属性。这样可以包含列表类型属性的预定义值。请看列表 9、10、和 11 中的例子。
  

列表 9. 添加自定义属性


 




               

Dim a_sReqTypeKey As String

Dim a_sLabel As String

Dim a_sDefText As String

Dim a_sDataType As String

Dim a_bAutoSuspect As Boolean

Dim a_iRank As Integer

Dim a_iDataTypeKey As Integer

Dim a_oReqAttr As ReqPro40.Attr


a_sReqTypeKey = 1

a_sLabel = "New"

a_sDefText = "Default"

a_sDataType = "RqCustomType.URLLink"

a_bAutoSuspect = False

a_iRank = 0

a_iDataTypeKey = enumAttrDataTypes.eAttrDataTypes_Text


' Project needs to be opened with exclusive access

Set a_oReqAttr = a_oProject.ReqType(a_sReqTypeKey, _

enumReqTypesLookups.eReqTypesLookups_Key).Attrs().Add( _

a_sLabel, _

a_iRank, _

a_bAutoSuspect, _

a_iDataTypeKey, _                                                   

a_sDefText, _

False)

a_oProject.Save

a_oReqAttr.SetCustomType a_sDataType, _

enumCustomTypeLookups.eCustomTypeLookup_ProgID


a_oProject.Save


  列表 10. 修改需求属性




               

' Modify attribute list type

' Project needs to be opened with exclusive access

a_sReqTypePrefix = "FEAT"

a_sLabel = "Type"


Set a_oReqAttr = a_oProject.ReqType(a_ sReqTypePrefix, _

enumReqTypesLookups.eReqTypesLookups_ Prefix).Attrs().Item(

a_sLabel,_

enumAttrLookups.eAttrLookups_Label)

a_iDataTypeKey = a_oReqAttr.DataType()


' Change a single-select list to a multi-select and vice versa

' Project needs to be opened with exclusive access

a_oReqAttr.ChangeAttrListType

a_oProject.Save


  

列表 11. 删除需求属性


 




               

' Project needs to be opened with exclusive access

a_oProject.ReqType(a_sReqTypeKey, _

enumReqTypesLookups.eReqTypesLookups_Key).Attrs().Delete _

a_sLabel, _

enumAttrLookups.eAttrLookups_Label

a_oProject.Save



文档类型

  Rational RequisitePro 可以按照类型来进行有序组织。对于需求文档来说,文档类型就像一个模版被使用。这包括安排一个文档扩充,一个默认需求类型能够,以及文件类型的轮廓。列表
12 和 列表 13 显示了要使用代码的例子。
  
列表 12. 创建一个新的文档类型


 




               

Dim a_oDocType As ReqPro40.DocType

Set a_oDocType = a_oProject.DocTypes.Add("Test", _   

' Name

"New Document Type", _' Desc

2) ' Default Reqtype


  

列表 13. 修改文档类型


 




               

a_oDocType.Name = "Modified Test"

a_oDocType.DefReqTypeKey = 1 ' 1 corresponds to a

' Reqtype key

a_oDocType.Description = "Documents of this type have modified

test reqs"

' When a new document of this doctype is created, its file

' extension will be set to this value.If documents of this

' doctype exist, then the extension cannot be changed.

a_oDocType.Extension = "ModReq"

  先前所显示的所有属性在这里都可以被查看和修改。此外,您可以查看或者修改这些属性:


[*]
文档模板的文件名称:
a_oDocType.TemplateFileName
[*]
文档模版的描述:
a_oDocType.TemplateDesc
[*]
模版的名称:
a_oDocType.TemplateName
  对于维护相同类型的所有文档的一致性来说文档类型是十分有用的。Rational RequisitePro 包括几个有用的模版。


文档版式和扩展编辑

  项目管理人员可以控制这个版式,从而用来保存文档和激活项目的扩展编辑功能。
  控制管理文档版式是可以被查看和修改的:



a_oProject. DocSaveFormat

  对于 Boolean 值,如果已经设定,要确保 Microsoft Word 文档可以使用在 Rational RequisitePro
外部被 Word 成功地打开。
  激活扩展编辑功能,这也是可以被查看和修改的:



a_oProject.DocTextEditEnabled

  这个 Boolean 值可以使您用下列任何一种方法在一个文档外部对需求文本进行更改:


[*]从一个视图
[*]从 Rational RequisiteWeb
[*]从 RequisitePro Extensibility Interface
[*]从整合的工具
  注意:


这个特性是由 Rational RequisitePro Version 7.0.1 和更新的版本所提供的。


项目安全性

  用这些方法,项目管理人员可以为所有用户管理项目的安全性和用户帐户信息:


[*]要访问需求和文档,就要为用户的鉴定和组权限激活其安全性
[*]创建和修改用户档案资料和用户组
  激项目安全性或者使之失效

  项目管理员可以激活一个项目的安全性或者使之无效。默认情况下,安全性是被禁用状态,允许不受限制数量的用户来访问这个项目。利用项目对象的
SecurityEnabled 属性来激活项目的安全性或者使之无效:



a_oProject.SecurityEnabled = True   

a_oProject.Save

  管理组

  项目管理员可以创建和删除用户组。管理员还可以通过给用户组分配文档类型和需求类型权限来控制项目文档和需求的访问。
  
列表 14. 管理组权限


 




               

Dim a_oProject As ReqPro40.Project

Dim a_sPath As String

Dim a_oApp As ReqPro40.Application

Dim a_oGroup As ReqPro40.Group

Dim a_sGrpName As String


a_sPath = "C:\Program"_

Files\Rational\RequisitePro\samples\Learning_Project-

Use_Cases\LEARNING - USE CASES.RQS"

a_sGrpName = "NewGroup"


Set a_oApp = New ReqPro40.Application


  

列表 15. 添加一个新组


 




               

If Not a_oApp Is Nothing Then

Set a_oProject = a_oApp.OpenProject _

(a_sPath, eOpenProjOpt_RQSFile, "admin", "")

If Not a_oProject Is Nothing Then

' Create new group with Read access

Set a_oGroup = a_oProject.Groups.Add(a_sGrpName, _

ePermission_Read, "New Group ", ePerm_All, ePerm_All,

ePerm_Read, ePerm_All, ePerm_All)


If Not a_oGroup Is Nothing Then

a_oProject.Save

End If

End If

End If




修改一个现存的组

  项目管理员可以更改下面一个组的属性 (请看列表 16 中的例子):


[*]组的名称
[*]组的描述
[*]管理项目结构的权限
[*]管理项目安全性的权限
[*]文档类型(编辑)的权限
[*]需求类型(编辑)的权限
  
列表 16. 最大宽幅的样本代码列表


 




               

If Not a_oApp Is Nothing Then

Set a_oProject = a_oApp.OpenProject _

(a_sPath, eOpenProjOpt_RQSFile, "admin", "")

If Not a_oProject Is Nothing Then

Set a_oGroup = a_oProject.Groups.Item(a_sGrpName,

eGroupLookups_Name)


If Not a_oGroup Is Nothing Then

' Change the name of the group

a_oGroup.Name = "ModifiedGroup1"

' Change the description of the group

a_oGroup.Description = "Modify an existing Group"


' Can manage Project structure and Project

' security               

a_oGroup.ProjPermissions = ePerm_ModStructure Or

ePerm_ModSecurity

' Set default doctype permissions for the group


a_oGroup.DefDocTypePermissions = ePerm_All

' Set default reqtype permissions for the group

a_oGroup.DefReqTypePermissions = ePerm_Delete

' Set default attribute permissions for a reqtype

a_oGroup.DefAttrPermissions = ePerm_Update


a_oProject.Save

End If

End If

End If


  请看列表 17 和列表 18 ,从而得知如何删除或者将一个用户更改为一个组。
  注意:


无论是预定义的 <Deleted Users> 组还是存入数据所属的组都不能被删除。
  
列表 17. 删除组


 




               

a_oProject.Groups.Delete a_sGrpName, eGroupLookups_Name

a_oProject.Save


  

列表 18. 将一个用户移到一个组中


 




               

Dim a_oGroup1 As ReqPro40.Group


Set a_oGroup1 = a_oProject.Groups.Item("Administrators",

eGroupLookups_Name)

a_oUser.GroupKey = a_oGroup1.Key

a_oProject.Save


  管理用户档案资料

  项目管理员可以修改用户名称,密码,以及邮件地址,还可以将用户分配到用户组中(请看列表 19、20, 以及列表 21)。没有管理员权限的用户可以更改他们自己的名称,密码和邮件地址。

  
列表 19. 添加一个新用户到组中


 




               

a_sUserName = "NewUser"

Set a_oUser = a_oProject.Users.Add(a_sUserName, a_oGroup.Key, "",

"New User", "")

a_oProject.Save


  列表 20. 修改用户属性




               

a_oUser.Name = "newuser2"

a_oUser.EMailAddress = "newuser2@example.com"

a_oUser.FullName = "New User 2"

a_oUser.ChangePassword "", "a", "a"

a_oProject.Save


  注意:


被删除的用户被移到 <Deleted Users> 组。
  
列表 21. 从一个组中删除一个用户


 




               

a_oProject.Users.Delete a_sUserName, eUserLookups_Name

a_oProject.Save



外部项目链接点

  项目管理员可以创建可修改外部项目的链接点。用户用这些链接点来创建当前项目中的需求和外部项目需求之间的链接点。当当前项目已经打开时,配置外部项目来自动打开,当这个项目打开时,您可以进行动态连接和断开外部项目。请看列表
22、23, 以及列表 24 的例子。
  注意:


这些特性包含于 Rational RequisitePro Version 7.0.1 和更新的版本中。
  
列表 22. 需要一个标题


 




               

Dim a_sExtProjRQS As String

Dim a_oCurProject As ReqPro40.Project

Dim a_oRelProjContexts As ReqPro40.RelatedProjectContexts

Dim a_oRelProjContext As ReqPro40.RelatedProjectContext


' Create a project

Set a_oCurProject = newProject()


  

列表 23. 添加外部项目


 




               

If Not a_oCurProject Is Nothing Then

' External Project

a_sExtProjRQS = "C:\Program

Files\Rational\RequisitePro\samples\Learning_Project-

Use_Cases\LEARNING - USE CASES.RQS"


' Get the related contexts object for the current Project

Set a_oRelProjContexts = a_oCurProject.RelatedProjectContexts


If Not a_oRelProjContexts Is Nothing Then

' Add a_sExtProjRQS as External Project

Set a_oRelProjContext =

a_oRelProjContexts.Add(a_sExtProjRQS, False)

End If

End If


  这个添加在 RelatedContexts 对象中的公共功能将第二个参数当作一个标识符,来显示外部连接是否是自动连接。
  Note:


这些特性包含在 Rational RequisitePro Version 7.0.1, iFix04 中。
  
列表 24. 将自动连接添加到外部项目中


 




               

If Not a_oCurProject Is Nothing Then

' External Project

a_sExtProjRQS = "C:\Program

Files\Rational\RequisitePro\samples\Learning_Project-

Use_Cases\LEARNING - USE CASES.RQS"


' Get the related contexts object for the current Project

Set a_oRelProjContexts = a_oCurProject.RelatedProjectContexts


If Not a_oRelProjContexts Is Nothing Then

' Add a_sExtProjRQS as External Project

Set a_oRelProjContext =

a_oRelProjContexts.Add(a_sExtProjRQS, True)

End If

End If


  注意:


列表 24 中的代码样本是有假定条件的,把 admin"/" 当作用户 ID 和密码来使用,从而连接到外部项目上。如果这个外部项目已经有一个不同用户
ID 和密码,使用多态性功能 Add,这样可以给用户 ID 和密码添加额外的参数(请查看列表 25)。
  
列表 25. 需要一个标题


 




               

Dim a_sExtProjectName As String

Dim a_sExtProjectName As String

Dim a_sRelatedProjectContext As ReqPro40.RelatedProjectContext


a_sExtProjectName = "C:\Program

Files\Rational\RequisitePro\samples\Learning_Project-

Use_Cases\LEARNING - USE CASES.RQS"


'Add external Project

Set a_sRelatedProjectContext =

a_oProject.RelatedProjectContexts.AddExternalProject(

a_sExtProjectName, True, "admin", "")




参考资料

  
学习



[*]您可以参阅本文在 develperWorks 全球网站上的
英文原文

[*]几个用于为 Rational RequisitePro 增加额外特性的 RequisitePro Extensibility
(RPX) 脚本,可以从 IBM® developerWorks® 的
RequisitePro 可扩展性脚本索引
中获得。这些程序只提供作为作编写 RPX 脚本的参考示例,IBM Rational
软件对这些程序并不提供技术支持。
[*]访问
developerWorks 上的 Rational RequisitePro 产品专题
,获取需求管理方面的内容和技术资源。
[*]访问
developerWorks 中国网站 Rational 专区
,获取技术资源和 Rational 软件交付平台(Rational
Software Delivery Platform)产品的最佳实践。
[*]订阅
developerWorks Rational 专区时事通讯
。时刻关注 developerWorks Rational
的内容。每隔一周,您将收到 Rational 软件交付平台的最新技术资源和最佳实践的更新内容。
[*]订阅
Rational Edge 中文版
时事通讯获得关于高效软件开发背后理念方面的技术文章。
[*]订阅
IBM developerWorks 时事通讯
,这是关于 developerWorks 最佳指南,文章,下载信息,社区活动,网络广播以及技术事件的周刊。
[*]浏览
技术书店
获取一些关于这些技术话题的书籍。
  
获得产品和技术



[*]获得免费的
IBM Rational RequisitePro 的试用版本

[*]下载其他
IBM Rational 软件试用版

  
讨论



[*]参与 developerWorks 上
需求管理和 RequisitePro 论坛
,发表您的问题和评论,与其他 RequisitePro 的使用者分享您的想法,理念以及解决方案。
[*]浏览
developerWorks 博客
,并加入
developerWorks 社区

页: [1]
查看完整版本: 使用 IBM Rational RequisitePro 进行项目执行管理