Search in sources :

Example 41 with Message

use of com.dexels.navajo.document.Message in project navajo by Dexels.

the class NavajoMap method processPropertyDirections.

private final void processPropertyDirections(Message m) {
    Iterator<Property> allProps = m.getAllProperties().iterator();
    while (allProps.hasNext()) {
        Property p = allProps.next();
        if (isPropertyInList(p, this.outputProperties, m.getType().equals(Message.MSG_TYPE_ARRAY_ELEMENT))) {
            p.setDirection(Property.DIR_OUT);
        } else if (isPropertyInList(p, this.inputProperties, m.getType().equals(Message.MSG_TYPE_ARRAY_ELEMENT))) {
            p.setDirection(Property.DIR_IN);
        }
    }
    Iterator<Message> subMessages = m.getAllMessages().iterator();
    while (subMessages.hasNext()) {
        processPropertyDirections(subMessages.next());
    }
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property)

Example 42 with Message

use of com.dexels.navajo.document.Message in project navajo by Dexels.

the class RESTAdapter method setDoSend.

@Override
public void setDoSend(String method) throws UserException, ConditionErrorException, SystemException {
    if (messagesPerRequest < 1 || useCurrentMessages == null) {
        setDoSend(method, prepareOutDoc());
        serviceCalled = true;
    } else {
        String[] messages = useCurrentMessages.split(",");
        Navajo copy = outDoc.copy();
        Navajo indoc = null;
        if (inDoc == null) {
            indoc = NavajoFactory.getInstance().createNavajo();
        } else {
            indoc = inDoc.copy();
        }
        for (String msgName : messages) {
            Message msg = access.getOutputDoc().getMessage(msgName);
            if (msg != null && msg.isArrayMessage()) {
                Message outMsg = NavajoFactory.getInstance().createMessage(outDoc, msgName);
                outMsg.setType("array");
                int counter = 0;
                int totalCounter = 0;
                for (Message element : msg.getElements()) {
                    outMsg.addElement(element);
                    counter++;
                    totalCounter++;
                    if (counter >= messagesPerRequest || totalCounter >= msg.getArraySize()) {
                        outDoc.addMessage(outMsg);
                        setDoSend(method, outDoc);
                        indoc.merge(inDoc);
                        // Going to clear data
                        outDoc = copy.copy();
                        outMsg = NavajoFactory.getInstance().createMessage(outDoc, msgName);
                        outMsg.setType("array");
                        counter = 0;
                    }
                }
                inDoc = indoc.copy();
            } else {
                throw new UserException(2, "Message " + msgName + "not found or not array message!");
            }
        }
        serviceCalled = true;
    }
}
Also used : Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo) UserException(com.dexels.navajo.script.api.UserException)

Example 43 with Message

use of com.dexels.navajo.document.Message in project navajo by Dexels.

the class AccessMap method getMessage.

private Message getMessage(Message parent, String name) {
    Message m = null;
    m = NavajoFactory.getInstance().createMessage(callingAccess.getOutputDoc(), name);
    if (parent != null) {
        parent.addMessage(m);
    } else {
        callingAccess.getOutputDoc().addMessage(m);
    }
    return m;
}
Also used : Message(com.dexels.navajo.document.Message)

Example 44 with Message

use of com.dexels.navajo.document.Message in project navajo by Dexels.

the class AccessMap method getOutMessageStack.

private String getOutMessageStack() {
    StringBuilder stackBuffer = new StringBuilder();
    Stack<Message> s = myAccess.getCompiledScript().getOutMsgStack();
    Iterator<Message> iter = s.iterator();
    while (iter.hasNext()) {
        Message o = iter.next();
        if (o != null) {
            stackBuffer.append(o + "\n");
        }
    }
    return stackBuffer.toString();
}
Also used : Message(com.dexels.navajo.document.Message)

Example 45 with Message

use of com.dexels.navajo.document.Message in project navajo by Dexels.

the class AccessMap method showMapDetails.

private void showMapDetails(Message parent, MappableTreeNode m) throws MappingException, UserException {
    Mappable myMap = (Mappable) m.myObject;
    addProperty(parent, "Map", m.getMapName(), Property.STRING_PROPERTY, 50);
    addProperty(parent, "Totaltime", Integer.valueOf(m.getTotaltime()), Property.STRING_PROPERTY, 50);
    Class<?> ccc = null;
    try {
        ccc = Class.forName("com.dexels.navajo.adapter.SPMap");
    } catch (ClassNotFoundException e) {
        logger.debug("SPMap missing?", e);
    }
    if (myMap instanceof com.dexels.navajo.adapter.SQLMap || (ccc != null && (ccc.isInstance(myMap)))) {
        SQLMap mySQL = (SQLMap) myMap;
        Message parameters = getMessage(parent, "MapParameters");
        addProperty(parameters, "Datasource", mySQL.getDatasource(), Property.STRING_PROPERTY, 50);
        addProperty(parameters, "DatabaseProductName", mySQL.getDatabaseProductName(), Property.STRING_PROPERTY, 100);
        addProperty(parameters, "DatabaseVersion", mySQL.getDatabaseVersion(), Property.STRING_PROPERTY, 100);
        addProperty(parameters, "SessionId", mySQL.getDatabaseSessionId(), Property.STRING_PROPERTY, -1);
        addProperty(parameters, "Query", mySQL.getQuery(), Property.STRING_PROPERTY, -1);
    }
    // Show parents.
    if (m.getParent() != null) {
        Message parentMap = getMessage(parent, "ParentMap");
        showMapDetails(parentMap, m.getParent());
    }
}
Also used : Mappable(com.dexels.navajo.script.api.Mappable) Message(com.dexels.navajo.document.Message)

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