Skip to content

Commit

Permalink
Fixed JsonKapuaPayload serialization
Browse files Browse the repository at this point in the history
Signed-off-by: coduz <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Nov 21, 2019
1 parent e15f4e7 commit 4337573
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.kapua.app.api.resources.v1.resources.model.message;

import io.swagger.annotations.ApiModelProperty;
import org.eclipse.kapua.message.KapuaPayload;
import org.eclipse.kapua.message.xml.XmlAdaptedMetric;
import org.eclipse.kapua.model.type.ObjectValueConverter;
Expand All @@ -25,8 +26,6 @@
import java.util.ArrayList;
import java.util.List;

import io.swagger.annotations.ApiModelProperty;

@XmlRootElement(name = "payload")
@XmlAccessorType(XmlAccessType.PROPERTY)
public class JsonKapuaPayload {
Expand All @@ -44,12 +43,12 @@ public JsonKapuaPayload(KapuaPayload payload) {

setBody(payload.getBody());

payload.getMetrics().forEach((metricName, metricValue) -> {
XmlAdaptedMetric jsonMetric = new XmlAdaptedMetric();
payload.getMetrics().entrySet().stream().filter((metric) -> metric.getValue() != null).forEach((metric) -> {

jsonMetric.setName(metricName);
jsonMetric.setValueType(metricValue.getClass());
jsonMetric.setValue(ObjectValueConverter.toString(metricValue));
XmlAdaptedMetric jsonMetric = new XmlAdaptedMetric();
jsonMetric.setName(metric.getKey());
jsonMetric.setValueType(metric.getValue().getClass());
jsonMetric.setValue(ObjectValueConverter.toString(metric.getValue()));

getMetrics().add(jsonMetric);
});
Expand Down

0 comments on commit 4337573

Please sign in to comment.