Codota Logo
KapuaDataMessage
Code IndexAdd Codota to your IDE (free)

How to use
KapuaDataMessage
in
org.eclipse.kapua.message.device.data

Best Java code snippets using org.eclipse.kapua.message.device.data.KapuaDataMessage (Showing top 18 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: eclipse/kapua

public JsonKapuaDataMessage(KapuaDataMessage kapuaDataMessage) {
  setId(kapuaDataMessage.getId());
  setScopeId(kapuaDataMessage.getScopeId());
  setDeviceId(kapuaDataMessage.getDeviceId());
  setClientId(kapuaDataMessage.getClientId());
  setReceivedOn(kapuaDataMessage.getReceivedOn());
  setSentOn(kapuaDataMessage.getSentOn());
  setCapturedOn(kapuaDataMessage.getCapturedOn());
  setPosition(kapuaDataMessage.getPosition());
  setChannel(kapuaDataMessage.getChannel());
  setPayload(kapuaDataMessage.getPayload());
}
origin: eclipse/kapua

    tmpTopic.getTopic(),
    null);
tmpMsg.setCapturedOn(capturedOn);
tmpMsg.setSentOn(sentOn);
tmpMsg.setReceivedOn(receivedOn);
tmpMsg.getPayload().getMetrics().put(metrics[0], metricsValuesDate[i % metricsValuesDate.length]);
tmpMsg.getPayload().getMetrics().put(metrics[1], metricsValuesString[i % metricsValuesString.length]);
tmpMsg.getPayload().getMetrics().put(metrics[2], metricsValuesInt[i % metricsValuesInt.length]);
tmpMsg.getPayload().getMetrics().put(metrics[3], metricsValuesFloat[i % metricsValuesFloat.length]);
tmpMsg.getPayload().getMetrics().put(metrics[4], metricsValuesBoolean[i % metricsValuesBoolean.length]);
tmpMsg.getPayload().getMetrics().put(metrics[5], metricsValuesDouble[i % metricsValuesDouble.length]);
tmpList.add(tmpMsg);
origin: eclipse/kapua

private void checkChannelInfoAgainstPreparedMessages(ChannelInfoListResult chnInfo, List<KapuaDataMessage> msgLst) {
  Set<String> msgTopics = new HashSet<>();
  Set<String> msgClients = new HashSet<>();
  Set<String> infoTopics = new HashSet<>();
  Set<String> infoClients = new HashSet<>();
  assertNotNull("No channel info data!", chnInfo);
  assertNotNull("No messages to compare to!", msgLst);
  for (KapuaDataMessage tmpMsg : msgLst) {
    msgClients.add(tmpMsg.getClientId());
    msgTopics.add(tmpMsg.getChannel().toString());
  }
  for (ChannelInfo tmpInfo : chnInfo.getItems()) {
    infoClients.add(tmpInfo.getClientId());
    infoTopics.add(tmpInfo.getName());
  }
  assertEquals("The number of clients does not match!", msgClients.size(), infoClients.size());
  assertEquals("The number of topics does not match!", msgTopics.size(), infoTopics.size());
  for (String tmpTopic : msgTopics) {
    assertTrue(String.format("The topic [%s] is not found in the info list!", tmpTopic), infoTopics.contains(tmpTopic));
  }
  for (String tmpClient : msgClients) {
    assertTrue(String.format("The client id [%s] is not found in the info list!", tmpClient), infoClients.contains(tmpClient));
  }
}
origin: eclipse/kapua

private boolean checkThatTheInsertedMessageMatchesTheOriginal(KapuaDataMessage origMsg, DatastoreMessage foundMsg) throws KapuaException {
  assertTrue(areSemanticPartsEqual(origMsg.getChannel().getSemanticParts(), foundMsg.getChannel().getSemanticParts()));
  if (origMsg.getPayload() != null) {
    assertArrayEquals(origMsg.getPayload().getBody(), foundMsg.getPayload().getBody());
    assertTrue(areMetricsEqual(origMsg.getPayload().getMetrics(), foundMsg.getPayload().getMetrics()));
  }
  assertTrue(arePositionsEqual(origMsg.getPosition(), foundMsg.getPosition()));
  assertTrue(foundMsg.getTimestamp().compareTo(origMsg.getReceivedOn()) >= 0);
  assertTrue(foundMsg.getTimestamp().compareTo(new Date(origMsg.getReceivedOn().getTime() + 10000)) <= 0);
  assertEquals(origMsg.getCapturedOn(), foundMsg.getCapturedOn());
  assertEquals(origMsg.getSentOn(), foundMsg.getSentOn());
  assertEquals(origMsg.getReceivedOn(), foundMsg.getReceivedOn());
  return true;
}
origin: eclipse/kapua

kapuaDataMessage.setId(jsonKapuaDataMessage.getId());
kapuaDataMessage.setScopeId(scopeId);
kapuaDataMessage.setDeviceId(jsonKapuaDataMessage.getDeviceId());
kapuaDataMessage.setClientId(jsonKapuaDataMessage.getClientId());
kapuaDataMessage.setReceivedOn(jsonKapuaDataMessage.getReceivedOn());
kapuaDataMessage.setSentOn(jsonKapuaDataMessage.getSentOn());
kapuaDataMessage.setCapturedOn(jsonKapuaDataMessage.getCapturedOn());
kapuaDataMessage.setPosition(jsonKapuaDataMessage.getPosition());
kapuaDataMessage.setChannel(jsonKapuaDataMessage.getChannel());
    });
kapuaDataMessage.setPayload(kapuaDataPayload);
origin: eclipse/kapua

@Override
public KuraDataMessage translate(KapuaDataMessage kapuaDataMessage)
    throws KapuaException {
  KapuaLocator locator = KapuaLocator.getInstance();
  AccountService accountService = locator.getService(AccountService.class);
  Account account = accountService.find(kapuaDataMessage.getScopeId());
  if (account == null) {
    throw new KapuaEntityNotFoundException(Account.TYPE, kapuaDataMessage.getScopeId());
  }
  //
  // Kapua Channel
  KuraDataChannel kuraDataChannel = translate(kapuaDataMessage.getChannel());
  kuraDataChannel.setClientId(kapuaDataMessage.getClientId());
  kuraDataChannel.setScope(account.getName());
  //
  // Kapua payload
  KuraDataPayload kuraDataPayload = translate(kapuaDataMessage.getPayload());
  kuraDataPayload.setBody(kapuaDataMessage.getPayload().getBody());
  kuraDataPayload.setMetrics(kapuaDataMessage.getPayload().getMetrics());
  kuraDataPayload.setPosition(TranslatorKapuaKuraUtils.translate(kapuaDataMessage.getPosition()));
  kuraDataPayload.setTimestamp(kapuaDataMessage.getSentOn());
  //
  // Kapua message
  KuraDataMessage kuraDataMessage = new KuraDataMessage();
  kuraDataMessage.setChannel(kuraDataChannel);
  kuraDataMessage.setPayload(kuraDataPayload);
  // Return Kapua Message
  return kuraDataMessage;
}
origin: eclipse/kapua

ArgumentValidator.notNull(requestMessage.getScopeId(), "scopeId");
ArgumentValidator.notNull(requestMessage.getDeviceId(), "deviceId");
ArgumentValidator.notNull(requestMessage.getClientId(), "clientId");
AUTHORIZATION_SERVICE.checkPermission(PERMISSION_FACTORY.newPermission(StreamDomains.STREAM_DOMAIN, Actions.write, requestMessage.getScopeId()));
try {
  Device device = DEVICE_REGISTRY_SERVICE.find(requestMessage.getScopeId(), requestMessage.getDeviceId());
    throw new KapuaEntityNotFoundException(Device.TYPE, requestMessage.getDeviceId());
origin: eclipse/kapua

private void checkMetricInfoAgainstPreparedMessages(MetricInfoListResult metInfo, List<KapuaDataMessage> msgLst) {
  Set<String> msgMetrics = new HashSet<>();
  Set<String> msgClients = new HashSet<>();
  Set<String> infoMetrics = new HashSet<>();
  Set<String> infoClients = new HashSet<>();
  assertNotNull("No channel info data!", metInfo);
  assertNotNull("No messages to compare to!", msgLst);
  for (KapuaDataMessage tmpMsg : msgLst) {
    msgClients.add(tmpMsg.getClientId());
    for (String tmpMet : tmpMsg.getPayload().getMetrics().keySet()) {
      msgMetrics.add(tmpMet);
    }
  }
  for (MetricInfo tmpMet : metInfo.getItems()) {
    infoClients.add(tmpMet.getClientId());
    infoMetrics.add(tmpMet.getName());
  }
  assertEquals("The number of clients does not match!", msgClients.size(), infoClients.size());
  assertEquals("The number of topics does not match!", msgMetrics.size(), infoMetrics.size());
  for (String tmpMetric : msgMetrics) {
    assertTrue(String.format("The topic [%s] is not found in the info list!", tmpMetric), infoMetrics.contains(tmpMetric));
  }
  for (String tmpClient : msgClients) {
    assertTrue(String.format("The client id [%s] is not found in the info list!", tmpClient), infoClients.contains(tmpClient));
  }
}
origin: eclipse/kapua

@And("^I set the following metrics to the message (\\d+) from the list \"(.+)\"$")
public void appendMetricsToSelectedMessage(int idx, String lstKey, List<TestMetric> metLst) throws Exception {
  List<KapuaDataMessage> tmpMsgLst = (List<KapuaDataMessage>) stepData.get(lstKey);
  KapuaDataMessage tmpMsg = tmpMsgLst.get(idx);
  tmpMsg.setPayload(new KapuaDataPayloadImpl());
  for (TestMetric tmpMet : metLst) {
    switch (tmpMet.getType().trim().toLowerCase()) {
    case "string": {
      tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), tmpMet.getValue());
      break;
    }
    case "int": {
      tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Integer.valueOf(tmpMet.getValue()));
      break;
    }
    case "double": {
      tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Double.valueOf(tmpMet.getValue()));
      break;
    }
    case "bool": {
      tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Boolean.valueOf(tmpMet.getValue().trim().toUpperCase()));
      break;
    }
    default: {
      fail(String.format("Unknown metric type [%s]", tmpMet.getType()));
      break;
    }
    }
  }
}
origin: eclipse/kapua

private void checkClientInfoAgainstPreparedMessages(ClientInfoListResult cliInfo, List<KapuaDataMessage> msgLst) {
  Set<String> msgClients = new HashSet<>();
  Set<String> infoClients = new HashSet<>();
  assertNotNull("No client info data!", cliInfo);
  assertNotNull("No messages to compare to!", msgLst);
  for (KapuaDataMessage tmpMsg : msgLst) {
    msgClients.add(tmpMsg.getClientId());
  }
  for (ClientInfo tmpClient : cliInfo.getItems()) {
    infoClients.add(tmpClient.getClientId());
  }
  assertEquals("The number of clients does not match!", msgClients.size(), infoClients.size());
  for (String tmpClient : msgClients) {
    assertTrue(String.format("The client id [%s] is not found in the info list!", tmpClient), infoClients.contains(tmpClient));
  }
}
origin: eclipse/kapua

@Given("^I store the messages from list \"(.*)\" with the server time and remember the IDs as \"(.*)\"$")
public void insertRandomMessagesIntoDatastoreWithCurrentTimestamps(String msgListKey, String idListKey) throws KapuaException {
  List<KapuaDataMessage> tmpMsgList = (List<KapuaDataMessage>) stepData.get(msgListKey);
  StorableId tmpId = null;
  List<StorableId> tmpList = new ArrayList<>();
  for (KapuaDataMessage tmpMsg : tmpMsgList) {
    tmpMsg.setReceivedOn(new Date());
    tmpId = insertMessageInStore(tmpMsg);
    tmpList.add(tmpId);
  }
  stepData.put(idListKey, tmpList);
}
origin: eclipse/kapua

@Given("^I prepare a random message with null payload and save it as \"(.*)\"$")
public void prepareRandomMessageWithNullPayload(String msgKey) throws Exception {
  KapuaDataMessage tmpMessage = createTestMessage(
      ((Account) stepData.get("LastAccount")).getId(),
      ((Device) stepData.get("LastDevice")).getId(),
      ((Device) stepData.get("LastDevice")).getClientId(),
      null, null);
  tmpMessage.setPayload(null);
  stepData.put(msgKey, tmpMessage);
}
origin: eclipse/kapua

@Then("^The datastore message \"(.*)\" matches the prepared message \"(.*)\"$")
public void checkThatTheStoredMessageMatchesTheOriginal(String datastoreMsgKey, String originalMsgKey) throws KapuaException {
  KapuaDataMessage origMsg = (KapuaDataMessage) stepData.get(originalMsgKey);
  DatastoreMessage foundMsg = (DatastoreMessage) stepData.get(datastoreMsgKey);
  checkThatTheInsertedMessageMatchesTheOriginal(origMsg, foundMsg);
  isChannelForFirstMessageInStoreOK(foundMsg.getDatastoreId(), foundMsg.getTimestamp());
  isClientForFirstMessageInStoreOK(foundMsg.getDatastoreId(), foundMsg.getTimestamp());
  if (origMsg.getPayload() != null) {
    isMetricForFirstMessageInStoreOK(foundMsg.getDatastoreId(), foundMsg.getTimestamp());
  }
}
origin: eclipse/kapua

KapuaDataMessage kapuaDataMessage = new KapuaDataMessageImpl();
kapuaDataMessage.setId(jsonKapuaDataMessage.getId());
kapuaDataMessage.setScopeId(scopeId);
kapuaDataMessage.setDeviceId(jsonKapuaDataMessage.getDeviceId());
kapuaDataMessage.setClientId(jsonKapuaDataMessage.getClientId());
kapuaDataMessage.setReceivedOn(jsonKapuaDataMessage.getReceivedOn());
kapuaDataMessage.setSentOn(jsonKapuaDataMessage.getSentOn());
kapuaDataMessage.setCapturedOn(jsonKapuaDataMessage.getCapturedOn());
kapuaDataMessage.setPosition(jsonKapuaDataMessage.getPosition());
kapuaDataMessage.setChannel(jsonKapuaDataMessage.getChannel());
kapuaDataMessage.setPayload(kapuaDataPayload);
origin: org.eclipse.kapua/kapua-translator-kapua-kura

@Override
public KuraDataMessage translate(KapuaDataMessage kapuaDataMessage)
    throws KapuaException {
  KapuaLocator locator = KapuaLocator.getInstance();
  AccountService accountService = locator.getService(AccountService.class);
  Account account = accountService.find(kapuaDataMessage.getScopeId());
  if (account == null) {
    throw new KapuaEntityNotFoundException(Account.TYPE, kapuaDataMessage.getScopeId());
  }
  //
  // Kapua Channel
  KuraDataChannel kuraDataChannel = translate(kapuaDataMessage.getChannel());
  kuraDataChannel.setClientId(kapuaDataMessage.getClientId());
  kuraDataChannel.setScope(account.getName());
  //
  // Kapua payload
  KuraDataPayload kuraDataPayload = translate(kapuaDataMessage.getPayload());
  kuraDataPayload.setBody(kapuaDataMessage.getPayload().getBody());
  kuraDataPayload.setMetrics(kapuaDataMessage.getPayload().getMetrics());
  kuraDataPayload.setPosition(TranslatorKapuaKuraUtils.translate(kapuaDataMessage.getPosition()));
  kuraDataPayload.setTimestamp(kapuaDataMessage.getSentOn());
  //
  // Kapua message
  KuraDataMessage kuraDataMessage = new KuraDataMessage();
  kuraDataMessage.setChannel(kuraDataChannel);
  kuraDataMessage.setPayload(kuraDataPayload);
  // Return Kapua Message
  return kuraDataMessage;
}
origin: eclipse/kapua

@Given("^I store the message \"(.*)\" with the server time and remember its ID as \"(.*)\"$")
public void insertRandomMessageIntoDatastoreWithCurrentTimestamp(String msgKey, String idKey) throws KapuaException {
  KapuaDataMessage tmpMessage = (KapuaDataMessage) stepData.get(msgKey);
  tmpMessage.setReceivedOn(new Date());
  StorableId storeId = insertMessageInStore(tmpMessage);
  stepData.put(idKey, storeId);
}
origin: eclipse/kapua

kapuaDataMessage.setScopeId(account.getId());
kapuaDataMessage.setDeviceId(device != null ? device.getId() : null);
kapuaDataMessage.setClientId(kuraDataMessage.getChannel().getClientId());
kapuaDataMessage.setChannel(kapuaDataChannel);
kapuaDataMessage.setPayload(kapuaDataPayload);
kapuaDataMessage.setCapturedOn(kuraDataMessage.getPayload().getTimestamp());
kapuaDataMessage.setSentOn(kuraDataMessage.getPayload().getTimestamp());
kapuaDataMessage.setReceivedOn(kuraDataMessage.getTimestamp());
kapuaDataMessage.setPosition(TranslatorKuraKapuaUtils.translate(kuraDataMessage.getPayload().getPosition()));
origin: org.eclipse.kapua/kapua-translator-kapua-kura

kapuaDataMessage.setScopeId(account.getId());
kapuaDataMessage.setDeviceId(device != null ? device.getId() : null);
kapuaDataMessage.setClientId(kuraDataMessage.getChannel().getClientId());
kapuaDataMessage.setChannel(kapuaDataChannel);
kapuaDataMessage.setPayload(kapuaDataPayload);
kapuaDataMessage.setCapturedOn(kuraDataMessage.getPayload().getTimestamp());
kapuaDataMessage.setSentOn(kuraDataMessage.getPayload().getTimestamp());
kapuaDataMessage.setReceivedOn(kuraDataMessage.getTimestamp());
kapuaDataMessage.setPosition(TranslatorKuraKapuaUtils.translate(kuraDataMessage.getPayload().getPosition()));
org.eclipse.kapua.message.device.dataKapuaDataMessage

Javadoc

Kapua data message object definition.

Most used methods

  • getClientId
  • getChannel
  • getPayload
  • getPosition
  • getScopeId
  • getSentOn
  • setCapturedOn
  • setPayload
  • setReceivedOn
  • setSentOn
  • getCapturedOn
  • getDeviceId
  • getCapturedOn,
  • getDeviceId,
  • getReceivedOn,
  • setChannel,
  • setClientId,
  • setDeviceId,
  • setPosition,
  • setScopeId,
  • getId,
  • setId

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • onCreateOptionsMenu (Activity)
  • putExtra (Intent)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • ResourceBundle (java.util)
    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • JLabel (javax.swing)
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