public ManagementOperationNotificationQuery newQuery() { return factory.newQuery(null); } }
ManagementOperationNotificationQuery newQuery() { return MANAGEMENT_OPERATION_NOTIFICATION_REGISTRY_FACTORY.newQuery(null); } }
/** * 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); }
@ApiParam(value = "The id of the requested Device", required = true) @PathParam("operationId") EntityId operationId, @ApiParam(value = "The id of the requested ManagementOperationNotification", required = true) @PathParam("managementOperationNotificationId") EntityId managementOperationNotificationId) throws Exception { ManagementOperationNotificationQuery query = managementOperationNotificationFactory.newQuery(scopeId);
default void closeDeviceManagementOperation(KapuaId scopeId, KapuaId operationId, Date updateOn, OperationStatus finalStatus) throws KapuaException { DeviceManagementOperation deviceManagementOperation = null; short attempts = 0; short limit = 3; boolean failed = false; do { try { deviceManagementOperation = getDeviceManagementOperation(scopeId, operationId); deviceManagementOperation.setEndedOn(updateOn); deviceManagementOperation.setStatus(finalStatus); DEVICE_MANAGEMENT_OPERATION_REGISTRY_SERVICE.update(deviceManagementOperation); LOG.info("Update DeviceManagementOperation {} with status {}... SUCCEEDED!", operationId, finalStatus); break; } catch (Exception e) { failed = true; attempts++; if (attempts >= limit) { throw e; } else { LOG.warn("Update DeviceManagementOperation {} with status {}... FAILED! Retrying...", operationId, finalStatus); } } } while (failed); ManagementOperationNotificationQuery query = MANAGEMENT_OPERATION_NOTIFICATION_FACTORY.newQuery(scopeId); query.setPredicate(new AttributePredicateImpl<>(ManagementOperationNotificationAttributes.OPERATION_ID, deviceManagementOperation.getId())); ManagementOperationNotificationListResult notifications = MANAGEMENT_OPERATION_NOTIFICATION_REGISTRY_SERVICE.query(query); for (ManagementOperationNotification mon : notifications.getItems()) { MANAGEMENT_OPERATION_NOTIFICATION_REGISTRY_SERVICE.delete(mon.getScopeId(), mon.getId()); } }