From 8e8891a6af1e6dc9a542f3f34d8e17411f5bba0d Mon Sep 17 00:00:00 2001 From: Surabhi Date: Thu, 14 Jul 2022 10:51:40 +0530 Subject: [PATCH] Generic transformer addition --- .../com/uci/orchestrator/Consumer/ReactiveConsumer.java | 9 +++++++++ src/main/resources/application.properties | 1 + 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/uci/orchestrator/Consumer/ReactiveConsumer.java b/src/main/java/com/uci/orchestrator/Consumer/ReactiveConsumer.java index d96fe04..a165dfd 100644 --- a/src/main/java/com/uci/orchestrator/Consumer/ReactiveConsumer.java +++ b/src/main/java/com/uci/orchestrator/Consumer/ReactiveConsumer.java @@ -100,6 +100,9 @@ public class ReactiveConsumer { @Value("${broadcast-transformer}") public String broadcastTransformerTopic; + @Value("${generic-transformer}") + public String genericTransformerTopic; + @Autowired public BotService botService; @@ -167,6 +170,8 @@ public void accept(XMessage msg) { log.info("final msg.toXML(): "+msg.toXML().toString()); if(firstTransformer.get("type") != null && firstTransformer.get("type").asText().equals("broadcast")) { kafkaProducer.send(broadcastTransformerTopic, msg.toXML()); + } else if(firstTransformer.get("type") != null && firstTransformer.get("type").asText().equals("generic")) { + kafkaProducer.send(genericTransformerTopic, msg.toXML()); } else { kafkaProducer.send(odkTransformerTopic, msg.toXML()); } @@ -242,6 +247,10 @@ private XMessage setXMessageTransformers(XMessage xMessage, JsonNode campaign) { metaData.put("federatedUsers", getFederatedUsersMeta(campaign, transformer)); } + if(transformer.get("type") != null && transformer.get("type").asText().equals("generic")) { + metaData.put("url", transformer.findValue("url").asText()); + } + if(transformer.findValue("hiddenFields") != null && !transformer.findValue("hiddenFields").isEmpty()) { metaData.put("hiddenFields", campaign.findValue("hiddenFields").toString()); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cb56af6..746902f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -13,6 +13,7 @@ inbound-error=${KAFKA_INBOUND_ERROR_TOPIC} odk-transformer=${KAFKA_ODK_TRANSFORMER_TOPIC} kafka.logs.topic = logs broadcast-transformer=${KAFKA_BROADCAST_TRANSFORMER_TOPIC:#{"broadcast-transformer"}} +generic-transformer=${KAFKA_GENERIC_TRANSFORMER_TOPIC:#{"generic-transformer"}} processOutbound=${KAFKA_PROCESS_OUTBOUND} outbound=${KAFKA_OUTBOUND_TOPIC}