Search in sources :

Example 11 with Connector

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

the class NewObjectWizard method doFinish.

private void doFinish(IProgressMonitor monitor) throws CoreException {
    String dboName, name;
    boolean bContinue = true;
    int index = 0;
    try {
        int total = 0;
        Class<?> c = getCreatedBeanClass();
        if (c != null) {
            total = 4;
            if (c.equals(WebServiceReference.class)) {
                total += ImportWsReference.getTotalTaskNumber();
            }
        }
        monitor.beginTask("Creating new object", total);
        newBean = getCreatedBean();
        if (newBean != null) {
            monitor.setTaskName("Object created");
            monitor.worked(1);
            dboName = newBean.getName();
            if (!StringUtils.isNormalized(dboName))
                throw new EngineException("Bean name is not normalized : \"" + dboName + "\".");
            // Verify if a child object with same name exist and change name
            while (bContinue) {
                if (index == 0)
                    name = dboName;
                else
                    name = dboName + index;
                newBean.setName(name);
                newBean.hasChanged = true;
                newBean.bNew = true;
                try {
                    new WalkHelper() {

                        boolean root = true;

                        boolean find = false;

                        @Override
                        protected boolean before(DatabaseObject dbo, Class<? extends DatabaseObject> dboClass) {
                            boolean isInstance = dboClass.isInstance(newBean);
                            find |= isInstance;
                            return isInstance;
                        }

                        @Override
                        protected void walk(DatabaseObject dbo) throws Exception {
                            if (root) {
                                root = false;
                                super.walk(dbo);
                                if (!find) {
                                    throw new EngineException("You cannot add to a " + newBean.getClass().getSimpleName() + " a database object of type " + parentObject.getClass().getSimpleName());
                                }
                            } else {
                                if (newBean.getName().equalsIgnoreCase(dbo.getName())) {
                                    throw new ObjectWithSameNameException("Unable to add the object because an object with the same name already exists in target.");
                                }
                            }
                        }
                    }.init(parentObject);
                    bContinue = false;
                } catch (ObjectWithSameNameException owsne) {
                    if ((parentObject instanceof HtmlTransaction) && (newBean instanceof Statement)) {
                        throw new EngineException("HtmlTransaction already contains a statement named \"" + name + "\".", owsne);
                    }
                    // Silently ignore
                    index++;
                } catch (EngineException ee) {
                    throw ee;
                } catch (Exception e) {
                    throw new EngineException("Exception in create", e);
                }
            }
            // Now add bean to target
            try {
                boolean hasChanged = parentObject.hasChanged;
                if ((newBean instanceof Statement) && (parentObject instanceof Transaction)) {
                    newBean.priority = 0;
                }
                if (newBean instanceof ScreenClass)
                    newBean.priority = parentObject.priority + 1;
                if (newBean instanceof Criteria) {
                    Connector connector = parentObject.getConnector();
                    if (parentObject.equals(((IScreenClassContainer<?>) connector).getDefaultScreenClass()))
                        throw new EngineException("You cannot add a new criterion on default screenclass.");
                }
                parentObject.add(newBean);
                monitor.setTaskName("Object added");
                monitor.worked(1);
                if (newBean instanceof HTTPStatement) {
                    HTTPStatement httpStatement = (HTTPStatement) newBean;
                    HtmlConnector connector = (HtmlConnector) httpStatement.getParentTransaction().getParent();
                    httpStatement.setMethod("GET");
                    httpStatement.setHost(connector.getServer());
                    httpStatement.setPort(connector.getPort());
                    httpStatement.setHttps(connector.isHttps());
                }
                if (newBean instanceof ContinueWithSiteClipperStatement) {
                    Project project = newBean.getProject();
                    if (project != null) {
                        String[] connectorWithSiteClipperConnector = ContinueWithSiteClipperStatement.getSiteClippersConnectorNames(project);
                        if (connectorWithSiteClipperConnector.length > 0) {
                            ((ContinueWithSiteClipperStatement) newBean).setSiteClipperConnectorName(connectorWithSiteClipperConnector[0]);
                        }
                    }
                }
                if (newBean instanceof Connector) {
                    Project project = (Project) parentObject;
                    if (project.getDefaultConnector() == null)
                        project.setDefaultConnector((Connector) newBean);
                    Connector.setupConnector(newBean);
                }
                if (newBean instanceof PageComponent) {
                    ApplicationComponent application = (ApplicationComponent) parentObject;
                    if (application.getRootPage() == null)
                        application.setRootPage((PageComponent) newBean);
                }
                if (newBean instanceof SequenceStep) {
                    Project project = newBean.getProject();
                    ((SequenceStep) newBean).setSourceSequence(project.getName() + TransactionStep.SOURCE_SEPARATOR + project.getSequencesList().get(0));
                }
                if (newBean instanceof TransactionStep) {
                    Project project = newBean.getProject();
                    Connector connector = project.getDefaultConnector();
                    Transaction transaction = connector.getDefaultTransaction();
                    ((TransactionStep) newBean).setSourceTransaction(project.getName() + TransactionStep.SOURCE_SEPARATOR + connector.getName() + TransactionStep.SOURCE_SEPARATOR + transaction.getName());
                }
                if (newBean instanceof IThenElseContainer) {
                    ThenStep thenStep = new ThenStep();
                    ((IThenElseContainer) newBean).addStep(thenStep);
                    ElseStep elseStep = new ElseStep();
                    ((IThenElseContainer) newBean).addStep(elseStep);
                }
                if (newBean instanceof IThenElseStatementContainer) {
                    ThenStatement thenStatement = new ThenStatement();
                    ((IThenElseStatementContainer) newBean).addStatement(thenStatement);
                    ElseStatement elseStatement = new ElseStatement();
                    ((IThenElseStatementContainer) newBean).addStatement(elseStatement);
                }
                if (newBean instanceof Sheet) {
                    InputStream is = null;
                    try {
                        String sheetName = newBean.getName() + ".xsl";
                        is = new FileInputStream(new File(Engine.XSL_PATH + "/customsheet.xsl"));
                        String projectName = ((DatabaseObject) parentObject).getProject().getName();
                        IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
                        final IFile file = project.getFile(sheetName);
                        if (!file.exists())
                            file.create(is, true, null);
                        ((Sheet) newBean).setUrl(sheetName);
                    } catch (Exception e) {
                    } finally {
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException e) {
                            }
                        }
                    }
                }
                if (newBean instanceof TestCase) {
                    TestCase testCase = (TestCase) newBean;
                    testCase.importRequestableVariables((RequestableObject) testCase.getParent());
                }
                if (newBean instanceof RequestableHttpVariable) {
                    RequestableHttpVariable variable = (RequestableHttpVariable) newBean;
                    AbstractHttpTransaction httpTransaction = (AbstractHttpTransaction) variable.getParent();
                    HttpMethodType httpMethodType = httpTransaction.getHttpVerb();
                    boolean isVarPost = httpMethodType.equals(HttpMethodType.PUT) || httpMethodType.equals(HttpMethodType.POST);
                    variable.setHttpMethod(isVarPost ? HttpMethodType.POST.name() : HttpMethodType.GET.name());
                }
                if (newBean instanceof WebServiceReference) {
                    try {
                        Project project = (Project) parentObject;
                        WebServiceReference webServiceReference = (WebServiceReference) newBean;
                        ImportWsReference wsr = new ImportWsReference(webServiceReference);
                        wsr.importInto(project);
                    } catch (Exception e) {
                        if (newBean != null) {
                            parentObject.remove(newBean);
                            parentObject.hasChanged = hasChanged;
                        }
                        throw new Exception(e);
                    }
                }
                if (newBean instanceof RestServiceReference) {
                    try {
                        Project project = (Project) parentObject;
                        RestServiceReference restServiceReference = (RestServiceReference) newBean;
                        ImportWsReference wsr = new ImportWsReference(restServiceReference);
                        wsr.importInto(project);
                    } catch (Exception e) {
                        if (newBean != null) {
                            parentObject.remove(newBean);
                            parentObject.hasChanged = hasChanged;
                        }
                        throw new Exception(e);
                    }
                }
                if (newBean instanceof SqlTransaction) {
                    SqlTransaction sqlTransaction = (SqlTransaction) newBean;
                    sqlTransaction.setSqlQuery(sqlQueriesWizardPage.getSQLQueries());
                    sqlTransaction.initializeQueries(true);
                }
                if (newBean instanceof SapJcoLogonTransaction) {
                    SapJcoLogonTransaction sapLogonTransaction = (SapJcoLogonTransaction) newBean;
                    sapLogonTransaction.addCredentialsVariables();
                }
                if (objectInfoPage != null) {
                    objectInfoPage.doApply();
                }
                ConvertigoPlugin.logInfo("New object class '" + this.className + "' named '" + newBean.getName() + "' has been added");
                monitor.setTaskName("Object setted up");
                monitor.worked(1);
                bContinue = false;
            } catch (com.twinsoft.convertigo.engine.ObjectWithSameNameException owsne) {
                if (newBean instanceof HandlerStatement) {
                    throw owsne;
                }
            }
        } else {
            throw new Exception("Could not instantiate bean!");
        }
    } catch (Exception e) {
        String message = "Unable to create a new object from class '" + this.className + "'.";
        ConvertigoPlugin.logException(e, message);
        if (objectExplorerPage != null) {
            objectExplorerPage.doCancel();
        }
    }
}
Also used : RestServiceReference(com.twinsoft.convertigo.beans.references.RestServiceReference) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) IThenElseContainer(com.twinsoft.convertigo.beans.steps.IThenElseContainer) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) HttpMethodType(com.twinsoft.convertigo.engine.enums.HttpMethodType) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) EngineException(com.twinsoft.convertigo.engine.EngineException) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) AbstractHttpTransaction(com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) FileInputStream(java.io.FileInputStream) IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) SapJcoLogonTransaction(com.twinsoft.convertigo.beans.transactions.SapJcoLogonTransaction) Transaction(com.twinsoft.convertigo.beans.core.Transaction) AbstractHttpTransaction(com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) IFile(org.eclipse.core.resources.IFile) File(java.io.File) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) IFile(org.eclipse.core.resources.IFile) SapJcoLogonTransaction(com.twinsoft.convertigo.beans.transactions.SapJcoLogonTransaction) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Criteria(com.twinsoft.convertigo.beans.core.Criteria) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) ImportWsReference(com.twinsoft.convertigo.engine.util.ImportWsReference) IThenElseStatementContainer(com.twinsoft.convertigo.beans.statements.IThenElseStatementContainer) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException) IOException(java.io.IOException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) IProject(org.eclipse.core.resources.IProject) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) TestCase(com.twinsoft.convertigo.beans.core.TestCase) WebServiceReference(com.twinsoft.convertigo.beans.references.WebServiceReference) Sheet(com.twinsoft.convertigo.beans.core.Sheet) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException)

Example 12 with Connector

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

the class ObjectInfoWizardPage method fillTree.

public void fillTree(Class<? extends DatabaseObject> beanClass) {
    treeItemName = null;
    tree.removeAll();
    if (parentObject instanceof Transaction) {
        Connector connector = (Connector) ((Transaction) parentObject).getParent();
        boolean isScreenClassAware = connector instanceof IScreenClassContainer<?>;
        if (beanClass.equals(ScEntryHandlerStatement.class) || beanClass.equals(ScExitHandlerStatement.class)) {
            if (isScreenClassAware) {
                if (connector instanceof HtmlConnector) {
                    HtmlConnector htmlConnector = (HtmlConnector) connector;
                    ScreenClass defaultScreenClass = htmlConnector.getDefaultScreenClass();
                    TreeItem branch = new TreeItem(tree, SWT.NONE);
                    branch.setText(defaultScreenClass.getName());
                    List<ScreenClass> screenClasses = defaultScreenClass.getInheritedScreenClasses();
                    for (ScreenClass screenClass : screenClasses) {
                        getInHeritedScreenClass(screenClass, branch);
                    }
                } else if (connector instanceof JavelinConnector) {
                    JavelinConnector javelinConnector = (JavelinConnector) connector;
                    ScreenClass defaultScreenClass = javelinConnector.getDefaultScreenClass();
                    TreeItem branch = new TreeItem(tree, SWT.NONE);
                    branch.setText(defaultScreenClass.getName());
                    List<ScreenClass> screenClasses = defaultScreenClass.getInheritedScreenClasses();
                    for (ScreenClass screenClass : screenClasses) {
                        getInHeritedScreenClass(screenClass, branch);
                    }
                }
                tree.setVisible(true);
            }
        } else if (beanClass.equals(HandlerStatement.class)) {
            TreeItem branch;
            branch = new TreeItem(tree, SWT.NONE);
            branch.setText(HandlerStatement.EVENT_TRANSACTION_STARTED);
            branch = new TreeItem(tree, SWT.NONE);
            branch.setText(HandlerStatement.EVENT_XML_GENERATED);
            tree.setVisible(true);
        } else
            tree.setVisible(false);
    }
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) FullSyncConnector(com.twinsoft.convertigo.beans.connectors.FullSyncConnector) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) TreeItem(org.eclipse.swt.widgets.TreeItem) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) IScreenClassContainer(com.twinsoft.convertigo.beans.core.IScreenClassContainer) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) Transaction(com.twinsoft.convertigo.beans.core.Transaction) AbstractHttpTransaction(com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction) AbstractCouchDbTransaction(com.twinsoft.convertigo.beans.transactions.couchdb.AbstractCouchDbTransaction) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) List(java.util.List)

Example 13 with Connector

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

the class ComponentInfoWizardPage method fillTree.

public void fillTree(Class<? extends DatabaseObject> beanClass) {
    treeItemName = null;
    tree.removeAll();
    if (parentObject instanceof Transaction) {
        Connector connector = (Connector) ((Transaction) parentObject).getParent();
        boolean isScreenClassAware = connector instanceof IScreenClassContainer<?>;
        if (beanClass.equals(ScEntryHandlerStatement.class) || beanClass.equals(ScExitHandlerStatement.class)) {
            if (isScreenClassAware) {
                if (connector instanceof HtmlConnector) {
                    HtmlConnector htmlConnector = (HtmlConnector) connector;
                    ScreenClass defaultScreenClass = htmlConnector.getDefaultScreenClass();
                    TreeItem branch = new TreeItem(tree, SWT.NONE);
                    branch.setText(defaultScreenClass.getName());
                    List<ScreenClass> screenClasses = defaultScreenClass.getInheritedScreenClasses();
                    for (ScreenClass screenClass : screenClasses) {
                        getInHeritedScreenClass(screenClass, branch);
                    }
                } else if (connector instanceof JavelinConnector) {
                    JavelinConnector javelinConnector = (JavelinConnector) connector;
                    ScreenClass defaultScreenClass = javelinConnector.getDefaultScreenClass();
                    TreeItem branch = new TreeItem(tree, SWT.NONE);
                    branch.setText(defaultScreenClass.getName());
                    List<ScreenClass> screenClasses = defaultScreenClass.getInheritedScreenClasses();
                    for (ScreenClass screenClass : screenClasses) {
                        getInHeritedScreenClass(screenClass, branch);
                    }
                }
                tree.setVisible(true);
            }
        } else if (beanClass.equals(HandlerStatement.class)) {
            TreeItem branch;
            branch = new TreeItem(tree, SWT.NONE);
            branch.setText(HandlerStatement.EVENT_TRANSACTION_STARTED);
            branch = new TreeItem(tree, SWT.NONE);
            branch.setText(HandlerStatement.EVENT_XML_GENERATED);
            tree.setVisible(true);
        } else
            tree.setVisible(false);
    }
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) FullSyncConnector(com.twinsoft.convertigo.beans.connectors.FullSyncConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) TreeItem(org.eclipse.swt.widgets.TreeItem) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) IScreenClassContainer(com.twinsoft.convertigo.beans.core.IScreenClassContainer) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) AbstractCouchDbTransaction(com.twinsoft.convertigo.beans.transactions.couchdb.AbstractCouchDbTransaction) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) List(java.util.List)

Example 14 with Connector

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

the class ReferencesView method handleScreenClassSelection.

private void handleScreenClassSelection(Object firstElement) {
    ScreenClassTreeObject screenClassTreeObject = (ScreenClassTreeObject) firstElement;
    ScreenClass screenClass = screenClassTreeObject.getObject();
    String screenClassName = screenClassTreeObject.getName();
    // Get the referencing transactions
    Connector connector = screenClass.getConnector();
    List<Transaction> transactions = connector.getTransactionsList();
    RootNode root = new RootNode();
    ScreenClassNode screenClassFolder = new ScreenClassNode(root, screenClassName, screenClass);
    root.addChild(screenClassFolder);
    IsUsedByNode isUsedByNode = new IsUsedByNode(screenClassFolder, "Is used by");
    EntryHandlerNode entryFolder = new EntryHandlerNode(isUsedByNode, "Transaction entry handlers", null);
    ExitHandlerNode exitFolder = new ExitHandlerNode(isUsedByNode, "Transaction exit handlers", null);
    if (connector instanceof HtmlConnector) {
        for (Transaction transaction : transactions) {
            HtmlTransaction htmlTransaction = (HtmlTransaction) transaction;
            List<Statement> statements = htmlTransaction.getStatements();
            for (Statement statement : statements) {
                if (statement instanceof ScHandlerStatement) {
                    ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
                    if (scHandlerStatement.getNormalizedScreenClassName().equals(screenClassName)) {
                        if (scHandlerStatement.getName().endsWith("Entry")) {
                            entryFolder.addChild(new TransactionNode(entryFolder, transaction.getName(), scHandlerStatement));
                        } else {
                            exitFolder.addChild(new TransactionNode(exitFolder, transaction.getName(), scHandlerStatement));
                        }
                    }
                }
            }
        }
    } else if (connector instanceof JavelinConnector) {
        for (Transaction transaction : transactions) {
            JavelinTransaction javelinTransaction = (JavelinTransaction) transaction;
            if (javelinTransaction.handlers.indexOf("function on" + screenClassName + "Entry()") != -1) {
                entryFolder.addChild(new TransactionNode(entryFolder, transaction.getName(), transaction));
            }
            if (javelinTransaction.handlers.indexOf("function on" + screenClassName + "Exit()") != -1) {
                exitFolder.addChild(new TransactionNode(exitFolder, transaction.getName(), transaction));
            }
        }
    }
    if (entryFolder.hasChildren()) {
        isUsedByNode.addChild(entryFolder);
    }
    if (exitFolder.hasChildren()) {
        isUsedByNode.addChild(exitFolder);
    }
    if (!isUsedByNode.hasChildren()) {
        screenClassFolder.addChild(new InformationNode(screenClassFolder, "This screen class is not used in any transaction"));
    } else {
        screenClassFolder.addChild(isUsedByNode);
    }
    // Build the treeviewer model
    treeViewer.setInput(null);
    treeViewer.setInput(root);
    treeViewer.expandAll();
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) ProxyHttpConnector(com.twinsoft.convertigo.beans.connectors.ProxyHttpConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) RootNode(com.twinsoft.convertigo.eclipse.views.references.model.RootNode) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) EntryHandlerNode(com.twinsoft.convertigo.eclipse.views.references.model.EntryHandlerNode) ExitHandlerNode(com.twinsoft.convertigo.eclipse.views.references.model.ExitHandlerNode) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) ScreenClassNode(com.twinsoft.convertigo.eclipse.views.references.model.ScreenClassNode) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) IsUsedByNode(com.twinsoft.convertigo.eclipse.views.references.model.IsUsedByNode) TransactionNode(com.twinsoft.convertigo.eclipse.views.references.model.TransactionNode) InformationNode(com.twinsoft.convertigo.eclipse.views.references.model.InformationNode) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement)

Example 15 with Connector

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

the class ReferencesView method handleTransactionSelection.

private void handleTransactionSelection(Object firstElement) {
    TransactionTreeObject transactionTreeObject = (TransactionTreeObject) firstElement;
    Transaction transaction = transactionTreeObject.getObject();
    String transactionName = transactionTreeObject.getName();
    // Get the referencing sequence steps
    String transactionProjectName = transaction.getProject().getName();
    String transactionConnectorName = transaction.getParent().getName();
    try {
        Project project = null;
        List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
        ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
        treeViewer.setInput(null);
        RootNode root = new RootNode();
        TransactionNode transactionFolder = new TransactionNode(root, transactionName, transaction);
        root.addChild(transactionFolder);
        IsUsedByNode isUsedByNode = new IsUsedByNode(transactionFolder, "Is used by");
        RequiresNode requiresNode = new RequiresNode(transactionFolder, "Requires");
        ProjectNode projectFolder = null;
        // Searching all objects are required transaction selected
        Connector connector = transaction.getConnector();
        if (connector instanceof HtmlConnector) {
            Project proj = ((HtmlConnector) connector).getProject();
            ProjectNode projectNode = new ProjectNode(requiresNode, transactionProjectName, proj);
            HtmlTransaction htmlTransaction = (HtmlTransaction) transaction;
            List<Statement> statements = htmlTransaction.getStatements();
            List<ScreenClass> screenClassList = new ArrayList<ScreenClass>();
            List<String> siteClipperConnectorNames = new ArrayList<String>();
            for (Statement statement : statements) {
                if (statement instanceof ScHandlerStatement) {
                    ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
                    String screenClassName = scHandlerStatement.getNormalizedScreenClassName();
                    ScreenClass screenClass = ((HtmlConnector) connector).getScreenClassByName(screenClassName);
                    if (screenClass != null) {
                        if (!screenClassList.contains(screenClass)) {
                            screenClassList.add(screenClass);
                            requiresNode.addChild(new ScreenClassNode(requiresNode, screenClassName, screenClass));
                        }
                    }
                }
                List<Statement> statementList = ((FunctionStatement) statement).getStatements();
                for (Statement st : statementList) {
                    if (st instanceof ContinueWithSiteClipperStatement) {
                        ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
                        String siteClipperconnectorName = continueWithSiteClipperStatement.getSiteClipperConnectorName();
                        if (!siteClipperConnectorNames.contains(siteClipperconnectorName)) {
                            siteClipperConnectorNames.add(siteClipperconnectorName);
                            Connector siteClipperConnector = proj.getConnectorByName(siteClipperconnectorName);
                            ConnectorNode connectorSiteClipperNode = new SiteClipperConnectorNode(projectNode, siteClipperconnectorName, siteClipperConnector);
                            projectNode.addChild(connectorSiteClipperNode);
                        }
                    }
                }
            }
            if (projectNode.hasChildren()) {
                requiresNode.addChild(projectNode);
            }
        } else if (connector instanceof JavelinConnector) {
            JavelinTransaction javelinTransaction = (JavelinTransaction) transaction;
            String handlers = javelinTransaction.handlers;
            List<JavelinScreenClass> screenClasses = ((JavelinConnector) connector).getAllScreenClasses();
            List<JavelinScreenClass> screenClassList = new ArrayList<JavelinScreenClass>();
            for (JavelinScreenClass screenClass : screenClasses) {
                if (handlers.indexOf("function on" + screenClass.getName()) != -1) {
                    if (!screenClassList.contains(screenClass)) {
                        screenClassList.add(screenClass);
                        requiresNode.addChild(new ScreenClassNode(requiresNode, screenClass.getName(), screenClass));
                    }
                }
            }
        }
        // Searching all objects are used transaction selected
        for (String projectName : projectNames) {
            project = getProject(projectName, projectExplorerView);
            if (project != null) {
                projectFolder = new ProjectNode(isUsedByNode, project.getName(), project);
                UrlMapper urlMapper = project.getUrlMapper();
                if (urlMapper != null) {
                    MapperNode mapperNode = new MapperNode(projectFolder, urlMapper.getName(), urlMapper);
                    List<UrlMapping> mappings = urlMapper.getMappingList();
                    for (UrlMapping mapping : mappings) {
                        MappingPathNode pathNode = new MappingPathNode(mapperNode, mapping.getPath(), mapping);
                        List<UrlMappingOperation> operations = mapping.getOperationList();
                        for (UrlMappingOperation operation : operations) {
                            String targetRequestable = operation.getTargetRequestable();
                            if (targetRequestable.equals(transactionProjectName + "." + transactionConnectorName + "." + transactionName)) {
                                MappingOperationNode operationNode = new MappingOperationNode(pathNode, operation.getName(), operation);
                                pathNode.addChild(operationNode);
                            }
                        }
                        if (pathNode.hasChildren()) {
                            mapperNode.addChild(pathNode);
                        }
                    }
                    if (mapperNode.hasChildren()) {
                        projectFolder.addChild(mapperNode);
                    }
                }
                List<Sequence> sequences = project.getSequencesList();
                for (Sequence sequence : sequences) {
                    List<Step> stepList = sequence.getAllSteps();
                    SequenceNode sequenceNode = new SequenceNode(projectFolder, sequence.getName(), sequence);
                    for (Step step : stepList) {
                        getTransactionReferencing(step, projectExplorerView, sequenceNode, transactionProjectName, transactionConnectorName, transactionName);
                    }
                    if (sequenceNode.hasChildren()) {
                        projectFolder.addChild(sequenceNode);
                    }
                }
                if (projectFolder.hasChildren()) {
                    isUsedByNode.addChild(projectFolder);
                }
            }
        }
        if (requiresNode.hasChildren()) {
            transactionFolder.addChild(requiresNode);
        }
        if (isUsedByNode.hasChildren()) {
            transactionFolder.addChild(isUsedByNode);
        }
        if (!transactionFolder.hasChildren()) {
            transactionFolder.addChild(new InformationNode(projectFolder, "This transaction is not used in any sequence"));
        }
        treeViewer.setInput(root);
        treeViewer.expandAll();
    } catch (EngineException e) {
        ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
    }
}
Also used : UrlMapping(com.twinsoft.convertigo.beans.core.UrlMapping) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) RootNode(com.twinsoft.convertigo.eclipse.views.references.model.RootNode) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) ProxyHttpConnector(com.twinsoft.convertigo.beans.connectors.ProxyHttpConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) MapperNode(com.twinsoft.convertigo.eclipse.views.references.model.MapperNode) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) ArrayList(java.util.ArrayList) EngineException(com.twinsoft.convertigo.engine.EngineException) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) BranchStep(com.twinsoft.convertigo.beans.steps.BranchStep) XMLComplexStep(com.twinsoft.convertigo.beans.steps.XMLComplexStep) BlockStep(com.twinsoft.convertigo.beans.steps.BlockStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) ScreenClassNode(com.twinsoft.convertigo.eclipse.views.references.model.ScreenClassNode) InformationNode(com.twinsoft.convertigo.eclipse.views.references.model.InformationNode) List(java.util.List) ArrayList(java.util.ArrayList) SiteClipperConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.SiteClipperConnectorNode) UrlMapper(com.twinsoft.convertigo.beans.core.UrlMapper) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) MappingOperationNode(com.twinsoft.convertigo.eclipse.views.references.model.MappingOperationNode) Sequence(com.twinsoft.convertigo.beans.core.Sequence) ConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.ConnectorNode) SiteClipperConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.SiteClipperConnectorNode) HtmlConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.HtmlConnectorNode) JavelinConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.JavelinConnectorNode) CicsConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.CicsConnectorNode) SqlConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.SqlConnectorNode) ProxyHttpConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.ProxyHttpConnectorNode) HttpConnectorNode(com.twinsoft.convertigo.eclipse.views.references.model.HttpConnectorNode) SequenceNode(com.twinsoft.convertigo.eclipse.views.references.model.SequenceNode) Project(com.twinsoft.convertigo.beans.core.Project) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) MappingPathNode(com.twinsoft.convertigo.eclipse.views.references.model.MappingPathNode) TransactionNode(com.twinsoft.convertigo.eclipse.views.references.model.TransactionNode) IsUsedByNode(com.twinsoft.convertigo.eclipse.views.references.model.IsUsedByNode) RequiresNode(com.twinsoft.convertigo.eclipse.views.references.model.RequiresNode) ProjectNode(com.twinsoft.convertigo.eclipse.views.references.model.ProjectNode) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement)

Aggregations

Connector (com.twinsoft.convertigo.beans.core.Connector)72 Transaction (com.twinsoft.convertigo.beans.core.Transaction)43 Project (com.twinsoft.convertigo.beans.core.Project)32 EngineException (com.twinsoft.convertigo.engine.EngineException)28 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)22 Sequence (com.twinsoft.convertigo.beans.core.Sequence)21 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)17 Step (com.twinsoft.convertigo.beans.core.Step)17 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)16 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)15 SiteClipperConnector (com.twinsoft.convertigo.beans.connectors.SiteClipperConnector)14 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)14 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)14 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)12 CouchDbConnector (com.twinsoft.convertigo.beans.connectors.CouchDbConnector)11 SqlConnector (com.twinsoft.convertigo.beans.connectors.SqlConnector)11 Statement (com.twinsoft.convertigo.beans.core.Statement)11 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)11 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)11 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)11