How to delete a history activity node?

cancel
Showing results for 
Search instead for 
Did you mean: 
kim_zheng
Member II

How to delete a history activity node?

Jump to solution

请问一下如何删除ACT_HI_ACTINS中的一条记录,我并没有找到Activiti内部有提供相应的接口?

I would like to ask how to delete a record in ACT_HI_ACTINS, I did not find Activiti internal to provide the appropriate interface?

1 Solution

Accepted Solutions
cjose
Senior Member II

Re: How to delete a history activity node?

Jump to solution

I don't think there are APIs to delete a record from ACT_HI_ACTINST. You can use the delete methods in  HistoryService to delete a process or task instance which will in-turn delete all the associated records from respective tables including ACT_HI_ACTINST

Ciju

View solution in original post

10 Replies
cjose
Senior Member II

Re: How to delete a history activity node?

Jump to solution

I don't think there are APIs to delete a record from ACT_HI_ACTINST. You can use the delete methods in  HistoryService to delete a process or task instance which will in-turn delete all the associated records from respective tables including ACT_HI_ACTINST

Ciju

kim_zheng
Member II

Re: How to delete a history activity node?

Jump to solution

thanks  for  your  answer Sincerely !!!  I have find another way to solve this problem . 

kgastaldo
Senior Member

Re: How to delete a history activity node?

Jump to solution

Hey Kim - Can you let us know what you did to resolve? It may be helpful to another user later! 

sunilkumartk
Active Member

Re: How to delete a history activity node?

Jump to solution

There is a Rest Api available for deleting the historic process instance.

DELETE history/historic-task-instances/{taskId}

You can refer the user guide for more information.

Or in case you are looking for a Java Api, i recommend you visit the corresponding git repo module.

kim_zheng
Member II

Re: How to delete a history activity node?

Jump to solution

i don't know  how to describe the process, so i will show the code directly . hope it will help another user.

  •     first  you need  a  mapper interface  

            public interface HistoryActivitiInstanceMapper {

                     @Delete(" delete from act_hi_actinst where ID_ = #{id}")
                     public Integer deleteHistoricActivitiInstanceById(String id);

             }

  •   second  define custom  SqlExecution use the mapper interface that you have    

      CustomSqlExecution<HistoryActivitiInstanceMapper, Integer> sqlExecution =

                  new AbstractCustomSqlExecution<HistoryActivitiInstanceMapper, Integer>(HistoryActivitiInstanceMapper.class) {
                     @Override
                        public Integer execute(HistoryActivitiInstanceMapper mapper) {
                                          return mapper.deleteHistoricActivitiInstanceById(currentId);
                     }
         };

  •    third  delete the HistoricActivityInstance by ID_
         managementService.executeCustomSql(qlExecution);
kim_zheng
Member II

Re: How to delete a history activity node?

Jump to solution

thanks for your help !!!

pteki
Member II

Re: How to delete a history activity node?

Jump to solution

Have any one found a way to retrieve the entire tree of the process instance, including all task details, once the instance goes to completed state? and moving them to an archive table from the ACT_HI?

cjose
Senior Member II

Re: How to delete a history activity node?

Jump to solution

The Activiti 7 work is doing that via different micro services. You can find more about Activiti 7 at Introduction · Activiti 7 & Activiti Cloud Developers Guide .

If you are using Activiti 5.x, I once did a project that moves everything from Activiti tables to Elasticsearch, it is available at GitHub - cijujoseph/activiti-analytics-spring-boot: A standalone app (ETL pattern using spring-boot)...

pteki
Member II

Re: How to delete a history activity node?

Jump to solution

Thank you for the reply. checking....

Instead of getting all the instances, is there any way to get only completed instances, irrespective of the processKey?

history/historic-process-instances?endTime!=null&size=100 -- ignoring the "endTime"