Remove a comment from a task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2012 05:07 PM
i add comments to a task with taskService.addComment(), but the taskService does not offer a method for removing comments. I found the CommentManager which has the method commentManager.delete(PersistentObject).
Is this the API for removing a task or is there another way to go? Somehow i have worries to use CommentManager and CommentEntity directly …
Regards
Chris
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2012 01:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2012 11:08 AM
Otherwise you get funny situations once people start commenting on stuff that is removed later … However, nowadays I'm not sure about that functionality …
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2012 04:08 PM
TaskService on the other side seem to be a documented API which is not likely to change over time. At least it makes me believe that it is not likely to change a lot…
Thus i would prefer something like TaskService.deleteComment(Comment) (but Comment has no unique identifier…)
When i use CommandManager, what do i need to do so that i can use it? Just instantiating it and using it like the following snippet does not work:
public void removeTaskComment(Comment comment) {
if (comment instanceof CommentEntity) {
CommentManager commentManager = new CommentManager();
CommentEntity commentEntity = (CommentEntity) comment;
commentManager.delete(commentEntity);
}
}
Caused by: java.lang.NullPointerException
at org.activiti.engine.impl.persistence.AbstractHistoricManager.<init>(AbstractHistoricManager.java:26)
at org.activiti.engine.impl.persistence.entity.CommentManager.<init>(CommentManager.java:27)
at erp.web.faces.beans.activiti.TaskManager.removeTaskComment(TaskManager.java:168)
is there something special which needs to be done to satisfy protected int historyLevel = Context.getProcessEngineConfiguration().getHistoryLevel();
History is enabled with "full"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2012 04:59 AM
You can't instantiate the comment manager directly. But if you want to hack your way around it: cast the process engine to 'ProcessEngineConfigurationImpl' and get the comment manager through there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2012 04:09 PM
unfortunately the cast to ProcessEngineImpl results in the same problem:
Caused by: org.activiti.engine.ActivitiException: couldn't instantiate org.activiti.engine.impl.persistence.entity.CommentManager: null
at org.activiti.engine.impl.persistence.GenericManagerFactory.openSession(GenericManagerFactory.java:40) [activiti-engine-5.10-SNAPSHOT.jar:]
at erp.web.faces.beans.activiti.TaskManager.removeTaskComment(TaskManager.java:185) [classes:]
at erp.web.faces.beans.activiti.TaskManager$Proxy$_$$_WeldClientProxy.removeTaskComment(TaskManager$Proxy$_$$_WeldClientProxy.java) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_26]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_26]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_26]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_26]
at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
… 37 more
Caused by: java.lang.NullPointerException
at org.activiti.engine.impl.persistence.AbstractHistoricManager.<init>(AbstractHistoricManager.java:26) [activiti-engine-5.10-SNAPSHOT.jar:]
at org.activiti.engine.impl.persistence.entity.CommentManager.<init>(CommentManager.java:27) [activiti-engine-5.10-SNAPSHOT.jar:]
at sun.reflect.GeneratedConstructorAccessor215.newInstance(Unknown Source) [:1.6.0_26]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_26]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_26]
at java.lang.Class.newInstance0(Class.java:355) [rt.jar:1.6.0_26]
at java.lang.Class.newInstance(Class.java:308) [rt.jar:1.6.0_26]
at org.activiti.engine.impl.persistence.GenericManagerFactory.openSession(GenericManagerFactory.java:38) [activiti-engine-5.10-SNAPSHOT.jar:]
with this code:
public void removeTaskComment(Comment comment) {
if (comment instanceof CommentEntity) {
ProcessEngineImpl pe = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
SessionFactory sessionFactory = pe.getProcessEngineConfiguration()
.getSessionFactories().get(CommentManager.class);
Session session = sessionFactory.openSession();
if (session != null && session instanceof CommentManager) {
CommentManager commentManager = (CommentManager) session;
CommentEntity commentEntity = (CommentEntity) comment;
commentManager.delete(commentEntity);
}
}
}
At first i tried with the injected ProcessEngine, but i could not cast that Weld proxy to ProcessEngineImpl, thats why i want to get it via ProcessEngines.getDefaultProcessEngine().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2012 04:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2012 12:36 PM
and ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration() already returns an ProcessEngineConfigurationImpl…
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2012 05:11 AM
Check the service implementation how to do that. That should give you access to the full blown context in which the comment manager should operate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2012 06:26 AM
