private static OnmsGeolocation geoLocation(OnmsNode node) { if (node != null && node.getAssetRecord() != null && node.getAssetRecord().getGeolocation() != null) { return node.getAssetRecord().getGeolocation(); } return null; }
private static OnmsGeolocation getGeoLocation(OnmsNode node) { if (node != null && node.getAssetRecord() != null && node.getAssetRecord().getGeolocation() != null) { return node.getAssetRecord().getGeolocation(); } return null; } }
private static OnmsGeolocation getGeoLocation(OnmsNode node) { if (node != null && node.getAssetRecord() != null && node.getAssetRecord().getGeolocation() != null) { return node.getAssetRecord().getGeolocation(); } return null; } }
private static OnmsGeolocation geoLocation(OnmsNode node) { if (node != null && node.getAssetRecord() != null && node.getAssetRecord().getGeolocation() != null) { return node.getAssetRecord().getGeolocation(); } return null; }
@Override public ItemProvider<String> getItemProvider() { return node -> { Double latitude = node.getAssetRecord().getGeolocation().getLatitude(); return latitude == null ? null : latitude.toString(); }; } }),
@Override public ItemProvider<String> getItemProvider() { return node -> { Double longitude = node.getAssetRecord().getGeolocation().getLongitude(); return longitude == null ? null : longitude.toString(); }; } }),
@Override public ItemProvider<String> getItemProvider() { return node -> node.getAssetRecord().getGeolocation().getAddress2(); } }),
@Override public ItemProvider<String> getItemProvider() { return node -> node.getAssetRecord().getGeolocation().getCountry(); } }),
@Override public ItemProvider<String> getItemProvider() { return node -> node.getAssetRecord().getGeolocation().getAddress1(); } }),
@Override public ItemProvider<String> getItemProvider() { return node -> node.getAssetRecord().getGeolocation().getCity(); } }),
@Override public ItemProvider<String> getItemProvider() { return node -> node.getAssetRecord().getGeolocation().getZip(); } }),
@Override public ItemProvider<String> getItemProvider() { return node -> node.getAssetRecord().getGeolocation().getState(); } }),
@Override public DisplayStatus evaluate(final HttpServletRequest request, final Object target) { if (target instanceof OnmsNode) { final OnmsNode node = (OnmsNode)target; if (node.getAssetRecord() != null && node.getAssetRecord().getGeolocation() != null) { final OnmsGeolocation geolocation = node.getAssetRecord().getGeolocation(); if (geolocation.getLongitude() != null && geolocation.getLatitude() != null) { return DisplayStatus.DISPLAY_LINK; } } } return DisplayStatus.NO_DISPLAY; }
@Override public DisplayStatus evaluate(final HttpServletRequest request, final Object target) { if (target instanceof OnmsNode) { final OnmsNode node = (OnmsNode)target; if (node.getAssetRecord() != null && node.getAssetRecord().getGeolocation() != null) { final OnmsGeolocation geolocation = node.getAssetRecord().getGeolocation(); if (geolocation.getLongitude() != null && geolocation.getLatitude() != null) { return DisplayStatus.DISPLAY_LINK; } } } return DisplayStatus.NO_DISPLAY; }
@Override public Map<Integer, Coordinates> resolve(Collection<Integer> nodeIds) { if (nodeIds == null || nodeIds.isEmpty()) { return new HashMap<>(); // nothing to do } // Lookup all nodes and gather the address string final Criteria criteria = new CriteriaBuilder(OnmsNode.class).in("id", nodeIds).toCriteria(); final Map<Integer, String> nodeIdAddressMap = nodeDao.findMatching(criteria).stream() .filter(n -> getGeoLocation(n) != null) .filter(n -> getGeoLocation(n).getLatitude() == null && getGeoLocation(n).getLongitude() == null) .filter(n -> !Strings.isNullOrEmpty(getGeoLocation(n).asAddressString())) .collect(Collectors.toMap(OnmsNode::getId, n -> n.getAssetRecord().getGeolocation().asAddressString())); return resolve(nodeIdAddressMap); }
@Override public Map<Integer, Coordinates> resolve(Collection<Integer> nodeIds) { if (nodeIds == null || nodeIds.isEmpty()) { return new HashMap<>(); // nothing to do } // Lookup all nodes and gather the address string final Criteria criteria = new CriteriaBuilder(OnmsNode.class).in("id", nodeIds).toCriteria(); final Map<Integer, String> nodeIdAddressMap = nodeDao.findMatching(criteria).stream() .filter(n -> getGeoLocation(n) != null) .filter(n -> getGeoLocation(n).getLatitude() == null && getGeoLocation(n).getLongitude() == null) .filter(n -> !Strings.isNullOrEmpty(getGeoLocation(n).asAddressString())) .collect(Collectors.toMap(OnmsNode::getId, n -> n.getAssetRecord().getGeolocation().asAddressString())); return resolve(nodeIdAddressMap); }
OnmsGeolocation toGeolocation = this.getGeolocation(); if (toGeolocation == null) { toGeolocation = new OnmsGeolocation(); this.setGeolocation(toGeolocation); final OnmsGeolocation fromGeolocation = newRecord.getGeolocation();
protected void updateGeolocation(GeolocationResolver geolocationResolver, OnmsNode node) { Objects.requireNonNull(geolocationResolver); Objects.requireNonNull(node); // Only resolve long/lat if not already set and an address is set final OnmsGeolocation geolocation = node.getAssetRecord().getGeolocation(); if (geolocation != null && geolocation.getLatitude() == null && geolocation.getLatitude() == null && !Strings.isNullOrEmpty(geolocation.asAddressString())) { final Coordinates coordinates = geolocationResolver.resolve(geolocation.asAddressString()); if (coordinates != null) { geolocation.setLongitude(coordinates.getLongitude()); geolocation.setLatitude(coordinates.getLatitude()); nodeDao.saveOrUpdate(node); } else { LOG.warn("Could not resolve address string '{}' for node with id {}", geolocation.asAddressString(), node.getId()); } } }
OnmsGeolocation gl = assetRecord.getGeolocation(); if (gl !=null){ if (gl.getLatitude() !=null)body.put("asset-latitude", gl.getLatitude().toString());
@Override public void visitNode(final OnmsNodeRequisition nodeReq) { final NodeBuilder nodeBldr = bldr.addNode(nodeReq.getNodeLabel()); nodeBldr.setLabelSource(NodeLabelSource.USER); nodeBldr.setType(NodeType.ACTIVE); nodeBldr.setForeignSource(nodeReq.getForeignSource()); nodeBldr.setForeignId(nodeReq.getForeignId()); nodeBldr.setLocation(nodeReq.getLocation()); nodeBldr.getAssetRecord().setBuilding(nodeReq.getBuilding()); nodeBldr.getAssetRecord().getGeolocation().setCity(nodeReq.getCity()); }