use of org.phoebus.logbook.LogEntry in project phoebus by ControlSystemStudio.
the class LogEntryCalenderDemo method start.
@Override
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(this.getClass().getResource("LogEntryCalenderView.fxml"));
loader.setControllerFactory(clazz -> {
try {
if (clazz.isAssignableFrom(LogEntryCalenderViewController.class)) {
return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
} else if (clazz.isAssignableFrom(AdvancedSearchViewController.class)) {
return clazz.getConstructor(LogClient.class).newInstance(getLogClient());
}
} catch (Exception e) {
Logger.getLogger(LogEntryEditorStage.class.getName()).log(Level.SEVERE, "Failed to construct controller for log calendar view", e);
}
return null;
});
loader.load();
LogEntryCalenderViewController controller = loader.getController();
Parent root = loader.getRoot();
primaryStage.setScene(new Scene(root, 400, 400));
primaryStage.show();
List<LogEntry> logs = new ArrayList<LogEntry>();
Set<Tag> tags = new HashSet<Tag>();
tags.add(TagImpl.of("tag1", "active"));
tags.add(TagImpl.of("tag2", "active"));
Set<Logbook> logbooks = new HashSet<Logbook>();
logbooks.add(LogbookImpl.of("logbook1", "active"));
logbooks.add(LogbookImpl.of("logbook2", "active"));
String path = "C:\\Users\\Kunal Shroff\\Pictures\\screenshot-git\\log-att";
File folder = new File(path);
List<File> listOfFiles = Arrays.asList(folder.listFiles());
for (int i = 0; i < 10; i++) {
LogEntryBuilder lb = LogEntryBuilder.log().owner("Owner").title("log " + i).description("First line for log " + i).createdDate(Instant.now().minusSeconds(i * 60 * 60)).inLogbooks(logbooks).withTags(tags);
StringBuilder sb = new StringBuilder();
for (int j = 0; j < i; j++) {
sb.append("Some additional log text");
}
lb.appendDescription(sb.toString());
listOfFiles.forEach(file -> {
try {
lb.attach(AttachmentImpl.of(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
});
logs.add(lb.build());
}
controller.setLogs(logs);
}
use of org.phoebus.logbook.LogEntry in project phoebus by ControlSystemStudio.
the class LogEntryGroupTest method testGetLogEntryGroupProperty1.
@Test
public void testGetLogEntryGroupProperty1() {
Map<String, String> attributes = new HashMap<>();
String uuid = UUID.randomUUID().toString();
attributes.put(LogGroupProperty.ATTRIBUTE_ID, uuid);
Property logGroupProperty = new OlogProperty(LogGroupProperty.NAME, attributes);
LogEntry logEntry1 = LogEntryBuilder.log().property(logGroupProperty).description("").build();
assertTrue(LogGroupProperty.getLogGroupProperty(logEntry1).isPresent());
logEntry1 = LogEntryBuilder.log().description("").build();
assertFalse(LogGroupProperty.getLogGroupProperty(logEntry1).isPresent());
logGroupProperty = new OlogProperty("Some other name", attributes);
logEntry1 = LogEntryBuilder.log().property(logGroupProperty).description("").build();
assertFalse(LogGroupProperty.getLogGroupProperty(logEntry1).isPresent());
}
use of org.phoebus.logbook.LogEntry in project phoebus by ControlSystemStudio.
the class LogEntryCalenderViewController method refresh.
private void refresh() {
map = new HashMap<Appointment, LogEntry>();
map = this.logEntries.stream().collect(Collectors.toMap(new Function<LogEntry, Appointment>() {
@Override
public Appointment apply(LogEntry logentry) {
AppointmentImplLocal appointment = new Agenda.AppointmentImplLocal();
appointment.withSummary(logentry.getDescription());
appointment.withDescription(logentry.getDescription());
appointment.withStartLocalDateTime(LocalDateTime.ofInstant(logentry.getCreatedDate(), ZoneId.systemDefault()));
appointment.withEndLocalDateTime(LocalDateTime.ofInstant(logentry.getCreatedDate().plusSeconds(2400), ZoneId.systemDefault()));
List<String> logbookNames = getLogbookNames();
if (logbookNames != null && !logbookNames.isEmpty()) {
int index = logbookNames.indexOf(logentry.getLogbooks().iterator().next().getName());
if (index >= 0 && index <= 22) {
appointment.setAppointmentGroup(appointmentGroupMap.get(String.format("group%02d", (index + 1))));
} else {
appointment.setAppointmentGroup(appointmentGroupMap.get(String.format("group%02d", 23)));
}
}
return appointment;
}
}, new Function<LogEntry, LogEntry>() {
@Override
public LogEntry apply(LogEntry logentry) {
return logentry;
}
}));
agenda.appointments().clear();
agenda.appointments().setAll(map.keySet());
}
use of org.phoebus.logbook.LogEntry in project phoebus by ControlSystemStudio.
the class LogPropertiesEditorDemo method getDummyLogClient.
private LogClient getDummyLogClient() {
return new LogClient() {
@Override
public LogEntry set(LogEntry log) throws LogbookException {
return null;
}
@Override
public LogEntry getLog(Long logId) {
return null;
}
@Override
public Collection<Attachment> listAttachments(Long logId) {
return null;
}
@Override
public List<LogEntry> findLogs(Map<String, String> map) {
return null;
}
@Override
public Collection<LogEntry> listLogs() {
return null;
}
@Override
public Collection<Property> listProperties() {
Map<String, String> experimentAttributes = new HashMap<>();
experimentAttributes.put("id", "1234");
experimentAttributes.put("type", "XPD xray diffraction");
experimentAttributes.put("scan-id", "6789");
Property experimentProperty = PropertyImpl.of("Experiment", experimentAttributes);
return Arrays.asList(experimentProperty);
}
};
}
use of org.phoebus.logbook.LogEntry in project phoebus by ControlSystemStudio.
the class LogEntryCalenderViewController method refresh.
private void refresh() {
map = new HashMap<Appointment, LogEntry>();
map = this.logEntries.stream().collect(Collectors.toMap(new Function<LogEntry, Appointment>() {
@Override
public Appointment apply(LogEntry logentry) {
AppointmentImplLocal appointment = new Agenda.AppointmentImplLocal();
appointment.withSummary(logentry.getDescription());
appointment.withDescription(logentry.getDescription());
appointment.withStartLocalDateTime(LocalDateTime.ofInstant(logentry.getCreatedDate(), ZoneId.systemDefault()));
appointment.withEndLocalDateTime(LocalDateTime.ofInstant(logentry.getCreatedDate().plusSeconds(2400), ZoneId.systemDefault()));
List<String> logbookNames = getLogbookNames();
if (logbookNames != null && !logbookNames.isEmpty()) {
int index = logbookNames.indexOf(logentry.getLogbooks().iterator().next().getName());
if (index >= 0 && index <= 22) {
appointment.setAppointmentGroup(appointmentGroupMap.get(String.format("group%02d", (index + 1))));
} else {
appointment.setAppointmentGroup(appointmentGroupMap.get(String.format("group%02d", 23)));
}
}
return appointment;
}
}, new Function<LogEntry, LogEntry>() {
@Override
public LogEntry apply(LogEntry logentry) {
return logentry;
}
}));
Platform.runLater(() -> {
agenda.appointments().clear();
agenda.appointments().setAll(map.keySet());
});
}
Aggregations