addLink
说明
addLink(
将 RDF/XML 元素添加到 reqResource
,resource
)reqResource
指定的需求或需求集合资源。该函数将元素名称设置为 j.0:Link
,并将 rdf:resource
属性设置为与 resource
关联的资源 URL。使用commit
函数将更改应用到服务提供商。有关 RDF/XML 元素的更多信息,请参阅万维网联盟网站上的 RDF 的 XML 语法和生命周期协作开放服务 (OSLC) 网站上的 QM 资源定义。
示例
添加和删除 OSLC 资源与需求之间的链接
此示例显示如何添加和删除 OSLC 资源与 OSLC 需求之间的链接。
按照为需求管理域创建并配置 OSLC 客户端中所述创建并配置 OSLC 客户端myClient
后,为需求资源类型创建查询功能。向服务提供者提交可用的需求资源的查询请求。
myQueryCapability = getQueryService(myClient,'Requirement');
reqs = queryRequirements(myQueryCapability)
reqs = 1×30 Requirement array with properties: ResourceUrl Dirty IsFetched Title Identifier
将其中一个需求分配给名为 myReq
的变量,将另一个需求分配给 linkReq
。获取需求的完整资源属性。
myReq = reqs(1); linkReq = reqs(5); fetch(myReq,myClient); fetch(linkReq,myClient);
添加从 linkReq
到 myReq
的链接。通过获取 myReq
的链接确认链接创建。
addLink(myReq,linkReq) links = getLinks(myReq)
links = 1×1 cell array {'https://localhost:9443/rm/CA_3d5ba3752e2c489b965a3ecceffb664a'}
在服务提供商中,确定一个测试用例来链接到需求。识别测试用例的资源 URL 并将其分配给名为 URL
的变量。添加从 URL
到 myReq
的链接。通过获取 myReq
的链接确认链接创建。
URL = 'https://localhost:9443/qm/_ibz6tGWYEeuAF8ZpKyQQtg';
addLink(myReq,URL)
links = getLinks(myReq)
links = 1×2 cell array {'https://localhost:9443/rm...'} {'https://localhost:9443/qm...'}
将变更提交给服务提供商。
status = commit(myReq,myClient)
status = StatusCode enumeration OK
获取更新需求 myReq
的完整资源属性。
status = fetch(myReq,myClient)
status = StatusCode enumeration OK
获取链接到 myReq
的资源 URL。
links = getLinks(myReq)
links = 1×2 cell array {'https://localhost:9443/rm...'} {'https://localhost:9443/qm...'}
获取第一个链接资源的 URL 并将其分配给 URL
。
URL = links{1}
URL = 'https://localhost:9443/rm/CA_3d5ba3752e2c489b965a3ecceffb664a'
在从 myReq
删除链接之前,请确认资源 URL 指向您要删除的需求。创建需求资源对象并设置资源 URL。获取需求的完整资源属性并检查需求。
req = oslc.rm.Requirement; setResourceUrl(req,URL); status = fetch(req,myClient)
status = StatusCode enumeration OK
req
ans = Requirement with properties: ResourceUrl: 'https://localhost:9443/rm/CA_3d5ba3752e2c489b965a...' Dirty: 0 IsFetched: 1 Title: '[SAFe] Lifecycle Scenario Template' Identifier: '1165'
从myReq
中删除链接并将更改提交给服务提供商。
removeLink(myReq,URL) status = commit(myReq,myClient)
status = StatusCode enumeration OK
获取更新需求 myReq
的完整资源属性。
status = fetch(myReq,myClient)
status = StatusCode enumeration OK
通过获取链接到 myReq
的资源的 URL 来验证链接是否被删除。
links = getLinks(myReq)
links = 1×1 cell array {'https://localhost:9443/qm/_ibz6tGWYEeuAF8ZpKyQQtg'}
输入参数
reqResource
— OSLC 需求资源
oslc.rm.Requirement
对象 | oslc.rm.RequirementCollection
对象
OSLC 需求或需求集合资源对象,指定为 oslc.rm.Requirement
或 oslc.rm.RequirementCollection
对象。
resource
— OSLC 资源 URL 或对象
字符向量 | oslc.rm.Requirement
对象 | oslc.rm.RequirementCollection
对象 | oslc.cm.ChangeRequest
对象 | ...
OSLC 资源 URL,指定为字符向量或 OSLC 资源对象,指定为以下对象之一:
提示
您还可以使用
addResourceProperty
添加链接来指定链接的关系。
版本历史记录
在 R2021a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)