use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class CacheExpiryEvent method getEventNavajo.
@Override
public Navajo getEventNavajo() {
Navajo input = NavajoFactory.getInstance().createNavajo();
Message event = NavajoFactory.getInstance().createMessage(input, "__event__");
try {
input.addMessage(event);
Property eventWebService = NavajoFactory.getInstance().createProperty(input, "Webservice", Property.STRING_PROPERTY, getWebservice(), 0, "", Property.DIR_OUT);
event.addProperty(eventWebService);
Property eventKey = NavajoFactory.getInstance().createProperty(input, "Key", Property.STRING_PROPERTY, getKey(), 0, "", Property.DIR_OUT);
event.addProperty(eventKey);
} catch (NavajoException e) {
logger.error("Error: ", e);
}
return input;
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class JsonTmlConverterImpl method toReplicationNavajo.
/* (non-Javadoc)
* @see com.dexels.navajo.document.json.impl.JsonTmlConferter#toNavajo(com.dexels.replication.api.ReplicationMessage, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public Navajo toReplicationNavajo(ReplicationMessage message, String tenant, String table, Optional<String> datasource) {
try {
Navajo n = NavajoFactory.getInstance().createNavajo();
Message msg = createTransactionMessage(message, tenant, table, datasource, n);
n.addMessage(msg);
// Add PK values.
Message pM = createPrimaryKeyMessage(message, n);
msg.addMessage(pM);
// Add column values.
Message cV = createColumnsMessage(message, n);
msg.addMessage(cV);
// }
return n;
} catch (Exception e) {
logger.error("Error: ", e);
}
return null;
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class JsonTmlConverterImpl method toNode.
/* (non-Javadoc)
* @see com.dexels.navajo.document.json.impl.JsonTmlConferter#toNode(com.dexels.navajo.document.Message, java.lang.String)
*/
@Override
public ObjectNode toNode(Message m, final String primaryKeys) {
ObjectNode result = createTopLevel(primaryKeys);
ObjectNode columnValuesList = objectMapper.createObjectNode();
result.set("Columns", columnValuesList);
List<Property> allProperties = m.getAllProperties();
if (allProperties != null) {
for (Property p : allProperties) {
ObjectNode o = objectMapper.createObjectNode();
o.put("Type", p.getType());
o.put("Value", p.getValue());
columnValuesList.set(p.getName(), o);
}
}
for (Message submessage : m.getAllMessages()) {
String name = submessage.getName();
if (Message.MSG_TYPE_ARRAY.equals((submessage.getType()))) {
ArrayNode node = objectMapper.createArrayNode();
for (Message element : submessage.getAllMessages()) {
node.add(toNode(element, primaryKeys));
}
ObjectNode submessages = ensureSub("SubMessage", result);
submessages.set(name, node);
} else {
ObjectNode submsg = ensureSub("SubMessage", result);
submsg.set(name, toNode(submessage, primaryKeys));
}
}
return result;
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class JsonTmlConverterImpl method toFlatNavajo.
@Override
public Navajo toFlatNavajo(String name, ImmutableMessage message) {
Navajo rootNavajo = NavajoFactory.getInstance().createNavajo();
Message root = toMessage(name, message, rootNavajo);
rootNavajo.addMessage(root);
return rootNavajo;
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class NavajoDomStreamer method processNavajo.
public static List<NavajoStreamEvent> processNavajo(Navajo navajo) {
List<NavajoStreamEvent> result = new ArrayList<>();
Navajo output = NavajoFactory.getInstance().createNavajo();
List<Message> all = navajo.getAllMessages();
Header h = navajo.getHeader();
if (h != null) {
result.add(header(h));
} else {
logger.warn("Unexpected case: Deal with tml without header?");
}
for (Message message : all) {
emitMessage(message, result, output);
}
NavajoStreamEvent done = done(navajo.getAllMethods().stream().map(e -> new Method(e.getName())).collect(Collectors.toList()));
result.add(done);
return result;
}
Aggregations