Search in sources :

Example 1 with SynchronizedTag

use of com.dexels.navajo.document.navascript.tags.SynchronizedTag in project navajo by Dexels.

the class NS3ToNSXML method parseInnerBody.

private List<NS3Compatible> parseInnerBody(NS3Compatible parent, XMLElement currentXML) throws Exception {
    currentXML.setAttribute("PROCESSED", "true");
    List<NS3Compatible> bodyElts = new ArrayList<>();
    Vector<XMLElement> children = currentXML.getChildren();
    for (XMLElement child : children) {
        String name = child.getName();
        String content = (child.getContent() != null && !"".equals(child.getContent()) ? child.getContent() : null);
        if (name.equals("Print")) {
            DebugTag pt = parsePrint(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Log")) {
            LogTag pt = parseLog(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Property")) {
            NS3Compatible pt = parseProperty(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Option")) {
            // Find type of option: name, value or selected
            NS3Compatible pt = parseProperty(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Map")) {
            MapTag mt = parseMap(parent, child);
            bodyElts.add(mt);
        }
        if (name.equals("Var")) {
            ParamTag pt = parseVar(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Break")) {
            BreakTag mt = parseBreak(parent, child);
            bodyElts.add(mt);
        }
        if (name.equals("Include")) {
            IncludeTag mt = parseInclude(parent, child);
            bodyElts.add(mt);
        }
        if (name.equals("Message")) {
            MessageTag pt = parseMessage(parent, child);
            bodyElts.add(pt);
        }
        if (name.equals("Synchronized")) {
            SynchronizedTag st = parseSynchronizedBlock(parent, child);
            bodyElts.add(st);
        }
        if (name.equals("ConditionalEmptyMessage")) {
            BlockTag pt = parseConditionalBlock(parent, child, true);
            bodyElts.add(pt);
        }
        if (name.equals("TopLevelStatement")) {
            bodyElts.addAll(parseInnerBody(parent, child));
        }
        if (name.equals("MethodOrSetter")) {
            MapTag parentMap = findClosestMapTag(parent, "");
            FieldTag ft = parseMethodOrSetter(parentMap, child);
            bodyElts.add(ft);
        }
        if (name.equals("Loop")) {
            LoopTag mt = parseLoop(parent, child);
            bodyElts.add(mt);
        }
    }
    return bodyElts;
}
Also used : ParamTag(com.dexels.navajo.document.navascript.tags.ParamTag) LoopTag(com.dexels.navajo.document.navascript.tags.LoopTag) DebugTag(com.dexels.navajo.document.navascript.tags.DebugTag) ArrayList(java.util.ArrayList) LogTag(com.dexels.navajo.document.navascript.tags.LogTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) BreakTag(com.dexels.navajo.document.navascript.tags.BreakTag) NS3Compatible(com.dexels.navajo.document.navascript.tags.NS3Compatible) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) BlockTag(com.dexels.navajo.document.navascript.tags.BlockTag) IncludeTag(com.dexels.navajo.document.navascript.tags.IncludeTag) MessageTag(com.dexels.navajo.document.navascript.tags.MessageTag) FieldTag(com.dexels.navajo.document.navascript.tags.FieldTag) SynchronizedTag(com.dexels.navajo.document.navascript.tags.SynchronizedTag)

Example 2 with SynchronizedTag

use of com.dexels.navajo.document.navascript.tags.SynchronizedTag in project navajo by Dexels.

the class NS3ToNSXML method parseSynchronizedBlock.

private SynchronizedTag parseSynchronizedBlock(NS3Compatible parent, XMLElement xe) throws Exception {
    SynchronizedTag st = new SynchronizedTag(myNavascript);
    st.addParent(parent);
    Vector<XMLElement> children = xe.getChildren();
    for (XMLElement child : children) {
        String name = child.getName();
        if (name.equals("SynchronizedArguments")) {
            parseSynchronizedArguments(null, st, child);
        }
        if (name.equals("TopLevelStatement")) {
            List<NS3Compatible> innerBodyElements = parseInnerBody(st, child);
            for (NS3Compatible ib : innerBodyElements) {
                addChildTag(st, ib);
            }
        }
    }
    return st;
}
Also used : SynchronizedTag(com.dexels.navajo.document.navascript.tags.SynchronizedTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) NS3Compatible(com.dexels.navajo.document.navascript.tags.NS3Compatible)

Example 3 with SynchronizedTag

use of com.dexels.navajo.document.navascript.tags.SynchronizedTag in project navajo by Dexels.

the class NavascriptSaxHandler method startElement.

@Override
public final void startElement(String tag, Map<String, String> h) throws Exception {
    if (tag.equals(Tags.NAVASCRIPT) || tag.equals("tsl")) {
        currentDocument = new NavascriptTag();
        currentDocument.setAuthor(h.get("author"));
        currentDocument.setNotes(h.get("notes"));
        currentDocument.setId(h.get("id"));
        currentNode.push(currentDocument);
        return;
    }
    BaseNode currentParent = currentNode.lastElement();
    if (tag.equals(Tags.FINALLY)) {
        FinallyTag ft = new FinallyTag(currentDocument);
        currentDocument.addFinally(ft);
        currentNode.push(ft);
    }
    if (tag.equals(Tags.METHODS)) {
        MethodsTag mt = new MethodsTag(currentDocument);
        currentDocument.addMethods(mt);
        currentNode.push(mt);
        currentMethods = mt;
    }
    if (tag.equals(Tags.METHOD)) {
        MethodTag m = new MethodTag(currentDocument);
        m.setScriptName(h.get("name"));
        if (currentMethods == null) {
            logger.error("Missing methods tag for this method " + h.get("name"));
            return;
        }
        currentNode.push(m);
        currentMethods.addMethod(m);
    }
    if (tag.equals(Tags.DEFINES)) {
        DefinesTag dt = new DefinesTag(currentDocument);
        currentDocument.addDefines(dt);
        currentNode.push(dt);
        currentDefines = dt;
    }
    if (tag.equals(Tags.DEFINE)) {
        DefineTag dt = new DefineTag(currentDocument);
        String name = h.get("name");
        dt.setName(name);
        if (currentDefines != null) {
            currentDefines.addDefine(dt);
        }
        currentNode.push(dt);
    }
    if (tag.equals(Tags.DEBUG)) {
        DebugTag dt = new DebugTag(currentDocument, h.get("value"));
        dt.setCondition(h.get("condition"));
        if (currentParent instanceof MapTag && currentMap.size() > 0) {
            currentMap.lastElement().addDebug(dt);
        } else if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addDebug(dt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(dt);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(dt);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(dt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).addDebug(dt);
        } else if (currentParent instanceof NavascriptTag) {
            currentDocument.addDebug(dt);
        } else {
            throw new Exception("Did not expect debug tag under this parent: " + currentParent.getTagName());
        }
        currentNode.push(dt);
        return;
    }
    if (tag.equals(Tags.LOG)) {
        LogTag dt = new LogTag(currentDocument, h.get("value"));
        dt.setCondition(h.get("condition"));
        if (currentParent instanceof MapTag && currentMap.size() > 0) {
            currentMap.lastElement().addDebug(dt);
        } else if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addDebug(dt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(dt);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(dt);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(dt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).addDebug(dt);
        } else if (currentParent instanceof NavascriptTag) {
            currentDocument.addDebug(dt);
        } else {
            throw new Exception("Did not expect log tag under this parent: " + currentParent.getTagName());
        }
        currentNode.push(dt);
        return;
    }
    if (tag.equals(Tags.INCLUDE)) {
        IncludeTag it = new IncludeTag(currentDocument, (h.get("script")));
        it.setCondition(h.get("condition"));
        if (currentParent instanceof MapTag && currentMap.size() > 0) {
            currentMap.lastElement().addInclude(it);
        } else if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addInclude(it);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(it);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(it);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(it);
        } else if (currentParent instanceof NavascriptTag) {
            currentDocument.addInclude(it);
        } else {
        }
        currentNode.push(it);
        return;
    }
    if (tag.equals(Tags.VALIDATIONS)) {
        if (!(currentParent instanceof NavascriptTag)) {
            throw new Exception("Validation tags can only be specified as top level tags");
        }
        validationsBlock = currentDocument.addValidations();
        currentNode.push(validationsBlock);
        return;
    }
    if (tag.equals(Tags.OPTION)) {
        String name = h.get(Attributes.NAME);
        String value = h.get(Attributes.VALUE);
        String selected = h.get(Attributes.SELECTED);
        boolean bSel = (selected != null ? selected.equals("1") : false);
        if (currentParent instanceof PropertyTag) {
            SelectionTag st = ((PropertyTag) currentParent).addSelection(name, value, bSel);
            currentNode.push(st);
        } else {
            throw new Exception("Option tags are only allowed after a property tag.");
        }
        return;
    }
    if (tag.equals(Tags.CHECK)) {
        String code = h.get("code");
        String desc = h.get(Attributes.DESCRIPTION);
        String condition = h.get(Attributes.CONDITION);
        if (validationsBlock != null) {
            CheckTag ct = validationsBlock.addCheck(code, desc, condition);
            currentNode.push(ct);
        } else {
            throw new Exception("Check tags can only be found under validations tag.");
        }
        return;
    }
    if (tag.equals(Tags.BREAK)) {
        BreakTag bt = new BreakTag(currentDocument, h.get(Attributes.CONDITION), h.get("conditionId"), h.get("conditionDescription"));
        if (currentParent instanceof MapTag && currentMap.size() > 0) {
            currentMap.lastElement().addBreak(bt);
        } else if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addBreak(bt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(bt);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(bt);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(bt);
        } else if (currentParent instanceof NavascriptTag) {
            currentDocument.addBreak(bt);
        } else {
            throw new Exception("Did not expect break tag under this parent: " + currentParent.getTagName());
        }
        currentNode.push(bt);
        return;
    }
    if (tag.equals(Tags.SYNCHRONIZED)) {
        SynchronizedTag st = new SynchronizedTag(currentDocument);
        st.setContext(h.get(Attributes.CONTEXT));
        st.setKey(h.get(Attributes.KEY));
        st.setTimeout(h.get(Attributes.TIMEOUT));
        st.setBreakOnNoLock(h.get(Attributes.BREAKON_NOLOCK));
        if (currentParent instanceof MapTag && currentMap.size() > 0) {
            currentMap.lastElement().addSynchronized(st);
        } else if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addSynchronized(st);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).addSynchronized(st);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(st);
        } else if (currentParent instanceof NavascriptTag) {
            ((NavascriptTag) currentParent).addSynchronized(st);
        } else {
            throw new Exception("Did not excpect synchronized tag under this parent: " + currentParent.getTagName());
        }
        currentNode.push(st);
    }
    if (tag.equals(Tags.BLOCK)) {
        BlockTag bt = new BlockTag(currentDocument);
        bt.setCondition(h.get(Attributes.CONDITION));
        if (currentParent instanceof MapTag && currentMap.size() > 0) {
            currentMap.lastElement().addBlock(bt);
        } else if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addBlock(bt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).addBlock(bt);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(bt);
        } else if (currentParent instanceof NavascriptTag) {
            ((NavascriptTag) currentParent).addBlock(bt);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(bt);
        } else {
            throw new Exception("Did not expect block tag under this parent: " + currentParent.getTagName());
        }
        currentNode.push(bt);
        return;
    }
    if (tag.equals(Tags.MESSAGE) || tag.equals(Tags.ANTIMESSAGE)) {
        MessageTag mt = new MessageTag(currentDocument, h.get(Attributes.NAME), h.get(Attributes.TYPE));
        mt.setCondition(h.get(Attributes.CONDITION));
        mt.setOrderBy(h.get(Attributes.ORDERBY));
        boolean isAntiMsg = tag.equals(Tags.ANTIMESSAGE);
        mt.setAntiMessage(isAntiMsg);
        if (h.get("mode") != null) {
            // postfix mode to prevent ignore message. Strip character later
            mt.setMode(h.get("mode") + "_");
        }
        if (currentParent instanceof MapTag && currentMap.size() > 0) {
            currentMap.lastElement().addMessage(mt);
        } else if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addMessage(mt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(mt);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(mt);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(mt);
        } else if (currentParent instanceof NavascriptTag) {
            currentDocument.addMessage(mt);
        } else {
            throw new Exception("Did not expect message tag under this parent: " + currentParent.getTagName());
        }
        currentMessage.push(mt);
        currentNode.push(mt);
        return;
    }
    if (tag.equals(Tags.MAP)) {
        String object = h.get(Attributes.OBJECT);
        String ref = h.get(Attributes.REF);
        String condition = h.get(Attributes.CONDITION);
        MapTag mt = null;
        if (object != null) {
            mt = new MapTag(currentDocument, object, h.get(Attributes.CONDITION), true);
        } else {
            // map ref on message
            mt = new MapTag(currentDocument, ref, h.get(Attributes.FILTER), (currentMap.size() > 0 ? currentMap.lastElement() : null), true);
            if (ref.startsWith("[")) {
                mt.setMappedMessage(true);
            }
        }
        mt.setCondition(condition);
        if (currentParent instanceof PropertyTag) {
            // selection property.
            ((PropertyTag) currentParent).addMap(mt);
        } else if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addMap(mt);
        } else if (currentParent instanceof MapTag && currentMap.size() > 0) {
            currentMap.lastElement().addMap(mt);
        } else if (currentParent instanceof FieldTag && currentField.size() > 0) {
            currentField.lastElement().addMap(mt);
        } else if (currentParent instanceof ParamTag) {
            ((ParamTag) currentParent).addMap(mt);
            ((ParamTag) currentParent).setType("array");
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(mt);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(mt);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(mt);
        } else if (currentParent instanceof NavascriptTag) {
            currentDocument.addMap(mt);
        } else {
            throw new Exception("Did not expect map tag under this parent: " + currentParent.getTagName());
        }
        currentMap.push(mt);
        currentNode.push(mt);
        return;
    }
    if (tag.equals(Tags.FIELD)) {
        String name = h.get(Attributes.NAME);
        FieldTag ft = new FieldTag(currentMap.lastElement(), null, name, true);
        // FIELD CAN ALSO BE UNDER MESSAGE!!!
        if (currentParent instanceof MessageTag) {
            currentMessage.lastElement().addField(ft);
        } else if (currentParent instanceof MapTag) {
            currentMap.lastElement().addField(ft);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(ft);
        } else {
            throw new Exception("Field tags can only be found under message or map tags.");
        }
        currentField.push(ft);
        currentNode.push(ft);
    }
    if (tag.startsWith(Tags.MAP + ".")) {
        // map.navajo
        String name = tag.split("\\.")[1].trim();
        MapTag mt = new MapTag(currentDocument, name, h.get(Attributes.CONDITION));
        Map<String, String> attributeMap = new HashMap<>();
        for (String key : h.keySet()) {
            attributeMap.put(key, h.get(key));
        }
        mt.addAttributes(attributeMap);
        if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addMap(mt);
        } else if (currentParent instanceof MapTag && currentMap != null) {
            currentMap.lastElement().addMap(mt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(mt);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(mt);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(mt);
        } else if (currentParent instanceof NavascriptTag) {
            currentDocument.addMap(mt);
        } else {
            StringBuffer sb = new StringBuffer();
            sb.append("Did not expect map[" + name + "] tag under this parent: " + currentParent.getTagName() + ", currentMessage: " + currentMessage.size());
            if (currentParent instanceof MessageTag) {
                sb.append("\nParent is a message with name: " + ((MessageTag) currentParent).getName());
            }
            throw new Exception(sb.toString());
        }
        currentMap.push(mt);
        currentNode.push(mt);
        return;
    }
    if (tag.equals(Tags.VALUE)) {
        String condition = h.get(Attributes.CONDITION);
        ValueTag vt = new ValueTag(currentDocument);
        vt.setCondition(condition);
        if (currentParent instanceof FieldTag) {
            // This FieldTag will be a normal "setter" field.
            ExpressionTag et = new ExpressionTag(currentDocument);
            et.addValueTag(vt);
            ((FieldTag) currentParent).setOldSkool(true);
            ((FieldTag) currentParent).setSetter(true);
            ((FieldTag) currentParent).addExpression(et);
        } else {
            ((ExpressionTag) currentParent).addValueTag(vt);
        }
        currentNode.push(vt);
    }
    if (tag.equals(Tags.EXPRESSION)) {
        String condition = h.get(Attributes.CONDITION);
        String value = h.get(Attributes.VALUE);
        ExpressionTag et = new ExpressionTag(currentDocument, condition, value);
        if (currentParent instanceof PropertyTag) {
            ((PropertyTag) currentParent).addExpression(et);
        } else if (currentParent instanceof FieldTag) {
            ((FieldTag) currentParent).addExpression(et);
        } else if (currentParent instanceof ParamTag) {
            ((ParamTag) currentParent).addExpression(et);
        } else if (currentParent instanceof MapTag) {
            // Oops. this cannot happen. Should have been a FieldTag. Fix this.
            MapTag fixThis = currentMap.pop();
            currentNode.pop();
            FieldTag ft = new FieldTag(currentMap.lastElement(), null, fixThis.getRefAttribute());
            currentNode.push(ft);
            currentField.push(ft);
            currentMessage.lastElement().removeMap(fixThis);
            currentMessage.lastElement().addField(ft);
            ft.addExpression(et);
        } else {
            throw new Exception("Expression tags can only be found under following tags: property, field, param");
        }
        currentNode.push(et);
        return;
    }
    if (tag.equals(Tags.PARAM)) {
        ParamTag pt = new ParamTag(currentDocument, h.get(Attributes.CONDITION), h.get(Attributes.NAME));
        String mode = h.get(Attributes.MODE);
        String value = h.get(Attributes.VALUE);
        pt.setType(h.get(Attributes.TYPE));
        if (value != null && !"".equals(value)) {
            // String Constant as value.
            ExpressionTag et = new ExpressionTag(currentDocument);
            et.setConstant(value);
            pt.addExpression(et);
        }
        pt.setMode(mode);
        if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addParam(pt);
        } else if (currentParent instanceof MapTag && currentMap != null) {
            currentMap.lastElement().addParam(pt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(pt);
        } else if (currentParent instanceof FinallyTag) {
            ((FinallyTag) currentParent).add(pt);
        } else if (currentParent instanceof SynchronizedTag) {
            ((SynchronizedTag) currentParent).add(pt);
        } else if (currentParent instanceof NavascriptTag) {
            currentDocument.addParam(pt);
        } else if (currentParent instanceof ParamTag) {
            ((ParamTag) currentParent).addParam(pt);
        } else {
            throw new Exception("Did not expect param tag under this parent: " + currentParent.getTagName());
        }
        currentNode.push(pt);
    }
    if (tag.equals(Tags.PROPERTY)) {
        String name = h.get(Attributes.NAME);
        String val = h.get(Attributes.VALUE);
        String type = h.get(Attributes.TYPE);
        String direction = h.get(Attributes.DIRECTION);
        String description = h.get(Attributes.DESCRIPTION);
        String length = h.get(Attributes.LENGTH);
        String cardinality = h.get(Attributes.CARDINALITY);
        String condition = h.get(Attributes.CONDITION);
        int iLen = (length != null ? Integer.parseInt(length) : 0);
        PropertyTag pt = new PropertyTag(currentDocument, name, type, val, iLen, description, direction);
        pt.setCondition(condition);
        if (cardinality != null) {
            pt.setCardinality(cardinality);
        }
        if (val != null) {
            // Dit kan NOG strakker. Niet alle types hoeven geunescaped worder
            Hashtable<String, String> h2 = new Hashtable<String, String>(h);
            val = BaseNode.XMLUnescape(val);
            h2.put(Attributes.VALUE, val);
        }
        if (currentParent instanceof MessageTag && currentMessage.size() > 0) {
            currentMessage.lastElement().addProperty(pt);
        } else if (currentParent instanceof MapTag && currentMap != null) {
            currentMap.lastElement().addProperty(pt);
        } else if (currentParent instanceof BlockTag) {
            ((BlockTag) currentParent).add(pt);
        } else {
            throw new Exception("Property tags can only be found under a message, map or block tag.");
        }
        currentNode.push(pt);
        return;
    }
    if (currentMap.size() > 0 && tag.startsWith(currentMap.lastElement().getAdapterName() + ".")) {
        // navajomap.callwebservice
        String fieldName = tag.split("\\.")[1];
        String adapterName = tag.split("\\.")[0];
        boolean isField = mapChecker.isField(adapterName, fieldName);
        if (currentParent instanceof MessageTag && isField && h.get(Attributes.VALUE) == null) {
            // Mapped field if it is a getter (no value field specified and no expression under the tag)
            // map ref on message
            MapTag mt = new MapTag(currentDocument, fieldName, h.get(Attributes.FILTER), currentMap.lastElement(), false);
            Map<String, String> attributeMap = new HashMap<>();
            for (String key : h.keySet()) {
                attributeMap.put(key, h.get(key));
            }
            mt.addAttributes(attributeMap);
            currentMessage.lastElement().addMap(mt);
            currentMap.push(mt);
            currentNode.push(mt);
        } else if (currentParent instanceof PropertyTag) {
            // selection property
            MapTag mt = new MapTag(currentDocument, fieldName, h.get(Attributes.FILTER), currentMap.lastElement(), false);
            Map<String, String> attributeMap = new HashMap<>();
            for (String key : h.keySet()) {
                attributeMap.put(key, h.get(key));
            }
            mt.addAttributes(attributeMap);
            ((PropertyTag) currentParent).addMap(mt);
            currentMap.push(mt);
            currentNode.push(mt);
        } else if (currentParent instanceof ParamTag) {
            // mapped param
            MapTag mt = new MapTag(currentDocument, fieldName, h.get(Attributes.FILTER), currentMap.lastElement(), false);
            Map<String, String> attributeMap = new HashMap<>();
            for (String key : h.keySet()) {
                attributeMap.put(key, h.get(key));
            }
            mt.addAttributes(attributeMap);
            ((ParamTag) currentParent).addMap(mt);
            ((ParamTag) currentParent).setType("array");
            currentMap.push(mt);
            currentNode.push(mt);
        } else {
            // Normal field
            FieldTag ft = new FieldTag(currentMap.lastElement(), null, fieldName);
            Map<String, String> attributeMap = new HashMap<>();
            for (String key : h.keySet()) {
                attributeMap.put(key, h.get(key));
            }
            ft.setAddAttributes(attributeMap);
            // TODO: Get all attributes of this tag and set them in field (navascript field can have any attribute value!
            if (h.get(Attributes.VALUE) != null) {
                ExpressionTag et = new ExpressionTag(currentDocument, h.get(Attributes.CONDITION), h.get(Attributes.VALUE));
                ft.addExpression(et);
            }
            if (currentParent instanceof MessageTag) {
                ((MessageTag) currentParent).addField(ft);
            } else if (currentParent instanceof BlockTag) {
                ((BlockTag) currentParent).add(ft);
            } else if (currentParent instanceof FinallyTag) {
                ((FinallyTag) currentParent).add(ft);
            } else if (currentParent instanceof MapTag) {
                ((MapTag) currentParent).addField(ft);
            } else {
                throw new Exception("Cannot place tag " + tag + " (setter/operation) under this tag: " + currentParent);
            }
            currentField.push(ft);
            currentNode.push(ft);
        }
    }
}
Also used : ParamTag(com.dexels.navajo.document.navascript.tags.ParamTag) HashMap(java.util.HashMap) ValueTag(com.dexels.navajo.document.navascript.tags.ValueTag) BreakTag(com.dexels.navajo.document.navascript.tags.BreakTag) NavascriptTag(com.dexels.navajo.document.navascript.tags.NavascriptTag) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) BlockTag(com.dexels.navajo.document.navascript.tags.BlockTag) DefineTag(com.dexels.navajo.document.navascript.tags.DefineTag) IncludeTag(com.dexels.navajo.document.navascript.tags.IncludeTag) MethodTag(com.dexels.navajo.document.navascript.tags.MethodTag) FieldTag(com.dexels.navajo.document.navascript.tags.FieldTag) SynchronizedTag(com.dexels.navajo.document.navascript.tags.SynchronizedTag) DefinesTag(com.dexels.navajo.document.navascript.tags.DefinesTag) DebugTag(com.dexels.navajo.document.navascript.tags.DebugTag) Hashtable(java.util.Hashtable) CheckTag(com.dexels.navajo.document.navascript.tags.CheckTag) BaseNode(com.dexels.navajo.document.base.BaseNode) LogTag(com.dexels.navajo.document.navascript.tags.LogTag) ExpressionTag(com.dexels.navajo.document.navascript.tags.ExpressionTag) FinallyTag(com.dexels.navajo.document.navascript.tags.FinallyTag) IOException(java.io.IOException) MethodsTag(com.dexels.navajo.document.navascript.tags.MethodsTag) PropertyTag(com.dexels.navajo.document.navascript.tags.PropertyTag) MessageTag(com.dexels.navajo.document.navascript.tags.MessageTag) SelectionTag(com.dexels.navajo.document.navascript.tags.SelectionTag) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with SynchronizedTag

use of com.dexels.navajo.document.navascript.tags.SynchronizedTag in project navajo by Dexels.

the class NS3ToNSXML method parseXML.

private void parseXML(NS3Compatible parent, XMLElement xe, int level) throws Exception {
    if (xe.getAttribute("PROCESSED") != null) {
        return;
    }
    String name = xe.getName();
    String content = (xe.getContent() != null && !"".equals(xe.getContent()) ? xe.getContent() : null);
    if (name.equals("DebugDefinition")) {
        parseHeaderDefinitions(xe);
    } else if (name.equals("Validations")) {
        ValidationsTag vt = parseValidations(parent, xe);
        myNavascript.addValidations(vt);
    } else if (name.equals("Var")) {
        ParamTag pt = parseVar(parent, xe);
        addChildTag(parent, pt);
    } else if (name.equals("Message")) {
        MessageTag mt = parseMessage(parent, xe);
        addChildTag(parent, mt);
    } else if (name.equals("ConditionalEmptyMessage")) {
        BlockTag mt = parseConditionalBlock(parent, xe, true);
        addChildTag(parent, mt);
    } else if (name.equals("Loop")) {
        LoopTag mt = parseLoop(parent, xe);
        addChildTag(parent, mt);
    } else if (name.equals("Synchronized")) {
        SynchronizedTag st = parseSynchronizedBlock(parent, xe);
        addChildTag(parent, st);
    } else if (name.equals("Map")) {
        MapTag mt = parseMap(parent, xe);
        addChildTag(parent, mt);
    } else if (name.equals("Break")) {
        BreakTag mt = parseBreak(parent, xe);
        addChildTag(parent, mt);
    } else if (name.equals("Include")) {
        IncludeTag it = parseInclude(parent, xe);
        addChildTag(parent, it);
    } else if (name.equals("Define")) {
        DefineTag dt = parseDefine(parent, xe);
        addDefine(dt);
    } else if (name.equals("Print")) {
        DebugTag dt = parsePrint(parent, xe);
        addChildTag(parent, dt);
    } else if (name.equals("Log")) {
        LogTag dt = parseLog(parent, xe);
        addChildTag(parent, dt);
    } else if (name.equals("Finally")) {
        FinallyTag ft = parseFinally(parent, xe);
        addChildTag(parent, ft);
    } else if (name.equals("Methods")) {
        MethodsTag mt = parseMethods(parent, xe);
        addChildTag(parent, mt);
    } else {
        Vector<XMLElement> children = xe.getChildren();
        for (XMLElement x : children) {
            if (x.getAttribute("PROCESSED") == null) {
                parseXML(parent, x, level + 1);
            }
        }
    }
}
Also used : ParamTag(com.dexels.navajo.document.navascript.tags.ParamTag) LoopTag(com.dexels.navajo.document.navascript.tags.LoopTag) DebugTag(com.dexels.navajo.document.navascript.tags.DebugTag) ValidationsTag(com.dexels.navajo.document.navascript.tags.ValidationsTag) LogTag(com.dexels.navajo.document.navascript.tags.LogTag) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) BreakTag(com.dexels.navajo.document.navascript.tags.BreakTag) MapTag(com.dexels.navajo.document.navascript.tags.MapTag) FinallyTag(com.dexels.navajo.document.navascript.tags.FinallyTag) MethodsTag(com.dexels.navajo.document.navascript.tags.MethodsTag) BlockTag(com.dexels.navajo.document.navascript.tags.BlockTag) DefineTag(com.dexels.navajo.document.navascript.tags.DefineTag) IncludeTag(com.dexels.navajo.document.navascript.tags.IncludeTag) MessageTag(com.dexels.navajo.document.navascript.tags.MessageTag) SynchronizedTag(com.dexels.navajo.document.navascript.tags.SynchronizedTag)

Aggregations

SynchronizedTag (com.dexels.navajo.document.navascript.tags.SynchronizedTag)4 CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)3 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)3 BlockTag (com.dexels.navajo.document.navascript.tags.BlockTag)3 BreakTag (com.dexels.navajo.document.navascript.tags.BreakTag)3 DebugTag (com.dexels.navajo.document.navascript.tags.DebugTag)3 IncludeTag (com.dexels.navajo.document.navascript.tags.IncludeTag)3 LogTag (com.dexels.navajo.document.navascript.tags.LogTag)3 MapTag (com.dexels.navajo.document.navascript.tags.MapTag)3 MessageTag (com.dexels.navajo.document.navascript.tags.MessageTag)3 ParamTag (com.dexels.navajo.document.navascript.tags.ParamTag)3 DefineTag (com.dexels.navajo.document.navascript.tags.DefineTag)2 FieldTag (com.dexels.navajo.document.navascript.tags.FieldTag)2 FinallyTag (com.dexels.navajo.document.navascript.tags.FinallyTag)2 LoopTag (com.dexels.navajo.document.navascript.tags.LoopTag)2 MethodsTag (com.dexels.navajo.document.navascript.tags.MethodsTag)2 NS3Compatible (com.dexels.navajo.document.navascript.tags.NS3Compatible)2 BaseNode (com.dexels.navajo.document.base.BaseNode)1 CheckTag (com.dexels.navajo.document.navascript.tags.CheckTag)1 DefinesTag (com.dexels.navajo.document.navascript.tags.DefinesTag)1