@Override public boolean isFiltered(IDeviceEvent event, IDevice device, IDeviceAssignment assignment) throws SiteWhereException { if (getSiteToken().equals(device.getSiteToken())) { return (getOperation() != FilterOperation.Include); } return (getOperation() == FilterOperation.Include); }
if (!device.getSiteToken().equals(criteria.getSiteToken())) { continue;
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()); } }
/** * Copy information from SPI into Mongo {@link Document}. * * @param source * @param target */ public static void toDocument(IDevice source, Document target) { target.append(PROP_HARDWARE_ID, source.getHardwareId()); target.append(PROP_SITE_TOKEN, source.getSiteToken()); target.append(PROP_SPECIFICATION_TOKEN, source.getSpecificationToken()); target.append(PROP_PARENT_HARDWARE_ID, source.getParentHardwareId()); target.append(PROP_COMMENTS, source.getComments()); target.append(PROP_ASSIGNMENT_TOKEN, source.getAssignmentToken()); // Save nested list of mappings. List<Document> mappings = new ArrayList<Document>(); for (IDeviceElementMapping mapping : source.getDeviceElementMappings()) { mappings.add(MongoDeviceElementMapping.toDocument(mapping)); } target.append(PROP_DEVICE_ELEMENT_MAPPINGS, mappings); MongoSiteWhereEntity.toDocument(source, target); MongoMetadataProvider.toDocument(source, target); }
Device result = new Device(); result.setHardwareId(source.getHardwareId()); result.setSiteToken(source.getSiteToken()); result.setParentHardwareId(source.getParentHardwareId()); result.setComments(source.getComments()); if (source.getSiteToken() != null) { if (includeSite) { ISite site = getDeviceManagement(tenant).getSiteByToken(source.getSiteToken()); if (site == null) { throw new SiteWhereException("Device contains an invalid site reference."); result.setSiteToken(source.getSiteToken());
ProtobufMarshaler.Device.Builder builder = ProtobufMarshaler.Device.newBuilder(); builder.setHardwareId(device.getHardwareId()); builder.setSiteToken(device.getSiteToken()); builder.setSpecificationToken(device.getSpecificationToken()); if (device.getParentHardwareId() != null) {
newAssignment.setSiteToken(device.getSiteToken());