Skip to content

Commit

Permalink
bot nodes changes
Browse files Browse the repository at this point in the history
  • Loading branch information
surabhi-mahawar committed Aug 30, 2022
1 parent d4953d3 commit 23a4a4b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main/java/com/uci/utils/bot/util/BotUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.ArrayNode;
import io.r2dbc.postgresql.codec.Json;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -207,6 +212,30 @@ public static String getBotNodeAdapterId(JsonNode botNode) {
return "";
}

/**
* Get adapter id from bot json node
* @param botNode
* @return
*/
public static List<String> getBotNodeTags(JsonNode botNode) {
if(botNode.path("tags") != null) {
List<String> list = null;
try{
ArrayNode arrayNode = (ArrayNode) botNode.path("tags");
ObjectMapper mapper = new ObjectMapper();
ObjectReader reader = mapper.readerFor(new TypeReference<List<String>>() {
});
// use it
list = reader.readValue(arrayNode);
} catch (Exception ex) {
log.error("Exception in getBotNodeTags: "+ex.getMessage());
}

return list;
}
return null;
}

/**
* Get adapter id from bot json node
* @param botNode
Expand Down

0 comments on commit 23a4a4b

Please sign in to comment.