@Override public ISearchResults<IDeviceGroup> listDeviceGroupsWithRole(String role, boolean includeDeleted, ISearchCriteria criteria) throws SiteWhereException { return delegate.listDeviceGroupsWithRole(role, includeDeleted, criteria); }
@Override public ISearchResults<IDeviceGroup> listDeviceGroupsWithRole(String role, ISearchCriteria criteria) throws SiteWhereException { return getDelegate().listDeviceGroupsWithRole(role, criteria); }
/** * Gets devices in all groups that have the given role. Duplicates are removed. * * @param groupRole * @param criteria * @param deviceManagement * @param assetManagement * @return * @throws SiteWhereException */ public static Collection<IDevice> getDevicesInGroupsWithRole(String groupRole, IDeviceSearchCriteria criteria, IDeviceManagement deviceManagement, IAssetManagement assetManagement) throws SiteWhereException { Map<String, IDevice> devices = new HashMap<String, IDevice>(); ISearchCriteria groupCriteria = new SearchCriteria(1, 0); ISearchResults<IDeviceGroup> groups = deviceManagement.listDeviceGroupsWithRole(groupRole, groupCriteria); for (IDeviceGroup group : groups.getResults()) { List<IDevice> groupDevices = getDevicesInGroup(group, criteria, deviceManagement, assetManagement); for (IDevice groupDevice : groupDevices) { devices.put(groupDevice.getToken(), groupDevice); } } return devices.values(); } }
/** * Gets devices in all groups that have the given role. Duplicates are * removed. * * @param groupRole * @param criteria * @return * @throws SiteWhereException */ public static Collection<IDevice> getDevicesInGroupsWithRole(String groupRole, IDeviceSearchCriteria criteria, ITenant tenant) throws SiteWhereException { Map<String, IDevice> devices = new HashMap<String, IDevice>(); ISearchCriteria groupCriteria = new SearchCriteria(1, 0); ISearchResults<IDeviceGroup> groups = SiteWhere.getServer().getDeviceManagement(tenant) .listDeviceGroupsWithRole(groupRole, false, groupCriteria); for (IDeviceGroup group : groups.getResults()) { List<IDevice> groupDevices = getDevicesInGroup(group.getToken(), criteria, tenant); for (IDevice groupDevice : groupDevices) { devices.put(groupDevice.getHardwareId(), groupDevice); } } return devices.values(); } }
} else { results = SiteWhere.getServer().getDeviceManagement(getTenant(servletRequest)) .listDeviceGroupsWithRole(role, includeDeleted, criteria);
@Override public void listDeviceGroupsWithRole(GListDeviceGroupsWithRoleRequest request, StreamObserver<GListDeviceGroupsWithRoleResponse> responseObserver) { try { GrpcUtils.handleServerMethodEntry(this, DeviceManagementGrpc.getListDeviceGroupsWithRoleMethod()); ISearchResults<IDeviceGroup> apiResult = getDeviceManagement().listDeviceGroupsWithRole( request.getCriteria().getRole(), CommonModelConverter.asApiSearchCriteria(request.getCriteria().getPaging())); GListDeviceGroupsWithRoleResponse.Builder response = GListDeviceGroupsWithRoleResponse.newBuilder(); GDeviceGroupSearchResults.Builder results = GDeviceGroupSearchResults.newBuilder(); for (IDeviceGroup apiGroup : apiResult.getResults()) { results.addDeviceGroups(DeviceModelConverter.asGrpcDeviceGroup(apiGroup)); } results.setCount(apiResult.getNumResults()); response.setResults(results.build()); responseObserver.onNext(response.build()); responseObserver.onCompleted(); } catch (Throwable e) { GrpcUtils.handleServerMethodException(DeviceManagementGrpc.getListDeviceGroupsWithRoleMethod(), e, responseObserver); } finally { GrpcUtils.handleServerMethodExit(DeviceManagementGrpc.getListDeviceGroupsWithRoleMethod()); } }