summaryrefslogtreecommitdiffstats
path: root/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves
diff options
context:
space:
mode:
Diffstat (limited to 'datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves')
-rw-r--r--datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/AdditionalMeasurementValues.java48
-rw-r--r--datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/AdditionalMeasurements.java84
-rw-r--r--datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/CommonEventHeader.java66
-rw-r--r--datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/Event.java62
-rw-r--r--datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/EventAPI.java46
-rw-r--r--datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/MeasurementFields.java48
-rw-r--r--datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/RawPayload.java57
7 files changed, 411 insertions, 0 deletions
diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/AdditionalMeasurementValues.java b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/AdditionalMeasurementValues.java
new file mode 100644
index 0000000..2add40f
--- /dev/null
+++ b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/AdditionalMeasurementValues.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 Samsung Electronics
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+package org.onap.rapp.datacollector.entity.ves;
+
+import lombok.Builder;
+import lombok.Data;
+import lombok.ToString;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.Table;
+
+@Data
+@Builder
+@ToString
+@Table("additional_measurement_value")
+public class AdditionalMeasurementValues {
+ @Column("am_name")
+ public final String name;
+ @Column("am_key")
+ public final String parameterName;
+ @Column("am_value")
+ public final String parameterValue;
+
+ public AdditionalMeasurementValues(String name, String parameterName, String parameterValue) {
+ this.name = name;
+ this.parameterName = parameterName;
+ this.parameterValue = parameterValue;
+ }
+
+ public static AdditionalMeasurementValues of(String name, String parameterName, String parameterValue) {
+ return AdditionalMeasurementValues.builder()
+ .name(name)
+ .parameterName(parameterName)
+ .parameterValue(parameterValue)
+ .build();
+ }
+}
diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/AdditionalMeasurements.java b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/AdditionalMeasurements.java
new file mode 100644
index 0000000..10d49ff
--- /dev/null
+++ b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/AdditionalMeasurements.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2021 Samsung Electronics
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+package org.onap.rapp.datacollector.entity.ves;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import lombok.Data;
+import lombok.ToString;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.Table;
+
+@Data
+@ToString
+@Table("additional_measurement")
+public class AdditionalMeasurements implements Serializable {
+ final Long eventId;
+ @Column("am_name")
+ public final String name;
+ public final List<AdditionalMeasurementValues> values;
+
+ private AdditionalMeasurements(Long eventId, String name, Map<String, String> hashMap) {
+ this.eventId = eventId;
+ this.name = name;
+ this.values = hashMap.keySet()
+ .stream()
+ .map(key -> AdditionalMeasurementValues.of(this.name, key, hashMap.getOrDefault(key, ""))
+ ).collect(Collectors.toUnmodifiableList());
+ }
+
+ @JsonCreator
+ public static AdditionalMeasurements of(@JsonProperty("name") String name, @JsonProperty("hashMap") Map<String, String> hashMap) {
+ return new AdditionalMeasurements(null, name, hashMap);
+ }
+
+ public static AdditionalMeasurements of(Long eventId, String name, Map<String, String> hashMap) {
+ return new AdditionalMeasurements(eventId, name, hashMap);
+ }
+
+ public static AdditionalMeasurementsBuilder builder() {
+ return new AdditionalMeasurementsBuilder();
+ }
+
+ public static class AdditionalMeasurementsBuilder {
+ private long eventId;
+ private String name;
+ private Map<String, String> hashMap;
+
+ public AdditionalMeasurementsBuilder withEventId(long id) {
+ this.eventId = id;
+ return this;
+ }
+
+ public AdditionalMeasurementsBuilder withName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public AdditionalMeasurementsBuilder withHashMap(Map<String, String> hashMap) {
+ this.hashMap = Collections.unmodifiableMap(hashMap);
+ return this;
+ }
+
+ public AdditionalMeasurements build() {
+ return new AdditionalMeasurements(eventId, name, hashMap);
+ }
+ }
+}
diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/CommonEventHeader.java b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/CommonEventHeader.java
new file mode 100644
index 0000000..e9d3f75
--- /dev/null
+++ b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/CommonEventHeader.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 Samsung Electronics
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+package org.onap.rapp.datacollector.entity.ves;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.data.annotation.Transient;
+
+@Data
+@EqualsAndHashCode
+@ToString
+@Builder
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CommonEventHeader {
+ public final String eventType;
+ public final String version;
+ public final String sourceId;
+ public final String reportingEntityName;
+ public final Long startEpochMicrosec;
+ public final String eventId;
+ public final Long lastEpochMicrosec;
+ public final String priority;
+ public final Integer sequence;
+ public final String sourceName;
+ public final String domain;
+ public final String eventName;
+ public final String reportingEntityId;
+ public final String nfcNamingCode;
+ public final String nfNamingCode;
+ @Transient
+ public final String timeZoneOffset;
+
+ protected CommonEventHeader(String eventType, String version, String sourceId, String reportingEntityName, Long startEpochMicrosec, String eventId, Long lastEpochMicrosec, String priority, Integer sequence, String sourceName, String domain, String eventName, String reportingEntityId, String nfcNamingCode, String nfNamingCode, String timeZone) {
+ this.eventType = eventType;
+ this.version = version;
+ this.sourceId = sourceId;
+ this.reportingEntityName = reportingEntityName;
+ this.startEpochMicrosec = startEpochMicrosec;
+ this.eventId = eventId;
+ this.lastEpochMicrosec = lastEpochMicrosec;
+ this.priority = priority;
+ this.sequence = sequence;
+ this.sourceName = sourceName;
+ this.domain = domain;
+ this.eventName = eventName;
+ this.reportingEntityId = reportingEntityId;
+ this.nfcNamingCode = nfcNamingCode;
+ this.nfNamingCode = nfNamingCode;
+ this.timeZoneOffset = timeZone;
+ }
+}
diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/Event.java b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/Event.java
new file mode 100644
index 0000000..2d00636
--- /dev/null
+++ b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/Event.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2021 Samsung Electronics
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+package org.onap.rapp.datacollector.entity.ves;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import lombok.Getter;
+import lombok.ToString;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.Embedded;
+import org.springframework.data.relational.core.mapping.Table;
+
+@JsonTypeName("event")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Table("ves_measurement")
+@ToString
+@Getter
+public class Event {
+ @Id
+ Long id;
+
+ @Column("rawdata")
+ public volatile String raw;
+
+ @Embedded(onEmpty = Embedded.OnEmpty.USE_NULL)
+ public final CommonEventHeader commonEventHeader;
+
+ @Column("event_id")
+ public final MeasurementFields measurementFields;
+
+ protected Event(final Long id, CommonEventHeader header, MeasurementFields fields, String raw) {
+ this.id = id;
+ this.commonEventHeader = header;
+ this.measurementFields = fields;
+ this.raw = raw;
+ }
+
+ public static Event of(CommonEventHeader header, MeasurementFields fields) {
+ return new Event(null, header, fields, "");
+ }
+
+ public static Event of(final Long id, CommonEventHeader header, MeasurementFields fields) {
+ return new Event(id, header, fields, "");
+ }
+
+ public static Event of(final Long id, CommonEventHeader header, MeasurementFields fields, String raw) {
+ return new Event(id, header, fields, raw);
+ }
+}
diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/EventAPI.java b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/EventAPI.java
new file mode 100644
index 0000000..95e9bfb
--- /dev/null
+++ b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/EventAPI.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2021 Samsung Electronics
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+
+package org.onap.rapp.datacollector.entity.ves;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@EqualsAndHashCode
+@Builder
+@Entity
+@Table(name = "ves_measurement")
+public class EventAPI {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String rawdata;
+
+ private Long lastEpochMicrosec;
+}
diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/MeasurementFields.java b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/MeasurementFields.java
new file mode 100644
index 0000000..802aace
--- /dev/null
+++ b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/MeasurementFields.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 Samsung Electronics
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package org.onap.rapp.datacollector.entity.ves;
+
+import java.util.Collections;
+import java.util.List;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.Table;
+
+@Data
+@ToString
+@EqualsAndHashCode
+@Builder
+@Table("ves_measurement_fields")
+public class MeasurementFields {
+ public static final MeasurementFields EMPTY = new MeasurementFields(-1L, -1L, Collections.emptyList());
+ public final Long eventId;
+ public final long measurementInterval;
+ public final String measurementFieldsVersion = "4.0";
+
+ @Column("event_id")
+ public final List<AdditionalMeasurements> additionalMeasurements;
+
+ private MeasurementFields(Long eventId, long measurementInterval, List<AdditionalMeasurements> additionalMeasurements) {
+ this.eventId = eventId;
+ this.measurementInterval = measurementInterval;
+ this.additionalMeasurements = Collections.unmodifiableList(additionalMeasurements);
+ }
+
+ public static MeasurementFields of(Long eventId) {
+ return new MeasurementFields(eventId, -1, Collections.emptyList());
+ }
+}
diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/RawPayload.java b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/RawPayload.java
new file mode 100644
index 0000000..0a7fe03
--- /dev/null
+++ b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/RawPayload.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2021 Samsung Electronics
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package org.onap.rapp.datacollector.entity.ves;
+
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.Table;
+
+@ToString
+@EqualsAndHashCode
+@Table("payload")
+public class RawPayload {
+ @Id
+ public final Long eventId;
+ public final String payload;
+
+ private RawPayload(Long eventId, String payload) {
+ this.eventId = eventId;
+ this.payload = payload;
+ }
+
+ public static class RawPayloadBuilder {
+ @Id
+ private Long eventId;
+ private String payload;
+
+ public RawPayloadBuilder withEvent(Long event) {
+ this.eventId = event;
+ return this;
+ }
+
+ public RawPayloadBuilder withPayload(String payload) {
+ this.payload = payload;
+ return this;
+ }
+
+ public RawPayload build() {
+ return new RawPayload(eventId, payload);
+ }
+ }
+
+ public static RawPayloadBuilder builder() {
+ return new RawPayloadBuilder();
+ }
+}