Search in sources :

Example 6 with LayoutEntity

use of org.opennms.netmgt.topology.persistence.api.LayoutEntity in project opennms by OpenNMS.

the class LayoutManager method loadLayout.

public LayoutEntity loadLayout(Graph graph) {
    LayoutEntity layoutEntity = findBy(graph);
    if (layoutEntity != null) {
        layoutEntity.setLastUsed(new Date());
        layoutDao.saveOrUpdate(layoutEntity);
    }
    return layoutEntity;
}
Also used : LayoutEntity(org.opennms.netmgt.topology.persistence.api.LayoutEntity) Date(java.util.Date)

Example 7 with LayoutEntity

use of org.opennms.netmgt.topology.persistence.api.LayoutEntity in project opennms by OpenNMS.

the class ManualLayoutAlgorithmTest method verifyLayoutCoordinatesHavePriority.

/*
     * If persisted layout is defined, verify that it has priority.
     */
@Test
public void verifyLayoutCoordinatesHavePriority() {
    final GraphProvider graphProvider = new SimpleGraphBuilder("dummy").vertex("vertex1").vX(1).vY(1).get();
    final ManualTest test = new ManualTest(graphProvider);
    final LayoutEntity persistedLayout = new LayoutEntity();
    int x = 5;
    int y = 5;
    for (VertexRef eachVertex : graphProvider.getVertices()) {
        VertexPositionEntity vertexPositionEntity = new VertexPositionEntity();
        vertexPositionEntity.setVertexRef(LayoutManager.toVertexRefEntity(eachVertex));
        vertexPositionEntity.setPosition(new PointEntity(x++, y++));
        persistedLayout.addVertexPosition(vertexPositionEntity);
    }
    Mockito.when(test.layoutManager.loadLayout(test.graph)).thenReturn(persistedLayout);
    new ManualLayoutAlgorithm(test.layoutManager).updateLayout(test.graph);
    Assert.assertEquals(ImmutableMap.builder().put(new DefaultVertexRef("dummy", "vertex1"), new Point(5, 5)).build(), test.layout.getLocations());
}
Also used : VertexPositionEntity(org.opennms.netmgt.topology.persistence.api.VertexPositionEntity) SimpleGraphBuilder(org.opennms.features.topology.api.support.SimpleGraphBuilder) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) GraphProvider(org.opennms.features.topology.api.topo.GraphProvider) LayoutEntity(org.opennms.netmgt.topology.persistence.api.LayoutEntity) PointEntity(org.opennms.netmgt.topology.persistence.api.PointEntity) Point(org.opennms.features.topology.api.Point) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) Point(org.opennms.features.topology.api.Point) Test(org.junit.Test)

Aggregations

LayoutEntity (org.opennms.netmgt.topology.persistence.api.LayoutEntity)7 Date (java.util.Date)4 Point (org.opennms.features.topology.api.Point)4 PointEntity (org.opennms.netmgt.topology.persistence.api.PointEntity)4 Collection (java.util.Collection)3 Graph (org.opennms.features.topology.api.Graph)3 Layout (org.opennms.features.topology.api.Layout)3 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)3 Vertex (org.opennms.features.topology.api.topo.Vertex)3 VertexRef (org.opennms.features.topology.api.topo.VertexRef)3 VertexPositionEntity (org.opennms.netmgt.topology.persistence.api.VertexPositionEntity)3 Hashing (com.google.common.hash.Hashing)2 StandardCharsets (java.nio.charset.StandardCharsets)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2