Search in sources :

Example 26 with Step

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

the class ShowStepInPickerAction 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();
            if (treeObject != null) {
                if (treeObject instanceof DatabaseObjectTreeObject) {
                    DatabaseObject selectedDbo = ((DatabaseObjectTreeObject) treeObject).getObject();
                    if (selectedDbo != null) {
                        StepSourceEvent event = null;
                        if (showSource) {
                            if (selectedDbo instanceof Step) {
                                Step step = (Step) selectedDbo;
                                Set<StepSource> sources = step.getSources();
                                if (!sources.isEmpty()) {
                                    event = new StepSourceEvent(sources.iterator().next());
                                } else {
                                    throw new Exception("No Source defined");
                                }
                            }
                        } else {
                            event = new StepSourceEvent(selectedDbo);
                        }
                        if (event != null) {
                            SourcePickerView spv = ConvertigoPlugin.getDefault().getSourcePickerView();
                            if (spv == null) {
                                spv = (SourcePickerView) getActivePage().showView("com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView");
                            }
                            if (spv != null) {
                                spv.sourceSelected(event);
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to show object in Picker!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Step(com.twinsoft.convertigo.beans.core.Step) Cursor(org.eclipse.swt.graphics.Cursor) StepSourceEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.StepSourceEvent) StepSource(com.twinsoft.convertigo.beans.core.StepSource) Shell(org.eclipse.swt.widgets.Shell) 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) Display(org.eclipse.swt.widgets.Display)

Example 27 with Step

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

Example 28 with Step

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

the class SequenceImportFromXsdAction 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) {
            DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) explorerView.getFirstSelectedTreeObject();
            DatabaseObject databaseObject = databaseObjectTreeObject.getObject();
            SequenceTreeObject sequenceTreeObject = (SequenceTreeObject) ((databaseObject instanceof Sequence) ? databaseObjectTreeObject : databaseObjectTreeObject.getParentDatabaseObjectTreeObject());
            Sequence sequence = (databaseObject instanceof Sequence) ? (Sequence) databaseObject : ((StepWithExpressions) databaseObject).getSequence();
            FileDialog fileDialog = new FileDialog(shell, SWT.PRIMARY_MODAL | SWT.SAVE);
            fileDialog.setText("Import schema file");
            fileDialog.setFilterExtensions(new String[] { "*.xsd" });
            fileDialog.setFilterNames(new String[] { "Schema files" });
            fileDialog.setFilterPath(Engine.PROJECTS_PATH);
            String filePath = fileDialog.open();
            if (filePath != null) {
                filePath = filePath.replaceAll("\\\\", "/");
                XmlSchemaCollection collection = new XmlSchemaCollection();
                collection.setBaseUri(filePath);
                XmlSchema xmlSchema = SchemaUtils.loadSchema(new File(filePath), collection);
                SchemaMeta.setCollection(xmlSchema, collection);
                SchemaObjectsDialog dlg = new SchemaObjectsDialog(shell, sequence, xmlSchema);
                if (dlg.open() == Window.OK) {
                    if (dlg.result instanceof Throwable) {
                        throw (Throwable) dlg.result;
                    } else {
                        Step step = (Step) dlg.result;
                        if (step != null) {
                            if (databaseObject instanceof Sequence) {
                                sequence.addStep(step);
                                sequence.hasChanged = true;
                            } else {
                                StepWithExpressions swe = (StepWithExpressions) databaseObject;
                                swe.addStep(step);
                                swe.hasChanged = true;
                            }
                            sequence.hasChanged = true;
                            // Reload sequence in tree without updating its schema for faster reload
                            ConvertigoPlugin.logDebug("Reload sequence: start");
                            explorerView.reloadTreeObject(sequenceTreeObject);
                            ConvertigoPlugin.logDebug("Reload sequence: end");
                            // Select target dbo in tree
                            explorerView.objectSelected(new CompositeEvent(databaseObject));
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to import step from xsd!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) SchemaObjectsDialog(com.twinsoft.convertigo.eclipse.dialogs.SchemaObjectsDialog) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Step(com.twinsoft.convertigo.beans.core.Step) Cursor(org.eclipse.swt.graphics.Cursor) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) Shell(org.eclipse.swt.widgets.Shell) XmlSchema(org.apache.ws.commons.schema.XmlSchema) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Display(org.eclipse.swt.widgets.Display)

Example 29 with Step

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

the class DatabaseObjectsManager method replaceXpath.

private void replaceXpath(String version, Sequence sequence, List<String> definition) {
    if (definition.size() > 0) {
        String xpath = definition.get(1);
        if (xpath.startsWith("./")) {
            Long key = Long.valueOf(definition.get(0));
            Step sourceStep = sequence.loadedSteps.get(key);
            if (sourceStep != null) {
                if (VersionUtils.compare(version, "4.6.0") < 0) {
                    if (sourceStep instanceof RequestableStep) {
                        String replace = (sourceStep instanceof TransactionStep) ? "transaction" : "sequence";
                        xpath = xpath.replaceFirst("./", "./" + replace + "/document/");
                        definition.set(1, xpath);
                    }
                } else if (VersionUtils.compare(version, "6.2.0") < 0) {
                    if (sourceStep instanceof ReadFileStep) {
                        xpath = ((ReadFileStep) sourceStep).migrateSourceXpathFor620(xpath);
                        definition.set(1, xpath);
                    }
                }
            }
        }
    }
}
Also used : TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) Step(com.twinsoft.convertigo.beans.core.Step) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) ReadFileStep(com.twinsoft.convertigo.beans.steps.ReadFileStep) XMLActionStep(com.twinsoft.convertigo.beans.steps.XMLActionStep) XMLGenerateDatesStep(com.twinsoft.convertigo.beans.steps.XMLGenerateDatesStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) ReadFileStep(com.twinsoft.convertigo.beans.steps.ReadFileStep)

Example 30 with Step

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

the class DatabaseObjectsManager method performWsMigration.

private boolean performWsMigration(String version, String projectName) {
    if (VersionUtils.compare(version, "4.6.0") < 0) {
        try {
            // Retrieve a !clone! of project to perform update
            Project project = getProjectByName(projectName);
            for (Connector connector : project.getConnectorsList()) {
                // Retrieve backup wsdlTypes and store Transaction's schema
                for (Transaction transaction : connector.getTransactionsList()) {
                    try {
                        String xsdTypes = transaction.migrateToXsdTypes();
                        transaction.writeSchemaToFile(xsdTypes);
                        Engine.logDatabaseObjectManager.info("Internal schema stored for \"" + transaction.getName() + "\" transaction");
                    } catch (Exception e) {
                        Engine.logDatabaseObjectManager.error("An error occured while writing schema to file for \"" + transaction.getName() + "\" transaction");
                    }
                }
            }
            // Fix sequence's steps sources
            for (Sequence sequence : project.getSequencesList()) {
                try {
                    List<Step> steps = sequence.getSteps();
                    // Replace source's xpath
                    // replace ./xxx by
                    // ./transaction/document/xxx or by
                    // ./sequence/document/xxx
                    replaceSourceXpath(version, sequence, steps);
                    Engine.logDatabaseObjectManager.info("Step sources updated for sequence \"" + sequence.getName() + "\"");
                } catch (Exception e) {
                    Engine.logDatabaseObjectManager.error("An error occured while updating step sources for sequence \"" + sequence.getName() + "\"");
                }
            }
        } catch (Exception e) {
            Engine.logDatabaseObjectManager.error("An error occured while updating project '" + projectName + "' for XSD", e);
            return false;
        }
    }
    return true;
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) Transaction(com.twinsoft.convertigo.beans.core.Transaction) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Step(com.twinsoft.convertigo.beans.core.Step) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) ReadFileStep(com.twinsoft.convertigo.beans.steps.ReadFileStep) XMLActionStep(com.twinsoft.convertigo.beans.steps.XMLActionStep) XMLGenerateDatesStep(com.twinsoft.convertigo.beans.steps.XMLGenerateDatesStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

Step (com.twinsoft.convertigo.beans.core.Step)70 Sequence (com.twinsoft.convertigo.beans.core.Sequence)36 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)32 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)26 EngineException (com.twinsoft.convertigo.engine.EngineException)26 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)25 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)24 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)24 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)21 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)21 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)20 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)19 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)18 Connector (com.twinsoft.convertigo.beans.core.Connector)17 Project (com.twinsoft.convertigo.beans.core.Project)17 Cursor (org.eclipse.swt.graphics.Cursor)17 Display (org.eclipse.swt.widgets.Display)17 Shell (org.eclipse.swt.widgets.Shell)17 Transaction (com.twinsoft.convertigo.beans.core.Transaction)16 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)16