public String toAddressString() { return join(", ", join(" ", getAddress1(), getAddress2()), getCity(), join(" ", getState(), getZip()), getCountry()); }
public GeolocationQueryBuilder withSeverity(GeolocationSeverity severity) { query.setSeverity(severity); return this; }
public GeolocationQueryBuilder withStatusCalculationStrategy(StatusCalculationStrategy statusCalculationStrategy) { query.setStatusCalculationStrategy(statusCalculationStrategy); return this; }
private static MapNode createMapNode(GeolocationInfo geolocationInfo) { final MapNode node = new MapNode(); // Coordinates if (geolocationInfo.getCoordinates() != null) { node.setLatitude(geolocationInfo.getCoordinates().getLatitude()); node.setLongitude(geolocationInfo.getCoordinates().getLongitude()); } // Node Info final NodeInfo nodeInfo = geolocationInfo.getNodeInfo(); node.setNodeId(String.valueOf(nodeInfo.getNodeId())); node.setNodeLabel(nodeInfo.getNodeLabel()); node.setForeignSource(nodeInfo.getForeignSource()); node.setForeignId(nodeInfo.getForeignId()); node.setIpAddress(nodeInfo.getIpAddress()); node.setDescription(nodeInfo.getDescription()); node.setMaintcontract(nodeInfo.getMaintcontract()); node.setCategories(new ArrayList<>(nodeInfo.getCategories())); // Severity node.setSeverityLabel(geolocationInfo.getSeverityInfo().getLabel()); node.setSeverity(String.valueOf(geolocationInfo.getSeverityInfo().getId())); // Count node.setUnackedCount(geolocationInfo.getAlarmUnackedCount()); return node; } }
private static GeolocationQuery toQuery(GeolocationQueryDTO queryDTO) { if (queryDTO != null) { GeolocationQuery query = new GeolocationQuery(); if (queryDTO.getSeverityFilter() != null) { query.setSeverity(getEnum(queryDTO.getSeverityFilter(), GeolocationSeverity.values())); } if (queryDTO.getStrategy() != null) { query.setStatusCalculationStrategy(getEnum(queryDTO.getStrategy(), StatusCalculationStrategy.values())); } query.setIncludeAcknowledgedAlarms(queryDTO.isIncludeAcknowledgedAlarms()); return query; } return null; }
private void applyStatus(GeolocationQuery query, List<GeolocationInfo> locations) { final Set<Integer> nodeIds = locations.stream().map(l -> l.getNodeInfo().getNodeId()).collect(Collectors.toSet()); if (!nodeIds.isEmpty()) { final Status status = calculateStatus(query, nodeIds); // Appliing the calculated status to each location for(GeolocationInfo info : locations) { OnmsSeverity severity = status.getSeverity(info.getNodeInfo().getNodeId()); // After the status was calculated, it is not guaranteed that status.size() == locations.size() // Therefore for all locations with no status must be set to "NORMAL" in the result if (severity == null) { severity = OnmsSeverity.NORMAL; } info.setSeverityInfo(new SeverityInfo(severity.getId(), severity.getLabel())); info.setAlarmUnackedCount(status.getUnacknowledgedAlarmCount(info.getNodeInfo().getNodeId())); } } }
private static AddressInfo toAddressInfo(OnmsGeolocation input) { if (input != null) { AddressInfo addressInfo = new AddressInfo(); addressInfo.setAddress1(input.getAddress1()); addressInfo.setAddress2(input.getAddress2()); addressInfo.setCity(input.getCity()); addressInfo.setCountry(input.getCountry()); addressInfo.setState(input.getState()); addressInfo.setZip(input.getZip()); return addressInfo; } return null; } }
public boolean isValid() { return !Strings.isNullOrEmpty(geolocationConfiguration.getTileServerUrl()) && !Strings.isNullOrEmpty(geolocationConfiguration.getOptions().get("attribution")); }
public String getTileServerUrl() { return geolocationConfiguration.getTileServerUrl(); }
public String getTileLayerAttribution() { return geolocationConfiguration.getOptions().get("attribution"); } }
public GeolocationQueryBuilder withIncludeAcknowledgedAlarms(boolean includeAcknowledgedAlarms) { query.setIncludeAcknowledgedAlarms(includeAcknowledgedAlarms); return this; }
public GeolocationQueryBuilder withNodeIds(Integer... nodeIds) { withNodeIds(Arrays.asList(nodeIds)); return this; }
public GeolocationQueryBuilder withLocation(String location) { query.setLocation(location); return this; }
public int getId() { return ordinal() + 3; } }
public GeolocationQueryBuilder withNodeIds(Collection<Integer> nodeIds) { query.setNodeIds(new ArrayList<>(nodeIds)); return this; }
private static MapNode createMapNode(GeolocationInfo geolocationInfo) { final MapNode node = new MapNode(); // Coordinates if (geolocationInfo.getCoordinates() != null) { node.setLatitude(geolocationInfo.getCoordinates().getLatitude()); node.setLongitude(geolocationInfo.getCoordinates().getLongitude()); } // Node Info final NodeInfo nodeInfo = geolocationInfo.getNodeInfo(); node.setNodeId(String.valueOf(nodeInfo.getNodeId())); node.setNodeLabel(nodeInfo.getNodeLabel()); node.setForeignSource(nodeInfo.getForeignSource()); node.setForeignId(nodeInfo.getForeignId()); node.setIpAddress(nodeInfo.getIpAddress()); node.setDescription(nodeInfo.getDescription()); node.setMaintcontract(nodeInfo.getMaintcontract()); node.setCategories(new ArrayList<>(nodeInfo.getCategories())); // Severity node.setSeverityLabel(geolocationInfo.getSeverityInfo().getLabel()); node.setSeverity(String.valueOf(geolocationInfo.getSeverityInfo().getId())); // Count node.setUnackedCount(geolocationInfo.getAlarmUnackedCount()); return node; } }
private static AddressInfo toAddressInfo(OnmsGeolocation input) { if (input != null) { AddressInfo addressInfo = new AddressInfo(); addressInfo.setAddress1(input.getAddress1()); addressInfo.setAddress2(input.getAddress2()); addressInfo.setCity(input.getCity()); addressInfo.setCountry(input.getCountry()); addressInfo.setState(input.getState()); addressInfo.setZip(input.getZip()); return addressInfo; } return null; } }
public boolean isValid() { return !Strings.isNullOrEmpty(geolocationConfiguration.getTileServerUrl()) && !Strings.isNullOrEmpty(geolocationConfiguration.getOptions().get("attribution")); }
public String getTileServerUrl() { return geolocationConfiguration.getTileServerUrl(); }
public String getTileLayerAttribution() { return geolocationConfiguration.getOptions().get("attribution"); } }