Skip to content

Commit

Permalink
fixed parsing eventlogger requests
Browse files Browse the repository at this point in the history
  • Loading branch information
matjaz99 committed Jun 27, 2024
1 parent 73fca0b commit f1dc126
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ public class ElEvent {
private String alarmId;
private String alarmSource;
private long timestamp = 0;
private String dateTime = "";
private String alarmName = "Alarm incident";
private int severity = 0;
private String severityString = "indeterminate";
private String notificationType = "alarm";
private String sourceInfo = "";
private String additionalInfo = "";
private String customInfo = "";

public String getAlarmId() {
return alarmId;
Expand All @@ -51,6 +52,14 @@ public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}

public String getDateTime() {
return dateTime;
}

public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}

public String getAlarmName() {
return alarmName;
}
Expand Down Expand Up @@ -91,11 +100,11 @@ public void setSourceInfo(String sourceInfo) {
this.sourceInfo = sourceInfo;
}

public String getAdditionalInfo() {
return additionalInfo;
public String getCustomInfo() {
return customInfo;
}

public void setAdditionalInfo(String additionalInfo) {
this.additionalInfo = additionalInfo;
public void setCustomInfo(String customInfo) {
this.customInfo = customInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ public void processIncomingEvent(WebhookMessage m) {
try {
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
Object[] obj = gson.fromJson(m.getBody(), Object[].class);
// ElEvent am = gson.fromJson(m.getBody(), ElEvent.class);
ElMessage em = gson.fromJson(m.getBody(), ElMessage.class);
// ElMessage em = gson.fromJson(m.getBody(), ElMessage.class);

List<DEvent> list = new ArrayList<>();

for (ElEvent el : em.getEvents()) {
for (int i = 0; i < obj.length; i++) {

Gson gson2 = new Gson();
String json = gson2.toJson(obj[i]);
ElEvent el = gson.fromJson(json, ElEvent.class);

DEvent e = new DEvent();
e.setTimestamp(System.currentTimeMillis());
e.setFirstTimestamp(e.getTimestamp());
Expand All @@ -73,7 +79,7 @@ public void processIncomingEvent(WebhookMessage m) {
e.setProbableCause("1024");
e.setCurrentValue("-");
e.setUrl("");
e.setDescription(el.getAdditionalInfo());
e.setDescription(el.getCustomInfo());
e.generateUID();
e.generateCID();

Expand Down

0 comments on commit f1dc126

Please sign in to comment.