Search in sources :

Example 66 with Message

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

the class BaseNavajoImpl method merge.

@Override
public Navajo merge(Navajo with, boolean preferThisNavajo) {
    // Find duplicate messages.
    List<Message> superMessages = this.getAllMessages();
    List<Message> subMessages = with.getAllMessages();
    for (int i = 0; i < superMessages.size(); i++) {
        Message superMsg = superMessages.get(i);
        for (int j = 0; j < subMessages.size(); j++) {
            Message subMsg = subMessages.get(j);
            if (superMsg.getName().equals(subMsg.getName())) {
                // Found duplicate!
                Message newMsg = subMsg.copy(this);
                this.mergeMessage(newMsg, preferThisNavajo);
            }
        }
    }
    // Find new messages.
    for (int i = 0; i < subMessages.size(); i++) {
        Message subMsg = subMessages.get(i);
        boolean newMsg = true;
        for (int j = 0; j < superMessages.size(); j++) {
            Message superMsg = superMessages.get(j);
            if (superMsg.getName().equals(subMsg.getName())) {
                newMsg = false;
                j = superMessages.size() + 1;
            }
        }
        if (newMsg) {
            this.addMessage(subMsg.copy(this));
        }
    }
    return this;
}
Also used : Message(com.dexels.navajo.document.Message)

Example 67 with Message

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

the class BaseNavajoImpl method appendDocBuffer.

/**
 * @deprecated
 */
@Override
@Deprecated
public void appendDocBuffer(Object d) {
    Navajo n = (Navajo) d;
    List<Message> msgs = n.getAllMessages();
    for (int i = 0; i < msgs.size(); i++) {
        Message m = msgs.get(i);
        addMessage(m.copy(this));
    }
}
Also used : Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo)

Example 68 with Message

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

the class BirtUtils method locateArrayMessage.

private String locateArrayMessage(Navajo n) {
    List<Message> mm = n.getAllMessages();
    for (Iterator<Message> iter = mm.iterator(); iter.hasNext(); ) {
        Message m = iter.next();
        if (Message.MSG_TYPE_ARRAY.equals(m.getType())) {
            return m.getFullMessageName();
        }
    }
    // two loops, for pre order:
    for (Iterator<Message> iter = mm.iterator(); iter.hasNext(); ) {
        Message m = iter.next();
        String res = locateArrayMessage(m);
        if (res != null) {
            return res;
        }
    }
    return null;
}
Also used : Message(com.dexels.navajo.document.Message)

Example 69 with Message

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

the class BirtUtils method createResultSet.

private void createResultSet(Document d, Element odaDataSetTag, Message sourceObject, String service) {
    Message first = null;
    if (sourceObject == null) {
        return;
    }
    if (sourceObject.getType().equals(Message.MSG_TYPE_ARRAY)) {
        first = sourceObject.getMessage(0);
        if (first == null) {
            return;
        }
    } else {
        first = sourceObject;
    }
    List<Property> props = first.getAllProperties();
    Element listprop = addProperty(d, odaDataSetTag, "list-property", "resultSet", null);
    for (int i = 0; i < props.size(); i++) {
        Property current = props.get(i);
        Element s = d.createElement("structure");
        listprop.appendChild(s);
        addProperty(d, s, "property", "position", "" + (i + 1));
        addProperty(d, s, "property", "name", current.getName());
        addProperty(d, s, "property", "nativeName", current.getName());
        addProperty(d, s, "property", "dataType", getPropertyType(current, false));
        if (Property.BINARY_PROPERTY.equals(current.getType())) {
            Element n = (Element) XMLutils.findNode(odaDataSetTag, "computedColumns");
            if (n == null) {
                n = addProperty(d, odaDataSetTag, "list-property", "computedColumns", null);
            }
            Element struc = addProperty(d, n, "structure", null, null);
            addProperty(d, struc, "property", "name", current.getName() + "_Data");
            addProperty(d, struc, "expression", "expression", "importPackage(Packages.org.dexels.utils); Base64.decode(dataSetRow[\"" + current.getName() + "\"])");
            addProperty(d, struc, "property", "dataType", "any");
        }
    }
    addProperty(d, odaDataSetTag, "property", "queryText", createArrayMessageQueryText(props, service, sourceObject));
}
Also used : Message(com.dexels.navajo.document.Message) Element(org.w3c.dom.Element) Property(com.dexels.navajo.document.Property)

Example 70 with Message

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

the class BirtUtils method locateArrayMessage.

private String locateArrayMessage(Message in) {
    List<Message> mm = in.getAllMessages();
    for (Iterator<Message> iter = mm.iterator(); iter.hasNext(); ) {
        Message m = iter.next();
        if (Message.MSG_TYPE_ARRAY.equals(m.getType())) {
            return m.getFullMessageName();
        }
    }
    // two loops, for breath first order:
    for (Iterator<Message> iter = mm.iterator(); iter.hasNext(); ) {
        Message m = iter.next();
        String res = locateArrayMessage(m);
        if (res != null) {
            return res;
        }
    }
    return null;
}
Also used : 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