我正在尝试使用" 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赋值的情况下创建缺陷。
请告诉我,我们怎样才能制造缺陷。
答案 0 :(得分:1)
SDK的第13版不支持此功能。请下载15版:
https://community.versionone.com/Developers/Developer-Library/Documentation/Java_SDK