Codota Logo
org.eclipse.kapua.service.device.management.registry.operation
Code IndexAdd Codota to your IDE (free)

How to use org.eclipse.kapua.service.device.management.registry.operation

Best Java code snippets using org.eclipse.kapua.service.device.management.registry.operation (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: eclipse/kapua

  public DeviceManagementOperationQuery newQuery() {
    return factory.newQuery(null);
  }
}
origin: eclipse/kapua

DeviceManagementOperationCreator newDeviceManagementOperationCreator() {
  return factory.newCreator(null);
}
origin: eclipse/kapua

public DeviceManagementOperation newDeviceManagementOperation() {
  return factory.newEntity(null);
}
origin: eclipse/kapua

  @ApiParam(value = "The id of the Device in which to count results") @PathParam("deviceId") EntityId deviceId,
  @ApiParam(value = "The DeviceManagementOperationQuery to use to filter count results", required = true) DeviceManagementOperationQuery query) throws Exception {
query.setScopeId(scopeId);
query.setPredicate(new AttributePredicateImpl<>(DeviceManagementOperationAttributes.DEVICE_ID, deviceId));
  DeviceManagementOperationProperty deviceManagementOperationProperty = deviceManagementOperationFactory.newStepProperty("asd", "string", "qwe");
  DeviceManagementOperationCreator deviceManagementOperationCreator = deviceManagementOperationFactory.newCreator(scopeId);
  deviceManagementOperationCreator.setStartedOn(new Date());
  deviceManagementOperationCreator.setDeviceId(deviceId);
  deviceManagementOperationCreator.setStatus(OperationStatus.COMPLETED);
  deviceManagementOperationCreator.setAppId("ASD");
  deviceManagementOperationCreator.setAction(KapuaMethod.CREATE);
  deviceManagementOperationCreator.setResource("qwe");
  deviceManagementOperationCreator.setInputProperties(Arrays.asList(deviceManagementOperationProperty));
  deviceManagementOperationRegistryService.create(deviceManagementOperationCreator);
return new CountResult(deviceManagementOperationRegistryService.count(query));
origin: eclipse/kapua

protected KapuaId createManagementOperation(KapuaId scopeId, KapuaId deviceId, KapuaId operationId, int totalCheckpoints, KapuaRequestMessage<?, ?> requestMessage) throws KapuaException {
  DeviceManagementOperationCreator deviceManagementOperationCreator = DEVICE_MANAGEMENT_OPERATION_FACTORY.newCreator(scopeId);
  deviceManagementOperationCreator.setDeviceId(deviceId);
  deviceManagementOperationCreator.setOperationId(operationId);
  deviceManagementOperationCreator.setStartedOn(new Date());
  deviceManagementOperationCreator.setAppId(requestMessage.getChannel().getAppName().getValue());
  deviceManagementOperationCreator.setAction(requestMessage.getChannel().getMethod());
  deviceManagementOperationCreator.setResource(!requestMessage.getChannel().getSemanticParts().isEmpty() ? requestMessage.getChannel().getSemanticParts().get(0) : null);
  deviceManagementOperationCreator.setStatus(OperationStatus.RUNNING);
  deviceManagementOperationCreator.setInputProperties(extractInputProperties(requestMessage));
  DeviceManagementOperation deviceManagementOperation = KapuaSecurityUtils.doPrivileged(() -> DEVICE_MANAGEMENT_OPERATION_REGISTRY_SERVICE.create(deviceManagementOperationCreator));
  return deviceManagementOperation.getId();
}
origin: eclipse/kapua

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());
  }
}
origin: eclipse/kapua

/**
 * Creates and return new DeviceManagementOperationNotification
 *
 * @param em
 * @param deviceManagementOperationCreator
 * @return
 * @throws KapuaException
 */
public static DeviceManagementOperation create(EntityManager em, DeviceManagementOperationCreator deviceManagementOperationCreator)
    throws KapuaException {
  //
  // Create DeviceManagementOperationNotification
  DeviceManagementOperationImpl deviceManagementOperationImpl = new DeviceManagementOperationImpl(deviceManagementOperationCreator.getScopeId());
  deviceManagementOperationImpl.setStartedOn(deviceManagementOperationCreator.getStartedOn());
  deviceManagementOperationImpl.setDeviceId(deviceManagementOperationCreator.getDeviceId());
  deviceManagementOperationImpl.setOperationId(deviceManagementOperationCreator.getOperationId());
  deviceManagementOperationImpl.setAppId(deviceManagementOperationCreator.getAppId());
  deviceManagementOperationImpl.setAction(deviceManagementOperationCreator.getAction());
  deviceManagementOperationImpl.setResource(deviceManagementOperationCreator.getResource());
  deviceManagementOperationImpl.setStatus(deviceManagementOperationCreator.getStatus());
  deviceManagementOperationImpl.setStatus(deviceManagementOperationCreator.getStatus());
  deviceManagementOperationImpl.setInputProperties(deviceManagementOperationCreator.getInputProperties());
  return ServiceDAO.create(em, deviceManagementOperationImpl);
}
origin: eclipse/kapua

protected void closeManagementOperation(KapuaId scopeId, KapuaId deviceId, KapuaId operationId, KapuaResponseMessage<?, ?> responseMessageMessage) throws KapuaException {
  DeviceManagementOperationQuery query = DEVICE_MANAGEMENT_OPERATION_FACTORY.newQuery(scopeId);
  query.setPredicate(
      new AndPredicateImpl(
          new AttributePredicateImpl<>(DeviceManagementOperationAttributes.DEVICE_ID, deviceId),
          new AttributePredicateImpl<>(DeviceManagementOperationAttributes.OPERATION_ID, operationId)
      )
  );
  DeviceManagementOperation deviceManagementOperation = DEVICE_MANAGEMENT_OPERATION_REGISTRY_SERVICE.query(query).getFirstItem();
  if (deviceManagementOperation == null) {
    throw new KapuaEntityNotFoundException(DeviceManagementOperation.TYPE, operationId);
  }
  deviceManagementOperation.setStatus(responseMessageMessage.getResponseCode().isAccepted() ? OperationStatus.COMPLETED : OperationStatus.FAILED);
  deviceManagementOperation.setEndedOn(responseMessageMessage.getReceivedOn());
  KapuaSecurityUtils.doPrivileged(() -> DEVICE_MANAGEMENT_OPERATION_REGISTRY_SERVICE.update(deviceManagementOperation));
}
origin: eclipse/kapua

  @ApiParam(value = "The id of the requested Device", required = true) @PathParam("deviceId") EntityId deviceId,
  @ApiParam(value = "The id of the requested DeviceManagementOperation", required = true) @PathParam("deviceManagementOperationId") EntityId deviceManagementOperationId) throws Exception {
DeviceManagementOperationQuery query = deviceManagementOperationFactory.newQuery(scopeId);
andPredicate.and(new AttributePredicateImpl<>(DeviceManagementOperationAttributes.ENTITY_ID, deviceManagementOperationId));
query.setPredicate(andPredicate);
query.setOffset(0);
query.setLimit(1);
DeviceManagementOperationListResult results = deviceManagementOperationRegistryService.query(query);
if (!results.isEmpty()) {
  return results.getFirstItem();
} else {
  throw new KapuaEntityNotFoundException(DeviceManagementOperation.TYPE, deviceManagementOperationId);
origin: eclipse/kapua

  default DeviceManagementOperation getDeviceManagementOperation(KapuaId scopeId, KapuaId operationId) throws KapuaException {
    DeviceManagementOperationQuery query = DEVICE_MANAGEMENT_OPERATION_FACTORY.newQuery(scopeId);
    query.setPredicate(new AttributePredicateImpl<>(DeviceManagementOperationAttributes.OPERATION_ID, operationId));

    DeviceManagementOperationListResult operations = DEVICE_MANAGEMENT_OPERATION_REGISTRY_SERVICE.query(query);
    DeviceManagementOperation deviceManagementOperation = operations.getFirstItem();

    if (deviceManagementOperation == null) {
      throw new KapuaEntityNotFoundException(DeviceManagementOperation.TYPE, operationId);
    }

    return deviceManagementOperation;
  }
}
origin: eclipse/kapua

default void addManagementNotification(KapuaId scopeId, KapuaId operationId, Date updateOn, OperationStatus operationStatus, String resource, Integer progress) throws KapuaException {
  DeviceManagementOperation deviceManagementOperation = getDeviceManagementOperation(scopeId, operationId);
  ManagementOperationNotificationCreator managementOperationNotificationCreator = MANAGEMENT_OPERATION_NOTIFICATION_FACTORY.newCreator(scopeId);
  managementOperationNotificationCreator.setOperationId(deviceManagementOperation.getId());
  managementOperationNotificationCreator.setSentOn(updateOn);
  managementOperationNotificationCreator.setStatus(operationStatus);
  managementOperationNotificationCreator.setResource(resource);
  managementOperationNotificationCreator.setProgress(progress);
  MANAGEMENT_OPERATION_NOTIFICATION_REGISTRY_SERVICE.create(managementOperationNotificationCreator);
}
origin: eclipse/kapua

private DeviceManagementOperationPropertyImpl(DeviceManagementOperationProperty jobStepProperty) {
  setName(jobStepProperty.getName());
  setPropertyType(jobStepProperty.getPropertyType());
  setPropertyValue(jobStepProperty.getPropertyValue());
}
origin: eclipse/kapua

/**
 * 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);
}
origin: eclipse/kapua

default void processCompletedNotification(KapuaId scopeId, KapuaId operationId, Date updateOn, String resource) throws KapuaException {
  DeviceManagementOperation deviceManagementOperation = getDeviceManagementOperation(scopeId, operationId);
  //
  // UGLY 'DEPLOY-V2'-related part
  //
  boolean isLastNotification = true;
  for (DeviceManagementOperationProperty ip : deviceManagementOperation.getInputProperties()) {
    if (ip.getName().equals("kapua.package.download.install")) {
      if (resource.equals("download")) {
        isLastNotification = !Boolean.parseBoolean(ip.getPropertyValue());
      }
      break;
    }
  }
  if (isLastNotification) {
    closeDeviceManagementOperation(scopeId, operationId, updateOn, OperationStatus.COMPLETED);
  } else {
    addManagementNotification(scopeId, operationId, updateOn, OperationStatus.COMPLETED, resource, 100);
  }
}
origin: eclipse/kapua

DeviceManagementOperationListResult newDeviceManagementOperationListResult() {
  return factory.newListResult();
}
origin: eclipse/kapua

  /**
   * Deletes the DeviceManagementOperation specified by the "deviceManagementOperationId" path parameter.
   *
   * @param deviceId                    The id of the Device in which to delete the ManagementOperation
   * @param deviceManagementOperationId The id of the DeviceManagementOperation to be deleted.
   * @return HTTP 200 if operation has completed successfully.
   * @throws Exception Whenever something bad happens. See specific {@link KapuaService} exceptions.
   * @since 1.0.0
   */
  @ApiOperation(nickname = "deviceManagementOperationDelete", value = "Delete a DeviceManagementOperation", notes = "Deletes the DeviceManagementOperation specified by the \"deviceManagementOperationId\" path parameter.")
  @DELETE
  @Path("{deviceManagementOperationId}")
  public Response deleteDeviceManagementOperation(@PathParam("scopeId") ScopeId scopeId,
                          @ApiParam(value = "The id of the Device in which to delete the ManagementOperation.", required = true) @PathParam("deviceId") EntityId deviceId,
                          @ApiParam(value = "The id of the DeviceManagementOperation to be deleted", required = true) @PathParam("deviceManagementOperationId") EntityId deviceManagementOperationId) throws Exception {
    deviceManagementOperationRegistryService.delete(scopeId, deviceManagementOperationId);

    return returnOk();
  }
}
origin: eclipse/kapua

  DeviceManagementOperationQuery newQuery() {
    return factory.newQuery(null);
  }
}
origin: eclipse/kapua

public DeviceManagementOperationCreator newDeviceManagementOperationCreator() {
  return factory.newCreator(null);
}
origin: eclipse/kapua

DeviceManagementOperation newDeviceManagementOperation() {
  return factory.newEntity(null);
}
origin: eclipse/kapua

public DeviceManagementOperationListResult newDeviceManagementOperationListResult() {
  return factory.newListResult();
}
org.eclipse.kapua.service.device.management.registry.operation

Most used classes

  • DeviceManagementOperationFactory
  • DeviceManagementOperationRegistryService
  • DeviceManagementOperation
  • DeviceManagementOperationCreator
  • DeviceManagementOperationListResult
    DeviceManagementOperationListResult definition.
  • ManagementOperationNotificationFactory,
  • DeviceManagementOperationProperty,
  • ManagementOperationNotificationCreator,
  • ManagementOperationNotificationListResult,
  • ManagementOperationNotificationQuery,
  • ManagementOperationNotificationService,
  • DeviceManagementOperationCreatorImpl,
  • DeviceManagementOperationDAO,
  • DeviceManagementOperationEntityManagerFactory,
  • DeviceManagementOperationImpl,
  • DeviceManagementOperationListResultImpl,
  • DeviceManagementOperationPropertyImpl,
  • DeviceManagementOperationQueryImpl,
  • DeviceManagementOperationRegistryServiceImpl
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now