@Transactional public int archiveWorkflows(List<Integer> workflowIds) { String workflowIdParams = params(workflowIds); int archivedWorkflows = archiveWorkflowTable(workflowIdParams); archiveActionTable(workflowIdParams); archiveStateTable(workflowIdParams); deleteWorkflows(workflowIdParams); return archivedWorkflows; }
private void archiveStateTable(String workflowIdParams) { String columns = columnsFromMetadata("nflow_workflow_state"); jdbc.update("insert into nflow_archive_workflow_state (" + columns + ") " + "select " + columns + " from nflow_workflow_state where workflow_id in " + workflowIdParams); }
Assert.notNull(olderThan, "olderThan must not be null"); Assert.isTrue(batchSize > 0, "batchSize must be greater than 0"); archiveDao.ensureValidArchiveTablesExist(); log.info("Archiving starting. Archiving passive workflows older than {}, in batches of {}.", olderThan, batchSize); StopWatch stopWatch = new StopWatch(); int archivedWorkflowsTotal = 0; do { workflowIds = archiveDao.listArchivableWorkflows(olderThan, batchSize); if (workflowIds.isEmpty()) { break; archivedWorkflows = archiveDao.archiveWorkflows(workflowIds); archivedWorkflowsTotal += archivedWorkflows;
private int archiveWorkflowTable(String workflowIdParams) { String columns = columnsFromMetadata("nflow_workflow"); return jdbc.update("insert into nflow_archive_workflow(" + columns + ") " + "select " + columns + " from nflow_workflow where id in " + workflowIdParams); }
private void archiveActionTable(String workflowIdParams) { String columns = columnsFromMetadata("nflow_workflow_action"); jdbc.update("insert into nflow_archive_workflow_action(" + columns + ") " + "select " + columns + " from nflow_workflow_action where workflow_id in " + workflowIdParams); }