Search in sources :

Example 1 with JavelinTransaction

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

Example 2 with JavelinTransaction

use of com.twinsoft.convertigo.beans.transactions.JavelinTransaction 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 3 with JavelinTransaction

use of com.twinsoft.convertigo.beans.transactions.JavelinTransaction in project convertigo by convertigo.

the class JavelinConnector method prepareForTransaction.

@Override
public void prepareForTransaction(Context context) throws EngineException {
    String t = context.statistics.start(EngineStatistics.GET_JAVELIN_OBJECT);
    try {
        // Quick and dirty workaround for ticket #1280
        if (!checkKeys())
            throw new EngineException("No more key available; check your license keys!");
        // if something append during transaction execution
        com.twinsoft.api.Session session = Engine.theApp.sessionManager.getSession(context.contextID);
        if (session != null)
            session.resetSomethingChange();
        if (Engine.isStudioMode()) {
            if (javelin != null) {
                Engine.logBeans.debug("(JavelinConnector) Using the studio Javelin object");
                return;
            }
            throw new EngineException("Studio mode: the Legacy connector must be open in order to execute transactions");
        }
        Engine.logBeans.debug("(JavelinConnector) Retrieving the Javelin object");
        JavelinTransaction javelinTransaction = null;
        try {
            javelinTransaction = (JavelinTransaction) context.requestedObject;
        } catch (ClassCastException e) {
            throw new EngineException("Requested object is not a transaction", e);
        }
        int timeout = javelinTransaction.getTimeoutForDataStable();
        int threshold = javelinTransaction.getDataStableThreshold();
        Authentication auth = null;
        if (context.isRequestFromVic) {
            // instance, from a web service call).
            if (!context.isTrustedRequest) {
                try {
                    VicApi vicApi = new VicApi();
                    if (!vicApi.isServiceAuthorized(context.tasUserName, context.tasVirtualServerName, context.tasServiceCode)) {
                        throw new EngineException("The service '" + context.tasServiceCode + "' is not authorized for the user '" + context.tasUserName);
                    }
                } catch (IOException e) {
                    throw new EngineException("Unable to retrieve authorization from the VIC database.", e);
                }
            }
        } else {
            // Check the Carioca authorizations only if this is a non trusted request
            if (context.isTrustedRequest) {
            // Nothing to do: all the tas* variables from the context must have been set
            // by the caller.
            // Means we must not execute the TAS API.
            } else {
                // Getting Authentication object
                context.tasVirtualServerName = getVirtualServer();
                try {
                    String authName = (context.tasSessionKey == null ? context.tasUserName : context.tasSessionKey);
                    auth = Engine.theApp.getAuthenticationObject(context.tasVirtualServerName, authName);
                    // Logging to Carioca only if needed
                    User user = auth.getCurrentUser();
                    if (user == null) {
                        // Request from Carioca
                        if (context.tasSessionKey != null) {
                            auth.login(context.tasSessionKey);
                            User currentUser = auth.getCurrentUser();
                            context.tasUserName = currentUser.getName();
                            context.tasUserPassword = currentUser.getPassword();
                            context.tasVirtualServerName = "(SV #" + currentUser.getServerID() + ")";
                            String message = "Authentication to Carioca with sesskey = '" + context.tasSessionKey + "' => user: \"" + context.tasUserName + "\"";
                            Engine.logBeans.debug("(JavelinConnector) " + message);
                        } else // Specific user
                        if ((context.tasUserName != null) && (context.tasUserPassword != null)) {
                            auth.login(context.tasUserName, context.tasUserPassword);
                            String message = "Authentication to Carioca with user = '" + context.tasUserName + "' and password = '" + context.tasUserPassword + "'";
                            Engine.logBeans.debug("(JavelinConnector) " + message);
                        } else {
                            context.tasUserName = EnginePropertiesManager.getProperty(PropertyName.CARIOCA_DEFAULT_USER_NAME);
                            context.tasUserPassword = EnginePropertiesManager.getProperty(PropertyName.CARIOCA_DEFAULT_USER_PASSWORD);
                            auth.login(context.tasUserName, context.tasUserPassword);
                            String message = "Default authentication to Carioca";
                            Engine.logBeans.debug("(JavelinConnector) " + message);
                        }
                    } else {
                        context.tasUserName = user.getName();
                        context.tasUserPassword = user.getPassword();
                        context.tasUserGroup = user.getMainGroupName();
                        context.tasVirtualServerName = "(#" + Long.toString(user.getServerID()) + ")";
                        String message = "Already authenticated to Carioca with user = '" + context.tasUserName + "' and password = '" + context.tasUserPassword + "'";
                        Engine.logBeans.debug("(JavelinConnector) " + message);
                    }
                } catch (Exception e) {
                    auth = null;
                    String message = "Unable to authenticate to Carioca.\n" + "Carioca virtual server: " + context.tasVirtualServerName + "\n" + "SessKey: \"" + context.tasSessionKey + "\"\n" + "User: \"" + context.tasUserName + "\"\n" + "Password: \"" + context.tasUserPassword + "\"";
                    EngineException ee = new EngineException(message, e);
                    throw ee;
                }
            }
        }
        // We retrieve the current project
        String javelinServiceCode = context.tasServiceCode;
        if (javelinServiceCode == null) {
            javelinServiceCode = getServiceCode();
            Engine.logBeans.debug("(JavelinConnector)  No service code provided; getting the connector service code.");
        }
        // Analyzes/overrrides service code for device number pooling
        javelinServiceCode = analyzeServiceCode(javelinServiceCode);
        Engine.logBeans.debug("(JavelinConnector) Service code: " + javelinServiceCode);
        session = Engine.theApp.sessionManager.getSession(context.contextID);
        if (session == null) {
            Engine.logBeans.debug("(JavelinConnector) No session has been found; creation of a new one and ignoring the user request.");
            context.inputDocument = null;
            try {
                if (context.isRequestFromVic) {
                    session = Engine.theApp.sessionManager.addVicSession(javelinServiceCode, context.tasUserName, context.tasUserGroup + "@" + context.tasVirtualServerName, context.tasDteAddress, context.tasCommDevice, context.contextID);
                } else if (context.isTrustedRequest) {
                    String connectionParameters = getServiceCode();
                    try {
                        StringTokenizer st = new StringTokenizer(connectionParameters, ",");
                        String appType = st.nextToken();
                        if (appType.equals("vic")) {
                            javelinServiceCode = st.nextToken();
                            context.tasDteAddress = st.nextToken();
                            context.tasCommDevice = st.nextToken();
                            Engine.logBeans.debug("(JavelinConnector) Trusted request => the connector handles connection parameters : " + connectionParameters);
                            Engine.logBeans.debug("(JavelinConnector) serviceCode: " + javelinServiceCode);
                            Engine.logBeans.debug("(JavelinConnector) dteAddress: " + context.tasDteAddress);
                            Engine.logBeans.debug("(JavelinConnector) commDevice: " + context.tasCommDevice);
                            Engine.logBeans.debug("(JavelinConnector) user: " + context.tasUserName);
                            String group = context.tasUserGroup + "@" + context.tasVirtualServerName;
                            Engine.logBeans.debug("(JavelinConnector) group: " + group);
                            session = Engine.theApp.sessionManager.addVicSession(javelinServiceCode, context.tasUserName, group, context.tasDteAddress, context.tasCommDevice, context.contextID);
                        }
                    } catch (NoSuchElementException e) {
                        Engine.logBeans.error("(JavelinConnector) Invalid connector connection parameters: " + connectionParameters);
                    }
                } else {
                    session = Engine.theApp.sessionManager.addSession((int) emulatorID, auth, javelinServiceCode, context.contextID, getJavelinLanguage(), isSslEnabled(), isSslTrustAllServerCertificates(), getIbmTerminalType());
                }
            } catch (Exception e) {
                String message = "Unable to open the Javelin session: serviceCode= '" + javelinServiceCode + "', contextID = '" + context.contextID + "'";
                EngineException ee = new EngineException(message, e);
                throw ee;
            }
            if (session == null) {
                String message = "Unable to add a new session: the access to the service '" + javelinServiceCode + "' has been forbidden by the Carioca administrator.";
                EngineException ee = new EngineException(message);
                throw ee;
            }
            javelin = session.getJavelinObject();
            javelin.setLog(new LogWrapper(Engine.logEmulators));
            javelin.setDataStableOnCursorOn(false);
            javelin.connect(javelinTransaction.getTimeoutForConnect());
            boolean isConnected = javelin.isConnected();
            Engine.logBeans.debug("(JavelinConnector) isConnected=" + isConnected);
            if (!isConnected) {
                throw new ConnectionException("Unable to connect the session! See the emulator logs for more details...");
            }
            executeConnectionSyncCode(javelin, timeout, threshold);
        } else {
            Engine.logBeans.debug("(JavelinConnector) Using the existing session");
            if (context.isNewSession) {
                Engine.logBeans.debug("(JavelinConnector) New session required and ignoring the user request");
                context.inputDocument = null;
                // First, we remove the previous session
                Engine.theApp.sessionManager.removeSession(context.contextID);
                try {
                    if (context.isRequestFromVic) {
                        session = Engine.theApp.sessionManager.addVicSession(javelinServiceCode, context.tasUserName, context.tasUserGroup, context.tasDteAddress, context.tasCommDevice, context.contextID);
                    } else {
                        session = Engine.theApp.sessionManager.addSession((int) emulatorID, auth, javelinServiceCode, context.contextID, getJavelinLanguage(), isSslEnabled(), isSslTrustAllServerCertificates(), getIbmTerminalType());
                    }
                } catch (Exception e) {
                    String message = "Unable to open the Javelin session: serviceCode= '" + javelinServiceCode + "', contextID = '" + context.contextID + "'";
                    Engine.logBeans.warn("(JavelinConnector) " + message);
                    EngineException ee = new EngineException(message, e);
                    throw ee;
                }
                if (session == null) {
                    String message = "Unable to add a new session: the access to the service '" + javelinServiceCode + "' has been forbidden by the Carioca administrator.";
                    Engine.logBeans.warn("(JavelinConnector) " + message);
                    EngineException ee = new EngineException(message);
                    throw ee;
                }
                javelin = session.getJavelinObject();
                javelin.setLog(new LogWrapper(Engine.logEmulators));
                javelin.setDataStableOnCursorOn(false);
                javelin.connect(javelinTransaction.getTimeoutForConnect());
                if (!javelin.isConnected()) {
                    throw new ConnectionException("Unable to connect the session! See the emulator logs for more details...");
                }
                executeConnectionSyncCode(javelin, timeout, threshold);
            } else {
                javelin = session.getJavelinObject();
                // Reconnect only if the requested transaction is not the end transaction
                if ((!context.isDestroying) && (!session.isConnected())) {
                    javelin.setDataStableOnCursorOn(false);
                    javelin.connect(javelinTransaction.getTimeoutForConnect());
                    if (!javelin.isConnected()) {
                        throw new ConnectionException("Unable to connect the session! See the emulator logs for more details...");
                    }
                    executeConnectionSyncCode(javelin, timeout, threshold);
                }
            }
        }
        context.isNewSession = false;
    } finally {
        context.statistics.stop(t);
    }
}
Also used : User(com.twinsoft.tas.User) EngineException(com.twinsoft.convertigo.engine.EngineException) FindString(com.twinsoft.convertigo.beans.common.FindString) IOException(java.io.IOException) LogWrapper(com.twinsoft.convertigo.engine.util.LogWrapper) RESyntaxException(org.apache.regexp.RESyntaxException) NoSuchElementException(java.util.NoSuchElementException) EvaluatorException(org.mozilla.javascript.EvaluatorException) JavaScriptException(org.mozilla.javascript.JavaScriptException) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) StringTokenizer(java.util.StringTokenizer) Authentication(com.twinsoft.tas.Authentication) VicApi(com.twinsoft.convertigo.engine.plugins.VicApi) NoSuchElementException(java.util.NoSuchElementException)

Example 4 with JavelinTransaction

use of com.twinsoft.convertigo.beans.transactions.JavelinTransaction in project convertigo by convertigo.

the class TransactionShowVariableAction 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();
            String variable = (String) ((VariableTreeObject) treeObject).getObject();
            JavelinTransaction transaction = (JavelinTransaction) treeObject.getParent().getParent().getObject();
            JavelinConnector javelinConnector = (JavelinConnector) transaction.getParent();
            IEditorPart wpart = getConnectorEditor(javelinConnector);
            if ((wpart != null) && (wpart instanceof ConnectorEditor)) {
                getActivePage().activate(wpart);
                ConnectorEditor connectorEditor = (ConnectorEditor) wpart;
                ConnectorEditorPart connectorEditorPart = connectorEditor.getConnectorEditorPart();
                AbstractConnectorComposite connectorComposite = connectorEditorPart.getConnectorComposite();
                if ((connectorComposite != null) && (connectorComposite instanceof JavelinConnectorComposite)) {
                    Javelin javelin = ((JavelinConnectorComposite) connectorComposite).getJavelin();
                    ScreenClass currentScreenClass = ((JavelinConnector) connectorEditorPart.getConnector()).getCurrentScreenClass();
                    String normalizedScreenClassName = StringUtils.normalize(currentScreenClass.getName());
                    int i;
                    String handlerName = "on" + normalizedScreenClassName + JavelinTransaction.EVENT_ENTRY_HANDLER;
                    if ((i = transaction.handlers.indexOf(handlerName)) == -1) {
                        display.beep();
                        ConvertigoPlugin.logWarning("Unable to show the position of the variable \"" + variable + "\": no handler found for the current screen class!");
                    } else {
                        ConvertigoPlugin.logDebug("Found handler: " + handlerName);
                        // Delimit the function
                        int bof, eof;
                        bof = transaction.handlers.indexOf('{', i) + 2;
                        eof = transaction.handlers.indexOf("function", bof);
                        if (eof == -1) {
                            eof = transaction.handlers.lastIndexOf('}') - 1;
                        } else {
                            eof = transaction.handlers.lastIndexOf('}', eof) - 1;
                        }
                        String function = transaction.handlers.substring(bof, eof);
                        // Delimit the marker for generated input variables code
                        int idxMarker = function.indexOf("\t// begin-of-variables");
                        if (idxMarker == -1) {
                            // No variable marker, do nothing
                            display.beep();
                            ConvertigoPlugin.logWarning("Unable to show the position of the variable \"" + variable + "\": no variable marker found for the handler!");
                            return;
                        }
                        int idxMarker2 = function.indexOf("\t// end-of-variables", idxMarker);
                        String code = function.substring(idxMarker, idxMarker2);
                        String line = "\tjavelin.send(" + variable + ");\n";
                        int idxPosition = code.indexOf(line);
                        if (idxPosition == -1) {
                            ConvertigoPlugin.logDebug("No variable '" + variable + "' found into the handler!");
                            return;
                        }
                        idxPosition = code.lastIndexOf("moveCursor(", idxPosition) + 11;
                        int idxComa = code.indexOf(',', idxPosition);
                        int idxClosedParenthesis = code.indexOf(')', idxComa);
                        int x = Integer.parseInt(code.substring(idxPosition, idxComa).trim());
                        int y = Integer.parseInt(code.substring(idxComa + 1, idxClosedParenthesis).trim());
                        ConvertigoPlugin.logDebug("Variable position found: " + x + ", " + y);
                        javelin.moveCursor(x, y);
                    }
                    javelin.requestFocus();
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to show variable to Javelin!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) AbstractConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.AbstractConnectorComposite) JavelinConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.JavelinConnectorComposite) Javelin(com.twinsoft.twinj.Javelin) IEditorPart(org.eclipse.ui.IEditorPart) Cursor(org.eclipse.swt.graphics.Cursor) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) ConnectorEditorPart(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorPart) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Shell(org.eclipse.swt.widgets.Shell) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) VariableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 5 with JavelinTransaction

use of com.twinsoft.convertigo.beans.transactions.JavelinTransaction in project convertigo by convertigo.

the class TransactionWriteVariableAction 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();
            String variable = (String) ((VariableTreeObject) treeObject).getObject();
            JavelinTransaction transaction = (JavelinTransaction) treeObject.getParent().getParent().getObject();
            JavelinConnector javelinConnector = (JavelinConnector) transaction.getParent();
            IEditorPart wpart = getConnectorEditor(javelinConnector);
            if ((wpart != null) && (wpart instanceof ConnectorEditor)) {
                getActivePage().activate(wpart);
                ConnectorEditor connectorEditor = (ConnectorEditor) wpart;
                ConnectorEditorPart connectorEditorPart = connectorEditor.getConnectorEditorPart();
                AbstractConnectorComposite connectorComposite = connectorEditorPart.getConnectorComposite();
                if ((connectorComposite != null) && (connectorComposite instanceof JavelinConnectorComposite)) {
                    Javelin javelin = ((JavelinConnectorComposite) connectorComposite).getJavelin();
                    ScreenClass currentScreenClass = ((JavelinConnector) connectorEditorPart.getConnector()).getCurrentScreenClass();
                    ConvertigoPlugin.logDebug("Analyzing screen class '" + currentScreenClass.getName() + "'...");
                    String normalizedScreenClassName = StringUtils.normalize(currentScreenClass.getName());
                    int i;
                    String handlerName = "on" + normalizedScreenClassName + JavelinTransaction.EVENT_ENTRY_HANDLER;
                    ConvertigoPlugin.logDebug("Handlers:\n" + transaction.handlers);
                    ConvertigoPlugin.logDebug("Searching for handler '" + handlerName + "'...");
                    if ((i = transaction.handlers.indexOf(handlerName)) == -1) {
                        display.beep();
                        ConvertigoPlugin.logDebug("No handler found for the current screen class!");
                    } else {
                        ConvertigoPlugin.logDebug("Handler found!");
                        // Delimit the function
                        int bof, eof;
                        bof = transaction.handlers.indexOf('{', i) + 1;
                        eof = transaction.handlers.indexOf("function", bof);
                        if (eof == -1) {
                            eof = transaction.handlers.lastIndexOf('}') - 1;
                        } else {
                            eof = transaction.handlers.lastIndexOf('}', eof) - 1;
                        }
                        String function = transaction.handlers.substring(bof, eof);
                        int c = javelin.getCurrentColumn();
                        int l = javelin.getCurrentLine();
                        String line1 = "\tjavelin.moveCursor(" + c + ", " + l + ");\n";
                        // We must remove the default value of the variable if any
                        String variableName = variable.toString();
                        int ii;
                        if ((ii = variableName.indexOf(' ')) != -1) {
                            variableName = variableName.substring(0, ii);
                        }
                        String line2 = "\tjavelin.send(" + variableName + ");\n";
                        // Delimit the marker for generated input variables code
                        String code = "";
                        int idxMarker = function.indexOf("\t// begin-of-variables");
                        if (idxMarker == -1) {
                            code = "\n\t// begin-of-variables: DO NOT EDIT OR MODIFY\n";
                            code += line1 + line2;
                            code += "\t// end-of-variables\n";
                            function = code + function;
                        } else {
                            idxMarker = function.indexOf("\t// end-of-variables");
                            // Update previous definition if any
                            int idxPreviousDefinition = function.indexOf(line2);
                            if (idxPreviousDefinition != -1) {
                                int i1 = function.lastIndexOf("moveCursor(", idxPreviousDefinition) + 11;
                                // Search for moveCursor only inside the variables block
                                if (i1 < idxMarker) {
                                    int i2 = function.indexOf(')', i1);
                                    function = function.substring(0, i1) + c + ", " + l + function.substring(i2);
                                }
                            } else // Add definition otherwise
                            {
                                code += line1 + line2;
                            }
                            function = function.substring(0, idxMarker) + code + function.substring(idxMarker);
                        }
                        transaction.handlers = transaction.handlers.substring(0, bof) + function + transaction.handlers.substring(eof);
                        transaction.hasChanged = true;
                        ConvertigoPlugin.logDebug("Code added:\n" + code);
                        explorerView.updateDatabaseObject(transaction);
                        // Update the opened handlers editor if any
                        JScriptEditorInput jsinput = ConvertigoPlugin.getDefault().getJScriptEditorInput(transaction);
                        if (jsinput != null) {
                            jsinput.reload();
                        }
                    }
                    javelin.requestFocus();
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to write variable from Javelin!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : JScriptEditorInput(com.twinsoft.convertigo.eclipse.editors.jscript.JScriptEditorInput) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) AbstractConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.AbstractConnectorComposite) JavelinConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.JavelinConnectorComposite) Javelin(com.twinsoft.twinj.Javelin) IEditorPart(org.eclipse.ui.IEditorPart) Cursor(org.eclipse.swt.graphics.Cursor) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) ConnectorEditorPart(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorPart) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Shell(org.eclipse.swt.widgets.Shell) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) VariableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject) Display(org.eclipse.swt.widgets.Display)

Aggregations

JavelinTransaction (com.twinsoft.convertigo.beans.transactions.JavelinTransaction)10 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)7 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)5 CicsConnector (com.twinsoft.convertigo.beans.connectors.CicsConnector)4 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)4 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)4 SiteClipperConnector (com.twinsoft.convertigo.beans.connectors.SiteClipperConnector)4 SqlConnector (com.twinsoft.convertigo.beans.connectors.SqlConnector)4 JavelinScreenClass (com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass)4 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)4 Connector (com.twinsoft.convertigo.beans.core.Connector)3 Statement (com.twinsoft.convertigo.beans.core.Statement)3 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)3 Javelin (com.twinsoft.twinj.Javelin)3 ProxyHttpConnector (com.twinsoft.convertigo.beans.connectors.ProxyHttpConnector)2 Sequence (com.twinsoft.convertigo.beans.core.Sequence)2 Step (com.twinsoft.convertigo.beans.core.Step)2 Transaction (com.twinsoft.convertigo.beans.core.Transaction)2 SiteClipperScreenClass (com.twinsoft.convertigo.beans.screenclasses.SiteClipperScreenClass)2 ContinueWithSiteClipperStatement (com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement)2