Search in sources :

Example 36 with Message

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

the class IncludeMap method store.

@Override
public void store() throws MappableException, UserException {
    try {
        File f = new File(navajoObject);
        if (type == null || type.equals("tml") || type.equals("tsl")) {
            Navajo n = (type != null && type.equals("tsl") ? NavajoFactory.getInstance().createNavaScript(new FileInputStream(f)) : NavajoFactory.getInstance().createNavajo(new FileInputStream(f)));
            Message current = access.getCurrentOutMessage();
            List<Message> msgList = n.getAllMessages();
            for (int i = 0; i < msgList.size(); i++) {
                Message tbc = msgList.get(i);
                Message copy = tbc.copy(access.getOutputDoc());
                if (current != null) {
                    current.addMessage(copy);
                } else {
                    access.getOutputDoc().addMessage(copy);
                }
            }
        }
    } catch (Exception e) {
        throw new UserException(-1, e.getMessage(), e);
    }
}
Also used : Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo) UserException(com.dexels.navajo.script.api.UserException) File(java.io.File) FileInputStream(java.io.FileInputStream) UserException(com.dexels.navajo.script.api.UserException) MappableException(com.dexels.navajo.script.api.MappableException)

Example 37 with Message

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

the class NavajoMap method setDeleteProperty.

public final void setDeleteProperty(String fullName) throws UserException {
    setPropertyName(fullName);
    if (currentProperty != null) {
        Message m = currentProperty.getParentMessage();
        deletedProperties.add(fullName);
        if (m != null) {
            m.removeProperty(currentProperty);
        }
    }
}
Also used : Message(com.dexels.navajo.document.Message)

Example 38 with Message

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

the class NavajoMap method processSuppressedProperties.

private final void processSuppressedProperties(Message m) {
    Iterator<Property> allProps = new ArrayList<Property>(m.getAllProperties()).iterator();
    while (allProps.hasNext()) {
        Property p = allProps.next();
        if (isPropertyInList(p, this.suppressProperties, m.getType().equals(Message.MSG_TYPE_ARRAY_ELEMENT))) {
            m.removeProperty(p);
        }
    }
    Iterator<Message> subMessages = m.getAllMessages().iterator();
    while (subMessages.hasNext()) {
        processSuppressedProperties(subMessages.next());
    }
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property)

Example 39 with Message

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

the class NavajoMap method getMessage.

public Message getMessage(String fullName) throws UserException {
    waitForResult();
    Message msg = null;
    if (msgPointer != null)
        msg = msgPointer.getMessage(fullName);
    else
        msg = inDoc.getMessage(fullName);
    if (msg == null)
        throw new UserException(-1, "Message " + fullName + " does not exists in response document");
    return msg;
}
Also used : Message(com.dexels.navajo.document.Message) UserException(com.dexels.navajo.script.api.UserException)

Example 40 with Message

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

the class NavajoMap method setAppendParms.

/**
 * @param b
 * @throws UserException
 *
 *             if messageOffset is '/', the messages of the received Doc will be appended to the root param block or to the current param message.
 */
public final void setAppendParms(String messageOffset) throws UserException {
    waitForResult();
    try {
        Message parm = (access.getCompiledScript().getCurrentParamMsg() == null ? access.getInDoc().getMessage("__parms__") : access.getCompiledScript().getCurrentParamMsg());
        List<Message> list = null;
        // If append message equals '/'.
        if (messageOffset.equals(Navajo.MESSAGE_SEPARATOR)) {
            list = inDoc.getAllMessages();
        } else if (inDoc.getMessage(messageOffset) == null) {
            return;
        } else if (inDoc.getMessage(messageOffset).getType().equals(Message.MSG_TYPE_ARRAY)) {
            list = new ArrayList<>();
            list.add(inDoc.getMessage(messageOffset));
        } else {
            list = inDoc.getMessages(messageOffset);
        }
        for (int i = 0; i < list.size(); i++) {
            Message inMsg = list.get(i);
            // Clone message and append it to currentMsg if it exists, else
            // directly under currentDoc.
            // currentDoc.importMessage(inMsg)
            Message clone = inDoc.copyMessage(inMsg, parm.getRootDoc());
            parm.addMessage(clone, true);
        }
    } catch (NavajoException ne) {
        throw new UserException(-1, ne.getMessage());
    }
}
Also used : Message(com.dexels.navajo.document.Message) NavajoException(com.dexels.navajo.document.NavajoException) UserException(com.dexels.navajo.script.api.UserException)

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