Java Code Examples for org.flowable.engine.ManagementService#executeCommand()

The following examples show how to use org.flowable.engine.ManagementService#executeCommand() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Application.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Bean
CommandLineRunner customMybatisXmlMapper(final ManagementService managementService) {
    return new CommandLineRunner() {
        @Override
        public void run(String... args) throws Exception {
            String processDefinitionDeploymentId = managementService.executeCommand(new Command<String>() {
                @Override
                public String execute(CommandContext commandContext) {
                    return (String) CommandContextUtil.getDbSqlSession()
                            .selectOne("selectProcessDefinitionDeploymentIdByKey", "waiter");
                }
            });

            LOGGER.info("Process definition deployment id = {}", processDefinitionDeploymentId);
        }
    };
}
 
Example 2
Source File: HistoryServiceTaskLogTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void deleteTaskWithLogEntries(TaskService taskService, ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration,
        String taskId) {
    taskService.deleteTask(taskId, true);
    managementService.executeCommand(new Command<Void>() {

        @Override
        public Void execute(CommandContext commandContext) {
            HistoricTaskLogEntryEntityManager historicTaskLogEntryEntityManager = CommandContextUtil.getTaskServiceConfiguration(commandContext)
                    .getHistoricTaskLogEntryEntityManager();
            List<HistoricTaskLogEntry> taskLogEntries = historicTaskLogEntryEntityManager
                    .findHistoricTaskLogEntriesByQueryCriteria(new HistoricTaskLogEntryQueryImpl(processEngineConfiguration.getCommandExecutor()));
            for (HistoricTaskLogEntry historicTaskLogEntry : taskLogEntries) {
                historicTaskLogEntryEntityManager.deleteHistoricTaskLogEntry(historicTaskLogEntry.getLogNumber());
            }

            HistoryJobService historyJobService = CommandContextUtil.getHistoryJobService(commandContext);
            List<HistoryJob> jobs = historyJobService.findHistoryJobsByQueryCriteria(new HistoryJobQueryImpl(commandContext));
            for (HistoryJob historyJob : jobs) {
                historyJobService.deleteHistoryJob((HistoryJobEntity) historyJob);
            }

            return null;
        }
    });
}
 
Example 3
Source File: CreateUserAndMembershipTestDelegate.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {

    ManagementService managementService = Context.getProcessEngineConfiguration().getManagementService();
    managementService.executeCommand(new Command<Void>() {
        @Override
        public Void execute(CommandContext commandContext) {
            return null;
        }
    });

    IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();

    String username = "Kermit";
    User user = identityService.newUser(username);
    user.setPassword("123");
    user.setFirstName("Manually");
    user.setLastName("created");
    identityService.saveUser(user);

    // Add admin group
    Group group = identityService.newGroup("admin");
    identityService.saveGroup(group);

    identityService.createMembership(username, "admin");
}
 
Example 4
Source File: SpringIdmTransactionsTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {

    ManagementService managementService = Context.getProcessEngineConfiguration().getManagementService();
    managementService.executeCommand(new Command<Void>() {

        @Override
        public Void execute(CommandContext commandContext) {
            return null;
        }
    });

    IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();

    String username = "Kermit";
    User user = identityService.newUser(username);
    user.setPassword("123");
    user.setFirstName("Manually");
    user.setLastName("created");
    identityService.saveUser(user);

    // Add admin group
    Group group = identityService.newGroup("admin");
    identityService.saveGroup(group);

    identityService.createMembership(username, "admin");
}
 
Example 5
Source File: TransactionRollbackTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    try {
        ManagementService managementService = CommandContextUtil.getProcessEngineConfiguration().getManagementService();
        managementService.executeCommand((Command<Void>) commandContext -> { throw new RuntimeException("exception from service task"); });
    } catch (Exception e) {
        e.printStackTrace();
    }

    execution.setVariable("theVariable", "test");
}