Search in sources :

Example 6 with StepWithExpressions

use of com.twinsoft.convertigo.beans.core.StepWithExpressions 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 7 with StepWithExpressions

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

the class ProjectTreeObject method checkForImports.

private void checkForImports(List<String> missingList, List<Step> steps) {
    String targetProjectName;
    for (Step step : steps) {
        if (step instanceof StepWithExpressions) {
            checkForImports(missingList, ((StepWithExpressions) step).getSteps());
        } else {
            if (step instanceof TransactionStep) {
                TransactionStep transactionStep = ((TransactionStep) step);
                targetProjectName = transactionStep.getProjectName();
                if (!targetProjectName.equals(getName())) {
                    try {
                        transactionStep.getSequence().getLoadedProject(targetProjectName);
                    } catch (EngineException e) {
                        if (!missingList.contains(targetProjectName))
                            missingList.add(targetProjectName);
                    }
                }
            } else if (step instanceof SequenceStep) {
                SequenceStep sequenceStep = ((SequenceStep) step);
                targetProjectName = sequenceStep.getProjectName();
                if (!targetProjectName.equals(getName())) {
                    try {
                        sequenceStep.getSequence().getLoadedProject(targetProjectName);
                    } catch (EngineException e) {
                        if (!missingList.contains(targetProjectName))
                            missingList.add(targetProjectName);
                    }
                }
            }
        }
    }
}
Also used : TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) EngineException(com.twinsoft.convertigo.engine.EngineException) Step(com.twinsoft.convertigo.beans.core.Step) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep)

Example 8 with StepWithExpressions

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

the class OutputStepAction method output.

private void output(Step step) {
    if (step != null) {
        step.setOutput(output);
        step.hasChanged = true;
        if (recurse && (step instanceof StepWithExpressions)) {
            for (Step child : ((StepWithExpressions) step).getSteps()) {
                output(child);
            }
        }
    }
}
Also used : StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) XMLAttributeStep(com.twinsoft.convertigo.beans.steps.XMLAttributeStep) Step(com.twinsoft.convertigo.beans.core.Step)

Example 9 with StepWithExpressions

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

the class VariableGenerateFromXmlAndLinkAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            if ((databaseObject != null) && ((databaseObject instanceof StepVariable))) {
                StepVariable stepVariable = (StepVariable) databaseObject;
                RequestableStep requestableStep = (RequestableStep) stepVariable.getParent();
                if (requestableStep != null) {
                    DatabaseObjectTreeObject parentDboTreeObject = ((DatabaseObjectTreeObject) treeObject).getParentDatabaseObjectTreeObject().getParentDatabaseObjectTreeObject();
                    RequestableObject requestableObject = null;
                    if (requestableStep instanceof SequenceStep) {
                        requestableObject = ((SequenceStep) requestableStep).getTargetSequence();
                    } else if (requestableStep instanceof TransactionStep) {
                        requestableObject = ((TransactionStep) requestableStep).getTargetTransaction();
                    }
                    if ((requestableObject != null) && (requestableObject instanceof IVariableContainer)) {
                        String variableName = stepVariable.getName();
                        IVariableContainer container = (IVariableContainer) requestableObject;
                        RequestableVariable variable = (RequestableVariable) container.getVariable(variableName);
                        // generate dom model
                        Document document = null;
                        try {
                            String description = variable.getDescription();
                            document = XMLUtils.parseDOMFromString(description);
                        } catch (Exception e) {
                        }
                        if (document != null) {
                            Element root = document.getDocumentElement();
                            if (root != null) {
                                // create step's structure from dom
                                DatabaseObject parentObject = requestableStep.getParent();
                                Step step = StepUtils.createStepFromXmlDomModel(parentObject, root);
                                // add step's structure to parent of requestableStep
                                if (parentObject instanceof Sequence) {
                                    Sequence parentSequence = (Sequence) parentObject;
                                    parentSequence.addStep(step);
                                    parentSequence.insertAtOrder(step, requestableStep.priority);
                                } else {
                                    StepWithExpressions parentSwe = (StepWithExpressions) parentObject;
                                    parentSwe.addStep(step);
                                    parentSwe.insertAtOrder(step, requestableStep.priority);
                                }
                                // set source definition of variable
                                XMLVector<String> sourceDefinition = new XMLVector<String>();
                                sourceDefinition.add(String.valueOf(step.priority));
                                sourceDefinition.add(".");
                                stepVariable.setSourceDefinition(sourceDefinition);
                                stepVariable.hasChanged = true;
                                // Reload parent dbo in tree
                                explorerView.reloadTreeObject(parentDboTreeObject);
                                // Select variable dbo in tree
                                explorerView.objectSelected(new CompositeEvent(databaseObject));
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to generate and link variable!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) Step(com.twinsoft.convertigo.beans.core.Step) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Cursor(org.eclipse.swt.graphics.Cursor) Document(org.w3c.dom.Document) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) IVariableContainer(com.twinsoft.convertigo.beans.core.IVariableContainer) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) Display(org.eclipse.swt.widgets.Display)

Example 10 with StepWithExpressions

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

the class SequenceExecuteSelectedAction method openEditors.

private void openEditors(ProjectExplorerView explorerView, List<Step> steps, Set<SequenceStep> alreadyOpened) {
    for (Step step : steps) {
        if (step.isEnabled()) {
            if (step instanceof SequenceStep) {
                SequenceStep sequenceStep = (SequenceStep) step;
                String projectName = sequenceStep.getProjectName();
                // load project if necessary
                if (!step.getSequence().getProject().getName().equals(projectName))
                    loadProject(explorerView, projectName);
                if (alreadyOpened.contains(sequenceStep)) {
                    // avoid sequence recursion
                    return;
                }
                alreadyOpened.add(sequenceStep);
                try {
                    ProjectTreeObject projectTreeObject = (ProjectTreeObject) explorerView.getProjectRootObject(projectName);
                    Sequence subSequence = projectTreeObject.getObject().getSequenceByName(sequenceStep.getSequenceName());
                    SequenceTreeObject subSequenceTreeObject = (SequenceTreeObject) explorerView.findTreeObjectByUserObject(subSequence);
                    // recurse on sequence
                    openEditors(explorerView, subSequenceTreeObject, alreadyOpened);
                } catch (EngineException e) {
                    e.printStackTrace();
                }
            } else if (step instanceof TransactionStep) {
                TransactionStep transactionStep = (TransactionStep) step;
                String projectName = transactionStep.getProjectName();
                if (!step.getSequence().getProject().getName().equals(projectName))
                    // load project if necessary
                    loadProject(explorerView, projectName);
                try {
                    ProjectTreeObject projectTreeObject = (ProjectTreeObject) explorerView.getProjectRootObject(projectName);
                    Connector connector = projectTreeObject.getObject().getConnectorByName(transactionStep.getConnectorName());
                    ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) explorerView.findTreeObjectByUserObject(connector);
                    // open connector editor
                    connectorTreeObject.openConnectorEditor();
                } catch (EngineException e) {
                    e.printStackTrace();
                }
            } else if (step instanceof StepWithExpressions) {
                openEditors(explorerView, ((StepWithExpressions) step).getSteps(), alreadyOpened);
            }
        }
    }
}
Also used : TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) Connector(com.twinsoft.convertigo.beans.core.Connector) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) EngineException(com.twinsoft.convertigo.engine.EngineException) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Step(com.twinsoft.convertigo.beans.core.Step) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Sequence(com.twinsoft.convertigo.beans.core.Sequence)

Aggregations

StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)35 Sequence (com.twinsoft.convertigo.beans.core.Sequence)27 Step (com.twinsoft.convertigo.beans.core.Step)26 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)24 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)22 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)19 Cursor (org.eclipse.swt.graphics.Cursor)19 Display (org.eclipse.swt.widgets.Display)19 Shell (org.eclipse.swt.widgets.Shell)19 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)18 EngineException (com.twinsoft.convertigo.engine.EngineException)16 StepEvent (com.twinsoft.convertigo.beans.core.StepEvent)15 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)15 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)15 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)10 TreePath (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreePath)8 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)7 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)6 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)6 XMLElementStep (com.twinsoft.convertigo.beans.steps.XMLElementStep)6