I'm creating one widget in Polarion using OpenAPI. I must create various workitems using the same.
Can anyone suggest how can I do this?
Thanks.
If you want to create a workItem using the openAPI, The steps will be,
Instatiate the IDataService object by Platform.getPlatform.lookupService(IDataService.class)
.
dataService.createInstance("WorkItem")
This will create a JVM(Non-Persisted) polarion object.
Fill the attributes, namely project URI and title by getting the data object of the newly created workItem object.
Load the ITransactionService, just as we loaded the IDataService.
Open a transaction by transactioITransactionService.beginTx()
workItem.save()
The complete code snippet wil be as follows:
IDataService dataservice = (IDataService) Platform.getPlatform.lookupService(IDataService.class);
ITransactionService transactionservice = (ITransactionService ) Platform.getPlatform.lookupService(ITransactionService.class);
PObject workItem = (PObject)dataservice.createInstance("WorkItem");
workItem.getData().setValue("project","<project-URI>");
workItem.getData().setValue("title","This is OpenAPI WorkItem");
try{
transactionservice.beginTx();
workItem.save();
} catch(Exception e){}