private boolean noPendingTask(DbSession dbSession, ComponentDto rootComponent) { return dbClient.ceQueueDao().selectByComponentUuid(dbSession, rootComponent.uuid()).isEmpty(); }
@Override public void handle(Request wsRequest, Response wsResponse) throws Exception { try (DbSession dbSession = dbClient.openSession(false)) { ComponentDto component = loadComponent(dbSession, wsRequest); userSession.checkComponentPermission(UserRole.USER, component); List<CeQueueDto> queueDtos = dbClient.ceQueueDao().selectByComponentUuid(dbSession, component.uuid()); CeTaskQuery activityQuery = new CeTaskQuery() .setComponentUuid(component.uuid()) .setOnlyCurrents(true); List<CeActivityDto> activityDtos = dbClient.ceActivityDao().selectByQuery(dbSession, activityQuery, forPage(1).andSize(1)); Ce.ComponentResponse.Builder wsResponseBuilder = ComponentResponse.newBuilder(); wsResponseBuilder.addAllQueue(formatter.formatQueue(dbSession, queueDtos)); if (activityDtos.size() == 1) { wsResponseBuilder.setCurrent(formatter.formatActivity(dbSession, activityDtos.get(0), null)); } writeProtobuf(wsResponseBuilder.build(), wsRequest, wsResponse); } }