11package org .phoebus .applications .logbook ;
22
3+ import org .phoebus .logbook .Attachment ;
4+ import org .phoebus .logbook .AttachmentImpl ;
5+ import org .phoebus .logbook .LogClient ;
6+ import org .phoebus .logbook .LogEntry ;
7+ import org .phoebus .logbook .LogEntryImpl ;
8+ import org .phoebus .logbook .LogEntryImpl .LogEntryBuilder ;
9+ import org .phoebus .logbook .LogEntryLevel ;
10+ import org .phoebus .logbook .Logbook ;
11+ import org .phoebus .logbook .LogbookException ;
12+ import org .phoebus .logbook .LogbookImpl ;
13+ import org .phoebus .logbook .Property ;
14+ import org .phoebus .logbook .PropertyImpl ;
15+ import org .phoebus .logbook .SearchResult ;
16+ import org .phoebus .logbook .Tag ;
17+ import org .phoebus .logbook .TagImpl ;
18+
319import java .io .File ;
420import java .io .FileInputStream ;
521import java .io .FileNotFoundException ;
622import java .io .IOException ;
723import java .io .InputStream ;
824import java .net .URLConnection ;
9- import java .nio .file .CopyOption ;
1025import java .nio .file .Files ;
11- import java .nio .file .StandardCopyOption ;
1226import java .time .Instant ;
1327import java .util .Arrays ;
1428import java .util .Collection ;
2337import java .util .stream .Collectors ;
2438import java .util .stream .Stream ;
2539
26- import org .phoebus .logbook .Attachment ;
27- import org .phoebus .logbook .AttachmentImpl ;
28- import org .phoebus .logbook .LogClient ;
29- import org .phoebus .logbook .LogEntry ;
30- import org .phoebus .logbook .LogEntryImpl ;
31- import org .phoebus .logbook .LogEntryImpl .LogEntryBuilder ;
32- import org .phoebus .logbook .Logbook ;
33- import org .phoebus .logbook .LogbookException ;
34- import org .phoebus .logbook .LogbookImpl ;
35- import org .phoebus .logbook .Property ;
36- import org .phoebus .logbook .PropertyImpl ;
37- import org .phoebus .logbook .SearchResult ;
38- import org .phoebus .logbook .Tag ;
39- import org .phoebus .logbook .TagImpl ;
40-
4140/**
4241 * A logbook which maintains logentries in memory. It is mainly for testing and debugging purpose.
4342 */
@@ -47,16 +46,16 @@ public class InMemoryLogClient implements LogClient {
4746 private final Map <Long , LogEntry > logEntries ;
4847
4948 private final Collection <Logbook > logbooks = Arrays .asList (LogbookImpl .of ("Controls" ),
50- LogbookImpl .of ("Commissioning" ),
51- LogbookImpl .of ("Scratch Pad" ));
49+ LogbookImpl .of ("Commissioning" ),
50+ LogbookImpl .of ("Scratch Pad" ));
5251 private final Collection <Tag > tags = Arrays .asList (TagImpl .of ("Operations" ),
53- TagImpl .of ("Alarm" ),
54- TagImpl .of ("Example" ));
52+ TagImpl .of ("Alarm" ),
53+ TagImpl .of ("Example" ));
5554 private final List <String > levels = Arrays .asList ("Urgent" , "Suggestion" , "Info" , "Request" , "Problem" );
5655
5756 private static List <Property > inMemoryProperties () {
5857 Map <String , String > tracAttributes = new HashMap <>();
59- Property track = PropertyImpl .of ("Track" ,tracAttributes );
58+ Property track = PropertyImpl .of ("Track" , tracAttributes );
6059 Map <String , String > experimentAttributes = new HashMap <>();
6160 Property experimentProperty = PropertyImpl .of ("Experiment" , experimentAttributes );
6261 Map <String , String > resourceAttributes = new HashMap <>();
@@ -80,8 +79,8 @@ public InMemoryLogClient() {
8079 }
8180
8281 @ Override
83- public Collection <String > listLevels () {
84- return levels ;
82+ public Collection <LogEntryLevel > listLevels () {
83+ return levels . stream (). map ( l -> new LogEntryLevel ( l , false )). toList () ;
8584 }
8685
8786 @ Override
@@ -110,6 +109,7 @@ public LogEntry getLog(Long logId) {
110109 }
111110
112111 String prefix = "phoebus_tmp_file" ;
112+
113113 @ Override
114114 public LogEntry set (LogEntry log ) {
115115 long id = logIdCounter .incrementAndGet ();
@@ -155,12 +155,12 @@ public SearchResult search(Map<String, String> map) {
155155 @ Override
156156 public List <LogEntry > findLogs (Map <String , String > map ) {
157157 Stream <LogEntry > searchStream = logEntries .values ().stream ();
158- if (map .containsKey ("start" )) {
158+ if (map .containsKey ("start" )) {
159159 searchStream = searchStream .filter (log -> {
160160 return log .getCreatedDate ().isAfter (Instant .ofEpochSecond (Long .valueOf (map .get ("start" ))));
161161 });
162162 }
163- if (map .containsKey ("end" )) {
163+ if (map .containsKey ("end" )) {
164164 searchStream = searchStream .filter (log -> {
165165 return log .getCreatedDate ().isBefore (Instant .ofEpochSecond (Long .valueOf (map .get ("end" ))));
166166 });
@@ -169,7 +169,7 @@ public List<LogEntry> findLogs(Map<String, String> map) {
169169 final String searchString = map .get ("search" ).replaceAll ("\\ *" , "" );
170170 if (!searchString .isEmpty ()) {
171171 searchStream = searchStream .filter (log -> {
172- return log .getDescription ().contains (searchString )|| log .getTitle ().contains (searchString );
172+ return log .getDescription ().contains (searchString ) || log .getTitle ().contains (searchString );
173173 });
174174 }
175175 }
0 commit comments