@CheckForNull private Long searchLastSnapshotDate(DbSession dbSession, ComponentDto component) { Optional<SnapshotDto> lastSnapshot = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.projectUuid()); return lastSnapshot.isPresent() ? lastSnapshot.get().getBuildDate() : null; }
@CheckForNull private Date findCreatedAfterFromComponentUuid(DbSession dbSession, ComponentDto component) { Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.uuid()); return snapshot.map(s -> longToDate(s.getPeriodDate())).orElse(null); }
private ShowWsResponse doHandle(Request request) { try (DbSession dbSession = dbClient.openSession(false)) { ComponentDto component = loadComponent(dbSession, request); userSession.checkComponentPermission(UserRole.USER, component); Optional<SnapshotDto> lastAnalysis = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.projectUuid()); List<ComponentDto> ancestors = dbClient.componentDao().selectAncestors(dbSession, component); OrganizationDto organizationDto = componentFinder.getOrganization(dbSession, component); return buildResponse(component, organizationDto, ancestors, lastAnalysis); } }
@Override public void handle(Request request, Response response) { try (DbSession dbSession = dbClient.openSession(false)) { ComponentDto file = loadComponent(dbSession, request); Supplier<Optional<Long>> periodDateSupplier = () -> dbClient.snapshotDao() .selectLastAnalysisByComponentUuid(dbSession, file.projectUuid()) .map(SnapshotDto::getPeriodDate); userSession.checkComponentPermission(UserRole.CODEVIEWER, file); int from = request.mandatoryParamAsInt(PARAM_FROM); int to = MoreObjects.firstNonNull(request.paramAsInt(PARAM_TO), Integer.MAX_VALUE); Iterable<DbFileSources.Line> lines = checkFoundWithOptional(sourceService.getLines(dbSession, file.uuid(), from, to), "No source found for file '%s'", file.getDbKey()); try (JsonWriter json = response.newJsonWriter()) { json.beginObject(); writeSource(lines, json, isMemberOfOrganization(dbSession, file), periodDateSupplier); json.endObject(); } } }
@CheckForNull private Long searchLastSnapshotDate(DbSession dbSession, ComponentDto component) { Optional<SnapshotDto> lastSnapshot = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.projectUuid()); return lastSnapshot.isPresent() ? lastSnapshot.get().getBuildDate() : null; }
@CheckForNull private Date findCreatedAfterFromComponentUuid(DbSession dbSession, ComponentDto component) { Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.uuid()); return snapshot.map(s -> longToDate(s.getPeriodDate())).orElse(null); }
private ShowWsResponse doHandle(Request request) { try (DbSession dbSession = dbClient.openSession(false)) { ComponentDto component = loadComponent(dbSession, request); userSession.checkComponentPermission(UserRole.USER, component); Optional<SnapshotDto> lastAnalysis = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.projectUuid()); List<ComponentDto> ancestors = dbClient.componentDao().selectAncestors(dbSession, component); OrganizationDto organizationDto = componentFinder.getOrganization(dbSession, component); return buildResponse(component, organizationDto, ancestors, lastAnalysis); } }