Search in sources :

Example 1 with Property

use of org.phoebus.logbook.Property in project phoebus by ControlSystemStudio.

the class LogGroupPropertyTest method testCheckLogEntryGroupProperty.

@Test
public void testCheckLogEntryGroupProperty() {
    Map<String, String> attributes1 = new HashMap<>();
    attributes1.put(LogGroupProperty.ATTRIBUTE_ID, "id value");
    Property property1 = PropertyImpl.of(LogGroupProperty.NAME, attributes1);
    OlogLog logEntry = new OlogLog();
    logEntry.setProperties(Arrays.asList(property1));
    Map<String, String> attributes2 = new HashMap<>();
    attributes1.put("another attr", "value");
    Property property2 = PropertyImpl.of("another name", attributes2);
    OlogLog logEntry2 = new OlogLog();
    logEntry2.setProperties(Arrays.asList(property2));
    try {
        Property property = LogGroupProperty.getLogEntryGroupProperty(Arrays.asList(logEntry, logEntry2));
        assertEquals("id value", property.getAttributes().get(LogGroupProperty.ATTRIBUTE_ID));
    } catch (LogbookException e) {
        fail();
    }
}
Also used : HashMap(java.util.HashMap) LogbookException(org.phoebus.logbook.LogbookException) Property(org.phoebus.logbook.Property) Test(org.junit.Test)

Example 2 with Property

use of org.phoebus.logbook.Property in project phoebus by ControlSystemStudio.

the class LogPropertiesController method getProperties.

/**
 * @return The list of logentry properties
 */
public List<Property> getProperties() {
    List<Property> treeProperties = new ArrayList<>();
    treeTableView.getRoot().getChildren().stream().forEach(node -> {
        Map<String, String> att = node.getChildren().stream().map(TreeItem::getValue).collect(Collectors.toMap(PropertyTreeNode::getName, (PropertyTreeNode prop) -> prop.getValue() == null ? "" : prop.getValue()));
        Property property = PropertyImpl.of(node.getValue().getName(), att);
        treeProperties.add(property);
    });
    return treeProperties;
}
Also used : SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Property(org.phoebus.logbook.Property) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty)

Example 3 with Property

use of org.phoebus.logbook.Property in project phoebus by ControlSystemStudio.

the class LogGroupPropertyTest method testHasLogGroup.

@Test
public void testHasLogGroup() {
    Map<String, String> attributes1 = new HashMap<>();
    attributes1.put(LogGroupProperty.ATTRIBUTE_ID, "id value");
    Property property1 = PropertyImpl.of(LogGroupProperty.NAME, attributes1);
    Map<String, String> attributes2 = new HashMap<>();
    attributes2.put("whatever", "id value");
    Property property2 = PropertyImpl.of("whatever", attributes2);
    OlogLog logEntry = new OlogLog();
    logEntry.setProperties(Arrays.asList(property1, property2));
    assertEquals("id value", LogGroupProperty.getLogGroupProperty(logEntry).get().getAttributes().get(LogGroupProperty.ATTRIBUTE_ID));
}
Also used : HashMap(java.util.HashMap) Property(org.phoebus.logbook.Property) Test(org.junit.Test)

Example 4 with Property

use of org.phoebus.logbook.Property in project phoebus by ControlSystemStudio.

the class LogGroupPropertyTest method testCheckLogEntryGroupPropertyNoEntryHasProperties.

@Test
public void testCheckLogEntryGroupPropertyNoEntryHasProperties() {
    Map<String, String> attributes1 = new HashMap<>();
    attributes1.put("attr", "id value");
    Property property1 = PropertyImpl.of("some name", attributes1);
    OlogLog logEntry = new OlogLog();
    logEntry.setProperties(Arrays.asList(property1));
    Map<String, String> attributes2 = new HashMap<>();
    attributes1.put("another attr", "value");
    Property property2 = PropertyImpl.of("another name", attributes2);
    OlogLog logEntry2 = new OlogLog();
    logEntry2.setProperties(Arrays.asList(property2));
    try {
        Property property = LogGroupProperty.getLogEntryGroupProperty(Arrays.asList(logEntry, logEntry2));
        assertNotNull(property.getAttributes().get(LogGroupProperty.ATTRIBUTE_ID));
    } catch (LogbookException e) {
        fail();
    }
}
Also used : HashMap(java.util.HashMap) LogbookException(org.phoebus.logbook.LogbookException) Property(org.phoebus.logbook.Property) Test(org.junit.Test)

Example 5 with Property

use of org.phoebus.logbook.Property in project phoebus by ControlSystemStudio.

the class LogGroupPropertyTest method testHasNotLogGroup1.

@Test
public void testHasNotLogGroup1() {
    Map<String, String> attributes1 = new HashMap<>();
    attributes1.put(LogGroupProperty.ATTRIBUTE_ID, "");
    Property property1 = PropertyImpl.of(LogGroupProperty.NAME, attributes1);
    OlogLog logEntry = new OlogLog();
    logEntry.setProperties(Arrays.asList(property1));
    assertTrue(LogGroupProperty.getLogGroupProperty(logEntry).isEmpty());
}
Also used : HashMap(java.util.HashMap) Property(org.phoebus.logbook.Property) Test(org.junit.Test)

Aggregations

Property (org.phoebus.logbook.Property)21 HashMap (java.util.HashMap)10 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)5 BooleanProperty (javafx.beans.property.BooleanProperty)5 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)5 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)5 FXMLLoader (javafx.fxml.FXMLLoader)5 Scene (javafx.scene.Scene)5 LogClient (org.phoebus.logbook.LogClient)5 LogEntry (org.phoebus.logbook.LogEntry)5 LogbookException (org.phoebus.logbook.LogbookException)5 VBox (javafx.scene.layout.VBox)4 IOException (java.io.IOException)3 ResourceBundle (java.util.ResourceBundle)3 Collectors (java.util.stream.Collectors)3 FXML (javafx.fxml.FXML)3 Logbook (org.phoebus.logbook.Logbook)3 Tag (org.phoebus.logbook.Tag)3 Arrays (java.util.Arrays)2