activiti學習筆記(四)managementService
managementService
- Job任務管理
- 資料庫相關通用操作
- 執行流程引擎命令(Command)
Job任務查詢
從上述表可以看出主要還是Job相關的查詢。
資料庫相關操作
- 查詢表結構後設資料(TableMetaData)
- 通用表查詢(TablePageQuery)
- 執行自定義的sql查詢(executeCustomSql)
示例
ProcessEngineConfiguration cfg = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
ProcessEngine processEngine = cfg.buildProcessEngine();
ManagementService managementService = processEngine.getManagementService();
// 獲取指定表的資料
TablePage tablePage = managementService.createTablePageQuery()
.tableName(managementService.getTableName(ProcessDefinitionEntity.class))
.listPage(0,100);
List<Map<String,Object>> rowsList = tablePage.getRows();
for (Map<String,Object> row : rowsList){
logger.info("row={}",row);
}
上述示例中通過呼叫tableName方法來指定要查詢的表,除了直接傳入表名如"act_ru_task"這種形式外,還可以使用上述managementService.getTableName(ProcessDefinitionEntity.class)
方法通過實體類來獲取表名。
接下來再看下如何自定義查詢方法:
首先修改配置檔案如下:
public interface MyCustomMapper {
@Select("select * from act_ru_task")
public List<Map<String,Object>> findAll();
}
介面的方法定義中新增select註解來實現自定義sql語句。
然後配置下流程配置檔案:
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/db_activiti" />
<property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
<property name="jdbcUsername" value="root" />
<property name="jdbcPassword" value="abc123" />
<property name="databaseSchemaUpdate" value="true" />
<property name="customMybatisMappers">
<set>
<value>com.activiti.MyCustomMapper</value>
</set>
</property>
</bean>
最後後臺程式碼呼叫這個自定義介面:
List<Map<String, Object>> mapList = managementService
.executeCustomSql(
new AbstractCustomSqlExecution<MyCustomMapper,List<Map<String,Object>>>(MyCustomMapper.class){
public List<Map<String, Object>> execute(MyCustomMapper myCustomMapper) {
return myCustomMapper.findAll();
}
});
for(Map<String,Object> map: mapList){
logger.info("map={}",map);
}
結果正常輸出act_ru_task表的資料。
下面接著看managementService執行自定義命令:
ProcessEngineConfiguration cfg = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
ProcessEngine processEngine = cfg.buildProcessEngine();
ManagementService managementService = processEngine.getManagementService();
managementService.executeCommand(new Command() {
public Object execute(CommandContext commandContext) {
// 自定義命令實現
return null;
}
});
相關文章
- activiti學習筆記二筆記
- Activiti 學習筆記 小結筆記
- Activiti 學習筆記四:流程例項、任務的執行筆記
- Activiti 學習筆記七:連線(SequenceFlow)筆記
- Activiti 學習筆記五:流程變數筆記變數
- Activiti工作流基礎學習筆記筆記
- Activiti 學習筆記12:分配個人任務筆記
- Activiti 學習筆記13:分配組任務筆記
- Activiti學習筆記三:管理流程定義筆記
- activiti學習記錄
- Activiti學習筆記一:建立資料庫表筆記資料庫
- Activiti 學習筆記八:排他閘道器(ExclusiveGateWay)筆記Gateway
- goLang學習筆記(四)Golang筆記
- Javascript 學習 筆記四JavaScript筆記
- Activiti 學習筆記六:流程執行歷史記錄筆記
- Activiti 學習筆記一到六小結筆記
- Activiti 學習筆記九:並行閘道器(parallelGateWay)筆記並行ParallelGateway
- ONNXRuntime學習筆記(四)筆記
- Android學習筆記四Android筆記
- Spss 學習筆記(四)SPSS筆記
- 四元數 學習筆記筆記
- c++學習筆記(四)C++筆記
- Activiti學習筆記二:簡單順序流演示demo筆記
- ES6 學習筆記四筆記
- TS學習筆記(四):函式筆記函式
- springboot 學習筆記(四)Spring Boot筆記
- 大資料學習筆記(四)大資料筆記
- NET Core-學習筆記(四)筆記
- Activiti 學習筆記11:接收活動(receiveTask,即等待活動)筆記
- Activiti 學習筆記14:工作流定義的角色組筆記
- Gradle外掛學習筆記(四)Gradle筆記
- 李巨集毅深度學習 筆記(四)深度學習筆記
- Java學習筆記 第四天Java筆記
- MySql 學習筆記四:表的拆分MySql筆記
- OS學習筆記四:同步機制筆記
- Delphi5學習筆記之四筆記
- Kubernetes學習筆記(四):服務筆記
- HexMap學習筆記(四)——不規則化筆記