Main Content

本页采用了机器翻译。点击此处可查看英文原文。

create

在 OSLC 服务提供商中创建资源

自 R2021a 起

    说明

    示例

    myResource = create(myCreationFactory,resource) 向与创建工厂 myCreationFactory 关联的生命周期协作开放服务 (OSLC) 服务提供商提交资源对象 resource 的创建请求。

    示例

    全部折叠

    此示例显示如何使用已配置的 OSLC 客户端提交用户创建资源的创建请求。

    按照为需求管理域创建并配置 OSLC 客户端中所述创建并配置 OSLC 客户端myClient后,为需求资源类型创建一个创建工厂。

    myCreationFactory = getCreationFactory(myClient,'Requirement');

    通过创建 oslc.rm.Requirement 类的实例来创建新的需求资源。

    myReq = oslc.rm.Requirement
    myReq = 
      Requirement with properties:
    
        ResourceUrl: ''
              Dirty: 0
          IsFetched: 0
              Title: ''
         Identifier: ''
    

    dcterms:title属性添加到需求并设置值。

    addTextProperty(myReq,'dcterms:title','My New Requirement');
    

    向服务提供商提交需求对象的创建请求。

    newReq = create(myCreationFactory,myReq)
    newReq = 
      Requirement with properties:
    
        ResourceUrl: 'https://localhost:9443/rm/resources/_oJNtgWrqEeup0...'
              Dirty: 1
          IsFetched: 0
              Title: ''
         Identifier: ''
    

    从服务提供商处检索需求资源的完整资源数据。使用show函数在系统浏览器中打开需求资源。

    status = fetch(newReq,myClient)
    status = 
    
      StatusCode enumeration
    
        OK
    show(newReq)

    输入参数

    全部折叠

    OSLC 资源创建工厂,指定为 oslc.core.CreationFactory 对象。

    输出参量

    全部折叠

    提示

    版本历史记录

    在 R2021a 中推出