Search in sources :

Example 1 with IteratorStep

use of com.twinsoft.convertigo.beans.steps.IteratorStep in project convertigo by convertigo.

the class SourcePickerHelperWrap method displayTargetWsdlDom.

public void displayTargetWsdlDom(DatabaseObject dbo) {
    try {
        if (dbo instanceof Step) {
            Step step = (Step) dbo;
            String xpath = getSourceXPath();
            String anchor = step.getAnchor();
            Document stepDoc = null;
            Step targetStep = step;
            while (targetStep instanceof IteratorStep) {
                targetStep = getTargetStep(targetStep);
            }
            if (targetStep != null) {
                Project project = step.getProject();
                XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(project.getName(), Option.fullSchema);
                XmlSchemaObject xso = SchemaMeta.getXmlSchemaObject(schema, targetStep);
                if (xso != null) {
                    stepDoc = XmlSchemaUtils.getDomInstance(xso);
                }
            }
            if (stepDoc != null) /* && !(targetStep instanceof IteratorStep)*/
            {
                // stepDoc can be null for non "xml" step : e.g jIf
                Document doc = step.getSequence().createDOM();
                Element root = (Element) doc.importNode(stepDoc.getDocumentElement(), true);
                doc.replaceChild(root, doc.getDocumentElement());
                removeUserDefinedNodes(doc.getDocumentElement());
                boolean shouldDisplayDom = (!(!step.isXml() && (step instanceof StepWithExpressions) && !(step instanceof IteratorStep)));
                if ((doc != null) && (shouldDisplayDom)) {
                    xpath = onDisplayXhtml(xpath);
                    displayXhtml(doc);
                    xpathEvaluator.removeAnchor();
                    xpathEvaluator.displaySelectionXpathWithAnchor(twsDomTree, anchor, xpath);
                    return;
                }
            }
        }
    } catch (Exception e) {
    // ConvertigoPlugin.logException(e, StringUtils.readStackTraceCauses(e));
    }
    clean();
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) IteratorStep(com.twinsoft.convertigo.beans.steps.IteratorStep) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) Step(com.twinsoft.convertigo.beans.core.Step) IteratorStep(com.twinsoft.convertigo.beans.steps.IteratorStep) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 2 with IteratorStep

use of com.twinsoft.convertigo.beans.steps.IteratorStep in project convertigo by convertigo.

the class SourcePickerHelper method displayTargetWsdlDom.

public void displayTargetWsdlDom(final DatabaseObject dbo) {
    try {
        Display.getDefault().asyncExec(new Runnable() {

            public void run() {
                Display display = Display.getDefault();
                Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
                Shell shell = getParentShell();
                shell.setCursor(waitCursor);
                boolean needToClean = true;
                try {
                    if (dbo instanceof Step) {
                        Step step = (Step) dbo;
                        String xpath = getSourceXPath();
                        String anchor = step.getAnchor();
                        Document stepDoc = null;
                        Step targetStep = step;
                        while (targetStep instanceof IteratorStep) {
                            targetStep = getTargetStep(targetStep);
                        }
                        if (targetStep != null) {
                            Project project = step.getProject();
                            String projectName = project.getName();
                            XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(projectName, Option.fullSchema);
                            XmlSchemaObject xso = SchemaMeta.getXmlSchemaObject(schema, targetStep);
                            if (xso != null) {
                                stepDoc = XmlSchemaUtils.getDomInstance(xso);
                            } else {
                                System.out.println("Could not retrieve schema for step \"" + targetStep.getName() + "\"!");
                            }
                        } else {
                            System.out.println("Could not retrieve schema : targeted step is null!");
                        }
                        if (stepDoc != null) /* && !(targetStep instanceof IteratorStep)*/
                        {
                            // stepDoc can be null for non "xml" step : e.g jIf
                            Document doc = step.getSequence().createDOM();
                            Element root = (Element) doc.importNode(stepDoc.getDocumentElement(), true);
                            doc.replaceChild(root, doc.getDocumentElement());
                            removeUserDefinedNodes(doc.getDocumentElement());
                            boolean shouldDisplayDom = (!(!step.isXml() && (step instanceof StepWithExpressions) && !(step instanceof IteratorStep)));
                            if ((doc != null) && (shouldDisplayDom)) {
                                needToClean = false;
                                xpath = onDisplayXhtml(xpath);
                                displayXhtml(doc);
                                xpathEvaluator.removeAnchor();
                                xpathEvaluator.displaySelectionXpathWithAnchor(twsDomTree, anchor, xpath);
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    needToClean = true;
                } finally {
                    if (needToClean) {
                        clean();
                    }
                    onDisplayDone();
                    shell.setCursor(null);
                    waitCursor.dispose();
                }
            }
        });
    } catch (Exception e) {
        ConvertigoPlugin.logException(e, StringUtils.readStackTraceCauses(e));
        clean();
    }
}
Also used : IteratorStep(com.twinsoft.convertigo.beans.steps.IteratorStep) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) Step(com.twinsoft.convertigo.beans.core.Step) IteratorStep(com.twinsoft.convertigo.beans.steps.IteratorStep) Cursor(org.eclipse.swt.graphics.Cursor) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) EngineException(com.twinsoft.convertigo.engine.EngineException) Project(com.twinsoft.convertigo.beans.core.Project) Shell(org.eclipse.swt.widgets.Shell) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Display(org.eclipse.swt.widgets.Display)

Example 3 with IteratorStep

use of com.twinsoft.convertigo.beans.steps.IteratorStep in project convertigo by convertigo.

the class StepUtils method createIteratorStep.

private static Step createIteratorStep(Sequence mainSequence, Object parent, Element element) throws EngineException {
    Step step = (Step) parent;
    if (parent != null) {
        step = new IteratorStep();
        step.bNew = true;
        addStepToParent(mainSequence, parent, step);
    }
    return step;
}
Also used : IteratorStep(com.twinsoft.convertigo.beans.steps.IteratorStep) XMLComplexStep(com.twinsoft.convertigo.beans.steps.XMLComplexStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) Step(com.twinsoft.convertigo.beans.core.Step) IteratorStep(com.twinsoft.convertigo.beans.steps.IteratorStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep)

Aggregations

Step (com.twinsoft.convertigo.beans.core.Step)3 IteratorStep (com.twinsoft.convertigo.beans.steps.IteratorStep)3 Project (com.twinsoft.convertigo.beans.core.Project)2 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)2 EngineException (com.twinsoft.convertigo.engine.EngineException)2 TransformerException (javax.xml.transform.TransformerException)2 XmlSchema (org.apache.ws.commons.schema.XmlSchema)2 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 XMLAttributeStep (com.twinsoft.convertigo.beans.steps.XMLAttributeStep)1 XMLComplexStep (com.twinsoft.convertigo.beans.steps.XMLComplexStep)1 XMLElementStep (com.twinsoft.convertigo.beans.steps.XMLElementStep)1 Cursor (org.eclipse.swt.graphics.Cursor)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1