public ProcessTreeTableModel(CategoryService categoryService, DashboardEventPublisher dashboardEventPublisher) { super(new DefaultMutableTreeTableNode()); this.categoryService = categoryService; this.dashboardEventPublisher = dashboardEventPublisher; this.fixColumns = Arrays.stream(ProcessTreeTableColumn.values()) .map(ProcessTreeTableColumn::getVisibleName) .collect(Collectors.toUnmodifiableList()); this.processList = new ArrayList<>(); }
@Override public List<AbstractUserEvent> read() { synchronized (userEvents) { if (userEvents.isEmpty()) { Path logsDirectory = sessionSettingsProvider.getLogsDirectory(); Path userEventsFile = logsDirectory.resolve("user.events.log"); try (Stream<String> lines = Files.lines(userEventsFile)) { userEvents.addAll(lines .map(this::convertLineToAbstractUserEvent) .map(AbstractUserEvent.class::cast) .sorted(Comparator.comparingLong(AbstractEvent::getTimestamp)) .collect(Collectors.toUnmodifiableList())); } catch (IOException e) { throw new RuntimeException("Must not happen", e); } } } return userEvents; }
private List<Cookie> parseCookies() { var cookieValues = getHeaders(HeaderNames.SET_COOKIE); // hope timestamp do not diff too much var createTime = Instant.now(); return cookieValues.stream() .flatMap(v -> HttpCookie.parse(v).stream()) .map(c -> Cookies.ofHttpCookie(createTime, c)) .collect(toUnmodifiableList()); }
@Override public List<CategoryState> getCategoryState(String process, List<String> groupTitle) { String category = getCategory(process, groupTitle); return getCategories() .stream() .map(c -> new CategoryState(c, c.equals(category))) .collect(Collectors.toUnmodifiableList()); }
@Override public List<Record> findRecords(Record.Type type, RecordData data) { return records.values().stream() .filter(record -> record.type() == type && record.data().equals(data)) .collect(Collectors.toUnmodifiableList()); }
@Override public List<CategoryState> getCategoryState(String process) { String category = getCategory(process); return getCategories() .stream() .map(c -> new CategoryState(c, c.equals(category))) .collect(Collectors.toUnmodifiableList()); }
@Override public List<Record> findRecords(Record.Type type, RecordName name) { return records.values().stream() .filter(record -> record.type() == type && record.name().equals(name)) .collect(Collectors.toUnmodifiableList()); }