Creation of precondition plugin on delete of workitem
Accepted answer
According to https://jazz.net/wiki/bin/view/Main/CustomPreconditionsTable#operations the operation ID is com.ibm.team.workitem.operation.workItemDelete
https://rsjazz.wordpress.com has several examples for advisors. You need to use the Extension point for advisors is com.ibm.team.process.service.operationAdvisors
Debug your extension on Jetty. If you have questions you can ask them here and hope for an answer provided the question actually carries information that people can work on. "but it did not work for us" is not really useful.
One other answer
We are also trying a precondition where a work item cannot be deleted if it has a relationship (eg parent->child)
on debugging the plugin in Jetty we see that the operationData is null. so ideally we cannot extract the data through:
Object data = operation.getOperationData();
However in the variable view of Debug for the operation class we see that the workItemHandle information is present:
name:val$workItem value: WorkItemImpl(id=1229)
I am not able to find any method in the operation class to retrieve the handle. Any suggestions how to retrieve this handle?
Thanks,
Abhishek Kumar
Comments
Create your own question. Posting answers with new questions is just an annoying, frustrating habit. I don't want to spend my day converting these answers into questions for forum users.
If you want to do this, you have to have some basic skills. Follow https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ to get them. The extensions workshop provides all you need to know for this question.
Various examples on https://rsjazz.wordpress.com/ show also how to get the data.
WorkItemImpl also tells you that the work item handle is already resolved.
Most of this information was already in the answer above. You should consider to follow such hints.
for extracting the data from pre-conditon from save workitem we use the following
Object data = operation.getOperationData();
if (!(data instanceof ISaveParameter)) { return; }
ISaveParameter saveParameter = (ISaveParameter) data;
if (saveParameter.isCreation()) {
return;
}
IAuditable auditable = saveParameter.getNewState();
if (!(auditable instanceof IWorkItem)) { return; }
but in the case of precondition of delete work item i am not able to extract the data this way.
Object data = operation.getOperationData(); returns null.(when we debug in jetty)
I searched for examples in your blog as well as in the workshop, but i wasn't able to find it.
WorkItemImpl class exists as a variable in the operation class but maybe it is not visible from the current execution context.
I can see the same in an experiment I was doing. This means, I am not able to access the work item in the delete and I can't actually test anything. The work item is somehow in the information, but I have no idea how to access it.
I don't have any more information unfortunately.
The method com.ibm.team.workitem.service.internal.WorkItemRepositoryService.deleteWorkItem(IWorkItemHandle, IRepositoryItemService)
performs the delete operation and that does not provide operation data. It is even documented. I don't know why, but this seems to be as designed. so if you want that to change, you would have to create an enhancement request. If you create one, for example here: https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWelcome , please provide a link below.
Hello Ralph,
I have raised an enhancement, follow this link.
Thanks.