public Builder metadata(String name, String value) { if (request.getMetadata() == null) { request.setMetadata(new HashMap<String, String>()); } request.getMetadata().put(name, value); return this; }
public Builder metadata(String name, String value) { if (request.getMetadata() == null) { request.setMetadata(new HashMap<String, String>()); } request.getMetadata().put(name, value); return this; }
Map<String, String> metadata = new HashMap<String, String>(); metadata.put("metadata", "value"); location.setMetadata(metadata); location.setUpdateState(true); request.getLocations().add(location); mx.setName("fuel.level"); mx.setValue(123.45); location.setMetadata(metadata); location.setUpdateState(true); request.getMeasurements().add(mx); alert.setSource(AlertSource.Device); alert.setLevel(AlertLevel.Error); location.setMetadata(metadata); location.setUpdateState(true); request.getAlerts().add(alert);
/** * Send a location event request via JSON/MQTT. * * @throws SiteWhereException */ public void sendLocationOverMqtt() throws SiteWhereException { DeviceRequest request = new DeviceRequest(); request.setDeviceToken("39430-GALAXYTAB3-7481908"); request.setType(Type.DeviceLocation); DeviceLocationCreateRequest location = new DeviceLocationCreateRequest(); location.setEventDate(new Date()); location.setLatitude(34.10469794977326); location.setLongitude(-84.23966646194458); location.setElevation(0.0); Map<String, String> metadata = new HashMap<String, String>(); metadata.put("fromMQTT", "true"); location.setMetadata(metadata); location.setUpdateState(true); request.setRequest(location); try { String payload = MarshalUtils.PRETTY_MAPPER.writeValueAsString(request); connection.publish("SiteWhere/default/input/json", payload.getBytes(), QoS.AT_MOST_ONCE, false); } catch (JsonProcessingException e) { throw new SiteWhereException(e); } catch (Exception e) { throw new SiteWhereException(e); } }
metadata.put(meta.getName(), meta.getValue()); request.setMetadata(metadata);
request.setMetadata(metadata);