/** * Create a not equal to predicate * * @param attributeName * @param attributeValue * @return */ public static <T> AttributePredicateImpl<T> attributeIsNotEqualTo(String attributeName, T attributeValue) { return new AttributePredicateImpl<>(attributeName, attributeValue, Operator.NOT_EQUAL); }
@When("^I search for device with tag \"([^\"]*)\"$") public void iSearchForDeviceWithTag(String deviceTagName) throws Throwable { Account lastAcc = (Account) stepData.get("LastAccount"); DeviceQueryImpl deviceQuery = new DeviceQueryImpl(lastAcc.getId()); KapuaQuery<Tag> tagQuery = new TagFactoryImpl().newQuery(lastAcc.getId()); tagQuery.setPredicate(new AttributePredicateImpl<>(TagAttributes.NAME, deviceTagName, AttributePredicate.Operator.EQUAL)); TagListResult tagQueryResult = tagService.query(tagQuery); Tag tag = tagQueryResult.getFirstItem(); deviceQuery.setPredicate(AttributePredicateImpl.attributeIsEqualTo(DeviceAttributes.TAG_IDS, tag.getId())); DeviceListResult deviceList = deviceRegistryService.query(deviceQuery); stepData.put("DeviceList", deviceList); }
@When("^I search for events from device \"(.+)\" in account \"(.+)\"$") public void searchForEventsFromDeviceWithClientID(String clientId, String account) throws KapuaException { DeviceEventQuery tmpQuery; Device tmpDev; DeviceEventListResult tmpList; Account tmpAcc; tmpAcc = KapuaLocator.getInstance().getService(AccountService.class).findByName(account); Assert.assertNotNull(tmpAcc); Assert.assertNotNull(tmpAcc.getId()); tmpDev = deviceRegistryService.findByClientId(tmpAcc.getId(), clientId); Assert.assertNotNull(tmpDev); Assert.assertNotNull(tmpDev.getId()); tmpQuery = new DeviceEventQueryImpl(tmpAcc.getId()); tmpQuery.setPredicate(AttributePredicateImpl.attributeIsEqualTo("deviceId", tmpDev.getId())); tmpQuery.setSortCriteria(new FieldSortCriteria("receivedOn", FieldSortCriteria.SortOrder.ASCENDING)); tmpList = deviceEventsService.query(tmpQuery); Assert.assertNotNull(tmpList); stepData.put("DeviceEventList", tmpList); }
/** * Create a not equal to predicate * * @param attributeName * @param attributeValue * @return */ public static <T> AttributePredicateImpl<T> attributeIsNotEqualTo(String attributeName, T attributeValue) { return new AttributePredicateImpl<>(attributeName, attributeValue, Operator.NOT_EQUAL); }
/** * Create an equal to predicate * * @param attributeName * @param attributeValue * @return */ public static <T> AttributePredicateImpl<T> attributeIsEqualTo(String attributeName, T attributeValue) { return new AttributePredicateImpl<>(attributeName, attributeValue); }
/** * Create an equal to predicate * * @param attributeName * @param attributeValue * @return */ public static <T> AttributePredicateImpl<T> attributeIsEqualTo(String attributeName, T attributeValue) { return new AttributePredicateImpl<>(attributeName, attributeValue); }
/** * Counts the results with the given {@link ManagementOperationNotificationQuery} parameter. * * @param scopeId The {@link ScopeId} in which to search results. * @param operationId The id of the {@link Device} in which to search results * @param query The {@link ManagementOperationNotificationQuery} to use to filter results. * @return The count of all the result matching the given {@link ManagementOperationNotificationQuery} parameter. * @throws Exception Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "ManagementOperationNotificationCount", value = "Counts the ManagementOperationNotifications", notes = "Counts the ManagementOperationNotifications with the given ManagementOperationNotificationQuery parameter returning the number of matching ManagementOperationNotifications", response = CountResult.class) @POST @Path("_count") @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public CountResult count( @ApiParam(value = "The ScopeId in which to count results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The device id to filter results.") @PathParam("deviceId") EntityId deviceId, @ApiParam(value = "The id of the Device in which to count results") @PathParam("operationId") EntityId operationId, @ApiParam(value = "The ManagementOperationNotificationQuery to use to filter count results", required = true) ManagementOperationNotificationQuery query) throws Exception { query.setScopeId(scopeId); query.setPredicate(new AttributePredicateImpl<>(ManagementOperationNotificationAttributes.OPERATION_ID, operationId)); return new CountResult(managementOperationNotificationService.count(query)); }
/** * Queries the results with the given {@link AccessRoleQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to search results. * @param query * The {@link AccessRoleQuery} to use to filter results. * @return The {@link AccessRoleListResult} of all the result matching the given {@link AccessRoleQuery} parameter. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "accessRoleQuery", value = "Queries the AccessRoles", notes = "Queries the AccessRoles with the given AccessRoleQuery parameter returning all matching AccessRoles", response = AccessRoleListResult.class) @POST @Path("_query") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public AccessRoleListResult query( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The AccessInfo id in which to search results.") @PathParam("accessInfoId") EntityId accessInfoId, @ApiParam(value = "The AccessRoleQuery to use to filter results.", required = true) AccessRoleQuery query) throws Exception { query.setScopeId(scopeId); query.setPredicate(new AttributePredicateImpl<>(AccessRoleAttributes.ACCESS_INFO_ID, accessInfoId)); return accessRoleService.query(query); }
/** * Counts the results with the given {@link RolePermissionQuery} parameter. * * @param scopeId The {@link ScopeId} in which to count results. * @param roleId The {@link Role} id in which to count results. * @param query The {@link RolePermissionQuery} to use to filter results. * @return The count of all the result matching the given {@link RolePermissionQuery} parameter. * @throws Exception Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "rolePermissionCount", value = "Counts the RolePermissions", notes = "Counts the RolePermissions with the given RolePermissionQuery parameter returning the number of matching RolePermissions", response = CountResult.class) @POST @Path("_count") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @ApiParam(value = "The ScopeId in which to count results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The Role id in which to count results.") @PathParam("roleId") EntityId roleId, @ApiParam(value = "The RolePermissionQuery to use to filter results.", required = true) RolePermissionQuery query) throws Exception { query.setScopeId(scopeId); query.setPredicate(new AttributePredicateImpl<>(RolePermissionAttributes.ROLE_ID, roleId)); return new CountResult(rolePermissionService.count(query)); }
/** * Queries the {@link AccessPermission}s with the given {@link AccessPermissionQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to search results. * @param accessInfoId * The {@link AccessInfo} id in which to search results. * @param query * The {@link AccessPermissionQuery} to use to filter results. * @return The {@link AccessPermissionListResult} of all the result matching the given {@link AccessPermissionQuery} parameter. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "accessPermissionQuery", value = "Queries the AccessPermissions", notes = "Queries the AccessPermissions with the given AccessPermissionQuery parameter returning all matching AccessPermissions", response = AccessPermissionListResult.class) @POST @Path("_query") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public AccessPermissionListResult query( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The AccessInfo id in which to search results.") @PathParam("accessInfoId") EntityId accessInfoId, @ApiParam(value = "The AccessPermissionQuery to use to filter results.", required = true) AccessPermissionQuery query) throws Exception { query.setScopeId(scopeId); query.setPredicate(new AttributePredicateImpl<>(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfoId)); return accessPermissionService.query(query); }
/** * Counts the results with the given {@link AccessRoleQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to search results. * @param query * The {@link AccessRoleQuery} to use to filter results. * @return The count of all the result matching the given {@link AccessRoleQuery} parameter. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "accessRoleCount", value = "Counts the AccessRoles", notes = "Counts the AccessRoles with the given AccessRoleQuery parameter returning the number of matching AccessRoles", response = CountResult.class) @POST @Path("_count") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @ApiParam(value = "The ScopeId in which to count results", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The AccessInfo id in which to count results.") @PathParam("accessInfoId") EntityId accessInfoId, @ApiParam(value = "The AccessRoleQuery to use to filter count results", required = true) AccessRoleQuery query) throws Exception { query.setScopeId(scopeId); query.setPredicate(new AttributePredicateImpl<>(AccessRoleAttributes.ACCESS_INFO_ID, accessInfoId)); return new CountResult(accessRoleService.count(query)); }
/** * Counts the {@link AccessPermission}s with the given {@link AccessPermissionQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to count results. * @param accessInfoId * The {@link AccessInfo} id in which to count results. * @param query * The {@link AccessPermissionQuery} to use to filter count results. * @return The count of all the result matching the given {@link AccessPermissionQuery} parameter. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "accessPermissionCount", value = "Counts the AccessPermissions", notes = "Counts the AccessPermissions with the given AccessPermissionQuery parameter returning the number of matching AccessPermissions", response = CountResult.class) @POST @Path("_count") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @ApiParam(value = "The ScopeId in which to count results", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The AccessInfo id in which to count results.") @PathParam("accessInfoId") EntityId accessInfoId, @ApiParam(value = "The AccessPermissionQuery to use to filter count results", required = true) AccessPermissionQuery query) throws Exception { query.setScopeId(scopeId); query.setPredicate(new AttributePredicateImpl<>(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfoId)); return new CountResult(accessPermissionService.count(query)); }
/** * Counts the results with the given {@link DeviceEventQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to search results. * @param deviceId * The id of the {@link Device} in which to search results * @param query * The {@link DeviceEventQuery} to use to filter results. * @return The count of all the result matching the given {@link DeviceEventQuery} parameter. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "deviceEventCount", value = "Counts the DeviceEvents", notes = "Counts the DeviceEvents with the given DeviceEventQuery parameter returning the number of matching DeviceEvents", response = CountResult.class) @POST @Path("_count") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @ApiParam(value = "The ScopeId in which to count results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The id of the Device in which to count results") @PathParam("deviceId") EntityId deviceId, @ApiParam(value = "The DeviceEventQuery to use to filter count results", required = true) DeviceEventQuery query) throws Exception { query.setScopeId(scopeId); query.setPredicate(new AttributePredicateImpl<>(DeviceEventAttributes.DEVICE_ID, deviceId)); return new CountResult(deviceEventService.count(query)); }
/** * Gets the {@link AccessRole} list in the scope. * * @param scopeId * The {@link ScopeId} in which to search results. * @param offset * The result set offset. * @param limit * The result set limit. * @return The {@link AccessRoleListResult} of all the accessRoles associated to the current selected scope. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "accessRoleSimpleQuery", value = "Gets the AccessRole list in the scope", notes = "Returns the list of all the accessRoles associated to the current selected scope.", response = AccessRoleListResult.class) @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AccessRoleListResult simpleQuery( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The optional id to filter results.") @PathParam("accessInfoId") EntityId accessInfoId, @ApiParam(value = "The result set offset.", defaultValue = "0") @QueryParam("offset") @DefaultValue("0") int offset, @ApiParam(value = "The result set limit.", defaultValue = "50", required = true) @QueryParam("limit") @DefaultValue("50") int limit) throws Exception { AccessRoleQuery query = accessRoleFactory.newQuery(scopeId); query.setPredicate(new AttributePredicateImpl<>(AccessRoleAttributes.ACCESS_INFO_ID, accessInfoId)); query.setOffset(offset); query.setLimit(limit); return query(scopeId, accessInfoId, query); }
/** * Queries the results with the given {@link ManagementOperationNotificationQuery} parameter. * * @param scopeId The {@link ScopeId} in which to search results. * @param operationId The id of the {@link Device} in which to search results * @param query The {@link ManagementOperationNotificationQuery} to use to filter results. * @return The {@link ManagementOperationNotificationListResult} of all the result matching the given {@link ManagementOperationNotificationQuery} parameter. * @throws Exception Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "ManagementOperationNotificationQuery", value = "Queries the ManagementOperationNotifications", notes = "Queries the ManagementOperationNotifications with the given ManagementOperationNotifications parameter returning all matching ManagementOperationNotifications", response = ManagementOperationNotificationListResult.class) @POST @Path("_query") @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public ManagementOperationNotificationListResult query( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The device id to filter results.") @PathParam("deviceId") EntityId deviceId, @ApiParam(value = "The id of the Device in which to search results") @PathParam("operationId") EntityId operationId, @ApiParam(value = "The ManagementOperationNotificationQuery to use to filter results.", required = true) ManagementOperationNotificationQuery query) throws Exception { query.setScopeId(scopeId); AndPredicateImpl andPredicate = new AndPredicateImpl(); andPredicate.and(new AttributePredicateImpl<>(ManagementOperationNotificationAttributes.OPERATION_ID, operationId)); query.setPredicate(andPredicate); return managementOperationNotificationService.query(query); }
/** * Queries the results with the given {@link DeviceManagementOperationQuery} parameter. * * @param scopeId The {@link ScopeId} in which to search results. * @param deviceId The id of the {@link Device} in which to search results * @param query The {@link DeviceManagementOperationQuery} to use to filter results. * @return The {@link DeviceManagementOperationListResult} of all the result matching the given {@link DeviceManagementOperationQuery} parameter. * @throws Exception Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "deviceManagementOperationQuery", value = "Queries the DeviceManagementOperations", notes = "Queries the DeviceManagementOperations with the given DeviceManagementOperations parameter returning all matching DeviceManagementOperations", response = DeviceManagementOperationListResult.class) @POST @Path("_query") @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public DeviceManagementOperationListResult query( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The id of the Device in which to search results") @PathParam("deviceId") EntityId deviceId, @ApiParam(value = "The DeviceManagementOperationQuery to use to filter results.", required = true) DeviceManagementOperationQuery query) throws Exception { query.setScopeId(scopeId); AndPredicateImpl andPredicate = new AndPredicateImpl(); andPredicate.and(new AttributePredicateImpl<>(DeviceManagementOperationAttributes.DEVICE_ID, deviceId)); query.setPredicate(andPredicate); return deviceManagementOperationRegistryService.query(query); }
/** * Gets the {@link AccessPermission} list in the scope. * * @param scopeId * The {@link ScopeId} in which to search results. * @param accessInfoId * The optional {@link AccessInfo} id to filter results. * @param offset * The result set offset. * @param limit * The result set limit. * @return The {@link AccessPermissionListResult} of all the {@link AccessPermission}s associated to the current selected scope. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "accessPermissionSimpleQuery", value = "Gets the AccessPermission list in the scope", notes = "Gets the AccessPermission list in the scope. The query parameter accessInfoId is optional and can be used to filter results", response = AccessPermissionListResult.class) @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AccessPermissionListResult simpleQuery( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The optional id to filter results.") @PathParam("accessInfoId") EntityId accessInfoId, @ApiParam(value = "The result set offset.", defaultValue = "0") @QueryParam("offset") @DefaultValue("0") int offset, @ApiParam(value = "The result set limit.", defaultValue = "50") @QueryParam("limit") @DefaultValue("50") int limit) throws Exception { AccessPermissionQuery query = accessPermissionFactory.newQuery(scopeId); query.setPredicate(new AttributePredicateImpl<>(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfoId)); query.setOffset(offset); query.setLimit(limit); return query(scopeId, accessInfoId, query); }
/** * Gets the {@link ManagementOperationNotification} list in the scope. * * @param scopeId The {@link ScopeId} in which to search results. * @param operationId The id of the {@link Device} in which to search results * @param resource The resource of the {@link ManagementOperationNotification} in which to search results * @param offset The result set offset. * @param limit The result set limit. * @return The {@link ManagementOperationNotificationListResult} of all the ManagementOperationNotifications associated to the current selected scope. * @throws Exception Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "ManagementOperationNotificationSimpleQuery", value = "Gets the ManagementOperationNotification list in the scope", notes = "Returns the list of all the ManagementOperationNotifications associated to the current selected scope.", response = ManagementOperationNotificationListResult.class) @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public ManagementOperationNotificationListResult simpleQuery( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The device id to filter results.") @PathParam("deviceId") EntityId deviceId, @ApiParam(value = "The operation id to filter results.") @PathParam("operationId") EntityId operationId, @ApiParam(value = "The resource of the ManagementOperationNotification in which to search results") @QueryParam("resource") String resource, @ApiParam(value = "The result set offset.", defaultValue = "0") @QueryParam("offset") @DefaultValue("0") int offset, @ApiParam(value = "The result set limit.", defaultValue = "50") @QueryParam("limit") @DefaultValue("50") int limit) throws Exception { ManagementOperationNotificationQuery query = managementOperationNotificationFactory.newQuery(scopeId); AndPredicateImpl andPredicate = new AndPredicateImpl(); andPredicate.and(new AttributePredicateImpl<>(ManagementOperationNotificationAttributes.OPERATION_ID, operationId)); query.setPredicate(andPredicate); query.setOffset(offset); query.setLimit(limit); return query(scopeId, deviceId, operationId, query); }
/** * Gets the {@link Domain} list in the scope. * * @param scopeId The {@link ScopeId} in which to search results. * @param name The {@link Domain} name in which to search results. * @param offset The result set offset. * @param limit The result set limit. * @return The {@link DomainListResult} of all the domains associated to the current selected scope. * @throws Exception Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "domainSimpleQuery", value = "Gets the Domain list in the scope", notes = "Returns the list of all the domains associated to the current selected scope.", response = DomainListResult.class) @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DomainListResult simpleQuery( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, @ApiParam(value = "The domain name to filter results.") @QueryParam("name") String name, @ApiParam(value = "The result set offset.", defaultValue = "0") @QueryParam("offset") @DefaultValue("0") int offset, @ApiParam(value = "The result set limit.", defaultValue = "50") @QueryParam("limit") @DefaultValue("50") int limit) throws Exception { DomainQuery query = domainFactory.newQuery(null); AndPredicateImpl andPredicate = new AndPredicateImpl(); if (!Strings.isNullOrEmpty(name)) { andPredicate.and(new AttributePredicateImpl<>(DomainAttributes.NAME, name)); } query.setPredicate(andPredicate); query.setOffset(offset); query.setLimit(limit); return query(scopeId, query); }
andPredicate.and(new AttributePredicateImpl<>(CredentialAttributes.USER_ID, userId));