org.activiti.engine.query.Query Java Examples
The following examples show how to use
org.activiti.engine.query.Query.
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: PurchaseApplyUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 6 votes |
/** * 查询用户任务数 * * @param user * @return */ public long getUserHistoryTaskCount(@RequestBody AuditUser user) { HistoryService historyService = processEngine.getHistoryService(); // Query query = historyService.createHistoricTaskInstanceQuery() // .processDefinitionKey("complaint") // .taskAssignee(user.getUserId()); HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery() .processDefinitionKey("resourceEnter") .taskAssignee(user.getUserId()); if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) { historicTaskInstanceQuery.taskName("resourceEnter"); } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) { historicTaskInstanceQuery.taskName("resourceEnterDealUser"); } Query query = historicTaskInstanceQuery; return query.count(); }
Example #2
Source File: ComplaintUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 6 votes |
/** * 查询用户任务数 * * @param user * @return */ public long getUserHistoryTaskCount(@RequestBody AuditUser user) { HistoryService historyService = processEngine.getHistoryService(); // Query query = historyService.createHistoricTaskInstanceQuery() // .processDefinitionKey("complaint") // .taskAssignee(user.getUserId()); HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery() .processDefinitionKey(getWorkflowDto(user.getCommunityId())) .taskAssignee(user.getUserId()); if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) { historicTaskInstanceQuery.taskName("complaint"); } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) { historicTaskInstanceQuery.taskName("complaitDealUser"); } Query query = historicTaskInstanceQuery; return query.count(); }
Example #3
Source File: ActivitiQuerySpecMapper.java From crnk-framework with Apache License 2.0 | 6 votes |
private static void applySortSpec(Query activitiQuery, QuerySpec querySpec) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { for (SortSpec orderSpec : querySpec.getSort()) { List<String> attributePath = orderSpec.getAttributePath(); PreconditionUtil.verify(attributePath.size() == 1, "nested attribute paths not supported"); String attributeName = attributePath.get(0); String orderbyMethodName = "orderBy" + firstToUpper(addTypePrefix(querySpec.getResourceClass(), attributeName)); Method method = activitiQuery.getClass().getMethod(orderbyMethodName); method.invoke(activitiQuery); if (orderSpec.getDirection() == Direction.DESC) { activitiQuery.desc(); } else { activitiQuery.asc(); } } }
Example #4
Source File: QueryUtils.java From hsweb-framework with Apache License 2.0 | 6 votes |
public static <U, R, T extends Query<?, U>> PagerResult<R> doQuery(T query, QueryParamEntity entity, Function<U, R> mapping, BiConsumer<Term, T> notFound) { applyQueryParam(query, entity, notFound); int total = (int) query.count(); if (total == 0) { return PagerResult.empty(); } entity.rePaging(total); List<R> list = query.listPage(entity.getPageIndex(), entity.getPageSize() * (entity.getPageIndex() + 1)) .stream() .map(mapping) .filter(Objects::nonNull) .collect(Collectors.toList()); return PagerResult.of(total, list, entity); }
Example #5
Source File: PurchaseApplyUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
/** * 获取用户审批的任务 * * @param user 用户信息 */ public List<PurchaseApplyDto> getUserHistoryTasks(@RequestBody AuditUser user) { HistoryService historyService = processEngine.getHistoryService(); HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery() .processDefinitionKey("resourceEnter") .taskAssignee(user.getUserId()); if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) { historicTaskInstanceQuery.taskName("resourceEnter"); } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) { historicTaskInstanceQuery.taskName("resourceEnterDealUser"); } Query query = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().desc(); List<HistoricTaskInstance> list = null; if (user.getPage() != PageDto.DEFAULT_PAGE) { list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow()); } else { list = query.list(); } List<String> complaintIds = new ArrayList<>(); for (HistoricTaskInstance task : list) { String processInstanceId = task.getProcessInstanceId(); //3.使用流程实例,查询 HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); //4.使用流程实例对象获取BusinessKey String business_key = pi.getBusinessKey(); complaintIds.add(business_key); } //查询 投诉信息 // ComplaintDto complaintDto = new ComplaintDto(); // complaintDto.setStoreId(user.getStoreId()); // complaintDto.setCommunityId(user.getCommunityId()); // complaintDto.setComplaintIds(complaintIds.toArray(new String[complaintIds.size()])); // List<ComplaintDto> tmpComplaintDtos = complaintInnerServiceSMOImpl.queryComplaints(complaintDto); return null; }
Example #6
Source File: ComplaintUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
/** * 获取用户审批的任务 * * @param user 用户信息 */ public List<ComplaintDto> getUserHistoryTasks(@RequestBody AuditUser user) { HistoryService historyService = processEngine.getHistoryService(); HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery() .processDefinitionKey(getWorkflowDto(user.getCommunityId())) .taskAssignee(user.getUserId()); if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) { historicTaskInstanceQuery.taskName("complaint"); } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) { historicTaskInstanceQuery.taskName("complaitDealUser"); } Query query = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().desc(); List<HistoricTaskInstance> list = null; if (user.getPage() != PageDto.DEFAULT_PAGE) { list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow()); } else { list = query.list(); } List<String> complaintIds = new ArrayList<>(); for (HistoricTaskInstance task : list) { String processInstanceId = task.getProcessInstanceId(); //3.使用流程实例,查询 HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); //4.使用流程实例对象获取BusinessKey String business_key = pi.getBusinessKey(); complaintIds.add(business_key); } //查询 投诉信息 ComplaintDto complaintDto = new ComplaintDto(); complaintDto.setStoreId(user.getStoreId()); complaintDto.setCommunityId(user.getCommunityId()); complaintDto.setComplaintIds(complaintIds.toArray(new String[complaintIds.size()])); List<ComplaintDto> tmpComplaintDtos = complaintInnerServiceSMOImpl.queryComplaints(complaintDto); return tmpComplaintDtos; }
Example #7
Source File: ActivitiQuerySpecMapper.java From crnk-framework with Apache License 2.0 | 5 votes |
private static Optional<Method> getMethod(Class<? extends Query> clazz, String methodName) { for (Method method : clazz.getMethods()) { if (methodName.equals(method.getName())) { return Optional.of(method); } } return Optional.empty(); }
Example #8
Source File: AbstractPaginateList.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
/** * uses the pagination parameters form the request and makes sure to order the result and set all pagination attributes for the response to render * * @param req * The request containing the pagination parameters * @param query * The query to get the paged list from * @param listName * The name model attribute name to use for the result list * @param model * The model to put the list and the pagination attributes in * @param defaultSort * THe default sort column (the rest attribute) that later will be mapped to an internal engine name */ @SuppressWarnings("rawtypes") public DataResponse paginateList(Map<String, String> requestParams, PaginateRequest paginateRequest, Query query, String defaultSort, Map<String, QueryProperty> properties) { if (paginateRequest == null) { paginateRequest = new PaginateRequest(); } // In case pagination request is incomplete, fill with values found in // URL if possible if (paginateRequest.getStart() == null) { paginateRequest.setStart(RequestUtil.getInteger(requestParams, "start", 0)); } if (paginateRequest.getSize() == null) { paginateRequest.setSize(RequestUtil.getInteger(requestParams, "size", 10)); } if (paginateRequest.getOrder() == null) { paginateRequest.setOrder(requestParams.get("order")); } if (paginateRequest.getSort() == null) { paginateRequest.setSort(requestParams.get("sort")); } // Use defaults for paging, if not set in the PaginationRequest, nor in // the URL Integer start = paginateRequest.getStart(); if (start == null || start < 0) { start = 0; } Integer size = paginateRequest.getSize(); if (size == null || size < 0) { size = 10; } String sort = paginateRequest.getSort(); if (sort == null) { sort = defaultSort; } String order = paginateRequest.getOrder(); if (order == null) { order = "asc"; } // Sort order if (sort != null && !properties.isEmpty()) { QueryProperty qp = properties.get(sort); if (qp == null) { throw new ActivitiIllegalArgumentException("Value for param 'sort' is not valid, '" + sort + "' is not a valid property"); } ((AbstractQuery) query).orderBy(qp); if (order.equals("asc")) { query.asc(); } else if (order.equals("desc")) { query.desc(); } else { throw new ActivitiIllegalArgumentException("Value for param 'order' is not valid : '" + order + "', must be 'asc' or 'desc'"); } } // Get result and set pagination parameters List list = processList(query.listPage(start, size)); DataResponse response = new DataResponse(); response.setStart(start); response.setSize(list.size()); response.setSort(sort); response.setOrder(order); response.setTotal(query.count()); response.setData(list); return response; }
Example #9
Source File: ProcessInstanceResourceRepository.java From crnk-framework with Apache License 2.0 | 4 votes |
@Override protected Query<ProcessInstanceQuery, ProcessInstance> createQuery() { return runtimeService.createProcessInstanceQuery().includeProcessVariables(); }
Example #10
Source File: ActivitiRepositoryBase.java From crnk-framework with Apache License 2.0 | 4 votes |
@Override public ResourceList<T> findAll(QuerySpec querySpec) { Query activitiQuery = createQuery(); List list = ActivitiQuerySpecMapper.find(activitiQuery, querySpec, baseFilters); return mapToResources(list); }
Example #11
Source File: QueryUtils.java From hsweb-framework with Apache License 2.0 | 4 votes |
public static <U, T extends Query<?, U>> PagerResult<U> doQuery(T query, QueryParamEntity entity) { return doQuery(query, entity, Function.identity()); }
Example #12
Source File: QueryUtils.java From hsweb-framework with Apache License 2.0 | 4 votes |
public static <U, R, T extends Query<?, U>> PagerResult<R> doQuery(T query, QueryParamEntity entity, Function<U, R> mapping) { return doQuery(query, entity, mapping, (term, tuQuery) -> log.warn("不支持的查询条件:{} {}", term.getTermType(), term.getColumn())); }
Example #13
Source File: AbstractPaginateList.java From activiti6-boot2 with Apache License 2.0 | 2 votes |
/** * uses the pagination parameters from the request and makes sure to order the result and set all pagination attributes for the response to render * * @param req * The request containing the pagination parameters * @param query * The query to get the paged list from * @param listName * The name model attribute name to use for the result list * @param model * The model to put the list and the pagination attributes in * @param defaultSort * THe default sort column (the rest attribute) that later will be mapped to an internal engine name */ @SuppressWarnings("rawtypes") public DataResponse paginateList(Map<String, String> requestParams, Query query, String defaultSort, Map<String, QueryProperty> properties) { return paginateList(requestParams, null, query, defaultSort, properties); }
Example #14
Source File: ActivitiRepositoryBase.java From crnk-framework with Apache License 2.0 | votes |
protected abstract Query createQuery();