Search in sources :

Example 81 with Message

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;
}
Also used : Message(com.dexels.navajo.document.Message) NavajoException(com.dexels.navajo.document.NavajoException) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property)

Example 82 with Message

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;
}
Also used : Message(com.dexels.navajo.document.Message) ReplicationMessage(com.dexels.replication.api.ReplicationMessage) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Navajo(com.dexels.navajo.document.Navajo)

Example 83 with Message

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Message(com.dexels.navajo.document.Message) ReplicationMessage(com.dexels.replication.api.ReplicationMessage) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Property(com.dexels.navajo.document.Property)

Example 84 with Message

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;
}
Also used : Message(com.dexels.navajo.document.Message) ReplicationMessage(com.dexels.replication.api.ReplicationMessage) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Navajo(com.dexels.navajo.document.Navajo)

Example 85 with Message

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;
}
Also used : Message(com.dexels.navajo.document.Message) Header(com.dexels.navajo.document.Header) ArrayList(java.util.ArrayList) Navajo(com.dexels.navajo.document.Navajo) Method(com.dexels.navajo.document.stream.api.Method) NavajoStreamEvent(com.dexels.navajo.document.stream.events.NavajoStreamEvent)

Aggregations

Message (com.dexels.navajo.document.Message)312 Property (com.dexels.navajo.document.Property)149 Navajo (com.dexels.navajo.document.Navajo)127 Test (org.junit.Test)95 NavajoException (com.dexels.navajo.document.NavajoException)39 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)35 Access (com.dexels.navajo.script.api.Access)27 UserException (com.dexels.navajo.script.api.UserException)27 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 Selection (com.dexels.navajo.document.Selection)25 Operand (com.dexels.navajo.document.Operand)22 IOException (java.io.IOException)19 ArrayList (java.util.ArrayList)19 MappableException (com.dexels.navajo.script.api.MappableException)18 Ignore (org.junit.Ignore)17 SystemException (com.dexels.navajo.script.api.SystemException)16 Optional (java.util.Optional)15 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)13 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)13 HashMap (java.util.HashMap)13