Skip to content

Commit

Permalink
Generic transformer addition
Browse files Browse the repository at this point in the history
  • Loading branch information
surabhi-mahawar committed Jul 14, 2022
1 parent a6a3315 commit 8e8891a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public class ReactiveConsumer {
@Value("${broadcast-transformer}")
public String broadcastTransformerTopic;

@Value("${generic-transformer}")
public String genericTransformerTopic;

@Autowired
public BotService botService;

Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit 8e8891a

Please sign in to comment.