在我的自定义工作流程中,我在创建工作流程时对PDF进行了一些更改:
<activiti:executionListener event="start" class="pt.entp.fields.CreateFields"></activiti:executionListener>
我想,当我取消工作流程时,工作流程会清除创建时所做的更改。没办法做到这一点?
答案 0 :(得分:2)
首先将当前版本存储在启动工作流监听器中:
NodeRef myPdfnode = ...
String currentversion = serviceRegistry.getVersionService.getCurrentVersion(myPdfnode).getVersionLabel();
execution.setVariable("mynode_currentversion", currentversion);
您需要使用结束工作流程监听器
恢复pdf文档的版本 <activiti:executionListener event="end"
class="pt.entp.fields.WorkflowEnded"></activiti:executionListener>
在那里,检查工作流是否确实被取消,然后恢复到您保存的版本:
String deleteReason = execution.getDeleteReason();
if ("cancelled".equals(deleteReason)){
NodeRef myPdfnode = ...
String initialversionLabel = execution.getVaraible("mynode_currentversion");
Version initialversion = serviceRegistry.getVersionService.getVersionHistory(myPdfnode).getVersion(initialversionLabel );
serviceRegistry.getVersionService.revert(myPdfnode, initialversion);
}