public int getPageSize() { return queryOptions.getNumberOfResults(); }
public int getPageSize() { return queryOptions.getNumberOfResults(); }
public void deleteRelatedApplicationMenus(FilterBuilder filterBuilder) throws SBonitaException { QueryOptions options = filterBuilder.buildQueryOptions(); List<SApplicationMenu> relatedMenus; do { relatedMenus = applicationService.searchApplicationMenus(options); for (SApplicationMenu relatedMenu : relatedMenus) { applicationService.deleteApplicationMenu(relatedMenu); } } while (relatedMenus.size() == options.getNumberOfResults()); }
public List<SMappedDocument> getAllDocumentOfTheList(final long processInstanceId, final String name) throws SBonitaReadException { QueryOptions queryOptions = new QueryOptions(0, 100); List<SMappedDocument> mappedDocuments; final List<SMappedDocument> result = new ArrayList<SMappedDocument>(); do { mappedDocuments = documentService.getDocumentList(name, processInstanceId, queryOptions.getFromIndex(), queryOptions.getNumberOfResults()); result.addAll(mappedDocuments); queryOptions = QueryOptions.getNextPage(queryOptions); } while (mappedDocuments.size() == 100); return result; }
public List<SMappedDocument> getAllDocumentOfTheList(final long processInstanceId, final String name) throws SBonitaReadException { QueryOptions queryOptions = new QueryOptions(0, 100); List<SMappedDocument> mappedDocuments; final List<SMappedDocument> result = new ArrayList<SMappedDocument>(); do { mappedDocuments = documentService.getDocumentList(name, processInstanceId, queryOptions.getFromIndex(), queryOptions.getNumberOfResults()); result.addAll(mappedDocuments); queryOptions = QueryOptions.getNextPage(queryOptions); } while (mappedDocuments.size() == 100); return result; }
public static QueryOptions getNextPage(final QueryOptions queryOptions) { return new QueryOptions(queryOptions.getFromIndex() + queryOptions.getNumberOfResults(), queryOptions.getNumberOfResults(), queryOptions.getOrderByOptions(), queryOptions.getFilters(), queryOptions.getMultipleFilter()); }
public void deleteRelatedApplicationMenus(FilterBuilder filterBuilder) throws SBonitaException { QueryOptions options = filterBuilder.buildQueryOptions(); List<SApplicationMenu> relatedMenus; do { relatedMenus = applicationService.searchApplicationMenus(options); for (SApplicationMenu relatedMenu : relatedMenus) { applicationService.deleteApplicationMenu(relatedMenu); } } while (relatedMenus.size() == options.getNumberOfResults()); }
public static QueryOptions getNextPage(final QueryOptions queryOptions) { return new QueryOptions(queryOptions.getFromIndex() + queryOptions.getNumberOfResults(), queryOptions.getNumberOfResults(), queryOptions.getOrderByOptions(), queryOptions.getFilters(), queryOptions.getMultipleFilter()); }
private List<SMappedDocument> getAllDocumentOfTheList(final long processInstanceId, final String name, final Long time) throws SBonitaReadException { if (time != null) { return documentService.getDocumentList(name, processInstanceId, time); } QueryOptions queryOptions = new QueryOptions(0, 100); List<SMappedDocument> mappedDocuments; final List<SMappedDocument> result = new ArrayList<SMappedDocument>(); do { mappedDocuments = documentService.getDocumentList(name, processInstanceId, queryOptions.getFromIndex(), queryOptions.getNumberOfResults()); result.addAll(mappedDocuments); queryOptions = QueryOptions.getNextPage(queryOptions); } while (mappedDocuments.size() == 100); return result; }
private List<SMappedDocument> getAllDocumentOfTheList(final long processInstanceId, final String name, final Long time) throws SBonitaReadException { if (time != null) { return documentService.getDocumentList(name, processInstanceId, time); } QueryOptions queryOptions = new QueryOptions(0, 100); List<SMappedDocument> mappedDocuments; final List<SMappedDocument> result = new ArrayList<SMappedDocument>(); do { mappedDocuments = documentService.getDocumentList(name, processInstanceId, queryOptions.getFromIndex(), queryOptions.getNumberOfResults()); result.addAll(mappedDocuments); queryOptions = QueryOptions.getNextPage(queryOptions); } while (mappedDocuments.size() == 100); return result; }
public QueryOptions(final QueryOptions queryOptions) { super(); fromIndex = queryOptions.getFromIndex(); numberOfResults = queryOptions.getNumberOfResults(); orderByOptions = queryOptions.getOrderByOptions(); filters = queryOptions.getFilters(); multipleFilter = queryOptions.getMultipleFilter(); }
public QueryOptions(final QueryOptions queryOptions) { super(); fromIndex = queryOptions.getFromIndex(); numberOfResults = queryOptions.getNumberOfResults(); orderByOptions = queryOptions.getOrderByOptions(); filters = queryOptions.getFilters(); multipleFilter = queryOptions.getMultipleFilter(); }
@Override public void deleteAll() throws SPlatformCommandDeletionException { if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), "deleteAll")); } final QueryOptions queryOptions = new QueryOptions(0, 100, SPlatformCommand.class, "id", OrderByType.ASC); List<SPlatformCommand> sPlatformCommands = null; do { try { sPlatformCommands = getPlatformCommands(queryOptions); } catch (final SPlatformCommandGettingException e) { if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogOnExceptionMethod(this.getClass(), "deleteAll", e)); } throw new SPlatformCommandDeletionException(e); } for (final SPlatformCommand sPlatformCommand : sPlatformCommands) { deletePlatformCommand(sPlatformCommand); } } while (sPlatformCommands.size() == queryOptions.getNumberOfResults()); if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogAfterMethod(this.getClass(), "deleteAll")); } }
@Override public void deleteAll() throws SPlatformCommandDeletionException { if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), "deleteAll")); } final QueryOptions queryOptions = new QueryOptions(0, 100, SPlatformCommand.class, "id", OrderByType.ASC); List<SPlatformCommand> sPlatformCommands = null; do { try { sPlatformCommands = getPlatformCommands(queryOptions); } catch (final SPlatformCommandGettingException e) { if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogOnExceptionMethod(this.getClass(), "deleteAll", e)); } throw new SPlatformCommandDeletionException(e); } for (final SPlatformCommand sPlatformCommand : sPlatformCommands) { deletePlatformCommand(sPlatformCommand); } } while (sPlatformCommands.size() == queryOptions.getNumberOfResults()); if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogAfterMethod(this.getClass(), "deleteAll")); } }
@Override public void beforeServicesStart(final PlatformServiceAccessor platformServiceAccessor, final TenantServiceAccessor tenantServiceAccessor) throws RestartException { try { final long tenantId = tenantServiceAccessor.getTenantId(); final TechnicalLoggerService logger = tenantServiceAccessor.getTechnicalLoggerService(); final ArrayList<Long> flownodesToRestart = new ArrayList<>(); flownodesToRestartByTenant.put(tenantId, flownodesToRestart); final FlowNodeInstanceService flowNodeInstanceService = tenantServiceAccessor.getActivityInstanceService(); // using a to low page size (100) causes too many access to the database and causes timeout exception if there are lot of elements. // As we retrieve only the id we can use a greater page size QueryOptions queryOptions = new QueryOptions(0, 50000); List<Long> ids; logInfo(logger, "Restarting flow nodes..."); do { ids = flowNodeInstanceService.getFlowNodeInstanceIdsToRestart(queryOptions); flownodesToRestart.addAll(ids); queryOptions = QueryOptions.getNextPage(queryOptions); } while (ids.size() == queryOptions.getNumberOfResults()); logInfo(logger, "Found " + flownodesToRestart.size() + " flow nodes to restart on tenant " + tenantId); } catch (final SBonitaReadException e) { throw new RestartException("unable to flag elements as to be restarted", e); } }
@Override public void beforeServicesStart(final PlatformServiceAccessor platformServiceAccessor, final TenantServiceAccessor tenantServiceAccessor) throws RestartException { try { final long tenantId = tenantServiceAccessor.getTenantId(); final TechnicalLoggerService logger = tenantServiceAccessor.getTechnicalLoggerService(); final ArrayList<Long> flownodesToRestart = new ArrayList<>(); flownodesToRestartByTenant.put(tenantId, flownodesToRestart); final FlowNodeInstanceService flowNodeInstanceService = tenantServiceAccessor.getActivityInstanceService(); // using a to low page size (100) causes too many access to the database and causes timeout exception if there are lot of elements. // As we retrieve only the id we can use a greater page size QueryOptions queryOptions = new QueryOptions(0, 50000); List<Long> ids; logInfo(logger, "Restarting flow nodes..."); do { ids = flowNodeInstanceService.getFlowNodeInstanceIdsToRestart(queryOptions); flownodesToRestart.addAll(ids); queryOptions = QueryOptions.getNextPage(queryOptions); } while (ids.size() == queryOptions.getNumberOfResults()); logInfo(logger, "Found " + flownodesToRestart.size() + " flow nodes to restart on tenant " + tenantId); } catch (final SBonitaReadException e) { throw new RestartException("unable to flag elements as to be restarted", e); } }
@Override public void beforeServicesStart(final PlatformServiceAccessor platformServiceAccessor, final TenantServiceAccessor tenantServiceAccessor) throws RestartException { final ProcessInstanceService processInstanceService = tenantServiceAccessor.getProcessInstanceService(); final TechnicalLoggerService logger = tenantServiceAccessor.getTechnicalLoggerService(); final long tenantId = tenantServiceAccessor.getTenantId(); final List<Long> ids = new ArrayList<Long>(); processInstancesByTenant.put(tenantId, ids); QueryOptions queryOptions = new QueryOptions(0, 1000, SProcessInstance.class, "id", OrderByType.ASC); try { List<SProcessInstance> processInstances; do { processInstances = processInstanceService.getProcessInstancesInStates(queryOptions, ProcessInstanceState.INITIALIZING, ProcessInstanceState.COMPLETING, ProcessInstanceState.COMPLETED, ProcessInstanceState.ABORTED, ProcessInstanceState.CANCELLED); queryOptions = QueryOptions.getNextPage(queryOptions); for (final SProcessInstance sProcessInstance : processInstances) { ids.add(sProcessInstance.getId()); } } while (processInstances.size() == queryOptions.getNumberOfResults()); logInfo(logger, "Found " + ids.size() + " process to restart on tenant " + tenantId); } catch (final SProcessInstanceReadException e) { handleException(e, "Unable to restart process: can't read process instances"); } }
@Override public void beforeServicesStart(final PlatformServiceAccessor platformServiceAccessor, final TenantServiceAccessor tenantServiceAccessor) throws RestartException { final ProcessInstanceService processInstanceService = tenantServiceAccessor.getProcessInstanceService(); final TechnicalLoggerService logger = tenantServiceAccessor.getTechnicalLoggerService(); final long tenantId = tenantServiceAccessor.getTenantId(); final List<Long> ids = new ArrayList<Long>(); processInstancesByTenant.put(tenantId, ids); QueryOptions queryOptions = new QueryOptions(0, 1000, SProcessInstance.class, "id", OrderByType.ASC); try { List<SProcessInstance> processInstances; do { processInstances = processInstanceService.getProcessInstancesInStates(queryOptions, ProcessInstanceState.INITIALIZING, ProcessInstanceState.COMPLETING, ProcessInstanceState.COMPLETED, ProcessInstanceState.ABORTED, ProcessInstanceState.CANCELLED); queryOptions = QueryOptions.getNextPage(queryOptions); for (final SProcessInstance sProcessInstance : processInstances) { ids.add(sProcessInstance.getId()); } } while (processInstances.size() == queryOptions.getNumberOfResults()); logInfo(logger, "Found " + ids.size() + " process to restart on tenant " + tenantId); } catch (final SProcessInstanceReadException e) { handleException(e, "Unable to restart process: can't read process instances"); } }