如何使用" VersionOne SDK JAVA API创建缺陷"客户

时间:2015-10-27 13:12:09

标签: java rest versionone

我正在尝试使用" VersionOne.SDK.Java.APIClient 13.0.1"创建缺陷。罐。

        Oid projectId = services.getOid(scopeId);
        IAssetType assetType = this.metaModel.getAssetType("Defect");
        Asset newAsset = services.createNew(assetType, projectId);

        IAttributeDefinition nameAttribute = assetType.getAttributeDefinition("Name");
        IAttributeDefinition Custom_FailureType = assetType.getAttributeDefinition("Custom_FailureType.Name");
        IAttributeDefinition defectStatus=assetType.getAttributeDefinition("Status.Name");
        IAttributeDefinition defectSeverity=assetType.getAttributeDefinition("Type.Name");
        IAttributeDefinition defectSource=assetType.getAttributeDefinition("Source.Name");
        IAttributeDefinition defectVersion=assetType.getAttributeDefinition("VersionAffected");

        //newAsset.addAttributeValue(Custom_FailureType, "My New Defect");
        newAsset.setAttributeValue(nameAttribute, "My New Defect");
        newAsset.setAttributeValue(Custom_FailureType, "Functional Failure");
        newAsset.setAttributeValue(defectStatus, "Done");
        newAsset.setAttributeValue(defectSeverity, "Minor");
        newAsset.setAttributeValue(defectSource, "sales");
        newAsset.setAttributeValue(defectVersion, "1.2.3");

        services.save(newAsset);

        System.out.println(newAsset.getOid().getToken());
        System.out.println(newAsset.getAttribute(nameAttribute).getValue());

但收到以下错误:

"无法为只读属性分配新值:Defect.Custom_FailureType.Name"

字段Custom_FailureType是必需的,因此我无法在不为Custom_FailureType赋值的情况下创建缺陷。

请告诉我,我们怎样才能制造缺陷。

1 个答案:

答案 0 :(得分:1)