use of org.opennms.netmgt.topology.persistence.api.VertexRefEntity in project opennms by OpenNMS.
the class LayoutDaoIT method createVertexPosition.
private VertexPositionEntity createVertexPosition(String vertexNamespace, String vertexId, int x, int y) {
VertexPositionEntity vertexPositionEntity = new VertexPositionEntity();
vertexPositionEntity.setPosition(new PointEntity(x, y));
vertexPositionEntity.setVertexRef(new VertexRefEntity(vertexNamespace, vertexId));
return vertexPositionEntity;
}
use of org.opennms.netmgt.topology.persistence.api.VertexRefEntity in project opennms by OpenNMS.
the class LayoutManager method isPersistedLayoutEqualToCurrentLayout.
public boolean isPersistedLayoutEqualToCurrentLayout(Graph graph) {
LayoutEntity layoutEntity = loadLayout(graph);
if (layoutEntity != null) {
// If we have a layout persisted, we verify if it is equal.
final Map<VertexRef, Point> persistedLocations = layoutEntity.getVertexPositions().stream().collect(Collectors.toMap((Function<VertexPositionEntity, VertexRef>) vertexPositionEntity -> {
VertexRefEntity vertexRefEntity = vertexPositionEntity.getVertexRef();
return new DefaultVertexRef(vertexRefEntity.getNamespace(), vertexRefEntity.getId());
}, vertexPositionEntity -> {
PointEntity position = vertexPositionEntity.getPosition();
return new Point(position.getX(), position.getY());
}));
// The locations may contain elements currently not visible, we filter them
final Map<VertexRef, Point> manualLocations = new HashMap<>();
graph.getLayout().getLocations().forEach((key, value) -> {
if (persistedLocations.containsKey(key)) {
// layoutEntity stores int coordinates, but manualLocations are stored as double.
// Convert to int to make it comparable.
manualLocations.put(key, new Point((int) value.getX(), (int) value.getY()));
}
});
final boolean layoutIsEqual = manualLocations.equals(persistedLocations);
return layoutIsEqual;
}
// We don't have anything persisted, so they are not equal
return false;
}
use of org.opennms.netmgt.topology.persistence.api.VertexRefEntity in project opennms by OpenNMS.
the class LayoutManager method toVertexRefEntity.
public static VertexRefEntity toVertexRefEntity(VertexRef vertexRef) {
Objects.requireNonNull(vertexRef);
VertexRefEntity vertexRefEntity = new VertexRefEntity();
vertexRefEntity.setId(vertexRef.getId());
vertexRefEntity.setNamespace(vertexRef.getNamespace());
return vertexRefEntity;
}
Aggregations