@Override public SmsParameters extractDeliveryParameters(IDeviceNestingContext nesting, IDeviceAssignment assignment, IDeviceCommandExecution execution) throws SiteWhereException { SmsParameters params = new SmsParameters(); // Load hostname and port from device metadata. Map<String, String> deviceMeta = nesting.getGateway().getMetadata(); String phone = deviceMeta.get(getPhoneNumberMetadataField()); params.setSmsPhoneNumber(phone); if (phone == null) { throw new SiteWhereException("No phone number found in device metadata. Unable to deliver."); } return params; }
@Override public CoapParameters extractDeliveryParameters(IDeviceNestingContext nesting, IDeviceAssignment assignment, IDeviceCommandExecution execution) throws SiteWhereException { Map<String, String> metadata = nesting.getGateway().getMetadata(); String hostname = metadata.get(getHostnameMetadataField()); String port = metadata.get(getPortMetadataField()); String url = metadata.get(getUrlMetadataField()); String method = metadata.get(getMethodMetadataField()); CoapParameters coap = new CoapParameters(); coap.setHostname(hostname); if (port != null) { coap.setPort(Integer.parseInt(port)); } if (url != null) { coap.setUrl(url); } if (method != null) { coap.setMethod(method); } return coap; }
public Builder(IDevice api) { request.setSiteToken(api.getSiteToken()); request.setSpecificationToken(api.getSpecificationToken()); request.setHardwareId(api.getHardwareId()); request.setStatus(api.getStatus()); request.setComments(api.getComments()); request.setParentHardwareId(api.getParentHardwareId()); if (api.getDeviceElementMappings() != null) { request.setDeviceElementMappings(new ArrayList<DeviceElementMapping>()); request.getDeviceElementMappings().addAll(api.getDeviceElementMappings()); } if (api.getMetadata() != null) { request.setMetadata(new HashMap<String, String>()); request.getMetadata().putAll(api.getMetadata()); } }
@Override public CoapParameters extractDeliveryParameters(IDeviceNestingContext nesting, IDeviceAssignment assignment, IDeviceCommandExecution execution) throws SiteWhereException { // Load hostname and port from device metadata. Map<String, String> deviceMeta = nesting.getGateway().getMetadata(); String hostname = deviceMeta.get(getHostnameMetadataField()); String port = deviceMeta.get(getPortMetadataField()); // Load url and method from command metadata. Map<String, String> commandMeta = execution.getCommand().getMetadata(); String url = commandMeta.get(getUrlMetadataField()); String method = commandMeta.get(getMethodMetadataField()); CoapParameters coap = new CoapParameters(); coap.setHostname(hostname); if (hostname == null) { throw new SiteWhereException("Hostname not found in device metadata. Unable to deliver command."); } if (port != null) { coap.setPort(Integer.parseInt(port)); } if (url != null) { coap.setUrl(url); } if (method != null) { coap.setMethod(method); } return coap; }
context.setParentDeviceId(device.getParentDeviceId()); context.setDeviceStatus(device.getStatus()); context.setDeviceMetadata(device.getMetadata()); context.setAssignmentStatus(assignment.getStatus()); context.setAssignmentMetadata(assignment.getMetadata());