Search in sources :

Example 1 with AsynchronousStepThread

use of com.twinsoft.convertigo.beans.core.StepWithExpressions.AsynchronousStepThread in project convertigo by convertigo.

the class Sequence method appendStepNode.

public void appendStepNode(Step step) throws EngineException {
    if (Thread.currentThread() instanceof AsynchronousStepThread) {
        AsynchronousStepThread thread = (AsynchronousStepThread) Thread.currentThread();
        thread.wakeTurn(step);
    }
    synchronized (this) {
        Node stepNode = step.getStepNode();
        if (stepNode != null) {
            workerElementMap.put(step.executeTimeID, stepNode);
            if (step.isXmlOrOutput()) {
                Element stepParentElement = findParentStepElement(step);
                if (stepParentElement != null) {
                    boolean isOutput = step.isOutput();
                    if (!isOutput && stepNode.getNodeType() == Node.ELEMENT_NODE) {
                        boolean recurse = !(step instanceof StepWithExpressions);
                        // output true/false quick fix for split step
                        if (step.getName().equalsIgnoreCase("Split"))
                            recurse = true;
                        // set output mode userdata (used by the TreeWalker OutputFilter)
                        setOutputUserData((Element) stepNode, "false", recurse);
                    }
                    if (step instanceof XMLCopyStep) {
                        if (isOutput) {
                            NamedNodeMap map = stepNode.getAttributes();
                            for (int i = 0; i < map.getLength(); i++) {
                                Node copied = map.item(i).cloneNode(true);
                                // set again user data because clone does not preserve it
                                setOutputUserData(copied, String.valueOf(isOutput), true);
                                append(stepParentElement, copied);
                            }
                        }
                        NodeList children = stepNode.getChildNodes();
                        for (int i = 0; i < children.getLength(); i++) {
                            Node copied = children.item(i).cloneNode(true);
                            // set again user data because clone does not preserve it
                            setOutputUserData(copied, String.valueOf(isOutput), true);
                            append(stepParentElement, copied);
                        }
                    } else {
                        append(stepParentElement, stepNode);
                    }
                }
            }
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) AsynchronousStepThread(com.twinsoft.convertigo.beans.core.StepWithExpressions.AsynchronousStepThread) XMLCopyStep(com.twinsoft.convertigo.beans.steps.XMLCopyStep)

Aggregations

AsynchronousStepThread (com.twinsoft.convertigo.beans.core.StepWithExpressions.AsynchronousStepThread)1 XMLCopyStep (com.twinsoft.convertigo.beans.steps.XMLCopyStep)1 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)1 Element (org.w3c.dom.Element)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1