use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class DefaultSelectionContext method deselectVertexRefs.
@Override
public boolean deselectVertexRefs(Collection<? extends VertexRef> vertexRefs) {
Set<VertexRef> oldSet = new HashSet<>();
oldSet.addAll(getSelectedVertexRefs());
for (VertexRef vertexRef : vertexRefs) {
setVertexRefSelected(vertexRef, false);
}
if (oldSet.equals(getSelectedVertexRefs())) {
return false;
} else {
return true;
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class DefaultSelectionContext method selectVertexRefs.
@Override
public boolean selectVertexRefs(Collection<? extends VertexRef> vertexRefs) {
Set<VertexRef> oldSet = new HashSet<>();
oldSet.addAll(getSelectedVertexRefs());
for (VertexRef vertexRef : vertexRefs) {
setVertexRefSelected(vertexRef, true);
}
if (oldSet.equals(getSelectedVertexRefs())) {
return false;
} else {
return true;
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class SavedHistory method getFragment.
public String getFragment() {
final StringBuilder retval = new StringBuilder().append("(").append(m_szl).append("),").append(m_boundBox.fragment()).append(",").append(m_boundBox.getCenter());
// Add a CRC of all of the key-value pairs in m_settings to make the fragment unique
CRC32 settingsCrc = new CRC32();
for (Map.Entry<String, String> entry : m_settings.entrySet()) {
settingsCrc.update(entry.getKey().getBytes(StandardCharsets.UTF_8));
settingsCrc.update(entry.getValue().getBytes(StandardCharsets.UTF_8));
}
retval.append(String.format(",(%X)", settingsCrc.getValue()));
CRC32 locationsCrc = new CRC32();
for (Map.Entry<VertexRef, Point> entry : m_locations.entrySet()) {
locationsCrc.update(entry.getKey().getId().getBytes(StandardCharsets.UTF_8));
// TODO cast to int for now
locationsCrc.update((int) entry.getValue().getX());
locationsCrc.update((int) entry.getValue().getY());
}
retval.append(String.format(",(%X)", locationsCrc.getValue()));
CRC32 selectionsCrc = new CRC32();
for (VertexRef entry : m_selectedVertices) {
selectionsCrc.update(entry.getNamespace().getBytes(StandardCharsets.UTF_8));
selectionsCrc.update(entry.getId().getBytes(StandardCharsets.UTF_8));
}
retval.append(String.format(",(%X)", selectionsCrc.getValue()));
CRC32 focusCrc = new CRC32();
for (VertexRef entry : m_focusVertices) {
focusCrc.update(entry.getNamespace().getBytes(StandardCharsets.UTF_8));
focusCrc.update(entry.getId().getBytes(StandardCharsets.UTF_8));
}
retval.append(String.format(",(%X)", focusCrc.getValue()));
CRC32 historyCrc = new CRC32();
for (SearchResult query : m_searchQueries) {
historyCrc.update(query.toString().getBytes(StandardCharsets.UTF_8));
}
retval.append(String.format(",(%X)", historyCrc.getValue()));
return retval.toString();
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class SavedHistory method toString.
@Override
public String toString() {
final StringBuilder retval = new StringBuilder().append(this.getClass().getSimpleName()).append(": ").append(getFragment()).append(": ");
boolean first = true;
for (Map.Entry<String, String> entry : m_settings.entrySet()) {
if (first) {
first = false;
} else {
retval.append(",");
}
retval.append(entry.getKey()).append("->").append(entry.getValue());
}
if (m_selectedVertices.size() > 0) {
first = true;
retval.append(",selectedVertices->{");
for (VertexRef entry : m_selectedVertices) {
if (first) {
first = false;
} else {
retval.append(",");
}
retval.append("[").append(entry.getNamespace()).append(":").append(entry.getId()).append("]");
}
retval.append("}");
}
if (m_focusVertices.size() > 0) {
first = true;
retval.append(",focusVertices->{");
for (VertexRef entry : m_focusVertices) {
if (first) {
first = false;
} else {
retval.append(",");
}
retval.append("[").append(entry.getNamespace()).append(":").append(entry.getId()).append("]");
}
retval.append("}");
}
return retval.toString();
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class TopologyContextMenu method addNavigateToItems.
// adds menu items for the "navigate to" operation
private static void addNavigateToItems(MenuBuilder menuBuilder, List<VertexRef> targets, OperationContext operationContext) {
if (!targets.isEmpty()) {
menuBuilder.createPath("Navigate To");
final GraphContainer graphContainer = operationContext.getGraphContainer();
// Find the vertices in other graphs that this vertex links to
final Collection<VertexRef> oppositeVertices = graphContainer.getTopologyServiceClient().getOppositeVertices(targets.get(0));
// Find all namespaces
final Set<String> targetNamespaces = oppositeVertices.stream().map(VertexRef::getNamespace).collect(Collectors.toSet());
// Find provider for namespaces and add menu entry
for (String eachTargetNamespace : targetNamespaces) {
// Find the graph provider for the target namespace
final GraphProvider targetGraphProvider = graphContainer.getTopologyServiceClient().getGraphProviders().stream().filter(g -> g.getNamespace().equals(eachTargetNamespace)).findFirst().orElse(null);
if (targetGraphProvider == null) {
LOG.warn("No graph provider found for namespace '{}'.", eachTargetNamespace);
continue;
}
NavigationMenuItem item = new NavigationMenuItem(targetGraphProvider, targets.get(0));
menuBuilder.addMenuItem(item, "Navigate To");
}
}
}
Aggregations