Search in sources :

Example 1 with SiteClipperConnector

use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector 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 SiteClipperConnector

use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.

the class StatementTreeObject method handlesBeanNameChanged.

protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
    DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
    DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
    Object oldValue = treeObjectEvent.oldValue;
    Object newValue = treeObjectEvent.newValue;
    Statement statement = getObject();
    boolean change = false;
    if (databaseObject instanceof ScreenClass) {
        String oldScreenClassName = StringUtils.normalize((String) oldValue);
        String newScreenClassName = StringUtils.normalize((String) newValue);
        // ScreenClass and Statement must have the same connector!
        if (statement.getConnector().equals(databaseObject.getConnector())) {
            // Modify screenclass handlers name
            if (statement instanceof ScHandlerStatement) {
                ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
                if (scHandlerStatement.getNormalizedScreenClassName().equals(oldScreenClassName)) {
                    String handlerType = scHandlerStatement.getHandlerType();
                    String beanName = "on" + newScreenClassName + handlerType;
                    try {
                        scHandlerStatement.setName(beanName);
                        scHandlerStatement.setNormalizedScreenClassName(newScreenClassName);
                        change = true;
                    } catch (EngineException e) {
                        ConvertigoPlugin.logWarning(e, "Could not rename ScHandlerStatement from \"" + scHandlerStatement.getName() + "\" to \"" + beanName + "\" !");
                    }
                }
            }
            if (statement instanceof ITriggerOwner) {
                ITriggerOwner ito = (ITriggerOwner) statement;
                AbstractTrigger atrigger = ito.getTrigger().getTrigger();
                if (atrigger instanceof ScreenClassTrigger) {
                    ScreenClassTrigger sct = (ScreenClassTrigger) atrigger;
                    List<String> screenClasses = sct.getScreenClasses();
                    for (int i = 0; i < screenClasses.size(); i++) if (screenClasses.get(i).equals(oldScreenClassName) && (change = true))
                        screenClasses.set(i, newScreenClassName);
                    if (change)
                        ito.setTrigger(new TriggerXMLizer(sct));
                }
            }
        }
    } else // Case of connector rename
    if (databaseObject instanceof SiteClipperConnector) {
        if (statement instanceof ContinueWithSiteClipperStatement) {
            boolean isLocalProject = statement.getProject().equals(databaseObject.getProject());
            boolean isSameValue = ((ContinueWithSiteClipperStatement) statement).getSiteClipperConnectorName().equals(oldValue);
            if (isSameValue && isLocalProject) {
                ((ContinueWithSiteClipperStatement) statement).setSiteClipperConnectorName((String) newValue);
                hasBeenModified(true);
                viewer.refresh();
                // refresh editors (e.g labels in combobox)
                getDescriptors();
            }
        }
    }
    if (statement instanceof CallFunctionStatement && databaseObject.getClass().equals(FunctionStatement.class) && ((FunctionStatement) databaseObject).getParentTransaction().equals(statement.getParentTransaction())) {
        CallFunctionStatement callfunction = (CallFunctionStatement) statement;
        if (callfunction.getFunctionName().equals(oldValue) && (change = true))
            callfunction.setFunctionName(newValue.toString());
    }
    if (change)
        try {
            hasBeenModified(true);
            ConvertigoPlugin.getDefault().getProjectExplorerView().refreshTreeObject(this);
        } catch (Exception e) {
            ConvertigoPlugin.logWarning(e, "Could not refresh in tree ScHandlerStatement \"" + statement.getName() + "\" !");
        }
}
Also used : TriggerXMLizer(com.twinsoft.convertigo.engine.parsers.triggers.TriggerXMLizer) ScreenClassTrigger(com.twinsoft.convertigo.engine.parsers.triggers.ScreenClassTrigger) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) CallFunctionStatement(com.twinsoft.convertigo.beans.statements.CallFunctionStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) SimpleStatement(com.twinsoft.convertigo.beans.statements.SimpleStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) EngineException(com.twinsoft.convertigo.engine.EngineException) ITriggerOwner(com.twinsoft.convertigo.engine.parsers.triggers.ITriggerOwner) PartInitException(org.eclipse.ui.PartInitException) EngineException(com.twinsoft.convertigo.engine.EngineException) CallFunctionStatement(com.twinsoft.convertigo.beans.statements.CallFunctionStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) CallFunctionStatement(com.twinsoft.convertigo.beans.statements.CallFunctionStatement) AbstractTrigger(com.twinsoft.convertigo.engine.parsers.triggers.AbstractTrigger) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement)

Example 3 with SiteClipperConnector

use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.

the class DboUtils method getTechnology.

public static String getTechnology(DatabaseObject parentObject, Class<? extends DatabaseObject> objectClass) {
    String technology = null;
    DatabaseObject parent = parentObject;
    if (parent != null) {
        // case of Variable
        if (Variable.class.isAssignableFrom(objectClass)) {
            return technology = parent.getClass().getName();
        }
        // parent is a connector
        if (parent instanceof Connector) {
            return technology = ((Connector) parent).getClass().getName();
        }
        // parent is a sequence
        if (parent instanceof Sequence) {
            return technology = ((Sequence) parent).getClass().getName();
        }
        // parent is a statement
        if (parent instanceof Statement) {
            return technology = "com.twinsoft.convertigo.beans.statements.BlockStatement";
        }
        // parent is a step
        if (parent instanceof Step) {
            technology = "com.twinsoft.convertigo.beans.steps.BlockStep";
            if (getClassName(parent.getClass()).startsWith("XML")) {
                technology = parent.getClass().getName();
            }
            return technology;
        }
        // parent is a transaction
        if (parent instanceof Transaction) {
            if (parent instanceof HtmlTransaction) {
                return technology = "com.twinsoft.convertigo.beans.transactions.HtmlTransaction";
            } else if (parent instanceof SiteClipperTransaction) {
                return technology = "com.twinsoft.convertigo.beans.transactions.SiteClipperTransaction";
            }
        }
        // parent is a screenclass
        if (parent instanceof ScreenClass) {
            while ((parent = parent.getParent()) instanceof ScreenClass) {
                ;
            }
            if (parent instanceof JavelinConnector)
                technology = ((JavelinConnector) parent).getEmulatorTechnology();
            if (parent instanceof HtmlConnector)
                technology = "com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass";
            if (parent instanceof SiteClipperConnector)
                technology = "com.twinsoft.convertigo.beans.screenclasses.SiteClipperScreenClass";
        }
    }
    return technology;
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) Statement(com.twinsoft.convertigo.beans.core.Statement) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) SiteClipperTransaction(com.twinsoft.convertigo.beans.transactions.SiteClipperTransaction) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Step(com.twinsoft.convertigo.beans.core.Step) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) Transaction(com.twinsoft.convertigo.beans.core.Transaction) SiteClipperTransaction(com.twinsoft.convertigo.beans.transactions.SiteClipperTransaction) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Example 4 with SiteClipperConnector

use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.

the class Biller method insertCariocaBilling.

public void insertCariocaBilling(Context context, Object data) throws EngineException {
    String sSqlRequest = null;
    try {
        Engine.logBillers.debug("[Biller] Trying to insert the billing into a Carioca database ");
        sqlRequester.checkConnection();
        int cache = 0;
        double cost = getCost(context, data);
        if (cost == -1) {
            Engine.logBillers.debug("[Biller] Billing aborted because the returned cost is -1, i.e. do not need to bill.");
            return;
        } else if (cost == -2) {
            Engine.logBillers.debug("[Biller] Billing zero cost because the response was in cache.");
            cost = 0;
            cache = 1;
        }
        Connector connector = context.getConnector();
        CertificateManager certificateManager = null;
        if (connector instanceof HttpConnector) {
            certificateManager = ((HttpConnector) connector).certificateManager;
        } else if (connector instanceof SiteClipperConnector) {
            certificateManager = ((SiteClipperConnector) connector).certificateManager;
        }
        if (!certificateManager.storeInformationCollected) {
            certificateManager.collectStoreInformation(context);
        }
        String certificate = new File(certificateManager.keyStore).getName();
        int idx = certificate.indexOf('.');
        if (idx != -1) {
            certificate = certificate.substring(0, idx);
        }
        Statement statement = null;
        long startBilling = System.currentTimeMillis();
        try {
            Engine.logBillers.debug("[Biller] Replacements from the context done");
            StringEx sqlRequest = new StringEx(sqlRequester.getProperty(Biller.PROPERTIES_SQL_REQUEST_INSERT_BILLING));
            try {
                Engine.logBillers.debug("[Biller] Replacing TAS IDs");
                sqlRequest.replace("{IDSVR}", context.get("IDSVR").toString());
                sqlRequest.replace("{IDSERV}", context.get("IDSERV").toString());
                sqlRequest.replace("{IDUSER}", context.get("IDUSER").toString());
                sqlRequest.replace("{IDPROF}", context.get("IDPROF").toString());
                sqlRequest.replace("{IDEMUL}", context.get("IDEMUL").toString());
                Engine.logBillers.debug("[Biller] Replacing TAS variables");
                sqlRequest.replaceSQL("{NomSv}", context.tasVirtualServerName, '\'');
                sqlRequest.replaceSQL("{UserName}", context.tasUserName, '\'');
                sqlRequest.replaceSQL("{UserGroup}", context.tasUserGroup, '\'');
                sqlRequest.replaceSQL("{Service}", getService(context, data), '\'');
                Engine.logBillers.debug("[Biller] Replacing POBI variables");
                sqlRequest.replace("{cdbanque}", context.get("cdbanque").toString());
                sqlRequest.replace("{cdguichet}", context.get("cdguichet").toString());
                sqlRequest.replaceSQL("{certificat}", certificate, '\'');
                sqlRequest.replace("{cache}", Integer.toString(cache));
                sqlRequest.replaceSQL("{module}", getModule(context, data), '\'');
                sqlRequest.replaceSQL("{userdata}", context.get("userdata").toString(), '\'');
                sqlRequest.replaceSQL("{BDFKey}", getDataKey(context, data), '\'');
                sqlRequest.replaceSQL("{UserGroupAuto}", context.get("UserGroupAuto").toString(), '\'');
            } catch (NullPointerException e) {
                throw new EngineException("One parameter for SQL replacement is missing.", e);
            }
            Calendar rightNow = Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat(sqlRequester.getProperty(Biller.PROPERTIES_SQL_DATE_FORMAT));
            String date = df.format(rightNow.getTime());
            sqlRequest.replace("{StartHour}", date);
            sqlRequest.replace("{EndHour}", date);
            Engine.logBillers.debug("[Biller] Start and End hour computed");
            sqlRequest.replace("{Cost}", Double.toString(cost));
            Engine.logBillers.debug("[Biller] Cost computed");
            sSqlRequest = sqlRequest.toString();
            Engine.logBillers.debug("[Biller] SQL: " + sSqlRequest);
            statement = sqlRequester.connection.createStatement();
            int nResult = statement.executeUpdate(sSqlRequest);
            Engine.logBillers.debug("[Biller] " + nResult + " row(s) inserted.");
        } finally {
            if (statement != null) {
                statement.close();
            }
            Engine.logBillers.info("[Biller] insertCariocaBilling, 1 request in " + (System.currentTimeMillis() - startBilling) + " ms");
        }
    } catch (SQLException e) {
        Engine.logBillers.warn("[Biller] Unable to insert the billing.\n" + e.getMessage() + " (error code: " + e.getErrorCode() + ")\nSQL: " + sSqlRequest);
    } catch (Exception e) {
        Engine.logBillers.error("[Biller] Unable to insert the billing", e);
    }
}
Also used : SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Calendar(java.util.Calendar) IOException(java.io.IOException) SQLException(java.sql.SQLException) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) StringEx(com.twinsoft.util.StringEx) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with SiteClipperConnector

use of com.twinsoft.convertigo.beans.connectors.SiteClipperConnector in project convertigo by convertigo.

the class Get method createCategories.

private void createCategories(Document document, DatabaseObject dbo, Class<? extends DatabaseObject> databaseObjectClass, Element root) throws Exception {
    Element response = document.createElement("response");
    try {
        List<String> defaultDboList = new ArrayList<>();
        Class<? extends DatabaseObject> parentObjectClass = dbo.getClass();
        Map<String, DboCategoryData> categoryNameToDboCategory = new HashMap<>();
        DboExplorerManager manager = Engine.theApp.getDboExplorerManager();
        for (DboGroup group : manager.getGroups()) {
            for (DboCategory category : group.getCategories()) {
                for (DboBeans beansCategory : category.getBeans()) {
                    for (DboBean bean : beansCategory.getBeans()) {
                        // Skip if bean is disabled
                        if (!bean.isEnable()) {
                            continue;
                        }
                        String className = bean.getClassName();
                        try {
                            Class<DatabaseObject> beanClass = GenericUtils.cast(Class.forName(className));
                            DboCategoryInfo dboCategoryInfo = DatabaseObject.getDboGroupInfo(beanClass);
                            if (dboCategoryInfo == null) {
                                continue;
                            }
                            // If one of these cases, do not add the category
                            if (dbo instanceof ScreenClass) {
                                ScreenClass sc = (ScreenClass) dbo;
                                // Do not show Criteria category if it is the default Screen Class
                                if (sc.getDepth() == 0 && dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Criteria.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof CicsConnector) {
                                // Do not show Pool category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof JavelinConnector) {
                                // Do not show ScreenClass category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof SqlConnector) {
                                // Do not show Pool category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof HtmlConnector) {
                                // Do not show Pool and ScreenClass categories
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class)) || dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof HttpConnector) {
                                // Do not show Pool category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof SiteClipperConnector) {
                                // Do not show Pool and ScreenClass categories
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Pool.class)) || dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(ScreenClass.class))) {
                                    continue;
                                }
                            } else if (dbo instanceof Transaction) {
                                // Do not show Statement category
                                if (dboCategoryInfo.equals(DatabaseObject.getDboGroupInfo(Statement.class))) {
                                    continue;
                                }
                            }
                            if (bean.isDefault()) {
                                defaultDboList.add(className);
                            }
                            // The bean should derived from
                            // DatabaseObject...
                            boolean isDatabaseObject = (DatabaseObject.class.isAssignableFrom(beanClass));
                            if (isDatabaseObject) {
                                // ... and should derived from the specified class
                                boolean isFromSpecifiedClass = (databaseObjectClass == null || (databaseObjectClass != null && databaseObjectClass.isAssignableFrom(beanClass)));
                                if (isFromSpecifiedClass) {
                                    // Check parent
                                    boolean bFound = DatabaseObjectsManager.checkParent(parentObjectClass, bean);
                                    if (bFound) {
                                        String technology = DboUtils.getTechnology(dbo, beanClass);
                                        // Check technology if needed
                                        if (technology != null) {
                                            Collection<String> acceptedTechnologies = bean.getEmulatorTechnologies();
                                            if (!acceptedTechnologies.isEmpty() && !acceptedTechnologies.contains(technology)) {
                                                continue;
                                            }
                                        }
                                        String beanInfoClassName = className + "BeanInfo";
                                        Class<BeanInfo> beanInfoClass = GenericUtils.cast(Class.forName(beanInfoClassName));
                                        if (beanInfoClass != null) {
                                            String categoryName = dboCategoryInfo.getCategoryName();
                                            // Create category
                                            DboCategoryData dboCategoryData = categoryNameToDboCategory.get(categoryName);
                                            if (dboCategoryData == null) {
                                                dboCategoryData = new DboCategoryData(dboCategoryInfo.getCategoryId(), categoryName, dboCategoryInfo.getIconClassCSS());
                                                categoryNameToDboCategory.put(categoryName, dboCategoryData);
                                            }
                                            // Beans name
                                            String beansName = beansCategory.getName();
                                            if (beansName.length() == 0) {
                                                beansName = categoryName;
                                            }
                                            // Create beans
                                            DboBeansData dboBeansData = dboCategoryData.getDboBeans(beansName);
                                            if (dboBeansData == null) {
                                                dboBeansData = new DboBeansData(beansName);
                                                dboCategoryData.addDboBeans(beansName, dboBeansData);
                                            }
                                            // Create bean
                                            DboBeanData dboBeanData = new DboBeanData(beanInfoClass.getConstructor().newInstance());
                                            dboBeansData.addDboBean(dboBeanData);
                                        } else {
                                            String message = java.text.MessageFormat.format("The \"{0}\" does not exist.", new Object[] { beanInfoClassName });
                                            throw new Exception(message);
                                        }
                                    }
                                }
                            } else {
                                String message = java.text.MessageFormat.format("The \"{0}\" class is not a Convertigo database object.", new Object[] { className });
                                throw new Exception(message);
                            }
                        } catch (ClassNotFoundException e) {
                            String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" class.\n\nClass not found: {1}", new Object[] { className, e.getMessage() });
                            throw new Exception(message);
                        } catch (Throwable e) {
                            String message = java.text.MessageFormat.format("Unable to analyze the \"{0}\" Convertigo database object.", new Object[] { className });
                            throw new Exception(message);
                        }
                    }
                }
            }
        }
        // Find the default selected bean for each categories
        for (DboCategoryData dboCategory : categoryNameToDboCategory.values()) {
            boolean defaultDboFound = false;
            List<DboBeanData> dboBeansList = dboCategory.getAllDboBean(true);
            // By default, we chose the first bean as default selected bean
            DboBeanData defaultSelectedBean = dboBeansList.get(0);
            // Find the default selected bean
            for (int i = 0; i < dboBeansList.size() && !defaultDboFound; ++i) {
                Class<DatabaseObject> beanClass = dboBeansList.get(i).getBeanClass();
                // Another bean is set as default selected bean
                if (defaultDboFound = defaultDboList.contains(beanClass.getName())) {
                    defaultSelectedBean = dboBeansList.get(i);
                }
            }
            defaultSelectedBean.setSelectedByDefault(true);
        }
        // XmlLize
        for (DboCategoryData dboCategory : categoryNameToDboCategory.values()) {
            response.appendChild(dboCategory.toXml(document));
        }
    } catch (Exception e) {
        throw new Exception("Unable to load database objects properties.");
    }
    root.appendChild(response);
}
Also used : HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) HashMap(java.util.HashMap) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) Element(org.w3c.dom.Element) BeanInfo(java.beans.BeanInfo) ArrayList(java.util.ArrayList) DboCategory(com.twinsoft.convertigo.engine.dbo_explorer.DboCategory) DboBeansData(com.twinsoft.convertigo.beans.dbo_explorer.DboBeansData) DboBeanData(com.twinsoft.convertigo.beans.dbo_explorer.DboBeanData) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) DboCategoryInfo(com.twinsoft.convertigo.beans.core.DatabaseObject.DboCategoryInfo) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) DboCategoryData(com.twinsoft.convertigo.beans.dbo_explorer.DboCategoryData) DboGroup(com.twinsoft.convertigo.engine.dbo_explorer.DboGroup) DboExplorerManager(com.twinsoft.convertigo.engine.dbo_explorer.DboExplorerManager) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DboBeans(com.twinsoft.convertigo.engine.dbo_explorer.DboBeans) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Transaction(com.twinsoft.convertigo.beans.core.Transaction) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DboBean(com.twinsoft.convertigo.engine.dbo_explorer.DboBean)

Aggregations

SiteClipperConnector (com.twinsoft.convertigo.beans.connectors.SiteClipperConnector)11 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)7 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)7 Connector (com.twinsoft.convertigo.beans.core.Connector)7 CicsConnector (com.twinsoft.convertigo.beans.connectors.CicsConnector)6 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)6 SqlConnector (com.twinsoft.convertigo.beans.connectors.SqlConnector)6 EngineException (com.twinsoft.convertigo.engine.EngineException)6 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)5 Statement (com.twinsoft.convertigo.beans.core.Statement)5 Transaction (com.twinsoft.convertigo.beans.core.Transaction)5 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)5 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)4 Sequence (com.twinsoft.convertigo.beans.core.Sequence)4 Step (com.twinsoft.convertigo.beans.core.Step)4 ArrayList (java.util.ArrayList)4 Project (com.twinsoft.convertigo.beans.core.Project)3 JavelinScreenClass (com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass)3 JavelinTransaction (com.twinsoft.convertigo.beans.transactions.JavelinTransaction)3 ProxyHttpConnector (com.twinsoft.convertigo.beans.connectors.ProxyHttpConnector)2