diff options
author | k.kedron <k.kedron@partner.samsung.com> | 2021-08-23 10:46:41 +0200 |
---|---|---|
committer | Pawel Slowikowski <p.slowikows2@samsung.com> | 2021-08-31 09:04:45 +0000 |
commit | e98fb976093674681dfac03fc87cdf8af295ca64 (patch) | |
tree | c896ba4cfb2b2f430f8b9b6819040503e4b0a67f | |
parent | e26f1224fb91c1ca49f4b4b37a4a5de06ba3a7ad (diff) |
Add trafficModel support
In mapped PM Bulk messaged
Issue-ID: INT-1947
Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
Change-Id: Ia8fc021a2d3edcad1ebbf74dd2a4a3323fd69652
-rw-r--r-- | datacollector/src/main/java/org/onap/rapp/datacollector/service/FileReadyParserImpl.java | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/service/FileReadyParserImpl.java b/datacollector/src/main/java/org/onap/rapp/datacollector/service/FileReadyParserImpl.java index d7f517e..831b026 100644 --- a/datacollector/src/main/java/org/onap/rapp/datacollector/service/FileReadyParserImpl.java +++ b/datacollector/src/main/java/org/onap/rapp/datacollector/service/FileReadyParserImpl.java @@ -18,14 +18,21 @@ import static java.util.Objects.nonNull; import static org.onap.rapp.datacollector.service.PMService.CELL_FIELD_NAME; import static org.onap.rapp.datacollector.service.PMService.VALUE_NAME; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; - +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.onap.rapp.datacollector.entity.fileready.FileReadyEvent; import org.onap.rapp.datacollector.entity.fileready.MeasDataCollection; import org.onap.rapp.datacollector.entity.fileready.MeasDataCollection.MeasInfo; @@ -38,19 +45,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; - @Service public class FileReadyParserImpl extends ParserAbstractClass implements VesParser { private static final Logger logger = LoggerFactory.getLogger(FileReadyParserImpl.class); + public static final String MAP_ENTITY_DELIMITER = ","; + public static final String MAP_VALUES_DELIMITER = ":"; + /** * Parse incoming Json string into list of Events * @@ -96,8 +98,7 @@ public class FileReadyParserImpl extends ParserAbstractClass implements VesParse // Adding measurement's results to additionalMeasList measValue.getMeasResults() .forEach(measResult -> { - Map<String, String> hashMap = new HashMap<>(); - hashMap.put(VALUE_NAME, measResult.getSValue()); + Map<String, String> hashMap = createAdditionalMeasurementHashMap(measResult.getSValue()); additionalMeasList.add(AdditionalMeasurements.builder() .withName(measInfo.getMeasTypes().getSMeasTypesList().get(measResult.getP() - 1)) .withHashMap(hashMap).build()); @@ -117,6 +118,16 @@ public class FileReadyParserImpl extends ParserAbstractClass implements VesParse return createdEvent; } + private Map<String, String> createAdditionalMeasurementHashMap(String value) { + if (!value.contains(MAP_ENTITY_DELIMITER)) { + return Collections.singletonMap(VALUE_NAME, value); + } else { + return Stream.of(value.split(MAP_ENTITY_DELIMITER)) + .map(m -> m.split(MAP_VALUES_DELIMITER)) + .collect(Collectors.toMap(v -> v[0], v -> v.length > 1 ? v[1] : "")); + } + } + /** * Creates CommonEventHeader as new copy of initial CommonEventHeader and sets its start/end date by average interval * |