andPredicate.and(new AttributePredicateImpl<>(AccountAttributes.NAME, name)); query.setPredicate(andPredicate); query.setOffset(offset); query.setLimit(limit);
/** * Queries the results with the given {@link AccountQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to search results. * @param query * The {@link AccountQuery} to use to filter results. * @return The {@link AccountListResult} of all the result matching the given {@link AccountQuery} parameter. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "accountQuery", value = "Queries the Accounts", // notes = "Queries the Accounts with the given AccountQuery parameter returning all matching Accounts", // response = AccountListResult.class) // @POST @Path("_query") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public AccountListResult query( @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, // @ApiParam(value = "The AccountQuery to use to filter results.", required = true) AccountQuery query) throws Exception { query.setScopeId(scopeId); return accountService.query(query); }
childAccountsQuery.setPredicate(new AttributePredicateImpl<>(KapuaEntityAttributes.ENTITY_ID, targetScopeId, Operator.NOT_EQUAL));
childAccountsQuery.setPredicate(new AttributePredicateImpl<>(KapuaEntityAttributes.ENTITY_ID, targetScopeId, Operator.NOT_EQUAL));
query.setPredicate(new AttributePredicateImpl<>(AccountAttributes.NAME, accountCreator.getName())); if (count(query) > 0) { throw new KapuaDuplicateNameException(accountCreator.getName());
/** * Counts the results with the given {@link AccountQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to count results. * @param query * The {@link AccountQuery} to use to filter results. * @return The count of all the result matching the given {@link AccountQuery} parameter. * @throws Exception * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @ApiOperation(nickname = "accountCount", value = "Counts the Accounts", // notes = "Counts the Accounts with the given AccountQuery parameter returning the number of matching Accounts", // 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 AccountQuery to use to filter count results", required = true) AccountQuery query) throws Exception { query.setScopeId(scopeId); return new CountResult(accountService.count(query)); }
query.setPredicate(new AttributePredicateImpl<>(AccountAttributes.NAME, accountCreator.getName())); if (count(query) > 0) { throw new KapuaDuplicateNameException(accountCreator.getName());