Skip to content

Commit

Permalink
Merge pull request #3 from ControlSystemStudio/master
Browse files Browse the repository at this point in the history
Update with community.
  • Loading branch information
iTerminate authored Mar 13, 2023
2 parents 428860c + d9ca4d3 commit 82dc0b4
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
* A Job to retrieve the latest alarm configuration details
*
* @author Kunal Shroff
*/
public class AlarmLogConfigSearchJob extends JobRunnableWithCancel {
Expand All @@ -31,7 +30,6 @@ public class AlarmLogConfigSearchJob extends JobRunnableWithCancel {
private final BiConsumer<String, Exception> errorHandler;

private final ObjectMapper objectMapper;
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS").withZone(ZoneId.of("UTC"));

public static Job submit(WebResource client,
final String pattern,
Expand Down Expand Up @@ -62,19 +60,20 @@ public String getName() {
@Override
public Runnable getRunnable() {
return () -> {
AlarmLogTableApp.logger.info("searching for alarm log entires : " +
AlarmLogTableApp.logger.info("searching for config log entries : " +
"config: " + pattern);

try {
MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
map.put("config", Arrays.asList(pattern));
map.put("size", Arrays.asList(String.valueOf(1)));
List<AlarmLogTableItem> result = objectMapper
.readValue(client.path("/search/alarm/").queryParams(map).accept(MediaType.APPLICATION_JSON).get(String.class),
.readValue(client.path("/search/alarm/config").queryParams(map).accept(MediaType.APPLICATION_JSON).get(String.class),
new TypeReference<List<AlarmLogTableItem>>() {
});
if (result.size() >= 1) {
alarmMessageHandler.accept(result.get(0));
} else {
alarmMessageHandler.accept(null);
}
} catch (JsonProcessingException e) {
errorHandler.accept("Failed to search for alarm logs ", e);
Expand Down
Loading

0 comments on commit 82dc0b4

Please sign in to comment.