Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class YouTrackEventTransformer implements IEventTransformer{
- private BlockingQueue<JsonNode> receivedEventData;
- private BlockingQueue<Event> transformedEvents;
- private ObjectMapper mapper;
- public YouTrackEventTransformer(BlockingQueue<JsonNode> receivedEventData,
- BlockingQueue<Event> transformedEvents){
- receivedEventData = receivedEventData;
- transformedEvents = transformedEvents;
- // Объявляем класс mapper для сериализации и десериализации JSON
- mapper = new ObjectMapper();
- }
- public void transform() {
- while (!receivedEventData.isEmpty) {
- JsonNode jsonData = receivedEventData.take;
- /* В зависимости от типа извлечённых данных вызываем
- соответствующий метод преобразования */
- switch (mapper.getValue("type").textValue()) {
- case "IssueCreated":
- transformIssueCreatedActivity(jsonData);
- break;
- case "IssueResolved":
- transformIssueCreatedActivity(jsonData);
- break;
- case "Comment":
- transformCommentActivity(jsonData);
- break;
- case "CommentAttachment"
- transformCommentAttachmentActivity(jsonData);
- break;
- case "TimeTrack":
- transformTimeTrackActivity(jsonData);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement